diff --git a/Gruntfile.js b/Gruntfile.js index 5282d4182..ec3a758cd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -139,100 +139,6 @@ module.exports = function (grunt) { demoCss: { src: ['demo/css/**/*.css'], dest: 'dist/demo.css' - }, - - bi_polyfillJs: { - src: ['src/polyfill/**/*.js'], - dest: 'bi/polyfill.js' - }, - - bi_coreJs: { - src: [ - 'src/core/jquery.js', - 'src/core/underscore.js', - 'src/core/foundation.js', - // 'src/core/mvc/**/*.js', - 'src/core/base.js', - 'src/core/ob.js', - 'src/core/widget.js', - // 'src/core/model.js', - // 'src/core/view.js', - 'src/core/shortcut.js', - 'src/core/utils/*.js', - 'src/core/behavior/behavior.js', - 'src/core/wrapper/layout.js', - 'src/core/**/*.js', - - 'src/data/data.js', - 'src/data/**/*.js', - 'src/config.js' - ], - dest: 'bi/core.js' - }, - //最基础的控件 - bi_baseJs: { - src: [ - 'src/third/**/*.js', - 'src/base/formula/config.js', - 'src/base/pane.js', - 'src/base/single/single.js', - 'src/base/single/text.js', - 'src/base/single/button/button.basic.js', - 'src/base/single/button/button.node.js', - 'src/base/single/tip/tip.js', - 'src/base/combination/group.button.js', - 'src/base/combination/tree.button.js', - 'src/base/combination/map.button.js', - 'src/base/tree/treeview.js', - 'src/base/tree/asynctree.js', - 'src/base/tree/parttree.js', - 'src/base/**/*.js' - ], - dest: 'bi/base.js' - }, - //实现好的一些基础实例 - bi_caseJs: { - src: [ - 'src/case/combo/popup.bubble.js', - 'src/case/**/*.js' - ], - dest: 'bi/case.js' - }, - bi_widgetJs: { - src: [ - 'src/widget/paramsettingcombo/popup.param.js', - 'src/widget/sequencetable/treenumber.sequencetable.js', - 'src/widget/**/*.js', - 'src/component/**/*.js' - ], - dest: 'bi/widget.js' - }, - bi_routerJs: { - src: [ - 'src/router/**/*.js' - ], - dest: 'bi/router.js' - }, - bi_chartJs: { - src: [ - 'src/addons/chart/chart.js', - 'src/addons/chart/chart.combine.js', - 'src/addons/chart/factory.charts.js', - 'src/addons/chart/**/*.js' - ], - dest: 'bi/chart.js' - }, - bi_coreCss: { - src: ['src/css/core/**/*.css', 'src/css/theme/**/*.css'], - dest: 'bi/core.css' - }, - bi_baseCss: { - src: ['src/css/base/**/*.css'], - dest: 'bi/base.css' - }, - bi_widgetCss: { - src: ['src/css/widget/**/*.css'], - dest: 'bi/widget.css' } }, diff --git a/bi/case.js b/bi/case.js deleted file mode 100644 index b9f3ed7b5..000000000 --- a/bi/case.js +++ /dev/null @@ -1,13987 +0,0 @@ -/** - * 可以改变图标的button - * - * Created by GUY on 2016/2/2. - * - * @class BI.IconChangeButton - * @extends BI.Single - */ -BI.IconChangeButton = BI.inherit(BI.Single, { - _defaultConfig: function () { - var conf = BI.IconChangeButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-icon-change-button", - iconClass: "", - iconWidth: null, - iconHeight: null, - - stopEvent: false, - stopPropagation: false, - selected: false, - once: false, //点击一次选中有效,再点无效 - forceSelected: false, //点击即选中, 选中了就不会被取消 - forceNotSelected: false, //无论怎么点击都不会被选中 - disableSelected: false, //使能选中 - - shadow: false, - isShadowShowingOnSelected: false, //选中状态下是否显示阴影 - trigger: null, - handler: BI.emptyFn - }) - }, - - _init: function () { - BI.IconChangeButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.button = BI.createWidget({ - type: "bi.icon_button", - element: this, - cls: o.iconClass, - height: o.height, - iconWidth: o.iconWidth, - iconHeight: o.iconHeight, - - stopEvent: o.stopEvent, - stopPropagation: o.stopPropagation, - selected: o.selected, - once: o.once, - forceSelected: o.forceSelected, - forceNotSelected: o.forceNotSelected, - disableSelected: o.disableSelected, - - shadow: o.shadow, - isShadowShowingOnSelected: o.isShadowShowingOnSelected, - trigger: o.trigger, - handler: o.handler - }); - - this.button.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button.on(BI.IconButton.EVENT_CHANGE, function () { - self.fireEvent(BI.IconChangeButton.EVENT_CHANGE, arguments); - }); - }, - - isSelected: function () { - return this.button.isSelected(); - }, - - setSelected: function (b) { - this.button.setSelected(b); - }, - - setIcon: function (cls) { - var o = this.options; - if (o.iconClass !== cls) { - this.element.removeClass(o.iconClass).addClass(cls); - o.iconClass = cls; - } - } -}); -BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE"; -BI.shortcut("bi.icon_change_button", BI.IconChangeButton);/** - * guy - * @extends BI.Single - * @type {*|void|Object} - */ -BI.HalfIconButton = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - var conf = BI.HalfIconButton.superclass._defaultConfig.apply(this,arguments); - return BI.extend(conf, { - extraCls: "bi-half-icon-button check-half-select-icon", - height: 16, - width: 16, - iconWidth: 16, - iconHeight: 16, - selected: false - }) - }, - - _init : function() { - BI.HalfIconButton.superclass._init.apply(this, arguments); - }, - - doClick: function(){ - BI.HalfIconButton.superclass.doClick.apply(this, arguments); - if(this.isValid()){ - this.fireEvent(BI.HalfIconButton.EVENT_CHANGE); - } - } -}); -BI.HalfIconButton.EVENT_CHANGE = "HalfIconButton.EVENT_CHANGE"; - -BI.shortcut("bi.half_icon_button", BI.HalfIconButton);/** - * 统一的trigger图标按钮 - * - * Created by GUY on 2015/9/16. - * @class BI.TriggerIconButton - * @extends BI.IconButton - */ -BI.TriggerIconButton = BI.inherit(BI.IconButton, { - - _defaultConfig: function () { - var conf = BI.TriggerIconButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-trigger-icon-button", - extraCls: "pull-down-font" - }); - }, - - _init: function () { - BI.TriggerIconButton.superclass._init.apply(this, arguments); - }, - - doClick: function () { - BI.TriggerIconButton.superclass.doClick.apply(this, arguments); - if (this.isValid()) { - this.fireEvent(BI.TriggerIconButton.EVENT_CHANGE, this); - } - } -}); -BI.TriggerIconButton.EVENT_CHANGE = "TriggerIconButton.EVENT_CHANGE"; -BI.shortcut("bi.trigger_icon_button", BI.TriggerIconButton);/** - * guy - * 复选框item - * @type {*|void|Object} - */ -BI.MultiSelectItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-multi-select-item", - height: 25, - logic: { - dynamic: false - } - }) - }, - _init: function () { - BI.MultiSelectItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - rgap: o.rgap, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("left", { - type: "bi.center_adapt", - items: [this.checkbox], - width: 36 - }, this.text) - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.MultiSelectItem.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - if (this.isValid()) { - this.fireEvent(BI.MultiSelectItem.EVENT_CHANGE, this.getValue(), this); - } - }, - - setSelected: function (v) { - BI.MultiSelectItem.superclass.setSelected.apply(this, arguments); - this.checkbox.setSelected(v); - } -}); -BI.MultiSelectItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_item", BI.MultiSelectItem);/** - * Created by GUY on 2016/2/2. - * - * @class BI.SingleSelectIconTextItem - * @extends BI.BasicButton - */ -BI.SingleSelectIconTextItem = BI.inherit(BI.Single, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectIconTextItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-single-select-icon-text-item bi-list-item-active", - iconClass: "", - hgap: 10, - height: 25 - }) - }, - _init: function () { - BI.SingleSelectIconTextItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.text = BI.createWidget({ - type: "bi.icon_text_item", - element: this, - cls: o.iconClass, - once: o.once, - selected: o.selected, - height: o.height, - iconHeight: o.iconHeight, - iconWidth: o.iconWidth, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - this.text.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - isSelected: function () { - return this.text.isSelected(); - }, - - setSelected: function (b) { - this.text.setSelected(b); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.SingleSelectIconTextItem.superclass.doClick.apply(this, arguments); - } -}); - -BI.shortcut("bi.single_select_icon_text_item", BI.SingleSelectIconTextItem);/** - * guy - * 复选框item - * @type {*|void|Object} - */ -BI.SingleSelectItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-single-select-item bi-list-item-active", - hgap: 10, - height: 25, - textAlign: "left" - }) - }, - _init: function () { - BI.SingleSelectItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.text = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: o.textAlign, - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.SingleSelectItem.superclass.doClick.apply(this, arguments); - }, - - setSelected: function (v) { - BI.SingleSelectItem.superclass.setSelected.apply(this, arguments); - } -}); - -BI.shortcut("bi.single_select_item", BI.SingleSelectItem);/** - * guy - * 单选框item - * @type {*|void|Object} - */ -BI.SingleSelectRadioItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectRadioItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-single-select-radio-item bi-list-item-active", - logic: { - dynamic: false - }, - hgap: 10, - height: 25 - }) - }, - _init: function () { - BI.SingleSelectRadioItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.radio = BI.createWidget({ - type: "bi.radio" - }); - this.radio.on(BI.Controller.EVENT_CHANGE, function (type) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("left", { - type: "bi.center_adapt", - items: [this.radio], - width: 36 - }, this.text) - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.SingleSelectRadioItem.superclass.doClick.apply(this, arguments); - this.radio.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.SingleSelectRadioItem.superclass.setSelected.apply(this, arguments); - this.radio.setSelected(v); - - } -}); - -BI.shortcut("bi.single_select_radio_item", BI.SingleSelectRadioItem);/** - * Created by roy on 15/10/16. - */ -BI.ArrowNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.ArrowNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-arrow-group-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25 - }); - }, - _init: function () { - var self = this, o = this.options; - BI.ArrowNode.superclass._init.apply(this, arguments); - this.checkbox = BI.createWidget({ - type: "bi.arrow_tree_group_node_checkbox", - iconWidth: 13, - iconHeight: 13 - }); - - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.ArrowNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isOpened()); - }, - setValue: function (v) { - this.text.setValue(v); - }, - - setOpened: function (v) { - BI.ArrowNode.superclass.setOpened.apply(this, arguments); - this.checkbox.setSelected(v); - } -}); - -BI.shortcut("bi.arrow_group_node", BI.ArrowNode);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.FirstPlusGroupNode - * @extends BI.NodeButton - */ -BI.FirstPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.FirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-first-plus-group-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25 - }) - }, - _init: function () { - BI.FirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.first_tree_node_checkbox", - stopPropagation: true - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.FirstPlusGroupNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.FirstPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.first_plus_group_node", BI.FirstPlusGroupNode);/** - * Created by User on 2016/3/31. - */ -/** - * > + icon + 文本 - * @class BI.IconArrowNode - * @extends BI.NodeButton - */ -BI.IconArrowNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.IconArrowNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-icon-arrow-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25, - iconHeight: 13, - iconWidth: 13, - iconCls: "" - }) - }, - _init: function () { - BI.IconArrowNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.tree_group_node_checkbox", - width: 23, - stopPropagation: true - }); - - var icon = BI.createWidget({ - type: "bi.center_adapt", - cls: o.iconCls, - width: 23, - items: [{ - type: "bi.icon", - height: o.iconHeight, - width: o.iconWidth - }] - }); - - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, { - width: 23, - el: icon - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.IconArrowNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.IconArrowNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.icon_arrow_node", BI.IconArrowNode);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.LastPlusGroupNode - * @extends BI.NodeButton - */ -BI.LastPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.LastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-last-plus-group-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25 - }) - }, - _init: function () { - BI.LastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.last_tree_node_checkbox", - stopPropagation: true - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if(type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.LastPlusGroupNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.LastPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.last_plus_group_node", BI.LastPlusGroupNode);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.MidPlusGroupNode - * @extends BI.NodeButton - */ -BI.MidPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-mid-plus-group-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25 - }) - }, - _init: function () { - BI.MidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.mid_tree_node_checkbox", - stopPropagation: true - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.MidPlusGroupNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MidPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArrowNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerIconArrowNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-icon-arrow-node bi-list-item", - layer: 0,//第几层级 - id: "", - pId: "", - open: false, - height: 25, - iconHeight: 13, - iconWidth: 13, - iconCls: "" - }) - }, - _init: function () { - BI.MultiLayerIconArrowNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.icon_arrow_node", - iconCls: o.iconCls, - //logic: { - // dynamic: true - //}, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - iconHeight: o.iconHeight, - iconWidth: o.iconWidth, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - self.setSelected(self.isSelected()); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - width: 13, - height: o.height - }) - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - items: [items] - }) - }, - - isOnce: function () { - return true; - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - isSelected: function () { - return this.node.isSelected(); - }, - - setSelected: function (b) { - BI.MultiLayerIconArrowNode.superclass.setSelected.apply(this, arguments); - this.node.setSelected(b); - }, - - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerIconArrowNode.superclass.setOpened.apply(this, arguments); - this.node.setOpened(v); - } -}); - -BI.shortcut("bi.multilayer_icon_arrow_node", BI.MultiLayerIconArrowNode);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.PlusGroupNode - * @extends BI.NodeButton - */ -BI.PlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.PlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-plus-group-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25 - }) - }, - _init: function () { - BI.PlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.tree_node_checkbox" - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.PlusGroupNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.PlusGroupNode.superclass.setOpened.apply(this, arguments); - if (this.checkbox) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.plus_group_node", BI.PlusGroupNode);/** - * 三角号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.TriangleGroupNode - * @extends BI.NodeButton - */ -BI.TriangleGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.TriangleGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-triangle-group-node bi-list-item", - logic: { - dynamic: false - }, - id: "", - pId: "", - open: false, - height: 25 - }) - }, - _init: function () { - BI.TriangleGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - iconWidth: 13, - iconHeight: 13, - type: "bi.tree_group_node_checkbox" - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 25, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.TriangleGroupNode.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isOpened()); - }, - - setOpened: function (v) { - BI.TriangleGroupNode.superclass.setOpened.apply(this, arguments); - this.checkbox.setSelected(v); - }, - - setText: function(text){ - BI.TriangleGroupNode.superclass.setText.apply(this, arguments); - this.text.setText(text); - } -}); - -BI.shortcut("bi.triangle_group_node", BI.TriangleGroupNode);/** - * guy - * 复选框item - * @type {*|void|Object} - */ -BI.FirstTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.FirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-first-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - id: "", - pId: "", - layer: 0, - height: 25 - }) - }, - _init: function () { - BI.FirstTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { - width: 13, - el: { - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - } - }), { - width: 25, - el: { - type: "bi.layout", - cls: "mid-line-conn-background", - width: 25, - height: o.height - } - }, { - el: this.text - }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.FirstTreeLeafItem.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.FirstTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.checkbox.setSelected(v); - } -}); - -BI.shortcut("bi.first_tree_leaf_item", BI.FirstTreeLeafItem);BI.IconTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.IconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-icon-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - height: 25, - iconWidth: 16, - iconHeight: 16, - iconCls: "" - }) - }, - - _init: function () { - BI.IconTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var icon = BI.createWidget({ - type: "bi.center_adapt", - width: 23, - cls: o.iconCls, - items: [{ - type: "bi.icon", - width: o.iconWidth, - height: o.iconHeight - }] - }); - - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 23, - el: icon - }, { - el: this.text - }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.IconTreeLeafItem.superclass.doClick.apply(this, arguments); - }, - - setSelected: function (v) { - BI.IconTreeLeafItem.superclass.setSelected.apply(this, arguments); - } -}); - -BI.shortcut("bi.icon_tree_leaf_item", BI.IconTreeLeafItem);/** - * guy - * 复选框item - * @type {*|void|Object} - */ -BI.LastTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.LastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-last-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - id: "", - pId: "", - layer: 0, - height: 25 - }) - }, - _init: function () { - BI.LastTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { - width: 13, - el: { - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - } - }), { - width: 25, - el: { - type: "bi.layout", - cls: "mid-line-conn-background", - width: 25, - height: o.height - } - }, { - el: this.text - }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.LastTreeLeafItem.superclass.doClick.apply(this, arguments); - // this.checkbox.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.LastTreeLeafItem.superclass.setSelected.apply(this, arguments); - // this.checkbox.setSelected(v); - } -}); - -BI.shortcut("bi.last_tree_leaf_item", BI.LastTreeLeafItem);/** - * guy - * 复选框item - * @type {*|void|Object} - */ -BI.MidTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-mid-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - id: "", - pId: "", - layer: 0, - height: 25 - }) - }, - _init: function () { - BI.MidTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox" - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.setSelected(self.isSelected()); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, ((o.layer === 0) ? "" : { - width: 13, - el: { - type: "bi.layout", - cls: "base-line-conn-background", - width: 13, - height: o.height - } - }), { - width: 25, - el: { - type: "bi.layout", - cls: "mid-line-conn-background", - width: 25, - height: o.height - } - }, { - el: this.text - }); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.MidTreeLeafItem.superclass.doClick.apply(this, arguments); - this.checkbox.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.MidTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.checkbox.setSelected(v); - } -}); - -BI.shortcut("bi.mid_tree_leaf_item", BI.MidTreeLeafItem);/** - * @class BI.MultiLayerIconTreeLeafItem - * @extends BI.BasicButton - */ -BI.MultiLayerIconTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerIconTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-multilayer-icon-tree-leaf-item bi-list-item-active", - layer: 0, - height: 25, - iconCls: "", - iconHeight: 14, - iconWidth: 12 - }) - }, - _init: function () { - BI.MultiLayerIconTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.item = BI.createWidget({ - type: "bi.icon_tree_leaf_item", - cls: "bi-list-item-none", - iconCls: o.iconCls, - id: o.id, - pId: o.pId, - isFront: true, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - iconWidth: o.iconWidth, - iconHeight: o.iconHeight - }); - this.item.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {//本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - width: 13, - height: o.height - }) - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 13), - items: [items] - }); - }, - - doRedMark: function () { - this.item.doRedMark.apply(this.item, arguments); - }, - - unRedMark: function () { - this.item.unRedMark.apply(this.item, arguments); - }, - - doHighLight: function () { - this.item.doHighLight.apply(this.item, arguments); - }, - - unHighLight: function () { - this.item.unHighLight.apply(this.item, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.MultiLayerIconTreeLeafItem.superclass.doClick.apply(this, arguments); - this.item.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.MultiLayerIconTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.item.setSelected(v); - }, - - getValue: function(){ - return this.options.value; - } -}); - -BI.shortcut("bi.multilayer_icon_tree_leaf_item", BI.MultiLayerIconTreeLeafItem);/** - * 树叶子节点 - * Created by GUY on 2015/9/6. - * @class BI.TreeTextLeafItem - * @extends BI.BasicButton - */ -BI.TreeTextLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function() { - return BI.extend(BI.TreeTextLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-tree-text-leaf-item bi-list-item-active", - id: "", - pId: "", - height: 25, - hgap: 0, - lgap: 0, - rgap: 0 - }) - }, - _init : function() { - BI.TreeTextLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - lgap: o.lgap, - rgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.text - }] - }) - }, - - doRedMark: function(){ - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function(){ - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function(){ - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function(){ - this.text.unHighLight.apply(this.text, arguments); - }, - - getId: function(){ - return this.options.id; - }, - - getPId: function(){ - return this.options.pId; - } -}); - -BI.shortcut("bi.tree_text_leaf_item", BI.TreeTextLeafItem);/** - * Created by GUY on 2015/8/28. - * @class BI.Calendar - * @extends BI.Widget - */ -BI.Calendar = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.Calendar.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-calendar", - logic: { - dynamic: false - }, - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - year: 2015, - month: 7, //7表示八月 - day: 25 - }) - }, - - _dateCreator: function (Y, M, D) { - var self = this, o = this.options, log = {}, De = Date.getDate(); - var mins = o.min.match(/\d+/g); - var maxs = o.max.match(/\d+/g); - Y < (mins[0] | 0) && (Y = (mins[0] | 0)); - Y > (maxs[0] | 0) && (Y = (maxs[0] | 0)); - - De.setFullYear(Y, M, D); - log.ymd = [De.getFullYear(), De.getMonth(), De.getDate()]; - - var MD = Date._MD.slice(0); - MD[1] = Date.isLeap(log.ymd[0]) ? 29 : 28; - - De.setFullYear(log.ymd[0], log.ymd[1], 1); - log.FDay = De.getDay(); - - log.PDay = MD[M === 0 ? 11 : M - 1] - log.FDay + 1; - log.NDay = 1; - - var items = []; - BI.each(BI.range(42), function (i) { - var td = {}, YY = log.ymd[0], MM = log.ymd[1] + 1, DD; - if (i < log.FDay) { - td.lastMonth = true; - DD = i + log.PDay; - MM === 1 && (YY -= 1); - MM = MM === 1 ? 12 : MM - 1; - } else if (i >= log.FDay && i < log.FDay + MD[log.ymd[1]]) { - DD = i - log.FDay + 1; - if (i - log.FDay + 1 === log.ymd[2]) { - td.currentDay = true; - } - } else { - td.nextMonth = true; - DD = log.NDay++; - MM === 12 && (YY += 1); - MM = MM === 12 ? 1 : MM + 1; - } - if (Date.checkVoid(YY, MM, DD, mins, maxs)[0]) { - td.disabled = true; - } - td.text = DD; - items.push(td); - }) - return items; - }, - - _init: function () { - BI.Calendar.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var items = BI.map(Date._SDN.slice(0, 7), function (i, value) { - return { - type: "bi.label", - height: 25, - text: value - } - }) - var title = BI.createWidget({ - type: "bi.button_group", - height: 25, - items: items - }) - var days = this._dateCreator(o.year, o.month, o.day); - items = []; - items.push(days.slice(0, 7)); - items.push(days.slice(7, 14)); - items.push(days.slice(14, 21)); - items.push(days.slice(21, 28)); - items.push(days.slice(28, 35)); - items.push(days.slice(35, 42)); - - items = BI.map(items, function (i, item) { - return BI.map(item, function (j, td) { - return BI.extend(td, { - type: "bi.text_item", - cls: "bi-list-item-active", - textAlign: "center", - whiteSpace: "normal", - once: false, - forceSelected: true, - height: 25, - value: o.year + "-" + o.month + "-" + td.text, - disabled: td.lastMonth || td.nextMonth || td.disabled - //selected: td.currentDay - }); - }); - }); - - this.days = BI.createWidget({ - type: "bi.button_group", - items: BI.createItems(items, {}), - layouts: [BI.LogicFactory.createLogic("table", BI.extend({}, o.logic, { - columns: 7, - rows: 6, - columnSize: [1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7, 1 / 7], - rowSize: 25 - }))] - }); - this.days.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }) - BI.createWidget(BI.extend({ - element: this - - }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("top", title, this.days) - })))); - }, - - isFrontDate: function () { - var o = this.options, c = this._const; - var Y = o.year, M = o.month, De = Date.getDate(), day = De.getDay(); - Y = Y | 0; - De.setFullYear(Y, M, 1); - var newDate = De.getOffsetDate(-1 * (day + 1)); - return !!Date.checkVoid(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), o.min, o.max)[0]; - }, - - isFinalDate: function () { - var o = this.options, c = this._const; - var Y = o.year, M = o.month, De = Date.getDate(), day = De.getDay(); - Y = Y | 0; - De.setFullYear(Y, M, 1); - var newDate = De.getOffsetDate(42 - day); - return !!Date.checkVoid(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), o.min, o.max)[0]; - }, - - setValue: function (ob) { - this.days.setValue([ob.year + "-" + ob.month + "-" + ob.day]); - }, - - getValue: function () { - var date = this.days.getValue()[0].match(/\d+/g); - return { - year: date[0] | 0, - month: date[1] | 0, - day: date[2] | 0 - } - } -}); - -BI.extend(BI.Calendar, { - getPageByDateJSON: function (json) { - var year = Date.getDate().getFullYear(); - var month = Date.getDate().getMonth(); - var page = (json.year - year) * 12; - page += json.month - month; - return page; - }, - getDateJSONByPage: function(v){ - var months = Date.getDate().getMonth(); - var page = v; - - //对当前page做偏移,使到当前年初 - page = page + months; - - var year = BI.parseInt(page / 12); - if(page < 0 && page % 12 !== 0){ - year--; - } - var month = page >= 0 ? (page % 12) : ((12 + page % 12) % 12); - return { - year: Date.getDate().getFullYear() + year, - month: month - } - } -}); - -BI.shortcut("bi.calendar", BI.Calendar);/** - * Created by GUY on 2015/8/28. - * @class BI.YearCalendar - * @extends BI.Widget - */ -BI.YearCalendar = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - var conf = BI.YearCalendar.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-year-calendar", - behaviors: {}, - logic: { - dynamic: false - }, - min: '1900-01-01', //最小日期 - max: '2099-12-31', //最大日期 - year: null - }) - }, - - _yearCreator: function (Y) { - var o = this.options; - Y = Y | 0; - var start = BI.YearCalendar.getStartYear(Y); - var items = []; - BI.each(BI.range(BI.YearCalendar.INTERVAL), function (i) { - var td = {}; - if (Date.checkVoid(start + i, 1, 1, o.min, o.max)[0]) { - td.disabled = true; - } - td.text = start + i; - items.push(td); - }); - return items; - }, - - _init: function () { - BI.YearCalendar.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.currentYear = Date.getDate().getFullYear(); - var years = this._yearCreator(o.year || this.currentYear); - - //纵向排列年 - var len = years.length, tyears = BI.makeArray(len, ""); - var map = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; - BI.each(years, function (i, y) { - tyears[i] = years[map[i]]; - }); - var items = []; - items.push(tyears.slice(0, 2)); - items.push(tyears.slice(2, 4)); - items.push(tyears.slice(4, 6)); - items.push(tyears.slice(6, 8)); - items.push(tyears.slice(8, 10)); - items.push(tyears.slice(10, 12)); - - items = BI.map(items, function (i, item) { - return BI.map(item, function (j, td) { - return BI.extend(td, { - type: "bi.text_item", - cls: "bi-list-item-active", - textAlign: "center", - whiteSpace: "normal", - once: false, - forceSelected: true, - height: 23, - width: 38, - value: td.text, - disabled: td.disabled - }); - }); - }); - - this.years = BI.createWidget({ - type: "bi.button_group", - behaviors: o.behaviors, - items: BI.createItems(items, {}), - layouts: [BI.LogicFactory.createLogic("table", BI.extend({}, o.logic, { - columns: 2, - rows: 6, - columnSize: [1 / 2, 1 / 2], - rowSize: 25 - })), { - type: "bi.center_adapt", - vgap: 1 - }] - }); - this.years.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - BI.createWidget(BI.extend({ - element: this - - }, BI.LogicFactory.createLogic("vertical", BI.extend({}, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("top", this.years) - })))); - }, - - isFrontYear: function () { - var o = this.options; - var Y = o.year; - Y = Y | 0; - return !!Date.checkVoid(BI.YearCalendar.getStartYear(Y) - 1, 1, 1, o.min, o.max)[0]; - }, - - isFinalYear: function () { - var o = this.options, c = this._const; - var Y = o.year; - Y = Y | 0; - return !!Date.checkVoid(BI.YearCalendar.getEndYear(Y) + 1, 1, 1, o.min, o.max)[0]; - }, - - setValue: function (val) { - this.years.setValue([val]); - }, - - getValue: function () { - return this.years.getValue()[0]; - } -}); -//类方法 -BI.extend(BI.YearCalendar, { - INTERVAL: 12, - - //获取显示的第一年 - getStartYear: function (year) { - var cur = Date.getDate().getFullYear(); - return year - ((year - cur + 3) % BI.YearCalendar.INTERVAL + 12) % BI.YearCalendar.INTERVAL; - }, - - getEndYear: function (year) { - return BI.YearCalendar.getStartYear(year) + BI.YearCalendar.INTERVAL; - }, - - getPageByYear: function (year) { - var cur = Date.getDate().getFullYear(); - year = BI.YearCalendar.getStartYear(year); - return (year - cur + 3) / BI.YearCalendar.INTERVAL; - } -}); - -BI.shortcut("bi.year_calendar", BI.YearCalendar);/** - * 绘制一些较复杂的canvas - * - * Created by GUY on 2015/11/24. - * @class BI.ComplexCanvas - * @extends BI.Widget - */ -BI.ComplexCanvas = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.ComplexCanvas.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-complex-canvas" - }) - }, - - - _init: function () { - BI.ComplexCanvas.superclass._init.apply(this, arguments); - var o = this.options; - this.canvas = BI.createWidget({ - type: "bi.canvas", - element: this, - width: o.width, - height: o.height - }); - }, - - //绘制树枝节点 - branch: function (x0, y0, x1, y1, x2, y2) { - var self = this, args = [].slice.call(arguments); - if (args.length <= 5) { - return this.canvas.line.apply(this.canvas, arguments); - } - var options; - if (BI.isOdd(args.length)) { - options = BI.last(args); - args = BI.initial(args); - } - args = [].slice.call(args, 2); - var odd = BI.filter(args, function (i) { - return i % 2 === 0; - }); - var even = BI.filter(args, function (i) { - return i % 2 !== 0; - }); - options || (options = {}); - var offset = options.offset || 20; - if ((y0 > y1 && y0 > y2) || (y0 < y1 && y0 < y2)) { - if (y0 > y1 && y0 > y2) { - var y = Math.max.apply(this, even) + offset; - } else { - var y = Math.min.apply(this, even) - offset; - } - var minx = Math.min.apply(this, odd); - var minix = BI.indexOf(odd, minx); - var maxx = Math.max.apply(this, odd); - var maxix = BI.indexOf(odd, maxx); - this.canvas.line(minx, even[minix], minx, y, maxx, y, maxx, even[maxix], options); - BI.each(odd, function (i, dot) { - if (i !== maxix && i !== minix) { - self.canvas.line(dot, even[i], dot, y, options); - } - }); - this.canvas.line(x0, y, x0, y0, options); - return; - } - if ((x0 > x1 && x0 > x2) || (x0 < x1 && x0 < x2)) { - if (x0 > x1 && x0 > x2) { - var x = Math.max.apply(this, odd) + offset; - } else { - var x = Math.min.apply(this, odd) - offset; - } - var miny = Math.min.apply(this, even); - var miniy = BI.indexOf(even, miny); - var maxy = Math.max.apply(this, even); - var maxiy = BI.indexOf(even, maxy); - this.canvas.line(odd[miniy], miny, x, miny, x, maxy, odd[maxiy], maxy, options); - BI.each(even, function (i, dot) { - if (i !== miniy && i !== maxiy) { - self.canvas.line(odd[i], dot, x, dot, options); - } - }); - this.canvas.line(x, y0, x0, y0, options); - return; - } - }, - - stroke: function (callback) { - this.canvas.stroke(callback); - } -}); - -BI.shortcut("bi.complex_canvas", BI.ComplexCanvas);/** - * Created by roy on 15/10/16. - * 上箭头与下箭头切换的树节点 - */ -BI.ArrowTreeGroupNodeCheckbox=BI.inherit(BI.IconButton,{ - _defaultConfig:function(){ - return BI.extend(BI.ArrowTreeGroupNodeCheckbox.superclass._defaultConfig.apply(this,arguments),{ - extraCls:"bi-arrow-tree-group-node", - iconWidth: 13, - iconHeight: 13 - }); - }, - _init:function(){ - BI.ArrowTreeGroupNodeCheckbox.superclass._init.apply(this,arguments); - }, - setSelected: function(v){ - BI.ArrowTreeGroupNodeCheckbox.superclass.setSelected.apply(this, arguments); - if(v) { - this.element.removeClass("column-next-page-h-font").addClass("column-pre-page-h-font"); - } else { - this.element.removeClass("column-pre-page-h-font").addClass("column-next-page-h-font"); - } - } -}); -BI.shortcut("bi.arrow_tree_group_node_checkbox",BI.ArrowTreeGroupNodeCheckbox);/** - * 十字型的树节点 - * @class BI.CheckingMarkNode - * @extends BI.IconButton - */ -BI.CheckingMarkNode = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - return BI.extend( BI.CheckingMarkNode.superclass._defaultConfig.apply(this, arguments), { - extraCls: "check-mark-font", - iconWidth: 13, - iconHeight: 13 - }); - }, - _init:function() { - BI.CheckingMarkNode.superclass._init.apply(this, arguments); - this.setSelected(this.options.selected); - - }, - setSelected: function(v){ - BI.CheckingMarkNode.superclass.setSelected.apply(this, arguments); - if(v===true) { - this.element.addClass("check-mark-font"); - } else { - this.element.removeClass("check-mark-font"); - } - } -}); -BI.shortcut("bi.checking_mark_node", BI.CheckingMarkNode);/** - * 十字型的树节点 - * @class BI.FirstTreeNodeCheckbox - * @extends BI.IconButton - */ -BI.FirstTreeNodeCheckbox = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - return BI.extend( BI.FirstTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { - extraCls: "tree-collapse-icon-type2", - iconWidth: 25, - iconHeight: 25 - }); - }, - _init:function() { - BI.FirstTreeNodeCheckbox.superclass._init.apply(this, arguments); - - }, - setSelected: function(v){ - BI.FirstTreeNodeCheckbox.superclass.setSelected.apply(this, arguments); - if(v===true) { - this.element.addClass("tree-expand-icon-type2"); - } else { - this.element.removeClass("tree-expand-icon-type2"); - } - } -}); -BI.shortcut("bi.first_tree_node_checkbox", BI.FirstTreeNodeCheckbox);/** - * 十字型的树节点 - * @class BI.LastTreeNodeCheckbox - * @extends BI.IconButton - */ -BI.LastTreeNodeCheckbox = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - return BI.extend( BI.LastTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { - extraCls: "tree-collapse-icon-type4", - iconWidth: 25, - iconHeight: 25 - }); - }, - _init:function() { - BI.LastTreeNodeCheckbox.superclass._init.apply(this, arguments); - - }, - setSelected: function(v){ - BI.LastTreeNodeCheckbox.superclass.setSelected.apply(this, arguments); - if(v===true) { - this.element.addClass("tree-expand-icon-type3"); - } else { - this.element.removeClass("tree-expand-icon-type3"); - } - } -}); -BI.shortcut("bi.last_tree_node_checkbox", BI.LastTreeNodeCheckbox);/** - * 十字型的树节点 - * @class BI.MidTreeNodeCheckbox - * @extends BI.IconButton - */ -BI.MidTreeNodeCheckbox = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - return BI.extend( BI.MidTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { - extraCls: "tree-collapse-icon-type3", - iconWidth: 25, - iconHeight: 25 - }); - }, - _init:function() { - BI.MidTreeNodeCheckbox.superclass._init.apply(this, arguments); - - }, - setSelected: function(v){ - BI.MidTreeNodeCheckbox.superclass.setSelected.apply(this, arguments); - if(v===true) { - this.element.addClass("tree-expand-icon-type3"); - } else { - this.element.removeClass("tree-expand-icon-type3"); - } - } -}); -BI.shortcut("bi.mid_tree_node_checkbox", BI.MidTreeNodeCheckbox);/** - * 三角形的树节点 - * Created by GUY on 2015/9/6. - * @class BI.TreeGroupNodeCheckbox - * @extends BI.IconButton - */ -BI.TreeGroupNodeCheckbox = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - return BI.extend( BI.TreeGroupNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { - extraCls: "tree-node-triangle-collapse-font", - iconWidth: 13, - iconHeight: 13 - }); - }, - _init:function() { - BI.TreeGroupNodeCheckbox.superclass._init.apply(this, arguments); - - }, - setSelected: function(v){ - BI.TreeGroupNodeCheckbox.superclass.setSelected.apply(this, arguments); - if(v) { - this.element.removeClass("tree-node-triangle-collapse-font").addClass("tree-node-triangle-expand-font"); - } else { - this.element.removeClass("tree-node-triangle-expand-font").addClass("tree-node-triangle-collapse-font"); - } - } -}); -BI.shortcut("bi.tree_group_node_checkbox", BI.TreeGroupNodeCheckbox);/** - * 十字型的树节点 - * @class BI.TreeNodeCheckbox - * @extends BI.IconButton - */ -BI.TreeNodeCheckbox = BI.inherit(BI.IconButton, { - _defaultConfig: function() { - return BI.extend( BI.TreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { - extraCls: "tree-collapse-icon-type1", - iconWidth: 25, - iconHeight: 25 - }); - }, - _init:function() { - BI.TreeNodeCheckbox.superclass._init.apply(this, arguments); - - }, - setSelected: function(v){ - BI.TreeNodeCheckbox.superclass.setSelected.apply(this, arguments); - if(v) { - this.element.addClass("tree-expand-icon-type1"); - } else { - this.element.removeClass("tree-expand-icon-type1"); - } - } -}); -BI.shortcut("bi.tree_node_checkbox", BI.TreeNodeCheckbox);/*! - * clipboard.js v1.6.1 - * https://zenorocha.github.io/clipboard.js - * - * Licensed MIT © Zeno Rocha - */ -try {//IE8下会抛错 - (function (f) { - if (typeof exports === "object" && typeof module !== "undefined") { - module.exports = f() - } else if (typeof define === "function" && define.amd) { - define([], f) - } else { - var g; - if (typeof window !== "undefined") { - g = window - } else if (typeof global !== "undefined") { - g = global - } else if (typeof self !== "undefined") { - g = self - } else { - g = this - } - g.Clipboard = f() - } - })(function () { - var define, module, exports; - return (function e(t, n, r) { - function s(o, u) { - if (!n[o]) { - if (!t[o]) { - var a = typeof require == "function" && require; - if (!u && a)return a(o, !0); - if (i)return i(o, !0); - var f = new Error("Cannot find module '" + o + "'"); - throw f.code = "MODULE_NOT_FOUND", f - } - var l = n[o] = {exports: {}}; - t[o][0].call(l.exports, function (e) { - var n = t[o][1][e]; - return s(n ? n : e) - }, l, l.exports, e, t, n, r) - } - return n[o].exports - } - - var i = typeof require == "function" && require; - for (var o = 0; o < r.length; o++)s(r[o]); - return s - })({ - 1: [function (require, module, exports) { - var DOCUMENT_NODE_TYPE = 9; - - /** - * A polyfill for Element.matches() - */ - if (typeof Element !== 'undefined' && !Element.prototype.matches) { - var proto = Element.prototype; - - proto.matches = proto.matchesSelector || - proto.mozMatchesSelector || - proto.msMatchesSelector || - proto.oMatchesSelector || - proto.webkitMatchesSelector; - } - - /** - * Finds the closest parent that matches a selector. - * - * @param {Element} element - * @param {String} selector - * @return {Function} - */ - function closest(element, selector) { - while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { - if (element.matches(selector)) return element; - element = element.parentNode; - } - } - - module.exports = closest; - - }, {}], 2: [function (require, module, exports) { - var closest = require('./closest'); - - /** - * Delegates event to a selector. - * - * @param {Element} element - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @param {Boolean} useCapture - * @return {Object} - */ - function delegate(element, selector, type, callback, useCapture) { - var listenerFn = listener.apply(this, arguments); - - element.addEventListener(type, listenerFn, useCapture); - - return { - destroy: function () { - element.removeEventListener(type, listenerFn, useCapture); - } - } - } - - /** - * Finds closest match and invokes callback. - * - * @param {Element} element - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @return {Function} - */ - function listener(element, selector, type, callback) { - return function (e) { - e.delegateTarget = closest(e.target, selector); - - if (e.delegateTarget) { - callback.call(element, e); - } - } - } - - module.exports = delegate; - - }, {"./closest": 1}], 3: [function (require, module, exports) { - /** - * Check if argument is a HTML element. - * - * @param {Object} value - * @return {Boolean} - */ - exports.node = function (value) { - return value !== undefined - && value instanceof HTMLElement - && value.nodeType === 1; - }; - - /** - * Check if argument is a list of HTML elements. - * - * @param {Object} value - * @return {Boolean} - */ - exports.nodeList = function (value) { - var type = Object.prototype.toString.call(value); - - return value !== undefined - && (type === '[object NodeList]' || type === '[object HTMLCollection]') - && ('length' in value) - && (value.length === 0 || exports.node(value[0])); - }; - - /** - * Check if argument is a string. - * - * @param {Object} value - * @return {Boolean} - */ - exports.string = function (value) { - return typeof value === 'string' - || value instanceof String; - }; - - /** - * Check if argument is a function. - * - * @param {Object} value - * @return {Boolean} - */ - exports.fn = function (value) { - var type = Object.prototype.toString.call(value); - - return type === '[object Function]'; - }; - - }, {}], 4: [function (require, module, exports) { - var is = require('./is'); - var delegate = require('delegate'); - - /** - * Validates all params and calls the right - * listener function based on its target type. - * - * @param {String|HTMLElement|HTMLCollection|NodeList} target - * @param {String} type - * @param {Function} callback - * @return {Object} - */ - function listen(target, type, callback) { - if (!target && !type && !callback) { - throw new Error('Missing required arguments'); - } - - if (!is.string(type)) { - throw new TypeError('Second argument must be a String'); - } - - if (!is.fn(callback)) { - throw new TypeError('Third argument must be a Function'); - } - - if (is.node(target)) { - return listenNode(target, type, callback); - } - else if (is.nodeList(target)) { - return listenNodeList(target, type, callback); - } - else if (is.string(target)) { - return listenSelector(target, type, callback); - } - else { - throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); - } - } - - /** - * Adds an event listener to a HTML element - * and returns a remove listener function. - * - * @param {HTMLElement} node - * @param {String} type - * @param {Function} callback - * @return {Object} - */ - function listenNode(node, type, callback) { - node.addEventListener(type, callback); - - return { - destroy: function () { - node.removeEventListener(type, callback); - } - } - } - - /** - * Add an event listener to a list of HTML elements - * and returns a remove listener function. - * - * @param {NodeList|HTMLCollection} nodeList - * @param {String} type - * @param {Function} callback - * @return {Object} - */ - function listenNodeList(nodeList, type, callback) { - Array.prototype.forEach.call(nodeList, function (node) { - node.addEventListener(type, callback); - }); - - return { - destroy: function () { - Array.prototype.forEach.call(nodeList, function (node) { - node.removeEventListener(type, callback); - }); - } - } - } - - /** - * Add an event listener to a selector - * and returns a remove listener function. - * - * @param {String} selector - * @param {String} type - * @param {Function} callback - * @return {Object} - */ - function listenSelector(selector, type, callback) { - return delegate(document.body, selector, type, callback); - } - - module.exports = listen; - - }, {"./is": 3, "delegate": 2}], 5: [function (require, module, exports) { - function select(element) { - var selectedText; - - if (element.nodeName === 'SELECT') { - element.focus(); - - selectedText = element.value; - } - else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { - var isReadOnly = element.hasAttribute('readonly'); - - if (!isReadOnly) { - element.setAttribute('readonly', ''); - } - - element.select(); - element.setSelectionRange(0, element.value.length); - - if (!isReadOnly) { - element.removeAttribute('readonly'); - } - - selectedText = element.value; - } - else { - if (element.hasAttribute('contenteditable')) { - element.focus(); - } - - var selection = window.getSelection(); - var range = document.createRange(); - - range.selectNodeContents(element); - selection.removeAllRanges(); - selection.addRange(range); - - selectedText = selection.toString(); - } - - return selectedText; - } - - module.exports = select; - - }, {}], 6: [function (require, module, exports) { - function E() { - // Keep this empty so it's easier to inherit from - // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) - } - - E.prototype = { - on: function (name, callback, ctx) { - var e = this.e || (this.e = {}); - - (e[name] || (e[name] = [])).push({ - fn: callback, - ctx: ctx - }); - - return this; - }, - - once: function (name, callback, ctx) { - var self = this; - - function listener() { - self.off(name, listener); - callback.apply(ctx, arguments); - }; - - listener._ = callback - return this.on(name, listener, ctx); - }, - - emit: function (name) { - var data = [].slice.call(arguments, 1); - var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; - var len = evtArr.length; - - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); - } - - return this; - }, - - off: function (name, callback) { - var e = this.e || (this.e = {}); - var evts = e[name]; - var liveEvents = []; - - if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); - } - } - - // Remove event from queue to prevent memory leak - // Suggested by https://github.com/lazd - // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 - - (liveEvents.length) - ? e[name] = liveEvents - : delete e[name]; - - return this; - } - }; - - module.exports = E; - - }, {}], 7: [function (require, module, exports) { - (function (global, factory) { - if (typeof define === "function" && define.amd) { - define(['module', 'select'], factory); - } else if (typeof exports !== "undefined") { - factory(module, require('select')); - } else { - var mod = { - exports: {} - }; - factory(mod, global.select); - global.clipboardAction = mod.exports; - } - })(this, function (module, _select) { - 'use strict'; - - var _select2 = _interopRequireDefault(_select); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - "default": obj - }; - } - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - var _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; - }(); - - var ClipboardAction = function () { - /** - * @param {Object} options - */ - function ClipboardAction(options) { - _classCallCheck(this, ClipboardAction); - - this.resolveOptions(options); - this.initSelection(); - } - - /** - * Defines base properties passed from constructor. - * @param {Object} options - */ - - - _createClass(ClipboardAction, [{ - key: 'resolveOptions', - value: function resolveOptions() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - this.action = options.action; - this.emitter = options.emitter; - this.target = options.target; - this.text = options.text; - this.trigger = options.trigger; - - this.selectedText = ''; - } - }, { - key: 'initSelection', - value: function initSelection() { - if (this.text) { - this.selectFake(); - } else if (this.target) { - this.selectTarget(); - } - } - }, { - key: 'selectFake', - value: function selectFake() { - var _this = this; - - var isRTL = document.documentElement.getAttribute('dir') == 'rtl'; - - this.removeFake(); - - this.fakeHandlerCallback = function () { - return _this.removeFake(); - }; - this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true; - - this.fakeElem = document.createElement('textarea'); - // Prevent zooming on iOS - this.fakeElem.style.fontSize = '12pt'; - // Reset box model - this.fakeElem.style.border = '0'; - this.fakeElem.style.padding = '0'; - this.fakeElem.style.margin = '0'; - // Move element out of screen horizontally - this.fakeElem.style.position = 'absolute'; - this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; - // Move element to the same position vertically - var yPosition = window.pageYOffset || document.documentElement.scrollTop; - this.fakeElem.style.top = yPosition + 'px'; - - this.fakeElem.setAttribute('readonly', ''); - this.fakeElem.value = this.text; - - document.body.appendChild(this.fakeElem); - - this.selectedText = (0, _select2["default"])(this.fakeElem); - this.copyText(); - } - }, { - key: 'removeFake', - value: function removeFake() { - if (this.fakeHandler) { - document.body.removeEventListener('click', this.fakeHandlerCallback); - this.fakeHandler = null; - this.fakeHandlerCallback = null; - } - - if (this.fakeElem) { - document.body.removeChild(this.fakeElem); - this.fakeElem = null; - } - } - }, { - key: 'selectTarget', - value: function selectTarget() { - this.selectedText = (0, _select2["default"])(this.target); - this.copyText(); - } - }, { - key: 'copyText', - value: function copyText() { - var succeeded = void 0; - - try { - succeeded = document.execCommand(this.action); - } catch (err) { - succeeded = false; - } - - this.handleResult(succeeded); - } - }, { - key: 'handleResult', - value: function handleResult(succeeded) { - this.emitter.emit(succeeded ? 'success' : 'error', { - action: this.action, - text: this.selectedText, - trigger: this.trigger, - clearSelection: this.clearSelection.bind(this) - }); - } - }, { - key: 'clearSelection', - value: function clearSelection() { - if (this.target) { - this.target.blur(); - } - - window.getSelection().removeAllRanges(); - } - }, { - key: 'destroy', - value: function destroy() { - this.removeFake(); - } - }, { - key: 'action', - set: function set() { - var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy'; - - this._action = action; - - if (this._action !== 'copy' && this._action !== 'cut') { - throw new Error('Invalid "action" value, use either "copy" or "cut"'); - } - }, - get: function get() { - return this._action; - } - }, { - key: 'target', - set: function set(target) { - if (target !== undefined) { - if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) { - if (this.action === 'copy' && target.hasAttribute('disabled')) { - throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); - } - - if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { - throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); - } - - this._target = target; - } else { - throw new Error('Invalid "target" value, use a valid Element'); - } - } - }, - get: function get() { - return this._target; - } - }]); - - return ClipboardAction; - }(); - - module.exports = ClipboardAction; - }); - - }, {"select": 5}], 8: [function (require, module, exports) { - (function (global, factory) { - if (typeof define === "function" && define.amd) { - define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory); - } else if (typeof exports !== "undefined") { - factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener')); - } else { - var mod = { - exports: {} - }; - factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener); - global.clipboard = mod.exports; - } - })(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) { - 'use strict'; - - var _clipboardAction2 = _interopRequireDefault(_clipboardAction); - - var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter); - - var _goodListener2 = _interopRequireDefault(_goodListener); - - function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { - "default": obj - }; - } - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - var _createClass = function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; - }(); - - function _possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; - } - - var Clipboard = function (_Emitter) { - _inherits(Clipboard, _Emitter); - - /** - * @param {String|HTMLElement|HTMLCollection|NodeList} trigger - * @param {Object} options - */ - function Clipboard(trigger, options) { - _classCallCheck(this, Clipboard); - - var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this)); - - _this.resolveOptions(options); - _this.listenClick(trigger); - return _this; - } - - /** - * Defines if attributes would be resolved using internal setter functions - * or custom functions that were passed in the constructor. - * @param {Object} options - */ - - - _createClass(Clipboard, [{ - key: 'resolveOptions', - value: function resolveOptions() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - this.action = typeof options.action === 'function' ? options.action : this.defaultAction; - this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; - this.text = typeof options.text === 'function' ? options.text : this.defaultText; - } - }, { - key: 'listenClick', - value: function listenClick(trigger) { - var _this2 = this; - - this.listener = (0, _goodListener2["default"])(trigger, 'click', function (e) { - return _this2.onClick(e); - }); - } - }, { - key: 'onClick', - value: function onClick(e) { - var trigger = e.delegateTarget || e.currentTarget; - - if (this.clipboardAction) { - this.clipboardAction = null; - } - - this.clipboardAction = new _clipboardAction2["default"]({ - action: this.action(trigger), - target: this.target(trigger), - text: this.text(trigger), - trigger: trigger, - emitter: this - }); - } - }, { - key: 'defaultAction', - value: function defaultAction(trigger) { - return getAttributeValue('action', trigger); - } - }, { - key: 'defaultTarget', - value: function defaultTarget(trigger) { - var selector = getAttributeValue('target', trigger); - - if (selector) { - return document.querySelector(selector); - } - } - }, { - key: 'defaultText', - value: function defaultText(trigger) { - return getAttributeValue('text', trigger); - } - }, { - key: 'destroy', - value: function destroy() { - this.listener.destroy(); - - if (this.clipboardAction) { - this.clipboardAction.destroy(); - this.clipboardAction = null; - } - } - }], [{ - key: 'isSupported', - value: function isSupported() { - var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; - - var actions = typeof action === 'string' ? [action] : action; - var support = !!document.queryCommandSupported; - - actions.forEach(function (action) { - support = support && !!document.queryCommandSupported(action); - }); - - return support; - } - }]); - - return Clipboard; - }(_tinyEmitter2["default"]); - - /** - * Helper function to retrieve attribute value. - * @param {String} suffix - * @param {Element} element - */ - function getAttributeValue(suffix, element) { - var attribute = 'data-clipboard-' + suffix; - - if (!element.hasAttribute(attribute)) { - return; - } - - return element.getAttribute(attribute); - } - - module.exports = Clipboard; - }); - - }, {"./clipboard-action": 7, "good-listener": 4, "tiny-emitter": 6}] - }, {}, [8])(8) - }); -} catch (e) { - /* - * zClip :: jQuery ZeroClipboard v1.1.1 - * http://steamdev.com/zclip - * - * Copyright 2011, SteamDev - * Released under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * - * Date: Wed Jun 01, 2011 - */ - - - (function ($) { - - $.fn.zclip = function (params) { - - if (typeof params == "object" && !params.length) { - - var settings = $.extend({ - - path: 'ZeroClipboard.swf', - copy: null, - beforeCopy: null, - afterCopy: null, - clickAfter: true, - setHandCursor: true, - setCSSEffects: true - - }, params); - - - return this.each(function () { - - var o = $(this); - - if (o.is(':visible') && (typeof settings.copy == 'string' || $.isFunction(settings.copy))) { - - ZeroClipboard.setMoviePath(settings.path); - var clip = new ZeroClipboard.Client(); - - if ($.isFunction(settings.copy)) { - o.bind('zClip_copy', settings.copy); - } - if ($.isFunction(settings.beforeCopy)) { - o.bind('zClip_beforeCopy', settings.beforeCopy); - } - if ($.isFunction(settings.afterCopy)) { - o.bind('zClip_afterCopy', settings.afterCopy); - } - - clip.setHandCursor(settings.setHandCursor); - clip.setCSSEffects(settings.setCSSEffects); - clip.addEventListener('mouseOver', function (client) { - o.trigger('mouseenter'); - }); - clip.addEventListener('mouseOut', function (client) { - o.trigger('mouseleave'); - }); - clip.addEventListener('mouseDown', function (client) { - - o.trigger('mousedown'); - - if (!$.isFunction(settings.copy)) { - clip.setText(settings.copy); - } else { - clip.setText(o.triggerHandler('zClip_copy')); - } - - if ($.isFunction(settings.beforeCopy)) { - o.trigger('zClip_beforeCopy'); - } - - }); - - clip.addEventListener('complete', function (client, text) { - - if ($.isFunction(settings.afterCopy)) { - - o.trigger('zClip_afterCopy'); - - } else { - if (text.length > 500) { - text = text.substr(0, 500) + "...\n\n(" + (text.length - 500) + " characters not shown)"; - } - - o.removeClass('hover'); - alert("Copied text to clipboard:\n\n " + text); - } - - if (settings.clickAfter) { - o.trigger('click'); - } - - }); - - - clip.glue(o[0], o.parent()[0]); - - $(window).bind('load resize', function () { - clip.reposition(); - }); - - - } - - }); - - } else if (typeof params == "string") { - - return this.each(function () { - - var o = $(this); - - params = params.toLowerCase(); - var zclipId = o.data('zclipId'); - var clipElm = $('#' + zclipId + '.zclip'); - - if (params == "remove") { - - clipElm.remove(); - o.removeClass('active hover'); - - } else if (params == "hide") { - - clipElm.hide(); - o.removeClass('active hover'); - - } else if (params == "show") { - - clipElm.show(); - - } - - }); - - } - - } - - - })(jQuery); - - -// ZeroClipboard -// Simple Set Clipboard System -// Author: Joseph Huckaby - var ZeroClipboard = { - - version: "1.0.7", - clients: {}, - // registered upload clients on page, indexed by id - moviePath: 'ZeroClipboard.swf', - // URL to movie - nextId: 1, - // ID of next movie - $: function (thingy) { - // simple DOM lookup utility function - if (typeof(thingy) == 'string') thingy = document.getElementById(thingy); - if (!thingy.addClass) { - // extend element with a few useful methods - thingy.hide = function () { - this.style.display = 'none'; - }; - thingy.show = function () { - this.style.display = ''; - }; - thingy.addClass = function (name) { - this.removeClass(name); - this.className += ' ' + name; - }; - thingy.removeClass = function (name) { - var classes = this.className.split(/\s+/); - var idx = -1; - for (var k = 0; k < classes.length; k++) { - if (classes[k] == name) { - idx = k; - k = classes.length; - } - } - if (idx > -1) { - classes.splice(idx, 1); - this.className = classes.join(' '); - } - return this; - }; - thingy.hasClass = function (name) { - return !!this.className.match(new RegExp("\\s*" + name + "\\s*")); - }; - } - return thingy; - }, - - setMoviePath: function (path) { - // set path to ZeroClipboard.swf - this.moviePath = path; - }, - - dispatch: function (id, eventName, args) { - // receive event from flash movie, send to client - var client = this.clients[id]; - if (client) { - client.receiveEvent(eventName, args); - } - }, - - register: function (id, client) { - // register new client to receive events - this.clients[id] = client; - }, - - getDOMObjectPosition: function (obj, stopObj) { - // get absolute coordinates for dom element - var info = { - left: 0, - top: 0, - width: obj.width ? obj.width : obj.offsetWidth, - height: obj.height ? obj.height : obj.offsetHeight - }; - - if (obj && (obj != stopObj)) { - info.left += obj.offsetLeft; - info.top += obj.offsetTop; - } - - return info; - }, - - Client: function (elem) { - // constructor for new simple upload client - this.handlers = {}; - - // unique ID - this.id = ZeroClipboard.nextId++; - this.movieId = 'ZeroClipboardMovie_' + this.id; - - // register client with singleton to receive flash events - ZeroClipboard.register(this.id, this); - - // create movie - if (elem) this.glue(elem); - } - }; - - ZeroClipboard.Client.prototype = { - - id: 0, - // unique ID for us - ready: false, - // whether movie is ready to receive events or not - movie: null, - // reference to movie object - clipText: '', - // text to copy to clipboard - handCursorEnabled: true, - // whether to show hand cursor, or default pointer cursor - cssEffects: true, - // enable CSS mouse effects on dom container - handlers: null, - // user event handlers - glue: function (elem, appendElem, stylesToAdd) { - // glue to DOM element - // elem can be ID or actual DOM element object - this.domElement = ZeroClipboard.$(elem); - - // float just above object, or zIndex 99 if dom element isn't set - var zIndex = 99; - if (this.domElement.style.zIndex) { - zIndex = parseInt(this.domElement.style.zIndex, 10) + 1; - } - - if (typeof(appendElem) == 'string') { - appendElem = ZeroClipboard.$(appendElem); - } else if (typeof(appendElem) == 'undefined') { - appendElem = document.getElementsByTagName('body')[0]; - } - - // find X/Y position of domElement - var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem); - - // create floating DIV above element - this.div = document.createElement('div'); - this.div.className = "zclip"; - this.div.id = "zclip-" + this.movieId; - $(this.domElement).data('zclipId', 'zclip-' + this.movieId); - var style = this.div.style; - style.position = 'absolute'; - style.left = '' + box.left + 'px'; - style.top = '' + box.top + 'px'; - style.width = '' + box.width + 'px'; - style.height = '' + box.height + 'px'; - style.zIndex = zIndex; - - if (typeof(stylesToAdd) == 'object') { - for (addedStyle in stylesToAdd) { - style[addedStyle] = stylesToAdd[addedStyle]; - } - } - - // style.backgroundColor = '#f00'; // debug - appendElem.appendChild(this.div); - - this.div.innerHTML = this.getHTML(box.width, box.height); - }, - - getHTML: function (width, height) { - // return HTML for movie - var html = ''; - var flashvars = 'id=' + this.id + '&width=' + width + '&height=' + height; - - if (navigator.userAgent.match(/MSIE/)) { - // IE gets an OBJECT tag - var protocol = location.href.match(/^https/i) ? 'https://' : 'http://'; - html += ''; - } else { - // all other browsers get an EMBED tag - html += ''; - } - return html; - }, - - hide: function () { - // temporarily hide floater offscreen - if (this.div) { - this.div.style.left = '-2000px'; - } - }, - - show: function () { - // show ourselves after a call to hide() - this.reposition(); - }, - - destroy: function () { - // destroy control and floater - if (this.domElement && this.div) { - this.hide(); - this.div.innerHTML = ''; - - var body = document.getElementsByTagName('body')[0]; - try { - body.removeChild(this.div); - } catch (e) { - ; - } - - this.domElement = null; - this.div = null; - } - }, - - reposition: function (elem) { - // reposition our floating div, optionally to new container - // warning: container CANNOT change size, only position - if (elem) { - this.domElement = ZeroClipboard.$(elem); - if (!this.domElement) this.hide(); - } - - if (this.domElement && this.div) { - var box = ZeroClipboard.getDOMObjectPosition(this.domElement); - var style = this.div.style; - style.left = '' + box.left + 'px'; - style.top = '' + box.top + 'px'; - } - }, - - setText: function (newText) { - // set text to be copied to clipboard - this.clipText = newText; - if (this.ready) { - this.movie.setText(newText); - } - }, - - addEventListener: function (eventName, func) { - // add user event listener for event - // event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel - eventName = eventName.toString().toLowerCase().replace(/^on/, ''); - if (!this.handlers[eventName]) { - this.handlers[eventName] = []; - } - this.handlers[eventName].push(func); - }, - - setHandCursor: function (enabled) { - // enable hand cursor (true), or default arrow cursor (false) - this.handCursorEnabled = enabled; - if (this.ready) { - this.movie.setHandCursor(enabled); - } - }, - - setCSSEffects: function (enabled) { - // enable or disable CSS effects on DOM container - this.cssEffects = !!enabled; - }, - - receiveEvent: function (eventName, args) { - // receive event from flash - eventName = eventName.toString().toLowerCase().replace(/^on/, ''); - - // special behavior for certain events - switch (eventName) { - case 'load': - // movie claims it is ready, but in IE this isn't always the case... - // bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function - this.movie = document.getElementById(this.movieId); - if (!this.movie) { - var self = this; - setTimeout(function () { - self.receiveEvent('load', null); - }, 1); - return; - } - - // firefox on pc needs a "kick" in order to set these in certain cases - if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { - var self = this; - setTimeout(function () { - self.receiveEvent('load', null); - }, 100); - this.ready = true; - return; - } - - this.ready = true; - try { - this.movie.setText(this.clipText); - } catch (e) { - } - try { - this.movie.setHandCursor(this.handCursorEnabled); - } catch (e) { - } - break; - - case 'mouseover': - if (this.domElement && this.cssEffects) { - this.domElement.addClass('hover'); - if (this.recoverActive) { - this.domElement.addClass('active'); - } - - - } - - - break; - - case 'mouseout': - if (this.domElement && this.cssEffects) { - this.recoverActive = false; - if (this.domElement.hasClass('active')) { - this.domElement.removeClass('active'); - this.recoverActive = true; - } - this.domElement.removeClass('hover'); - - } - break; - - case 'mousedown': - if (this.domElement && this.cssEffects) { - this.domElement.addClass('active'); - } - break; - - case 'mouseup': - if (this.domElement && this.cssEffects) { - this.domElement.removeClass('active'); - this.recoverActive = false; - } - break; - } // switch eventName - if (this.handlers[eventName]) { - for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) { - var func = this.handlers[eventName][idx]; - - if (typeof(func) == 'function') { - // actual function reference - func(this, args); - } else if ((typeof(func) == 'object') && (func.length == 2)) { - // PHP style object + method, i.e. [myObject, 'myMethod'] - func[0][func[1]](this, args); - } else if (typeof(func) == 'string') { - // name of function - window[func](this, args); - } - } // foreach event handler defined - } // user defined handler for event - } - - }; -}/** - * 复制 - * Created by GUY on 2016/2/16. - * @class BI.ClipBoard - * @extends BI.BasicButton - */ -BI.ClipBoard = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.ClipBoard.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-clipboard", - copy: BI.emptyFn, - afterCopy: BI.emptyFn - }) - }, - - _init: function () { - BI.ClipBoard.superclass._init.apply(this, arguments); - }, - - mounted: function () { - var self = this, o = this.options; - if (window.Clipboard) { - this.clipboard = new Clipboard(this.element[0], { - text: function () { - return BI.isFunction(o.copy) ? o.copy() : o.copy; - } - }); - this.clipboard.on("success", o.afterCopy) - } else { - this.element.zclip({ - path: BI.resourceURL + "/ZeroClipboard.swf", - copy: o.copy, - beforeCopy: o.beforeCopy, - afterCopy: o.afterCopy - }); - } - }, - - destroyed: function () { - this.clipboard && this.clipboard.destroy(); - } -}); - -BI.shortcut("bi.clipboard", BI.ClipBoard);/** - * 自定义选色 - * - * Created by GUY on 2015/11/17. - * @class BI.CustomColorChooser - * @extends BI.Widget - */ -BI.CustomColorChooser = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.CustomColorChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-custom-color-chooser", - width: 227, - height: 245 - }) - }, - - _init: function () { - BI.CustomColorChooser.superclass._init.apply(this, arguments); - var self = this; - this.editor = BI.createWidget({ - type: "bi.color_picker_editor" - }); - this.editor.on(BI.ColorPickerEditor.EVENT_CHANGE, function () { - self.setValue(this.getValue()); - }); - this.farbtastic = BI.createWidget({ - type: "bi.farbtastic" - }); - this.farbtastic.on(BI.Farbtastic.EVENT_CHANGE, function () { - self.setValue(this.getValue()); - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - type: "bi.absolute", - items: [{ - el: this.editor, - left: 10, - top: 10, - right: 10 - }], - height: 30 - }, { - type: "bi.absolute", - items: [{ - el: this.farbtastic, - left: 15, - right: 15, - top: 10 - }], - height: 215 - }] - }) - }, - - setValue: function (color) { - this.editor.setValue(color); - this.farbtastic.setValue(color); - }, - - getValue: function () { - return this.editor.getValue(); - } -}); -BI.CustomColorChooser.EVENT_CHANGE = "CustomColorChooser.EVENT_CHANGE"; -BI.shortcut("bi.custom_color_chooser", BI.CustomColorChooser);/** - * 选色控件 - * - * Created by GUY on 2015/11/17. - * @class BI.ColorChooser - * @extends BI.Widget - */ -BI.ColorChooser = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ColorChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-color-chooser", - el: {} - }) - }, - - _init: function () { - BI.ColorChooser.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget(BI.extend({ - type: "bi.color_chooser_trigger", - width: o.width, - height: o.height - }, o.el)); - this.colorPicker = BI.createWidget({ - type: "bi.color_chooser_popup" - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 1, - el: this.trigger, - popup: { - el: this.colorPicker, - stopPropagation: false, - minWidth: 202 - } - }); - - var fn = function () { - var color = self.colorPicker.getValue(); - self.trigger.setValue(color); - var colors = BI.string2Array(BI.Cache.getItem("colors") || ""); - var que = new BI.Queue(8); - que.fromArray(colors); - que.remove(color); - que.unshift(color); - BI.Cache.setItem("colors", BI.array2String(que.toArray())); - }; - - this.colorPicker.on(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, function () { - fn(); - }); - - this.colorPicker.on(BI.ColorChooserPopup.EVENT_CHANGE, function () { - fn(); - self.combo.hideView(); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.colorPicker.setStoreColors(BI.string2Array(BI.Cache.getItem("colors") || "")); - }); - - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - self.fireEvent(BI.ColorChooser.EVENT_CHANGE, arguments); - }) - }, - - isViewVisible: function () { - return this.combo.isViewVisible(); - }, - - hideView: function () { - this.combo.hideView(); - }, - - showView: function () { - this.combo.showView(); - }, - - setValue: function (color) { - this.combo.setValue(color); - }, - - getValue: function () { - return this.colorPicker.getValue(); - } -}); -BI.ColorChooser.EVENT_CHANGE = "ColorChooser.EVENT_CHANGE"; -BI.shortcut("bi.color_chooser", BI.ColorChooser);/** - * 选色控件 - * - * Created by GUY on 2015/11/17. - * @class BI.ColorChooserPopup - * @extends BI.Widget - */ -BI.ColorChooserPopup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ColorChooserPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-color-chooser-popup", - width: 200, - height: 145 - }) - }, - - _init: function () { - BI.ColorChooserPopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.colorEditor = BI.createWidget({ - type: "bi.color_picker_editor" - }); - - this.colorEditor.on(BI.ColorPickerEditor.EVENT_CHANGE, function () { - self.setValue(this.getValue()); - self.fireEvent(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, arguments); - }); - - this.storeColors = BI.createWidget({ - type: "bi.color_picker", - items: [[{ - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }]], - width: 190, - height: 25 - }); - this.storeColors.on(BI.ColorPicker.EVENT_CHANGE, function () { - self.setValue(this.getValue()[0]); - self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); - }); - - this.colorPicker = BI.createWidget({ - type: "bi.color_picker", - width: 190, - height: 50 - }); - - this.colorPicker.on(BI.ColorPicker.EVENT_CHANGE, function () { - self.setValue(this.getValue()[0]); - self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); - }); - - this.customColorChooser = BI.createWidget({ - type: "bi.custom_color_chooser" - }); - - var panel = BI.createWidget({ - type: "bi.popup_panel", - buttons: [BI.i18nText("BI-Basic_Cancel"), BI.i18nText("BI-Basic_Save")], - title: BI.i18nText("BI-Custom_Color"), - el: this.customColorChooser, - stopPropagation: false, - bgap: -1, - rgap: 1, - lgap: 1, - minWidth: 227 - }); - - this.more = BI.createWidget({ - type: "bi.combo", - direction: "right,top", - isNeedAdjustHeight: false, - el: { - type: "bi.text_item", - cls: "color-chooser-popup-more bi-list-item", - textAlign: "center", - height: 20, - text: BI.i18nText("BI-Basic_More") + "..." - }, - popup: panel - }); - - this.more.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { - self.customColorChooser.setValue(self.getValue()); - }); - panel.on(BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { - switch (index) { - case 0: - self.more.hideView(); - break; - case 1: - self.setValue(self.customColorChooser.getValue()); - self.more.hideView(); - self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); - break; - } - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: { - type: "bi.absolute", - cls: "bi-background bi-border-bottom", - items: [{ - el: this.colorEditor, - left: 0, - right: 0, - top: 5 - }] - }, - height: 30 - }, { - el: { - type: "bi.absolute", - items: [{ - el: this.storeColors, - left: 5, - right: 5, - top: 5 - }] - }, - height: 30 - }, { - el: { - type: "bi.absolute", - items: [{ - el: this.colorPicker, - left: 5, - right: 5, - top: 5 - }] - }, - height: 65 - }, { - el: this.more, - height: 20 - }] - }) - }, - - setStoreColors: function (colors) { - if (BI.isArray(colors)) { - var items = BI.map(colors, function (i, color) { - return { - value: color - } - }); - BI.count(colors.length, 8, function (i) { - items.push({ - value: "", - disabled: true - }) - }); - this.storeColors.populate([items]); - } - }, - - setValue: function (color) { - this.colorEditor.setValue(color); - this.colorPicker.setValue(color); - this.storeColors.setValue(color); - }, - - getValue: function () { - return this.colorEditor.getValue(); - } -}); -BI.ColorChooserPopup.EVENT_VALUE_CHANGE = "ColorChooserPopup.EVENT_VALUE_CHANGE"; -BI.ColorChooserPopup.EVENT_CHANGE = "ColorChooserPopup.EVENT_CHANGE"; -BI.shortcut("bi.color_chooser_popup", BI.ColorChooserPopup);/** - * 选色控件 - * - * Created by GUY on 2015/11/17. - * @class BI.ColorChooserTrigger - * @extends BI.Trigger - */ -BI.ColorChooserTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - var conf = BI.ColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-color-chooser-trigger", - height: 30 - }) - }, - - _init: function () { - BI.ColorChooserTrigger.superclass._init.apply(this, arguments); - this.colorContainer = BI.createWidget({ - type: "bi.layout", - cls: "bi-card color-chooser-trigger-content" - }); - - var down = BI.createWidget({ - type: "bi.icon_button", - disableSelected: true, - cls: "icon-combo-down-icon trigger-triangle-font", - width: 12, - height: 8 - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.colorContainer, - left: 3, - right: 3, - top: 3, - bottom: 3 - }, { - el: down, - right: 3, - bottom: 3 - }] - }); - if (this.options.value) { - this.setValue(this.options.value); - } - }, - - setValue: function (color) { - BI.ColorChooserTrigger.superclass.setValue.apply(this, arguments); - if (color === "") { - this.colorContainer.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-background"); - } else if (color === "transparent") { - this.colorContainer.element.css("background-color", "").removeClass("auto-color-background").addClass("trans-color-background") - } else { - this.colorContainer.element.css({"background-color": color}).removeClass("auto-color-background").removeClass("trans-color-background"); - } - } -}); -BI.ColorChooserTrigger.EVENT_CHANGE = "ColorChooserTrigger.EVENT_CHANGE"; -BI.shortcut("bi.color_chooser_trigger", BI.ColorChooserTrigger);/** - * 简单选色控件按钮 - * - * Created by GUY on 2015/11/16. - * @class BI.ColorPickerButton - * @extends BI.BasicButton - */ -BI.ColorPickerButton = BI.inherit(BI.BasicButton, { - - _defaultConfig: function () { - var conf = BI.ColorPickerButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-color-picker-button bi-background bi-border-top bi-border-left" - }) - }, - - _init: function () { - BI.ColorPickerButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (o.value) { - this.element.css("background-color", o.value); - var name = this.getName(); - this.element.hover(function () { - self._createMask(); - if (self.isEnabled()) { - BI.Maskers.show(name); - } - }, function () { - if (!self.isSelected()) { - BI.Maskers.hide(name); - } - }); - } - }, - - _createMask: function () { - var o = this.options, name = this.getName(); - if (this.isEnabled() && !BI.Maskers.has(name)) { - var w = BI.Maskers.make(name, this, { - offset: { - left: -1, - top: -1, - right: -1, - bottom: -1 - } - }); - w.element.addClass("color-picker-button-mask").css("background-color", o.value); - } - }, - - setSelected: function (b) { - BI.ColorPickerButton.superclass.setSelected.apply(this, arguments); - if (!!b) { - this._createMask(); - } - BI.Maskers[!!b ? "show" : "hide"](this.getName()); - } -}); -BI.ColorPickerButton.EVENT_CHANGE = "ColorPickerButton.EVENT_CHANGE"; -BI.shortcut("bi.color_picker_button", BI.ColorPickerButton);/** - * 简单选色控件 - * - * Created by GUY on 2015/11/16. - * @class BI.ColorPicker - * @extends BI.Widget - */ -BI.ColorPicker = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ColorPicker.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-color-picker", - items: null - }) - }, - - _items: [ - [{ - value: "#ffffff" - }, { - value: "#f2f2f2" - }, { - value: "#e5e5e5" - }, { - value: "#d9d9d9" - }, { - value: "#cccccc" - }, { - value: "#bfbfbf" - }, { - value: "#b2b2b2" - }, { - value: "#a6a6a6" - }, { - value: "#999999" - }, { - value: "#8c8c8c" - }, { - value: "#808080" - }, { - value: "#737373" - }, { - value: "#666666" - }, { - value: "#4d4d4d" - }, { - value: "#333333" - }, { - value: "#000000" - }], - [{ - value: "#d8b5a6" - }, { - value: "#ff9e9a" - }, { - value: "#ffc17d" - }, { - value: "#f5e56b" - }, { - value: "#d8e698" - }, { - value: "#e0ebaf" - }, { - value: "#c3d825" - }, { - value: "#bce2e8" - }, { - value: "#85d3cd" - }, { - value: "#bce2e8" - }, { - value: "#a0d8ef" - }, { - value: "#89c3eb" - }, { - value: "#bbc8e6" - }, { - value: "#bbbcde" - }, { - value: "#d6b4cc" - }, { - value: "#fbc0d3" - }], - [{ - value: "#bb9581" - }, { - value: "#f37d79" - }, { - value: "#fba74f" - }, { - value: "#ffdb4f" - }, { - value: "#c7dc68" - }, { - value: "#b0ca71" - }, { - value: "#99ab4e" - }, { - value: "#84b9cb" - }, { - value: "#00a3af" - }, { - value: "#2ca9e1" - }, { - value: "#0095d9" - }, { - value: "#4c6cb3" - }, { - value: "#8491c3" - }, { - value: "#a59aca" - }, { - value: "#cc7eb1" - }, { - value: "#e89bb4" - }], - [{ - value: "#9d775f" - }, { - value: "#dd4b4b" - }, { - value: "#ef8b07" - }, { - value: "#fcc800" - }, { - value: "#aacf53" - }, { - value: "#82ae46" - }, { - value: "#69821b" - }, { - value: "#59b9c6" - }, { - value: "#2a83a2" - }, { - value: "#007bbb" - }, { - value: "#19448e" - }, { - value: "#274a78" - }, { - value: "#4a488e" - }, { - value: "#7058a3" - }, { - value: "#884898" - }, { - value: "#d47596" - }] - ], - - _init: function () { - BI.ColorPicker.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.colors = BI.createWidget({ - type: "bi.button_group", - element: this, - items: BI.createItems(o.items || this._items, { - type: "bi.color_picker_button", - once: false - }), - layouts: [{ - type: "bi.grid" - }] - }); - this.colors.on(BI.ButtonGroup.EVENT_CHANGE, function () { - self.fireEvent(BI.ColorPicker.EVENT_CHANGE, arguments); - }) - }, - - populate: function(items){ - var args =[].slice.call(arguments); - args[0] = BI.createItems(items, { - type: "bi.color_picker_button", - once: false - }); - this.colors.populate.apply(this.colors, args); - }, - - setValue: function (color) { - this.colors.setValue(color); - }, - - getValue: function () { - return this.colors.getValue(); - } -}); -BI.ColorPicker.EVENT_CHANGE = "ColorPicker.EVENT_CHANGE"; -BI.shortcut("bi.color_picker", BI.ColorPicker);/** - * 简单选色控件 - * - * Created by GUY on 2015/11/16. - * @class BI.ColorPickerEditor - * @extends BI.Widget - */ -BI.ColorPickerEditor = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.ColorPickerEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-color-picker-editor", - // width: 200, - height: 20 - }) - }, - - _init: function () { - BI.ColorPickerEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.colorShow = BI.createWidget({ - type: "bi.layout", - cls: "color-picker-editor-display bi-card", - height: 20 - }); - var RGB = BI.createWidgets(BI.createItems([{text: "R"}, {text: "G"}, {text: "B"}], { - type: "bi.label", - cls: "color-picker-editor-label", - width: 10, - height: 20 - })); - - var checker = function (v) { - return BI.isNumeric(v) && (v | 0) >= 0 && (v | 0) <= 255; - }; - var Ws = BI.createWidgets([{}, {}, {}], { - type: "bi.small_text_editor", - cls: "color-picker-editor-input", - validationChecker: checker, - errorText: BI.i18nText("BI-Color_Picker_Error_Text"), - allowBlank: true, - value: 255, - width: 32, - height: 20 - }); - BI.each(Ws, function (i, w) { - w.on(BI.TextEditor.EVENT_CHANGE, function () { - if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { - self.colorShow.element.css("background-color", self.getValue()); - self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); - } - }); - }); - this.R = Ws[0]; - this.G = Ws[1]; - this.B = Ws[2]; - - this.none = BI.createWidget({ - type: "bi.checkbox", - title: BI.i18nText("BI-Basic_Auto") - }); - this.none.on(BI.Checkbox.EVENT_CHANGE, function () { - if (this.isSelected()) { - self.lastColor = self.getValue(); - self.setValue(""); - } else { - self.setValue(self.lastColor || "#000000"); - } - if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { - self.colorShow.element.css("background-color", self.getValue()); - self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); - } - }); - - this.transparent = BI.createWidget({ - type: "bi.checkbox", - title: BI.i18nText("BI-Transparent_Color") - }); - this.transparent.on(BI.Checkbox.EVENT_CHANGE, function () { - if (this.isSelected()) { - self.lastColor = self.getValue(); - self.setValue("transparent"); - } else { - self.setValue(self.lastColor || "#000000"); - } - if (self.R.isValid() && self.G.isValid() && self.B.isValid()) { - self.colorShow.element.css("background-color", self.getValue()); - self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); - } - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.colorShow, - width: 'fill' - }, { - el: RGB[0], - lgap: 10, - width: 16 - }, { - el: this.R, - width: 32 - }, { - el: RGB[1], - lgap: 10, - width: 16 - }, { - el: this.G, - width: 32 - }, { - el: RGB[2], - lgap: 10, - width: 16 - }, { - el: this.B, - width: 32 - }, { - el: { - type: "bi.center_adapt", - items: [this.none] - }, - width: 18 - }, { - el: { - type: "bi.center_adapt", - items: [this.transparent] - }, - width: 18 - }] - }) - }, - - setValue: function (color) { - if (color === "transparent") { - this.transparent.setSelected(true); - this.none.setSelected(false); - this.R.setValue(""); - this.G.setValue(""); - this.B.setValue(""); - return; - } - if (!color) { - color = ""; - this.none.setSelected(true); - } else { - this.none.setSelected(false); - } - this.transparent.setSelected(false); - this.colorShow.element.css("background-color", color); - var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color)); - this.R.setValue(BI.isNull(json.r) ? "" : json.r); - this.G.setValue(BI.isNull(json.g) ? "" : json.g); - this.B.setValue(BI.isNull(json.b) ? "" : json.b); - }, - - getValue: function () { - if (this.transparent.isSelected()) { - return "transparent"; - } - return BI.DOM.rgb2hex(BI.DOM.json2rgb({ - r: this.R.getValue(), - g: this.G.getValue(), - b: this.B.getValue() - })) - } -}); -BI.ColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE"; -BI.shortcut("bi.color_picker_editor", BI.ColorPickerEditor);/** - * 选色控件 - * - * Created by GUY on 2015/11/16. - * @class BI.Farbtastic - * @extends BI.Widget - */ -BI.Farbtastic = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.Farbtastic.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-farbtastic", - width: 195, - height: 195 - }) - }, - - _init: function () { - BI.Farbtastic.superclass._init.apply(this, arguments); - }, - - mounted: function () { - var self = this; - this.farbtastic = $.farbtastic(this.element, function (v) { - self.fireEvent(BI.Farbtastic.EVENT_CHANGE, self.getValue(), self); - }); - }, - - setValue: function (color) { - this.farbtastic.setColor(color); - }, - - getValue: function () { - return this.farbtastic.color; - } -}); -BI.Farbtastic.EVENT_CHANGE = "Farbtastic.EVENT_CHANGE"; -BI.shortcut("bi.farbtastic", BI.Farbtastic);/** - * Farbtastic Color Picker 1.2 - * © 2008 Steven Wittens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -jQuery.fn.farbtastic = function (callback) { - $.farbtastic(this, callback); - return this; -}; - -jQuery.farbtastic = function (container, callback) { - var container = $(container).get(0); - return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); -} - -jQuery._farbtastic = function (container, callback) { - // Store farbtastic object - var fb = this; - - // Insert markup - $(container).html('
'); - var e = $('.farbtastic', container); - fb.wheel = $('.wheel', container).get(0); - // Dimensions - fb.radius = 84; - fb.square = 100; - fb.width = 194; - - // Fix background PNGs in IE6 - if (navigator.appVersion.match(/MSIE [0-6]\./)) { - $('*', e).each(function () { - if (this.currentStyle.backgroundImage != 'none') { - var image = this.currentStyle.backgroundImage; - image = this.currentStyle.backgroundImage.substring(5, image.length - 2); - $(this).css({ - 'backgroundImage': 'none', - 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" - }); - } - }); - } - - /** - * Link to the given element(s) or callback. - */ - fb.linkTo = function (callback) { - // Unbind previous nodes - if (typeof fb.callback == 'object') { - $(fb.callback).unbind('keyup', fb.updateValue); - } - - // Reset color - fb.color = null; - - // Bind callback or elements - if (typeof callback == 'function') { - fb.callback = callback; - } - else if (typeof callback == 'object' || typeof callback == 'string') { - fb.callback = $(callback); - fb.callback.bind('keyup', fb.updateValue); - if (fb.callback.get(0).value) { - fb.setColor(fb.callback.get(0).value); - } - } - return this; - } - fb.updateValue = function (event) { - if (this.value && this.value != fb.color) { - fb.setColor(this.value); - } - } - - /** - * Change color with HTML syntax #123456 - */ - fb.setColor = function (color) { - var unpack = fb.unpack(color); - if (fb.color != color && unpack) { - fb.color = color; - fb.rgb = unpack; - fb.hsl = fb.RGBToHSL(fb.rgb); - fb.updateDisplay(); - } - return this; - } - - /** - * Change color with HSL triplet [0..1, 0..1, 0..1] - */ - fb.setHSL = function (hsl) { - fb.hsl = hsl; - fb.rgb = fb.HSLToRGB(hsl); - fb.color = fb.pack(fb.rgb); - fb.updateDisplay(); - return this; - } - - ///////////////////////////////////////////////////// - - /** - * Retrieve the coordinates of the given event relative to the center - * of the widget. - */ - fb.widgetCoords = function (event) { - var x, y; - var el = event.target || event.srcElement; - var reference = fb.wheel; - - if (typeof event.offsetX != 'undefined') { - // Use offset coordinates and find common offsetParent - var pos = { x: event.offsetX, y: event.offsetY }; - - // Send the coordinates upwards through the offsetParent chain. - var e = el; - while (e) { - e.mouseX = pos.x; - e.mouseY = pos.y; - pos.x += e.offsetLeft; - pos.y += e.offsetTop; - e = e.offsetParent; - } - - // Look for the coordinates starting from the wheel widget. - var e = reference; - var offset = { x: 0, y: 0 } - while (e) { - if (typeof e.mouseX != 'undefined') { - x = e.mouseX - offset.x; - y = e.mouseY - offset.y; - break; - } - offset.x += e.offsetLeft; - offset.y += e.offsetTop; - e = e.offsetParent; - } - - // Reset stored coordinates - e = el; - while (e) { - e.mouseX = undefined; - e.mouseY = undefined; - e = e.offsetParent; - } - } - else { - // Use absolute coordinates - var pos = fb.absolutePosition(reference); - x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x; - y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y; - } - // Subtract distance to middle - return { x: x - fb.width / 2, y: y - fb.width / 2 }; - } - - /** - * Mousedown handler - */ - fb.click = function (event) { - // Capture mouse - // if (!document.dragging) { - // $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); - // document.dragging = true; - // } - - // Check which area is being dragged - var pos = fb.widgetCoords(event); - fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square; - - // Process - fb.mousemove(event); - return false; - } - - /** - * Mousemove handler - */ - fb.mousemove = function (event) { - // Get coordinates relative to color picker center - var pos = fb.widgetCoords(event); - - // Set new HSL parameters - if (fb.circleDrag) { - var hue = Math.atan2(pos.x, -pos.y) / 6.28; - if (hue < 0) hue += 1; - fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]); - } - else { - var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5)); - var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5)); - fb.setHSL([fb.hsl[0], sat, lum]); - } - return false; - } - - /** - * Mouseup handler - */ - // fb.mouseup = function () { - // // Uncapture mouse - // $(document).unbind('mousemove', fb.mousemove); - // $(document).unbind('mouseup', fb.mouseup); - // document.dragging = false; - // } - - /** - * Update the markers and styles - */ - fb.updateDisplay = function () { - // Markers - var angle = fb.hsl[0] * 6.28; - $('.h-marker', e).css({ - left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px', - top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px' - }); - - $('.sl-marker', e).css({ - left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px', - top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px' - }); - - // Saturation/Luminance gradient - $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5]))); - - // Linked elements or callback - if (typeof fb.callback == 'object') { - // Set background/foreground color - $(fb.callback).css({ - backgroundColor: fb.color, - color: fb.hsl[2] > 0.5 ? '#000' : '#fff' - }); - - // Change linked value - $(fb.callback).each(function() { - if (this.value && this.value != fb.color) { - this.value = fb.color; - } - }); - } - else if (typeof fb.callback == 'function') { - fb.callback.call(fb, fb.color); - } - } - - /** - * Get absolute position of element - */ - fb.absolutePosition = function (el) { - var r = { x: el.offsetLeft, y: el.offsetTop }; - // Resolve relative to offsetParent - if (el.offsetParent) { - var tmp = fb.absolutePosition(el.offsetParent); - r.x += tmp.x; - r.y += tmp.y; - } - return r; - }; - - /* Various color utility functions */ - fb.pack = function (rgb) { - var r = Math.round(rgb[0] * 255); - var g = Math.round(rgb[1] * 255); - var b = Math.round(rgb[2] * 255); - return '#' + (r < 16 ? '0' : '') + r.toString(16) + - (g < 16 ? '0' : '') + g.toString(16) + - (b < 16 ? '0' : '') + b.toString(16); - } - - fb.unpack = function (color) { - if (color.length == 7) { - return [parseInt('0x' + color.substring(1, 3)) / 255, - parseInt('0x' + color.substring(3, 5)) / 255, - parseInt('0x' + color.substring(5, 7)) / 255]; - } - else if (color.length == 4) { - return [parseInt('0x' + color.substring(1, 2)) / 15, - parseInt('0x' + color.substring(2, 3)) / 15, - parseInt('0x' + color.substring(3, 4)) / 15]; - } - } - - fb.HSLToRGB = function (hsl) { - var m1, m2, r, g, b; - var h = hsl[0], s = hsl[1], l = hsl[2]; - m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s; - m1 = l * 2 - m2; - return [this.hueToRGB(m1, m2, h+0.33333), - this.hueToRGB(m1, m2, h), - this.hueToRGB(m1, m2, h-0.33333)]; - } - - fb.hueToRGB = function (m1, m2, h) { - h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h); - if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; - if (h * 2 < 1) return m2; - if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; - return m1; - } - - fb.RGBToHSL = function (rgb) { - var min, max, delta, h, s, l; - var r = rgb[0], g = rgb[1], b = rgb[2]; - min = Math.min(r, Math.min(g, b)); - max = Math.max(r, Math.max(g, b)); - delta = max - min; - l = (min + max) / 2; - s = 0; - if (l > 0 && l < 1) { - s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); - } - h = 0; - if (delta > 0) { - if (max == r && max != g) h += (g - b) / delta; - if (max == g && max != b) h += (2 + (b - r) / delta); - if (max == b && max != r) h += (4 + (r - g) / delta); - h /= 6; - } - return [h, s, l]; - } - - // Install mousedown handler (the others are set on the document on-demand) - $('*', e).click(fb.click); - - // Init color - fb.setColor('#000000'); - - // Set linked elements/callback - if (callback) { - fb.linkTo(callback); - } -}/** - * Created by GUY on 2017/2/8. - * - * @class BI.BubbleCombo - * @extends BI.Widget - */ -BI.BubbleCombo = BI.inherit(BI.Widget, { - _const: { - TRIANGLE_LENGTH: 6 - }, - _defaultConfig: function () { - return BI.extend(BI.BubbleCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-bubble-combo", - trigger: "click", - toggle: true, - direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right - isDefaultInit: false, - destroyWhenHide: false, - isNeedAdjustHeight: true,//是否需要高度调整 - isNeedAdjustWidth: true, - stopPropagation: false, - adjustLength: 0,//调整的距离 - // adjustXOffset: 0, - // adjustYOffset: 10, - hideChecker: BI.emptyFn, - offsetStyle: "left", //left,right,center - el: {}, - popup: {} - }) - }, - _init: function () { - BI.BubbleCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - trigger: o.trigger, - toggle: o.toggle, - direction: o.direction, - isDefaultInit: o.isDefaultInit, - destroyWhenHide: o.destroyWhenHide, - isNeedAdjustHeight: o.isNeedAdjustHeight, - isNeedAdjustWidth: o.isNeedAdjustWidth, - adjustLength: this._getAdjustLength(), - stopPropagation: o.stopPropagation, - adjustXOffset: 0, - adjustYOffset: 0, - hideChecker: o.hideChecker, - offsetStyle: o.offsetStyle, - el: o.el, - popup: BI.extend({ - type: "bi.bubble_popup_view" - }, o.popup) - }); - this.combo.on(BI.Combo.EVENT_TRIGGER_CHANGE, function () { - self.fireEvent(BI.BubbleCombo.EVENT_TRIGGER_CHANGE, arguments); - }); - this.combo.on(BI.Combo.EVENT_CHANGE, function () { - self.fireEvent(BI.BubbleCombo.EVENT_CHANGE, arguments); - }); - this.combo.on(BI.Combo.EVENT_EXPAND, function () { - self.fireEvent(BI.BubbleCombo.EVENT_EXPAND, arguments); - }); - this.combo.on(BI.Combo.EVENT_COLLAPSE, function () { - self.fireEvent(BI.BubbleCombo.EVENT_COLLAPSE, arguments); - }); - this.combo.on(BI.Combo.EVENT_AFTER_INIT, function () { - self.fireEvent(BI.BubbleCombo.EVENT_AFTER_INIT, arguments); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, arguments); - }); - this.combo.on(BI.Combo.EVENT_AFTER_POPUPVIEW, function () { - self._showTriangle(); - self.fireEvent(BI.BubbleCombo.EVENT_AFTER_POPUPVIEW, arguments); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self._hideTriangle(); - self.fireEvent(BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW, arguments); - }); - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - self.fireEvent(BI.BubbleCombo.EVENT_AFTER_HIDEVIEW, arguments); - }); - }, - - _getAdjustLength: function () { - return this._const.TRIANGLE_LENGTH + this.options.adjustLength; - }, - - _createTriangle: function (direction) { - var pos = {}, op = {}; - var adjustLength = this.options.adjustLength; - var offset = this.element.offset(); - var left = offset.left, right = offset.left + this.element.outerWidth(); - var top = offset.top, bottom = offset.top + this.element.outerHeight(); - switch (direction) { - case "left": - pos = { - top: top, - height: this.element.outerHeight(), - left: left - adjustLength - this._const.TRIANGLE_LENGTH - }; - op = {width: this._const.TRIANGLE_LENGTH}; - break; - case "right": - pos = { - top: top, - height: this.element.outerHeight(), - left: right + adjustLength - }; - op = {width: this._const.TRIANGLE_LENGTH}; - break; - case "top": - pos = { - left: left, - width: this.element.outerWidth(), - top: top - adjustLength - this._const.TRIANGLE_LENGTH - }; - op = {height: this._const.TRIANGLE_LENGTH}; - break; - case "bottom": - pos = { - left: left, - width: this.element.outerWidth(), - top: bottom + adjustLength - }; - op = {height: this._const.TRIANGLE_LENGTH}; - break; - default: - break; - } - this.triangle && this.triangle.destroy(); - this.triangle = BI.createWidget(op, { - type: "bi.center_adapt", - cls: "button-combo-triangle-wrapper", - items: [{ - type: "bi.layout", - cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" - }] - }); - pos.el = this.triangle; - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [pos] - }) - }, - - _createLeftTriangle: function () { - this._createTriangle("left"); - }, - - _createRightTriangle: function () { - this._createTriangle("right"); - }, - - _createTopTriangle: function () { - this._createTriangle("top"); - }, - - _createBottomTriangle: function () { - this._createTriangle("bottom"); - }, - - _showTriangle: function () { - var pos = this.combo.getPopupPosition(); - switch (pos.dir) { - case "left,top": - case "left,bottom": - this._createLeftTriangle(); - this.combo.getView().showLine("right"); - break; - case "right,top": - case "right,bottom": - this._createRightTriangle(); - this.combo.getView().showLine("left"); - break; - case "top,left": - case "top,right": - this._createTopTriangle(); - this.combo.getView().showLine("bottom"); - break; - case "bottom,left": - case "bottom,right": - this._createBottomTriangle(); - this.combo.getView().showLine("top"); - break; - } - }, - - _hideTriangle: function () { - this.triangle && this.triangle.destroy(); - this.triangle = null; - this.combo.getView() && this.combo.getView().hideLine(); - }, - - hideView: function () { - this._hideTriangle(); - this.combo && this.combo.hideView(); - }, - - showView: function () { - this.combo && this.combo.showView(); - }, - - isViewVisible: function () { - return this.combo.isViewVisible(); - } -}); - -BI.BubbleCombo.EVENT_TRIGGER_CHANGE = "EVENT_TRIGGER_CHANGE"; -BI.BubbleCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.BubbleCombo.EVENT_EXPAND = "EVENT_EXPAND"; -BI.BubbleCombo.EVENT_COLLAPSE = "EVENT_COLLAPSE"; -BI.BubbleCombo.EVENT_AFTER_INIT = "EVENT_AFTER_INIT"; - - -BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.BubbleCombo.EVENT_AFTER_POPUPVIEW = "EVENT_AFTER_POPUPVIEW"; -BI.BubbleCombo.EVENT_BEFORE_HIDEVIEW = "EVENT_BEFORE_HIDEVIEW"; -BI.BubbleCombo.EVENT_AFTER_HIDEVIEW = "EVENT_AFTER_HIDEVIEW"; -BI.shortcut("bi.bubble_combo", BI.BubbleCombo);/** - * Created by GUY on 2017/2/8. - * - * @class BI.BubblePopupView - * @extends BI.PopupView - */ -BI.BubblePopupView = BI.inherit(BI.PopupView, { - _defaultConfig: function () { - var config = BI.BubblePopupView.superclass._defaultConfig.apply(this, arguments); - return BI.extend(config, { - baseCls: config.baseCls + " bi-bubble-popup-view" - }) - }, - _init: function () { - BI.BubblePopupView.superclass._init.apply(this, arguments); - }, - - showLine: function (direction) { - var pos = {}, op = {}; - switch (direction) { - case "left": - pos = { - top: 0, - bottom: 0, - left: -1 - }; - op = {width: 3}; - break; - case "right": - pos = { - top: 0, - bottom: 0, - right: -1 - }; - op = {width: 3}; - break; - case "top": - pos = { - left: 0, - right: 0, - top: -1 - }; - op = {height: 3}; - break; - case "bottom": - pos = { - left: 0, - right: 0, - bottom: -1 - }; - op = {height: 3}; - break; - default: - break; - } - this.line = BI.createWidget(op, { - type: "bi.layout", - cls: "bubble-popup-line bi-high-light-background" - }); - pos.el = this.line; - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [pos] - }) - }, - - hideLine: function () { - this.line && this.line.destroy(); - } -}); - -BI.shortcut("bi.bubble_popup_view", BI.BubblePopupView); - -/** - * Created by GUY on 2017/2/8. - * - * @class BI.BubblePopupBarView - * @extends BI.BubblePopupView - */ -BI.BubblePopupBarView = BI.inherit(BI.BubblePopupView, { - _defaultConfig: function () { - return BI.extend(BI.BubblePopupBarView.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-bubble-bar-popup-view", - buttons: [{value: BI.i18nText(BI.i18nText("BI-Basic_Sure"))}, {value: BI.i18nText("BI-Basic_Cancel"), level: "ignore"}] - }) - }, - _init: function () { - BI.BubblePopupBarView.superclass._init.apply(this, arguments); - }, - _createToolBar: function () { - var o = this.options, self = this; - - var items = []; - BI.each(o.buttons.reverse(), function (i, buttonOpt) { - if(BI.isWidget(buttonOpt)){ - items.push(buttonOpt); - }else{ - items.push(BI.extend({ - type: 'bi.button', - height: 30, - handler: function (v) { - self.fireEvent(BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, v); - } - }, buttonOpt)) - } - }); - return BI.createWidget({ - type: 'bi.right_vertical_adapt', - height: 40, - hgap: 10, - bgap: 10, - items: items - }); - } -}); -BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; -BI.shortcut("bi.bubble_bar_popup_view", BI.BubblePopupBarView);/** - * Created by Young's on 2016/4/28. - */ -BI.EditorIconCheckCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.EditorIconCheckCombo.superclass._defaultConfig.apply(this, arguments), { - baseClass: "bi-check-editor-combo", - width: 100, - height: 24, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: true, - watermark: "", - errorText: "" - }) - }, - - _init: function () { - BI.EditorIconCheckCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.editor_trigger", - items: o.items, - height: o.height, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.trigger.on(BI.EditorTrigger.EVENT_CHANGE, function () { - self.popup.setValue(this.getValue()); - self.fireEvent(BI.EditorIconCheckCombo.EVENT_CHANGE); - }); - this.popup = BI.createWidget({ - type: "bi.text_value_check_combo_popup", - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.editorIconCheckCombo.hideView(); - self.fireEvent(BI.EditorIconCheckCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editorIconCheckCombo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 300 - } - }); - }, - - setValue: function (v) { - this.editorIconCheckCombo.setValue(v); - }, - - getValue: function () { - return this.trigger.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.editorIconCheckCombo.populate(items); - } -}); -BI.EditorIconCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.editor_icon_check_combo", BI.EditorIconCheckCombo);/** - * Created by GUY on 2016/2/2. - * - * @class BI.IconCombo - * @extend BI.Widget - */ -BI.IconCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.IconCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-icon-combo", - width: 24, - height: 24, - iconClass: "", - el: {}, - popup: {}, - minWidth: 100, - maxWidth: 'auto', - maxHeight: 300, - direction: "bottom", - adjustLength: 3,//调整的距离 - adjustXOffset: 0, - adjustYOffset: 0, - offsetStyle: "left", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE - }) - }, - - _init: function () { - BI.IconCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget(o.el, { - type: "bi.icon_combo_trigger", - iconClass: o.iconClass, - title: o.title, - items: o.items, - width: o.width, - height: o.height, - iconWidth: o.iconWidth, - iconHeight: o.iconHeight - }); - this.popup = BI.createWidget(o.popup, { - type: "bi.icon_combo_popup", - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.iconCombo.hideView(); - self.fireEvent(BI.IconCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.iconCombo = BI.createWidget({ - type: "bi.combo", - element: this, - direction: o.direction, - trigger: o.trigger, - container: o.container, - adjustLength: o.adjustLength, - adjustXOffset: o.adjustXOffset, - adjustYOffset: o.adjustYOffset, - offsetStyle: o.offsetStyle, - el: this.trigger, - popup: { - el: this.popup, - maxWidth: o.maxWidth, - maxHeight: o.maxHeight, - minWidth: o.minWidth - } - }); - }, - - showView: function () { - this.iconCombo.showView(); - }, - - hideView: function () { - this.iconCombo.hideView(); - }, - - setValue: function (v) { - this.iconCombo.setValue(v); - }, - - getValue: function () { - return this.iconCombo.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.iconCombo.populate(items); - } -}); -BI.IconCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_combo", BI.IconCombo);/** - * Created by GUY on 2016/2/2. - * - * @class BI.IconComboPopup - * @extend BI.Pane - */ -BI.IconComboPopup = BI.inherit(BI.Pane, { - _defaultConfig: function () { - return BI.extend(BI.IconComboPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi.icon-combo-popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE - }); - }, - - _init: function () { - BI.IconComboPopup.superclass._init.apply(this, arguments); - var o = this.options, self = this; - this.popup = BI.createWidget({ - type: "bi.button_group", - items: BI.createItems(o.items, { - type: "bi.single_select_icon_text_item", - height: 30 - }), - chooseType: o.chooseType, - layouts: [{ - type: "bi.vertical" - }] - }); - - this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.IconComboPopup.EVENT_CHANGE, val, obj); - } - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.popup] - }); - }, - - populate: function (items) { - BI.IconComboPopup.superclass.populate.apply(this, arguments); - items = BI.createItems(items, { - type: "bi.single_select_icon_text_item", - height: 30 - }); - this.popup.populate(items); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - this.popup.setValue(v); - } - -}); -BI.IconComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_combo_popup", BI.IconComboPopup);/** - * Created by GUY on 2016/2/2. - * - * @class BI.IconComboTrigger - * @extend BI.Widget - */ -BI.IconComboTrigger = BI.inherit(BI.Trigger, { - _defaultConfig: function () { - return BI.extend(BI.IconComboTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-icon-combo-trigger", - el: {}, - items: [], - iconClass: "", - width: 25, - height: 25, - isShowDown: true - }); - }, - - _init: function () { - BI.IconComboTrigger.superclass._init.apply(this, arguments); - var o = this.options, self = this; - this.button = BI.createWidget(o.el, { - type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + o.iconClass, - disableSelected: true, - width: o.width, - height: o.height, - iconWidth: o.iconWidth, - iconHeight: o.iconHeight - }); - this.down = BI.createWidget({ - type: "bi.icon_button", - disableSelected: true, - cls: "icon-combo-down-icon trigger-triangle-font", - width: 12, - height: 8 - }); - this.down.setVisible(o.isShowDown); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.button, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: this.down, - right: 0, - bottom: 0 - }] - }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } - }, - - populate: function (items) { - var o = this.options; - this.options.items = items || []; - this.button.setIcon(o.iconClass); - this.button.setSelected(false); - this.down.setSelected(false); - }, - - setValue: function (v) { - BI.IconComboTrigger.superclass.setValue.apply(this, arguments); - var o = this.options; - var iconClass = ""; - v = BI.isArray(v) ? v[0] : v; - if (BI.any(this.options.items, function (i, item) { - if (v === item.value) { - iconClass = item.iconClass; - return true; - } - })) { - this.button.setIcon(iconClass); - this.button.setSelected(true); - this.down.setSelected(true); - } else { - this.button.setIcon(o.iconClass); - this.button.setSelected(false); - this.down.setSelected(false); - } - } -}); -BI.IconComboTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_combo_trigger", BI.IconComboTrigger);/** - * Created by Windy on 2017/12/12. - * combo : icon + text + icon, popup : icon + text - */ -BI.IconTextValueCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { - baseClass: "bi-icon-text-value-combo", - height: 30, - value: "", - el: {} - }); - }, - - _init: function () { - BI.IconTextValueCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget(o.el, { - type: "bi.select_icon_text_trigger", - items: o.items, - height: o.height - }); - this.popup = BI.createWidget({ - type: "bi.icon_text_value_combo_popup", - items: o.items - }); - this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.textIconCombo.hideView(); - self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.textIconCombo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 300 - } - }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } - }, - - setValue: function (v) { - this.textIconCombo.setValue(v); - }, - - getValue: function () { - return this.textIconCombo.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.textIconCombo.populate(items); - } -}); -BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo);/** - * Created by Windy on 2017/12/12. - */ -BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { - _defaultConfig: function () { - return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-icon-text-icon-popup" - }); - }, - - _init: function () { - BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); - var o = this.options, self = this; - this.popup = BI.createWidget({ - type: "bi.button_group", - items: BI.createItems(o.items, { - type: "bi.single_select_icon_text_item", - height: 30 - }), - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - layouts: [{ - type: "bi.vertical" - }] - }); - - this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); - } - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.popup] - }); - }, - - populate: function (items) { - BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); - items = BI.createItems(items, { - type: "bi.single_select_icon_text_item", - height: 30 - }); - this.popup.populate(items); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - this.popup.setValue(v); - } - -}); -BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** - * 单选combo - * - * @class BI.StaticCombo - * @extend BI.Widget - */ -BI.StaticCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.StaticCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-static-combo", - height: 24, - text: "", - el: {}, - items: [], - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE - }) - }, - - _init: function () { - BI.StaticCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget(o.el, { - type: "bi.text_icon_item", - cls: "bi-select-text-trigger bi-border pull-down-font", - text: o.text, - readonly: true, - textLgap: 5, - height: o.height - 2 - }); - this.popup = BI.createWidget({ - type: "bi.text_value_combo_popup", - textAlign: o.textAlign, - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { - self.combo.hideView(); - self.fireEvent(BI.StaticCombo.EVENT_CHANGE, arguments); - }); - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup - } - }); - }, - - populate: function (items) { - this.combo.populate(items); - }, - - setValue: function (v) { - this.combo.setValue(v); - }, - - getValue: function () { - return this.combo.getValue(); - } -}); -BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.static_combo", BI.StaticCombo);/** - * @class BI.TextValueCheckCombo - * @extend BI.Widget - * combo : text + icon, popup : check + text - */ -BI.TextValueCheckCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.TextValueCheckCombo.superclass._defaultConfig.apply(this, arguments), { - baseClass: "bi-text-value-check-combo", - width: 100, - height: 24, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - value: "" - }); - }, - - _init: function () { - BI.TextValueCheckCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.select_text_trigger", - items: o.items, - height: o.height - }); - this.popup = BI.createWidget({ - type: "bi.text_value_check_combo_popup", - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.textIconCheckCombo.hideView(); - self.fireEvent(BI.TextValueCheckCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.textIconCheckCombo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 300 - } - }); - - if (BI.isKey(o.value)) { - this.setValue(o.value); - } - }, - - setTitle: function (title) { - this.trigger.setTitle(title); - }, - - setValue: function (v) { - this.textIconCheckCombo.setValue(v); - }, - - setWarningTitle: function (title) { - this.trigger.setWarningTitle(title); - }, - - getValue: function () { - return this.textIconCheckCombo.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.textIconCheckCombo.populate(items); - } -}); -BI.TextValueCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.text_value_check_combo", BI.TextValueCheckCombo);/** - * @class BI.SmallTextValueCheckCombo - * @extend BI.Widget - * combo : text + icon, popup : check + text - */ -BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.SmallTextValueCheckCombo.superclass._defaultConfig.apply(this, arguments), { - width: 100, - height: 24, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - text: "" - }) - }, - - _init: function () { - BI.SmallTextValueCheckCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.small_select_text_trigger", - items: o.items, - height: o.height, - text: o.text - }); - this.popup = BI.createWidget({ - type: "bi.text_value_check_combo_popup", - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueCheckComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.SmallTextIconCheckCombo.hideView(); - self.fireEvent(BI.SmallTextValueCheckCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.SmallTextIconCheckCombo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 300 - } - }); - }, - - setValue: function (v) { - this.SmallTextIconCheckCombo.setValue(v); - }, - - getValue: function () { - return this.SmallTextIconCheckCombo.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.SmallTextIconCheckCombo.populate(items); - } -}); -BI.SmallTextValueCheckCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.small_text_value_check_combo", BI.SmallTextValueCheckCombo);BI.TextValueCheckComboPopup = BI.inherit(BI.Pane, { - _defaultConfig: function () { - return BI.extend(BI.TextValueCheckComboPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-text-icon-popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE - }); - }, - - _init: function () { - BI.TextValueCheckComboPopup.superclass._init.apply(this, arguments); - var o = this.options, self = this; - this.popup = BI.createWidget({ - type: "bi.button_group", - items: this._formatItems(o.items), - chooseType: o.chooseType, - layouts: [{ - type: "bi.vertical" - }] - }); - - this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.TextValueCheckComboPopup.EVENT_CHANGE, val, obj); - } - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.popup] - }); - }, - - _formatItems: function (items) { - return BI.map(items, function (i, item) { - return BI.extend({ - type: "bi.icon_text_item", - cls: "item-check-font bi-list-item", - height: 30 - }, item); - }); - }, - - populate: function (items) { - BI.TextValueCheckComboPopup.superclass.populate.apply(this, arguments); - this.popup.populate(this._formatItems(items)); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - this.popup.setValue(v); - } - -}); -BI.TextValueCheckComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.text_value_check_combo_popup", BI.TextValueCheckComboPopup);/** - * @class BI.TextValueCombo - * @extend BI.Widget - * combo : text + icon, popup : text - * 参见场景dashboard布局方式选择 - */ -BI.TextValueCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), { - baseClass: "bi-text-value-combo", - height: 30, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - value: "", - el: {} - }); - }, - - _init: function () { - BI.TextValueCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget(o.el, { - type: "bi.select_text_trigger", - items: o.items, - height: o.height - }); - this.popup = BI.createWidget({ - type: "bi.text_value_combo_popup", - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.textIconCombo.hideView(); - self.fireEvent(BI.TextValueCombo.EVENT_CHANGE, arguments); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.textIconCombo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 300 - } - }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } - }, - - setValue: function (v) { - this.textIconCombo.setValue(v); - }, - - getValue: function () { - return this.textIconCombo.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.textIconCombo.populate(items); - } -}); -BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.text_value_combo", BI.TextValueCombo);/** - * @class BI.SmallTextValueCombo - * @extend BI.Widget - * combo : text + icon, popup : text - * 参见场景dashboard布局方式选择 - */ -BI.SmallTextValueCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.SmallTextValueCombo.superclass._defaultConfig.apply(this, arguments), { - width: 100, - height: 24, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - el: {}, - text: "" - }) - }, - - _init: function () { - BI.SmallTextValueCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget(o.el, { - type: "bi.small_select_text_trigger", - items: o.items, - height: o.height, - text: o.text - }); - this.popup = BI.createWidget({ - type: "bi.text_value_combo_popup", - chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.SmallTextValueCombo.hideView(); - self.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.SmallTextValueCombo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 300 - } - }); - }, - - setValue: function (v) { - this.SmallTextValueCombo.setValue(v); - }, - - getValue: function () { - return this.SmallTextValueCombo.getValue(); - }, - - populate: function (items) { - this.options.items = items; - this.SmallTextValueCombo.populate(items); - } -}); -BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueComboPopup = BI.inherit(BI.Pane, { - _defaultConfig: function () { - return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-text-icon-popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE - }); - }, - - _init: function () { - BI.TextValueComboPopup.superclass._init.apply(this, arguments); - var o = this.options, self = this; - this.popup = BI.createWidget({ - type: "bi.button_group", - items: BI.createItems(o.items, { - type: "bi.single_select_item", - textAlign: o.textAlign, - height: 30 - }), - chooseType: o.chooseType, - layouts: [{ - type: "bi.vertical" - }] - }); - - this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); - } - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.popup] - }); - }, - - populate: function (items) { - BI.TextValueComboPopup.superclass.populate.apply(this, arguments); - items = BI.createItems(items, { - type: "bi.single_select_item", - height: 30 - }); - this.popup.populate(items); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - this.popup.setValue(v); - } - -}); -BI.TextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.text_value_combo_popup", BI.TextValueComboPopup);/** - * @class BI.TextValueDownListCombo - * @extend BI.Widget - */ -BI.TextValueDownListCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.TextValueDownListCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-text-value-down-list-combo", - height: 30 - }) - }, - - _init: function () { - BI.TextValueDownListCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this._createValueMap(); - - this.trigger = BI.createWidget({ - type: "bi.down_list_select_text_trigger", - height: o.height, - items: o.items - }); - - this.combo = BI.createWidget({ - type: "bi.down_list_combo", - element: this, - chooseType: BI.Selection.Single, - adjustLength: 2, - height: o.height, - el: this.trigger, - items: BI.deepClone(o.items) - }); - - this.combo.on(BI.DownListCombo.EVENT_CHANGE, function () { - self.setValue(self.combo.getValue()[0].value); - self.fireEvent(BI.TextValueDownListCombo.EVENT_CHANGE); - }); - - this.combo.on(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, function () { - self.setValue(self.combo.getValue()[0].childValue); - self.fireEvent(BI.TextValueDownListCombo.EVENT_CHANGE); - }); - }, - - _createValueMap: function () { - var self = this; - this.valueMap = {}; - BI.each(BI.flatten(this.options.items), function (idx, item) { - if (BI.has(item, "el")) { - BI.each(item.children, function (id, it) { - self.valueMap[it.value] = {value: item.el.value, childValue: it.value} - }); - } else { - self.valueMap[item.value] = {value: item.value}; - } - }); - }, - - setValue: function (v) { - v = this.valueMap[v]; - this.combo.setValue([v]); - this.trigger.setValue(v.childValue || v.value); - }, - - getValue: function () { - var v = this.combo.getValue()[0]; - return [v.childValue || v.value]; - }, - - populate: function (items) { - this.options.items = BI.flatten(items); - this.combo.populate(items); - this._createValueMap(); - } -}); -BI.TextValueDownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.text_value_down_list_combo", BI.TextValueDownListCombo);/** - * 选择字段trigger, downlist专用 - * 显示形式为 父亲值(儿子值) - * - * @class BI.DownListSelectTextTrigger - * @extends BI.Trigger - */ -BI.DownListSelectTextTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.DownListSelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-down-list-select-text-trigger", - height: 24, - text: "" - }); - }, - - _init: function () { - BI.DownListSelectTextTrigger.superclass._init.apply(this, arguments); - var o = this.options; - this.trigger = BI.createWidget({ - type: "bi.select_text_trigger", - element: this, - height: o.height, - items: this._formatItemArray(o.items), - text: o.text - }); - }, - - _formatItemArray: function(){ - var sourceArray = BI.flatten(BI.deepClone(this.options.items)); - var targetArray = []; - BI.each(sourceArray, function(idx, item){ - if(BI.has(item, "el")){ - BI.each(item.children, function(id, it){ - it.text = item.el.text + "(" + it.text + ")"; - }); - targetArray = BI.concat(targetArray, item.children); - }else{ - targetArray.push(item); - } - }); - return targetArray; - }, - - setValue: function (vals) { - this.trigger.setValue(vals); - }, - - populate: function (items) { - this.trigger.populate(this._formatItemArray(items)); - } -}); -BI.shortcut("bi.down_list_select_text_trigger", BI.DownListSelectTextTrigger);/** - * 有清楚按钮的文本框 - * Created by GUY on 2015/9/29. - * @class BI.SmallTextEditor - * @extends BI.SearchEditor - */ -BI.ClearEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.ClearEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-clear-editor", - height: 24, - errorText: "", - watermark: "", - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn - }); - }, - _init: function () { - BI.ClearEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - watermark: o.watermark, - allowBlank: true, - errorText: o.errorText, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker - }); - this.clear = BI.createWidget({ - type: "bi.icon_button", - stopEvent: true, - cls: "search-close-h-font" - }); - this.clear.on(BI.IconButton.EVENT_CHANGE, function () { - self.setValue(""); - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT); - self.fireEvent(BI.ClearEditor.EVENT_CLEAR); - }); - BI.createWidget({ - element: this, - type: "bi.htape", - items: [ - { - el: this.editor - }, - { - el: this.clear, - width: 25 - }] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.ClearEditor.EVENT_FOCUS); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.ClearEditor.EVENT_BLUR); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.ClearEditor.EVENT_CLICK); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self._checkClear(); - self.fireEvent(BI.ClearEditor.EVENT_CHANGE); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.ClearEditor.EVENT_KEY_DOWN, v); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.ClearEditor.EVENT_SPACE) - }); - this.editor.on(BI.Editor.EVENT_BACKSPACE, function () { - self.fireEvent(BI.ClearEditor.EVENT_BACKSPACE) - }); - - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.ClearEditor.EVENT_VALID) - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self.fireEvent(BI.ClearEditor.EVENT_ERROR) - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.ClearEditor.EVENT_ENTER); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.ClearEditor.EVENT_RESTRICT) - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self._checkClear(); - self.fireEvent(BI.ClearEditor.EVENT_EMPTY) - }); - this.editor.on(BI.Editor.EVENT_REMOVE, function () { - self.fireEvent(BI.ClearEditor.EVENT_REMOVE) - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self.fireEvent(BI.ClearEditor.EVENT_CONFIRM) - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.ClearEditor.EVENT_START); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.ClearEditor.EVENT_PAUSE); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.ClearEditor.EVENT_STOP); - }); - - this.clear.invisible(); - }, - - _checkClear: function () { - if (!this.getValue()) { - this.clear.invisible(); - } else { - this.clear.visible(); - } - }, - - focus: function () { - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - }, - - getValue: function () { - if (this.isValid()) { - var res = this.editor.getValue().match(/[\S]+/g); - return BI.isNull(res) ? "" : res[res.length - 1]; - } - }, - - setValue: function (v) { - this.editor.setValue(v); - if (BI.isKey(v)) { - this.clear.visible(); - } - }, - - isValid: function () { - return this.editor.isValid(); - } -}); -BI.ClearEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.ClearEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.ClearEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.ClearEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.ClearEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.ClearEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.ClearEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE"; -BI.ClearEditor.EVENT_CLEAR = "EVENT_CLEAR"; - -BI.ClearEditor.EVENT_START = "EVENT_START"; -BI.ClearEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.ClearEditor.EVENT_STOP = "EVENT_STOP"; -BI.ClearEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.ClearEditor.EVENT_VALID = "EVENT_VALID"; -BI.ClearEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.ClearEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.ClearEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.ClearEditor.EVENT_REMOVE = "EVENT_REMOVE"; -BI.ClearEditor.EVENT_EMPTY = "EVENT_EMPTY"; -BI.shortcut("bi.clear_editor", BI.ClearEditor);/** - * 带标记的文本框 - * Created by GUY on 2016/1/25. - * @class BI.ShelterEditor - * @extends BI.Widget - */ -BI.ShelterEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.ShelterEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-shelter-editor", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: true, - watermark: "", - errorText: "", - height: 24, - textAlign: "left" - }) - }, - - _init: function () { - BI.ShelterEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.text = BI.createWidget({ - type: "bi.text_button", - cls: "shelter-editor-text", - title: o.title, - warningTitle: o.warningTitle, - tipType: o.tipType, - textAlign: o.textAlign, - height: o.height, - hgap: 4 - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.text.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.text.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.ShelterEditor.EVENT_CLICK_LABEL); - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.ShelterEditor.EVENT_FOCUS, arguments); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.ShelterEditor.EVENT_BLUR, arguments); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.ShelterEditor.EVENT_CLICK, arguments); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self.fireEvent(BI.ShelterEditor.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.ShelterEditor.EVENT_KEY_DOWN, arguments); - }); - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.ShelterEditor.EVENT_VALID, arguments); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self._showHint(); - self._checkText(); - self.fireEvent(BI.ShelterEditor.EVENT_CONFIRM, arguments); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.ShelterEditor.EVENT_START, arguments); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.ShelterEditor.EVENT_PAUSE, arguments); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.ShelterEditor.EVENT_STOP, arguments); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.ShelterEditor.EVENT_SPACE, arguments); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self._checkText(); - self.fireEvent(BI.ShelterEditor.EVENT_ERROR, arguments); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.ShelterEditor.EVENT_ENTER, arguments); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.ShelterEditor.EVENT_RESTRICT, arguments); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self.fireEvent(BI.ShelterEditor.EVENT_EMPTY, arguments); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - this._showHint(); - self._checkText(); - }, - - _checkText: function () { - var o = this.options; - if (this.editor.getValue() === "") { - this.text.setValue(o.watermark || ""); - this.text.element.addClass("bi-water-mark"); - } else { - this.text.setValue(this.editor.getValue()); - this.text.element.removeClass("bi-water-mark"); - } - }, - - _showInput: function () { - this.editor.visible(); - this.text.invisible(); - }, - - _showHint: function () { - this.editor.invisible(); - this.text.visible(); - }, - - setTitle: function (title) { - this.text.setTitle(title); - }, - - setWarningTitle: function (title) { - this.text.setWarningTitle(title); - }, - - focus: function () { - this._showInput(); - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - this._showHint(); - this._checkText(); - }, - - doRedMark: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setTextStyle: function (style) { - this.text.setStyle(style); - }, - - setValue: function (k) { - this.editor.setValue(k); - this._checkText(); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - getState: function () { - return this.text.getValue(); - }, - - setState: function (v) { - this._showHint(); - this.text.setValue(v); - } -}); -BI.ShelterEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.ShelterEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.ShelterEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.ShelterEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.ShelterEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.ShelterEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; - -BI.ShelterEditor.EVENT_START = "EVENT_START"; -BI.ShelterEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.ShelterEditor.EVENT_STOP = "EVENT_STOP"; -BI.ShelterEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.ShelterEditor.EVENT_VALID = "EVENT_VALID"; -BI.ShelterEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.ShelterEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.ShelterEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.ShelterEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY"; - -BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/** - * Created by User on 2017/7/28. - */ -BI.SignInitialEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.SignInitialEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-sign-initial-editor", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: true, - watermark: "", - errorText: "", - value: "", - text: "", - height: 24 - }) - }, - - _init: function () { - BI.SignInitialEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.text = BI.createWidget({ - type: "bi.text_button", - cls: "sign-editor-text", - title: o.title, - warningTitle: o.warningTitle, - tipType: o.tipType, - textAlign: "left", - height: o.height, - hgap: 4, - handler: function () { - self._showInput(); - self.editor.focus(); - self.editor.selectAll(); - } - }); - this.text.on(BI.TextButton.EVENT_CHANGE, function () { - BI.nextTick(function () { - self.fireEvent(BI.SignInitialEditor.EVENT_CLICK_LABEL) - }); - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments); - }); - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_VALID, arguments); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self._showHint(); - self._checkText(); - self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM, arguments); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self._checkText(); - self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY, arguments); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - this._showHint(); - self._checkText(); - }, - - _checkText: function () { - var o = this.options; - BI.nextTick(BI.bind(function () { - if (this.editor.getValue() === "") { - this.text.setValue(o.watermark || ""); - this.text.element.addClass("bi-water-mark"); - } else { - var v = this.editor.getValue(); - v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")"; - this.text.setValue(v); - this.text.element.removeClass("bi-water-mark"); - } - }, this)); - }, - - _showInput: function () { - this.editor.visible(); - this.text.invisible(); - }, - - _showHint: function () { - this.editor.invisible(); - this.text.visible(); - }, - - setTitle: function (title) { - this.text.setTitle(title); - }, - - setWarningTitle: function (title) { - this.text.setWarningTitle(title); - }, - - focus: function () { - this._showInput(); - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - this._showHint(); - this._checkText(); - }, - - doRedMark: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setValue: function (v) { - var o = this.options; - this.editor.setValue(v.value); - o.text = v.text || o.text; - this._checkText(); - }, - - getValue: function () { - return { - value: this.editor.getValue(), - text: this.options.text - } - }, - - getState: function () { - return this.text.getValue(); - }, - - setState: function (v) { - var o = this.options; - this._showHint(); - v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")"; - this.text.setValue(v); - } -}); -BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SignInitialEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.SignInitialEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.SignInitialEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.SignInitialEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.SignInitialEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; - -BI.SignInitialEditor.EVENT_START = "EVENT_START"; -BI.SignInitialEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SignInitialEditor.EVENT_STOP = "EVENT_STOP"; -BI.SignInitialEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.SignInitialEditor.EVENT_VALID = "EVENT_VALID"; -BI.SignInitialEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.SignInitialEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.SignInitialEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.SignInitialEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.SignInitialEditor.EVENT_EMPTY = "EVENT_EMPTY"; - -BI.shortcut("bi.sign_initial_editor", BI.SignInitialEditor);/** - * 带标记的文本框 - * Created by GUY on 2015/8/28. - * @class BI.SignEditor - * @extends BI.Widget - */ -BI.SignEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.SignEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-sign-editor", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: true, - watermark: "", - errorText: "", - height: 24 - }) - }, - - _init: function () { - BI.SignEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.text = BI.createWidget({ - type: "bi.text_button", - cls: "sign-editor-text", - title: o.title, - warningTitle: o.warningTitle, - tipType: o.tipType, - textAlign: "left", - height: o.height, - hgap: 4, - handler: function () { - self._showInput(); - self.editor.focus(); - self.editor.selectAll(); - } - }); - this.text.on(BI.TextButton.EVENT_CHANGE, function () { - BI.nextTick(function () { - self.fireEvent(BI.SignEditor.EVENT_CLICK_LABEL) - }); - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.SignEditor.EVENT_FOCUS, arguments); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.SignEditor.EVENT_BLUR, arguments); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.SignEditor.EVENT_CLICK, arguments); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self.fireEvent(BI.SignEditor.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.SignEditor.EVENT_KEY_DOWN, arguments); - }); - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.SignEditor.EVENT_VALID, arguments); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self._showHint(); - self._checkText(); - self.fireEvent(BI.SignEditor.EVENT_CONFIRM, arguments); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.SignEditor.EVENT_START, arguments); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.SignEditor.EVENT_PAUSE, arguments); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.SignEditor.EVENT_STOP, arguments); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.SignEditor.EVENT_SPACE, arguments); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self._checkText(); - self.fireEvent(BI.SignEditor.EVENT_ERROR, arguments); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.SignEditor.EVENT_ENTER, arguments); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.SignEditor.EVENT_RESTRICT, arguments); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self.fireEvent(BI.SignEditor.EVENT_EMPTY, arguments); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - this._showHint(); - self._checkText(); - }, - - _checkText: function () { - var o = this.options; - BI.nextTick(BI.bind(function () { - if (this.editor.getValue() === "") { - this.text.setValue(o.watermark || ""); - this.text.element.addClass("bi-water-mark"); - } else { - this.text.setValue(this.editor.getValue()); - this.text.element.removeClass("bi-water-mark"); - } - }, this)); - }, - - _showInput: function () { - this.editor.visible(); - this.text.invisible(); - }, - - _showHint: function () { - this.editor.invisible(); - this.text.visible(); - }, - - setTitle: function (title) { - this.text.setTitle(title); - }, - - setWarningTitle: function (title) { - this.text.setWarningTitle(title); - }, - - focus: function () { - this._showInput(); - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - this._showHint(); - this._checkText(); - }, - - doRedMark: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setValue: function (k) { - this.editor.setValue(k); - this._checkText(); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - getState: function () { - return this.text.getValue(); - }, - - setState: function (v) { - this._showHint(); - this.text.setValue(v); - } -}); -BI.SignEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SignEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.SignEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.SignEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.SignEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.SignEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; - -BI.SignEditor.EVENT_START = "EVENT_START"; -BI.SignEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SignEditor.EVENT_STOP = "EVENT_STOP"; -BI.SignEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.SignEditor.EVENT_VALID = "EVENT_VALID"; -BI.SignEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.SignEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.SignEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.SignEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.SignEditor.EVENT_EMPTY = "EVENT_EMPTY"; - -BI.shortcut("bi.sign_editor", BI.SignEditor);/** - * guy - * 记录状态的输入框 - * @class BI.StateEditor - * @extends BI.Single - */ -BI.StateEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.StateEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-state-editor", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: true, - watermark: "", - errorText: "", - height: 24 - }) - }, - - _init: function () { - BI.StateEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.text = BI.createWidget({ - type: "bi.text_button", - cls: "state-editor-infinite-text bi-disabled", - textAlign: "left", - height: o.height, - text: BI.i18nText("BI-Basic_Unrestricted"), - hgap: 4, - handler: function () { - self._showInput(); - self.editor.focus(); - self.editor.setValue(""); - } - }); - this.text.on(BI.TextButton.EVENT_CHANGE, function () { - BI.nextTick(function () { - self.fireEvent(BI.StateEditor.EVENT_CLICK_LABEL); - }); - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.StateEditor.EVENT_FOCUS, arguments); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.StateEditor.EVENT_BLUR, arguments); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.StateEditor.EVENT_CLICK, arguments); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self.fireEvent(BI.StateEditor.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.StateEditor.EVENT_KEY_DOWN, arguments); - }); - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.StateEditor.EVENT_VALID, arguments); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self._showHint(); - self.fireEvent(BI.StateEditor.EVENT_CONFIRM, arguments); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.StateEditor.EVENT_START, arguments); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.StateEditor.EVENT_PAUSE, arguments); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.StateEditor.EVENT_STOP, arguments); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.StateEditor.EVENT_SPACE, arguments); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self.fireEvent(BI.StateEditor.EVENT_ERROR, arguments); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.StateEditor.EVENT_ENTER, arguments); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.StateEditor.EVENT_RESTRICT, arguments); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self.fireEvent(BI.StateEditor.EVENT_EMPTY, arguments); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - this._showHint(); - }, - - doRedMark: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - focus: function () { - if (this.options.disabled === false) { - this._showInput(); - this.editor.focus(); - } - }, - - blur: function () { - this.editor.blur(); - this._showHint(); - }, - - _showInput: function () { - this.editor.visible(); - this.text.invisible(); - }, - - _showHint: function () { - this.editor.invisible(); - this.text.visible(); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setValue: function (k) { - this.editor.setValue(k); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - getState: function () { - return this.editor.getValue().match(/[^\s]+/g); - }, - - setState: function (v) { - BI.StateEditor.superclass.setValue.apply(this, arguments); - if (BI.isNumber(v)) { - if (v === BI.Selection.All) { - this.text.setText(BI.i18nText("BI-Select_All")); - this.text.setTitle(""); - this.text.element.removeClass("state-editor-infinite-text"); - } else if (v === BI.Selection.Multi) { - this.text.setText(BI.i18nText("BI-Select_Part")); - this.text.setTitle(""); - this.text.element.removeClass("state-editor-infinite-text"); - } else { - this.text.setText(BI.i18nText("BI-Basic_Unrestricted")); - this.text.setTitle(""); - this.text.element.addClass("state-editor-infinite-text"); - } - return; - } - if (BI.isString(v)) { - // if (BI.isEmpty(v)) { - // this.text.setText(BI.i18nText("BI-Basic_Unrestricted")); - // this.text.setTitle(""); - // this.text.element.addClass("state-editor-infinite-text"); - // } else { - this.text.setText(v); - this.text.setTitle(v); - this.text.element.removeClass("state-editor-infinite-text"); - // } - return; - } - if (BI.isArray(v)) { - if (BI.isEmpty(v)) { - this.text.setText(BI.i18nText("BI-Basic_Unrestricted")); - this.text.element.addClass("state-editor-infinite-text"); - } else if (v.length === 1) { - this.text.setText(v[0]); - this.text.setTitle(v[0]); - this.text.element.removeClass("state-editor-infinite-text"); - } else { - this.text.setText(BI.i18nText("BI-Select_Part")); - this.text.setTitle(""); - this.text.element.removeClass("state-editor-infinite-text"); - } - } - } -}); -BI.StateEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.StateEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.StateEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.StateEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.StateEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.StateEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; - -BI.StateEditor.EVENT_START = "EVENT_START"; -BI.StateEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.StateEditor.EVENT_STOP = "EVENT_STOP"; -BI.StateEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.StateEditor.EVENT_VALID = "EVENT_VALID"; -BI.StateEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.StateEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.StateEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.StateEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.StateEditor.EVENT_EMPTY = "EVENT_EMPTY"; - -BI.shortcut("bi.state_editor", BI.StateEditor);/** - * 无限制-已选择状态输入框 - * Created by GUY on 2016/5/18. - * @class BI.SimpleStateEditor - * @extends BI.Single - */ -BI.SimpleStateEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.SimpleStateEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-simple-state-editor", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - mouseOut: false, - allowBlank: true, - watermark: "", - errorText: "", - height: 24 - }) - }, - - _init: function () { - BI.SimpleStateEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.text = BI.createWidget({ - type: "bi.text_button", - cls: "state-editor-infinite-text bi-disabled", - textAlign: "left", - height: o.height, - text: BI.i18nText("BI-Basic_Unrestricted"), - hgap: 4, - handler: function () { - self._showInput(); - self.editor.focus(); - self.editor.setValue(""); - } - }); - this.text.on(BI.TextButton.EVENT_CHANGE, function () { - BI.nextTick(function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_CLICK_LABEL); - }); - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_FOCUS, arguments); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_BLUR, arguments); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_CLICK, arguments); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.SimpleStateEditor.EVENT_KEY_DOWN, arguments); - }); - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_VALID, arguments); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self._showHint(); - self.fireEvent(BI.SimpleStateEditor.EVENT_CONFIRM, arguments); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_START, arguments); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_PAUSE, arguments); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_STOP, arguments); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_SPACE, arguments); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_ERROR, arguments); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_ENTER, arguments); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_RESTRICT, arguments); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self.fireEvent(BI.SimpleStateEditor.EVENT_EMPTY, arguments); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - this._showHint(); - }, - - doRedMark: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - focus: function () { - this._showInput(); - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - this._showHint(); - }, - - _showInput: function () { - this.editor.visible(); - this.text.invisible(); - }, - - _showHint: function () { - this.editor.invisible(); - this.text.visible(); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setValue: function (k) { - this.editor.setValue(k); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - getState: function () { - return this.editor.getValue().match(/[^\s]+/g); - }, - - setState: function (v) { - BI.SimpleStateEditor.superclass.setValue.apply(this, arguments); - if (BI.isNumber(v)) { - if (v === BI.Selection.All) { - this.text.setText(BI.i18nText("BI-Already_Selected")); - this.text.element.removeClass("state-editor-infinite-text"); - } else if (v === BI.Selection.Multi) { - this.text.setText(BI.i18nText("BI-Already_Selected")); - this.text.element.removeClass("state-editor-infinite-text"); - } else { - this.text.setText(BI.i18nText("BI-Basic_Unrestricted")); - this.text.element.addClass("state-editor-infinite-text"); - } - return; - } - if (!BI.isArray(v) || v.length === 1) { - this.text.setText(v); - this.text.setTitle(v); - this.text.element.removeClass("state-editor-infinite-text"); - } else if (BI.isEmpty(v)) { - this.text.setText(BI.i18nText("BI-Basic_Unrestricted")); - this.text.element.addClass("state-editor-infinite-text"); - } else { - this.text.setText(BI.i18nText("BI-Already_Selected")); - this.text.element.removeClass("state-editor-infinite-text"); - } - } -}); -BI.SimpleStateEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SimpleStateEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.SimpleStateEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.SimpleStateEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.SimpleStateEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.SimpleStateEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; - -BI.SimpleStateEditor.EVENT_START = "EVENT_START"; -BI.SimpleStateEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SimpleStateEditor.EVENT_STOP = "EVENT_STOP"; -BI.SimpleStateEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.SimpleStateEditor.EVENT_VALID = "EVENT_VALID"; -BI.SimpleStateEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.SimpleStateEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.SimpleStateEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.SimpleStateEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.SimpleStateEditor.EVENT_EMPTY = "EVENT_EMPTY"; - -BI.shortcut("bi.simple_state_editor", BI.SimpleStateEditor);/** - * 有确定取消按钮的弹出层 - * @class BI.BarPopoverSection - * @extends BI.PopoverSection - * @abstract - */ -BI.BarPopoverSection = BI.inherit(BI.PopoverSection, { - _defaultConfig: function () { - return BI.extend(BI.BarPopoverSection.superclass._defaultConfig.apply(this, arguments), { - btns: [BI.i18nText(BI.i18nText("BI-Basic_Sure")), BI.i18nText(BI.i18nText("BI-Basic_Cancel"))] - }) - }, - - _init: function () { - BI.BarPopoverSection.superclass._init.apply(this, arguments); - }, - - rebuildSouth: function (south) { - var self = this, o = this.options; - this.sure = BI.createWidget({ - type: 'bi.button', - text: this.options.btns[0], - warningTitle: o.warningTitle, - height: 30, - value: 0, - handler: function (v) { - self.end(); - self.close(v); - } - }); - this.cancel = BI.createWidget({ - type: 'bi.button', - text: this.options.btns[1], - height: 30, - value: 1, - level: 'ignore', - handler: function (v) { - self.close(v); - } - }); - BI.createWidget({ - type: 'bi.right_vertical_adapt', - element: south, - lgap: 10, - items: [this.cancel, this.sure] - }); - }, - - setConfirmButtonEnable: function(v){ - this.sure.setEnable(!!v); - } -});/** - * 下拉框弹出层的多选版本,toolbar带有若干按钮, zIndex在1000w - * @class BI.MultiPopupView - * @extends BI.Widget - */ - -BI.MultiPopupView = BI.inherit(BI.PopupView, { - - _defaultConfig: function () { - var conf = BI.MultiPopupView.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-multi-list-view", - buttons: [BI.i18nText("BI-Basic_Sure")] - }) - }, - - _init: function () { - BI.MultiPopupView.superclass._init.apply(this, arguments); - }, - - _createToolBar: function () { - var o = this.options, self = this; - if (o.buttons.length === 0) { - return; - } - - var text = []; //构造[{text:content},……] - BI.each(o.buttons, function (idx, item) { - text.push({ - text: item, - value: idx - }) - }); - - this.buttongroup = BI.createWidget({ - type: "bi.button_group", - cls: "list-view-toolbar bi-high-light bi-border-top", - height: 30, - items: BI.createItems(text, { - type: "bi.text_button", - once: false, - shadow: true, - isShadowShowingOnSelected: true - }), - layouts: [{ - type: "bi.center", - hgap: 0, - vgap: 0 - }] - }); - - this.buttongroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { - self.fireEvent(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, value, obj); - }); - - return this.buttongroup; - } - -}); - -BI.MultiPopupView.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; - -BI.shortcut("bi.multi_popup_view", BI.MultiPopupView);/** - * 可以理解为MultiPopupView和Panel两个面板的结合体 - * @class BI.PopupPanel - * @extends BI.MultiPopupView - */ - -BI.PopupPanel = BI.inherit(BI.MultiPopupView, { - - _defaultConfig: function () { - var conf = BI.PopupPanel.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-popup-panel", - title: "" - }) - }, - - _init: function () { - BI.PopupPanel.superclass._init.apply(this, arguments); - }, - - _createTool: function () { - var self = this, o = this.options; - var close = BI.createWidget({ - type: "bi.icon_button", - cls: "close-h-font", - width: 25, - height: 25 - }); - close.on(BI.IconButton.EVENT_CHANGE, function () { - self.setVisible(false); - self.fireEvent(BI.PopupPanel.EVENT_CLOSE); - }); - return BI.createWidget({ - type: "bi.htape", - cls: "popup-panel-title bi-background bi-border", - height: 25, - items: [{ - el: { - type: "bi.label", - textAlign: "left", - text: o.title, - height: 25, - lgap: 10 - } - }, { - el: close, - width: 25 - }] - }); - } -}); - -BI.PopupPanel.EVENT_CHANGE = "EVENT_CHANGE"; -BI.PopupPanel.EVENT_CLOSE = "EVENT_CLOSE"; -BI.PopupPanel.EVENT_CLICK_TOOLBAR_BUTTON = "EVENT_CLICK_TOOLBAR_BUTTON"; - -BI.shortcut("bi.popup_panel", BI.PopupPanel);/** - * list面板 - * - * Created by GUY on 2015/10/30. - * @class BI.ListPane - * @extends BI.Pane - */ -BI.ListPane = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - var conf = BI.ListPane.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-list-pane", - logic: { - dynamic: true - }, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - vgap: 0, - hgap: 0, - items: [], - itemsCreator: BI.emptyFn, - hasNext: BI.emptyFn, - onLoaded: BI.emptyFn, - el: { - type: "bi.button_group" - } - }) - }, - _init: function () { - BI.ListPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.button_group = BI.createWidget(o.el, { - type: "bi.button_group", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - behaviors: {}, - items: o.items, - itemsCreator: function (op, calback) { - if (op.times === 1) { - self.empty(); - BI.nextTick(function () { - self.loading() - }); - } - o.itemsCreator(op, function () { - calback.apply(self, arguments); - op.times === 1 && BI.nextTick(function () { - self.loaded(); - }); - }); - }, - hasNext: o.hasNext, - layouts: [{ - type: "bi.vertical" - }] - }); - - this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.ListPane.EVENT_CHANGE, value, obj); - } - }); - this.check(); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Top), BI.extend({ - scrolly: true, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - vgap: o.vgap, - hgap: o.hgap - }, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Top, this.button_group) - })))); - }, - - hasPrev: function () { - return this.button_group.hasPrev && this.button_group.hasPrev(); - }, - - hasNext: function () { - return this.button_group.hasNext && this.button_group.hasNext(); - }, - - prependItems: function (items) { - this.options.items = items.concat(this.options.items); - this.button_group.prependItems.apply(this.button_group, arguments); - this.check(); - }, - - addItems: function (items) { - this.options.items = this.options.items.concat(items); - this.button_group.addItems.apply(this.button_group, arguments); - this.check(); - }, - - removeItemAt: function (indexes) { - indexes = indexes || []; - BI.removeAt(this.options.items, indexes); - this.button_group.removeItemAt.apply(this.button_group, arguments); - this.check(); - }, - - populate: function (items) { - var self = this, o = this.options; - if (arguments.length === 0 && (BI.isFunction(this.button_group.attr("itemsCreator")))) {//接管loader的populate方法 - this.button_group.attr("itemsCreator").apply(this, [{times: 1}, function () { - if (arguments.length === 0) { - throw new Error("参数不能为空"); - } - self.populate.apply(self, arguments); - }]); - return; - } - BI.ListPane.superclass.populate.apply(this, arguments); - this.button_group.populate.apply(this.button_group, arguments); - }, - - empty: function () { - this.button_group.empty(); - }, - - setNotSelectedValue: function () { - this.button_group.setNotSelectedValue.apply(this.button_group, arguments); - }, - - getNotSelectedValue: function () { - return this.button_group.getNotSelectedValue(); - }, - - setValue: function () { - this.button_group.setValue.apply(this.button_group, arguments); - }, - - getValue: function () { - return this.button_group.getValue.apply(this.button_group, arguments); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - getAllLeaves: function () { - return this.button_group.getAllLeaves(); - }, - - getSelectedButtons: function () { - return this.button_group.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.button_group.getNotSelectedButtons(); - }, - - getIndexByValue: function (value) { - return this.button_group.getIndexByValue(value); - }, - - getNodeById: function (id) { - return this.button_group.getNodeById(id); - }, - - getNodeByValue: function (value) { - return this.button_group.getNodeByValue(value); - } -}); -BI.ListPane.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.list_pane", BI.ListPane);/** - * 带有标题栏的pane - * @class BI.Panel - * @extends BI.Widget - */ -BI.Panel = BI.inherit(BI.Widget,{ - _defaultConfig : function(){ - return BI.extend(BI.Panel.superclass._defaultConfig.apply(this,arguments),{ - baseCls: "bi-panel bi-border", - title:"", - titleButtons:[], - el:{}, - logic:{ - dynamic: false - } - }); - }, - - _init:function(){ - BI.Panel.superclass._init.apply(this,arguments); - var o = this.options; - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("vertical", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("top", this._createTitle() - ,this.options.el) - })))); - }, - - _createTitle:function(){ - var self = this, o = this.options; - this.text = BI.createWidget({ - type: "bi.label", - cls: "panel-title-text", - text: o.title, - height: 30 - }); - - this.button_group = BI.createWidget({ - type:"bi.button_group", - items: o.titleButtons, - layouts: [{ - type: "bi.center_adapt", - lgap:10 - }] - }); - - this.button_group.on(BI.Controller.EVENT_CHANGE, function(){ - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function(value, obj){ - self.fireEvent(BI.Panel.EVENT_CHANGE, value, obj); - }); - - return { - el: { - type: "bi.left_right_vertical_adapt", - cls: "panel-title bi-tips bi-border-bottom bi-background", - height: 30, - items: { - left: [this.text], - right: [this.button_group] - }, - lhgap: 10, - rhgap: 10 - }, - height: 30 - }; - }, - - setTitle: function(title){ - this.text.setValue(title); - } -}); -BI.Panel.EVENT_CHANGE = "Panel.EVENT_CHANGE"; - -BI.shortcut("bi.panel",BI.Panel);/** - * 选择列表 - * - * Created by GUY on 2015/11/1. - * @class BI.SelectList - * @extends BI.Widget - */ -BI.SelectList = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SelectList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-list", - direction: BI.Direction.Top,//toolbar的位置 - logic: { - dynamic: true - }, - items: [], - itemsCreator: BI.emptyFn, - hasNext: BI.emptyFn, - onLoaded: BI.emptyFn, - toolbar: { - type: "bi.multi_select_bar" - }, - el: { - type: "bi.list_pane" - } - }) - }, - _init: function () { - BI.SelectList.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - //全选 - this.toolbar = BI.createWidget(o.toolbar); - this.allSelected = false; - this.toolbar.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - self.allSelected = this.isSelected(); - if (type === BI.Events.CLICK) { - self.setAllSelected(self.allSelected); - self.fireEvent(BI.SelectList.EVENT_CHANGE, value, obj); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.list = BI.createWidget(o.el, { - type: "bi.list_pane", - items: o.items, - itemsCreator: function (op, callback) { - op.times === 1 && self.toolbar.setVisible(false); - o.itemsCreator(op, function (items) { - callback.apply(self, arguments); - if (op.times === 1) { - self.toolbar.setVisible(items && items.length > 0); - self.toolbar.setEnable(items && items.length > 0); - } - self._checkAllSelected(); - }); - }, - onLoaded: o.onLoaded, - hasNext: o.hasNext - }); - - this.list.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (type === BI.Events.CLICK) { - self._checkAllSelected(); - self.fireEvent(BI.SelectList.EVENT_CHANGE, value, obj); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ - scrolly: true - }, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.toolbar, this.list) - })))); - - if (o.items.length <= 0) { - this.toolbar.setVisible(false); - this.toolbar.setEnable(false); - } - }, - - _checkAllSelected: function () { - var selectLength = this.list.getValue().length; - var notSelectLength = this.getAllLeaves().length - selectLength; - var hasNext = this.list.hasNext(); - var isAlreadyAllSelected = this.toolbar.isSelected(); - var isHalf = selectLength > 0 && (notSelectLength > 0 || (!isAlreadyAllSelected && hasNext)); - isHalf = isHalf || (notSelectLength > 0 && hasNext && isAlreadyAllSelected); - this.toolbar.setHalfSelected(isHalf); - !isHalf && this.toolbar.setSelected(selectLength > 0 && notSelectLength <= 0 && (!hasNext || isAlreadyAllSelected)); - }, - - setAllSelected: function (v) { - BI.each(this.getAllButtons(), function (i, btn) { - (btn.setSelected || btn.setAllSelected).apply(btn, [v]); - }); - this.allSelected = !!v; - this.toolbar.setSelected(v); - this.toolbar.setHalfSelected(false); - }, - - setToolBarVisible: function (b) { - this.toolbar.setVisible(b); - }, - - isAllSelected: function () { - return this.allSelected; - // return this.toolbar.isSelected(); - }, - - hasPrev: function () { - return this.list.hasPrev(); - }, - - hasNext: function () { - return this.list.hasNext(); - }, - - prependItems: function (items) { - this.list.prependItems.apply(this.list, arguments); - }, - - addItems: function (items) { - this.list.addItems.apply(this.list, arguments); - }, - - setValue: function (data) { - var selectAll = data.type === BI.ButtonGroup.CHOOSE_TYPE_ALL; - this.setAllSelected(selectAll); - this.list[selectAll ? "setNotSelectedValue" : "setValue"](data.value); - this._checkAllSelected(); - }, - - getValue: function () { - if (this.isAllSelected() === false) { - return { - type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - value: this.list.getValue(), - assist: this.list.getNotSelectedValue() - }; - } else { - return { - type: BI.ButtonGroup.CHOOSE_TYPE_ALL, - value: this.list.getNotSelectedValue(), - assist: this.list.getValue() - }; - } - }, - - empty: function () { - this.list.empty(); - }, - - populate: function (items) { - this.toolbar.setVisible(!BI.isEmptyArray(items)); - this.toolbar.setEnable(!BI.isEmptyArray(items)); - this.list.populate.apply(this.list, arguments); - this._checkAllSelected(); - }, - - _setEnable: function (enable) { - BI.SelectList.superclass._setEnable.apply(this, arguments); - this.toolbar.setEnable(enable); - }, - - resetHeight: function (h) { - var toolHeight = ( this.toolbar.element.outerHeight() || 25) * ( this.toolbar.isVisible() ? 1 : 0); - this.list.resetHeight ? this.list.resetHeight(h - toolHeight) : - this.list.element.css({"max-height": h - toolHeight + "px"}) - }, - - setNotSelectedValue: function () { - this.list.setNotSelectedValue.apply(this.list, arguments); - this._checkAllSelected(); - }, - - getNotSelectedValue: function () { - return this.list.getNotSelectedValue(); - }, - - getAllButtons: function () { - return this.list.getAllButtons(); - }, - - getAllLeaves: function () { - return this.list.getAllLeaves(); - }, - - getSelectedButtons: function () { - return this.list.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.list.getNotSelectedButtons(); - }, - - getIndexByValue: function (value) { - return this.list.getIndexByValue(value); - }, - - getNodeById: function (id) { - return this.list.getNodeById(id); - }, - - getNodeByValue: function (value) { - return this.list.getNodeByValue(value); - } -}); -BI.SelectList.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.select_list", BI.SelectList);/** - * Created by roy on 15/11/6. - */ -BI.LazyLoader = BI.inherit(BI.Widget, { - _const: { - PAGE: 100 - }, - _defaultConfig: function () { - return BI.extend(BI.LazyLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-lazy-loader", - el: {} - }) - }, - - _init: function () { - var self = this, o = this.options; - BI.LazyLoader.superclass._init.apply(this, arguments); - var all = o.items.length; - this.loader = BI.createWidget({ - type: "bi.loader", - element: this, - //下面是button_group的属性 - el: o.el, - - itemsCreator: function (options, populate) { - populate(self._getNextItems(options)); - }, - hasNext: function (option) { - return option.count < all; - } - }); - - this.loader.on(BI.Loader.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.LazyLoader.EVENT_CHANGE, obj) - }) - }, - _getNextItems: function (options) { - var self = this, o = this.options; - var lastNum = o.items.length - this._const.PAGE * (options.times - 1); - var lastItems = BI.last(o.items, lastNum); - var nextItems = BI.first(lastItems, this._const.PAGE); - return nextItems; - }, - - populate: function (items) { - this.loader.populate(items); - }, - - addItems: function (items) { - this.loader.addItems(items); - }, - - empty: function () { - this.loader.empty(); - }, - - setNotSelectedValue: function () { - this.loader.setNotSelectedValue.apply(this.loader, arguments); - }, - - getNotSelectedValue: function () { - return this.loader.getNotSelectedValue(); - }, - - setValue: function () { - this.loader.setValue.apply(this.loader, arguments); - }, - - getValue: function () { - return this.loader.getValue.apply(this.loader, arguments); - }, - - getAllButtons: function () { - return this.loader.getAllButtons(); - }, - - getAllLeaves: function () { - return this.loader.getAllLeaves(); - }, - - getSelectedButtons: function () { - return this.loader.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.loader.getNotSelectedButtons(); - }, - - getIndexByValue: function (value) { - return this.loader.getIndexByValue(value); - }, - - getNodeById: function (id) { - return this.loader.getNodeById(id); - }, - - getNodeByValue: function (value) { - return this.loader.getNodeByValue(value); - } -}); -BI.LazyLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.lazy_loader", BI.LazyLoader);/** - * 恶心的加载控件, 为解决排序问题引入的控件 - * - * Created by GUY on 2015/11/12. - * @class BI.ListLoader - * @extends BI.Widget - */ -BI.ListLoader = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.ListLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-list-loader", - - isDefaultInit: true,//是否默认初始化数据 - - //下面是button_group的属性 - el: { - type: "bi.button_group" - }, - - items: [], - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn, - - //下面是分页信息 - count: false, - next: {}, - hasNext: BI.emptyFn - }) - }, - - _nextLoad: function () { - var self = this, o = this.options; - this.next.setLoading(); - o.itemsCreator.apply(this, [{times: ++this.times}, function () { - self.next.setLoaded(); - self.addItems.apply(self, arguments); - }]); - }, - - _init: function () { - BI.ListLoader.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (o.itemsCreator === false) { - o.next = false; - } - - this.button_group = BI.createWidget(o.el, { - type: "bi.button_group", - element: this, - chooseType: 0, - items: o.items, - behaviors: {}, - layouts: [{ - type: "bi.vertical" - }] - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.ListLoader.EVENT_CHANGE, obj); - } - }); - - if (o.next !== false) { - this.next = BI.createWidget(BI.extend({ - type: "bi.loading_bar" - }, o.next)); - this.next.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self._nextLoad(); - } - }) - } - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.next] - }); - - o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () { - this.populate(); - }, this)); - if (BI.isNotEmptyArray(o.items)) { - this.populate(o.items); - } - }, - - hasNext: function () { - var o = this.options; - if (BI.isNumber(o.count)) { - return this.count < o.count; - } - return !!o.hasNext.apply(this, [{ - times: this.times, - count: this.count - }]) - }, - - addItems: function (items) { - this.count += items.length; - if (BI.isObject(this.next)) { - if (this.hasNext()) { - this.options.items = this.options.items.concat(items); - this.next.setLoaded(); - } else { - this.next.setEnd(); - } - } - this.button_group.addItems.apply(this.button_group, arguments); - this.next.element.appendTo(this.element); - }, - - populate: function (items) { - var self = this, o = this.options; - if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) { - o.itemsCreator.apply(this, [{times: 1}, function () { - if (arguments.length === 0) { - throw new Error("参数不能为空"); - } - self.populate.apply(self, arguments); - o.onLoaded(); - }]); - return; - } - this.options.items = items; - this.times = 1; - this.count = 0; - this.count += items.length; - if (BI.isObject(this.next)) { - if (this.hasNext()) { - this.next.setLoaded(); - } else { - this.next.invisible(); - } - } - BI.DOM.hang([this.next]); - this.button_group.populate.apply(this.button_group, arguments); - this.next.element.appendTo(this.element); - }, - - empty: function () { - BI.DOM.hang([this.next]); - this.button_group.empty(); - this.next.element.appendTo(this.element); - BI.each([this.next], function (i, ob) { - ob && ob.setVisible(false); - }); - }, - - setNotSelectedValue: function () { - this.button_group.setNotSelectedValue.apply(this.button_group, arguments); - }, - - getNotSelectedValue: function () { - return this.button_group.getNotSelectedValue(); - }, - - setValue: function () { - this.button_group.setValue.apply(this.button_group, arguments); - }, - - getValue: function () { - return this.button_group.getValue.apply(this.button_group, arguments); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - getAllLeaves: function () { - return this.button_group.getAllLeaves(); - }, - - getSelectedButtons: function () { - return this.button_group.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.button_group.getNotSelectedButtons(); - }, - - getIndexByValue: function (value) { - return this.button_group.getIndexByValue(value); - }, - - getNodeById: function (id) { - return this.button_group.getNodeById(id); - }, - - getNodeByValue: function (value) { - return this.button_group.getNodeByValue(value); - } -}); -BI.ListLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.list_loader", BI.ListLoader);/** - * Created by GUY on 2016/4/29. - * - * @class BI.SortList - * @extends BI.Widget - */ -BI.SortList = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.SortList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sort-list", - - isDefaultInit: true,//是否默认初始化数据 - - //下面是button_group的属性 - el: { - type: "bi.button_group" - }, - - items: [], - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn, - - //下面是分页信息 - count: false, - next: {}, - hasNext: BI.emptyFn - - //containment: this.element, - //connectWith: ".bi-sort-list", - }) - }, - - _init: function () { - BI.SortList.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.loader = BI.createWidget({ - type: "bi.list_loader", - element: this, - isDefaultInit: o.isDefaultInit, - el: o.el, - items: this._formatItems(o.items), - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (items) { - callback(self._formatItems(items)); - }); - }, - onLoaded: o.onLoaded, - count: o.count, - next: o.next, - hasNext: o.hasNext - }); - this.loader.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.SortList.EVENT_CHANGE, value, obj); - } - }); - - this.loader.element.sortable({ - containment: o.containment || this.element, - connectWith: o.connectWith || ".bi-sort-list", - items: ".sort-item", - cursor: o.cursor || "drag", - tolerance: o.tolerance || "intersect", - placeholder: { - element: function ($currentItem) { - var holder = BI.createWidget({ - type: "bi.layout", - cls: "bi-sortable-holder", - height: $currentItem.outerHeight() - }); - holder.element.css({ - "margin-left": $currentItem.css("margin-left"), - "margin-right": $currentItem.css("margin-right"), - "margin-top": $currentItem.css("margin-top"), - "margin-bottom": $currentItem.css("margin-bottom"), - "margin": $currentItem.css("margin") - }); - return holder.element; - }, - update: function () { - - } - }, - start: function (event, ui) { - - }, - stop: function (event, ui) { - self.fireEvent(BI.SortList.EVENT_CHANGE); - }, - over: function (event, ui) { - - } - }); - }, - - _formatItems: function (items) { - BI.each(items, function (i, item) { - item = BI.stripEL(item); - item.cls = item.cls ? item.cls + " sort-item" : "sort-item"; - item.attributes = { - sorted: item.value - }; - }); - return items; - }, - - hasNext: function () { - return this.loader.hasNext(); - }, - - addItems: function (items) { - this.loader.addItems(items); - }, - - populate: function (items) { - if (items) { - arguments[0] = this._formatItems(items); - } - this.loader.populate.apply(this.loader, arguments); - }, - - empty: function () { - this.loader.empty(); - }, - - setNotSelectedValue: function () { - this.loader.setNotSelectedValue.apply(this.loader, arguments); - }, - - getNotSelectedValue: function () { - return this.loader.getNotSelectedValue(); - }, - - setValue: function () { - this.loader.setValue.apply(this.loader, arguments); - }, - - getValue: function () { - return this.loader.getValue(); - }, - - getAllButtons: function () { - return this.loader.getAllButtons(); - }, - - getAllLeaves: function () { - return this.loader.getAllLeaves(); - }, - - getSelectedButtons: function () { - return this.loader.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.loader.getNotSelectedButtons(); - }, - - getIndexByValue: function (value) { - return this.loader.getIndexByValue(value); - }, - - getNodeById: function (id) { - return this.loader.getNodeById(id); - }, - - getNodeByValue: function (value) { - return this.loader.getNodeByValue(value); - }, - - getSortedValues: function () { - return this.loader.element.sortable("toArray", {attribute: "sorted"}); - } -}); -BI.SortList.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.sort_list", BI.SortList);/** - * 有总页数和总行数的分页控件 - * Created by Young's on 2016/10/13. - */ -BI.AllCountPager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.AllCountPager.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-all-count-pager", - height: 30, - pages: 1, //必选项 - curr: 1, //初始化当前页, pages为数字时可用, - count: 1 //总行数 - }) - }, - _init: function () { - BI.AllCountPager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.small_text_editor", - cls: "pager-editor", - validationChecker: function (v) { - return (self.rowCount.getValue() === 0 && v === "0") || BI.isPositiveInteger(v); - }, - hgap: 4, - vgap: 0, - value: o.curr, - errorText: BI.i18nText("BI-Please_Input_Positive_Integer"), - width: 35, - height: 20 - }); - - this.pager = BI.createWidget({ - type: "bi.pager", - width: 36, - layouts: [{ - type: "bi.horizontal", - hgap: 1, - vgap: 1 - }], - - dynamicShow: false, - pages: o.pages, - curr: o.curr, - groups: 0, - - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Previous_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: 20, - cls: "all-pager-prev column-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Next_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: 20, - cls: "all-pager-next column-next-page-h-font" - }, - - hasPrev: o.hasPrev, - hasNext: o.hasNext, - firstPage: o.firstPage, - lastPage: o.lastPage - }); - - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.pager.setValue(BI.parseInt(self.editor.getValue())); - self.fireEvent(BI.AllCountPager.EVENT_CHANGE); - }); - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - self.fireEvent(BI.AllCountPager.EVENT_CHANGE); - }); - this.pager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.editor.setValue(self.pager.getCurrentPage()); - }); - - this.allPages = BI.createWidget({ - type: "bi.label", - width: 30, - title: o.pages, - text: "/" + o.pages - }); - - this.rowCount = BI.createWidget({ - type: "bi.label", - height: o.height, - hgap: 5, - text: o.count, - title: o.count - }); - - var count = BI.createWidget({ - type: "bi.left", - height: o.height, - scrollable: false, - items: [{ - type: "bi.label", - height: o.height, - text: BI.i18nText("BI-Basic_Total"), - width: 15 - }, this.rowCount, { - type: "bi.label", - height: o.height, - text: BI.i18nText("BI-Tiao_Data"), - width: 50, - textAlign: "left" - }] - }); - BI.createWidget({ - type: "bi.center_adapt", - element: this, - columnSize: ["", 35, 40, 36], - items: [count, this.editor, this.allPages, this.pager] - }) - }, - - alwaysShowPager: true, - - setAllPages: function (v) { - this.allPages.setText("/" + v); - this.allPages.setTitle(v); - this.pager.setAllPages(v); - this.editor.setEnable(v >= 1); - }, - - setValue: function (v) { - this.pager.setValue(v); - }, - - setVPage: function (v) { - this.pager.setValue(v); - }, - - setCount: function (count) { - this.rowCount.setText(count); - this.rowCount.setTitle(count); - }, - - getCurrentPage: function () { - return this.pager.getCurrentPage(); - }, - - hasPrev: function () { - return this.pager.hasPrev(); - }, - - hasNext: function () { - return this.pager.hasNext(); - }, - - setPagerVisible: function (b) { - this.editor.setVisible(b); - this.allPages.setVisible(b); - this.pager.setVisible(b); - }, - - populate: function () { - this.pager.populate(); - } -}); -BI.AllCountPager.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.all_count_pager", BI.AllCountPager);/** - * 显示页码的分页控件 - * - * Created by GUY on 2016/6/30. - * @class BI.DirectionPager - * @extends BI.Widget - */ -BI.DirectionPager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.DirectionPager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-direction-pager", - height: 30, - horizontal: { - pages: false, //总页数 - curr: 1, //初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - }, - vertical: { - pages: false, //总页数 - curr: 1, //初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - } - }) - }, - _init: function () { - BI.DirectionPager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var v = o.vertical, h = o.horizontal; - this._createVPager(); - this._createHPager(); - this.layout = BI.createWidget({ - type: "bi.absolute", - scrollable: false, - element: this, - items: [{ - el: this.vpager, - top: 5, - right: 74 - }, { - el: this.vlabel, - top: 5, - right: 111 - }, { - el: this.hpager, - top: 5, - right: -9 - }, { - el: this.hlabel, - top: 5, - right: 28 - }] - }); - }, - - _createVPager: function () { - var self = this, o = this.options; - var v = o.vertical; - this.vlabel = BI.createWidget({ - type: "bi.label", - width: 24, - height: 20, - value: v.curr, - title: v.curr, - invisible: true - }); - this.vpager = BI.createWidget({ - type: "bi.pager", - width: 76, - layouts: [{ - type: "bi.horizontal", - scrollx: false, - rgap: 24, - vgap: 1 - }], - invisible: true, - - dynamicShow: false, - pages: v.pages, - curr: v.curr, - groups: 0, - - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Up_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: 20, - iconWidth: 16, - iconHeight: 16, - cls: "direction-pager-prev column-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Down_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: 20, - iconWidth: 16, - iconHeight: 16, - cls: "direction-pager-next column-next-page-h-font" - }, - - hasPrev: v.hasPrev, - hasNext: v.hasNext, - firstPage: v.firstPage, - lastPage: v.lastPage - }); - - this.vpager.on(BI.Pager.EVENT_CHANGE, function () { - self.fireEvent(BI.DirectionPager.EVENT_CHANGE); - }); - this.vpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.vlabel.setValue(this.getCurrentPage()); - self.vlabel.setTitle(this.getCurrentPage()); - }); - }, - - _createHPager: function () { - var self = this, o = this.options; - var h = o.horizontal; - this.hlabel = BI.createWidget({ - type: "bi.label", - width: 24, - height: 20, - value: h.curr, - title: h.curr, - invisible: true - }); - this.hpager = BI.createWidget({ - type: "bi.pager", - width: 76, - layouts: [{ - type: "bi.horizontal", - scrollx: false, - rgap: 24, - vgap: 1 - }], - invisible: true, - - dynamicShow: false, - pages: h.pages, - curr: h.curr, - groups: 0, - - first: false, - last: false, - prev: { - type: "bi.icon_button", - value: "prev", - title: BI.i18nText("BI-Left_Page"), - warningTitle: BI.i18nText("BI-Current_Is_First_Page"), - height: 20, - iconWidth: 16, - iconHeight: 16, - cls: "direction-pager-prev row-pre-page-h-font" - }, - next: { - type: "bi.icon_button", - value: "next", - title: BI.i18nText("BI-Right_Page"), - warningTitle: BI.i18nText("BI-Current_Is_Last_Page"), - height: 20, - iconWidth: 16, - iconHeight: 16, - cls: "direction-pager-next row-next-page-h-font" - }, - - hasPrev: h.hasPrev, - hasNext: h.hasNext, - firstPage: h.firstPage, - lastPage: h.lastPage - }); - - this.hpager.on(BI.Pager.EVENT_CHANGE, function () { - self.fireEvent(BI.DirectionPager.EVENT_CHANGE); - }); - this.hpager.on(BI.Pager.EVENT_AFTER_POPULATE, function () { - self.hlabel.setValue(this.getCurrentPage()); - self.hlabel.setTitle(this.getCurrentPage()); - }); - }, - - getVPage: function () { - return this.vpager.getCurrentPage(); - }, - - getHPage: function () { - return this.hpager.getCurrentPage(); - }, - - setVPage: function (v) { - this.vpager.setValue(v); - this.vlabel.setValue(v); - this.vlabel.setTitle(v); - }, - - setHPage: function (v) { - this.hpager.setValue(v); - this.hlabel.setValue(v); - this.hlabel.setTitle(v); - }, - - hasVNext: function () { - return this.vpager.hasNext(); - }, - - hasHNext: function () { - return this.hpager.hasNext(); - }, - - hasVPrev: function () { - return this.vpager.hasPrev(); - }, - - hasHPrev: function () { - return this.hpager.hasPrev(); - }, - - setHPagerVisible: function (b) { - this.hpager.setVisible(b); - this.hlabel.setVisible(b); - }, - - setVPagerVisible: function (b) { - this.vpager.setVisible(b); - this.vlabel.setVisible(b); - }, - - populate: function () { - this.vpager.populate(); - this.hpager.populate(); - var vShow = false, hShow = false; - if (!this.hasHNext() && !this.hasHPrev()) { - this.setHPagerVisible(false); - } else { - this.setHPagerVisible(true); - hShow = true; - } - if (!this.hasVNext() && !this.hasVPrev()) { - this.setVPagerVisible(false); - } else { - this.setVPagerVisible(true); - vShow = true; - } - this.setVisible(hShow || vShow); - var num = [74, 111, -9, 28]; - var items = this.layout.attr("items"); - - if (vShow === true && hShow === true) { - items[0].right = num[0]; - items[1].right = num[1]; - items[2].right = num[2]; - items[3].right = num[3]; - } else if (vShow === true) { - items[0].right = num[2]; - items[1].right = num[3]; - } else if (hShow === true) { - items[2].right = num[2]; - items[3].right = num[3]; - } - this.layout.attr("items", items); - this.layout.resize(); - }, - - clear: function () { - this.vpager.attr("curr", 1); - this.hpager.attr("curr", 1); - } -}); -BI.DirectionPager.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.direction_pager", BI.DirectionPager);/** - * 分页控件 - * - * Created by GUY on 2015/8/31. - * @class BI.DetailPager - * @extends BI.Widget - */ -BI.DetailPager = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DetailPager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-detail-pager", - behaviors: {}, - layouts: [{ - type: "bi.horizontal", - hgap: 10, - vgap: 0 - }], - - dynamicShow: true, //是否动态显示上一页、下一页、首页、尾页, 若为false,则指对其设置使能状态 - //dynamicShow为false时以下两个有用 - dynamicShowFirstLast: false,//是否动态显示首页、尾页 - dynamicShowPrevNext: false,//是否动态显示上一页、下一页 - pages: false, //总页数 - curr: function () { - return 1; - }, //初始化当前页 - groups: 0, //连续显示分页数 - jump: BI.emptyFn, //分页的回调函数 - - first: false, //是否显示首页 - last: false, //是否显示尾页 - prev: "上一页", - next: "下一页", - - firstPage: 1, - lastPage: function () { //在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法 - return 1; - }, - hasPrev: BI.emptyFn, //pages不可用时有效 - hasNext: BI.emptyFn //pages不可用时有效 - }) - }, - _init: function () { - BI.DetailPager.superclass._init.apply(this, arguments); - var self = this; - this.currPage = BI.result(this.options, "curr"); - //翻页太灵敏 - this._lock = false; - this._debouce = BI.debounce(function () { - self._lock = false; - }, 300); - this._populate(); - }, - - _populate: function () { - var self = this, o = this.options, view = [], dict = {}; - this.empty(); - var pages = BI.result(o, "pages"); - var curr = BI.result(this, "currPage"); - var groups = BI.result(o, "groups"); - var first = BI.result(o, "first"); - var last = BI.result(o, "last"); - var prev = BI.result(o, "prev"); - var next = BI.result(o, "next"); - - if (pages === false) { - groups = 0; - first = false; - last = false; - } else { - groups > pages && (groups = pages); - } - - //计算当前组 - dict.index = Math.ceil((curr + ((groups > 1 && groups !== pages) ? 1 : 0)) / (groups === 0 ? 1 : groups)); - - //当前页非首页,则输出上一页 - if (((!o.dynamicShow && !o.dynamicShowPrevNext) || curr > 1) && prev !== false) { - if (BI.isKey(prev)) { - view.push({ - text: prev, - value: "prev", - disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) - }) - } else { - view.push(BI.extend({ - disabled: pages === false ? o.hasPrev(curr) === false : !(curr > 1 && prev !== false) - }, prev)); - } - } - - //当前组非首组,则输出首页 - if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (dict.index > 1 && groups !== 0)) && first) { - view.push({ - text: first, - value: "first", - disabled: !(dict.index > 1 && groups !== 0) - }); - if (dict.index > 1 && groups !== 0) { - view.push({ - type: "bi.label", - cls: "page-ellipsis", - text: "\u2026" - }); - } - } - - //输出当前页组 - dict.poor = Math.floor((groups - 1) / 2); - dict.start = dict.index > 1 ? curr - dict.poor : 1; - dict.end = dict.index > 1 ? (function () { - var max = curr + (groups - dict.poor - 1); - return max > pages ? pages : max; - }()) : groups; - if (dict.end - dict.start < groups - 1) { //最后一组状态 - dict.start = dict.end - groups + 1; - } - var s = dict.start, e = dict.end; - if (first && last && (dict.index > 1 && groups !== 0) && (pages > groups && dict.end < pages && groups !== 0)) { - s++; - e--; - } - for (; s <= e; s++) { - if (s === curr) { - view.push({ - text: s, - value: s, - selected: true - }) - } else { - view.push({ - text: s, - value: s - }) - } - } - - //总页数大于连续分页数,且当前组最大页小于总页,输出尾页 - if (((!o.dynamicShow && !o.dynamicShowFirstLast) || (pages > groups && dict.end < pages && groups !== 0)) && last) { - if (pages > groups && dict.end < pages && groups !== 0) { - view.push({ - type: "bi.label", - cls: "page-ellipsis", - text: "\u2026" - }); - } - view.push({ - text: last, - value: "last", - disabled: !(pages > groups && dict.end < pages && groups !== 0) - }) - } - - //当前页不为尾页时,输出下一页 - dict.flow = !prev && groups === 0; - if (((!o.dynamicShow && !o.dynamicShowPrevNext) && next) || (curr !== pages && next || dict.flow)) { - view.push((function () { - if (BI.isKey(next)) { - if (pages === false) { - return {text: next, value: "next", disabled: o.hasNext(curr) === false} - } - return (dict.flow && curr === pages) - ? - {text: next, value: "next", disabled: true} - : - {text: next, value: "next", disabled: !(curr !== pages && next || dict.flow)}; - } else { - return BI.extend({ - disabled: pages === false ? o.hasNext(curr) === false : !(curr !== pages && next || dict.flow) - }, next); - } - }())); - } - - this.button_group = BI.createWidget({ - type: "bi.button_group", - element: this, - items: BI.createItems(view, { - cls: "page-item bi-border bi-list-item-active", - height: 23, - hgap: 10 - }), - behaviors: o.behaviors, - layouts: o.layouts - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (self._lock === true) { - return; - } - self._lock = true; - self._debouce(); - if (type === BI.Events.CLICK) { - var v = self.button_group.getValue()[0]; - switch (v) { - case "first": - self.currPage = 1; - break; - case "last": - self.currPage = pages; - break; - case "prev": - self.currPage--; - break; - case "next": - self.currPage++; - break; - default: - self.currPage = v; - break; - } - o.jump.apply(self, [{ - pages: pages, - curr: self.currPage - }]); - self._populate(); - self.fireEvent(BI.DetailPager.EVENT_CHANGE, obj); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.fireEvent(BI.DetailPager.EVENT_AFTER_POPULATE); - }, - - getCurrentPage: function () { - return this.currPage; - }, - - setAllPages: function (pages) { - this.options.pages = pages; - }, - - hasPrev: function (v) { - v || (v = 1); - var o = this.options; - var pages = this.options.pages; - return pages === false ? o.hasPrev(v) : v > 1; - }, - - hasNext: function (v) { - v || (v = 1); - var o = this.options; - var pages = this.options.pages; - return pages === false ? o.hasNext(v) : v < pages; - }, - - setValue: function (v) { - var o = this.options; - v = v | 0; - v = v < 1 ? 1 : v; - if (o.pages === false) { - var lastPage = BI.result(o, "lastPage"), firstPage = 1; - this.currPage = v > lastPage ? lastPage : ((firstPage = BI.result(o, "firstPage")), (v < firstPage ? firstPage : v)); - } else { - v = v > o.pages ? o.pages : v; - this.currPage = v; - } - this._populate(); - }, - - getValue: function () { - var val = this.button_group.getValue()[0]; - switch (val) { - case "prev": - return -1; - case "next": - return 1; - case "first": - return BI.MIN; - case "last": - return BI.MAX; - default : - return val; - } - }, - - attr: function (key, value) { - BI.DetailPager.superclass.attr.apply(this, arguments); - if (key === "curr") { - this.currPage = BI.result(this.options, "curr"); - } - }, - - populate: function () { - this._populate(); - } -}); -BI.DetailPager.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DetailPager.EVENT_AFTER_POPULATE = "EVENT_AFTER_POPULATE"; -BI.shortcut("bi.detail_pager", BI.DetailPager);/** - * - * Created by GUY on 2017/09/18. - * @class BI.TextToolbar - * @extends BI.Widget - */ -BI.RichEditorAction = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorAction.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "" - }); - }, - - _init: function () { - BI.RichEditorAction.superclass._init.apply(this, arguments); - var self = this, o = this.options; - o.editor.on(BI.NicEditor.EVENT_SELECTED, function (e) { - self.setEnable(true); - self.checkNodes(e.target); - self.key(e); - }); - o.editor.on(BI.NicEditor.EVENT_BLUR, function () { - self.setEnable(false); - }); - o.editor.on(BI.NicEditor.EVENT_KEYDOWN, BI.bind(this.keydown, this)); - }, - - checkNodes: function (e) { - if (!e) { - return false; - } - var elm = e; - do { - if (this.options.tags && this.options.tags.contains(elm.nodeName)) { - this.activate(); - return true; - } - } while (elm = elm.parentNode && elm.className && elm.className.indexOf("bi-nic-editor") >= -1); - elm = e; - while (elm.nodeType == 3) { - elm = elm.parentNode; - } - if (this.options.css) { - for (var itm in this.options.css) { - if ($(elm).css(itm) == this.options.css[itm]) { - this.activate(); - return true; - } - } - } - this.deactivate(); - return false; - }, - - start: function () { - - }, - - key: function () { - - }, - - keydown: function () { - }, - - hideIf: function (e) { - - }, - - activate: function () { - }, - - deactivate: function () { - }, - - doCommand: function (args) { - if (this.options.command) { - this.options.editor.nicCommand(this.options.command, args); - } - } -});/** - * - * Created by GUY on 2017/09/18. - * @class BI.RichEditorParamAction - * @extends BI.Widget - */ -BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorParamAction.superclass._defaultConfig.apply(this, arguments), {}); - }, - - _init: function () { - BI.RichEditorParamAction.superclass._init.apply(this, arguments); - }, - - _isParam: function (sel) { - return sel.attr("data-type") === "param"; - }, - - _createBlankNode: function () { - return $("").html(" "); - }, - - _addBlank: function ($param) { - var o = this.options; - var instance = o.editor.selectedInstance; - var next = $param.next(); - if (next.length === 0 || this._isParam(next)) { - var preNode = this._createBlankNode(); - var nextNode = this._createBlankNode(); - $param.before(preNode); - $param.after(nextNode); - instance.setFocus(nextNode[0]); - } else { - instance.setFocus(next[0]); - } - }, - - _get$Sel: function () { - var o = this.options; - var instance = o.editor.selectedInstance; - var sel = $(instance.selElm()); - if (sel[0].nodeType === 3 && this._isParam(sel.parent())) { - sel = sel.parent(); - } - return sel; - }, - - addParam: function (param) { - var o = this.options; - var sel = this._get$Sel(); - var $param = $("").attr({ - "data-type": "param", - "data-value": param - }).css({ - color: "white", - backgroundColor: "#009de3", - padding: "0 5px" - }).text(param).keydown(function (e) { - if (e.keyCode === BI.KeyCode.BACKSPACE || e.keyCode === BI.KeyCode.DELETE) { - $param.destroy(); - } - e.stopEvent(); - return false; - }); - var wrapper = o.editor.instance.getElm().element; - if (wrapper.find(sel).length <= 0) { - wrapper.append($param); - } else { - sel.after($param); - } - this._addBlank($param); - }, - - keydown: function (e) { - var o = this.options; - var sel = this._get$Sel(); - if (e.keyCode === 229) {//中文输入法 - if (this._isParam(sel)) { - this._addBlank(sel); - e.stopEvent(); - return false; - } - } - if (BI.Key[e.keyCode] || e.keyCode === BI.KeyCode.TAB || e.keyCode === BI.KeyCode.ENTER || e.keyCode === BI.KeyCode.SPACE) { - if (this._isParam(sel)) { - e.stopEvent(); - return false; - } - } - if (e.keyCode === BI.KeyCode.BACKSPACE || e.keyCode === BI.KeyCode.DELETE) { - if (this._isParam(sel)) { - sel.destroy(); - e.preventDefault(); - return false; - } - } - }, - - key: function (e) { - } -});/** - * 颜色选择 - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorTextToolbar - * @extends BI.Widget - */ -BI.RichEditorTextToolbar = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-rich-editor-text-toolbar bi-background", - buttons: [ - {type: "bi.rich_editor_size_chooser"}, - {type: "bi.rich_editor_bold_button"}, - {type: "bi.rich_editor_italic_button"}, - {type: "bi.rich_editor_underline_button"}, - {type: "bi.rich_editor_color_chooser"}, - {type: "bi.rich_editor_background_color_chooser"}, - {type: "bi.rich_editor_align_left_button"}, - {type: "bi.rich_editor_align_center_button"}, - {type: "bi.rich_editor_align_right_button"}, - {type: "bi.rich_editor_param_button"} - ], - height: 28 - }); - }, - - _init: function () { - BI.RichEditorTextToolbar.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var buttons = BI.createWidgets(BI.map(o.buttons, function (i, btn) { - return BI.extend(btn, { - editor: o.editor - }); - })); - this.element.mousedown(function (e) { - BI.each(buttons, function (i, btn) { - btn.hideIf(e); - }); - }); - BI.createWidget({ - type: "bi.left", - element: this, - items: buttons, - hgap: 3, - vgap: 3 - }); - }, - - mounted: function () { - var self = this; - if (BI.isIE9Below()) {// IE8下必须要设置unselectable才能不blur输入框 - this.element.mousedown(function () { - self._noSelect(self.element[0]); - }); - this._noSelect(this.element[0]); - } - }, - - _noSelect: function (element) { - if (element.setAttribute && element.nodeName.toLowerCase() != "input" && element.nodeName.toLowerCase() != "textarea") { - element.setAttribute("unselectable", "on"); - } - for (var i = 0; i < element.childNodes.length; i++) { - this._noSelect(element.childNodes[i]); - } - } -}); -BI.shortcut("bi.rich_editor_text_toolbar", BI.RichEditorTextToolbar);/** - * 富文本编辑器 - * - * Created by GUY on 2017/9/15. - * @class BI.NicEditor - * @extends BI.Widget - */ -!(function () { - BI.NicEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.NicEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-nic-editor" - }); - }, - _init: function () { - BI.NicEditor.superclass._init.apply(this, arguments); - var o = this.options; - $(document).bind("mousedown." + this.getName(), BI.bind(this.selectCheck, this)); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [{ - type: "bi.layout", - height: 1 - }, this.instance = this.addInstance()] - }) - }, - - addInstance: function () { - var o = this.options; - var conf = { - ne: this, - height: o.height - 1, - maxHeight: o.maxHeight ? o.maxHeight : null - }; - if (this.element[0].contentEditable || !!window.opera) { - var newInstance = new nicEditorInstance(conf); - } else { - console.error("不支持此浏览器"); - } - return newInstance; - }, - - nicCommand: function (cmd, args) { - if (this.selectedInstance) { - this.selectedInstance.nicCommand(cmd, args); - } - }, - - selectCheck: function (e) { - var t = e.target; - var found = false; - do { - if (t.nodeName !== "svg" && t.className && t.className.indexOf(prefix) != -1) { - return; - // return false; - } - } while (t = t.parentNode); - this.fireEvent('blur', t); - this.lastSelectedInstance = this.selectedInstance; - this.selectedInstance = null; - // return false; - }, - - setValue: function (v) { - this.instance.setContent(v); - }, - - getValue: function () { - return this.instance.getContent(); - }, - - destroyed: function () { - $(document).unbind("mousedown." + this.getName()); - } - }); - BI.NicEditor.EVENT_SELECTED = "selected"; - BI.NicEditor.EVENT_BLUR = "blur"; - BI.NicEditor.EVENT_KEYDOWN = "keydown"; - BI.shortcut('bi.nic_editor', BI.NicEditor); - - var prefix = "niceditor-"; - - var nicEditorInstance = BI.inherit(BI.Layout, { - isSelected: false, - _init: function () { - nicEditorInstance.superclass._init.apply(this, arguments); - var o = this.options; - this.ne = this.options.ne; - this.elm = BI.createWidget({ - type: "bi.layout", - width: o.width - 8, - scrollable: false - }); - this.elm.element.css({ - margin: "4px", - minHeight: (o.height - 8) + "px", - outline: "none" - }).html(o.value); - - this.element.css("maxHeight", (o.maxHeight) ? o.maxHeight + 'px' : null); - - this.e = BI.createWidget({ - type: "bi.layout", - invisible: true, - tagName: "textarea" - }); - BI.createWidget({ - type: "bi.default", - element: this, - scrolly: true, - items: [this.elm, this.e] - }); - - this.ne.on("blur", BI.bind(this.blur, this)); - - this.start(); - this.blur(); - }, - - start: function () { - this.elm.element.attr("contentEditable", true); - if (this.getContent() == "") { - // this.setContent("
"); - } - this.instanceDoc = document.defaultView; - this.elm.element.on('mousedown', BI.bind(this.selected, this)); - this.elm.element.on('keydown', BI.bind(this.keyDown, this)); - this.elm.element.on('focus', BI.bind(this.selected, this)); - this.elm.element.on('blur', BI.bind(this.blur, this)); - this.elm.element.on('keyup', BI.bind(this.selected, this)); - this.ne.fireEvent('add'); - }, - - disable: function () { - this.elm.element.attr("contentEditable", false); - }, - - getSel: function () { - return (window.getSelection) ? window.getSelection() : document.selection; - }, - - getRng: function () { - var s = this.getSel(); - if (!s || s.rangeCount === 0) { - return; - } - return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange(); - }, - - selRng: function (rng, s) { - if (window.getSelection) { - s.removeAllRanges(); - s.addRange(rng); - } else { - rng.select(); - } - }, - - selElm: function () { - var r = this.getRng(); - if (!r) { - return; - } - if (r.startContainer) { - var contain = r.startContainer; - if (r.cloneContents().childNodes.length == 1) { - for (var i = 0; i < contain.childNodes.length; i++) { - var rng = contain.childNodes[i].ownerDocument.createRange(); - rng.selectNode(contain.childNodes[i]); - if (r.compareBoundaryPoints(Range.START_TO_START, rng) != 1 && - r.compareBoundaryPoints(Range.END_TO_END, rng) != -1) { - return contain.childNodes[i]; - } - } - } - return contain; - } else { - return (this.getSel().type == "Control") ? r.item(0) : r.parentElement(); - } - }, - - saveRng: function () { - this.savedRange = this.getRng(); - this.savedSel = this.getSel(); - }, - - setFocus: function (el) { - try { - el.focus(); - } catch (e) { - - } - if (!window.getSelection) { - var rng; - try { - el.focus(); - } catch (e) { - - } - rng = document.selection.createRange(); - rng.moveStart('character', -el.innerText.length); - var text = rng.text; - for (var i = 0; i < el.innerText.length; i++) { - if (el.innerText.substring(0, i + 1) == text.substring(text.length - i - 1, text.length)) { - result = i + 1; - } - } - } else { - var range = document.createRange(); - range.selectNodeContents(el); - range.collapse(false); - var sel = window.getSelection(); - sel.removeAllRanges(); - sel.addRange(range); - } - }, - - restoreRng: function () { - if (this.savedRange) { - this.selRng(this.savedRange, this.savedSel); - } - }, - - keyDown: function (e, t) { - this.ne.fireEvent('keydown', e); - }, - - selected: function (e) { - var t = e.target; - if (!t && !(t = this.selElm())) { - t = this.selElm(); - } - if (!e.ctrlKey) { - var selInstance = this.ne.selectedInstance; - if (selInstance != this) { - if (selInstance) { - this.ne.fireEvent('blur', e); - } - this.ne.selectedInstance = this; - this.ne.fireEvent('focus', e); - } - this.ne.fireEvent('selected', e); - this.isFocused = true; - this.elm.element.addClass(prefix + 'selected'); - } - // return false; - }, - - blur: function () { - this.isFocused = false; - this.elm.element.removeClass(prefix + 'selected'); - }, - - saveContent: function () { - this.ne.fireEvent('save'); - this.e.element.value(this.getContent()); - }, - - getElm: function () { - return this.elm; - }, - - getContent: function () { - this.content = this.getElm().element.html(); - this.ne.fireEvent('get'); - return this.content; - }, - - setContent: function (e) { - this.content = e; - this.ne.fireEvent('set'); - this.elm.element.html(this.content); - }, - - nicCommand: function (cmd, args) { - document.execCommand(cmd, false, args); - } - }); -}()); -/** - * 颜色选择trigger - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorBackgroundChooserTrigger - * @extends BI.Widget - */ -BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - width: 20, - height: 20 - }); - }, - - _init: function () { - BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments); - this.font = BI.createWidget({ - type: "bi.icon_button", - cls: "text-background-font" - }); - - this.underline = BI.createWidget({ - type: "bi.icon_button", - cls: "text-color-underline-font" - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.font, - top: 2, - left: 2 - }, { - el: this.underline, - top: 7, - left: 2 - }] - }) - }, - - setValue: function (color) { - this.underline.element.css("color", color); - }, - - getValue: function () { - return this.font.element.css("color"); - } -}); -BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorAlignCenterButton - * @extends BI.RichEditorAction - */ -BI.RichEditorAlignCenterButton = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorAlignCenterButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "justifycenter" - }); - }, - - _init: function () { - BI.RichEditorAlignCenterButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.align = BI.createWidget({ - type: "bi.icon_button", - element: this, - forceNotSelected: true, - title: BI.i18nText("BI-Word_Align_Center"), - height: 20, - width: 20, - cls: "text-toolbar-button bi-list-item-active text-align-center-font" - }); - this.align.on(BI.IconButton.EVENT_CHANGE, function () { - self.doCommand(); - }); - }, - activate: function () { - }, - - deactivate: function () { - } -}); -BI.shortcut("bi.rich_editor_align_center_button", BI.RichEditorAlignCenterButton)/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorAlignLeftButton - * @extends BI.RichEditorAction - */ -BI.RichEditorAlignLeftButton = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorAlignLeftButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "justifyleft" - }); - }, - - _init: function () { - BI.RichEditorAlignLeftButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.align = BI.createWidget({ - type: "bi.icon_button", - element: this, - forceNotSelected: true, - title: BI.i18nText("BI-Word_Align_Left"), - height: 20, - width: 20, - cls: "text-toolbar-button bi-list-item-active text-align-left-font" - }); - this.align.on(BI.IconButton.EVENT_CHANGE, function () { - self.doCommand(); - }); - }, - activate: function () { - }, - - deactivate: function () { - } -}); -BI.shortcut("bi.rich_editor_align_left_button", BI.RichEditorAlignLeftButton)/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorAlignRightButton - * @extends BI.RichEditorAction - */ -BI.RichEditorAlignRightButton = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorAlignRightButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "justifyright" - }); - }, - - _init: function () { - BI.RichEditorAlignRightButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.align = BI.createWidget({ - type: "bi.icon_button", - element: this, - forceNotSelected: true, - title: BI.i18nText("BI-Word_Align_Right"), - height: 20, - width: 20, - cls: "text-toolbar-button bi-list-item-active text-align-right-font" - }); - this.align.on(BI.IconButton.EVENT_CHANGE, function () { - self.doCommand(); - }); - }, - activate: function () { - }, - - deactivate: function () { - } -}); -BI.shortcut("bi.rich_editor_align_right_button", BI.RichEditorAlignRightButton)/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorBoldButton - * @extends BI.RichEditorAction - */ -BI.RichEditorBoldButton = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorBoldButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "Bold", - tags: ["B", "STRONG"], - css: {fontWeight: "bold"} - }); - }, - - _init: function () { - BI.RichEditorBoldButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.bold = BI.createWidget({ - type: "bi.icon_button", - element: this, - title: BI.i18nText("BI-Basic_Bold"), - height: 20, - width: 20, - cls: "text-toolbar-button bi-list-item-active text-bold-font" - }); - this.bold.on(BI.IconButton.EVENT_CHANGE, function () { - self.doCommand(); - }); - }, - activate: function () { - this.bold.setSelected(true); - }, - - deactivate: function () { - this.bold.setSelected(false); - } -}); -BI.shortcut("bi.rich_editor_bold_button", BI.RichEditorBoldButton)/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorItalicButton - * @extends BI.RichEditorAction - */ -BI.RichEditorItalicButton = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorItalicButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "Italic", - tags: ["EM", "I"], - css: {fontStyle: "italic"} - }); - }, - - _init: function () { - BI.RichEditorItalicButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.italic = BI.createWidget({ - type: "bi.icon_button", - element: this, - title: BI.i18nText("BI-Basic_Italic"), - height: 20, - width: 20, - cls: "text-toolbar-button bi-list-item-active text-italic-font" - }); - this.italic.on(BI.IconButton.EVENT_CHANGE, function () { - self.doCommand(); - }); - }, - activate: function () { - this.italic.setSelected(true); - }, - - deactivate: function () { - this.italic.setSelected(false); - } -}); -BI.shortcut("bi.rich_editor_italic_button", BI.RichEditorItalicButton)/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorParamButton - * @extends BI.RichEditorParamAction - */ -BI.RichEditorParamButton = BI.inherit(BI.RichEditorParamAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorParamButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20 - }); - }, - - _init: function () { - BI.RichEditorParamButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.param = BI.createWidget({ - type: "bi.button", - element: this, - level: "ignore", - minWidth: 0, - text: BI.i18nText("BI-Formula_Insert"), - height: 20, - width: 30 - }); - this.param.on(BI.Button.EVENT_CHANGE, function () { - self.addParam("参数") - }); - }, - activate: function () { - }, - - deactivate: function () { - } -}); -BI.shortcut("bi.rich_editor_param_button", BI.RichEditorParamButton)/** - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorItalicButton - * @extends BI.RichEditorAction - */ -BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorUnderlineButton.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "Underline", - tags: ["U"], - css: {textDecoration: "underline"} - }); - }, - - _init: function () { - BI.RichEditorUnderlineButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.underline = BI.createWidget({ - type: "bi.icon_button", - element: this, - title: BI.i18nText("BI-Basic_Underline"), - height: 20, - width: 20, - cls: "text-toolbar-button bi-list-item-active text-underline-font" - }); - this.underline.on(BI.IconButton.EVENT_CHANGE, function () { - self.doCommand(); - }); - }, - activate: function () { - this.underline.setSelected(true); - }, - - deactivate: function () { - this.underline.setSelected(false); - } -}); -BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/** - * 颜色选择trigger - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorColorChooserTrigger - * @extends BI.Widget - */ -BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - width: 20, - height: 20 - }); - }, - - _init: function () { - BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments); - this.font = BI.createWidget({ - type: "bi.icon_button", - cls: "text-color-font" - }); - - this.underline = BI.createWidget({ - type: "bi.icon_button", - cls: "text-color-underline-font" - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.font, - top: 2, - left: 2 - }, { - el: this.underline, - top: 7, - left: 2 - }] - }) - }, - - setValue: function (color) { - this.underline.element.css("color", color); - }, - - getValue: function () { - return this.font.element.css("color"); - } -}); -BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/** - * 颜色选择 - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorBackgroundColorChooser - * @extends BI.RichEditorAction - */ -BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20 - }); - }, - - _init: function () { - BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.colorchooser = BI.createWidget({ - type: "bi.color_chooser", - element: this, - width: o.width, - height: o.height, - el: { - type: "bi.rich_editor_background_color_chooser_trigger", - title: BI.i18nText("BI-Widget_Background_Colour"), - cls: "text-toolbar-button" - } - }); - this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { - var backgroundColor = this.getValue(); - o.editor.element.css({ - backgroundColor: backgroundColor, - color: BI.DOM.getContrastColor(backgroundColor) - }); - this.setValue(""); - }); - }, - - hideIf: function (e) { - if(!this.colorchooser.element.find(e.target).length > 0) { - this.colorchooser.hideView(); - } - }, - - deactivate: function () { - } -}); -BI.shortcut("bi.rich_editor_background_color_chooser", BI.RichEditorBackgroundColorChooser);/** - * 颜色选择 - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorColorChooser - * @extends BI.RichEditorAction - */ -BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), { - width: 20, - height: 20, - command: "foreColor" - }); - }, - - _init: function () { - BI.RichEditorColorChooser.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.colorchooser = BI.createWidget({ - type: "bi.color_chooser", - element: this, - width: o.width, - height: o.height, - el: { - type: "bi.rich_editor_color_chooser_trigger", - title: BI.i18nText("BI-Font_Colour"), - cls: "text-toolbar-button" - } - }); - this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { - self.doCommand(this.getValue()); - }); - - }, - - hideIf: function (e) { - if(!this.colorchooser.element.find(e.target).length > 0) { - this.colorchooser.hideView(); - } - }, - - deactivate: function () { - this.colorchooser.setValue(""); - } -}); -BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/** - * 字体大小选择 - * - * Created by GUY on 2015/11/26. - * @class BI.RichEditorSizeChooser - * @extends BI.RichEditorAction - */ -BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, { - _defaultConfig: function () { - return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-rich-editor-size-chooser bi-border bi-card", - command: "FontSize", - width: 50, - height: 20 - }); - }, - - _items: [{ - value: 1, - text: "1(8pt)" - }, { - value: 2, - text: "2(10pt)" - }, { - value: 3, - text: "3(12pt)" - }, { - value: 4, - text: "4(14pt)" - }, { - value: 5, - text: "5(18pt)" - }, { - value: 6, - text: "6(24pt)" - }], - - _init: function () { - BI.RichEditorSizeChooser.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.text_trigger", - readonly: true, - height: o.height, - triggerWidth: 16, - text: BI.i18nText("BI-Font_Size") - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - el: this.trigger, - adjustLength: 1, - popup: { - maxWidth: 70, - minWidth: 70, - el: { - type: "bi.button_group", - items: BI.createItems(this._items, { - type: "bi.single_select_item" - }), - layouts: [{ - type: "bi.vertical" - }] - } - } - }); - this.combo.on(BI.Combo.EVENT_CHANGE, function () { - var val = this.getValue()[0]; - self.doCommand(val); - this.hideView(); - this.setValue([]); - }); - }, - - hideIf: function (e) { - if(!this.combo.element.find(e.target).length > 0) { - this.combo.hideView(); - } - } -}); -BI.shortcut("bi.rich_editor_size_chooser", BI.RichEditorSizeChooser);/** - * 富文本编辑器 - * - * Created by GUY on 2017/9/15. - * @class BI.RichEditor - * @extends BI.Widget - */ -BI.RichEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.RichEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-rich-editor bi-card", - toolbar: {} - }); - }, - _init: function () { - BI.RichEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.nic_editor", - width: o.width, - height: o.height - }); - - this.editor.on(BI.NicEditor.EVENT_BLUR, function () { - self.fireEvent(BI.RichEditor.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - toggle: false, - direction: "top,left", - isNeedAdjustWidth: false, - isNeedAdjustHeight: false, - adjustLength: 1, - el: this.editor, - popup: { - el: BI.extend({ - type: "bi.rich_editor_text_toolbar", - editor: this.editor - }, o.toolbar), - height: 30, - stopPropagation: true, - stopEvent: true - } - }); - - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - }); - }, - - setValue: function (v) { - this.editor.setValue(v); - }, - - getValue: function () { - return this.editor.getValue(); - } -}); -BI.RichEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut('bi.rich_editor', BI.RichEditor);/** - * 分段控件使用的button - * - * Created by GUY on 2015/9/7. - * @class BI.SegmentButton - * @extends BI.BasicButton - */ -BI.SegmentButton = BI.inherit(BI.BasicButton, { - - _defaultConfig: function () { - var conf = BI.SegmentButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + ' bi-segment-button bi-list-item-active', - shadow: true, - readonly: true, - hgap: 5 - }) - }, - - _init: function () { - BI.SegmentButton.superclass._init.apply(this, arguments); - var opts = this.options, self = this; - //if (BI.isNumber(opts.height) && BI.isNull(opts.lineHeight)) { - // this.element.css({lineHeight : (opts.height - 2) + 'px'}); - //} - this.text = BI.createWidget({ - type: "bi.label", - element: this, - height: opts.height - 2, - whiteSpace: opts.whiteSpace, - text: opts.text, - value: opts.value, - hgap: opts.hgap - }) - }, - - setSelected: function () { - BI.SegmentButton.superclass.setSelected.apply(this, arguments); - }, - - setText: function (text) { - BI.SegmentButton.superclass.setText.apply(this, arguments); - this.text.setText(text); - }, - - destroy: function () { - BI.SegmentButton.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut('bi.segment_button', BI.SegmentButton);/** - * 单选按钮组 - * - * Created by GUY on 2015/9/7. - * @class BI.Segment - * @extends BI.Widget - */ -BI.Segment = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.Segment.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-segment", - items: [], - height: 24 - }); - }, - _init: function () { - BI.Segment.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.buttonGroup = BI.createWidget({ - element: this, - type: "bi.button_group", - items: BI.createItems(o.items, { - type: "bi.segment_button", - height: o.height - 2, - whiteSpace: o.whiteSpace - }), - layout: [ - { - type: "bi.center" - } - ] - }) - this.buttonGroup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments) - }); - this.buttonGroup.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { - self.fireEvent(BI.Segment.EVENT_CHANGE, value, obj) - }) - }, - - setValue: function (v) { - this.buttonGroup.setValue(v); - }, - - setEnabledValue: function (v) { - this.buttonGroup.setEnabledValue(v); - }, - - getValue: function () { - return this.buttonGroup.getValue(); - } -}); -BI.Segment.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.segment', BI.Segment);/** - * 自适应宽度的表格 - * - * Created by GUY on 2016/2/3. - * @class BI.AdaptiveTable - * @extends BI.Widget - */ -BI.AdaptiveTable = BI.inherit(BI.Widget, { - - _const: { - perColumnSize: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.AdaptiveTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-adaptive-table", - el: { - type: "bi.resizable_table" - }, - isNeedResize: true, - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false,//是否需要合并单元格 - mergeCols: [], //合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - header: [], - items: [], //二维数组 - - //交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.AdaptiveTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var data = this._digest(); - this.table = BI.createWidget(o.el, { - type: "bi.resizable_table", - element: this, - width: o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: false, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: data.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: data.columnSize, - - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: data.regionColumnSize, - - header: o.header, - items: o.items, - //交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - self._populate(); - self.table.populate(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.columnSize = this.getColumnSize(); - self._populate(); - self.table.populate(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - _getFreezeColLength: function () { - var o = this.options; - return o.isNeedFreeze === true ? BI.clamp(o.freezeCols.length, 0, o.columnSize.length) : 0; - }, - - _digest: function () { - var o = this.options; - var columnSize = o.columnSize.slice(); - var regionColumnSize = o.regionColumnSize.slice(); - var freezeCols = o.freezeCols.slice(); - var regionSize = o.regionColumnSize[0]; - var freezeColLength = this._getFreezeColLength(); - if (!regionSize || regionSize > o.width - 10 || regionSize < 10) { - regionSize = (freezeColLength > o.columnSize.length / 2 ? 2 / 3 : 1 / 3) * o.width; - } - if (freezeColLength === 0) { - regionSize = 0; - } - if (freezeCols.length >= columnSize.length) { - freezeCols = []; - } - if (!BI.isNumber(columnSize[0])) { - columnSize = o.minColumnSize.slice(); - } - var summaryFreezeColumnSize = 0, summaryColumnSize = 0; - BI.each(columnSize, function (i, size) { - if (i < freezeColLength) { - summaryFreezeColumnSize += size; - } - summaryColumnSize += size; - }); - if (freezeColLength > 0) { - columnSize[freezeColLength - 1] = BI.clamp(regionSize - (summaryFreezeColumnSize - columnSize[freezeColLength - 1]), - o.minColumnSize[freezeColLength - 1] || 10, o.maxColumnSize[freezeColLength - 1] || Number.MAX_VALUE); - } - if (columnSize.length > 0) { - columnSize[columnSize.length - 1] = BI.clamp(o.width - BI.GridTableScrollbar.SIZE - regionSize - (summaryColumnSize - summaryFreezeColumnSize - columnSize[columnSize.length - 1]), - o.minColumnSize[columnSize.length - 1] || 10, o.maxColumnSize[columnSize.length - 1] || Number.MAX_VALUE); - } - regionColumnSize[0] = regionSize; - - return { - freezeCols: freezeCols, - columnSize: columnSize, - regionColumnSize: regionColumnSize - } - }, - - _populate: function () { - var o = this.options; - var data = this._digest(); - o.regionColumnSize = data.regionColumnSize; - o.columnSize = data.columnSize; - this.table.setColumnSize(data.columnSize); - this.table.setRegionColumnSize(data.regionColumnSize); - this.table.attr("freezeCols", data.freezeCols); - }, - - setWidth: function (width) { - BI.AdaptiveTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.AdaptiveTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (regionColumnSize) { - this.options.regionColumnSize = regionColumnSize; - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - attr: function (key, value) { - var v = BI.AdaptiveTable.superclass.attr.apply(this, arguments); - if (key === "freezeCols") { - return v; - } - return this.table.attr.apply(this.table, arguments); - }, - - restore: function () { - this.table.restore(); - }, - - populate: function (items) { - var self = this, o = this.options; - this._populate(); - this.table.populate.apply(this.table, arguments); - }, - - destroy: function () { - this.table.destroy(); - BI.AdaptiveTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut('bi.adaptive_table', BI.AdaptiveTable);/** - * - * 层级树状结构的表格 - * - * Created by GUY on 2016/8/12. - * @class BI.DynamicSummaryLayerTreeTable - * @extends BI.Widget - */ -BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DynamicSummaryLayerTreeTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-dynamic-summary-layer-tree-table", - - el: { - type: "bi.resizable_table" - }, - isNeedResize: true,//是否需要调整列宽 - isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - - isNeedMerge: true,//是否需要合并单元格 - mergeCols: [], - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - footerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - //行表头 - rowHeaderCreator: null, - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - footer: false, - items: [], - - //交叉表头 - crossHeader: [], - crossItems: [] - }) - }, - - _getVDeep: function () { - return this.options.crossHeader.length;//纵向深度 - }, - - _getHDeep: function () { - var o = this.options; - return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); - }, - - _createHeader: function (vDeep) { - var self = this, o = this.options; - var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep, o.headerCellStyleGetter); - var result = []; - BI.each(items, function (row, node) { - var c = [crossHeader[row]]; - result.push(c.concat(node || [])); - }); - if (header && header.length > 0) { - var newHeader = this._formatColumns(header); - var deep = this._getHDeep(); - if (deep <= 0) { - newHeader.unshift(o.rowHeaderCreator || { - type: "bi.table_style_cell", - text: BI.i18nText("BI-Row_Header"), - styleGetter: o.headerCellStyleGetter - }); - } else { - newHeader[0] = o.rowHeaderCreator || { - type: "bi.table_style_cell", - text: BI.i18nText("BI-Row_Header"), - styleGetter: o.headerCellStyleGetter - }; - } - result.push(newHeader); - } - return result; - }, - - _formatItems: function (nodes, header, deep) { - var self = this, o = this.options; - var result = []; - - function track(node, layer) { - node.type || (node.type = "bi.layer_tree_table_cell"); - node.layer = layer; - var next = [node]; - next = next.concat(node.values || []); - if (next.length > 0) { - result.push(next); - } - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - track(child, layer + 1); - }); - } - } - - BI.each(nodes, function (i, node) { - BI.each(node.children, function (j, c) { - track(c, 0); - }); - if (BI.isArray(node.values)) { - var next = [{ - type: "bi.table_style_cell", - text: BI.i18nText("BI-Summary_Values"), - styleGetter: function () { - return o.summaryCellStyleGetter(true); - } - }].concat(node.values); - result.push(next) - } - }); - return BI.DynamicSummaryTreeTable.formatSummaryItems(result, header, o.crossItems, 1); - }, - - _formatColumns: function (columns, deep) { - if (BI.isNotEmptyArray(columns)) { - deep = deep || this._getHDeep(); - return columns.slice(Math.max(0, deep - 1)); - } - return columns; - }, - - _formatFreezeCols: function () { - if (this.options.freezeCols.length > 0) { - return [0]; - } - return []; - }, - - _formatColumnSize: function (columnSize, deep) { - if (columnSize.length <= 0) { - return []; - } - var result = [0]; - deep = deep || this._getHDeep(); - BI.each(columnSize, function (i, size) { - if (i < deep) { - result[0] += size; - return; - } - result.push(size); - }); - return result; - }, - - _recomputeColumnSize: function () { - var o = this.options; - o.regionColumnSize = this.table.getRegionColumnSize(); - var columnSize = this.table.getColumnSize().slice(); - if (o.freezeCols.length > 1) { - for (var i = 0; i < o.freezeCols.length - 1; i++) { - columnSize.splice(1, 0, 0); - } - } - o.columnSize = columnSize; - }, - - _digest: function () { - var o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = this._createHeader(vDeep); - var data = this._formatItems(o.items, header, deep); - var columnSize = o.columnSize.slice(); - var minColumnSize = o.minColumnSize.slice(); - var maxColumnSize = o.maxColumnSize.slice(); - BI.removeAt(columnSize, data.deletedCols); - BI.removeAt(minColumnSize, data.deletedCols); - BI.removeAt(maxColumnSize, data.deletedCols); - return { - header: data.header, - items: data.items, - columnSize: this._formatColumnSize(columnSize, deep), - minColumnSize: this._formatColumns(minColumnSize, deep), - maxColumnSize: this._formatColumns(maxColumnSize, deep), - freezeCols: this._formatFreezeCols() - } - }, - - _init: function () { - BI.DynamicSummaryLayerTreeTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var data = this._digest(); - this.table = BI.createWidget(o.el, { - type: "bi.resizable_table", - element: this, - width: o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - isNeedFreeze: o.isNeedFreeze, - freezeCols: data.freezeCols, - isNeedMerge: o.isNeedMerge, - mergeCols: [], - mergeRule: o.mergeRule, - columnSize: data.columnSize, - minColumnSize: data.minColumnSize, - maxColumnSize: data.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - regionColumnSize: o.regionColumnSize, - header: data.header, - items: data.items - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - self._recomputeColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - self._recomputeColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - setWidth: function (width) { - BI.DynamicSummaryLayerTreeTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.DynamicSummaryLayerTreeTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - }, - - getColumnSize: function () { - return this.options.columnSize; - }, - - setRegionColumnSize: function (columnSize) { - this.options.regionColumnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - attr: function (key, value) { - var self = this; - if (BI.isObject(key)) { - BI.each(key, function (k, v) { - self.attr(k, v); - }); - return; - } - BI.DynamicSummaryLayerTreeTable.superclass.attr.apply(this, arguments); - switch (key) { - case "columnSize": - case "minColumnSize": - case "maxColumnSize": - case "freezeCols": - case "mergeCols": - return; - } - this.table.attr.apply(this.table, [key, value]); - }, - - restore: function () { - this.table.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - var data = this._digest(); - this.table.setColumnSize(data.columnSize); - this.table.attr("minColumnSize", data.minColumnSize); - this.table.attr("maxColumnSize", data.maxColumnSize); - this.table.attr("freezeCols", data.freezeCols); - this.table.populate(data.items, data.header); - }, - - destroy: function () { - this.table.destroy(); - BI.DynamicSummaryLayerTreeTable.superclass.destroy.apply(this, arguments); - } -}); - -BI.shortcut("bi.dynamic_summary_layer_tree_table", BI.DynamicSummaryLayerTreeTable);/** - * - * 树状结构的表格 - * - * Created by GUY on 2015/8/12. - * @class BI.DynamicSummaryTreeTable - * @extends BI.Widget - */ -BI.DynamicSummaryTreeTable = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DynamicSummaryTreeTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-dynamic-summary-tree-table", - el: { - type: "bi.resizable_table" - }, - - isNeedResize: true,//是否需要调整列宽 - isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - - isNeedMerge: true,//是否需要合并单元格 - mergeCols: [], - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - footerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - footer: false, - items: [], - - //交叉表头 - crossHeader: [], - crossItems: [] - }) - }, - - _getVDeep: function () { - return this.options.crossHeader.length;//纵向深度 - }, - - _getHDeep: function () { - var o = this.options; - return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); - }, - - _init: function () { - BI.DynamicSummaryTreeTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var data = this._digest(); - this.table = BI.createWidget(o.el, { - type: "bi.resizable_table", - element: this, - width: o.width, - height: o.height, - - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - header: data.header, - items: data.items - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - var columnSize = this.getColumnSize(); - var length = o.columnSize.length - columnSize.length; - o.columnSize = columnSize.slice(); - o.columnSize = o.columnSize.concat(BI.makeArray(length, 0)); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - var columnSize = this.getColumnSize(); - var length = o.columnSize.length - columnSize.length; - o.columnSize = columnSize.slice(); - o.columnSize = o.columnSize.concat(BI.makeArray(length, 0)); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - _digest: function () { - var o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); - var items = BI.DynamicSummaryTreeTable.formatHorizontalItems(o.items, deep, false, o.summaryCellStyleGetter); - var data = BI.DynamicSummaryTreeTable.formatSummaryItems(items, header, o.crossItems, deep); - var columnSize = o.columnSize.slice(); - var minColumnSize = o.minColumnSize.slice(); - var maxColumnSize = o.maxColumnSize.slice(); - BI.removeAt(columnSize, data.deletedCols); - BI.removeAt(minColumnSize, data.deletedCols); - BI.removeAt(maxColumnSize, data.deletedCols); - return { - header: data.header, - items: data.items, - columnSize: columnSize, - minColumnSize: minColumnSize, - maxColumnSize: maxColumnSize - }; - }, - - setWidth: function (width) { - BI.DynamicSummaryTreeTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.DynamicSummaryTreeTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - }, - - getColumnSize: function () { - return this.options.columnSize; - }, - - setRegionColumnSize: function (columnSize) { - this.options.regionColumnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - attr: function (key) { - BI.DynamicSummaryTreeTable.superclass.attr.apply(this, arguments); - switch (key) { - case "minColumnSize": - case "maxColumnSize": - return; - } - this.table.attr.apply(this.table, arguments); - }, - - restore: function () { - this.table.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - var data = this._digest(); - this.table.setColumnSize(data.columnSize); - this.table.attr("minColumnSize", data.minColumnSize); - this.table.attr("maxColumnSize", data.maxColumnSize); - this.table.populate(data.items, data.header); - }, - - destroy: function () { - this.table.destroy(); - BI.DynamicSummaryTreeTable.superclass.destroy.apply(this, arguments); - } -}); - -BI.extend(BI.DynamicSummaryTreeTable, { - - formatHorizontalItems: function (nodes, deep, isCross, styleGetter) { - var result = []; - - function track(store, node) { - var next; - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var next; - if (store != -1) { - next = store.slice(); - next.push(node); - } else { - next = []; - } - track(next, child); - }); - if (store != -1) { - next = store.slice(); - next.push(node); - } else { - next = []; - } - if ((store == -1 || node.children.length > 1) && BI.isNotEmptyArray(node.values)) { - var summary = { - text: BI.i18nText("BI-Summary_Values"), - type: "bi.table_style_cell", - styleGetter: function () { - return styleGetter(store === -1) - } - }; - for (var i = next.length; i < deep; i++) { - next.push(summary); - } - if (!isCross) { - next = next.concat(node.values); - } - if (next.length > 0) { - if (!isCross) { - result.push(next); - } else { - for (var k = 0, l = node.values.length; k < l; k++) { - result.push(next); - } - } - } - } - return; - } - if (store != -1) { - next = store.slice(); - for (var i = next.length; i < deep; i++) { - next.push(node); - } - } else { - next = []; - } - if (!isCross && BI.isArray(node.values)) { - next = next.concat(node.values); - } - if (isCross && BI.isArray(node.values)) { - for (var i = 0, len = node.values.length; i < len - 1; i++) { - if (next.length > 0) { - result.push(next); - } - } - } - if (next.length > 0) { - result.push(next); - } - } - - BI.each(nodes, function (i, node) { - track(-1, node); - }); - //填充空位 - BI.each(result, function (i, line) { - var last = BI.last(line); - for (var j = line.length; j < deep; j++) { - line.push(last); - } - }); - return result; - }, - - formatSummaryItems: function (items, header, crossItems, deep) { - //求纵向需要去除的列 - var cols = []; - var leaf = 0; - - function track(node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - track(child); - }); - if (BI.isNotEmptyArray(node.values)) { - if (node.children.length === 1) { - for (var i = 0; i < node.values.length; i++) { - cols.push(leaf + i + deep); - } - } - leaf += node.values.length; - } - return; - } - if (node.values && node.values.length > 1) { - leaf += node.values.length; - } else { - leaf++; - } - } - - BI.each(crossItems, function (i, node) { - track(node); - }); - - if (cols.length > 0) { - var nHeader = [], nItems = []; - BI.each(header, function (i, node) { - var nNode = node.slice(); - BI.removeAt(nNode, cols); - nHeader.push(nNode); - }); - BI.each(items, function (i, node) { - var nNode = node.slice(); - BI.removeAt(nNode, cols); - nItems.push(nNode);; - }); - header = nHeader; - items = nItems; - } - return {items: items, header: header, deletedCols: cols}; - } -}); - -BI.shortcut("bi.dynamic_summary_tree_table", BI.DynamicSummaryTreeTable);/** - * Created by GUY on 2016/5/7. - * @class BI.LayerTreeTableCell - * @extends BI.Single - */ -BI.LayerTreeTableCell = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.LayerTreeTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-layer-tree-table-cell", - layer: 0, - text: "" - }) - }, - - _init: function () { - BI.LayerTreeTableCell.superclass._init.apply(this, arguments); - var o = this.options; - BI.createWidget({ - type: "bi.label", - element: this.element, - textAlign: "left", - whiteSpace: "nowrap", - height: o.height, - text: o.text, - value: o.value, - lgap: 5 + 30 * o.layer, - rgap: 5 - }) - } -}); - -BI.shortcut("bi.layer_tree_table_cell", BI.LayerTreeTableCell);/** - * - * 层级树状结构的表格 - * - * Created by GUY on 2016/5/7. - * @class BI.LayerTreeTable - * @extends BI.Widget - */ -BI.LayerTreeTable = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.LayerTreeTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-layer-tree-table", - el: { - type: "bi.resizable_table" - }, - - isNeedResize: false,//是否需要调整列宽 - isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 - - isNeedFreeze: false,//是否需要冻结单元格 - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - - isNeedMerge: true,//是否需要合并单元格 - mergeCols: [], - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - rowHeaderCreator: null, - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], - - //交叉表头 - crossHeader: [], - crossItems: [] - }) - }, - - _getVDeep: function () { - return this.options.crossHeader.length;//纵向深度 - }, - - _getHDeep: function () { - var o = this.options; - return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); - }, - - _createHeader: function (vDeep) { - var self = this, o = this.options; - var header = o.header || [], crossHeader = o.crossHeader || []; - var items = BI.TableTree.formatCrossItems(o.crossItems, vDeep, o.headerCellStyleGetter); - var result = []; - BI.each(items, function (row, node) { - var c = [crossHeader[row]]; - result.push(c.concat(node || [])); - }); - if (header && header.length > 0) { - var newHeader = this._formatColumns(header); - var deep = this._getHDeep(); - if (deep <= 0) { - newHeader.unshift(o.rowHeaderCreator || { - type: "bi.table_style_cell", - text: BI.i18nText("BI-Row_Header"), - styleGetter: o.headerCellStyleGetter - }); - } else { - newHeader[0] = o.rowHeaderCreator || { - type: "bi.table_style_cell", - text: BI.i18nText("BI-Row_Header"), - styleGetter: o.headerCellStyleGetter - }; - } - result.push(newHeader); - } - return result; - }, - - _formatItems: function (nodes) { - var self = this, o = this.options; - var result = []; - - function track(node, layer) { - node.type || (node.type = "bi.layer_tree_table_cell"); - node.layer = layer; - var next = [node]; - next = next.concat(node.values || []); - if (next.length > 0) { - result.push(next); - } - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - track(child, layer + 1); - }); - } - } - - BI.each(nodes, function (i, node) { - BI.each(node.children, function (j, c) { - track(c, 0); - }); - if (BI.isArray(node.values)) { - var next = [{ - type: "bi.table_style_cell", text: BI.i18nText("BI-Summary_Values"), styleGetter: function () { - return o.summaryCellStyleGetter(true); - } - }].concat(node.values); - result.push(next) - } - }); - return result; - }, - - _formatColumns: function (columns, deep) { - if (BI.isNotEmptyArray(columns)) { - deep = deep || this._getHDeep(); - return columns.slice(Math.max(0, deep - 1)); - } - return columns; - }, - - _formatFreezeCols: function () { - if (this.options.freezeCols.length > 0) { - return [0]; - } - return []; - }, - - _formatColumnSize: function (columnSize, deep) { - if (columnSize.length <= 0) { - return []; - } - var result = [0]; - deep = deep || this._getHDeep(); - BI.each(columnSize, function (i, size) { - if (i < deep) { - result[0] += size; - return; - } - result.push(size); - }); - return result; - }, - - _digest: function () { - var o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - return { - header: this._createHeader(vDeep), - items: this._formatItems(o.items), - columnSize: this._formatColumnSize(o.columnSize, deep), - minColumnSize: this._formatColumns(o.minColumnSize, deep), - maxColumnSize: this._formatColumns(o.maxColumnSize, deep), - freezeCols: this._formatFreezeCols() - } - }, - - _init: function () { - BI.LayerTreeTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var data = this._digest(); - this.table = BI.createWidget(o.el, { - type: "bi.resizable_table", - element: this, - width: o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - isNeedFreeze: o.isNeedFreeze, - freezeCols: data.freezeCols, - isNeedMerge: o.isNeedMerge, - mergeCols: [], - mergeRule: o.mergeRule, - columnSize: data.columnSize, - minColumnSize: data.minColumnSize, - maxColumnSize: data.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - regionColumnSize: o.regionColumnSize, - header: data.header, - items: data.items - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - setWidth: function (width) { - BI.LayerTreeTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.LayerTreeTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - }, - - getColumnSize: function () { - var columnSize = this.table.getColumnSize(); - var deep = this._getHDeep(); - var pre = []; - if (deep > 0) { - pre = BI.makeArray(deep, columnSize[0] / deep); - } - return pre.concat(columnSize.slice(1)); - }, - - setRegionColumnSize: function (columnSize) { - this.options.regionColumnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - attr: function (key, value) { - var self = this; - if (BI.isObject(key)) { - BI.each(key, function (k, v) { - self.attr(k, v); - }); - return; - } - BI.LayerTreeTable.superclass.attr.apply(this, arguments); - switch (key) { - case "columnSize": - case "minColumnSize": - case "maxColumnSize": - case "freezeCols": - case "mergeCols": - return; - } - this.table.attr.apply(this.table, [key, value]); - }, - - restore: function () { - this.table.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - o.items = items || []; - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - var data = this._digest(); - this.table.setColumnSize(data.columnSize); - this.table.attr("freezeCols", data.freezeCols); - this.table.attr("minColumnSize", data.minColumnSize); - this.table.attr("maxColumnSize", data.maxColumnSize); - this.table.populate(data.items, data.header); - }, - - destroy: function () { - this.table.destroy(); - BI.LayerTreeTable.superclass.destroy.apply(this, arguments); - } -}); - -BI.shortcut("bi.layer_tree_table", BI.LayerTreeTable);/** - * - * Created by GUY on 2016/5/26. - * @class BI.TableStyleCell - * @extends BI.Single - */ -BI.TableStyleCell = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.TableStyleCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-table-style-cell", - styleGetter: BI.emptyFn - }); - }, - - _init: function () { - BI.TableStyleCell.superclass._init.apply(this, arguments); - var o = this.options; - this.text = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - forceCenter: true, - hgap: 5, - text: o.text - }); - this._digestStyle(); - }, - - _digestStyle: function () { - var o = this.options; - var style = o.styleGetter(); - if (style) { - this.text.element.css(style); - } - }, - - setText: function (text) { - this.text.setText(text); - }, - - populate: function () { - this._digestStyle(); - } -}); -BI.shortcut('bi.table_style_cell', BI.TableStyleCell);/** - * - * 树状结构的表格 - * - * Created by GUY on 2015/9/22. - * @class BI.TableTree - * @extends BI.Widget - */ -BI.TableTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.TableTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-table-tree", - el: { - type: "bi.resizable_table" - }, - isNeedResize: true,//是否需要调整列宽 - isResizeAdapt: true,//是否需要在调整列宽或区域宽度的时候它们自适应变化 - - freezeCols: [], //冻结的列号,从0开始,isNeedFreeze为tree时生效 - - isNeedMerge: true,//是否需要合并单元格 - mergeCols: [], - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], - - //交叉表头 - crossHeader: [], - crossItems: [] - }) - }, - - _getVDeep: function () { - return this.options.crossHeader.length;//纵向深度 - }, - - _getHDeep: function () { - var o = this.options; - return Math.max(o.mergeCols.length, o.freezeCols.length, BI.TableTree.maxDeep(o.items) - 1); - }, - - _init: function () { - BI.TableTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var data = this._digest(); - this.table = BI.createWidget(o.el, { - type: "bi.resizable_table", - element: this, - width: o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - header: data.header, - items: data.items - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - _digest: function () { - var self = this, o = this.options; - var deep = this._getHDeep(); - var vDeep = this._getVDeep(); - var header = BI.TableTree.formatHeader(o.header, o.crossHeader, o.crossItems, deep, vDeep, o.headerCellStyleGetter); - var items = BI.TableTree.formatItems(o.items, deep, false, o.summaryCellStyleGetter); - return { - header: header, - items: items - } - }, - - setWidth: function (width) { - BI.TableTree.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.TableTree.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.regionColumnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - attr: function () { - BI.TableTree.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - restore: function () { - this.table.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items || []; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - var data = this._digest(); - this.table.populate(data.items, data.header); - }, - - destroy: function () { - this.table.destroy(); - BI.TableTree.superclass.destroy.apply(this, arguments); - } -}); - -BI.extend(BI.TableTree, { - formatHeader: function (header, crossHeader, crossItems, hDeep, vDeep, styleGetter) { - var items = BI.TableTree.formatCrossItems(crossItems, vDeep, styleGetter); - var result = []; - for (var i = 0; i < vDeep; i++) { - var c = []; - for (var j = 0; j < hDeep; j++) { - c.push(crossHeader[i]); - } - result.push(c.concat(items[i] || [])); - } - if (header && header.length > 0) { - result.push(header); - } - return result; - }, - - formatItems: function (nodes, deep, isCross, styleGetter) { - var self = this; - var result = []; - - function track(store, node) { - var next; - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var next; - if (store != -1) { - next = store.slice(); - next.push(node); - } else { - next = []; - } - track(next, child); - }); - if (store != -1) { - next = store.slice(); - next.push(node); - } else { - next = []; - } - if (/**(store == -1 || node.children.length > 1) &&**/ BI.isNotEmptyArray(node.values)) { - var summary = { - text: BI.i18nText("BI-Summary_Values"), - type: "bi.table_style_cell", - styleGetter: function () { - return styleGetter(store === -1) - } - }; - for (var i = next.length; i < deep; i++) { - next.push(summary); - } - if (!isCross) { - next = next.concat(node.values); - } - if (next.length > 0) { - if (!isCross) { - result.push(next); - } else { - for (var k = 0, l = node.values.length; k < l; k++) { - result.push(next); - } - } - } - } - - return; - } - if (store != -1) { - next = store.slice(); - for (var i = next.length; i < deep; i++) { - next.push(node); - } - } else { - next = []; - } - if (!isCross && BI.isArray(node.values)) { - next = next.concat(node.values); - } - if (isCross && BI.isArray(node.values)) { - for (var i = 0, len = node.values.length; i < len - 1; i++) { - if (next.length > 0) { - result.push(next); - } - } - } - if (next.length > 0) { - result.push(next); - } - } - - BI.each(nodes, function (i, node) { - track(-1, node); - }); - //填充空位 - BI.each(result, function (i, line) { - var last = BI.last(line); - for (var j = line.length; j < deep; j++) { - line.push(last); - } - }); - return result; - }, - - formatCrossItems: function (nodes, deep, styleGetter) { - var items = BI.TableTree.formatItems(nodes, deep, true, styleGetter); - return BI.unzip(items); - }, - - maxDeep: function (nodes) { - function track(deep, node) { - var d = deep; - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - d = Math.max(d, track(deep + 1, child)); - }); - } - return d; - } - - var deep = 1; - if (BI.isObject(nodes)) { - BI.each(nodes, function (i, node) { - deep = Math.max(deep, track(1, node)); - }); - } - return deep; - } -}); - -BI.shortcut("bi.tree_table", BI.TableTree);/** - * guy - * 复选导航条 - * Created by GUY on 2015/8/25. - * @class BI.MultiSelectBar - * @extends BI.BasicButton - */ -BI.MultiSelectBar = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectBar.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-multi-select-bar", - height: 25, - text: BI.i18nText('BI-Select_All'), - isAllCheckedBySelectedValue: BI.emptyFn, - //手动控制选中 - disableSelected: true, - isHalfCheckedBySelectedValue: function (selectedValues) { - return selectedValues.length > 0; - } - }) - }, - _init: function () { - BI.MultiSelectBar.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.checkbox", - stopPropagation: true, - handler: function () { - self.setSelected(self.isSelected()); - } - }); - this.half = BI.createWidget({ - type: "bi.half_icon_button", - stopPropagation: true, - handler: function () { - self.setSelected(true); - } - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); - }); - this.half.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); - }); - this.half.on(BI.HalfIconButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, self.isSelected(), self); - }); - this.checkbox.on(BI.Checkbox.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, self.isSelected(), self); - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - width: 36, - el: { - type: "bi.center_adapt", - items: [this.checkbox, this.half] - } - }, { - el: this.text - }] - }); - this.half.invisible(); - }, - - //自己手动控制选中 - beforeClick: function () { - var isHalf = this.isHalfSelected(), isSelected = this.isSelected(); - if (isHalf === true) { - this.setSelected(true); - } else { - this.setSelected(!isSelected); - } - }, - - setSelected: function (v) { - this.checkbox.setSelected(v); - this.setHalfSelected(false); - }, - - setHalfSelected: function (b) { - this._half = !!b; - if (b === true) { - this.half.visible(); - this.checkbox.invisible(); - } else { - this.half.invisible(); - this.checkbox.visible(); - } - }, - - isHalfSelected: function () { - return !!this._half; - }, - - isSelected: function () { - return this.checkbox.isSelected(); - }, - - setValue: function (selectedValues) { - BI.MultiSelectBar.superclass.setValue.apply(this, arguments); - var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); - this.setSelected(isAllChecked); - !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); - } -}); -BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_bar", BI.MultiSelectBar);/** - * 表关联树 - * - * Created by GUY on 2015/12/15. - * @class BI.BranchRelation - * @extends BI.Widget - */ -BI.BranchRelation = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.BranchRelation.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-branch-relation-tree", - items: [], - - centerOffset: 0,//重心偏移量 - direction: BI.Direction.Bottom, - align: BI.VerticalAlign.Top - }) - }, - - _init: function () { - BI.BranchRelation.superclass._init.apply(this, arguments); - this.populate(this.options.items); - }, - - //树分层 - _stratification: function () { - var levels = []; - this.tree.recursion(function (node, route) { - //node.isRoot = route.length <= 1; - node.leaf = node.isLeaf(); - if (!levels[route.length - 1]) { - levels[route.length - 1] = []; - } - levels[route.length - 1].push(node); - }); - return levels; - }, - - //计算所有节点的叶子结点个数 - _calculateLeaves: function () { - var count = 0; - - function track(node) { - var c = 0; - if (node.isLeaf()) { - return 1; - } - BI.each(node.getChildren(), function (i, child) { - c += track(child); - }); - node.set("leaves", c); - return c; - } - - count = track(this.tree.getRoot()); - return count; - }, - - //树平移 - _translate: function (levels) { - var adjust = []; - var maxLevel = levels.length; - BI.each(levels, function (i, nodes) { - if (!adjust[i]) { - adjust[i] = []; - } - BI.each(nodes, function (j, node) { - if (node.isLeaf() && i < maxLevel - 1) { - var newNode = new BI.Node(BI.UUID()); - //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot; - newNode.isNew = true; - //把node向下一层移 - var tar = 0; - if (j > 0) { - var c = nodes[j - 1].getLastChild(); - tar = levels[i + 1].indexOf(c) + 1; - } - levels[i + 1].splice(tar, 0, node); - //新增一个临时树节点 - var index = node.parent.getChildIndex(node.id); - node.parent.removeChildByIndex(index); - node.parent.addChild(newNode, index); - newNode.addChild(node); - adjust[i].push(newNode); - nodes[j] = newNode; - } else { - adjust[i].push(node); - } - }) - }); - return adjust; - }, - - //树补白 - _fill: function (levels) { - var adjust = []; - var maxLevel = levels.length; - BI.each(levels, function (i, nodes) { - if (!adjust[i]) { - adjust[i] = []; - } - BI.each(nodes, function (j, node) { - if (node.isLeaf() && i < maxLevel - 1) { - var newNode = new BI.Node(BI.UUID()); - newNode.leaf = true; - newNode.width = node.width; - newNode.height = node.height; - newNode.isNew = true; - //把node向下一层移 - var tar = 0; - if (j > 0) { - var c = nodes[j - 1].getLastChild(); - tar = levels[i + 1].indexOf(c) + 1; - } - levels[i + 1].splice(tar, 0, newNode); - //新增一个临时树节点 - node.addChild(newNode); - } - adjust[i].push(node); - }) - }); - return adjust; - }, - - //树调整 - _adjust: function (adjust) { - while (true) { - var isAllNeedAjust = false; - BI.backEach(adjust, function (i, nodes) { - BI.each(nodes, function (j, node) { - if (!node.isNew) { - var needAdjust = true; - BI.any(node.getChildren(), function (k, n) { - if (!n.isNew) { - needAdjust = false; - return true; - } - }); - if (!node.isLeaf() && needAdjust === true) { - var allChilds = []; - BI.each(node.getChildren(), function (k, n) { - allChilds = allChilds.concat(n.getChildren()); - }); - node.removeAllChilds(); - BI.each(allChilds, function (k, c) { - node.addChild(c); - }); - var newNode = new BI.Node(BI.UUID()); - //newNode.isEmptyRoot = node.isRoot || node.isEmptyRoot; - newNode.isNew = true; - var index = node.parent.getChildIndex(node.id); - node.parent.removeChildByIndex(index); - node.parent.addChild(newNode, index); - newNode.addChild(node); - isAllNeedAjust = true; - } - } - }) - }); - if (isAllNeedAjust === false) { - break; - } else {//树重构 - adjust = this._stratification(); - } - } - return adjust; - }, - - _calculateWidth: function () { - var o = this.options; - var width = 0; - - function track1(node) { - var w = 0; - if (node.isLeaf()) { - return node.width; - } - BI.each(node.getChildren(), function (i, child) { - w += track1(child); - }); - return w; - } - - function track2(node) { - var w = 0; - if (node.isLeaf()) { - return node.height; - } - BI.each(node.getChildren(), function (i, child) { - w += track2(child); - }); - return w; - } - - if (this._isVertical()) { - width = track1(this.tree.getRoot()); - } else { - width = track2(this.tree.getRoot()); - } - - return width; - }, - - _isVertical: function () { - var o = this.options; - return o.direction === BI.Direction.Top || o.direction === BI.Direction.Bottom; - }, - - _calculateHeight: function () { - var o = this.options; - var height = 0; - - function track1(node) { - var h = 0; - BI.each(node.getChildren(), function (i, child) { - h = Math.max(h, track1(child)); - }); - return h + (node.height || 0); - } - - function track2(node) { - var h = 0; - BI.each(node.getChildren(), function (i, child) { - h = Math.max(h, track2(child)); - }); - return h + (node.width || 0); - } - - if (this._isVertical()) { - height = track1(this.tree.getRoot()); - } else { - height = track2(this.tree.getRoot()); - } - return height; - }, - - _calculateXY: function (levels) { - var o = this.options; - var width = this._calculateWidth(); - var height = this._calculateHeight(); - var levelCount = levels.length; - var allLeavesCount = this._calculateLeaves(); - //计算坐标 - var xy = {}; - var levelHeight = height / levelCount; - BI.each(levels, function (i, nodes) { - //计算权重 - var weights = []; - BI.each(nodes, function (j, node) { - weights[j] = (node.get("leaves") || 1) / allLeavesCount; - }); - BI.each(nodes, function (j, node) { - //求前j个元素的权重 - var weight = BI.sum(weights.slice(0, j)); - //求坐标 - var x = weight * width + weights[j] * width / 2; - var y = i * levelHeight + levelHeight / 2; - xy[node.id] = {x: x, y: y}; - }) - }); - return xy; - }, - - _stroke: function (levels, xy) { - var height = this._calculateHeight(); - var levelCount = levels.length; - var levelHeight = height / levelCount; - var self = this, o = this.options; - switch (o.direction) { - case BI.Direction.Top: - BI.each(levels, function (i, nodes) { - BI.each(nodes, function (j, node) { - if (node.getChildrenLength() > 0 && !node.leaf) { - var path = ""; - var start = xy[node.id]; - var split = start.y + levelHeight / 2; - path += "M" + start.x + "," + (start.y + o.centerOffset) + "L" + start.x + "," + split; - var end = []; - BI.each(node.getChildren(), function (t, c) { - var e = end[t] = xy[c.id]; - path += "M" + e.x + "," + (e.y + o.centerOffset) + "L" + e.x + "," + split; - }); - if (end.length > 0) { - path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split; - } - self.svg.path(path).attr("stroke", "#d4dadd"); - } - }) - }); - break; - case BI.Direction.Bottom: - BI.each(levels, function (i, nodes) { - BI.each(nodes, function (j, node) { - if (node.getChildrenLength() > 0 && !node.leaf) { - var path = ""; - var start = xy[node.id]; - var split = start.y - levelHeight / 2; - path += "M" + start.x + "," + (start.y - o.centerOffset) + "L" + start.x + "," + split; - var end = []; - BI.each(node.getChildren(), function (t, c) { - var e = end[t] = xy[c.id]; - path += "M" + e.x + "," + (e.y - o.centerOffset) + "L" + e.x + "," + split; - }); - if (end.length > 0) { - path += "M" + BI.first(end).x + "," + split + "L" + BI.last(end).x + "," + split; - } - self.svg.path(path).attr("stroke", "#d4dadd"); - } - }) - }); - break; - case BI.Direction.Left: - BI.each(levels, function (i, nodes) { - BI.each(nodes, function (j, node) { - if (node.getChildrenLength() > 0 && !node.leaf) { - var path = ""; - var start = xy[node.id]; - var split = start.y + levelHeight / 2; - path += "M" + (start.y + o.centerOffset) + "," + start.x + "L" + split + "," + start.x; - var end = []; - BI.each(node.getChildren(), function (t, c) { - var e = end[t] = xy[c.id]; - path += "M" + (e.y + o.centerOffset) + "," + e.x + "L" + split + "," + e.x; - }); - if (end.length > 0) { - path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x; - } - self.svg.path(path).attr("stroke", "#d4dadd"); - } - }) - }); - break; - case BI.Direction.Right: - BI.each(levels, function (i, nodes) { - BI.each(nodes, function (j, node) { - if (node.getChildrenLength() > 0 && !node.leaf) { - var path = ""; - var start = xy[node.id]; - var split = start.y - levelHeight / 2; - path += "M" + (start.y - o.centerOffset) + "," + start.x + "L" + split + "," + start.x; - var end = []; - BI.each(node.getChildren(), function (t, c) { - var e = end[t] = xy[c.id]; - path += "M" + (e.y - o.centerOffset) + "," + e.x + "L" + split + "," + e.x; - }); - if (end.length > 0) { - path += "M" + split + "," + BI.first(end).x + "L" + split + "," + BI.last(end).x; - } - self.svg.path(path).attr("stroke", "#d4dadd"); - } - }) - }); - break; - } - }, - - _createBranches: function (levels) { - var self = this, o = this.options; - if (o.direction === BI.Direction.Bottom || o.direction === BI.Direction.Right) { - levels = levels.reverse(); - } - var xy = this._calculateXY(levels); - //画图 - this._stroke(levels, xy); - }, - - _isNeedAdjust: function () { - var o = this.options; - return o.direction === BI.Direction.Top && o.align === BI.VerticalAlign.Bottom || o.direction === BI.Direction.Bottom && o.align === BI.VerticalAlign.Top - || o.direction === BI.Direction.Left && o.align === BI.HorizontalAlign.Right || o.direction === BI.Direction.Right && o.align === BI.HorizontalAlign.Left - }, - - setValue: function (value) { - - }, - - getValue: function () { - - }, - - _transformToTreeFormat: function (sNodes) { - var i, l; - if (!sNodes) { - return []; - } - - if (BI.isArray(sNodes)) { - var r = []; - var tmpMap = []; - for (i = 0, l = sNodes.length; i < l; i++) { - tmpMap[sNodes[i].id] = sNodes[i]; - } - for (i = 0, l = sNodes.length; i < l; i++) { - if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) { - if (!tmpMap[sNodes[i].pId].children) { - tmpMap[sNodes[i].pId].children = []; - } - tmpMap[sNodes[i].pId].children.push(sNodes[i]); - } else { - r.push(sNodes[i]); - } - } - return r; - } else { - return [sNodes]; - } - }, - - populate: function (items) { - var self = this, o = this.options; - o.items = items || []; - this.empty(); - items = this._transformToTreeFormat(o.items); - this.tree = new BI.Tree(); - this.tree.initTree(items); - - this.svg = BI.createWidget({ - type: "bi.svg" - }); - - //树分层 - var levels = this._stratification(); - - if (this._isNeedAdjust()) { - //树平移 - var adjust = this._translate(levels); - //树调整 - adjust = this._adjust(adjust); - - this._createBranches(adjust); - } else { - var adjust = this._fill(levels); - - this._createBranches(adjust); - } - - var container = BI.createWidget({ - type: "bi.layout", - width: this._isVertical() ? this._calculateWidth() : this._calculateHeight(), - height: this._isVertical() ? this._calculateHeight() : this._calculateWidth() - }); - BI.createWidget({ - type: "bi.absolute", - element: container, - items: [{ - el: this.svg, - top: 0, - left: 0, - right: 0, - bottom: 0 - }] - }); - if (this._isVertical()) { - items = [{ - type: "bi.handstand_branch_tree", - expander: { - direction: o.direction - }, - el: { - layouts: [{ - type: "bi.horizontal_adapt", - verticalAlign: o.align - }] - }, - items: items - }] - } else { - items = [{ - type: "bi.branch_tree", - expander: { - direction: o.direction - }, - el: { - layouts: [{ - type: "bi.vertical" - }, { - type: o.align === BI.HorizontalAlign.Left ? "bi.left" : "bi.right" - }] - }, - items: items - }] - } - BI.createWidget({ - type: "bi.adaptive", - element: container, - items: items - }); - BI.createWidget({ - type: "bi.center_adapt", - scrollable: true, - element: this, - items: [container] - }); - } -}); -BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE"; -BI.shortcut("bi.branch_relation", BI.BranchRelation);/** - * 倒立的Branch - * @class BI.HandStandBranchExpander - * @extend BI.Widget - * create by young - */ -BI.HandStandBranchExpander = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.HandStandBranchExpander.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-handstand-branch-expander", - direction: BI.Direction.Top, - logic: { - dynamic: true - }, - el: {type: "bi.label"}, - popup: {} - }) - }, - - _init: function () { - BI.HandStandBranchExpander.superclass._init.apply(this, arguments); - var o = this.options; - this._initExpander(); - this._initBranchView(); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(o.direction, { - type: "bi.center_adapt", - items: [this.expander] - }, this.branchView) - })))); - }, - - _initExpander: function () { - var self = this, o = this.options; - this.expander = BI.createWidget(o.el); - this.expander.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _initBranchView: function () { - var self = this, o = this.options; - this.branchView = BI.createWidget(o.popup, {}); - this.branchView.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - populate: function (items) { - this.branchView.populate.apply(this.branchView, arguments); - }, - - getValue: function () { - return this.branchView.getValue(); - } -}); -BI.HandStandBranchExpander.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.handstand_branch_expander", BI.HandStandBranchExpander);/** - * @class BI.BranchExpander - * @extend BI.Widget - * create by young - */ -BI.BranchExpander = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.BranchExpander.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-branch-expander", - direction: BI.Direction.Left, - logic: { - dynamic: true - }, - el: {}, - popup: {} - }) - }, - - _init: function () { - BI.BranchExpander.superclass._init.apply(this, arguments); - var o = this.options; - this._initExpander(); - this._initBranchView(); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({}, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.expander, this.branchView) - })))); - }, - - _initExpander: function () { - var self = this, o = this.options; - this.expander = BI.createWidget(o.el, { - type: "bi.label", - width: 30, - height: "100%" - }); - this.expander.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _initBranchView: function () { - var self = this, o = this.options; - this.branchView = BI.createWidget(o.popup, {}); - this.branchView.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - populate: function (items) { - this.branchView.populate.apply(this.branchView, arguments); - }, - - getValue: function () { - return this.branchView.getValue(); - } -}); -BI.BranchExpander.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.branch_expander", BI.BranchExpander);/** - * @class BI.HandStandBranchTree - * @extends BI.Widget - * create by young - * 横向分支的树 - */ -BI.HandStandBranchTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.HandStandBranchTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-handstand-branch-tree", - expander: {}, - el: {}, - items: [] - }) - }, - _init: function () { - BI.HandStandBranchTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.branchTree = BI.createWidget({ - type: "bi.custom_tree", - element: this, - expander: BI.extend({ - type: "bi.handstand_branch_expander", - el: {}, - popup: { - type: "bi.custom_tree" - } - }, o.expander), - el: BI.extend({ - type: "bi.button_tree", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - layouts: [{ - type: "bi.horizontal_adapt" - }] - }, o.el), - items: this.options.items - }); - this.branchTree.on(BI.CustomTree.EVENT_CHANGE, function(){ - self.fireEvent(BI.HandStandBranchTree.EVENT_CHANGE, arguments); - }); - this.branchTree.on(BI.Controller.EVENT_CHANGE, function(){ - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - populate: function () { - this.branchTree.populate.apply(this.branchTree, arguments); - }, - - getValue: function () { - return this.branchTree.getValue(); - } -}); -BI.HandStandBranchTree.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.handstand_branch_tree", BI.HandStandBranchTree);/** - * @class BI.BranchTree - * @extends BI.Widget - * create by young - * 横向分支的树 - */ -BI.BranchTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.BranchTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-branch-tree", - expander: {}, - el: {}, - items: [] - }) - }, - _init: function () { - BI.BranchTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.branchTree = BI.createWidget({ - type: "bi.custom_tree", - element: this, - expander: BI.extend({ - type: "bi.branch_expander", - el: {}, - popup: { - type: "bi.custom_tree" - } - }, o.expander), - el: BI.extend({ - type: "bi.button_tree", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - layouts: [{ - type: "bi.vertical" - }] - }, o.el), - items: this.options.items - }); - this.branchTree.on(BI.CustomTree.EVENT_CHANGE, function(){ - self.fireEvent(BI.BranchTree.EVENT_CHANGE, arguments); - }); - this.branchTree.on(BI.Controller.EVENT_CHANGE, function(){ - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - populate: function () { - this.branchTree.populate.apply(this.branchTree, arguments); - }, - - getValue: function () { - return this.branchTree.getValue(); - } -}); -BI.BranchTree.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.branch_tree", BI.BranchTree);/** - * guy - * 异步树 - * @class BI.DisplayTree - * @extends BI.TreeView - */ -BI.DisplayTree = BI.inherit(BI.TreeView, { - _defaultConfig: function () { - return BI.extend(BI.DisplayTree.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-display-tree" - }) - }, - _init: function () { - BI.DisplayTree.superclass._init.apply(this, arguments); - }, - - //配置属性 - _configSetting: function () { - var setting = { - view: { - selectedMulti: false, - dblClickExpand: false, - showIcon: false, - showTitle: false - }, - data: { - key: { - title: "title", - name: "text" - }, - simpleData: { - enable: true - } - }, - callback: { - beforeCollapse: beforeCollapse - } - }; - - function beforeCollapse(treeId, treeNode) { - return false; - } - - return setting; - }, - - _dealWidthNodes: function (nodes) { - nodes = BI.DisplayTree.superclass._dealWidthNodes.apply(this, arguments); - var self = this, o = this.options; - BI.each(nodes, function (i, node) { - if (node.text == null) { - if (node.count > 0) { - node.text = node.value + "(" + BI.i18nText("BI-Basic_Altogether") + node.count + BI.i18nText("BI-Basic_Count") + ")"; - } - } - }); - return nodes; - }, - - initTree: function (nodes, setting) { - var setting = setting || this._configSetting(); - this.nodes = $.fn.zTree.init(this.tree.element, setting, nodes); - }, - - destroy: function () { - BI.DisplayTree.superclass.destroy.apply(this, arguments); - } -}); -BI.DisplayTree.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.display_tree", BI.DisplayTree);/** - * guy - * 二级树 - * @class BI.LevelTree - * @extends BI.Single - */ -BI.LevelTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.LevelTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-level-tree", - el: { - chooseType: 0 - }, - expander: {}, - items: [] - }) - }, - - _init: function () { - BI.LevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {layer: layer}; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.last_plus_group_node"; - break; - default : - extend.type = "bi.mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.last_tree_leaf_item"; - break; - default : - extend.type = "bi.mid_tree_leaf_item"; - } - BI.defaults(node, extend); - } - }); - return nodes; - }, - - _assertId: function (sNodes) { - BI.each(sNodes, function (i, node) { - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - }); - }, - - //构造树结构, - initTree: function (nodes) { - var self = this, o = this.options; - this.empty(); - this._assertId(nodes); - this.tree = BI.createWidget({ - type: "bi.custom_tree", - element: this, - expander: BI.extend({ - el: {}, - popup: { - type: "bi.custom_tree" - } - }, o.expander), - - items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), - - el: BI.extend({ - type: "bi.button_tree", - chooseType: 0, - layouts: [{ - type: "bi.vertical" - }] - }, o.el) - }); - this.tree.on(BI.Controller.EVENT_CHANGE, function (type) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.LevelTree.EVENT_CHANGE, arguments); - } - }) - }, - - //生成树方法 - stroke: function (nodes) { - this.tree.stroke.apply(this.tree, arguments); - }, - - populate: function (items) { - items = this._formatItems(BI.Tree.transformToTreeFormat(items), 0); - this.tree.populate(items); - }, - - setValue: function (v) { - this.tree.setValue(v); - }, - - getValue: function () { - return this.tree.getValue(); - }, - - getAllLeaves: function () { - return this.tree.getAllLeaves(); - }, - - getNodeById: function (id) { - return this.tree.getNodeById(id); - }, - - getNodeByValue: function (id) { - return this.tree.getNodeByValue(id); - } -}); -BI.LevelTree.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.level_tree", BI.LevelTree);/** - * 简单的多选树 - * - * Created by GUY on 2016/2/16. - * @class BI.SimpleTreeView - * @extends BI.Widget - */ -BI.SimpleTreeView = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.SimpleTreeView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-simple-tree", - itemsCreator: BI.emptyFn, - items: null - }) - }, - _init: function () { - BI.SimpleTreeView.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.structure = new BI.Tree(); - this.tree = BI.createWidget({ - type: "bi.tree_view", - element: this, - itemsCreator: function (op, callback) { - var fn = function (items) { - callback({ - items: items - }); - self.structure.initTree(BI.Tree.transformToTreeFormat(items)); - }; - if (BI.isNotNull(o.items)) { - fn(o.items); - } else { - o.itemsCreator(op, fn); - } - } - }); - this.tree.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.SimpleTreeView.EVENT_CHANGE, arguments); - }); - if (BI.isNotEmptyArray(o.items)) { - this.populate(); - } - }, - - populate: function (items, keyword) { - if (items) { - this.options.items = items; - } - this.tree.stroke({ - keyword: keyword - }); - }, - - setValue: function (v) { - v || (v = []); - var self = this, map = {}; - var selected = []; - BI.each(v, function (i, val) { - var node = self.structure.search(val, "value"); - if (node) { - var p = node; - p = p.getParent(); - if (p) { - if (!map[p.value]) { - map[p.value] = 0; - } - map[p.value]++; - } - - while (p && p.getChildrenLength() <= map[p.value]) { - selected.push(p.value); - p = p.getParent(); - if (p) { - if (!map[p.value]) { - map[p.value] = 0; - } - map[p.value]++; - } - } - } - }); - - this.tree.setValue(BI.makeObject(v.concat(selected))); - }, - - _getValue: function () { - var self = this, result = [], val = this.tree.getValue(); - var track = function (nodes) { - BI.each(nodes, function (key, node) { - if (BI.isEmpty(node)) { - result.push(key); - } else { - track(node); - } - }) - }; - track(val); - return result; - }, - - empty: function () { - this.tree.empty(); - }, - - getValue: function () { - var self = this, result = [], val = this._getValue(); - BI.each(val, function (i, key) { - var target = self.structure.search(key, "value"); - if (target) { - self.structure._traverse(target, function (node) { - if (node.isLeaf()) { - result.push(node.value); - } - }) - } - }); - return result; - } -}); -BI.SimpleTreeView.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.simple_tree", BI.SimpleTreeView); -/** - * 文本输入框trigger - * - * Created by GUY on 2015/9/15. - * @class BI.EditorTrigger - * @extends BI.Trigger - */ -BI.EditorTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4 - }, - - _defaultConfig: function () { - var conf = BI.EditorTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-editor-trigger bi-border", - height: 24, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: false, - watermark: "", - errorText: "" - }); - }, - - _init: function () { - this.options.height -= 2; - BI.EditorTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - value: o.value, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.EditorTrigger.EVENT_CHANGE, arguments); - }); - - BI.createWidget({ - element: this, - type: 'bi.htape', - items: [ - { - el: this.editor - }, { - el: { - type: "bi.trigger_icon_button", - cls: "bi-border-left", - width: o.triggerWidth || o.height - }, - width: o.triggerWidth || o.height - } - ] - }); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - setValue: function (value) { - this.editor.setValue(value); - }, - - setText: function (text) { - this.editor.setState(text); - } -}); -BI.EditorTrigger.EVENT_CHANGE = "BI.EditorTrigger.EVENT_CHANGE"; -BI.shortcut("bi.editor_trigger", BI.EditorTrigger);/** - * 图标按钮trigger - * - * Created by GUY on 2015/10/8. - * @class BI.IconTrigger - * @extends BI.Trigger - */ -BI.IconTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-icon-trigger", - el: {}, - height: 24 - }); - }, - _init: function () { - var o = this.options; - BI.IconTrigger.superclass._init.apply(this, arguments); - this.iconButton = BI.createWidget(o.el, { - type: "bi.trigger_icon_button", - element: this, - width: o.width, - height: o.height - }); - } -}); -BI.shortcut('bi.icon_trigger', BI.IconTrigger);/** - * 文字trigger - * - * Created by GUY on 2015/9/15. - * @class BI.IconTextTrigger - * @extends BI.Trigger - */ -BI.IconTextTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4 - }, - - _defaultConfig: function () { - var conf = BI.IconTextTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-trigger", - height: 24 - }); - }, - - _init: function () { - BI.IconTextTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - height: o.height, - text: o.text, - hgap: c.hgap - }); - this.trigerButton = BI.createWidget({ - type: "bi.trigger_icon_button", - cls: "bi-border-left", - width: o.triggerWidth || o.height - }); - - BI.createWidget({ - element: this, - type: 'bi.htape', - ref: function (_ref) { - self.wrapper = _ref; - }, - items: [{ - el: { - type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + o.iconClass, - ref: function (_ref) { - self.icon = _ref; - }, - disableSelected: true - }, - width: o.triggerWidth || o.height - }, - { - el: this.text - }, { - el: this.trigerButton, - width: o.triggerWidth || o.height - } - ] - }); - }, - - setValue: function (value) { - this.text.setValue(value); - this.text.setTitle(value); - }, - - setIcon: function (iconCls) { - var o = this.options; - this.icon.setIcon(iconCls); - var iconItem = this.wrapper.attr("items")[0]; - if(BI.isNull(iconCls) || BI.isEmptyString(iconCls)){ - if(iconItem.width !== 0){ - iconItem.width = 0; - this.wrapper.resize(); - } - }else{ - if(iconItem.width !== (o.triggerWidth || o.height)){ - iconItem.width = (o.triggerWidth || o.height); - this.wrapper.resize(); - } - } - }, - - setText: function (text) { - this.text.setText(text); - this.text.setTitle(text); - } -}); -BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/** - * Created by Windy on 2017/12/12. - */ -BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.SelectIconTextTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-text-trigger bi-border", - height: 24 - }); - }, - - _init: function () { - this.options.height -= 2; - BI.SelectIconTextTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.icon_text_trigger", - element: this, - height: o.height - }); - if (BI.isKey(o.text)) { - this.setValue(o.text); - } - }, - - setValue: function (vals) { - var o = this.options; - vals = BI.isArray(vals) ? vals : [vals]; - var result; - var items = BI.Tree.transformToArrayFormat(this.options.items); - BI.any(items, function (i, item) { - if (BI.deepContains(vals, item.value)) { - result = { - text: item.text || item.value, - iconClass: item.iconClass - }; - return true; - } - }); - - if (BI.isNotNull(result)) { - this.trigger.setText(result.text); - this.trigger.setIcon(result.iconClass); - } else { - this.trigger.setText(o.text); - this.trigger.setIcon(""); - } - }, - - populate: function (items) { - this.options.items = items; - } -}); -BI.shortcut("bi.select_icon_text_trigger", BI.SelectIconTextTrigger);/** - * 文字trigger - * - * Created by GUY on 2015/9/15. - * @class BI.TextTrigger - * @extends BI.Trigger - */ -BI.TextTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4 - }, - - _defaultConfig: function () { - var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-trigger", - height: 24 - }); - }, - - _init: function () { - BI.TextTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - height: o.height, - text: o.text, - hgap: c.hgap, - readonly: o.readonly - }); - this.trigerButton = BI.createWidget({ - type: "bi.trigger_icon_button", - cls: "bi-border-left", - width: o.triggerWidth || o.height - }); - - BI.createWidget({ - element: this, - type: 'bi.htape', - items: [ - { - el: this.text - }, { - el: this.trigerButton, - width: o.triggerWidth || o.height - } - ] - }); - }, - - setValue: function (value) { - this.text.setValue(value); - this.text.setTitle(value); - }, - - setText: function (text) { - this.text.setText(text); - this.text.setTitle(text); - } -}); -BI.shortcut("bi.text_trigger", BI.TextTrigger);/** - * 选择字段trigger - * - * Created by GUY on 2015/9/15. - * @class BI.SelectTextTrigger - * @extends BI.Trigger - */ -BI.SelectTextTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-text-trigger bi-border", - height: 24 - }); - }, - - _init: function () { - this.options.height -= 2; - BI.SelectTextTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.text_trigger", - element: this, - height: o.height - }); - if (BI.isKey(o.text)) { - this.setValue(o.text); - } - }, - - setValue: function (vals) { - var o = this.options; - vals = BI.isArray(vals) ? vals : [vals]; - var result = []; - var items = BI.Tree.transformToArrayFormat(this.options.items); - BI.each(items, function (i, item) { - if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { - result.push(item.text || item.value); - } - }); - - if (result.length > 0) { - this.trigger.setText(result.join(",")); - } else { - this.trigger.setText(o.text); - } - }, - - populate: function (items) { - this.options.items = items; - } -}); -BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger);/** - * 选择字段trigger小一号的 - * - * @class BI.SmallSelectTextTrigger - * @extends BI.Trigger - */ -BI.SmallSelectTextTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.SmallSelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-small-select-text-trigger bi-border", - height: 20 - }); - }, - - _init: function () { - this.options.height -= 2; - BI.SmallSelectTextTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.trigger = BI.createWidget({ - type: "bi.small_text_trigger", - element: this, - height: o.height - 2 - }); - if (BI.isKey(o.text)) { - this.setValue(o.text); - } - }, - - setValue: function (vals) { - var o = this.options; - vals = BI.isArray(vals) ? vals : [vals]; - var result = []; - var items = BI.Tree.transformToArrayFormat(this.options.items); - BI.each(items, function (i, item) { - if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { - result.push(item.text || item.value); - } - }); - - if (result.length > 0) { - this.trigger.element.removeClass("bi-water-mark"); - this.trigger.setText(result.join(",")); - } else { - this.trigger.element.addClass("bi-water-mark"); - this.trigger.setText(o.text); - } - }, - - populate: function (items) { - this.options.items = items; - } -}); -BI.shortcut("bi.small_select_text_trigger", BI.SmallSelectTextTrigger);/** - * 文字trigger(右边小三角小一号的) == - * - * @class BI.SmallTextTrigger - * @extends BI.Trigger - */ -BI.SmallTextTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4 - }, - - _defaultConfig: function () { - var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-trigger", - height: 20 - }); - }, - - _init: function () { - BI.SmallTextTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - height: o.height, - text: o.text, - hgap: c.hgap - }); - this.trigerButton = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.triggerWidth || o.height - }); - - BI.createWidget({ - element: this, - type: 'bi.htape', - items: [ - { - el: this.text - }, { - el: this.trigerButton, - width: o.triggerWidth || o.height - } - ] - }); - }, - - setValue: function (value) { - this.text.setValue(value); - }, - - setText: function (text) { - this.text.setText(text); - } -}); -BI.shortcut("bi.small_text_trigger", BI.SmallTextTrigger); \ No newline at end of file diff --git a/bi/chart.js b/bi/chart.js deleted file mode 100644 index b095fe2bb..000000000 --- a/bi/chart.js +++ /dev/null @@ -1,7602 +0,0 @@ -/** - * 图表控件 - * @class BI.Chart - * @extends BI.Widget - */ -BI.Chart = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.Chart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-chart" - }) - }, - - _init: function () { - BI.Chart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.isSetOptions = false; - this.vanCharts = VanCharts.init(self.element[0]); - - this._resizer = BI.debounce(function () { - if (self.element.width() > 0 && self.element.height() > 0) { - self.vanCharts.resize(); - } - }, 30); - BI.ResizeDetector.addResizeListener(this, function (e) { - self._resizer(); - }); - }, - - resize: function () { - if (this.isSetOptions === true) { - this._resizer(); - } - }, - - magnify: function () { - this.vanCharts.refreshRestore() - }, - - populate: function (items, options) { - var self = this, o = this.options; - o.items = items; - this.config = options || {}; - this.config.series = o.items; - - var setOptions = function () { - self.vanCharts.setOptions(self.config); - self.isSetOptions = true; - }; - BI.nextTick(setOptions); - } -}); -BI.Chart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.chart', BI.Chart);/** - * 图表控件 - * @class BI.CombineChart - * @extends BI.Widget - */ -BI.CombineChart = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.CombineChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-combine-chart", - items: [], - xAxis: [{type: "category"}], - yAxis: [{type: "value"}], - types: [[], []], - popupItemsGetter: BI.emptyFn, - formatConfig: BI.emptyFn - }) - }, - - _init: function () { - BI.CombineChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - //图可配置属性 - this.CombineChart = BI.createWidget({ - type: "bi.chart", - element: this.element - }); - this.CombineChart.on(BI.Chart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.CombineChart.EVENT_CHANGE, obj); - }); - - if (BI.isNotEmptyArray(o.items)) { - this.populate(o.items); - } - }, - - _formatItems: function (items) { - var result = [], self = this, o = this.options; - var yAxisIndex = 0; - BI.each(items, function (i, belongAxisItems) { - var combineItems = BI.ChartCombineFormatItemFactory.combineItems(o.types[i], belongAxisItems); - BI.each(combineItems, function (j, axisItems) { - if (BI.isArray(axisItems)) { - result = BI.concat(result, axisItems); - } else { - result.push(BI.extend(axisItems, {"yAxis": yAxisIndex})); - } - }); - if (BI.isNotEmptyArray(combineItems)) { - yAxisIndex++; - } - }); - var config = BI.ChartCombineFormatItemFactory.combineConfig(); - config.plotOptions.click = function () { - var data = BI.clone(this.options); - data.toolTipRect = this.getTooltipRect(); - var items = o.popupItemsGetter(data); - if (items && items.length === 1) { - self.fireEvent(BI.CombineChart.EVENT_ITEM_CLICK, BI.extend({}, items[0], data)); - } - if (items && items.length > 1) { - self._createPopup(items, data.toolTipRect, data); - } - self.fireEvent(BI.CombineChart.EVENT_CHANGE, data); - }; - return [result, config]; - }, - - _createPopup: function (items, rect, opt) { - var self = this; - if (this.combo) { - this.combo.destroy(); - } - this._doDestroy = true; - this.combo = BI.createWidget({ - type: "bi.combo", - direction: "bottom", - isNeedAdjustWidth: false, - popup: { - el: BI.createWidget({ - type: "bi.vertical", - cls: "bi-linkage-list", - items: BI.map(items, function (i, item) { - return { - el: BI.extend({ - type: "bi.text_button", - cls: "bi-linkage-list-item", - height: 30, - handler: function () { - self.fireEvent(BI.CombineChart.EVENT_ITEM_CLICK, BI.extend({}, item, opt)); - self.combo.destroy(); - }, - hgap: 10 - }, item) - } - }) - }) - }, - width: 0 - }); - BI.createWidget({ - type: "bi.absolute", - element: this.element, - items: [{ - el: this.combo, - top: rect.y, - left: rect.x - }] - }); - this.combo.element.hover(function () { - self._doDestroy = false; - }, function () { - self._doDestroy = true; - self._debounce2Destroy(); - }); - this._debounce2Destroy = BI.debounce(BI.bind(destroyCombo, this.combo), 3000); - this.combo.showView(); - this._debounce2Destroy(); - - function destroyCombo() { - if (self._doDestroy) { - this.destroy(); - } - } - }, - - setTypes: function (types) { - this.options.types = types || [[]]; - }, - - populate: function (items, types) { - var o = this.options; - if (BI.isNotNull(types)) { - this.setTypes(types); - } - var opts = this._formatItems(items); - BI.extend(opts[1], { - xAxis: o.xAxis, - yAxis: o.yAxis - }); - var result = o.formatConfig(opts[1], opts[0]) || opts; - this.CombineChart.populate(result[0], result[1]); - }, - - resize: function () { - this.CombineChart.resize(); - }, - - magnify: function () { - this.CombineChart.magnify(); - } -}); -BI.CombineChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.CombineChart.EVENT_ITEM_CLICK = "EVENT_ITEM_CLICK"; -BI.shortcut('bi.combine_chart', BI.CombineChart);BI.ChartCombineFormatItemFactory = { - combineItems: function (types, items) { - var calItems = BI.values(items); - return BI.map(calItems, function (idx, item) { - return BI.ChartCombineFormatItemFactory.formatItems(types[idx], item); - }); - }, - - formatItems: function (type, items) { - var item = {}; - switch (type) { - case BICst.WIDGET.BAR: - case BICst.WIDGET.ACCUMULATE_BAR: - case BICst.WIDGET.COMPARE_BAR: - item = BI.extend({"type": "bar"}, items); - break; - case BICst.WIDGET.BUBBLE: - item = BI.extend({"type": "bubble"}, items); - break; - case BICst.WIDGET.FORCE_BUBBLE: - item = BI.extend({"type": "forceBubble"}, items); - break; - case BICst.WIDGET.SCATTER: - item = BI.extend({"type": "scatter"}, items); - break; - case BICst.WIDGET.AXIS: - case BICst.WIDGET.ACCUMULATE_AXIS: - case BICst.WIDGET.PERCENT_ACCUMULATE_AXIS: - case BICst.WIDGET.COMPARE_AXIS: - case BICst.WIDGET.FALL_AXIS: - item = BI.extend({"type": "column"}, items); - break; - case BICst.WIDGET.LINE: - item = BI.extend({"type": "line"}, items); - break; - case BICst.WIDGET.AREA: - case BICst.WIDGET.ACCUMULATE_AREA: - case BICst.WIDGET.COMPARE_AREA: - case BICst.WIDGET.RANGE_AREA: - case BICst.WIDGET.PERCENT_ACCUMULATE_AREA: - item = BI.extend({"type": "area"}, items); - break; - case BICst.WIDGET.DONUT: - item = BI.extend({"type": "pie"}, items); - break; - case BICst.WIDGET.RADAR: - case BICst.WIDGET.ACCUMULATE_RADAR: - item = BI.extend({"type": "radar"}, items); - break; - case BICst.WIDGET.PIE: - item = BI.extend({"type": "pie"}, items); - break; - case BICst.WIDGET.DASHBOARD: - item = BI.extend({"type": "gauge"}, items); - break; - case BICst.WIDGET.MAP: - item = BI.extend({"type": "areaMap"}, items); - break; - case BICst.WIDGET.GIS_MAP: - item = BI.extend({"type": "pointMap"}, items); - break; - default: - item = BI.extend({"type": "column"}, items); - break; - } - return item; - }, - - combineConfig: function () { - return { - "title": "", - "chartType": "column", - "plotOptions": { - "rotatable": false, - "startAngle": 0, - "borderRadius": 0, - "endAngle": 360, - "innerRadius": "0.0%", - "layout": "horizontal", - "hinge": "rgb(101,107,109)", - "dataLabels": { - "autoAdjust": true, - "style": {"fontFamily": "inherit", "color": "inherit", "fontSize": "12px"}, - "formatter": { - "identifier": "${VALUE}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat, - "XFormat": this._contentFormat2Decimal, - "YFormat": this._contentFormat2Decimal, - "sizeFormat": this._contentFormat2Decimal - }, - "align": "outside", - "enabled": false - }, - "percentageLabel": { - "formatter": { - "identifier": "${PERCENT}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat - }, - "style": { - "fontFamily": "inherit", "color": "inherit", "fontSize": "12px" - }, - "align": "bottom", - "enabled": true - }, - "valueLabel": { - "formatter": { - "identifier": "${SERIES}${VALUE}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat - }, - "backgroundColor": "rgb(255,255,0)", - "style": { - "fontFamily": "inherit", "color": "inherit", "fontSize": "12px" - }, - "align": "inside", - "enabled": true - }, - "hingeBackgroundColor": "rgb(220,242,249)", - "seriesLabel": { - "formatter": { - "identifier": "${CATEGORY}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat - }, - "style": { - "fontFamily": "inherit", "color": "inherit", "fontSize": "12px" - }, - "align": "bottom", - "enabled": true - }, - "paneBackgroundColor": "rgb(252,252,252)", - "needle": "rgb(229,113,90)", - "large": false, - "connectNulls": false, - "shadow": true, - "curve": false, - "sizeBy": "area", - "tooltip": { - "formatter": { - "identifier": "${SERIES}${X}${Y}${SIZE}{CATEGORY}${SERIES}${VALUE}", - "valueFormat": this._contentFormat2Decimal, - "seriesFormat": this._contentFormat, - "percentFormat": this._contentFormatPercentage, - "categoryFormat": this._contentFormat, - "XFormat": this._contentFormat2Decimal, - "sizeFormat": this._contentFormat2Decimal, - "YFormat": this._contentFormat2Decimal - }, - "shared": false, - "padding": 5, - "backgroundColor": "rgba(0,0,0,0.4980392156862745)", - "borderColor": "rgb(0,0,0)", - "shadow": false, - "borderRadius": 2, - "borderWidth": 0, - "follow": false, - "enabled": true, - "animation": true, - "style": { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", - "color": "#c4c6c6", - "fontSize": "12px", - "fontWeight": "" - } - }, - "maxSize": 80, - "fillColorOpacity": 0.5, - "step": false, - "force": false, - "minSize": 15, - "displayNegative": true, - "categoryGap": "16.0%", - "borderColor": "rgb(255,255,255)", - "borderWidth": 1, - "gap": "22.0%", - "animation": true, - "lineWidth": 2, - "bubble": { - "large": false, - "connectNulls": false, - "shadow": true, - "curve": false, - "sizeBy": "area", - "maxSize": 80, - "minSize": 15, - "lineWidth": 0, - "animation": true, - "fillColorOpacity": 0.699999988079071, - "marker": { - "symbol": "circle", - "radius": 28.39695010101295, - "enabled": true - } - } - }, - "dTools": { - "enabled": false, - "style": { - "fontFamily": "Microsoft YaHei, Hiragino Sans GB W3", - "color": "#1a1a1a", - "fontSize": "12px" - }, - "backgroundColor": 'white' - }, - "dataSheet": { - "enabled": false, - "borderColor": "rgb(0,0,0)", - "borderWidth": 1, - "formatter": this._contentFormat2Decimal, - "style": { - "fontFamily": "inherit", "color": "inherit", "fontSize": "12px" - } - }, - "borderColor": "rgb(238,238,238)", - "shadow": false, - "legend": { - "borderColor": "rgb(204,204,204)", - "borderRadius": 0, - "shadow": false, - "borderWidth": 0, - "visible": true, - "style": { - "fontFamily": "inherit", "color": "inherit", "fontSize": "12px" - }, - "position": "right", - "enabled": false - }, - "rangeLegend": { - "range": { - "min": 0, - "color": [ - [ - 0, - "rgb(182,226,255)" - ], - [ - 0.5, - "rgb(109,196,255)" - ], - [ - 1, - "rgb(36,167,255)" - ] - ], - "max": 266393 - }, - "enabled": false - }, - "zoom": {"zoomType": "xy", "zoomTool": {"visible": false, "resize": true, "from": "", "to": ""}}, - "plotBorderColor": "rgba(255,255,255,0)", - "tools": { - "hidden": false, - "toImage": {"enabled": false}, - "sort": {"enabled": false}, - "fullScreen": {"enabled": false}, - "refresh": { - "enabled": false - } - }, - "plotBorderWidth": 0, - "style": "normal", - "colors": ["rgb(99,178,238)", "rgb(118,218,145)"], - "borderRadius": 0, - "borderWidth": 0, - "plotShadow": false, - "plotBorderRadius": 0 - }; - }, - - _contentFormat: function () { - return BI.contentFormat(arguments[0], '') - }, - - _contentFormat2Decimal: function () { - return BI.contentFormat(arguments[0], '#.##;-#.##') - }, - - _contentFormatPercentage: function () { - return BI.contentFormat(arguments[0], '#.##%;-#.##%') - } -};/** - * 图表控件 - * @class BI.AbstractChart - * @extends BI.Widget - */ -BI.AbstractChart = BI.inherit(BI.Widget, { - - constants: { - LEFT_AXIS: 0, - RIGHT_AXIS: 1, - RIGHT_AXIS_SECOND: 2, - X_AXIS: 3, - ROTATION: -90, - NORMAL: 1, - LEGEND_BOTTOM: 4, - ZERO2POINT: 2, - ONE2POINT: 3, - TWO2POINT: 4, - MINLIMIT: 1e-5, - LEGEND_HEIGHT: 80, - LEGEND_WIDTH: "30.0%", - FIX_COUNT: 6, - STYLE_NORMAL: 21, - NO_PROJECT: 16, - DASHBOARD_AXIS: 4, - ONE_POINTER: 1, - MULTI_POINTER: 2, - HALF_DASHBOARD: 9, - PERCENT_DASHBOARD: 10, - PERCENT_SCALE_SLOT: 11, - VERTICAL_TUBE: 12, - HORIZONTAL_TUBE: 13, - LNG_FIRST: 3, - LAT_FIRST: 4, - themeColor: "#65bce7", - autoCustom: 1, - POLYGON: 7, - AUTO_CUSTOM: 1, - AUTO: 1, - NOT_SHOW: 2, - LINE_WIDTH: 1, - NUM_SEPARATORS: false, - FONT_STYLE: { - "fontFamily": "inherit", - "color": "inherit", - "fontSize": "12px" - } - }, - - _defaultConfig: function () { - return BI.extend(BI.AbstractChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-abstract-chart", - popupItemsGetter: BI.emptyFn - }) - }, - - _init: function () { - BI.AbstractChart.superclass._init.apply(this, arguments); - }, - - /** - * 格式化坐标轴数量级及其所影响的系列的各项属性 - * @param config 配置信息 - * @param items 系列数据 - * @param type 坐标轴数量级 - * @param position 坐标轴位置 - * @param formatter 系列tooltip格式化内容 - */ - formatNumberLevelInYaxis: function (config, items, type, position, formatter, isPercentChart) { - var magnify = this.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - if (BI.isNotNull(da.y) && !BI.isNumber(da.y)) { - da.y = BI.parseFloat(da.y); - } - if (BI.isNotNull(da.y)) { - da.y = BI.contentFormat(BI.parseFloat(da.y.div(magnify).toFixed(4)), "#.####;-#.####"); - } - } - }); - if (position === item.yAxis) { - item.tooltip = BI.deepClone(config.plotOptions.tooltip); - item.tooltip.formatter.valueFormat = formatter; - if(isPercentChart) { - item.tooltip.formatter.percentFormat = formatter; - item.tooltip.formatter.identifier = "${CATEGORY}${SERIES}${PERCENT}"; - } - } - }); - }, - - formatNumberLevelInXaxis: function (items, type) { - var magnify = this.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (BI.isNotNull(da.x) && !BI.isNumber(da.x)) { - da.x = BI.parseFloat(da.x); - } - if (BI.isNotNull(da.x)) { - da.x = BI.contentFormat(BI.parseFloat(da.x.div(magnify).toFixed(4)), "#.####;-#.####"); - } - }); - }) - }, - - formatXYDataWithMagnify: function (number, magnify) { - if (BI.isNull(number)) { - return null - } - if (!BI.isNumber(number)) { - number = BI.parseFloat(number); - } - return BI.contentFormat(BI.parseFloat(number.div(magnify).toFixed(4)), "#.####;-#.####"); - }, - - calcMagnify: function (type) { - var magnify = 1; - switch (type) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - case BICst.TARGET_STYLE.NUM_LEVEL.PERCENT: - magnify = 1; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - magnify = 10000; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - magnify = 1000000; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - magnify = 100000000; - break; - } - return magnify; - }, - - formatChartLegend: function (config, chartLegend) { - switch (chartLegend) { - case BICst.CHART_LEGENDS.BOTTOM: - config.legend.enabled = true; - config.legend.position = "bottom"; - config.legend.maxHeight = this.constants.LEGEND_HEIGHT; - break; - case BICst.CHART_LEGENDS.RIGHT: - config.legend.enabled = true; - config.legend.position = "right"; - config.legend.maxWidth = this.constants.LEGEND_WIDTH; - break; - case BICst.CHART_LEGENDS.NOT_SHOW: - default: - config.legend.enabled = false; - break; - } - }, - - getXYAxisUnit: function (numberLevelType, axis_unit) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - return (BI.isEmptyString(unit) && BI.isEmptyString(axis_unit)) ? unit : "(" + unit + axis_unit + ")"; - }, - - formatTickInXYaxis: function (type, number_level, separators, isCompareBar) { - var formatter = '#.##'; - switch (type) { - case this.constants.NORMAL: - formatter = '#.##'; - if (separators) { - formatter = '#,###.##' - } - break; - case this.constants.ZERO2POINT: - formatter = '#0'; - if (separators) { - formatter = '#,###'; - } - break; - case this.constants.ONE2POINT: - formatter = '#0.0'; - if (separators) { - formatter = '#,###.0'; - } - break; - case this.constants.TWO2POINT: - formatter = '#0.00'; - if (separators) { - formatter = '#,###.00'; - } - break; - } - if (number_level === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT) { - formatter += '%'; - } - formatter += ";-" + formatter; - if(isCompareBar) { - return function () { - arguments[0] = arguments[0] > 0 ? arguments[0] : (-1) * arguments[0]; - return BI.contentFormat(arguments[0], formatter); - } - } - return function () { - return BI.contentFormat(arguments[0], formatter) - } - }, - - formatDataLabel: function (state, items, config, style) { - var self = this; - if (state === true) { - BI.each(items, function (idx, item) { - item.dataLabels = { - "align": "outside", - "autoAdjust": true, - style: style, - enabled: true, - formatter: { - identifier: "${VALUE}", - valueFormat: config.yAxis[item.yAxis].formatter - } - }; - }); - } - }, - - formatDataLabelForAxis: function (state, items, format, style, isPercentChart) { - var self = this; - if (state === true) { - BI.each(items, function (idx, item) { - item.dataLabels = { - "align": "outside", - "autoAdjust": true, - style: style, - enabled: true, - formatter: { - identifier: "${VALUE}", - valueFormat: format, - } - }; - if(isPercentChart) { - item.dataLabels.formatter.identifier = "${PERCENT}"; - item.dataLabels.formatter.percentFormat = format; - } - }); - } - }, - - setFontStyle: function (fontStyle, config) { - if (config.dataSheet) { - config.dataSheet.style = fontStyle; - } - config.xAxis[0].title.style = fontStyle; - config.xAxis[0].labelStyle = fontStyle; - config.legend.style = fontStyle; - BI.each(config.yAxis, function (idx, axis) { - axis.labelStyle = fontStyle; - axis.title.style = fontStyle; - }) - }, - - _formatItems: function (items) { - return items; - }, - - populate: function (items, options) { - }, - - resize: function () { - }, - - magnify: function () { - } -}); - -BI.AbstractChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.AbstractChart.EVENT_ITEM_CLICK = "EVENT_ITEM_CLICK"; -/** - * 图表控件 - * @class BI.AccumulateAreaChart - * @extends BI.Widget - */ -BI.AccumulateAreaChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.AccumulateAreaChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-accumulate-area-chart" - }) - }, - - _init: function () { - BI.AccumulateAreaChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE - }]; - this.yAxis = []; - - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.AccumulateAreaChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - - config.colors = this.config.chartColor; - config.style = formatChartStyle(this.config.chartStyle); - formatChartLineStyle(this.config.chartLineType); - formatCordon(this.config.cordon); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var unit = ""; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - unit = self.getXYAxisUnit(self.config.leftYAxisNumberLevel, self.config.leftYAxisUnit); - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + unit : unit; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter, self.config.numSeparators); - - break; - case self.constants.RIGHT_AXIS: - unit = self.getXYAxisUnit(self.config.rightYAxisNumberLevel, self.config.rightYAxisUnit); - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + unit : unit; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter, self.config.rightNumSeparators); - break; - } - }); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "area"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle(v) { - switch (v) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatChartLineStyle(v) { - switch (v) { - case BICst.CHART_SHAPE.RIGHT_ANGLE: - config.plotOptions.curve = false; - config.plotOptions.step = true; - break; - case BICst.CHART_SHAPE.CURVE: - config.plotOptions.curve = true; - config.plotOptions.step = false; - break; - case BICst.CHART_SHAPE.NORMAL: - default: - config.plotOptions.curve = false; - config.plotOptions.step = false; - break; - } - } - - function formatCordon(cordon) { - BI.each(cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - }, - - _formatItems: function (items) { - return BI.map(items, function (idx, item) { - var i = BI.UUID(); - return BI.map(item, function (id, it) { - return BI.extend({}, it, {stack: i}); - }); - }); - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - chartLineType: options.chartLineType || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - this.yAxis = []; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.AREA); - }); - types.push(type); - }); - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.AccumulateAreaChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.accumulate_area_chart', BI.AccumulateAreaChart);/** - * 图表控件 - * @class BI.AccumulateAxisChart - * @extends BI.Widget - */ -BI.AccumulateAxisChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.AccumulateAxisChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-accumulate-axis-chart" - }) - }, - - _init: function () { - BI.AccumulateAxisChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE - }]; - this.yAxis = []; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.AccumulateAxisChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - axis.title.text = getTitleText(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS, self.config.showLeftYAxisTitle, self.config.leftYAxisTitle); - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - axis.title.text = getTitleText(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS, self.config.showRightYAxisTitle, self.config.rightYAxisTitle); - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - } - }); - - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - config.xAxis[0].title.align = "center"; - BI.extend(config.xAxis[0], { - lineWidth: self.config.lineWidth, - enableTick: self.config.enableTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "column"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function getTitleText(numberLevelType, position, show, title) { - var unit = ""; - - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - - unit = unit === "" ? unit : "(" + unit + ")"; - - return show === true ? title + unit : unit; - } - }, - - _formatItems: function (items) { - return BI.map(items, function (idx, item) { - var i = BI.UUID(); - return BI.map(item, function (id, it) { - return BI.extend({}, it, {stack: i}); - }); - }); - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - this.yAxis = []; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.AXIS); - }); - types.push(type); - }); - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.AccumulateAxisChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.accumulate_axis_chart', BI.AccumulateAxisChart);/** - * 图表控件 - * @class BI.AccumulateBarChart - * @extends BI.Widget - */ -BI.AccumulateBarChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.AccumulateBarChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-accumulate-bar-chart" - }) - }, - - _init: function () { - BI.AccumulateBarChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - formatter: function () { - return this > 0 ? this : (-1) * this - }, - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - gridLineWidth: 0, - position: "left" - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.AccumulateBarChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - var unit = getXYAxisUnit(this.config.xAxisNumberLevel, this.constants.LEFT_AXIS); - var xTitle = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.X_AXIS); - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - - config.yAxis = this.yAxis; - config.yAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle + unit : unit; - config.yAxis[0].title.rotation = this.constants.ROTATION; - BI.extend(config.yAxis[0], { - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - labelRotation: this.config.textDirection, - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - maxWidth: '40%' - }); - - self.formatNumberLevelInXaxis(items, this.config.leftYAxisNumberLevel); - config.xAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + xTitle : xTitle; - config.xAxis[0].title.align = "center"; - BI.extend(config.xAxis[0], { - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators), - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - showLabel: this.config.showLabel, - enableTick: this.config.enableTick, - lineWidth: this.config.lineWidth, - enableMinorTick: this.config.enableMinorTick - }); - config.chartType = "bar"; - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.xAxis[0].formatter, this.config.chartFont); - - config.plotOptions.tooltip.formatter.valueFormat = config.xAxis[0].formatter; - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.xAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function (items) { - BI.each(items, function (idx, item) { - var stackId = BI.UUID(); - BI.each(item, function (id, it) { - it.stack = stackId; - BI.each(it.data, function (i, t) { - var tmp = t.x; - t.x = t.y; - t.y = tmp; - }) - }); - }); - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - xAxisStyle: options.xAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - xAxisNumberLevel: options.xAxisNumberLevel || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - minimalist_model: options.minimalist_model || false, - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.BAR); - }); - types.push(type); - }); - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.AccumulateBarChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.accumulate_bar_chart', BI.AccumulateBarChart);/** - * 图表控件 - * @class BI.AccumulateRadarChart - * @extends BI.Widget - */ -BI.AccumulateRadarChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.AccumulateRadarChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-accumulate-radar-chart" - }) - }, - - _init: function () { - BI.AccumulateRadarChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.radiusAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - formatter: function () { - return this > 0 ? this : (-1) * this - }, - gridLineWidth: 0, - position: "bottom" - }]; - - this.angleAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE - }]; - - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.AccumulateRadarChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatItems: function (items) { - return BI.map(items, function (idx, item) { - var i = BI.UUID(); - return BI.map(item, function (id, it) { - return BI.extend({}, it, {stack: i}); - }); - }); - }, - - _formatConfig: function (config, items) { - var self = this; - - delete config.zoom; - - var title = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartRadarStyle(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - - config.radiusAxis = this.radiusAxis; - config.angleAxis = this.angleAxis; - config.radiusAxis[0].formatter = self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators); - formatNumberLevelInYaxis(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS, config.radiusAxis[0].formatter); - config.radiusAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + title : title; - config.radiusAxis[0].gridLineWidth = this.config.showGridLine === true ? 1 : 0; - config.chartType = "radar"; - config.plotOptions.columnType = true; - delete config.xAxis; - delete config.yAxis; - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.radiusAxis[0].formatter, this.config.chartFont); - - //全局样式的图表文字 - config.radiusAxis[0].labelStyle = config.radiusAxis[0].title.style = this.config.chartFont; - config.angleAxis[0].labelStyle = config.angleAxis[0].title.style = this.config.chartFont; - config.legend.style = this.config.chartFont; - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatChartRadarStyle() { - switch (self.config.chartRadarType) { - case BICst.CHART_SHAPE.POLYGON: - config.plotOptions.shape = "polygon"; - break; - case BICst.CHART_SHAPE.CIRCLE: - config.plotOptions.shape = "circle"; - break; - } - } - - function formatNumberLevelInYaxis(type, position, formatter) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - } - }) - }); - config.plotOptions.tooltip.formatter.valueFormat = formatter; - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartRadarType: options.chartRadarType || c.NORMAL, - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - cordon: options.cordon || [], - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.RADAR); - }); - types.push(type); - }); - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.AccumulateRadarChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.accumulate_radar_chart', BI.AccumulateRadarChart);/** - * 图表控件 - * @class BI.AreaChart - * @extends BI.Widget - */ -BI.AreaChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.AreaChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-area-chart" - }) - }, - - _init: function () { - BI.AreaChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.AreaChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartLineStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var title = ""; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - title = getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators), - gridLineWidth: self.config.showGridLine === true ? 1 : 0 - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - title = getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - } - }); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "area"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatChartLineStyle() { - switch (self.config.chartLineType) { - case BICst.CHART_SHAPE.RIGHT_ANGLE: - config.plotOptions.curve = false; - config.plotOptions.step = true; - break; - case BICst.CHART_SHAPE.CURVE: - config.plotOptions.curve = true; - config.plotOptions.step = false; - break; - case BICst.CHART_SHAPE.NORMAL: - default: - config.plotOptions.curve = false; - config.plotOptions.step = false; - break; - } - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - rightYAxisSecondTitle: options.rightYAxisSecondTitle || "", - chartLineType: options.chartLineType || c.NORMAL, - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - rightYAxisSecondStyle: options.rightYAxisSecondStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - showRightYAxisSecondTitle: options.showRightYAxisSecondTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - rightYAxisSecondReversed: options.rightYAxisSecondReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - rightYAxisSecondNumberLevel: options.rightYAxisSecondNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - rightYAxisSecondUnit: options.rightYAxisSecondUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.AREA); - }); - types.push(type); - }); - - this.yAxis = []; - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.AreaChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.area_chart', BI.AreaChart);/** - * 图表控件 柱状 - * @class BI.AxisChart - * @extends BI.Widget - * leftYxis 左值轴属性 - * rightYxis 右值轴属性 - * xAxis 分类轴属性 - */ -BI.AxisChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.AxisChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-axis-chart" - }) - }, - - _init: function () { - BI.AxisChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.AxisChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var title; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - title = getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - title = getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTIck: self.config.enableMinorTick, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators), - gridLineWidth: self.config.showGridLine === true ? 1 : 0 - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - } - }); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - var lineItem = []; - var otherItem = []; - BI.each(items, function (idx, item) { - if (item.type === "line") { - lineItem.push(item); - } else { - otherItem.push(item); - } - }); - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [BI.concat(otherItem, lineItem), config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - populate: function (items, options, types) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: true - }; - this.options.items = items; - - this.yAxis = []; - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.AxisChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.axis_chart', BI.AxisChart);/** - * 图表控件 - * @class BI.BarChart - * @extends BI.Widget - */ -BI.BarChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.BarChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-bar-chart" - }) - }, - - _init: function () { - BI.BarChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - formatter: function () { - return this > 0 ? this : (-1) * this - }, - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - gridLineWidth: 0, - position: "left" - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - var tmp = obj.x; - obj.x = obj.y; - obj.y = tmp; - self.fireEvent(BI.BarChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - - //分类轴 - config.yAxis = this.yAxis; - config.yAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - config.yAxis[0].title.rotation = this.constants.ROTATION; - BI.extend(config.yAxis[0], { - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - labelRotation: this.config.textDirection, - enableTick: this.config.enableTick, - lineWidth: this.config.lineWidth, - maxWidth: '40%' - }); - - //值轴 - self.formatNumberLevelInXaxis(items, this.config.leftYAxisNumberLevel); - config.xAxis[0].title.text = getXAxisTitle(this.config.leftYAxisNumberLevel, this.constants.X_AXIS); - config.xAxis[0].title.align = "center"; - BI.extend(config.xAxis[0], { - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators), - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - enableTick: this.config.enableTick, - showLabel: this.config.showLabel, - lineWidth: this.config.lineWidth, - enableMinorTick: this.config.enableMinorTick - }); - config.chartType = "bar"; - - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.xAxis[0].formatter, this.config.chartFont); - - config.plotOptions.tooltip.formatter.valueFormat = config.xAxis[0].formatter; - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.xAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function getXAxisTitle(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - unit = unit === "" ? unit : "(" + unit + ")"; - - return self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + unit : unit; - } - }, - - _formatItems: function (items) { - BI.each(items, function (idx, item) { - BI.each(item, function (id, it) { - BI.each(it.data, function (i, t) { - var tmp = t.x; - t.x = t.y; - t.y = tmp; - }) - }); - }); - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - xAxisStyle: options.xAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - xAxisNumberLevel: options.xAxisNumberLevel || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.BAR); - }); - types.push(type); - }); - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.BarChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.bar_chart', BI.BarChart);/** - * 图表控件 - * @class BI.BubbleChart - * @extends BI.Widget - */ -BI.BubbleChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.BubbleChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-bubble-chart" - }) - }, - - _init: function () { - BI.BubbleChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "left", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.BubbleChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - delete config.zoom; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.dataLabels.formatter.identifier = "${X}${Y}${SIZE}"; - config.plotOptions.shadow = this.config.bubbleStyle !== this.constants.NO_PROJECT; - config.yAxis = this.yAxis; - - config.yAxis[0].formatter = self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators); - formatNumberLevelInYaxis(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.yAxis[0].title.text = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.yAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + config.yAxis[0].title.text : config.yAxis[0].title.text; - config.yAxis[0].gridLineWidth = this.config.showGridLine === true ? 1 : 0; - config.yAxis[0].lineWidth = 1; - config.yAxis[0].title.rotation = this.constants.ROTATION; - config.yAxis[0].maxWidth = '40%'; - - config.xAxis[0].formatter = self.formatTickInXYaxis(this.config.xAxisStyle, this.config.xAxisNumberLevel, this.config.rightNumSeparators); - self.formatNumberLevelInXaxis(items, this.config.xAxisNumberLevel); - config.xAxis[0].title.text = getXYAxisUnit(this.config.xAxisNumberLevel, this.constants.X_AXIS); - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle + config.xAxis[0].title.text : config.xAxis[0].title.text; - config.xAxis[0].title.align = "center"; - config.xAxis[0].gridLineWidth = this.config.showGridLine === true ? 1 : 0; - config.xAxis[0].maxHeith = '40%'; - config.chartType = "bubble"; - - if (BI.isNotEmptyArray(this.config.tooltip)) { - config.plotOptions.bubble.tooltip = { - useHtml: true, - style: { - color: 'RGB(184, 184, 184)' - }, - formatter: function () { - var y = self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators)(this.y); - var x = self.formatTickInXYaxis(self.config.xAxisStyle, self.config.xAxisNumberLevel, self.config.rightNumSeparators)(this.x); - return this.seriesName + '
(X)' + self.config.tooltip[0] + ':' + x + '
(Y)' + self.config.tooltip[1] - + ':' + y + '
(' + BI.i18nText("BI-Size") + ')' + self.config.tooltip[2] + ':' + this.size + '
'} - }; - } - - //为了给数据标签加个%,还要遍历所有的系列,唉 - if (config.plotOptions.dataLabels.enabled === true) { - BI.each(items, function (idx, item) { - item.dataLabels = { - "style" : self.config.chartFont, - "align": "outside", - "autoAdjust": true, - enabled: true, - formatter: { - identifier: "${X}${Y}${SIZE}", - "XFormat": function () { - return BI.contentFormat(arguments[0], '#.##;-#.##') - }, - "YFormat": function () { - return BI.contentFormat(arguments[0], '#.##;-#.##') - }, - "sizeFormat": function () { - return BI.contentFormat(arguments[0], '#.##;-#.##') - } - } - }; - item.dataLabels.formatter.XFormat = config.xAxis[0].formatter; - item.dataLabels.formatter.YFormat = config.yAxis[0].formatter; - }); - } - - //全局样式图表文字 - config.yAxis[0].title.style = config.yAxis[0].labelStyle = this.config.chartFont; - config.xAxis[0].title.style = config.xAxis[0].labelStyle = this.config.chartFont; - config.legend.style = this.config.chartFont; - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatNumberLevelInYaxis(type, position) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - } - }) - }); - if (type === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT) { - //config.plotOptions.tooltip.formatter.valueFormat = "function(){return window.FR ? FR.contentFormat(arguments[0], '#0%') : arguments[0]}"; - } - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function (items) { - BI.each(items, function (idx, item) { - BI.each(item, function (id, it) { - BI.each(it.data, function (i, da) { - var data = da.size; - da.size = BI.contentFormat(data, '#.##;-#.##') - }) - }) - }); - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - xAxisStyle: options.xAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - xAxisNumberLevel: options.xAxisNumberLevel || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - cordon: options.cordon || [], - tooltip: options.tooltip || [], - bubbleStyle: options.bubbleStyle || c.NO_PROJECT, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.BUBBLE); - }); - types.push(type); - }); - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.BubbleChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.bubble_chart', BI.BubbleChart); -/** - * 图表控件 - * @class BI.CompareAreaChart - * @extends BI.Widget - */ -BI.CompareAreaChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.CompareAreaChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-compare-area-chart" - }) - }, - - _init: function () { - BI.CompareAreaChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.CompareAreaChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartLineStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var title = ""; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - title = getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.rotation = self.constants.ROTATION; - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + title : title; - BI.extend(axis, { - reversed: false, - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - formatNumberLevelInYaxis(self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - title = getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.rotation = self.constants.ROTATION; - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + title : title; - BI.extend(axis, { - reversed: true, - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - formatNumberLevelInYaxis(self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - } - var res = _calculateValueNiceDomain(0, self.maxes[idx]); - axis.max = res[1].mul(2); - axis.min = res[0].mul(2); - axis.tickInterval = BI.parseFloat((BI.parseFloat(axis.max).sub(BI.parseFloat(axis.min)))).div(5); - }); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "area"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function _calculateValueNiceDomain(minValue, maxValue) { - - minValue = Math.min(0, minValue); - - var tickInterval = _linearTickInterval(minValue, maxValue); - - return _linearNiceDomain(minValue, maxValue, tickInterval); - } - - function _linearTickInterval(minValue, maxValue, m) { - - m = m || 5; - var span = maxValue - minValue; - var step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)); - var err = m / span * step; - - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - - return step; - } - - function _linearNiceDomain(minValue, maxValue, tickInterval) { - - minValue = VanUtils.accMul(Math.floor(minValue / tickInterval), tickInterval); - - maxValue = VanUtils.accMul(Math.ceil(maxValue / tickInterval), tickInterval); - - return [minValue, maxValue]; - } - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatChartLineStyle() { - switch (self.config.chartLineType) { - case BICst.CHART_SHAPE.RIGHT_ANGLE: - config.plotOptions.area = { - curve: false, - step: true - }; - break; - case BICst.CHART_SHAPE.CURVE: - config.plotOptions.area = { - curve: true, - step: false - }; - break; - case BICst.CHART_SHAPE.NORMAL: - default: - config.plotOptions.area = { - curve: false, - step: false - }; - break; - } - } - - function formatNumberLevelInYaxis(type, position, formatter) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - var max = null; - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - if ((BI.isNull(max) || BI.parseFloat(da.y) > BI.parseFloat(max))) { - max = da.y; - } - } - }); - if (position === item.yAxis) { - item.tooltip = BI.deepClone(config.plotOptions.tooltip); - item.tooltip.formatter.valueFormat = formatter; - } - if (BI.isNotNull(max)) { - self.maxes.push(max); - } - }); - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function (items) { - var self = this; - this.maxes = []; - BI.each(items, function (idx, item) { - BI.each(item, function (id, it) { - if (idx > 0) { - BI.extend(it, {reversed: true, xAxis: 0}); - } else { - BI.extend(it, {reversed: false, xAxis: 1}); - } - }); - }); - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - chartLineType: options.chartLineType || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.AREA); - }); - types.push(type); - }); - - this.yAxis = []; - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.CompareAreaChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.compare_area_chart', BI.CompareAreaChart);/** - * 图表控件 - * @class BI.CompareAxisChart - * @extends BI.Widget - */ -BI.CompareAxisChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.CompareAxisChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-compare-axis-chart" - }) - }, - - _init: function () { - BI.CompareAxisChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }, { - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "top", - gridLineWidth: 0, - type: "category", - showLabel: false - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.CompareAxisChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function(config, items){ - var self = this, o = this.options; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartLineStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if(this.config.showZoom === true){ - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function(idx, axis){ - var unit = ''; - switch (axis.axisIndex){ - case self.constants.LEFT_AXIS: - unit = getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.rotation = self.constants.ROTATION; - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + unit : unit; - BI.extend(axis, { - reversed: false, - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - formatNumberLevelInYaxis(self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - unit = getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.rotation = self.constants.ROTATION; - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + unit : unit; - BI.extend(axis, { - reversed: true, - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - formatNumberLevelInYaxis(self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - } - var res = _calculateValueNiceDomain(0, self.maxes[idx]); - axis.max = res[1].mul(2); - axis.min = res[0].mul(2); - axis.tickInterval = BI.parseFloat((BI.parseFloat(axis.max).sub(BI.parseFloat(axis.min)))).div(5); - }); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - BI.extend(config.xAxis[1], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - enableMinorTick: this.config.enableMinorTick - }); - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle(){ - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon(){ - BI.each(self.config.cordon, function(idx, cor){ - if(idx === 0 && self.xAxis.length > 0){ - var magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function(i, t){ - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if(idx > 0 && self.yAxis.length >= idx){ - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function(i, t){ - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatChartLineStyle(){ - switch (self.config.chartLineType) { - case BICst.CHART_SHAPE.RIGHT_ANGLE: - config.plotOptions.curve = false; - config.plotOptions.step = true; - break; - case BICst.CHART_SHAPE.CURVE: - config.plotOptions.curve = true; - config.plotOptions.step = false; - break; - case BICst.CHART_SHAPE.NORMAL: - default: - config.plotOptions.curve = false; - config.plotOptions.step = false; - break; - } - } - - function formatNumberLevelInYaxis(type, position, formatter){ - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - var max = null; - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - if((BI.isNull(max) || BI.parseFloat(da.y) > BI.parseFloat(max))){ - max = da.y; - } - } - }); - if(position === item.yAxis){ - item.tooltip = BI.deepClone(config.plotOptions.tooltip); - item.tooltip.formatter.valueFormat = formatter; - } - if(BI.isNotNull(max)){ - self.maxes.push(max); - } - }); - } - - function getXYAxisUnit(numberLevelType, position){ - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if(position === self.constants.X_AXIS){ - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if(position === self.constants.LEFT_AXIS){ - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if(position === self.constants.RIGHT_AXIS){ - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - - function _calculateValueNiceDomain(minValue, maxValue){ - - minValue = Math.min(0, minValue); - - var tickInterval = _linearTickInterval(minValue, maxValue); - - return _linearNiceDomain(minValue, maxValue, tickInterval); - } - - function _linearTickInterval(minValue, maxValue, m){ - - m = m || 5; - var span = maxValue - minValue; - var step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)); - var err = m / span * step; - - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - - return step; - } - - function _linearNiceDomain(minValue, maxValue, tickInterval){ - - minValue = VanUtils.accMul(Math.floor(minValue / tickInterval), tickInterval); - - maxValue = VanUtils.accMul(Math.ceil(maxValue / tickInterval), tickInterval); - - return [minValue, maxValue]; - } - }, - - _formatItems: function(items){ - var self = this; - this.maxes = []; - BI.each(items, function(idx, item){ - BI.each(item, function(id, it){ - if(idx > 0){ - BI.extend(it, {reversed: true, xAxis: 1}); - }else{ - BI.extend(it, {reversed: false, xAxis: 0}); - } - }); - }); - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - chartLineType: options.chartLineType || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - - this.yAxis = []; - - var types = []; - BI.each(items, function(idx, axisItems){ - var type = []; - BI.each(axisItems, function(id, item){ - type.push(BICst.WIDGET.AXIS); - }); - types.push(type); - }); - - BI.each(types, function(idx, type){ - if(BI.isEmptyArray(type)){ - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0, - reversed: idx > 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function(){ - this.combineChart.magnify(); - } -}); -BI.CompareAxisChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.compare_axis_chart', BI.CompareAxisChart);/** - * 图表控件 - * @class BI.CompareBarChart - * @extends BI.Widget - */ -BI.CompareBarChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.CompareBarChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-compare-bar-chart" - }) - }, - - _init: function () { - BI.CompareBarChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - formatter: function () { - return this > 0 ? this : (-1) * this; - }, - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - gridLineWidth: 0, - position: "left" - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.CompareBarChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - var yTitle = getXYAxisUnit(this.config.xAxisNumberLevel, this.constants.LEFT_AXIS); - var xTitle = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.X_AXIS); - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - - config.yAxis = this.yAxis; - config.yAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle + yTitle : yTitle; - config.yAxis[0].title.rotation = this.constants.ROTATION; - BI.extend(config.yAxis[0], { - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - maxWidth: '40%' - }); - - self.formatNumberLevelInXaxis(items, this.config.leftYAxisNumberLevel); - config.xAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + xTitle : xTitle; - config.xAxis[0].title.align = "center"; - BI.extend(config.xAxis[0], { - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators, true), - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - lineWidth: this.config.lineWidth, - showLabel: this.config.showLabel, - enableTick: this.config.enableTick, - enableMinorTick: this.config.enableMinorTick - }); - - config.chartType = "bar"; - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.xAxis[0].formatter, this.config.chartFont); - - config.plotOptions.tooltip.formatter.valueFormat = config.xAxis[0].formatter; - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.xAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function (items) { - var result = []; - var i = BI.UUID(); - BI.each(items, function (idx, item) { - BI.each(item, function (id, it) { - BI.each(it.data, function (i, t) { - var tmp = t.x; - t.x = t.y; - t.y = tmp; - if (idx === 0) { - t.x = -t.x; - } - }); - it.stack = i; - }) - }); - BI.each(items, function (idx, item) { - result = BI.concat(result, item); - }); - return [result]; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - xAxisStyle: options.xAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - xAxisNumberLevel: options.xAxisNumberLevel || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = this._formatItems(items); - var types = []; - BI.each(this.options.items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.BAR); - }); - types.push(type); - }); - this.combineChart.populate(this.options.items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.CompareBarChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.compare_bar_chart', BI.CompareBarChart);/** - * 图表控件 - * @class BI.DashboardChart - * @extends BI.Widget - */ -BI.DashboardChart = BI.inherit(BI.AbstractChart, { - - - _defaultConfig: function () { - return BI.extend(BI.DashboardChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-dashboard-chart" - }) - }, - - _init: function () { - BI.DashboardChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.gaugeAxis = [{ - "minorTickColor": "rgb(226,226,226)", - "tickColor": "rgb(186,186,186)", - labelStyle: this.constants.FONT_STYLE, - "step": 0, - "showLabel": true - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.DashboardChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - var isDashboard = BI.contains([self.constants.NORMAL, self.constants.HALF_DASHBOARD], self.config.chartDashboardType); - var isMultiPointers = self.config.numberOfPointer === self.constants.MULTI_POINTER; - formatChartDashboardStyle(); - config.chartType = "gauge"; - delete config.zoom; - delete config.xAxis; - delete config.yAxis; - if (isDashboard && !isMultiPointers) { - config.plotOptions.seriesLabel.enabled = false; - if(BI.isNull(items[0].data[0].z)) { - config.plotOptions.tooltip.formatter.identifier = "${SERIES}${X}${Y}${SIZE}${VALUE}" - } - } - config.gaugeAxis[0].labelStyle = this.config.chartFont; - return [items, config]; - - function formatChartDashboardStyle() { - var bands = getBandsStyles(self.config.bandsStyles, self.config.autoCustomStyle); - var percentageLabel = BI.extend(config.plotOptions.percentageLabel, { - enabled: self.config.showPercentage === BICst.PERCENTAGE.SHOW - }); - - config.gaugeAxis = self.gaugeAxis; - var slotValueLAbel = { - enabled: true, - formatter: function () { - var value = this.value; - if (self.config.dashboardNumberLevel === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT && self.config.numSeparators) { - value = BI.contentFormat(this.value, "#,##0%;-#,##0%") - } else if (self.config.dashboardNumberLevel === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT && !self.config.numSeparators) { - value = BI.contentFormat(this.value, "#0.00%"); - } else if (!(self.config.dashboardNumberLevel === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT) && self.config.numSeparators) { - value = BI.contentFormat(this.value, "#,###.##;-#,###.##") - } else { - value = BI.contentFormat(this.value, "#.##;-#.##"); - } - - var label = '
' + this.seriesName + '
' + '
' + value + - getXYAxisUnit(self.config.dashboardNumberLevel, self.constants.DASHBOARD_AXIS) + '
'; - - if (isDashboard && items[0].data.length > 1) { - if (isMultiPointers) { - return '
' + this.seriesName + ':' + value + - getXYAxisUnit(self.config.dashboardNumberLevel, self.constants.DASHBOARD_AXIS) + '
'; - } - return label - } else if (isDashboard && BI.isNull(items[0].data[0].z)) { - return label - } - - return '
' + this.category + '
' + label; - }, - style: self.config.chartFont, - useHtml: true - }; - switch (self.config.chartDashboardType) { - case BICst.CHART_SHAPE.HALF_DASHBOARD: - setPlotOptions("pointer_semi", bands, slotValueLAbel, percentageLabel); - break; - case BICst.CHART_SHAPE.PERCENT_DASHBOARD: - setPlotOptions("ring", bands, slotValueLAbel, percentageLabel); - break; - case BICst.CHART_SHAPE.PERCENT_SCALE_SLOT: - setPlotOptions("slot", bands, slotValueLAbel, percentageLabel); - break; - case BICst.CHART_SHAPE.HORIZONTAL_TUBE: - BI.extend(slotValueLAbel, { - align: "bottom" - }); - BI.extend(percentageLabel, { - align: "bottom" - }); - setPlotOptions("thermometer", bands, slotValueLAbel, percentageLabel, "horizontal", "vertical"); - break; - case BICst.CHART_SHAPE.VERTICAL_TUBE: - BI.extend(slotValueLAbel, { - align: "left" - }); - BI.extend(percentageLabel, { - align: "left" - }); - setPlotOptions("thermometer", bands, slotValueLAbel, percentageLabel, "vertical", "horizontal"); - break; - case BICst.CHART_SHAPE.NORMAL: - default: - setPlotOptions("pointer", bands, slotValueLAbel, percentageLabel); - break; - } - changeMaxMinScale(); - formatNumberLevelInYaxis(self.config.dashboardNumberLevel, self.constants.LEFT_AXIS); - if (self.config.dashboardNumberLevel === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT) { - config.gaugeAxis[0].formatter = function () { - var scaleValue = this; - if (self.config.numSeparators) { - scaleValue = BI.contentFormat(scaleValue, '#,##0%;-#,##0%') - } else { - scaleValue = BI.contentFormat(scaleValue, '#0.00%') - } - return scaleValue + getXYAxisUnit(self.config.dashboardNumberLevel, self.constants.DASHBOARD_AXIS); - }; - } else { - config.gaugeAxis[0].formatter = function () { - var value = this; - if (self.config.numSeparators) { - value = BI.contentFormat(value, "#,###;-#,###") - } - return value + getXYAxisUnit(self.config.dashboardNumberLevel, self.constants.DASHBOARD_AXIS); - }; - } - } - - function setPlotOptions(style, bands, slotValueLAbel, percentageLabel, thermometerLayout, layout) { - config.style = style; - config.plotOptions.bands = bands; - config.plotOptions.valueLabel = slotValueLAbel; - config.plotOptions.percentageLabel = percentageLabel; - config.plotOptions.thermometerLayout = thermometerLayout; - config.plotOptions.layout = layout; - } - - function changeMaxMinScale() { - self.gaugeAxis[0].min = BI.parseFloat(self.config.minScale) || null; - self.gaugeAxis[0].max = BI.parseFloat(self.config.maxScale) || null; - } - - function formatNumberLevelInYaxis(type, position) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - } - }) - }); - - config.plotOptions.tooltip.formatter.valueFormat = function () { - return BI.contentFormat(this, '#.##;-#.##') + getXYAxisUnit(type, position) - }; - - if (self.config.numSeparators) { - config.plotOptions.tooltip.formatter.valueFormat = function () { - return BI.contentFormat(arguments[0], '#,###.##;-#,###.##') - }; - } - - if (type === BICst.TARGET_STYLE.NUM_LEVEL.PERCENT) { - config.plotOptions.tooltip.formatter.valueFormat = function () { - return BI.contentFormat(arguments[0], '#0.00%') - }; - if (self.config.numSeparators) { - config.plotOptions.tooltip.formatter.valueFormat = function () { - return BI.contentFormat(arguments[0], '#,##0%;-#,##0%') - }; - } - } - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.DASHBOARD_AXIS) { - self.config.dashboardUnit !== "" && (unit = unit + self.config.dashboardUnit) - } - return unit; - } - - function getBandsStyles(styles, change) { - var min = 0, bands = [], color = null, max = null, conditionMax = null; - - BI.each(items, function (idx, item) { - var data = item.data[0]; - if ((BI.isNull(max) || data.y > max)) { - max = data.y - } - }); - - switch (change) { - - case BICst.SCALE_SETTING.AUTO: - break; - case BICst.SCALE_SETTING.CUSTOM: - if (styles.length === 0) { - return bands - } else { - var maxScale = _calculateValueNiceDomain(0, max)[1]; - - BI.each(styles, function (idx, style) { - if(BI.parseFloat(style.range.min) > BI.parseFloat(style.range.max)) { - return bands.push({ - color: color, - from: conditionMax, - to: maxScale - }); - } - bands.push({ - color: style.color, - from: style.range.min, - to: style.range.max - }); - color = style.color; - conditionMax = style.range.max - }); - min = BI.parseInt(styles[0].range.min); - bands.push({ - color: "#808080", - from: 0, - to: min - }); - - bands.push({ - color: color, - from: conditionMax, - to: maxScale - }); - - return bands; - } - } - } - - function _calculateValueNiceDomain(minValue, maxValue) { - minValue = Math.min(0, minValue); - var tickInterval = _linearTickInterval(minValue, maxValue); - - return _linearNiceDomain(minValue, maxValue, tickInterval); - } - - function _linearTickInterval(minValue, maxValue, m) { - m = m || 5; - var span = maxValue - minValue; - var step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)); - var err = m / span * step; - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - - return step; - } - - function _linearNiceDomain(minValue, maxValue, tickInterval) { - minValue = VanUtils.accMul(Math.floor(minValue / tickInterval), tickInterval); - maxValue = VanUtils.accMul(Math.ceil(maxValue / tickInterval), tickInterval); - - return [minValue, maxValue]; - } - }, - - _formatItems: function (items) { - if (items.length === 0) { - return []; - } - var c = this.constants; - if (this.config.chartDashboardType === c.NORMAL || this.config.chartDashboardType === c.HALF_DASHBOARD) { - var result = []; - if (this.config.numberOfPointer === c.ONE_POINTER && items[0].length === 1) {//单个系列 - BI.each(items[0][0].data, function (idx, da) { - result.push({ - data: [BI.extend({}, da, { - x: items[0][0].name - })], - name: da.x - }) - }); - return [result]; - } else if(this.config.numberOfPointer === c.ONE_POINTER && items[0].length > 1) { - BI.each(items[0], function (idx, item) { - result.push({ - data: [BI.extend(item.data[0], { - x: item.name - })], - name: BI.UUID() - }) - }); - return [result] - } - if (this.config.numberOfPointer === c.MULTI_POINTER && items[0].length > 1) {//多个系列 - BI.each(items, function (idx, item) { - BI.each(item, function (id, it) { - var data = it.data[0]; - data.x = it.name; - result.push(data); - }) - }); - return [[{ - data: result, - name: "" - }]]; - } - } else { - var others = []; - if (BI.isNotNull(items[0][0].data[0].z)) { - BI.each(items[0], function (idx, item) { - BI.each(item.data, function (id, da) { - others.push({ - data: [BI.extend({}, da, { - x: item.name, - y: da.y - })], - name: da.x - }) - }) - }); - return [others]; - } - } - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants, o = this.options; - this.config = { - dashboardNumberLevel: options.dashboardNumberLevel || c.NORMAL, - dashboardUnit: options.dashboardUnit || "", - chartDashboardType: options.chartDashboardType || c.NORMAL, - numberOfPointer: options.numberOfPointer || c.ONE_POINTER, - bandsStyles: options.bandsStyles || [], - autoCustomStyle: options.autoCustom || c.AUTO, - minScale: options.minScale, - maxScale: options.maxScale, - showPercentage: options.showPercentage || c.NOT_SHOW, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - o.items = this._formatItems(items); - var types = []; - BI.each(o.items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.DASHBOARD); - }); - types.push(type); - }); - - this.combineChart.populate(o.items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.DashboardChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.dashboard_chart', BI.DashboardChart);/** - * 图表控件 - * @class BI.DonutChart - * @extends BI.Widget - */ -BI.DonutChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.DonutChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-donut-chart" - }) - }, - - _init: function () { - BI.DonutChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.DonutChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function(config, items){ - var self = this; - delete config.zoom; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - - this.formatChartLegend(config, this.config.chartLegend); - - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - - config.plotOptions.innerRadius = "50.0%"; - config.chartType = "pie"; - config.plotOptions.dataLabels.align = "outside"; - config.plotOptions.dataLabels.connectorWidth = "outside"; - config.plotOptions.dataLabels.style = this.config.chartFont; - config.plotOptions.dataLabels.formatter.identifier = "${VALUE}${PERCENT}"; - delete config.xAxis; - delete config.yAxis; - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - da.y = self.formatXYDataWithMagnify(da.y, 1); - }) - }); - - config.legend.style = this.config.chartFont; - return [items, config]; - - function formatChartStyle(){ - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - - var types = []; - BI.each(items, function(idx, axisItems){ - var type = []; - BI.each(axisItems, function(id, item){ - type.push(BICst.WIDGET.DONUT); - }); - types.push(type); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function(){ - this.combineChart.magnify(); - } -}); -BI.DonutChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.donut_chart', BI.DonutChart);/** - * 图表控件 - * @class BI.FallAxisChart - * @extends BI.Widget - */ -BI.FallAxisChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.FallAxisChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-fall-axis-chart" - }) - }, - - _init: function () { - BI.FallAxisChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "left", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.FallAxisChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function(config, items){ - var self = this, o = this.options; - var yTitle = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - config.legend.enabled = false; - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.dataSheet.enabled = this.config.showDataTable; - if(config.dataSheet.enabled === true){ - config.xAxis[0].showLabel = false; - } - config.zoom.zoomTool.enabled = this.config.showZoom; - if(this.config.showZoom === true){ - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.extend(config.yAxis[0], { - lineWidth: this.config.lineWidth, - showLabel: this.config.showLabel, - enableTick: this.config.enableTick, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators) - }); - formatNumberLevelInYaxis(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS, config.yAxis[0].formatter); - config.yAxis[0].title.rotation = this.constants.ROTATION; - config.yAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + yTitle : yTitle; - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - enableMinorTick: this.config.enableMinorTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - //为了给数据标签加个%,还要遍历所有的系列,唉 - if(config.plotOptions.dataLabels.enabled === true){ - BI.each(items, function(idx, item){ - if(idx === 0){ - item.dataLabels = {}; - return; - } - item.dataLabels = { - "style": self.config.chartFont, - "align": "outside", - "autoAdjust": true, - enabled: true, - formatter: { - identifier: "${VALUE}", - valueFormat: config.yAxis[0].formatter - } - }; - }); - } - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle(){ - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon(){ - BI.each(self.config.cordon, function(idx, cor){ - if(idx === 0 && self.xAxis.length > 0){ - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function(i, t){ - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if(idx > 0 && self.yAxis.length >= idx){ - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function(i, t){ - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatNumberLevelInYaxis(type, position, formatter){ - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - } - }) - }); - config.plotOptions.tooltip.formatter.valueFormat = formatter; - } - - function getXYAxisUnit(numberLevelType, position){ - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if(position === self.constants.X_AXIS){ - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if(position === self.constants.LEFT_AXIS){ - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if(position === self.constants.RIGHT_AXIS){ - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function(items){ - var o = this.options; - if(BI.isEmptyArray(items)){ - return []; - } - items = items[0]; - var tables = [], sum = 0; - var colors = this.config.chartColor || []; - if(BI.isEmptyArray(colors)){ - colors = ["rgb(152, 118, 170)", "rgb(0, 157, 227)"]; - } - BI.each(items, function(idx, item){ - BI.each(item.data, function(i, t){ - if(t.y < 0){ - tables.push([t.x, t.y, sum + t.y, t]); - }else{ - tables.push([t.x, t.y, sum, t]); - } - sum += t.y; - }); - }); - - return [BI.map(BI.makeArray(2, null), function(idx, item){ - return { - "data": BI.map(tables, function(id, cell){ - var axis = BI.extend({}, cell[3], { - x: cell[0], - y: Math.abs(cell[2 - idx]) - }); - if(idx === 1){ - axis.color = cell[2 - idx] < 0 ? colors[1] : colors[0]; - }else{ - axis.color = "rgba(0,0,0,0)"; - axis.borderColor = "rgba(0,0,0,0)"; - axis.borderWidth = 0; - axis.clickColor = "rgba(0,0,0,0)"; - axis.mouseOverColor = "rgba(0,0,0,0)"; - axis.tooltip = { - enable: false - } - } - return axis; - }), - stack: "stackedFall", - name: idx === 1 ? items[0].name : BI.UUID() - }; - })]; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || ["#5caae4", "#70cc7f", "#ebbb67", "#e97e7b", "#6ed3c9"], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - var types = []; - BI.each(items, function(idx, axisItems){ - var type = []; - BI.each(axisItems, function(id, item){ - type.push(BICst.WIDGET.AXIS); - }); - types.push(type); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function(){ - this.combineChart.magnify(); - } -}); -BI.FallAxisChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.fall_axis_chart', BI.FallAxisChart);/** - * 图表控件 - * @class BI.ForceBubbleChart - * @extends BI.Widget - */ -BI.ForceBubbleChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.ForceBubbleChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-force-bubble-chart" - }) - }, - - _init: function () { - BI.ForceBubbleChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.ForceBubbleChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - config.chartType = 'forceBubble'; - config.colors = this.config.chartColor; - this.formatChartLegend(config, this.config.chartLegend); - - config.plotOptions.force = true; - config.plotOptions.shadow = this.config.bubbleStyle !== this.constants.NO_PROJECT; - config.plotOptions.dataLabels.enabled = true; - config.plotOptions.dataLabels.align = "inside"; - config.plotOptions.dataLabels.style = this.config.chartFont; - config.plotOptions.dataLabels.formatter.identifier = "${CATEGORY}${VALUE}"; - delete config.xAxis; - delete config.yAxis; - delete config.zoom; - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - da.y = self.formatXYDataWithMagnify(da.y, 1); - }) - }); - config.legend.style = this.config.chartFont; - return [items, config]; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartColor: options.chartColor || [], - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - bubbleStyle: options.bubbleStyle || c.NO_PROJECT, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.FORCE_BUBBLE); - }); - types.push(type); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.ForceBubbleChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.force_bubble_chart', BI.ForceBubbleChart);/** - * 图表控件 - * @class BI.GISMapChart - * @extends BI.Widget - */ -BI.GISMapChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.GISMapChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-gis-map-chart" - }) - }, - - _init: function () { - BI.GISMapChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.GISMapChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - delete config.dataSheet; - delete config.legend; - delete config.zoom; - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.dataLabels.useHtml = true; - config.plotOptions.dataLabels.style = this.config.chartFont; - config.plotOptions.dataLabels.formatter = function () { - var name = (BI.isArray(this.name) ? '' : this.name + ',') + BI.contentFormat(this.value, '#.##;-#.##') ; - var style = "padding: 5px; background-color: rgba(0,0,0,0.4980392156862745);border-color: rgb(0,0,0); border-radius:2px; border-width:0px;"; - var a = '
' + name + '
'; - return a; - }; - config.plotOptions.tooltip.shared = true; - config.plotOptions.tooltip.formatter = function () { - var tip = BI.isArray(this.name) ? '' : this.name; - BI.each(this.points, function (idx, point) { - tip += ('
' + point.seriesName + ':' + BI.contentFormat((point.size || point.y), '#.##;-#.##') + '
'); - }); - return tip; - }; - config.geo = { - "tileLayer": "http://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}", - "attribution": "© 2016 AutoNavi" - }; - if (this.config.showBackgroundLayer === true && BI.isNotNull(this.config.backgroundLayerInfo)) { - config.geo = {}; - if (this.config.backgroundLayerInfo.type === BICst.WMS_SERVER) { - config.geo.tileLayer = false; - config.geo.wmsUrl = this.config.backgroundLayerInfo.url; - config.geo.wmsLayer = this.config.backgroundLayerInfo.wmsLayer - } else { - config.geo.tileLayer = this.config.backgroundLayerInfo.url; - } - } - config.chartType = "pointMap"; - config.plotOptions.icon = { - iconUrl: BICst.GIS_ICON_PATH, - iconSize: [24, 24] - }; - - config.plotOptions.marker = { - symbol: BICst.GIS_ICON_PATH, - width: 24, - height: 24, - enable: true - }; - delete config.xAxis; - delete config.yAxis; - return [items, config]; - - }, - - _checkLngLatValid: function (lnglat) { - if (lnglat.length < 2) { - return false; - } - return lnglat[0] <= 180 && lnglat[0] >= -180 && lnglat[1] <= 90 && lnglat[1] >= -90; - }, - - _formatItems: function (items) { - var self = this; - var results = []; - BI.each(items, function (idx, item) { - var result = []; - BI.each(item, function (id, it) { - var res = []; - BI.each(it.data, function (i, da) { - da.y = self.formatXYDataWithMagnify(da.y, 1); - var lnglat = da.x.split(","); - if (self.config.lnglat === self.constants.LAT_FIRST) { - var lng = lnglat[1]; - lnglat[1] = lnglat[0]; - lnglat[0] = lng; - } - da.lnglat = lnglat; - da.value = da.y; - da.name = BI.isNotNull(da.z) ? da.z : da.lnglat; - if (self._checkLngLatValid(da.lnglat)) { - res.push(da); - } - }); - if (BI.isNotEmptyArray(res)) { - result.push(BI.extend(it, { - data: res - })); - } - }); - if (BI.isNotEmptyArray(result)) { - results.push(result); - } - }); - return results; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - lnglat: options.lnglat || c.LNG_FIRST, - chartFont: options.chartFont || c.FONT_STYLE, - showBackgroundLayer: options.showBackgroundLayer || false, - backgroundLayerInfo: options.backgroundLayerInfo - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function () { - type.push(BICst.WIDGET.GIS_MAP); - }); - types.push(type); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.GISMapChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.gis_map_chart', BI.GISMapChart);/** - * 图表控件 - * @class BI.LineChart - * @extends BI.Widget - */ -BI.LineChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.LineChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-line-chart" - }) - }, - - _init: function () { - BI.LineChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.LineChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartLineStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var title = ""; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - axis.title.rotation = self.constants.ROTATION; - title = getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + title : title; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - title = getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - } - }); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "line"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatChartLineStyle() { - switch (self.config.chartLineType) { - case BICst.CHART_SHAPE.RIGHT_ANGLE: - config.plotOptions.curve = false; - config.plotOptions.step = true; - break; - case BICst.CHART_SHAPE.CURVE: - config.plotOptions.curve = true; - config.plotOptions.step = false; - break; - case BICst.CHART_SHAPE.NORMAL: - default: - config.plotOptions.curve = false; - config.plotOptions.step = false; - break; - } - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - chartLineType: options.chartLineType || c.NORMAL, - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.LINE); - }); - types.push(type); - }); - - this.yAxis = []; - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.LineChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.line_chart', BI.LineChart);/** - * 图表控件 - * @class BI.MapChart - * @extends BI.Widget - */ -BI.MapChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.MapChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-map-chart" - }) - }, - - _init: function () { - BI.MapChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.MapChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, c = this.constants; - formatRangeLegend(); - delete config.legend; - delete config.zoom; - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.tooltip.shared = true; - var formatterArray = []; - BI.each(items, function (idx, item) { - if (BI.has(item, "settings")) { - formatterArray.push(formatToolTipAndDataLabel(item.settings.format || c.NORMAL, item.settings.num_level || c.NORMAL, - item.settings.unit || "", item.settings.numSeparators || c.NUM_SEPARATORS)); - } - }); - config.plotOptions.tooltip.formatter = function () { - var tip = this.name; - var point = this.points[0]; - var index = BI.isNull(point.size) ? 0 : 1; - tip += ('
' + point.seriesName + ':' + BI.contentFormat(point.size || point.y, formatterArray[index]) + '
'); - return tip; - }; - config.plotOptions.dataLabels.formatter.valueFormat = function () { - return BI.contentFormat(arguments[0], formatterArray[0]); - }; - config.plotOptions.dataLabels.style = this.config.chartFont; - - config.plotOptions.bubble.dataLabels = config.plotOptions.dataLabels; - config.plotOptions.bubble.dataLabels.formatter.identifier = "${SIZE}"; - - config.plotOptions.bubble.tooltip = config.plotOptions.tooltip; - - config.geo = this.config.geo; - if (this.config.showBackgroundLayer === true && BI.isNotNull(this.config.backgroundLayerInfo)) { - if (this.config.backgroundLayerInfo.type === BICst.WMS_SERVER) { - config.geo.tileLayer = false; - config.geo.wmsUrl = this.config.backgroundLayerInfo.url; - config.geo.wmsLayer = this.config.backgroundLayerInfo.wmsLayer - } else { - config.geo.tileLayer = this.config.backgroundLayerInfo.url; - } - } - if (this.config.initDrillPath.length > 1) { - config.initDrillPath = this.config.initDrillPath; - } - config.dTools.enabled = true; - config.dTools.click = function (point) { - point = point || {}; - var pointOption = point.options || {}; - self.fireEvent(BI.MapChart.EVENT_CLICK_DTOOL, pointOption); - }; - config.chartType = "areaMap"; - delete config.xAxis; - delete config.yAxis; - - var find = BI.find(items, function (idx, item) { - return BI.has(item, "type") && item.type === "areaMap"; - }); - if (BI.isNull(find)) { - items.push({ - type: "areaMap", - data: [] - }) - } - - return [items, config]; - - function formatRangeLegend() { - config.rangeLegend.enabled = true; - switch (self.config.chartLegend) { - case BICst.CHART_LEGENDS.BOTTOM: - config.rangeLegend.visible = true; - config.rangeLegend.position = "bottom"; - break; - case BICst.CHART_LEGENDS.RIGHT: - config.rangeLegend.visible = true; - config.rangeLegend.position = "right"; - break; - case BICst.CHART_LEGENDS.NOT_SHOW: - config.rangeLegend.visible = false; - break; - } - config.rangeLegend.continuous = false; - config.rangeLegend.range = getRangeStyle(self.config.mapStyles, self.config.autoCustom, self.config.themeColor); - config.rangeLegend.formatter = function () { - var to = this.to; - if (BI.isNotEmptyArray(items) && BI.has(items[0], "settings")) { - var settings = items[0].settings; - var legendFormat = formatToolTipAndDataLabel(settings.format || c.NORMAL, settings.num_level || c.NORMAL, - settings.unit || "", settings.numSeparators || c.NUM_SEPARATORS); - to = BI.contentFormat(to, legendFormat) - } - return to - }; - } - - function formatToolTipAndDataLabel(format, numberLevel, unit, numSeparators) { - var formatter = '#.##'; - switch (format) { - case self.constants.NORMAL: - formatter = '#.##'; - if (numSeparators) formatter = '#,###.##'; - break; - case self.constants.ZERO2POINT: - formatter = '#0'; - if (numSeparators) formatter = '#,###'; - break; - case self.constants.ONE2POINT: - formatter = '#0.0'; - if (numSeparators) formatter = '#,###.0'; - break; - case self.constants.TWO2POINT: - formatter = '#0.00'; - if (numSeparators) formatter = '#,###.00'; - break; - } - - switch (numberLevel) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - formatter += ''; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - formatter += BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - formatter += BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - formatter += BI.i18nText("BI-Yi"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.PERCENT: - formatter += '%'; - break; - } - - return formatter + unit; - } - - function getRangeStyle(styles, change, defaultColor) { - var range = [], color = null, defaultStyle = {}; - var conditionMax = null, conditionMin = null, min = null; - - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, it) { - if (BI.isNull(min) || BI.parseFloat(min) > BI.parseFloat(it.y)) { - min = it.y - } - }) - }); - - switch (change) { - case BICst.SCALE_SETTING.AUTO: - defaultStyle.color = defaultColor; - return defaultStyle; - case BICst.SCALE_SETTING.CUSTOM: - if (styles.length !== 0) { - var maxScale = _calculateValueNiceDomain(0, self.max)[1]; - BI.each(styles, function (idx, style) { - if (style.range.max) { - range.push({ - color: style.color || "rgba(255,255,255,0)", - from: style.range.min, - to: style.range.max - }); - } else { - var to = style.range.min < maxScale ? maxScale : 266396; - range.push({ - color: style.color || "rgba(255,255,255,0)", - from: style.range.min, - to: to, - }); - } - color = style.color; - conditionMax = style.range.max - }); - - conditionMin = BI.parseFloat(styles[0].range.min); - if (conditionMin !== 0) { - range.push({ - color: "#808080", - from: 0, - to: conditionMin - }); - } - - if (conditionMax && conditionMax < maxScale) { - range.push({ - color: color || "rgba(255,255,255,0)", - from: conditionMax, - to: maxScale - }); - } - return range; - } else { - defaultStyle.color = defaultColor; - return defaultStyle; - } - } - } - - function _calculateValueNiceDomain(minValue, maxValue) { - minValue = Math.min(0, minValue); - var tickInterval = _linearTickInterval(minValue, maxValue); - - return _linearNiceDomain(minValue, maxValue, tickInterval); - } - - function _linearTickInterval(minValue, maxValue, m) { - m = m || 5; - var span = maxValue - minValue; - var step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)); - var err = m / span * step; - - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - - return step; - } - - function _linearNiceDomain(minValue, maxValue, tickInterval) { - minValue = VanUtils.accMul(Math.floor(minValue / tickInterval), tickInterval); - maxValue = VanUtils.accMul(Math.ceil(maxValue / tickInterval), tickInterval); - - return [minValue, maxValue]; - } - }, - - _formatDrillItems: function (items) { - var self = this; - BI.each(items.series, function (idx, da) { - var hasArea = false; - BI.each(da.data, function (idx, data) { - data.y = self.formatXYDataWithMagnify(data.y, 1); - if (BI.has(da, "settings")) { - data.y = self.formatXYDataWithMagnify(data.y, self.calcMagnify(da.settings.num_level || self.constants.NORMAL)); - } - if (BI.has(da, "type") && da.type == "bubble") { - data.name = data.x; - data.size = data.y; - } else { - data.name = data.x; - data.value = data.y; - } - if (BI.has(da, "type") && da.type === "areaMap") { - hasArea = true; - } - if (BI.has(data, "drilldown")) { - self._formatDrillItems(data.drilldown); - } - }); - if (hasArea === false) { - items.series.push({ - type: "areaMap", - data: [] - }); - } - }); - }, - - _formatItems: function (items) { - var self = this; - this.max = null; - this.min = null; - BI.each(items, function (idx, item) { - BI.each(item, function (id, it) { - BI.each(it.data, function (i, da) { - da.y = self.formatXYDataWithMagnify(da.y, 1); - if (BI.has(it, "settings")) { - da.y = self.formatXYDataWithMagnify(da.y, self.calcMagnify(it.settings.num_level || self.constants.NORMAL)); - } - if ((BI.isNull(self.max) || BI.parseFloat(da.y) > BI.parseFloat(self.max)) && id === 0) { - self.max = da.y; - } - if ((BI.isNull(self.min) || BI.parseFloat(da.y) < BI.parseFloat(self.min)) && id === 0) { - self.min = da.y; - } - if (BI.has(it, "type") && it.type == "bubble") { - da.name = da.x; - da.size = da.y; - } else { - da.name = da.x; - da.value = da.y; - } - if (BI.has(da, "drilldown")) { - self._formatDrillItems(da.drilldown); - } - }); - }) - }); - return items; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - geo: options.geo, - initDrillPath: options.initDrillPath || [], - tooltip: options.tooltip || "", - themeColor: options.themeColor || "#65bce7", - mapStyles: options.mapStyles || [], - autoCustom: options.autoCustom || c.AUTO_CUSTOM, - showBackgroundLayer: options.showBackgroundLayer || false, - backgroundLayerInfo: options.backgroundLayerInfo, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.MAP); - }); - types.push(type); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.MapChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MapChart.EVENT_CLICK_DTOOL = "EVENT_CLICK_DTOOL"; -BI.shortcut('bi.map_chart', BI.MapChart);/** - * 图表控件 - * @class BI.MultiAxisChart - * @extends BI.Widget - * leftYxis 左值轴属性 - * rightYxis 右值轴属性 - * xAxis 分类轴属性 - */ -BI.MultiAxisChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.MultiAxisChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-axis-chart" - }) - }, - - _init: function () { - BI.MultiAxisChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: {"fontFamily": "inherit", "color": "#808080", "fontSize": "12px", "fontWeight": ""} - }, - labelStyle: { - "fontFamily": "inherit", "color": "#808080", "fontSize": "12px" - }, - position: "bottom", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.MultiAxisChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - config.colors = this.config.chartColor; - config.style = this.formatChartStyle(); - this.formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var title = ""; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - title = self.getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - title = self.getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS_SECOND: - title = self.getXYAxisUnit(self.config.rightYAxisSecondNumberLevel, self.constants.RIGHT_AXIS_SECOND); - axis.title.text = self.config.showRightYAxisSecondTitle === true ? self.config.rightYAxisSecondTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisSecondReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisSecondStyle, self.config.rightYAxisSecondNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisSecondNumberLevel, idx, axis.formatter); - break; - default: - break; - } - }); - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - if (config.dataSheet) { - config.dataSheet.style = this.config.chartFont; - } - config.xAxis[0].title.style = config.xAxis[0].labelStyle = this.config.chartFont; - config.legend.style = this.config.chartFont; - config.plotOptions.dataLabels.style = this.config.chartFont; - BI.each(config.yAxis, function (idx, axis) { - axis.title.style = self.config.chartFont; - }); - - return [items, config]; - }, - - formatChartStyle: function () { - switch (this.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - }, - - formatCordon: function () { - var self = this; - var magnify = 1; - BI.each(this.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": { - "fontFamily": "inherit", - "color": "#808080", - "fontSize": "12px", - "fontWeight": "" - }, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - default: - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": { - "fontFamily": "inherit", - "color": "#808080", - "fontSize": "12px", - "fontWeight": "" - }, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - }, - - getXYAxisUnit: function (numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - default: - break; - } - if (position === this.constants.X_AXIS) { - this.config.xAxisUnit !== "" && (unit = unit + this.config.xAxisUnit) - } - if (position === this.constants.LEFT_AXIS) { - this.config.leftYAxisUnit !== "" && (unit = unit + this.config.leftYAxisUnit) - } - if (position === this.constants.RIGHT_AXIS) { - this.config.rightYAxisUnit !== "" && (unit = unit + this.config.rightYAxisUnit) - } - if (position === this.constants.RIGHT_AXIS_SECOND) { - this.config.rightYAxisSecondUnit !== "" && (unit = unit + this.config.rightYAxisSecondUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - }, - - populate: function (items, options, types) { - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - rightYAxisSecondTitle: options.rightYAxisSecondTitle || "", - chartColor: options.chartColor || ["#5caae4", "#70cc7f", "#ebbb67", "#e97e7b", "#6ed3c9"], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - rightYAxisSecondStyle: options.rightYAxisSecondStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - showRightYAxisSecondTitle: options.showRightYAxisSecondTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - rightYAxisSecondReversed: options.rightYAxisSecondReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - rightYAxisSecondNumberLevel: options.rightYAxisSecondNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - rightYAxisSecondUnit: options.rightYAxisSecondUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - this.yAxis = []; - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: {"fontFamily": "inherit", "color": "#808080", "fontSize": "12px", "fontWeight": ""} - }, - labelStyle: { - "fontFamily": "inherit", "color": "#808080", "fontSize": "12px" - }, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.MultiAxisChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.multi_axis_chart', BI.MultiAxisChart);/** - * 图表控件 - * @class BI.MultiAxisChart - * @extends BI.Widget - * leftYxis 左值轴属性 - * rightYxis 右值轴属性 - * xAxis 分类轴属性 - */ -BI.MultiAxisCombineChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.MultiAxisCombineChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-axis-combine-chart" - }) - }, - - _init: function () { - BI.MultiAxisCombineChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: {"fontFamily": "inherit", "color": "#808080", "fontSize": "12px", "fontWeight": ""} - }, - labelStyle: { - "fontFamily": "inherit", "color": "#808080", "fontSize": "12px" - }, - position: "bottom", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.MultiAxisCombineChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - config.colors = this.config.chartColor; - config.style = this.formatChartStyle(); - this.formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - BI.each(config.yAxis, function (idx, axis) { - var title = ""; - switch (axis.axisIndex) { - case self.constants.LEFT_AXIS: - title = self.getXYAxisUnit(self.config.leftYAxisNumberLevel, self.constants.LEFT_AXIS); - axis.title.text = self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - axis.labelStyle.color = axis.lineColor = axis.tickColor = config.colors[0]; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.leftYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.leftYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS: - title = self.getXYAxisUnit(self.config.rightYAxisNumberLevel, self.constants.RIGHT_AXIS); - axis.title.text = self.config.showRightYAxisTitle === true ? self.config.rightYAxisTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - axis.labelStyle.color = axis.lineColor = axis.tickColor = config.colors[1]; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisStyle, self.config.rightYAxisNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisNumberLevel, idx, axis.formatter); - break; - case self.constants.RIGHT_AXIS_SECOND: - title = self.getXYAxisUnit(self.config.rightYAxisSecondNumberLevel, self.constants.RIGHT_AXIS_SECOND); - axis.title.text = self.config.showRightYAxisSecondTitle === true ? self.config.rightYAxisSecondTitle + title : title; - axis.title.rotation = self.constants.ROTATION; - axis.labelStyle.color = axis.lineColor = axis.tickColor = config.colors[2]; - BI.extend(axis, { - lineWidth: self.config.lineWidth, - showLabel: self.config.showLabel, - enableTick: self.config.enableTick, - reversed: self.config.rightYAxisSecondReversed, - enableMinorTick: self.config.enableMinorTick, - gridLineWidth: self.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(self.config.rightYAxisSecondStyle, self.config.rightYAxisSecondNumberLevel, self.config.rightNumSeparators) - }); - self.formatNumberLevelInYaxis(config, items, self.config.rightYAxisSecondNumberLevel, idx, axis.formatter); - break; - default: - break; - } - }); - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabel(config.plotOptions.dataLabels.enabled, items, config, this.config.chartFont); - - //全局样式的图表文字 - if (config.dataSheet) { - config.dataSheet.style = this.config.chartFont; - } - config.xAxis[0].title.style = config.xAxis[0].labelStyle = this.config.chartFont; - config.legend.style = this.config.chartFont; - config.plotOptions.dataLabels.style = this.config.chartFont; - BI.each(config.yAxis, function (idx, axis) { - axis.title.style = self.config.chartFont; - }); - - return [items, config]; - }, - - formatChartStyle: function () { - switch (this.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - }, - - formatCordon: function () { - var self = this; - var magnify = 1; - BI.each(this.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": { - "fontFamily": "inherit", - "color": "#808080", - "fontSize": "12px", - "fontWeight": "" - }, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - default: - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": { - "fontFamily": "inherit", - "color": "#808080", - "fontSize": "12px", - "fontWeight": "" - }, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - }, - - getXYAxisUnit: function (numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - default: - break; - } - if (position === this.constants.X_AXIS) { - this.config.xAxisUnit !== "" && (unit = unit + this.config.xAxisUnit) - } - if (position === this.constants.LEFT_AXIS) { - this.config.leftYAxisUnit !== "" && (unit = unit + this.config.leftYAxisUnit) - } - if (position === this.constants.RIGHT_AXIS) { - this.config.rightYAxisUnit !== "" && (unit = unit + this.config.rightYAxisUnit) - } - if (position === this.constants.RIGHT_AXIS_SECOND) { - this.config.rightYAxisSecondUnit !== "" && (unit = unit + this.config.rightYAxisSecondUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - }, - - populate: function (items, options, types) { - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - rightYAxisTitle: options.rightYAxisTitle || "", - rightYAxisSecondTitle: options.rightYAxisSecondTitle || "", - chartColor: options.chartColor || ["#5caae4", "#70cc7f", "#ebbb67", "#e97e7b", "#6ed3c9"], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - rightYAxisStyle: options.rightYAxisStyle || c.NORMAL, - rightYAxisSecondStyle: options.rightYAxisSecondStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - showRightYAxisTitle: options.showRightYAxisTitle || false, - showRightYAxisSecondTitle: options.showRightYAxisSecondTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - rightYAxisReversed: options.rightYAxisReversed || false, - rightYAxisSecondReversed: options.rightYAxisSecondReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - rightYAxisNumberLevel: options.rightYAxisNumberLevel || c.NORMAL, - rightYAxisSecondNumberLevel: options.rightYAxisSecondNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - rightYAxisUnit: options.rightYAxisUnit || "", - rightYAxisSecondUnit: options.rightYAxisSecondUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - this.yAxis = []; - BI.each(types, function (idx, type) { - if (BI.isEmptyArray(type)) { - return; - } - var newYAxis = { - type: "value", - title: { - style: {"fontFamily": "inherit", "color": "#808080", "fontSize": "12px", "fontWeight": ""} - }, - labelStyle: { - "fontFamily": "inherit", "color": "#808080", "fontSize": "12px" - }, - position: idx > 0 ? "right" : "left", - lineWidth: 1, - axisIndex: idx, - gridLineWidth: 0 - }; - self.yAxis.push(newYAxis); - }); - - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.MultiAxisCombineChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.multi_axis_combine_chart', BI.MultiAxisCombineChart);/** - * 图表控件 - * @class BI.PercentAccumulateAreaChart - * @extends BI.Widget - */ -BI.PercentAccumulateAreaChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.PercentAccumulateAreaChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-percent-accumulate-area-chart" - }) - }, - - _init: function () { - BI.PercentAccumulateAreaChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "left", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.PercentAccumulateAreaChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - config.yAxis[0].title.text = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.yAxis[0].title.rotation = this.constants.ROTATION; - BI.extend(config.yAxis[0], { - lineWidth: this.config.lineWidth, - showLabel: this.config.showLabel, - enableTick: this.config.enableTick, - reversed: this.config.leftYAxisReversed, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS, config.yAxis[0].formatter, true); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "area"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.yAxis[0].formatter, this.config.chartFont, true); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - - unit = unit === "" ? unit : "(" + unit + ")"; - - return self.config.showLeftYAxisTitle === true ? self.config.leftYAxisTitle + unit : unit - } - }, - - _formatItems: function (items) { - return BI.map(items, function (idx, item) { - var i = BI.UUID(); - return BI.map(item, function (id, it) { - return BI.extend({}, it, {stack: i, stackByPercent: true}); - }); - }); - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.AREA); - }); - types.push(type); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.PercentAccumulateAreaChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.percent_accumulate_area_chart', BI.PercentAccumulateAreaChart);/** - * 图表控件 百分比堆积柱状 - * @class BI.PercentAccumulateAxisChart - * @extends BI.Widget - */ -BI.PercentAccumulateAxisChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.PercentAccumulateAxisChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-percent-accumulate-axis-chart" - }) - }, - - _init: function () { - BI.PercentAccumulateAxisChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "value", - title: { - style: self.constants.FONT_STYLE - }, - labelStyle: self.constants.FONT_STYLE, - position: "left", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.PercentAccumulateAxisChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this, o = this.options; - var yTitle = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.dataSheet.enabled = this.config.showDataTable; - config.xAxis[0].showLabel = !config.dataSheet.enabled; - config.zoom.zoomTool.enabled = this.config.showZoom; - if (this.config.showZoom === true) { - delete config.dataSheet; - delete config.zoom.zoomType; - } - - config.yAxis = this.yAxis; - config.yAxis[0].title.rotation = this.constants.ROTATION; - config.yAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + yTitle : yTitle; - BI.extend(config.yAxis[0], { - lineWidth: this.config.lineWidth, - showLabel: this.config.showLabel, - enableTick: this.config.enableTick, - reversed: this.config.leftYAxisReversed, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators) - }); - self.formatNumberLevelInYaxis(config, items, this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS, config.yAxis[0].formatter, true); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.yAxis[0].formatter, this.config.chartFont, true); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function (items) { - return BI.map(items, function (idx, item) { - var i = BI.UUID(); - return BI.map(item, function (id, it) { - return BI.extend({}, it, {stack: i, stackByPercent: true}); - }); - }); - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showDataTable: options.showDataTable || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - showZoom: options.showZoom || false, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.AXIS); - }); - types.push(type); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.PercentAccumulateAxisChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.percent_accumulate_axis_chart', BI.PercentAccumulateAxisChart);/** - * 图表控件 - * @class BI.PieChart - * @extends BI.Widget - */ -BI.PieChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.PieChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-pie-chart" - }) - }, - - _init: function () { - BI.PieChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.PieChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function(config, items){ - var self = this, o = this.options; - delete config.zoom; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartPieStyle(); - - this.formatChartLegend(config, this.config.chartLegend); - - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.tooltip.formatter.identifier = "${CATEGORY}${SERIES}${VALUE}${PERCENT}"; - - config.chartType = "pie"; - delete config.xAxis; - delete config.yAxis; - config.plotOptions.dataLabels.align = "outside"; - config.plotOptions.dataLabels.connectorWidth = "outside"; - config.plotOptions.dataLabels.formatter.identifier = "${VALUE}${PERCENT}"; - config.plotOptions.dataLabels.style = this.config.chartFont; - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - da.y = self.formatXYDataWithMagnify(da.y, 1); - }) - }); - - config.legend.style = this.config.chartFont; - - return [items, config]; - - function formatChartStyle(){ - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatChartPieStyle(){ - switch (self.config.chartPieType){ - case BICst.CHART_SHAPE.EQUAL_ARC_ROSE: - config.plotOptions.roseType = "sameArc"; - break; - case BICst.CHART_SHAPE.NOT_EQUAL_ARC_ROSE: - config.plotOptions.roseType = "differentArc"; - break; - case BICst.CHART_SHAPE.NORMAL: - default: - delete config.plotOptions.roseType; - break; - } - config.plotOptions.innerRadius = self.config.chartInnerRadius + "%"; - config.plotOptions.endAngle = self.config.chartTotalAngle; - } - - }, - - //目前饼图不会有多个系列,如果有多个就要把它们合并在一起 - _isNeedConvert: function(items){ - var result = BI.find(items, function(idx, item){ - return item.length > 1; - }); - return BI.isNotNull(result); - }, - - _formatItems: function(items){ - if(this._isNeedConvert(items)){ - //把每个坐标轴所有的多个系列合并成一个系列 - return BI.map(items, function(idx, item){ - var seriesItem = []; - var obj = {data: [], name: ""}; - seriesItem.push(obj); - BI.each(item, function(id, series){ - BI.each(series.data, function(i, da){ - obj.data.push(BI.extend({}, da, {x: series.name})); - }); - }); - return seriesItem; - }) - }else{ - return items; - } - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - chartPieType: options.chartPieType || c.NORMAL, - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - chartInnerRadius: options.chartInnerRadius || 0, - chartTotalAngle: options.chartTotalAngle || BICst.PIE_ANGLES.TOTAL, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - - var types = []; - BI.each(items, function(idx, axisItems){ - var type = []; - BI.each(axisItems, function(id, item){ - type.push(BICst.WIDGET.PIE); - }); - types.push(type); - }); - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function(){ - this.combineChart.magnify(); - } -}); -BI.PieChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.pie_chart', BI.PieChart); - -/** - * 图表控件 - * @class BI.RadarChart - * @extends BI.Widget - */ -BI.RadarChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.RadarChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-radar-chart" - }) - }, - - _init: function () { - BI.RadarChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.radiusAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - formatter: function () { - return this > 0 ? this : (-1) * this - }, - gridLineWidth: 0, - position: "bottom" - }]; - - this.angleAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE - }]; - - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.RadarChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - - delete config.zoom; - - var title = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatChartRadarStyle(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - - config.radiusAxis = this.radiusAxis; - config.angleAxis = this.angleAxis; - config.radiusAxis[0].formatter = self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators); - formatNumberLevelInYaxis(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS, config.radiusAxis[0].formatter); - config.radiusAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + title : title; - config.radiusAxis[0].gridLineWidth = this.config.showGridLine === true ? 1 : 0; - config.chartType = "radar"; - delete config.xAxis; - delete config.yAxis; - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.radiusAxis[0].formatter, this.config.chartFont); - - //全局样式 - config.legend.style = this.config.chartFont; - config.radiusAxis[0].title.style = config.radiusAxis[0].labelStyle = this.config.chartFont; - config.angleAxis[0].title.style = config.angleAxis[0].labelStyle = this.config.chartFont; - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatChartRadarStyle() { - switch (self.config.chartRadarType) { - case BICst.CHART_SHAPE.POLYGON: - config.plotOptions.shape = "polygon"; - break; - case BICst.CHART_SHAPE.CIRCLE: - config.plotOptions.shape = "circle"; - break; - } - } - - function formatNumberLevelInYaxis(type, position, formatter) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - } - }) - }); - config.plotOptions.tooltip.formatter.valueFormat = formatter; - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - chartRadarType: options.chartRadarType || c.POLYGON, - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.STYLE_NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - cordon: options.cordon || [], - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.RADAR); - }); - types.push(type); - }); - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.RadarChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.radar_chart', BI.RadarChart);/** - * 图表控件 - * @class BI.RangeAreaChart - * @extends BI.Widget - * 范围面积图的构造范围的两组item的必须有对应y值item1完全大于item2 - */ -BI.RangeAreaChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.RangeAreaChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-range-area-chart" - }) - }, - - _init: function () { - BI.RangeAreaChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "category", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "left", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.RangeAreaChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - _formatConfig: function (config, items) { - var self = this; - var title = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.connectNulls = this.config.nullContinue; - - config.yAxis = this.yAxis; - config.yAxis[0].title.rotation = this.constants.ROTATION; - config.yAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + title : title; - BI.extend(config.yAxis[0], { - lineWidth: this.config.lineWidth, - showLabel: this.config.showLabel, - enableTick: this.config.enableTick, - enableMinorTick: this.config.enableMinorTick, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - reversed: config.yAxis[0].reversed = this.config.leftYAxisReversed, - formatter: self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators) - }); - formatNumberLevelInYaxis(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS, config.yAxis[0].formatter); - - config.xAxis[0].title.align = "center"; - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle : ""; - BI.extend(config.xAxis[0], { - lineWidth: this.config.lineWidth, - enableTick: this.config.enableTick, - labelRotation: this.config.textDirection, - gridLineWidth: this.config.showGridLine === true ? 1 : 0, - maxHeight: '40%' - }); - - config.chartType = "area"; - config.plotOptions.tooltip.formatter.identifier = "${CATEGORY}${VALUE}"; - - //为了给数据标签加个%,还要遍历所有的系列,唉 - this.formatDataLabelForAxis(config.plotOptions.dataLabels.enabled, items, config.yAxis[0].formatter, this.config.chartFont); - - //全局样式的图表文字 - this.setFontStyle(this.config.chartFont, config); - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style" : self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatNumberLevelInYaxis(type, position, formatter) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - if (position === item.yAxis) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - } - }) - }); - config.plotOptions.tooltip.formatter.valueFormat = formatter; - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - _formatItems: function (data) { - var o = this.options; - var items = []; - BI.each(data, function (idx, item) { - items = BI.concat(items, item); - }); - if (BI.isEmptyArray(items)) { - return []; - } - if (items.length === 1) { - return [items]; - } - var colors = this.config.chartColor || []; - if (BI.isEmptyArray(colors)) { - colors = ["#5caae4"]; - } - var seriesMinus = []; - BI.each(items[0].data, function (idx, item) { - var res = items[1].data[idx].y - item.y; - seriesMinus.push({ - x: items[1].data[idx].x, - y: res, - targetIds: items[1].data[idx].targetIds - }); - }); - items[1] = { - data: seriesMinus, - name: items[1].name, - stack: "stackedArea", - fillColor: colors[0] - }; - BI.each(items, function (idx, item) { - if (idx === 0) { - BI.extend(item, { - name: items[0].name, - fillColorOpacity: 0, - stack: "stackedArea", - marker: {enabled: false}, - fillColor: "#000000" - }); - } - }); - return [items]; - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - chartStyle: options.chartStyle || c.NORMAL, - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - leftYAxisReversed: options.leftYAxisReversed || false, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - textDirection: options.textDirection || 0, - cordon: options.cordon || [], - lineWidth: BI.isNull(options.lineWidth) ? 1 : options.lineWidth, - showLabel: BI.isNull(options.showLabel) ? true : options.showLabel, - enableTick: BI.isNull(options.enableTick) ? true : options.enableTick, - enableMinorTick: BI.isNull(options.enableMinorTick) ? true : options.enableMinorTick, - numSeparators: options.numSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE, - nullContinue: options.nullContinue || false - }; - this.options.items = items; - - var types = []; - var type = []; - BI.each(items, function (idx, axisItems) { - type.push(BICst.WIDGET.AREA); - }); - if (BI.isNotEmptyArray(type)) { - types.push(type); - } - - this.combineChart.populate(this._formatItems(items), types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.RangeAreaChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.range_area_chart', BI.RangeAreaChart);/** - * 图表控件 - * @class BI.ScatterChart - * @extends BI.Widget - */ -BI.ScatterChart = BI.inherit(BI.AbstractChart, { - - _defaultConfig: function () { - return BI.extend(BI.ScatterChart.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-scatter-chart" - }) - }, - - _init: function () { - BI.ScatterChart.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.xAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "bottom", - gridLineWidth: 0 - }]; - this.yAxis = [{ - type: "value", - title: { - style: this.constants.FONT_STYLE - }, - labelStyle: this.constants.FONT_STYLE, - position: "left", - gridLineWidth: 0 - }]; - this.combineChart = BI.createWidget({ - type: "bi.combine_chart", - xAxis: this.xAxis, - popupItemsGetter: o.popupItemsGetter, - formatConfig: BI.bind(this._formatConfig, this), - element: this.element - }); - this.combineChart.on(BI.CombineChart.EVENT_CHANGE, function (obj) { - self.fireEvent(BI.ScatterChart.EVENT_CHANGE, obj); - }); - this.combineChart.on(BI.CombineChart.EVENT_ITEM_CLICK, function (obj) { - self.fireEvent(BI.AbstractChart.EVENT_ITEM_CLICK, obj) - }); - }, - - - _formatConfig: function (config, items) { - var self = this; - delete config.zoom; - config.colors = this.config.chartColor; - config.style = formatChartStyle(); - config.plotOptions.marker = {"symbol": "circle", "radius": 4.5, "enabled": true}; - formatCordon(); - this.formatChartLegend(config, this.config.chartLegend); - config.plotOptions.dataLabels.enabled = this.config.showDataLabel; - config.plotOptions.dataLabels.formatter.identifier = "${X}${Y}"; - - config.yAxis = this.yAxis; - config.xAxis = this.xAxis; - - config.yAxis[0].formatter = self.formatTickInXYaxis(this.config.leftYAxisStyle, this.config.leftYAxisNumberLevel, this.config.numSeparators); - formatNumberLevelInYaxis(this.config.leftYAxisNumberLevel); - config.yAxis[0].title.text = getXYAxisUnit(this.config.leftYAxisNumberLevel, this.constants.LEFT_AXIS); - config.yAxis[0].title.text = this.config.showLeftYAxisTitle === true ? this.config.leftYAxisTitle + config.yAxis[0].title.text : config.yAxis[0].title.text; - config.yAxis[0].gridLineWidth = this.config.showGridLine === true ? 1 : 0; - config.yAxis[0].title.rotation = this.constants.ROTATION; - config.yAxis[0].maxWidth = '40%'; - - config.xAxis[0].formatter = self.formatTickInXYaxis(this.config.xAxisStyle, this.config.xAxisNumberLevel, this.config.rightNumSeparators); - formatNumberLevelInXaxis(this.config.xAxisNumberLevel); - config.xAxis[0].title.text = getXYAxisUnit(this.config.xAxisNumberLevel, this.constants.X_AXIS); - config.xAxis[0].title.text = this.config.showXAxisTitle === true ? this.config.xAxisTitle + config.xAxis[0].title.text : config.xAxis[0].title.text; - config.xAxis[0].title.align = "center"; - config.xAxis[0].gridLineWidth = this.config.showGridLine === true ? 1 : 0; - config.xAxis[0].maxHeight = '40%'; - config.chartType = "scatter"; - - if (BI.isNotEmptyArray(this.config.tooltip)) { - config.plotOptions.tooltip.formatter = function () { - var y = self.formatTickInXYaxis(self.config.leftYAxisStyle, self.config.leftYAxisNumberLevel, self.config.numSeparators)(this.y); - var x = self.formatTickInXYaxis(self.config.xAxisStyle, self.config.xAxisNumberLevel, self.config.rightNumSeparators)(this.x); - return this.seriesName + '
(X)' + self.config.tooltip[0] - + ':' + x + '
(Y)' + self.config.tooltip[1] + ':' + y + '
' - }; - } - - if (config.plotOptions.dataLabels.enabled === true) { - BI.each(items, function (idx, item) { - item.dataLabels = { - "style": self.config.chartFont, - "align": "outside", - "autoAdjust": true, - enabled: true, - formatter: { - identifier: "${X}${Y}", - "XFormat": function () { - return BI.contentFormat(arguments[0], '#.##;-#.##') - }, - "YFormat": function () { - return BI.contentFormat(arguments[0], '#.##;-#.##') - } - } - }; - item.dataLabels.formatter.XFormat = config.xAxis[0].formatter; - item.dataLabels.formatter.YFormat = config.yAxis[0].formatter; - }); - } - - //全局样式图表文字 - config.legend.style = this.config.chartFont; - config.yAxis[0].title.style = config.yAxis[0].labelStyle = this.config.chartFont; - config.xAxis[0].title.style = config.xAxis[0].labelStyle = this.config.chartFont; - - return [items, config]; - - function formatChartStyle() { - switch (self.config.chartStyle) { - case BICst.CHART_STYLE.STYLE_GRADUAL: - return "gradual"; - case BICst.CHART_STYLE.STYLE_NORMAL: - default: - return "normal"; - } - } - - function formatCordon() { - BI.each(self.config.cordon, function (idx, cor) { - if (idx === 0 && self.xAxis.length > 0) { - var magnify = self.calcMagnify(self.config.xAxisNumberLevel); - self.xAxis[0].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "top" - } - }); - }); - } - if (idx > 0 && self.yAxis.length >= idx) { - var magnify = 1; - switch (idx - 1) { - case self.constants.LEFT_AXIS: - magnify = self.calcMagnify(self.config.leftYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS: - magnify = self.calcMagnify(self.config.rightYAxisNumberLevel); - break; - case self.constants.RIGHT_AXIS_SECOND: - magnify = self.calcMagnify(self.config.rightYAxisSecondNumberLevel); - break; - } - self.yAxis[idx - 1].plotLines = BI.map(cor, function (i, t) { - return BI.extend(t, { - value: t.value.div(magnify), - width: 1, - label: { - "style": self.config.chartFont, - "text": t.text, - "align": "left" - } - }); - }); - } - }) - } - - function formatNumberLevelInXaxis(type) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - da.x = self.formatXYDataWithMagnify(da.x, magnify); - }) - }) - } - - function formatNumberLevelInYaxis(type) { - var magnify = self.calcMagnify(type); - BI.each(items, function (idx, item) { - BI.each(item.data, function (id, da) { - da.y = self.formatXYDataWithMagnify(da.y, magnify); - }) - }); - } - - function getXYAxisUnit(numberLevelType, position) { - var unit = ""; - switch (numberLevelType) { - case BICst.TARGET_STYLE.NUM_LEVEL.NORMAL: - unit = ""; - break; - case BICst.TARGET_STYLE.NUM_LEVEL.TEN_THOUSAND: - unit = BI.i18nText("BI-Wan"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.MILLION: - unit = BI.i18nText("BI-Million"); - break; - case BICst.TARGET_STYLE.NUM_LEVEL.YI: - unit = BI.i18nText("BI-Yi"); - break; - } - if (position === self.constants.X_AXIS) { - self.config.xAxisUnit !== "" && (unit = unit + self.config.xAxisUnit) - } - if (position === self.constants.LEFT_AXIS) { - self.config.leftYAxisUnit !== "" && (unit = unit + self.config.leftYAxisUnit) - } - if (position === self.constants.RIGHT_AXIS) { - self.config.rightYAxisUnit !== "" && (unit = unit + self.config.rightYAxisUnit) - } - return unit === "" ? unit : "(" + unit + ")"; - } - }, - - populate: function (items, options) { - options || (options = {}); - var self = this, c = this.constants; - this.config = { - leftYAxisTitle: options.leftYAxisTitle || "", - chartColor: options.chartColor || [], - leftYAxisStyle: options.leftYAxisStyle || c.NORMAL, - xAxisStyle: options.xAxisStyle || c.NORMAL, - showXAxisTitle: options.showXAxisTitle || false, - showLeftYAxisTitle: options.showLeftYAxisTitle || false, - xAxisNumberLevel: options.xAxisNumberLevel || c.NORMAL, - leftYAxisNumberLevel: options.leftYAxisNumberLevel || c.NORMAL, - xAxisUnit: options.xAxisUnit || "", - leftYAxisUnit: options.leftYAxisUnit || "", - xAxisTitle: options.xAxisTitle || "", - chartLegend: options.chartLegend || c.LEGEND_BOTTOM, - showDataLabel: options.showDataLabel || false, - showGridLine: BI.isNull(options.showGridLine) ? true : options.showGridLine, - cordon: options.cordon || [], - tooltip: options.tooltip || [], - numSeparators: options.numSeparators || false, - rightNumSeparators: options.rightNumSeparators || false, - chartFont: options.chartFont || c.FONT_STYLE - }; - this.options.items = items; - var types = []; - BI.each(items, function (idx, axisItems) { - var type = []; - BI.each(axisItems, function (id, item) { - type.push(BICst.WIDGET.SCATTER); - }); - types.push(type); - }); - this.combineChart.populate(items, types); - }, - - resize: function () { - this.combineChart.resize(); - }, - - magnify: function () { - this.combineChart.magnify(); - } -}); -BI.ScatterChart.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut('bi.scatter_chart', BI.ScatterChart); \ No newline at end of file diff --git a/bi/core.js b/bi/core.js deleted file mode 100644 index 459c767c1..000000000 --- a/bi/core.js +++ /dev/null @@ -1,25908 +0,0 @@ -/*! - * jQuery JavaScript Library v1.9.1 - * http://jquery.com/ - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * - * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2013-2-4 - */ -(function( window, undefined ) { - -// Can't do this because several apps including ASP.NET trace -// the stack via arguments.caller.callee and Firefox dies if -// you try to trace through "use strict" call chains. (#13335) -// Support: Firefox 18+ -//"use strict"; -var - // The deferred used on DOM ready - readyList, - - // A central reference to the root jQuery(document) - rootjQuery, - - // Support: IE<9 - // For `typeof node.method` instead of `node.method !== undefined` - core_strundefined = typeof undefined, - - // Use the correct document accordingly with window argument (sandbox) - document = window.document, - location = window.location, - - // Map over jQuery in case of overwrite - _jQuery = window.jQuery, - - // Map over the $ in case of overwrite - _$ = window.$, - - // [[Class]] -> type pairs - class2type = {}, - - // List of deleted data cache ids, so we can reuse them - core_deletedIds = [], - - core_version = "1.9.1", - - // Save a reference to some core methods - core_concat = core_deletedIds.concat, - core_push = core_deletedIds.push, - core_slice = core_deletedIds.slice, - core_indexOf = core_deletedIds.indexOf, - core_toString = class2type.toString, - core_hasOwn = class2type.hasOwnProperty, - core_trim = core_version.trim, - - // Define a local copy of jQuery - jQuery = function( selector, context ) { - // The jQuery object is actually just the init constructor 'enhanced' - return new jQuery.fn.init( selector, context, rootjQuery ); - }, - - // Used for matching numbers - core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, - - // Used for splitting on whitespace - core_rnotwhite = /\S+/g, - - // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, - - // Match a standalone tag - rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, - - // JSON RegExp - rvalidchars = /^[\],:{}\s]*$/, - rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, - rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, - rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g, - - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([\da-z])/gi, - - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function( all, letter ) { - return letter.toUpperCase(); - }, - - // The ready event handler - completed = function( event ) { - - // readyState === "complete" is good enough for us to call the dom ready in oldIE - if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { - detach(); - jQuery.ready(); - } - }, - // Clean-up method for dom ready events - detach = function() { - if ( document.addEventListener ) { - document.removeEventListener( "DOMContentLoaded", completed, false ); - window.removeEventListener( "load", completed, false ); - - } else { - document.detachEvent( "onreadystatechange", completed ); - window.detachEvent( "onload", completed ); - } - }; - -jQuery.fn = jQuery.prototype = { - // The current version of jQuery being used - jquery: core_version, - - constructor: jQuery, - init: function( selector, context, rootjQuery ) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if ( !selector ) { - return this; - } - - // Handle HTML strings - if ( typeof selector === "string" ) { - if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [ null, selector, null ]; - - } else { - match = rquickExpr.exec( selector ); - } - - // Match html or make sure no context is specified for #id - if ( match && (match[1] || !context) ) { - - // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; - - // scripts is true for back-compat - jQuery.merge( this, jQuery.parseHTML( - match[1], - context && context.nodeType ? context.ownerDocument || context : document, - true - ) ); - - // HANDLE: $(html, props) - if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { - for ( match in context ) { - // Properties of context are called as methods if possible - if ( jQuery.isFunction( this[ match ] ) ) { - this[ match ]( context[ match ] ); - - // ...and otherwise set as attributes - } else { - this.attr( match, context[ match ] ); - } - } - } - - return this; - - // HANDLE: $(#id) - } else { - elem = document.getElementById( match[2] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id !== match[2] ) { - return rootjQuery.find( selector ); - } - - // Otherwise, we inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - return this; - } - - // HANDLE: $(expr, $(...)) - } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } else { - return this.constructor( context ).find( selector ); - } - - // HANDLE: $(DOMElement) - } else if ( selector.nodeType ) { - this.context = this[0] = selector; - this.length = 1; - return this; - - // HANDLE: $(function) - // Shortcut for document ready - } else if ( jQuery.isFunction( selector ) ) { - return rootjQuery.ready( selector ); - } - - if ( selector.selector !== undefined ) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray( selector, this ); - }, - - // Start with an empty selector - selector: "", - - // The default length of a jQuery object is 0 - length: 0, - - // The number of elements contained in the matched element set - size: function() { - return this.length; - }, - - toArray: function() { - return core_slice.call( this ); - }, - - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function( num ) { - return num == null ? - - // Return a 'clean' array - this.toArray() : - - // Return just the object - ( num < 0 ? this[ this.length + num ] : this[ num ] ); - }, - - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function( elems ) { - - // Build a new jQuery matched element set - var ret = jQuery.merge( this.constructor(), elems ); - - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - ret.context = this.context; - - // Return the newly-formed element set - return ret; - }, - - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function( callback, args ) { - return jQuery.each( this, callback, args ); - }, - - ready: function( fn ) { - // Add the callback - jQuery.ready.promise().done( fn ); - - return this; - }, - - slice: function() { - return this.pushStack( core_slice.apply( this, arguments ) ); - }, - - first: function() { - return this.eq( 0 ); - }, - - last: function() { - return this.eq( -1 ); - }, - - eq: function( i ) { - var len = this.length, - j = +i + ( i < 0 ? len : 0 ); - return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); - }, - - map: function( callback ) { - return this.pushStack( jQuery.map(this, function( elem, i ) { - return callback.call( elem, i, elem ); - })); - }, - - end: function() { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: core_push, - sort: [].sort, - splice: [].splice -}; - -// Give the init function the jQuery prototype for later instantiation -jQuery.fn.init.prototype = jQuery.fn; - -jQuery.extend = jQuery.fn.extend = function() { - var src, copyIsArray, copy, name, options, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if ( typeof target === "boolean" ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target !== "object" && !jQuery.isFunction(target) ) { - target = {}; - } - - // extend jQuery itself if only one argument is passed - if ( length === i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) { - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { - // Extend the base object - for ( name in options ) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) { - continue; - } - - // Recurse if we're merging plain objects or arrays - if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { - if ( copyIsArray ) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; - - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[ name ] = jQuery.extend( deep, clone, copy ); - - // Don't bring in undefined values - } else if ( copy !== undefined ) { - target[ name ] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -jQuery.extend({ - noConflict: function( deep ) { - if ( window.$ === jQuery ) { - window.$ = _$; - } - - if ( deep && window.jQuery === jQuery ) { - window.jQuery = _jQuery; - } - - return jQuery; - }, - - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function( hold ) { - if ( hold ) { - jQuery.readyWait++; - } else { - jQuery.ready( true ); - } - }, - - // Handle when the DOM is ready - ready: function( wait ) { - - // Abort if there are pending holds or we're already ready - if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { - return; - } - - // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). - if ( !document.body ) { - return setTimeout( jQuery.ready ); - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if ( wait !== true && --jQuery.readyWait > 0 ) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith( document, [ jQuery ] ); - - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger("ready").off("ready"); - } - }, - - // See test/unit/core.js for details concerning isFunction. - // Since version 1.3, DOM methods and functions like alert - // aren't supported. They return false on IE (#2968). - isFunction: function( obj ) { - return jQuery.type(obj) === "function"; - }, - - isArray: Array.isArray || function( obj ) { - return jQuery.type(obj) === "array"; - }, - - isWindow: function( obj ) { - return obj != null && obj == obj.window; - }, - - isNumeric: function( obj ) { - return !isNaN( parseFloat(obj) ) && isFinite( obj ); - }, - - type: function( obj ) { - if ( obj == null ) { - return String( obj ); - } - return typeof obj === "object" || typeof obj === "function" ? - class2type[ core_toString.call(obj) ] || "object" : - typeof obj; - }, - - isPlainObject: function( obj ) { - // Must be an Object. - // Because of IE, we also have to check the presence of the constructor property. - // Make sure that DOM nodes and window objects don't pass through, as well - if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { - return false; - } - - try { - // Not own constructor property must be Object - if ( obj.constructor && - !core_hasOwn.call(obj, "constructor") && - !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { - return false; - } - } catch ( e ) { - // IE8,9 Will throw exceptions on certain host objects #9897 - return false; - } - - // Own properties are enumerated firstly, so to speed up, - // if last one is own, then all properties are own. - - var key; - for ( key in obj ) {} - - return key === undefined || core_hasOwn.call( obj, key ); - }, - - isEmptyObject: function( obj ) { - var name; - for ( name in obj ) { - return false; - } - return true; - }, - - error: function( msg ) { - throw new Error( msg ); - }, - - // data: string of html - // context (optional): If specified, the fragment will be created in this context, defaults to document - // keepScripts (optional): If true, will include scripts passed in the html string - parseHTML: function( data, context, keepScripts ) { - if ( !data || typeof data !== "string" ) { - return null; - } - if ( typeof context === "boolean" ) { - keepScripts = context; - context = false; - } - context = context || document; - - var parsed = rsingleTag.exec( data ), - scripts = !keepScripts && []; - - // Single tag - if ( parsed ) { - return [ context.createElement( parsed[1] ) ]; - } - - parsed = jQuery.buildFragment( [ data ], context, scripts ); - if ( scripts ) { - jQuery( scripts ).remove(); - } - return jQuery.merge( [], parsed.childNodes ); - }, - - parseJSON: function( data ) { - // Attempt to parse using the native JSON parser first - if ( window.JSON && window.JSON.parse ) { - return window.JSON.parse( data ); - } - - if ( data === null ) { - return data; - } - - if ( typeof data === "string" ) { - - // Make sure leading/trailing whitespace is removed (IE can't handle it) - data = jQuery.trim( data ); - - if ( data ) { - // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js - if ( rvalidchars.test( data.replace( rvalidescape, "@" ) - .replace( rvalidtokens, "]" ) - .replace( rvalidbraces, "")) ) { - - return ( new Function( "return " + data ) )(); - } - } - } - - jQuery.error( "Invalid JSON: " + data ); - }, - - // Cross-browser xml parsing - parseXML: function( data ) { - var xml, tmp; - if ( !data || typeof data !== "string" ) { - return null; - } - try { - if ( window.DOMParser ) { // Standard - tmp = new DOMParser(); - xml = tmp.parseFromString( data , "text/xml" ); - } else { // IE - xml = new ActiveXObject( "Microsoft.XMLDOM" ); - xml.async = "false"; - xml.loadXML( data ); - } - } catch( e ) { - xml = undefined; - } - if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { - jQuery.error( "Invalid XML: " + data ); - } - return xml; - }, - - noop: function() {}, - - // Evaluates a script in a global context - // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context - globalEval: function( data ) { - if ( data && jQuery.trim( data ) ) { - // We use execScript on Internet Explorer - // We use an anonymous function so that context is window - // rather than jQuery in Firefox - ( window.execScript || function( data ) { - window[ "eval" ].call( window, data ); - } )( data ); - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function( string ) { - return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); - }, - - nodeName: function( elem, name ) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - - // args is for internal usage only - each: function( obj, callback, args ) { - var value, - i = 0, - length = obj.length, - isArray = isArraylike( obj ); - - if ( args ) { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.apply( obj[ i ], args ); - - if ( value === false ) { - break; - } - } - } - - // A special, fast, case for the most common use of each - } else { - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } else { - for ( i in obj ) { - value = callback.call( obj[ i ], i, obj[ i ] ); - - if ( value === false ) { - break; - } - } - } - } - - return obj; - }, - - // Use native String.trim function wherever possible - trim: core_trim && !core_trim.call("\uFEFF\xA0") ? - function( text ) { - return text == null ? - "" : - core_trim.call( text ); - } : - - // Otherwise use our own trimming functionality - function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, - - // results is for internal usage only - makeArray: function( arr, results ) { - var ret = results || []; - - if ( arr != null ) { - if ( isArraylike( Object(arr) ) ) { - jQuery.merge( ret, - typeof arr === "string" ? - [ arr ] : arr - ); - } else { - core_push.call( ret, arr ); - } - } - - return ret; - }, - - inArray: function( elem, arr, i ) { - var len; - - if ( arr ) { - if ( core_indexOf ) { - return core_indexOf.call( arr, elem, i ); - } - - len = arr.length; - i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; - - for ( ; i < len; i++ ) { - // Skip accessing in sparse arrays - if ( i in arr && arr[ i ] === elem ) { - return i; - } - } - } - - return -1; - }, - - merge: function( first, second ) { - var l = second.length, - i = first.length, - j = 0; - - if ( typeof l === "number" ) { - for ( ; j < l; j++ ) { - first[ i++ ] = second[ j ]; - } - } else { - while ( second[j] !== undefined ) { - first[ i++ ] = second[ j++ ]; - } - } - - first.length = i; - - return first; - }, - - grep: function( elems, callback, inv ) { - var retVal, - ret = [], - i = 0, - length = elems.length; - inv = !!inv; - - // Go through the array, only saving the items - // that pass the validator function - for ( ; i < length; i++ ) { - retVal = !!callback( elems[ i ], i ); - if ( inv !== retVal ) { - ret.push( elems[ i ] ); - } - } - - return ret; - }, - - // arg is for internal usage only - map: function( elems, callback, arg ) { - var value, - i = 0, - length = elems.length, - isArray = isArraylike( elems ), - ret = []; - - // Go through the array, translating each of the items to their - if ( isArray ) { - for ( ; i < length; i++ ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - - // Go through every key on the object, - } else { - for ( i in elems ) { - value = callback( elems[ i ], i, arg ); - - if ( value != null ) { - ret[ ret.length ] = value; - } - } - } - - // Flatten any nested arrays - return core_concat.apply( [], ret ); - }, - - // A global GUID counter for objects - guid: 1, - - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function( fn, context ) { - var args, proxy, tmp; - - if ( typeof context === "string" ) { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } - - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if ( !jQuery.isFunction( fn ) ) { - return undefined; - } - - // Simulated bind - args = core_slice.call( arguments, 2 ); - proxy = function() { - return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) ); - }; - - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; - - return proxy; - }, - - // Multifunctional method to get and set values of a collection - // The value/s can optionally be executed if it's a function - access: function( elems, fn, key, value, chainable, emptyGet, raw ) { - var i = 0, - length = elems.length, - bulk = key == null; - - // Sets many values - if ( jQuery.type( key ) === "object" ) { - chainable = true; - for ( i in key ) { - jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); - } - - // Sets one value - } else if ( value !== undefined ) { - chainable = true; - - if ( !jQuery.isFunction( value ) ) { - raw = true; - } - - if ( bulk ) { - // Bulk operations run against the entire set - if ( raw ) { - fn.call( elems, value ); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function( elem, key, value ) { - return bulk.call( jQuery( elem ), value ); - }; - } - } - - if ( fn ) { - for ( ; i < length; i++ ) { - fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); - } - } - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call( elems ) : - length ? fn( elems[0], key ) : emptyGet; - }, - - now: function() { - return ( new Date() ).getTime(); - } -}); - -jQuery.ready.promise = function( obj ) { - if ( !readyList ) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // we once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { - // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout( jQuery.ready ); - - // Standards-based browsers support DOMContentLoaded - } else if ( document.addEventListener ) { - // Use the handy event callback - document.addEventListener( "DOMContentLoaded", completed, false ); - - // A fallback to window.onload, that will always work - window.addEventListener( "load", completed, false ); - - // If IE event model is used - } else { - // Ensure firing before onload, maybe late but safe also for iframes - document.attachEvent( "onreadystatechange", completed ); - - // A fallback to window.onload, that will always work - window.attachEvent( "onload", completed ); - - // If IE and not a frame - // continually check to see if the document is ready - var top = false; - - try { - top = window.frameElement == null && document.documentElement; - } catch(e) {} - - if ( top && top.doScroll ) { - (function doScrollCheck() { - if ( !jQuery.isReady ) { - - try { - // Use the trick by Diego Perini - // http://javascript.nwbox.com/IEContentLoaded/ - top.doScroll("left"); - } catch(e) { - return setTimeout( doScrollCheck, 50 ); - } - - // detach all dom ready events - detach(); - - // and execute any waiting functions - jQuery.ready(); - } - })(); - } - } - } - return readyList.promise( obj ); -}; - -// Populate the class2type map -jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { - class2type[ "[object " + name + "]" ] = name.toLowerCase(); -}); - -function isArraylike( obj ) { - var length = obj.length, - type = jQuery.type( obj ); - - if ( jQuery.isWindow( obj ) ) { - return false; - } - - if ( obj.nodeType === 1 && length ) { - return true; - } - - return type === "array" || type !== "function" && - ( length === 0 || - typeof length === "number" && length > 0 && ( length - 1 ) in obj ); -} - -// All jQuery objects should point back to these -rootjQuery = jQuery(document); -// String to Object options format cache -var optionsCache = {}; - -// Convert String-formatted options into Object-formatted ones and store in cache -function createOptions( options ) { - var object = optionsCache[ options ] = {}; - jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) { - object[ flag ] = true; - }); - return object; -} - -/* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ -jQuery.Callbacks = function( options ) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === "string" ? - ( optionsCache[ options ] || createOptions( options ) ) : - jQuery.extend( {}, options ); - - var // Flag to know if list is currently firing - firing, - // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list was already fired - fired, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // First callback to fire (used internally by add and fireWith) - firingStart, - // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = !options.once && [], - // Fire callbacks - fire = function( data ) { - memory = options.memory && data; - fired = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - firing = true; - for ( ; list && firingIndex < firingLength; firingIndex++ ) { - if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { - memory = false; // To prevent further calls using add - break; - } - } - firing = false; - if ( list ) { - if ( stack ) { - if ( stack.length ) { - fire( stack.shift() ); - } - } else if ( memory ) { - list = []; - } else { - self.disable(); - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function() { - if ( list ) { - // First, we save the current length - var start = list.length; - (function add( args ) { - jQuery.each( args, function( _, arg ) { - var type = jQuery.type( arg ); - if ( type === "function" ) { - if ( !options.unique || !self.has( arg ) ) { - list.push( arg ); - } - } else if ( arg && arg.length && type !== "string" ) { - // Inspect recursively - add( arg ); - } - }); - })( arguments ); - // Do we need to add the callbacks to the - // current firing batch? - if ( firing ) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away - } else if ( memory ) { - firingStart = start; - fire( memory ); - } - } - return this; - }, - // Remove a callback from the list - remove: function() { - if ( list ) { - jQuery.each( arguments, function( _, arg ) { - var index; - while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { - list.splice( index, 1 ); - // Handle firing indexes - if ( firing ) { - if ( index <= firingLength ) { - firingLength--; - } - if ( index <= firingIndex ) { - firingIndex--; - } - } - } - }); - } - return this; - }, - // Check if a given callback is in the list. - // If no argument is given, return whether or not list has callbacks attached. - has: function( fn ) { - return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); - }, - // Remove all callbacks from the list - empty: function() { - list = []; - return this; - }, - // Have the list do nothing anymore - disable: function() { - list = stack = memory = undefined; - return this; - }, - // Is it disabled? - disabled: function() { - return !list; - }, - // Lock the list in its current state - lock: function() { - stack = undefined; - if ( !memory ) { - self.disable(); - } - return this; - }, - // Is it locked? - locked: function() { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function( context, args ) { - args = args || []; - args = [ context, args.slice ? args.slice() : args ]; - if ( list && ( !fired || stack ) ) { - if ( firing ) { - stack.push( args ); - } else { - fire( args ); - } - } - return this; - }, - // Call all the callbacks with the given arguments - fire: function() { - self.fireWith( this, arguments ); - return this; - }, - // To know if the callbacks have already been called at least once - fired: function() { - return !!fired; - } - }; - - return self; -}; -jQuery.extend({ - - Deferred: function( func ) { - var tuples = [ - // action, add listener, listener list, final state - [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], - [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], - [ "notify", "progress", jQuery.Callbacks("memory") ] - ], - state = "pending", - promise = { - state: function() { - return state; - }, - always: function() { - deferred.done( arguments ).fail( arguments ); - return this; - }, - then: function( /* fnDone, fnFail, fnProgress */ ) { - var fns = arguments; - return jQuery.Deferred(function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { - var action = tuple[ 0 ], - fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; - // deferred[ done | fail | progress ] for forwarding actions to newDefer - deferred[ tuple[1] ](function() { - var returned = fn && fn.apply( this, arguments ); - if ( returned && jQuery.isFunction( returned.promise ) ) { - returned.promise() - .done( newDefer.resolve ) - .fail( newDefer.reject ) - .progress( newDefer.notify ); - } else { - newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); - } - }); - }); - fns = null; - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function( obj ) { - return obj != null ? jQuery.extend( obj, promise ) : promise; - } - }, - deferred = {}; - - // Keep pipe for back-compat - promise.pipe = promise.then; - - // Add list-specific methods - jQuery.each( tuples, function( i, tuple ) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; - - // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; - - // Handle state - if ( stateString ) { - list.add(function() { - // state = [ resolved | rejected ] - state = stateString; - - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); - } - - // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function() { - deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); - return this; - }; - deferred[ tuple[0] + "With" ] = list.fireWith; - }); - - // Make the deferred a promise - promise.promise( deferred ); - - // Call given func if any - if ( func ) { - func.call( deferred, deferred ); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function( subordinate /* , ..., subordinateN */ ) { - var i = 0, - resolveValues = core_slice.call( arguments ), - length = resolveValues.length, - - // the count of uncompleted subordinates - remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, - - // the master Deferred. If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), - - // Update function for both resolve and progress values - updateFunc = function( i, contexts, values ) { - return function( value ) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; - if( values === progressValues ) { - deferred.notifyWith( contexts, values ); - } else if ( !( --remaining ) ) { - deferred.resolveWith( contexts, values ); - } - }; - }, - - progressValues, progressContexts, resolveContexts; - - // add listeners to Deferred subordinates; treat others as resolved - if ( length > 1 ) { - progressValues = new Array( length ); - progressContexts = new Array( length ); - resolveContexts = new Array( length ); - for ( ; i < length; i++ ) { - if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { - resolveValues[ i ].promise() - .done( updateFunc( i, resolveContexts, resolveValues ) ) - .fail( deferred.reject ) - .progress( updateFunc( i, progressContexts, progressValues ) ); - } else { - --remaining; - } - } - } - - // if we're not waiting on anything, resolve the master - if ( !remaining ) { - deferred.resolveWith( resolveContexts, resolveValues ); - } - - return deferred.promise(); - } -}); -jQuery.support = (function() { - - var support, all, a, - input, select, fragment, - opt, eventName, isSupported, i, - div = document.createElement("div"); - - // Setup - div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; - - // Support tests won't run in some limited or non-browser environments - all = div.getElementsByTagName("*"); - a = div.getElementsByTagName("a")[ 0 ]; - if ( !all || !a || !all.length ) { - return {}; - } - - // First batch of tests - select = document.createElement("select"); - opt = select.appendChild( document.createElement("option") ); - input = div.getElementsByTagName("input")[ 0 ]; - - a.style.cssText = "top:1px;float:left;opacity:.5"; - support = { - // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) - getSetAttribute: div.className !== "t", - - // IE strips leading whitespace when .innerHTML is used - leadingWhitespace: div.firstChild.nodeType === 3, - - // Make sure that tbody elements aren't automatically inserted - // IE will insert them into empty tables - tbody: !div.getElementsByTagName("tbody").length, - - // Make sure that link elements get serialized correctly by innerHTML - // This requires a wrapper element in IE - htmlSerialize: !!div.getElementsByTagName("link").length, - - // Get the style information from getAttribute - // (IE uses .cssText instead) - style: /top/.test( a.getAttribute("style") ), - - // Make sure that URLs aren't manipulated - // (IE normalizes it by default) - hrefNormalized: a.getAttribute("href") === "/a", - - // Make sure that element opacity exists - // (IE uses filter instead) - // Use a regex to work around a WebKit issue. See #5145 - opacity: /^0.5/.test( a.style.opacity ), - - // Verify style float existence - // (IE uses styleFloat instead of cssFloat) - cssFloat: !!a.style.cssFloat, - - // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) - checkOn: !!input.value, - - // Make sure that a selected-by-default option has a working selected property. - // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) - optSelected: opt.selected, - - // Tests for enctype support on a form (#6743) - enctype: !!document.createElement("form").enctype, - - // Makes sure cloning an html5 element does not cause problems - // Where outerHTML is undefined, this still works - html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", - - // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode - boxModel: document.compatMode === "CSS1Compat", - - // Will be defined later - deleteExpando: true, - noCloneEvent: true, - inlineBlockNeedsLayout: false, - shrinkWrapBlocks: false, - reliableMarginRight: true, - boxSizingReliable: true, - pixelPosition: false - }; - - // Make sure checked status is properly cloned - input.checked = true; - support.noCloneChecked = input.cloneNode( true ).checked; - - // Make sure that the options inside disabled selects aren't marked as disabled - // (WebKit marks them as disabled) - select.disabled = true; - support.optDisabled = !opt.disabled; - - // Support: IE<9 - try { - delete div.test; - } catch( e ) { - support.deleteExpando = false; - } - - // Check if we can trust getAttribute("value") - input = document.createElement("input"); - input.setAttribute( "value", "" ); - support.input = input.getAttribute( "value" ) === ""; - - // Check if an input maintains its value after becoming a radio - input.value = "t"; - input.setAttribute( "type", "radio" ); - support.radioValue = input.value === "t"; - - // #11217 - WebKit loses check when the name is after the checked attribute - input.setAttribute( "checked", "t" ); - input.setAttribute( "name", "t" ); - - fragment = document.createDocumentFragment(); - fragment.appendChild( input ); - - // Check if a disconnected checkbox will retain its checked - // value of true after appended to the DOM (IE6/7) - support.appendChecked = input.checked; - - // WebKit doesn't clone checked state correctly in fragments - support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Support: IE<9 - // Opera does not clone events (and typeof div.attachEvent === undefined). - // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() - if ( div.attachEvent ) { - div.attachEvent( "onclick", function() { - support.noCloneEvent = false; - }); - - div.cloneNode( true ).click(); - } - - // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event) - // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php - for ( i in { submit: true, change: true, focusin: true }) { - div.setAttribute( eventName = "on" + i, "t" ); - - support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false; - } - - div.style.backgroundClip = "content-box"; - div.cloneNode( true ).style.backgroundClip = ""; - support.clearCloneStyle = div.style.backgroundClip === "content-box"; - - // Run tests that need a body at doc ready - jQuery(function() { - var container, marginDiv, tds, - divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", - body = document.getElementsByTagName("body")[0]; - - if ( !body ) { - // Return for frameset docs that don't have a body - return; - } - - container = document.createElement("div"); - container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"; - - body.appendChild( container ).appendChild( div ); - - // Support: IE8 - // Check if table cells still have offsetWidth/Height when they are set - // to display:none and there are still other visible table cells in a - // table row; if so, offsetWidth/Height are not reliable for use when - // determining if an element has been hidden directly using - // display:none (it is still safe to use offsets if a parent element is - // hidden; don safety goggles and see bug #4512 for more information). - div.innerHTML = "
t
"; - tds = div.getElementsByTagName("td"); - tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; - isSupported = ( tds[ 0 ].offsetHeight === 0 ); - - tds[ 0 ].style.display = ""; - tds[ 1 ].style.display = "none"; - - // Support: IE8 - // Check if empty table cells still have offsetWidth/Height - support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); - - // Check box-sizing and margin behavior - div.innerHTML = ""; - div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; - support.boxSizing = ( div.offsetWidth === 4 ); - support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); - - // Use window.getComputedStyle because jsdom on node.js will break without it. - if ( window.getComputedStyle ) { - support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; - support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; - - // Check if div with explicit width and no margin-right incorrectly - // gets computed margin-right based on width of container. (#3333) - // Fails in WebKit before Feb 2011 nightlies - // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right - marginDiv = div.appendChild( document.createElement("div") ); - marginDiv.style.cssText = div.style.cssText = divReset; - marginDiv.style.marginRight = marginDiv.style.width = "0"; - div.style.width = "1px"; - - support.reliableMarginRight = - !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); - } - - if ( typeof div.style.zoom !== core_strundefined ) { - // Support: IE<8 - // Check if natively block-level elements act like inline-block - // elements when setting their display to 'inline' and giving - // them layout - div.innerHTML = ""; - div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; - support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); - - // Support: IE6 - // Check if elements with layout shrink-wrap their children - div.style.display = "block"; - div.innerHTML = "
"; - div.firstChild.style.width = "5px"; - support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); - - if ( support.inlineBlockNeedsLayout ) { - // Prevent IE 6 from affecting layout for positioned elements #11048 - // Prevent IE from shrinking the body in IE 7 mode #12869 - // Support: IE<8 - body.style.zoom = 1; - } - } - - body.removeChild( container ); - - // Null elements to avoid leaks in IE - container = div = tds = marginDiv = null; - }); - - // Null elements to avoid leaks in IE - all = select = fragment = opt = a = input = null; - - return support; -})(); - -var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, - rmultiDash = /([A-Z])/g; - -function internalData( elem, name, data, pvt /* Internal Use Only */ ){ - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var thisCache, ret, - internalKey = jQuery.expando, - getByName = typeof name === "string", - - // We have to handle DOM nodes and JS objects differently because IE6-7 - // can't GC object references properly across the DOM-JS boundary - isNode = elem.nodeType, - - // Only DOM nodes need the global jQuery cache; JS object data is - // attached directly to the object so GC can occur automatically - cache = isNode ? jQuery.cache : elem, - - // Only defining an ID for JS objects if its cache already exists allows - // the code to shortcut on the same path as a DOM node with no cache - id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; - - // Avoid doing any more work than we need to when trying to get data on an - // object that has no data at all - if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { - return; - } - - if ( !id ) { - // Only DOM nodes need a new unique ID for each element since their data - // ends up in the global cache - if ( isNode ) { - elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++; - } else { - id = internalKey; - } - } - - if ( !cache[ id ] ) { - cache[ id ] = {}; - - // Avoids exposing jQuery metadata on plain JS objects when the object - // is serialized using JSON.stringify - if ( !isNode ) { - cache[ id ].toJSON = jQuery.noop; - } - } - - // An object can be passed to jQuery.data instead of a key/value pair; this gets - // shallow copied over onto the existing cache - if ( typeof name === "object" || typeof name === "function" ) { - if ( pvt ) { - cache[ id ] = jQuery.extend( cache[ id ], name ); - } else { - cache[ id ].data = jQuery.extend( cache[ id ].data, name ); - } - } - - thisCache = cache[ id ]; - - // jQuery data() is stored in a separate object inside the object's internal data - // cache in order to avoid key collisions between internal data and user-defined - // data. - if ( !pvt ) { - if ( !thisCache.data ) { - thisCache.data = {}; - } - - thisCache = thisCache.data; - } - - if ( data !== undefined ) { - thisCache[ jQuery.camelCase( name ) ] = data; - } - - // Check for both converted-to-camel and non-converted data property names - // If a data property was specified - if ( getByName ) { - - // First Try to find as-is property data - ret = thisCache[ name ]; - - // Test for null|undefined property data - if ( ret == null ) { - - // Try to find the camelCased property - ret = thisCache[ jQuery.camelCase( name ) ]; - } - } else { - ret = thisCache; - } - - return ret; -} - -function internalRemoveData( elem, name, pvt ) { - if ( !jQuery.acceptData( elem ) ) { - return; - } - - var i, l, thisCache, - isNode = elem.nodeType, - - // See jQuery.data for more information - cache = isNode ? jQuery.cache : elem, - id = isNode ? elem[ jQuery.expando ] : jQuery.expando; - - // If there is already no cache entry for this object, there is no - // purpose in continuing - if ( !cache[ id ] ) { - return; - } - - if ( name ) { - - thisCache = pvt ? cache[ id ] : cache[ id ].data; - - if ( thisCache ) { - - // Support array or space separated string names for data keys - if ( !jQuery.isArray( name ) ) { - - // try the string as a key before any manipulation - if ( name in thisCache ) { - name = [ name ]; - } else { - - // split the camel cased version by spaces unless a key with the spaces exists - name = jQuery.camelCase( name ); - if ( name in thisCache ) { - name = [ name ]; - } else { - name = name.split(" "); - } - } - } else { - // If "name" is an array of keys... - // When data is initially created, via ("key", "val") signature, - // keys will be converted to camelCase. - // Since there is no way to tell _how_ a key was added, remove - // both plain key and camelCase key. #12786 - // This will only penalize the array argument path. - name = name.concat( jQuery.map( name, jQuery.camelCase ) ); - } - - for ( i = 0, l = name.length; i < l; i++ ) { - delete thisCache[ name[i] ]; - } - - // If there is no data left in the cache, we want to continue - // and let the cache object itself get destroyed - if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { - return; - } - } - } - - // See jQuery.data for more information - if ( !pvt ) { - delete cache[ id ].data; - - // Don't destroy the parent cache unless the internal data object - // had been the only thing left in it - if ( !isEmptyDataObject( cache[ id ] ) ) { - return; - } - } - - // Destroy the cache - if ( isNode ) { - jQuery.cleanData( [ elem ], true ); - - // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) - } else if ( jQuery.support.deleteExpando || cache != cache.window ) { - delete cache[ id ]; - - // When all else fails, null - } else { - cache[ id ] = null; - } -} - -jQuery.extend({ - cache: {}, - - // Unique for each copy of jQuery on the page - // Non-digits removed to match rinlinejQuery - expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ), - - // The following elements throw uncatchable exceptions if you - // attempt to add expando properties to them. - noData: { - "embed": true, - // Ban all objects except for Flash (which handle expandos) - "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", - "applet": true - }, - - hasData: function( elem ) { - elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; - return !!elem && !isEmptyDataObject( elem ); - }, - - data: function( elem, name, data ) { - return internalData( elem, name, data ); - }, - - removeData: function( elem, name ) { - return internalRemoveData( elem, name ); - }, - - // For internal use only. - _data: function( elem, name, data ) { - return internalData( elem, name, data, true ); - }, - - _removeData: function( elem, name ) { - return internalRemoveData( elem, name, true ); - }, - - // A method for determining if a DOM node can handle the data expando - acceptData: function( elem ) { - // Do not set data on non-element because it will not be cleared (#8335). - if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) { - return false; - } - - var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; - - // nodes accept data unless otherwise specified; rejection can be conditional - return !noData || noData !== true && elem.getAttribute("classid") === noData; - } -}); - -jQuery.fn.extend({ - data: function( key, value ) { - var attrs, name, - elem = this[0], - i = 0, - data = null; - - // Gets all values - if ( key === undefined ) { - if ( this.length ) { - data = jQuery.data( elem ); - - if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { - attrs = elem.attributes; - for ( ; i < attrs.length; i++ ) { - name = attrs[i].name; - - if ( !name.indexOf( "data-" ) ) { - name = jQuery.camelCase( name.slice(5) ); - - dataAttr( elem, name, data[ name ] ); - } - } - jQuery._data( elem, "parsedAttrs", true ); - } - } - - return data; - } - - // Sets multiple values - if ( typeof key === "object" ) { - return this.each(function() { - jQuery.data( this, key ); - }); - } - - return jQuery.access( this, function( value ) { - - if ( value === undefined ) { - // Try to fetch any internally stored data first - return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null; - } - - this.each(function() { - jQuery.data( this, key, value ); - }); - }, null, value, arguments.length > 1, null, true ); - }, - - removeData: function( key ) { - return this.each(function() { - jQuery.removeData( this, key ); - }); - } -}); - -function dataAttr( elem, key, data ) { - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if ( data === undefined && elem.nodeType === 1 ) { - - var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); - - data = elem.getAttribute( name ); - - if ( typeof data === "string" ) { - try { - data = data === "true" ? true : - data === "false" ? false : - data === "null" ? null : - // Only convert to a number if it doesn't change the string - +data + "" === data ? +data : - rbrace.test( data ) ? jQuery.parseJSON( data ) : - data; - } catch( e ) {} - - // Make sure we set the data so it isn't changed later - jQuery.data( elem, key, data ); - - } else { - data = undefined; - } - } - - return data; -} - -// checks a cache object for emptiness -function isEmptyDataObject( obj ) { - var name; - for ( name in obj ) { - - // if the public data object is empty, the private is still empty - if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { - continue; - } - if ( name !== "toJSON" ) { - return false; - } - } - - return true; -} -jQuery.extend({ - queue: function( elem, type, data ) { - var queue; - - if ( elem ) { - type = ( type || "fx" ) + "queue"; - queue = jQuery._data( elem, type ); - - // Speed up dequeue by getting out quickly if this is just a lookup - if ( data ) { - if ( !queue || jQuery.isArray(data) ) { - queue = jQuery._data( elem, type, jQuery.makeArray(data) ); - } else { - queue.push( data ); - } - } - return queue || []; - } - }, - - dequeue: function( elem, type ) { - type = type || "fx"; - - var queue = jQuery.queue( elem, type ), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks( elem, type ), - next = function() { - jQuery.dequeue( elem, type ); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if ( fn === "inprogress" ) { - fn = queue.shift(); - startLength--; - } - - hooks.cur = fn; - if ( fn ) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if ( type === "fx" ) { - queue.unshift( "inprogress" ); - } - - // clear up the last queue stop function - delete hooks.stop; - fn.call( elem, next, hooks ); - } - - if ( !startLength && hooks ) { - hooks.empty.fire(); - } - }, - - // not intended for public consumption - generates a queueHooks object, or returns the current one - _queueHooks: function( elem, type ) { - var key = type + "queueHooks"; - return jQuery._data( elem, key ) || jQuery._data( elem, key, { - empty: jQuery.Callbacks("once memory").add(function() { - jQuery._removeData( elem, type + "queue" ); - jQuery._removeData( elem, key ); - }) - }); - } -}); - -jQuery.fn.extend({ - queue: function( type, data ) { - var setter = 2; - - if ( typeof type !== "string" ) { - data = type; - type = "fx"; - setter--; - } - - if ( arguments.length < setter ) { - return jQuery.queue( this[0], type ); - } - - return data === undefined ? - this : - this.each(function() { - var queue = jQuery.queue( this, type, data ); - - // ensure a hooks for this queue - jQuery._queueHooks( this, type ); - - if ( type === "fx" && queue[0] !== "inprogress" ) { - jQuery.dequeue( this, type ); - } - }); - }, - dequeue: function( type ) { - return this.each(function() { - jQuery.dequeue( this, type ); - }); - }, - // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ - delay: function( time, type ) { - time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; - type = type || "fx"; - - return this.queue( type, function( next, hooks ) { - var timeout = setTimeout( next, time ); - hooks.stop = function() { - clearTimeout( timeout ); - }; - }); - }, - clearQueue: function( type ) { - return this.queue( type || "fx", [] ); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function( type, obj ) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function() { - if ( !( --count ) ) { - defer.resolveWith( elements, [ elements ] ); - } - }; - - if ( typeof type !== "string" ) { - obj = type; - type = undefined; - } - type = type || "fx"; - - while( i-- ) { - tmp = jQuery._data( elements[ i ], type + "queueHooks" ); - if ( tmp && tmp.empty ) { - count++; - tmp.empty.add( resolve ); - } - } - resolve(); - return defer.promise( obj ); - } -}); -var nodeHook, boolHook, - rclass = /[\t\r\n]/g, - rreturn = /\r/g, - rfocusable = /^(?:input|select|textarea|button|object)$/i, - rclickable = /^(?:a|area)$/i, - rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i, - ruseDefault = /^(?:checked|selected)$/i, - getSetAttribute = jQuery.support.getSetAttribute, - getSetInput = jQuery.support.input; - -jQuery.fn.extend({ - attr: function( name, value ) { - return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); - }, - - removeAttr: function( name ) { - return this.each(function() { - jQuery.removeAttr( this, name ); - }); - }, - - prop: function( name, value ) { - return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); - }, - - removeProp: function( name ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); - }, - - addClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = typeof value === "string" && value; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call( this, j, this.className ) ); - }); - } - - if ( proceed ) { - // The disjunction here is for better compressibility (see removeClass) - classes = ( value || "" ).match( core_rnotwhite ) || []; - - for ( ; i < len; i++ ) { - elem = this[ i ]; - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " " - ); - - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - if ( cur.indexOf( " " + clazz + " " ) < 0 ) { - cur += clazz + " "; - } - } - elem.className = jQuery.trim( cur ); - - } - } - } - - return this; - }, - - removeClass: function( value ) { - var classes, elem, cur, clazz, j, - i = 0, - len = this.length, - proceed = arguments.length === 0 || typeof value === "string" && value; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call( this, j, this.className ) ); - }); - } - if ( proceed ) { - classes = ( value || "" ).match( core_rnotwhite ) || []; - - for ( ; i < len; i++ ) { - elem = this[ i ]; - // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - "" - ); - - if ( cur ) { - j = 0; - while ( (clazz = classes[j++]) ) { - // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { - cur = cur.replace( " " + clazz + " ", " " ); - } - } - elem.className = value ? jQuery.trim( cur ) : ""; - } - } - } - - return this; - }, - - toggleClass: function( value, stateVal ) { - var type = typeof value, - isBool = typeof stateVal === "boolean"; - - if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); - } - - return this.each(function() { - if ( type === "string" ) { - // toggle individual class names - var className, - i = 0, - self = jQuery( this ), - state = stateVal, - classNames = value.match( core_rnotwhite ) || []; - - while ( (className = classNames[ i++ ]) ) { - // check each className given, space separated list - state = isBool ? state : !self.hasClass( className ); - self[ state ? "addClass" : "removeClass" ]( className ); - } - - // Toggle whole class name - } else if ( type === core_strundefined || type === "boolean" ) { - if ( this.className ) { - // store className if set - jQuery._data( this, "__className__", this.className ); - } - - // If the element has a class name or if we're passed "false", - // then remove the whole classname (if there was one, the above saved it). - // Otherwise bring back whatever was previously saved (if anything), - // falling back to the empty string if nothing was stored. - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; - } - }); - }, - - hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { - return true; - } - } - - return false; - }, - - val: function( value ) { - var ret, hooks, isFunction, - elem = this[0]; - - if ( !arguments.length ) { - if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { - return ret; - } - - ret = elem.value; - - return typeof ret === "string" ? - // handle most common string cases - ret.replace(rreturn, "") : - // handle cases where value is null/undef or number - ret == null ? "" : ret; - } - - return; - } - - isFunction = jQuery.isFunction( value ); - - return this.each(function( i ) { - var val, - self = jQuery(this); - - if ( this.nodeType !== 1 ) { - return; - } - - if ( isFunction ) { - val = value.call( this, i, self.val() ); - } else { - val = value; - } - - // Treat null/undefined as ""; convert numbers to string - if ( val == null ) { - val = ""; - } else if ( typeof val === "number" ) { - val += ""; - } else if ( jQuery.isArray( val ) ) { - val = jQuery.map(val, function ( value ) { - return value == null ? "" : value + ""; - }); - } - - hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; - - // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { - this.value = val; - } - }); - } -}); - -jQuery.extend({ - valHooks: { - option: { - get: function( elem ) { - // attributes.value is undefined in Blackberry 4.7 but - // uses .value. See #6932 - var val = elem.attributes.value; - return !val || val.specified ? elem.value : elem.text; - } - }, - select: { - get: function( elem ) { - var value, option, - options = elem.options, - index = elem.selectedIndex, - one = elem.type === "select-one" || index < 0, - values = one ? null : [], - max = one ? index + 1 : options.length, - i = index < 0 ? - max : - one ? index : 0; - - // Loop through all the selected options - for ( ; i < max; i++ ) { - option = options[ i ]; - - // oldIE doesn't update selected after form reset (#2551) - if ( ( option.selected || i === index ) && - // Don't return options that are disabled or in a disabled optgroup - ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && - ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { - - // Get the specific value for the option - value = jQuery( option ).val(); - - // We don't need an array for one selects - if ( one ) { - return value; - } - - // Multi-Selects return an array - values.push( value ); - } - } - - return values; - }, - - set: function( elem, value ) { - var values = jQuery.makeArray( value ); - - jQuery(elem).find("option").each(function() { - this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; - }); - - if ( !values.length ) { - elem.selectedIndex = -1; - } - return values; - } - } - }, - - attr: function( elem, name, value ) { - var hooks, notxml, ret, - nType = elem.nodeType; - - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === core_strundefined ) { - return jQuery.prop( elem, name, value ); - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - // All attributes are lowercase - // Grab necessary hook if one is defined - if ( notxml ) { - name = name.toLowerCase(); - hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); - } - - if ( value !== undefined ) { - - if ( value === null ) { - jQuery.removeAttr( elem, name ); - - } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - elem.setAttribute( name, value + "" ); - return value; - } - - } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - - // In IE9+, Flash objects don't have .getAttribute (#12945) - // Support: IE9+ - if ( typeof elem.getAttribute !== core_strundefined ) { - ret = elem.getAttribute( name ); - } - - // Non-existent attributes return null, we normalize to undefined - return ret == null ? - undefined : - ret; - } - }, - - removeAttr: function( elem, value ) { - var name, propName, - i = 0, - attrNames = value && value.match( core_rnotwhite ); - - if ( attrNames && elem.nodeType === 1 ) { - while ( (name = attrNames[i++]) ) { - propName = jQuery.propFix[ name ] || name; - - // Boolean attributes get special treatment (#10870) - if ( rboolean.test( name ) ) { - // Set corresponding property to false for boolean attributes - // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8 - if ( !getSetAttribute && ruseDefault.test( name ) ) { - elem[ jQuery.camelCase( "default-" + name ) ] = - elem[ propName ] = false; - } else { - elem[ propName ] = false; - } - - // See #9699 for explanation of this approach (setting first, then removal) - } else { - jQuery.attr( elem, name, "" ); - } - - elem.removeAttribute( getSetAttribute ? name : propName ); - } - } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { - // Setting the type on a radio button after the value resets the value in IE6-9 - // Reset value to default in case type is set after value during creation - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - } - }, - - propFix: { - tabindex: "tabIndex", - readonly: "readOnly", - "for": "htmlFor", - "class": "className", - maxlength: "maxLength", - cellspacing: "cellSpacing", - cellpadding: "cellPadding", - rowspan: "rowSpan", - colspan: "colSpan", - usemap: "useMap", - frameborder: "frameBorder", - contenteditable: "contentEditable" - }, - - prop: function( elem, name, value ) { - var ret, hooks, notxml, - nType = elem.nodeType; - - // don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { - return; - } - - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); - - if ( notxml ) { - // Fix name and attach hooks - name = jQuery.propFix[ name ] || name; - hooks = jQuery.propHooks[ name ]; - } - - if ( value !== undefined ) { - if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { - return ret; - - } else { - return ( elem[ name ] = value ); - } - - } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { - return ret; - - } else { - return elem[ name ]; - } - } - }, - - propHooks: { - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabindex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - } - } -}); - -// Hook for boolean attributes -boolHook = { - get: function( elem, name ) { - var - // Use .prop to determine if this attribute is understood as boolean - prop = jQuery.prop( elem, name ), - - // Fetch it accordingly - attr = typeof prop === "boolean" && elem.getAttribute( name ), - detail = typeof prop === "boolean" ? - - getSetInput && getSetAttribute ? - attr != null : - // oldIE fabricates an empty string for missing boolean attributes - // and conflates checked/selected into attroperties - ruseDefault.test( name ) ? - elem[ jQuery.camelCase( "default-" + name ) ] : - !!attr : - - // fetch an attribute node for properties not recognized as boolean - elem.getAttributeNode( name ); - - return detail && detail.value !== false ? - name.toLowerCase() : - undefined; - }, - set: function( elem, value, name ) { - if ( value === false ) { - // Remove boolean attributes when set to false - jQuery.removeAttr( elem, name ); - } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) { - // IE<8 needs the *property* name - elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name ); - - // Use defaultChecked and defaultSelected for oldIE - } else { - elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true; - } - - return name; - } -}; - -// fix oldIE value attroperty -if ( !getSetInput || !getSetAttribute ) { - jQuery.attrHooks.value = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - return jQuery.nodeName( elem, "input" ) ? - - // Ignore the value *property* by using defaultValue - elem.defaultValue : - - ret && ret.specified ? ret.value : undefined; - }, - set: function( elem, value, name ) { - if ( jQuery.nodeName( elem, "input" ) ) { - // Does not return so that setAttribute is also used - elem.defaultValue = value; - } else { - // Use nodeHook if defined (#1954); otherwise setAttribute is fine - return nodeHook && nodeHook.set( elem, value, name ); - } - } - }; -} - -// IE6/7 do not support getting/setting some attributes with get/setAttribute -if ( !getSetAttribute ) { - - // Use this for any attribute in IE6/7 - // This fixes almost every IE6/7 issue - nodeHook = jQuery.valHooks.button = { - get: function( elem, name ) { - var ret = elem.getAttributeNode( name ); - return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ? - ret.value : - undefined; - }, - set: function( elem, value, name ) { - // Set the existing or create a new attribute node - var ret = elem.getAttributeNode( name ); - if ( !ret ) { - elem.setAttributeNode( - (ret = elem.ownerDocument.createAttribute( name )) - ); - } - - ret.value = value += ""; - - // Break association with cloned elements by also using setAttribute (#9646) - return name === "value" || value === elem.getAttribute( name ) ? - value : - undefined; - } - }; - - // Set contenteditable to false on removals(#10429) - // Setting to empty string throws an error as an invalid value - jQuery.attrHooks.contenteditable = { - get: nodeHook.get, - set: function( elem, value, name ) { - nodeHook.set( elem, value === "" ? false : value, name ); - } - }; - - // Set width and height to auto instead of 0 on empty string( Bug #8150 ) - // This is for removals - jQuery.each([ "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - set: function( elem, value ) { - if ( value === "" ) { - elem.setAttribute( name, "auto" ); - return value; - } - } - }); - }); -} - - -// Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !jQuery.support.hrefNormalized ) { - jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { - jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { - get: function( elem ) { - var ret = elem.getAttribute( name, 2 ); - return ret == null ? undefined : ret; - } - }); - }); - - // href/src property should get the full normalized URL (#10299/#12915) - jQuery.each([ "href", "src" ], function( i, name ) { - jQuery.propHooks[ name ] = { - get: function( elem ) { - return elem.getAttribute( name, 4 ); - } - }; - }); -} - -if ( !jQuery.support.style ) { - jQuery.attrHooks.style = { - get: function( elem ) { - // Return undefined in the case of empty string - // Note: IE uppercases css property names, but if we were to .toLowerCase() - // .cssText, that would destroy case senstitivity in URL's, like in "background" - return elem.style.cssText || undefined; - }, - set: function( elem, value ) { - return ( elem.style.cssText = value + "" ); - } - }; -} - -// Safari mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it -if ( !jQuery.support.optSelected ) { - jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { - get: function( elem ) { - var parent = elem.parentNode; - - if ( parent ) { - parent.selectedIndex; - - // Make sure that it also works with optgroups, see #5701 - if ( parent.parentNode ) { - parent.parentNode.selectedIndex; - } - } - return null; - } - }); -} - -// IE6/7 call enctype encoding -if ( !jQuery.support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} - -// Radios and checkboxes getter/setter -if ( !jQuery.support.checkOn ) { - jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = { - get: function( elem ) { - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; - } - }; - }); -} -jQuery.each([ "radio", "checkbox" ], function() { - jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { - set: function( elem, value ) { - if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); - } - } - }); -}); -var rformElems = /^(?:input|select|textarea)$/i, - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; - -function returnTrue() { - return true; -} - -function returnFalse() { - return false; -} - -/* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ -jQuery.event = { - - global: {}, - - add: function( elem, types, handler, data, selector ) { - var tmp, events, t, handleObjIn, - special, eventHandle, handleObj, - handlers, type, namespaces, origType, - elemData = jQuery._data( elem ); - - // Don't attach events to noData or text/comment nodes (but allow plain objects) - if ( !elemData ) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if ( handler.handler ) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if ( !handler.guid ) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - if ( !(events = elemData.events) ) { - events = elemData.events = {}; - } - if ( !(eventHandle = elemData.handle) ) { - eventHandle = elemData.handle = function( e ) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ? - jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : - undefined; - }; - // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events - eventHandle.elem = elem; - } - - // Handle multiple events separated by a space - // jQuery(...).bind("mouseover mouseout", fn); - types = ( types || "" ).match( core_rnotwhite ) || [""]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[t] ) || []; - type = origType = tmp[1]; - namespaces = ( tmp[2] || "" ).split( "." ).sort(); - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = ( selector ? special.delegateType : special.bindType ) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: origType, - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test( selector ), - namespace: namespaces.join(".") - }, handleObjIn ); - - // Init the event handler queue if we're the first - if ( !(handlers = events[ type ]) ) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener/attachEvent if the special events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { - // Bind the global event handler to the element - if ( elem.addEventListener ) { - elem.addEventListener( type, eventHandle, false ); - - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, eventHandle ); - } - } - } - - if ( special.add ) { - special.add.call( elem, handleObj ); - - if ( !handleObj.handler.guid ) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if ( selector ) { - handlers.splice( handlers.delegateCount++, 0, handleObj ); - } else { - handlers.push( handleObj ); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - // Nullify elem to prevent memory leaks in IE - elem = null; - }, - - // Detach an event or set of events from an element - remove: function( elem, types, handler, selector, mappedTypes ) { - var j, handleObj, tmp, - origCount, t, events, - special, handlers, type, - namespaces, origType, - elemData = jQuery.hasData( elem ) && jQuery._data( elem ); - - if ( !elemData || !(events = elemData.events) ) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = ( types || "" ).match( core_rnotwhite ) || [""]; - t = types.length; - while ( t-- ) { - tmp = rtypenamespace.exec( types[t] ) || []; - type = origType = tmp[1]; - namespaces = ( tmp[2] || "" ).split( "." ).sort(); - - // Unbind all events (on this namespace, if provided) for the element - if ( !type ) { - for ( type in events ) { - jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = ( selector ? special.delegateType : special.bindType ) || type; - handlers = events[ type ] || []; - tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); - - // Remove matching events - origCount = j = handlers.length; - while ( j-- ) { - handleObj = handlers[ j ]; - - if ( ( mappedTypes || origType === handleObj.origType ) && - ( !handler || handler.guid === handleObj.guid ) && - ( !tmp || tmp.test( handleObj.namespace ) ) && - ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { - handlers.splice( j, 1 ); - - if ( handleObj.selector ) { - handlers.delegateCount--; - } - if ( special.remove ) { - special.remove.call( elem, handleObj ); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if ( origCount && !handlers.length ) { - if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { - jQuery.removeEvent( elem, type, elemData.handle ); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if ( jQuery.isEmptyObject( events ) ) { - delete elemData.handle; - - // removeData also checks for emptiness and clears the expando if empty - // so use it instead of delete - jQuery._removeData( elem, "events" ); - } - }, - - trigger: function( event, data, elem, onlyHandlers ) { - var handle, ontype, cur, - bubbleType, special, tmp, i, - eventPath = [ elem || document ], - type = core_hasOwn.call( event, "type" ) ? event.type : event, - namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; - - cur = tmp = elem = elem || document; - - // Don't do events on text and comment nodes - if ( elem.nodeType === 3 || elem.nodeType === 8 ) { - return; - } - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { - return; - } - - if ( type.indexOf(".") >= 0 ) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split("."); - type = namespaces.shift(); - namespaces.sort(); - } - ontype = type.indexOf(":") < 0 && "on" + type; - - // Caller can pass in a jQuery.Event object, Object, or just an event type string - event = event[ jQuery.expando ] ? - event : - new jQuery.Event( type, typeof event === "object" && event ); - - event.isTrigger = true; - event.namespace = namespaces.join("."); - event.namespace_re = event.namespace ? - new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : - null; - - // Clean up the event in case it is being reused - event.result = undefined; - if ( !event.target ) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data == null ? - [ event ] : - jQuery.makeArray( data, [ event ] ); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { - - bubbleType = special.delegateType || type; - if ( !rfocusMorph.test( bubbleType + type ) ) { - cur = cur.parentNode; - } - for ( ; cur; cur = cur.parentNode ) { - eventPath.push( cur ); - tmp = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if ( tmp === (elem.ownerDocument || document) ) { - eventPath.push( tmp.defaultView || tmp.parentWindow || window ); - } - } - - // Fire handlers on the event path - i = 0; - while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { - - event.type = i > 1 ? - bubbleType : - special.bindType || type; - - // jQuery handler - handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); - if ( handle ) { - handle.apply( cur, data ); - } - - // Native handler - handle = ontype && cur[ ontype ]; - if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) { - event.preventDefault(); - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if ( !onlyHandlers && !event.isDefaultPrevented() ) { - - if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && - !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { - - // Call a native DOM method on the target with the same name name as the event. - // Can't use an .isFunction() check here because IE6/7 fails that test. - // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { - - // Don't re-trigger an onFOO event when we call its FOO() method - tmp = elem[ ontype ]; - - if ( tmp ) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - try { - elem[ type ](); - } catch ( e ) { - // IE<9 dies on focus/blur to hidden element (#1486,#12518) - // only reproducible on winXP IE8 native, not IE9 in IE8 mode - } - jQuery.event.triggered = undefined; - - if ( tmp ) { - elem[ ontype ] = tmp; - } - } - } - } - - return event.result; - }, - - dispatch: function( event ) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix( event ); - - var i, ret, handleObj, matched, j, - handlerQueue = [], - args = core_slice.call( arguments ), - handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], - special = jQuery.event.special[ event.type ] || {}; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { - return; - } - - // Determine handlers - handlerQueue = jQuery.event.handlers.call( this, event, handlers ); - - // Run delegates first; they may want to stop propagation beneath us - i = 0; - while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { - event.currentTarget = matched.elem; - - j = 0; - while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { - - // Triggered event must either 1) have no namespace, or - // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). - if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { - - event.handleObj = handleObj; - event.data = handleObj.data; - - var obj = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ); - if(obj.apply){ - ret = obj.apply( matched.elem, args ); - } - - if ( ret !== undefined ) { - if ( (event.result = ret) === false ) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if ( special.postDispatch ) { - special.postDispatch.call( this, event ); - } - - return event.result; - }, - - handlers: function( event, handlers ) { - var sel, handleObj, matches, i, - handlerQueue = [], - delegateCount = handlers.delegateCount, - cur = event.target; - - // Find delegate handlers - // Black-hole SVG instance trees (#13180) - // Avoid non-left-click bubbling in Firefox (#3861) - if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { - - for ( ; cur != this; cur = cur.parentNode || this ) { - - // Don't check non-elements (#13208) - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) - if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { - matches = []; - for ( i = 0; i < delegateCount; i++ ) { - handleObj = handlers[ i ]; - - // Don't conflict with Object.prototype properties (#13203) - sel = handleObj.selector + " "; - - if ( matches[ sel ] === undefined ) { - matches[ sel ] = handleObj.needsContext ? - jQuery( sel, this ).index( cur ) >= 0 : - jQuery.find( sel, this, null, [ cur ] ).length; - } - if ( matches[ sel ] ) { - matches.push( handleObj ); - } - } - if ( matches.length ) { - handlerQueue.push({ elem: cur, handlers: matches }); - } - } - } - } - - // Add the remaining (directly-bound) handlers - if ( delegateCount < handlers.length ) { - handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); - } - - return handlerQueue; - }, - - fix: function( event ) { - if ( event[ jQuery.expando ] ) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, copy, - type = event.type, - originalEvent = event, - fixHook = this.fixHooks[ type ]; - - if ( !fixHook ) { - this.fixHooks[ type ] = fixHook = - rmouseEvent.test( type ) ? this.mouseHooks : - rkeyEvent.test( type ) ? this.keyHooks : - {}; - } - copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; - - event = new jQuery.Event( originalEvent ); - - i = copy.length; - while ( i-- ) { - prop = copy[ i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Support: IE<9 - // Fix target property (#1925) - if ( !event.target ) { - event.target = originalEvent.srcElement || document; - } - - // Support: Chrome 23+, Safari? - // Target should not be a text node (#504, #13143) - if ( event.target.nodeType === 3 ) { - event.target = event.target.parentNode; - } - - // Support: IE<9 - // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) - event.metaKey = !!event.metaKey; - - return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), - - fixHooks: {}, - - keyHooks: { - props: "char charCode key keyCode".split(" "), - filter: function( event, original ) { - - // Add which for key events - if ( event.which == null ) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), - filter: function( event, original ) { - var body, eventDoc, doc, - button = original.button, - fromElement = original.fromElement; - - // Calculate pageX/Y if missing and clientX/Y available - if ( event.pageX == null && original.clientX != null ) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); - event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); - } - - // Add relatedTarget, if necessary - if ( !event.relatedTarget && fromElement ) { - event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if ( !event.which && button !== undefined ) { - event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); - } - - return event; - } - }, - - special: { - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - click: { - // For checkbox, fire native event so checked state will be right - trigger: function() { - if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { - this.click(); - return false; - } - } - }, - focus: { - // Fire native event if possible so blur/focus sequence is correct - trigger: function() { - if ( this !== document.activeElement && this.focus ) { - try { - this.focus(); - return false; - } catch ( e ) { - // Support: IE<9 - // If we error on focus to hidden element (#1486, #12518), - // let .trigger() run the handlers - } - } - }, - delegateType: "focusin" - }, - blur: { - trigger: function() { - if ( this === document.activeElement && this.blur ) { - this.blur(); - return false; - } - }, - delegateType: "focusout" - }, - - beforeunload: { - postDispatch: function( event ) { - - // Even when returnValue equals to undefined Firefox will still show alert - if ( event.result !== undefined ) { - event.originalEvent.returnValue = event.result; - } - } - } - }, - - simulate: function( type, elem, event, bubble ) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { type: type, - isSimulated: true, - originalEvent: {} - } - ); - if ( bubble ) { - jQuery.event.trigger( e, null, elem ); - } else { - jQuery.event.dispatch.call( elem, e ); - } - if ( e.isDefaultPrevented() ) { - event.preventDefault(); - } - } -}; - -jQuery.removeEvent = document.removeEventListener ? - function( elem, type, handle ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, handle, false ); - } - } : - function( elem, type, handle ) { - var name = "on" + type; - - if ( elem.detachEvent ) { - - // #8545, #7054, preventing memory leaks for custom events in IE6-8 - // detachEvent needed property on element, by name of that event, to properly expose it to GC - if ( typeof elem[ name ] === core_strundefined ) { - elem[ name ] = null; - } - - elem.detachEvent( name, handle ); - } - }; - -jQuery.Event = function( src, props ) { - // Allow instantiation without the 'new' keyword - if ( !(this instanceof jQuery.Event) ) { - return new jQuery.Event( src, props ); - } - - // Event object - if ( src && src.type ) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || - src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if ( props ) { - jQuery.extend( this, props ); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; -}; - -// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html -jQuery.Event.prototype = { - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse, - - preventDefault: function() { - var e = this.originalEvent; - - this.isDefaultPrevented = returnTrue; - if ( !e ) { - return; - } - - // If preventDefault exists, run it on the original event - if ( e.preventDefault ) { - e.preventDefault(); - - // Support: IE - // Otherwise set the returnValue property of the original event to false - } else { - e.returnValue = false; - } - }, - stopPropagation: function() { - var e = this.originalEvent; - - this.isPropagationStopped = returnTrue; - if ( !e ) { - return; - } - // If stopPropagation exists, run it on the original event - if ( e.stopPropagation ) { - e.stopPropagation(); - } - - // Support: IE - // Set the cancelBubble property of the original event to true - e.cancelBubble = true; - }, - stopImmediatePropagation: function() { - this.isImmediatePropagationStopped = returnTrue; - this.stopPropagation(); - } -}; - -// Create mouseenter/leave events using mouseover/out and event-time checks -jQuery.each({ - mouseenter: "mouseover", - mouseleave: "mouseout" -}, function( orig, fix ) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function( event ) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; - - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if ( !related || (related !== target && !jQuery.contains( target, related )) ) { - event.type = handleObj.origType; - ret = handleObj.handler.apply( this, arguments ); - event.type = fix; - } - return ret; - } - }; -}); - -// IE submit delegation -if ( !jQuery.support.submitBubbles ) { - - jQuery.event.special.submit = { - setup: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Lazy-add a submit handler when a descendant form may potentially be submitted - jQuery.event.add( this, "click._submit keypress._submit", function( e ) { - // Node name check avoids a VML-related crash in IE (#9807) - var elem = e.target, - form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; - if ( form && !jQuery._data( form, "submitBubbles" ) ) { - jQuery.event.add( form, "submit._submit", function( event ) { - event._submit_bubble = true; - }); - jQuery._data( form, "submitBubbles", true ); - } - }); - // return undefined since we don't need an event listener - }, - - postDispatch: function( event ) { - // If form was submitted by the user, bubble the event up the tree - if ( event._submit_bubble ) { - delete event._submit_bubble; - if ( this.parentNode && !event.isTrigger ) { - jQuery.event.simulate( "submit", this.parentNode, event, true ); - } - } - }, - - teardown: function() { - // Only need this for delegated form submit events - if ( jQuery.nodeName( this, "form" ) ) { - return false; - } - - // Remove delegated handlers; cleanData eventually reaps submit handlers attached above - jQuery.event.remove( this, "._submit" ); - } - }; -} - -// IE change delegation and checkbox/radio fix -if ( !jQuery.support.changeBubbles ) { - - jQuery.event.special.change = { - - setup: function() { - - if ( rformElems.test( this.nodeName ) ) { - // IE doesn't fire change on a check/radio until blur; trigger it on click - // after a propertychange. Eat the blur-change in special.change.handle. - // This still fires onchange a second time for check/radio after blur. - if ( this.type === "checkbox" || this.type === "radio" ) { - jQuery.event.add( this, "propertychange._change", function( event ) { - if ( event.originalEvent.propertyName === "checked" ) { - this._just_changed = true; - } - }); - jQuery.event.add( this, "click._change", function( event ) { - if ( this._just_changed && !event.isTrigger ) { - this._just_changed = false; - } - // Allow triggered, simulated change events (#11500) - jQuery.event.simulate( "change", this, event, true ); - }); - } - return false; - } - // Delegated event; lazy-add a change handler on descendant inputs - jQuery.event.add( this, "beforeactivate._change", function( e ) { - var elem = e.target; - - if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { - jQuery.event.add( elem, "change._change", function( event ) { - if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { - jQuery.event.simulate( "change", this.parentNode, event, true ); - } - }); - jQuery._data( elem, "changeBubbles", true ); - } - }); - }, - - handle: function( event ) { - var elem = event.target; - - // Swallow native change events from checkbox/radio, we already triggered them above - if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { - return event.handleObj.handler.apply( this, arguments ); - } - }, - - teardown: function() { - jQuery.event.remove( this, "._change" ); - - return !rformElems.test( this.nodeName ); - } - }; -} - -// Create "bubbling" focus and blur events -if ( !jQuery.support.focusinBubbles ) { - jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - - // Attach a single capturing handler while someone wants focusin/focusout - var attaches = 0, - handler = function( event ) { - jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); - }; - - jQuery.event.special[ fix ] = { - setup: function() { - if ( attaches++ === 0 ) { - document.addEventListener( orig, handler, true ); - } - }, - teardown: function() { - if ( --attaches === 0 ) { - document.removeEventListener( orig, handler, true ); - } - } - }; - }); -} - -jQuery.fn.extend({ - - on: function( types, selector, data, fn, /*INTERNAL*/ one ) { - var type, origFn; - - // Types can be a map of types/handlers - if ( typeof types === "object" ) { - // ( types-Object, selector, data ) - if ( typeof selector !== "string" ) { - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - for ( type in types ) { - this.on( type, selector, data, types[ type ], one ); - } - return this; - } - - if ( data == null && fn == null ) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if ( fn == null ) { - if ( typeof selector === "string" ) { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - if ( fn === false ) { - fn = returnFalse; - } else if ( !fn ) { - return this; - } - - if ( one === 1 ) { - origFn = fn; - fn = function( event ) { - // Can use an empty set, since event contains the info - jQuery().off( event ); - return origFn.apply( this, arguments ); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); - } - return this.each( function() { - jQuery.event.add( this, types, fn, data, selector ); - }); - }, - one: function( types, selector, data, fn ) { - return this.on( types, selector, data, fn, 1 ); - }, - off: function( types, selector, fn ) { - var handleObj, type; - if ( types && types.preventDefault && types.handleObj ) { - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery( types.delegateTarget ).off( - handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, - handleObj.selector, - handleObj.handler - ); - return this; - } - if ( typeof types === "object" ) { - // ( types-object [, selector] ) - for ( type in types ) { - this.off( type, selector, types[ type ] ); - } - return this; - } - if ( selector === false || typeof selector === "function" ) { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - if ( fn === false ) { - fn = returnFalse; - } - return this.each(function() { - jQuery.event.remove( this, types, fn, selector ); - }); - }, - - bind: function( types, data, fn ) { - return this.on( types, null, data, fn ); - }, - unbind: function( types, fn ) { - return this.off( types, null, fn ); - }, - - delegate: function( selector, types, data, fn ) { - return this.on( types, selector, data, fn ); - }, - undelegate: function( selector, types, fn ) { - // ( namespace ) or ( selector, types [, fn] ) - return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); - }, - - trigger: function( type, data ) { - return this.each(function() { - jQuery.event.trigger( type, data, this ); - }); - }, - triggerHandler: function( type, data ) { - var elem = this[0]; - if ( elem ) { - return jQuery.event.trigger( type, data, elem, true ); - } - } -}); -/*! - * Sizzle CSS Selector Engine - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license - * http://sizzlejs.com/ - */ -(function( window, undefined ) { - -var i, - cachedruns, - Expr, - getText, - isXML, - compile, - hasDuplicate, - outermostContext, - - // Local document vars - setDocument, - document, - docElem, - documentIsXML, - rbuggyQSA, - rbuggyMatches, - matches, - contains, - sortOrder, - - // Instance-specific data - expando = "sizzle" + -(new Date()), - preferredDoc = window.document, - support = {}, - dirruns = 0, - done = 0, - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - - // General-purpose constants - strundefined = typeof undefined, - MAX_NEGATIVE = 1 << 31, - - // Array methods - arr = [], - pop = arr.pop, - push = arr.push, - slice = arr.slice, - // Use a stripped-down indexOf if we can't use a native one - indexOf = arr.indexOf || function( elem ) { - var i = 0, - len = this.length; - for ( ; i < len; i++ ) { - if ( this[i] === elem ) { - return i; - } - } - return -1; - }, - - - // Regular expressions - - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/css3-syntax/#characters - characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", - - // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = characterEncoding.replace( "w", "w#" ), - - // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors - operators = "([*^$|!~]?=)", - attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + - "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", - - // Prefer arguments quoted, - // then not containing pseudos/brackets, - // then attribute selectors/non-parenthetical expressions, - // then anything else - // These preferences are here to reduce the number of selectors - // needing tokenize in the PSEUDO preFilter - pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), - - rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), - rpseudo = new RegExp( pseudos ), - ridentifier = new RegExp( "^" + identifier + "$" ), - - matchExpr = { - "ID": new RegExp( "^#(" + characterEncoding + ")" ), - "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), - "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), - "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), - "ATTR": new RegExp( "^" + attributes ), - "PSEUDO": new RegExp( "^" + pseudos ), - "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + - "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + - "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), - // For use in libraries implementing .is() - // We use this for POS matching in `select` - "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + - whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) - }, - - rsibling = /[\x20\t\r\n\f]*[+~]/, - - rnative = /^[^{]+\{\s*\[native code/, - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, - - rinputs = /^(?:input|select|textarea|button)$/i, - rheader = /^h\d$/i, - - rescape = /'|\\/g, - rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, - - // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters - runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g, - funescape = function( _, escaped ) { - var high = "0x" + escaped - 0x10000; - // NaN means non-codepoint - return high !== high ? - escaped : - // BMP codepoint - high < 0 ? - String.fromCharCode( high + 0x10000 ) : - // Supplemental Plane codepoint (surrogate pair) - String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); - }; - -// Use a stripped-down slice if we can't use a native one -try { - slice.call( preferredDoc.documentElement.childNodes, 0 )[0].nodeType; -} catch ( e ) { - slice = function( i ) { - var elem, - results = []; - while ( (elem = this[i++]) ) { - results.push( elem ); - } - return results; - }; -} - -/** - * For feature detection - * @param {Function} fn The function to test for native support - */ -function isNative( fn ) { - return rnative.test( fn + "" ); -} - -/** - * Create key-value caches of limited size - * @returns {Function(string, Object)} Returns the Object data after storing it on itself with - * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) - * deleting the oldest entry - */ -function createCache() { - var cache, - keys = []; - - return (cache = function( key, value ) { - // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) - if ( keys.push( key += " " ) > Expr.cacheLength ) { - // Only keep the most recent entries - delete cache[ keys.shift() ]; - } - return (cache[ key ] = value); - }); -} - -/** - * Mark a function for special use by Sizzle - * @param {Function} fn The function to mark - */ -function markFunction( fn ) { - fn[ expando ] = true; - return fn; -} - -/** - * Support testing using an element - * @param {Function} fn Passed the created div and expects a boolean result - */ -function assert( fn ) { - var div = document.createElement("div"); - - try { - return fn( div ); - } catch (e) { - return false; - } finally { - // release memory in IE - div = null; - } -} - -function Sizzle( selector, context, results, seed ) { - var match, elem, m, nodeType, - // QSA vars - i, groups, old, nid, newContext, newSelector; - - if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { - setDocument( context ); - } - - context = context || document; - results = results || []; - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { - return []; - } - - if ( !documentIsXML && !seed ) { - - // Shortcuts - if ( (match = rquickExpr.exec( selector )) ) { - // Speed-up: Sizzle("#ID") - if ( (m = match[1]) ) { - if ( nodeType === 9 ) { - elem = context.getElementById( m ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE, Opera, and Webkit return items - // by name instead of ID - if ( elem.id === m ) { - results.push( elem ); - return results; - } - } else { - return results; - } - } else { - // Context is not a document - if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && - contains( context, elem ) && elem.id === m ) { - results.push( elem ); - return results; - } - } - - // Speed-up: Sizzle("TAG") - } else if ( match[2] ) { - push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); - return results; - - // Speed-up: Sizzle(".CLASS") - } else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) { - push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); - return results; - } - } - - // QSA path - if ( support.qsa && !rbuggyQSA.test(selector) ) { - old = true; - nid = expando; - newContext = context; - newSelector = nodeType === 9 && selector; - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - groups = tokenize( selector ); - - if ( (old = context.getAttribute("id")) ) { - nid = old.replace( rescape, "\\$&" ); - } else { - context.setAttribute( "id", nid ); - } - nid = "[id='" + nid + "'] "; - - i = groups.length; - while ( i-- ) { - groups[i] = nid + toSelector( groups[i] ); - } - newContext = rsibling.test( selector ) && context.parentNode || context; - newSelector = groups.join(","); - } - - if ( newSelector ) { - try { - push.apply( results, slice.call( newContext.querySelectorAll( - newSelector - ), 0 ) ); - return results; - } catch(qsaError) { - } finally { - if ( !old ) { - context.removeAttribute("id"); - } - } - } - } - } - - // All others - return select( selector.replace( rtrim, "$1" ), context, results, seed ); -} - -/** - * Detect xml - * @param {Element|Object} elem An element or a document - */ -isXML = Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -/** - * Sets document-related variables once based on the current document - * @param {Element|Object} [doc] An element or document object to use to set the document - * @returns {Object} Returns the current document - */ -setDocument = Sizzle.setDocument = function( node ) { - var doc = node ? node.ownerDocument || node : preferredDoc; - - // If no document and documentElement is available, return - if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { - return document; - } - - // Set our document - document = doc; - docElem = doc.documentElement; - - // Support tests - documentIsXML = isXML( doc ); - - // Check if getElementsByTagName("*") returns only elements - support.tagNameNoComments = assert(function( div ) { - div.appendChild( doc.createComment("") ); - return !div.getElementsByTagName("*").length; - }); - - // Check if attributes should be retrieved by attribute nodes - support.attributes = assert(function( div ) { - div.innerHTML = ""; - var type = typeof div.lastChild.getAttribute("multiple"); - // IE8 returns a string for some attributes even when not present - return type !== "boolean" && type !== "string"; - }); - - // Check if getElementsByClassName can be trusted - support.getByClassName = assert(function( div ) { - // Opera can't find a second classname (in 9.6) - div.innerHTML = ""; - if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { - return false; - } - - // Safari 3.2 caches class attributes and doesn't catch changes - div.lastChild.className = "e"; - return div.getElementsByClassName("e").length === 2; - }); - - // Check if getElementById returns elements by name - // Check if getElementsByName privileges form controls or returns elements by ID - support.getByName = assert(function( div ) { - // Inject content - div.id = expando + 0; - div.innerHTML = "
"; - docElem.insertBefore( div, docElem.firstChild ); - - // Test - var pass = doc.getElementsByName && - // buggy browsers will return fewer than the correct 2 - doc.getElementsByName( expando ).length === 2 + - // buggy browsers will return more than the correct 0 - doc.getElementsByName( expando + 0 ).length; - support.getIdNotName = !doc.getElementById( expando ); - - // Cleanup - docElem.removeChild( div ); - - return pass; - }); - - // IE6/7 return modified attributes - Expr.attrHandle = assert(function( div ) { - div.innerHTML = ""; - return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && - div.firstChild.getAttribute("href") === "#"; - }) ? - {} : - { - "href": function( elem ) { - return elem.getAttribute( "href", 2 ); - }, - "type": function( elem ) { - return elem.getAttribute("type"); - } - }; - - // ID find and filter - if ( support.getIdNotName ) { - Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== strundefined && !documentIsXML ) { - var m = context.getElementById( id ); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }; - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - return elem.getAttribute("id") === attrId; - }; - }; - } else { - Expr.find["ID"] = function( id, context ) { - if ( typeof context.getElementById !== strundefined && !documentIsXML ) { - var m = context.getElementById( id ); - - return m ? - m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? - [m] : - undefined : - []; - } - }; - Expr.filter["ID"] = function( id ) { - var attrId = id.replace( runescape, funescape ); - return function( elem ) { - var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); - return node && node.value === attrId; - }; - }; - } - - // Tag - Expr.find["TAG"] = support.tagNameNoComments ? - function( tag, context ) { - if ( typeof context.getElementsByTagName !== strundefined ) { - return context.getElementsByTagName( tag ); - } - } : - function( tag, context ) { - var elem, - tmp = [], - i = 0, - results = context.getElementsByTagName( tag ); - - // Filter out possible comments - if ( tag === "*" ) { - while ( (elem = results[i++]) ) { - if ( elem.nodeType === 1 ) { - tmp.push( elem ); - } - } - - return tmp; - } - return results; - }; - - // Name - Expr.find["NAME"] = support.getByName && function( tag, context ) { - if ( typeof context.getElementsByName !== strundefined ) { - return context.getElementsByName( name ); - } - }; - - // Class - Expr.find["CLASS"] = support.getByClassName && function( className, context ) { - if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) { - return context.getElementsByClassName( className ); - } - }; - - // QSA and matchesSelector support - - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - rbuggyMatches = []; - - // qSa(:focus) reports false when true (Chrome 21), - // no need to also add to buggyMatches since matches checks buggyQSA - // A support test would require too much code (would include document ready) - rbuggyQSA = [ ":focus" ]; - - if ( (support.qsa = isNative(doc.querySelectorAll)) ) { - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert(function( div ) { - // Select is set to empty string on purpose - // This is to test IE's treatment of not explictly - // setting a boolean content attribute, - // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 - div.innerHTML = ""; - - // IE8 - Some boolean attributes are not treated correctly - if ( !div.querySelectorAll("[selected]").length ) { - rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":checked").length ) { - rbuggyQSA.push(":checked"); - } - }); - - assert(function( div ) { - - // Opera 10-12/IE8 - ^= $= *= and empty values - // Should not select anything - div.innerHTML = ""; - if ( div.querySelectorAll("[i^='']").length ) { - rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here and will not see later tests - if ( !div.querySelectorAll(":enabled").length ) { - rbuggyQSA.push( ":enabled", ":disabled" ); - } - - // Opera 10-11 does not throw on post-comma invalid pseudos - div.querySelectorAll("*,:x"); - rbuggyQSA.push(",.*:"); - }); - } - - if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector || - docElem.mozMatchesSelector || - docElem.webkitMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector) )) ) { - - assert(function( div ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - support.disconnectedMatch = matches.call( div, "div" ); - - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( div, "[s!='']:x" ); - rbuggyMatches.push( "!=", pseudos ); - }); - } - - rbuggyQSA = new RegExp( rbuggyQSA.join("|") ); - rbuggyMatches = new RegExp( rbuggyMatches.join("|") ); - - // Element contains another - // Purposefully does not implement inclusive descendent - // As in, an element does not contain itself - contains = isNative(docElem.contains) || docElem.compareDocumentPosition ? - function( a, b ) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - return a === bup || !!( bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains( bup ) : - a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - )); - } : - function( a, b ) { - if ( b ) { - while ( (b = b.parentNode) ) { - if ( b === a ) { - return true; - } - } - } - return false; - }; - - // Document order sorting - sortOrder = docElem.compareDocumentPosition ? - function( a, b ) { - var compare; - - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) { - if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) { - if ( a === doc || contains( preferredDoc, a ) ) { - return -1; - } - if ( b === doc || contains( preferredDoc, b ) ) { - return 1; - } - return 0; - } - return compare & 4 ? -1 : 1; - } - - return a.compareDocumentPosition ? -1 : 1; - } : - function( a, b ) { - var cur, - i = 0, - aup = a.parentNode, - bup = b.parentNode, - ap = [ a ], - bp = [ b ]; - - // Exit early if the nodes are identical - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Parentless nodes are either documents or disconnected - } else if ( !aup || !bup ) { - return a === doc ? -1 : - b === doc ? 1 : - aup ? -1 : - bup ? 1 : - 0; - - // If the nodes are siblings, we can do a quick check - } else if ( aup === bup ) { - return siblingCheck( a, b ); - } - - // Otherwise we need full lists of their ancestors for comparison - cur = a; - while ( (cur = cur.parentNode) ) { - ap.unshift( cur ); - } - cur = b; - while ( (cur = cur.parentNode) ) { - bp.unshift( cur ); - } - - // Walk down the tree looking for a discrepancy - while ( ap[i] === bp[i] ) { - i++; - } - - return i ? - // Do a sibling check if the nodes have a common ancestor - siblingCheck( ap[i], bp[i] ) : - - // Otherwise nodes in our document sort first - ap[i] === preferredDoc ? -1 : - bp[i] === preferredDoc ? 1 : - 0; - }; - - // Always assume the presence of duplicates if sort doesn't - // pass them to our comparison function (as in Google Chrome). - hasDuplicate = false; - [0, 0].sort( sortOrder ); - support.detectDuplicates = hasDuplicate; - - return document; -}; - -Sizzle.matches = function( expr, elements ) { - return Sizzle( expr, null, null, elements ); -}; - -Sizzle.matchesSelector = function( elem, expr ) { - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - // Make sure that attribute selectors are quoted - expr = expr.replace( rattributeQuotes, "='$1']" ); - - // rbuggyQSA always contains :focus, so no need for an existence check - if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) { - try { - var ret = matches.call( elem, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || support.disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { - return ret; - } - } catch(e) {} - } - - return Sizzle( expr, document, null, [elem] ).length > 0; -}; - -Sizzle.contains = function( context, elem ) { - // Set document vars if needed - if ( ( context.ownerDocument || context ) !== document ) { - setDocument( context ); - } - return contains( context, elem ); -}; - -Sizzle.attr = function( elem, name ) { - var val; - - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - if ( !documentIsXML ) { - name = name.toLowerCase(); - } - if ( (val = Expr.attrHandle[ name ]) ) { - return val( elem ); - } - if ( documentIsXML || support.attributes ) { - return elem.getAttribute( name ); - } - return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ? - name : - val && val.specified ? val.value : null; -}; - -Sizzle.error = function( msg ) { - throw new Error( "Syntax error, unrecognized expression: " + msg ); -}; - -// Document sorting and removing duplicates -Sizzle.uniqueSort = function( results ) { - var elem, - duplicates = [], - i = 1, - j = 0; - - // Unless we *know* we can detect duplicates, assume their presence - hasDuplicate = !support.detectDuplicates; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( ; (elem = results[i]); i++ ) { - if ( elem === results[ i - 1 ] ) { - j = duplicates.push( i ); - } - } - while ( j-- ) { - results.splice( duplicates[ j ], 1 ); - } - } - - return results; -}; - -function siblingCheck( a, b ) { - var cur = b && a, - diff = cur && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE ); - - // Use IE sourceIndex if available on both nodes - if ( diff ) { - return diff; - } - - // Check if b follows a - if ( cur ) { - while ( (cur = cur.nextSibling) ) { - if ( cur === b ) { - return -1; - } - } - } - - return a ? 1 : -1; -} - -// Returns a function to use in pseudos for input types -function createInputPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === type; - }; -} - -// Returns a function to use in pseudos for buttons -function createButtonPseudo( type ) { - return function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && elem.type === type; - }; -} - -// Returns a function to use in pseudos for positionals -function createPositionalPseudo( fn ) { - return markFunction(function( argument ) { - argument = +argument; - return markFunction(function( seed, matches ) { - var j, - matchIndexes = fn( [], seed.length, argument ), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while ( i-- ) { - if ( seed[ (j = matchIndexes[i]) ] ) { - seed[j] = !(matches[j] = seed[j]); - } - } - }); - }); -} - -/** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ -getText = Sizzle.getText = function( elem ) { - var node, - ret = "", - i = 0, - nodeType = elem.nodeType; - - if ( !nodeType ) { - // If no nodeType, this is expected to be an array - for ( ; (node = elem[i]); i++ ) { - // Do not traverse comment nodes - ret += getText( node ); - } - } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { - // Use textContent for elements - // innerText usage removed for consistency of new lines (see #11153) - if ( typeof elem.textContent === "string" ) { - return elem.textContent; - } else { - // Traverse its children - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - ret += getText( elem ); - } - } - } else if ( nodeType === 3 || nodeType === 4 ) { - return elem.nodeValue; - } - // Do not include comment or processing instruction nodes - - return ret; -}; - -Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - find: {}, - - relative: { - ">": { dir: "parentNode", first: true }, - " ": { dir: "parentNode" }, - "+": { dir: "previousSibling", first: true }, - "~": { dir: "previousSibling" } - }, - - preFilter: { - "ATTR": function( match ) { - match[1] = match[1].replace( runescape, funescape ); - - // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); - - if ( match[2] === "~=" ) { - match[3] = " " + match[3] + " "; - } - - return match.slice( 0, 4 ); - }, - - "CHILD": function( match ) { - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 what (child|of-type) - 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 4 xn-component of xn+y argument ([+-]?\d*n|) - 5 sign of xn-component - 6 x of xn-component - 7 sign of y-component - 8 y of y-component - */ - match[1] = match[1].toLowerCase(); - - if ( match[1].slice( 0, 3 ) === "nth" ) { - // nth-* requires argument - if ( !match[3] ) { - Sizzle.error( match[0] ); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); - match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); - - // other types prohibit arguments - } else if ( match[3] ) { - Sizzle.error( match[0] ); - } - - return match; - }, - - "PSEUDO": function( match ) { - var excess, - unquoted = !match[5] && match[2]; - - if ( matchExpr["CHILD"].test( match[0] ) ) { - return null; - } - - // Accept quoted arguments as-is - if ( match[4] ) { - match[2] = match[4]; - - // Strip excess characters from unquoted arguments - } else if ( unquoted && rpseudo.test( unquoted ) && - // Get excess from tokenize (recursively) - (excess = tokenize( unquoted, true )) && - // advance to the next closing parenthesis - (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { - - // excess is a negative index - match[0] = match[0].slice( 0, excess ); - match[2] = unquoted.slice( 0, excess ); - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice( 0, 3 ); - } - }, - - filter: { - - "TAG": function( nodeName ) { - if ( nodeName === "*" ) { - return function() { return true; }; - } - - nodeName = nodeName.replace( runescape, funescape ).toLowerCase(); - return function( elem ) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - "CLASS": function( className ) { - var pattern = classCache[ className + " " ]; - - return pattern || - (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && - classCache( className, function( elem ) { - return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); - }); - }, - - "ATTR": function( name, operator, check ) { - return function( elem ) { - var result = Sizzle.attr( elem, name ); - - if ( result == null ) { - return operator === "!="; - } - if ( !operator ) { - return true; - } - - result += ""; - - return operator === "=" ? result === check : - operator === "!=" ? result !== check : - operator === "^=" ? check && result.indexOf( check ) === 0 : - operator === "*=" ? check && result.indexOf( check ) > -1 : - operator === "$=" ? check && result.slice( -check.length ) === check : - operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : - operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : - false; - }; - }, - - "CHILD": function( type, what, argument, first, last ) { - var simple = type.slice( 0, 3 ) !== "nth", - forward = type.slice( -4 ) !== "last", - ofType = what === "of-type"; - - return first === 1 && last === 0 ? - - // Shortcut for :nth-*(n) - function( elem ) { - return !!elem.parentNode; - } : - - function( elem, context, xml ) { - var cache, outerCache, node, diff, nodeIndex, start, - dir = simple !== forward ? "nextSibling" : "previousSibling", - parent = elem.parentNode, - name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType; - - if ( parent ) { - - // :(first|last|only)-(child|of-type) - if ( simple ) { - while ( dir ) { - node = elem; - while ( (node = node[ dir ]) ) { - if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { - return false; - } - } - // Reverse direction for :only-* (if we haven't yet done so) - start = dir = type === "only" && !start && "nextSibling"; - } - return true; - } - - start = [ forward ? parent.firstChild : parent.lastChild ]; - - // non-xml :nth-child(...) stores cache data on `parent` - if ( forward && useCache ) { - // Seek `elem` from a previously-cached index - outerCache = parent[ expando ] || (parent[ expando ] = {}); - cache = outerCache[ type ] || []; - nodeIndex = cache[0] === dirruns && cache[1]; - diff = cache[0] === dirruns && cache[2]; - node = nodeIndex && parent.childNodes[ nodeIndex ]; - - while ( (node = ++nodeIndex && node && node[ dir ] || - - // Fallback to seeking `elem` from the start - (diff = nodeIndex = 0) || start.pop()) ) { - - // When found, cache indexes on `parent` and break - if ( node.nodeType === 1 && ++diff && node === elem ) { - outerCache[ type ] = [ dirruns, nodeIndex, diff ]; - break; - } - } - - // Use previously-cached element index if available - } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { - diff = cache[1]; - - // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) - } else { - // Use the same loop as above to seek `elem` from the start - while ( (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) ) { - - if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { - // Cache the index of each encountered element - if ( useCache ) { - (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; - } - - if ( node === elem ) { - break; - } - } - } - } - - // Incorporate the offset, then check against cycle size - diff -= last; - return diff === first || ( diff % first === 0 && diff / first >= 0 ); - } - }; - }, - - "PSEUDO": function( pseudo, argument ) { - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error( "unsupported pseudo: " + pseudo ); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if ( fn[ expando ] ) { - return fn( argument ); - } - - // But maintain support for old signatures - if ( fn.length > 1 ) { - args = [ pseudo, pseudo, "", argument ]; - return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction(function( seed, matches ) { - var idx, - matched = fn( seed, argument ), - i = matched.length; - while ( i-- ) { - idx = indexOf.call( seed, matched[i] ); - seed[ idx ] = !( matches[ idx ] = matched[i] ); - } - }) : - function( elem ) { - return fn( elem, 0, args ); - }; - } - - return fn; - } - }, - - pseudos: { - // Potentially complex pseudos - "not": markFunction(function( selector ) { - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile( selector.replace( rtrim, "$1" ) ); - - return matcher[ expando ] ? - markFunction(function( seed, matches, context, xml ) { - var elem, - unmatched = matcher( seed, null, xml, [] ), - i = seed.length; - - // Match elements unmatched by `matcher` - while ( i-- ) { - if ( (elem = unmatched[i]) ) { - seed[i] = !(matches[i] = elem); - } - } - }) : - function( elem, context, xml ) { - input[0] = elem; - matcher( input, null, xml, results ); - return !results.pop(); - }; - }), - - "has": markFunction(function( selector ) { - return function( elem ) { - return Sizzle( selector, elem ).length > 0; - }; - }), - - "contains": markFunction(function( text ) { - return function( elem ) { - return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; - }; - }), - - // "Whether an element is represented by a :lang() selector - // is based solely on the element's language value - // being equal to the identifier C, - // or beginning with the identifier C immediately followed by "-". - // The matching of C against the element's language value is performed case-insensitively. - // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo - "lang": markFunction( function( lang ) { - // lang value must be a valid identifider - if ( !ridentifier.test(lang || "") ) { - Sizzle.error( "unsupported lang: " + lang ); - } - lang = lang.replace( runescape, funescape ).toLowerCase(); - return function( elem ) { - var elemLang; - do { - if ( (elemLang = documentIsXML ? - elem.getAttribute("xml:lang") || elem.getAttribute("lang") : - elem.lang) ) { - - elemLang = elemLang.toLowerCase(); - return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; - } - } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); - return false; - }; - }), - - // Miscellaneous - "target": function( elem ) { - var hash = window.location && window.location.hash; - return hash && hash.slice( 1 ) === elem.id; - }, - - "root": function( elem ) { - return elem === docElem; - }, - - "focus": function( elem ) { - return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); - }, - - // Boolean properties - "enabled": function( elem ) { - return elem.disabled === false; - }, - - "disabled": function( elem ) { - return elem.disabled === true; - }, - - "checked": function( elem ) { - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); - }, - - "selected": function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - // Contents - "empty": function( elem ) { - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), - // not comment, processing instructions, or others - // Thanks to Diego Perini for the nodeName shortcut - // Greater than "@" means alpha characters (specifically not starting with "#" or "?") - for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { - if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) { - return false; - } - } - return true; - }, - - "parent": function( elem ) { - return !Expr.pseudos["empty"]( elem ); - }, - - // Element/input types - "header": function( elem ) { - return rheader.test( elem.nodeName ); - }, - - "input": function( elem ) { - return rinputs.test( elem.nodeName ); - }, - - "button": function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && elem.type === "button" || name === "button"; - }, - - "text": function( elem ) { - var attr; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && - elem.type === "text" && - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type ); - }, - - // Position-in-collection - "first": createPositionalPseudo(function() { - return [ 0 ]; - }), - - "last": createPositionalPseudo(function( matchIndexes, length ) { - return [ length - 1 ]; - }), - - "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { - return [ argument < 0 ? argument + length : argument ]; - }), - - "even": createPositionalPseudo(function( matchIndexes, length ) { - var i = 0; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "odd": createPositionalPseudo(function( matchIndexes, length ) { - var i = 1; - for ( ; i < length; i += 2 ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; --i >= 0; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }), - - "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; - for ( ; ++i < length; ) { - matchIndexes.push( i ); - } - return matchIndexes; - }) - } -}; - -// Add button/input type pseudos -for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { - Expr.pseudos[ i ] = createInputPseudo( i ); -} -for ( i in { submit: true, reset: true } ) { - Expr.pseudos[ i ] = createButtonPseudo( i ); -} - -function tokenize( selector, parseOnly ) { - var matched, match, tokens, type, - soFar, groups, preFilters, - cached = tokenCache[ selector + " " ]; - - if ( cached ) { - return parseOnly ? 0 : cached.slice( 0 ); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while ( soFar ) { - - // Comma and first run - if ( !matched || (match = rcomma.exec( soFar )) ) { - if ( match ) { - // Don't consume trailing commas as valid - soFar = soFar.slice( match[0].length ) || soFar; - } - groups.push( tokens = [] ); - } - - matched = false; - - // Combinators - if ( (match = rcombinators.exec( soFar )) ) { - matched = match.shift(); - tokens.push( { - value: matched, - // Cast descendant combinators to space - type: match[0].replace( rtrim, " " ) - } ); - soFar = soFar.slice( matched.length ); - } - - // Filters - for ( type in Expr.filter ) { - if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || - (match = preFilters[ type ]( match ))) ) { - matched = match.shift(); - tokens.push( { - value: matched, - type: type, - matches: match - } ); - soFar = soFar.slice( matched.length ); - } - } - - if ( !matched ) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error( selector ) : - // Cache the tokens - tokenCache( selector, groups ).slice( 0 ); -} - -function toSelector( tokens ) { - var i = 0, - len = tokens.length, - selector = ""; - for ( ; i < len; i++ ) { - selector += tokens[i].value; - } - return selector; -} - -function addCombinator( matcher, combinator, base ) { - var dir = combinator.dir, - checkNonElements = base && dir === "parentNode", - doneName = done++; - - return combinator.first ? - // Check against closest ancestor/preceding element - function( elem, context, xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - return matcher( elem, context, xml ); - } - } - } : - - // Check against all ancestor/preceding elements - function( elem, context, xml ) { - var data, cache, outerCache, - dirkey = dirruns + " " + doneName; - - // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching - if ( xml ) { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - if ( matcher( elem, context, xml ) ) { - return true; - } - } - } - } else { - while ( (elem = elem[ dir ]) ) { - if ( elem.nodeType === 1 || checkNonElements ) { - outerCache = elem[ expando ] || (elem[ expando ] = {}); - if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) { - if ( (data = cache[1]) === true || data === cachedruns ) { - return data === true; - } - } else { - cache = outerCache[ dir ] = [ dirkey ]; - cache[1] = matcher( elem, context, xml ) || cachedruns; - if ( cache[1] === true ) { - return true; - } - } - } - } - } - }; -} - -function elementMatcher( matchers ) { - return matchers.length > 1 ? - function( elem, context, xml ) { - var i = matchers.length; - while ( i-- ) { - if ( !matchers[i]( elem, context, xml ) ) { - return false; - } - } - return true; - } : - matchers[0]; -} - -function condense( unmatched, map, filter, context, xml ) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for ( ; i < len; i++ ) { - if ( (elem = unmatched[i]) ) { - if ( !filter || filter( elem, context, xml ) ) { - newUnmatched.push( elem ); - if ( mapped ) { - map.push( i ); - } - } - } - } - - return newUnmatched; -} - -function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { - if ( postFilter && !postFilter[ expando ] ) { - postFilter = setMatcher( postFilter ); - } - if ( postFinder && !postFinder[ expando ] ) { - postFinder = setMatcher( postFinder, postSelector ); - } - return markFunction(function( seed, results, context, xml ) { - var temp, i, elem, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && ( seed || !selector ) ? - condense( elems, preMap, preFilter, context, xml ) : - elems, - - matcherOut = matcher ? - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if ( matcher ) { - matcher( matcherIn, matcherOut, context, xml ); - } - - // Apply postFilter - if ( postFilter ) { - temp = condense( matcherOut, postMap ); - postFilter( temp, [], context, xml ); - - // Un-match failing elements by moving them back to matcherIn - i = temp.length; - while ( i-- ) { - if ( (elem = temp[i]) ) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); - } - } - } - - if ( seed ) { - if ( postFinder || preFilter ) { - if ( postFinder ) { - // Get the final matcherOut by condensing this intermediate into postFinder contexts - temp = []; - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) ) { - // Restore matcherIn since elem is not yet a final match - temp.push( (matcherIn[i] = elem) ); - } - } - postFinder( null, (matcherOut = []), temp, xml ); - } - - // Move matched elements from seed to results to keep them synchronized - i = matcherOut.length; - while ( i-- ) { - if ( (elem = matcherOut[i]) && - (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { - - seed[temp] = !(results[temp] = elem); - } - } - } - - // Add elements to results, through postFinder if defined - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice( preexisting, matcherOut.length ) : - matcherOut - ); - if ( postFinder ) { - postFinder( null, results, matcherOut, xml ); - } else { - push.apply( results, matcherOut ); - } - } - }); -} - -function matcherFromTokens( tokens ) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[" "], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator( function( elem ) { - return elem === checkContext; - }, implicitRelative, true ), - matchAnyContext = addCombinator( function( elem ) { - return indexOf.call( checkContext, elem ) > -1; - }, implicitRelative, true ), - matchers = [ function( elem, context, xml ) { - return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - (checkContext = context).nodeType ? - matchContext( elem, context, xml ) : - matchAnyContext( elem, context, xml ) ); - } ]; - - for ( ; i < len; i++ ) { - if ( (matcher = Expr.relative[ tokens[i].type ]) ) { - matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; - } else { - matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); - - // Return special upon seeing a positional matcher - if ( matcher[ expando ] ) { - // Find the next relative operator (if any) for proper handling - j = ++i; - for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[j].type ] ) { - break; - } - } - return setMatcher( - i > 1 && elementMatcher( matchers ), - i > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, "$1" ), - matcher, - i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), - j < len && toSelector( tokens ) - ); - } - matchers.push( matcher ); - } - } - - return elementMatcher( matchers ); -} - -function matcherFromGroupMatchers( elementMatchers, setMatchers ) { - // A counter to specify which element is currently being matched - var matcherCachedRuns = 0, - bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function( seed, context, xml, results, expandContext ) { - var elem, j, matcher, - setMatched = [], - matchedCount = 0, - i = "0", - unmatched = seed && [], - outermost = expandContext != null, - contextBackup = outermostContext, - // We must always have either seed elements or context - elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ), - // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1); - - if ( outermost ) { - outermostContext = context !== document && context; - cachedruns = matcherCachedRuns; - } - - // Add elements passing elementMatchers directly to results - // Keep `i` a string if there are no elements so `matchedCount` will be "00" below - for ( ; (elem = elems[i]) != null; i++ ) { - if ( byElement && elem ) { - j = 0; - while ( (matcher = elementMatchers[j++]) ) { - if ( matcher( elem, context, xml ) ) { - results.push( elem ); - break; - } - } - if ( outermost ) { - dirruns = dirrunsUnique; - cachedruns = ++matcherCachedRuns; - } - } - - // Track unmatched elements for set filters - if ( bySet ) { - // They will have gone through all possible matchers - if ( (elem = !matcher && elem) ) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if ( seed ) { - unmatched.push( elem ); - } - } - } - - // Apply set filters to unmatched elements - matchedCount += i; - if ( bySet && i !== matchedCount ) { - j = 0; - while ( (matcher = setMatchers[j++]) ) { - matcher( unmatched, setMatched, context, xml ); - } - - if ( seed ) { - // Reintegrate element matches to eliminate the need for sorting - if ( matchedCount > 0 ) { - while ( i-- ) { - if ( !(unmatched[i] || setMatched[i]) ) { - setMatched[i] = pop.call( results ); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense( setMatched ); - } - - // Add matches to results - push.apply( results, setMatched ); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if ( outermost && !seed && setMatched.length > 0 && - ( matchedCount + setMatchers.length ) > 1 ) { - - Sizzle.uniqueSort( results ); - } - } - - // Override manipulation of globals by nested matchers - if ( outermost ) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - return bySet ? - markFunction( superMatcher ) : - superMatcher; -} - -compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ selector + " " ]; - - if ( !cached ) { - // Generate a function of recursive functions that can be used to check each element - if ( !group ) { - group = tokenize( selector ); - } - i = group.length; - while ( i-- ) { - cached = matcherFromTokens( group[i] ); - if ( cached[ expando ] ) { - setMatchers.push( cached ); - } else { - elementMatchers.push( cached ); - } - } - - // Cache the compiled function - cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); - } - return cached; -}; - -function multipleContexts( selector, contexts, results ) { - var i = 0, - len = contexts.length; - for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results ); - } - return results; -} - -function select( selector, context, results, seed ) { - var i, tokens, token, type, find, - match = tokenize( selector ); - - if ( !seed ) { - // Try to minimize operations if there is only one group - if ( match.length === 1 ) { - - // Take a shortcut and set the context if the root selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - context.nodeType === 9 && !documentIsXML && - Expr.relative[ tokens[1].type ] ) { - - context = Expr.find["ID"]( token.matches[0].replace( runescape, funescape ), context )[0]; - if ( !context ) { - return results; - } - - selector = selector.slice( tokens.shift().value.length ); - } - - // Fetch a seed set for right-to-left matching - i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; - while ( i-- ) { - token = tokens[i]; - - // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { - break; - } - if ( (find = Expr.find[ type ]) ) { - // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( runescape, funescape ), - rsibling.test( tokens[0].type ) && context.parentNode || context - )) ) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice( i, 1 ); - selector = seed.length && toSelector( tokens ); - if ( !selector ) { - push.apply( results, slice.call( seed, 0 ) ); - return results; - } - - break; - } - } - } - } - } - - // Compile and execute a filtering function - // Provide `match` to avoid retokenization if we modified the selector above - compile( selector, match )( - seed, - context, - documentIsXML, - results, - rsibling.test( selector ) - ); - return results; -} - -// Deprecated -Expr.pseudos["nth"] = Expr.pseudos["eq"]; - -// Easy API for creating new setFilters -function setFilters() {} -Expr.filters = setFilters.prototype = Expr.pseudos; -Expr.setFilters = new setFilters(); - -// Initialize with the default document -setDocument(); - -// Override sizzle attribute retrieval -Sizzle.attr = jQuery.attr; -jQuery.find = Sizzle; -jQuery.expr = Sizzle.selectors; -jQuery.expr[":"] = jQuery.expr.pseudos; -jQuery.unique = Sizzle.uniqueSort; -jQuery.text = Sizzle.getText; -jQuery.isXMLDoc = Sizzle.isXML; -jQuery.contains = Sizzle.contains; - - -})( window ); -var runtil = /Until$/, - rparentsprev = /^(?:parents|prev(?:Until|All))/, - isSimple = /^.[^:#\[\.,]*$/, - rneedsContext = jQuery.expr.match.needsContext, - // methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - -jQuery.fn.extend({ - find: function( selector ) { - var i, ret, self, - len = this.length; - - if ( typeof selector !== "string" ) { - self = this; - return this.pushStack( jQuery( selector ).filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( self[ i ], this ) ) { - return true; - } - } - }) ); - } - - ret = []; - for ( i = 0; i < len; i++ ) { - jQuery.find( selector, this[ i ], ret ); - } - - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); - ret.selector = ( this.selector ? this.selector + " " : "" ) + selector; - return ret; - }, - - has: function( target ) { - var i, - targets = jQuery( target, this ), - len = targets.length; - - return this.filter(function() { - for ( i = 0; i < len; i++ ) { - if ( jQuery.contains( this, targets[i] ) ) { - return true; - } - } - }); - }, - - not: function( selector ) { - return this.pushStack( winnow(this, selector, false) ); - }, - - filter: function( selector ) { - return this.pushStack( winnow(this, selector, true) ); - }, - - is: function( selector ) { - return !!selector && ( - typeof selector === "string" ? - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - rneedsContext.test( selector ) ? - jQuery( selector, this.context ).index( this[0] ) >= 0 : - jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0 ); - }, - - closest: function( selectors, context ) { - var cur, - i = 0, - l = this.length, - ret = [], - pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? - jQuery( selectors, context || this.context ) : - 0; - - for ( ; i < l; i++ ) { - cur = this[i]; - - while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { - if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { - ret.push( cur ); - break; - } - cur = cur.parentNode; - } - } - - return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret ); - }, - - // Determine the position of an element within - // the matched set of elements - index: function( elem ) { - - // No argument, return index in parent - if ( !elem ) { - return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; - } - - // index in selector - if ( typeof elem === "string" ) { - return jQuery.inArray( this[0], jQuery( elem ) ); - } - - // Locate the position of the desired element - return jQuery.inArray( - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[0] : elem, this ); - }, - - add: function( selector, context ) { - var set = typeof selector === "string" ? - jQuery( selector, context ) : - jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), - all = jQuery.merge( this.get(), set ); - - return this.pushStack( jQuery.unique(all) ); - }, - - addBack: function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter(selector) - ); - } -}); - -jQuery.fn.andSelf = jQuery.fn.addBack; - -function sibling( cur, dir ) { - do { - cur = cur[ dir ]; - } while ( cur && cur.nodeType !== 1 ); - - return cur; -} - -jQuery.each({ - parent: function( elem ) { - var parent = elem.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function( elem ) { - return jQuery.dir( elem, "parentNode" ); - }, - parentsUntil: function( elem, i, until ) { - return jQuery.dir( elem, "parentNode", until ); - }, - next: function( elem ) { - return sibling( elem, "nextSibling" ); - }, - prev: function( elem ) { - return sibling( elem, "previousSibling" ); - }, - nextAll: function( elem ) { - return jQuery.dir( elem, "nextSibling" ); - }, - prevAll: function( elem ) { - return jQuery.dir( elem, "previousSibling" ); - }, - nextUntil: function( elem, i, until ) { - return jQuery.dir( elem, "nextSibling", until ); - }, - prevUntil: function( elem, i, until ) { - return jQuery.dir( elem, "previousSibling", until ); - }, - siblings: function( elem ) { - return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); - }, - children: function( elem ) { - return jQuery.sibling( elem.firstChild ); - }, - contents: function( elem ) { - return jQuery.nodeName( elem, "iframe" ) ? - elem.contentDocument || elem.contentWindow.document : - jQuery.merge( [], elem.childNodes ); - } -}, function( name, fn ) { - jQuery.fn[ name ] = function( until, selector ) { - var ret = jQuery.map( this, fn, until ); - - if ( !runtil.test( name ) ) { - selector = until; - } - - if ( selector && typeof selector === "string" ) { - ret = jQuery.filter( selector, ret ); - } - - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; - - if ( this.length > 1 && rparentsprev.test( name ) ) { - ret = ret.reverse(); - } - - return this.pushStack( ret ); - }; -}); - -jQuery.extend({ - filter: function( expr, elems, not ) { - if ( not ) { - expr = ":not(" + expr + ")"; - } - - return elems.length === 1 ? - jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : - jQuery.find.matches(expr, elems); - }, - - dir: function( elem, dir, until ) { - var matched = [], - cur = elem[ dir ]; - - while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { - if ( cur.nodeType === 1 ) { - matched.push( cur ); - } - cur = cur[dir]; - } - return matched; - }, - - sibling: function( n, elem ) { - var r = []; - - for ( ; n; n = n.nextSibling ) { - if ( n.nodeType === 1 && n !== elem ) { - r.push( n ); - } - } - - return r; - } -}); - -// Implement the identical functionality for filter and not -function winnow( elements, qualifier, keep ) { - - // Can't pass null or undefined to indexOf in Firefox 4 - // Set to 0 to skip string check - qualifier = qualifier || 0; - - if ( jQuery.isFunction( qualifier ) ) { - return jQuery.grep(elements, function( elem, i ) { - var retVal = !!qualifier.call( elem, i, elem ); - return retVal === keep; - }); - - } else if ( qualifier.nodeType ) { - return jQuery.grep(elements, function( elem ) { - return ( elem === qualifier ) === keep; - }); - - } else if ( typeof qualifier === "string" ) { - var filtered = jQuery.grep(elements, function( elem ) { - return elem.nodeType === 1; - }); - - if ( isSimple.test( qualifier ) ) { - return jQuery.filter(qualifier, filtered, !keep); - } else { - qualifier = jQuery.filter( qualifier, filtered ); - } - } - - return jQuery.grep(elements, function( elem ) { - return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; - }); -} -function createSafeFragment( document ) { - var list = nodeNames.split( "|" ), - safeFrag = document.createDocumentFragment(); - - if ( safeFrag.createElement ) { - while ( list.length ) { - safeFrag.createElement( - list.pop() - ); - } - } - return safeFrag; -} - -var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + - "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", - rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, - rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), - rleadingWhitespace = /^\s+/, - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, - rtagName = /<([\w:]+)/, - rtbody = /\s*$/g, - - // We have to close these tags to support XHTML (#13200) - wrapMap = { - option: [ 1, "" ], - legend: [ 1, "
", "
" ], - area: [ 1, "", "" ], - param: [ 1, "", "" ], - thead: [ 1, "", "
" ], - tr: [ 2, "", "
" ], - col: [ 2, "", "
" ], - td: [ 3, "", "
" ], - - // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, - // unless wrapped in a div with non-breaking characters in front of it. - _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
", "
" ] - }, - safeFragment = createSafeFragment( document ), - fragmentDiv = safeFragment.appendChild( document.createElement("div") ); - -wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; -wrapMap.th = wrapMap.td; - -jQuery.fn.extend({ - text: function( value ) { - return jQuery.access( this, function( value ) { - return value === undefined ? - jQuery.text( this ) : - this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); - }, null, value, arguments.length ); - }, - - wrapAll: function( html ) { - if ( jQuery.isFunction( html ) ) { - return this.each(function(i) { - jQuery(this).wrapAll( html.call(this, i) ); - }); - } - - if ( this[0] ) { - // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); - - if ( this[0].parentNode ) { - wrap.insertBefore( this[0] ); - } - - wrap.map(function() { - var elem = this; - - while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { - elem = elem.firstChild; - } - - return elem; - }).append( this ); - } - - return this; - }, - - wrapInner: function( html ) { - if ( jQuery.isFunction( html ) ) { - return this.each(function(i) { - jQuery(this).wrapInner( html.call(this, i) ); - }); - } - - return this.each(function() { - var self = jQuery( this ), - contents = self.contents(); - - if ( contents.length ) { - contents.wrapAll( html ); - - } else { - self.append( html ); - } - }); - }, - - wrap: function( html ) { - var isFunction = jQuery.isFunction( html ); - - return this.each(function(i) { - jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); - }); - }, - - unwrap: function() { - return this.parent().each(function() { - if ( !jQuery.nodeName( this, "body" ) ) { - jQuery( this ).replaceWith( this.childNodes ); - } - }).end(); - }, - - append: function() { - return this.domManip(arguments, true, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - this.appendChild( elem ); - } - }); - }, - - prepend: function() { - return this.domManip(arguments, true, function( elem ) { - if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { - this.insertBefore( elem, this.firstChild ); - } - }); - }, - - before: function() { - return this.domManip( arguments, false, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this ); - } - }); - }, - - after: function() { - return this.domManip( arguments, false, function( elem ) { - if ( this.parentNode ) { - this.parentNode.insertBefore( elem, this.nextSibling ); - } - }); - }, - - // keepData is for internal use only--do not document - remove: function( selector, keepData ) { - var elem, - i = 0; - - for ( ; (elem = this[i]) != null; i++ ) { - if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) { - if ( !keepData && elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem ) ); - } - - if ( elem.parentNode ) { - if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { - setGlobalEval( getAll( elem, "script" ) ); - } - elem.parentNode.removeChild( elem ); - } - } - } - - return this; - }, - - empty: function() { - var elem, - i = 0; - - for ( ; (elem = this[i]) != null; i++ ) { - // Remove element nodes and prevent memory leaks - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - } - - // Remove any remaining nodes - while ( elem.firstChild ) { - elem.removeChild( elem.firstChild ); - } - - // If this is a select, ensure that it displays empty (#12336) - // Support: IE<9 - if ( elem.options && jQuery.nodeName( elem, "select" ) ) { - elem.options.length = 0; - } - } - - return this; - }, - - clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - - return this.map( function () { - return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); - }); - }, - - html: function( value ) { - return jQuery.access( this, function( value ) { - var elem = this[0] || {}, - i = 0, - l = this.length; - - if ( value === undefined ) { - return elem.nodeType === 1 ? - elem.innerHTML.replace( rinlinejQuery, "" ) : - undefined; - } - - // See if we can take a shortcut and just use innerHTML - if ( typeof value === "string" && !rnoInnerhtml.test( value ) && - ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && - ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && - !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { - - value = value.replace( rxhtmlTag, "<$1>" ); - - try { - for (; i < l; i++ ) { - // Remove element nodes and prevent memory leaks - elem = this[i] || {}; - if ( elem.nodeType === 1 ) { - jQuery.cleanData( getAll( elem, false ) ); - elem.innerHTML = value; - } - } - - elem = 0; - - // If using innerHTML throws an exception, use the fallback method - } catch(e) {} - } - - if ( elem ) { - this.empty().append( value ); - } - }, null, value, arguments.length ); - }, - - replaceWith: function( value ) { - var isFunc = jQuery.isFunction( value ); - - // Make sure that the elements are removed from the DOM before they are inserted - // this can help fix replacing a parent with child elements - if ( !isFunc && typeof value !== "string" ) { - value = jQuery( value ).not( this ).detach(); - } - - return this.domManip( [ value ], true, function( elem ) { - var next = this.nextSibling, - parent = this.parentNode; - - if ( parent ) { - jQuery( this ).remove(); - parent.insertBefore( elem, next ); - } - }); - }, - - detach: function( selector ) { - return this.remove( selector, true ); - }, - - domManip: function( args, table, callback ) { - - // Flatten any nested arrays - args = core_concat.apply( [], args ); - - var first, node, hasScripts, - scripts, doc, fragment, - i = 0, - l = this.length, - set = this, - iNoClone = l - 1, - value = args[0], - isFunction = jQuery.isFunction( value ); - - // We can't cloneNode fragments that contain checked, in WebKit - if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) { - return this.each(function( index ) { - var self = set.eq( index ); - if ( isFunction ) { - args[0] = value.call( this, index, table ? self.html() : undefined ); - } - self.domManip( args, table, callback ); - }); - } - - if ( l ) { - fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); - first = fragment.firstChild; - - if ( fragment.childNodes.length === 1 ) { - fragment = first; - } - - if ( first ) { - table = table && jQuery.nodeName( first, "tr" ); - scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); - hasScripts = scripts.length; - - // Use the original fragment for the last item instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - for ( ; i < l; i++ ) { - node = fragment; - - if ( i !== iNoClone ) { - node = jQuery.clone( node, true, true ); - - // Keep references to cloned scripts for later restoration - if ( hasScripts ) { - jQuery.merge( scripts, getAll( node, "script" ) ); - } - } - - callback.call( - table && jQuery.nodeName( this[i], "table" ) ? - findOrAppend( this[i], "tbody" ) : - this[i], - node, - i - ); - } - - if ( hasScripts ) { - doc = scripts[ scripts.length - 1 ].ownerDocument; - - // Reenable scripts - jQuery.map( scripts, restoreScript ); - - // Evaluate executable scripts on first document insertion - for ( i = 0; i < hasScripts; i++ ) { - node = scripts[ i ]; - if ( rscriptType.test( node.type || "" ) && - !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { - - if ( node.src ) { - // Hope ajax is available... - jQuery.ajax({ - url: node.src, - type: "GET", - dataType: "script", - async: false, - global: false, - "throws": true - }); - } else { - jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); - } - } - } - } - - // Fix #11809: Avoid leaking memory - fragment = first = null; - } - } - - return this; - } -}); - -function findOrAppend( elem, tag ) { - return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); -} - -// Replace/restore the type attribute of script elements for safe DOM manipulation -function disableScript( elem ) { - var attr = elem.getAttributeNode("type"); - elem.type = ( attr && attr.specified ) + "/" + elem.type; - return elem; -} -function restoreScript( elem ) { - var match = rscriptTypeMasked.exec( elem.type ); - if ( match ) { - elem.type = match[1]; - } else { - elem.removeAttribute("type"); - } - return elem; -} - -// Mark scripts as having already been evaluated -function setGlobalEval( elems, refElements ) { - var elem, - i = 0; - for ( ; (elem = elems[i]) != null; i++ ) { - jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) ); - } -} - -function cloneCopyEvent( src, dest ) { - - if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { - return; - } - - var type, i, l, - oldData = jQuery._data( src ), - curData = jQuery._data( dest, oldData ), - events = oldData.events; - - if ( events ) { - delete curData.handle; - curData.events = {}; - - for ( type in events ) { - for ( i = 0, l = events[ type ].length; i < l; i++ ) { - jQuery.event.add( dest, type, events[ type ][ i ] ); - } - } - } - - // make the cloned public data object a copy from the original - if ( curData.data ) { - curData.data = jQuery.extend( {}, curData.data ); - } -} - -function fixCloneNodeIssues( src, dest ) { - var nodeName, e, data; - - // We do not need to do anything for non-Elements - if ( dest.nodeType !== 1 ) { - return; - } - - nodeName = dest.nodeName.toLowerCase(); - - // IE6-8 copies events bound via attachEvent when using cloneNode. - if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) { - data = jQuery._data( dest ); - - for ( e in data.events ) { - jQuery.removeEvent( dest, e, data.handle ); - } - - // Event data gets referenced instead of copied if the expando gets copied too - dest.removeAttribute( jQuery.expando ); - } - - // IE blanks contents when cloning scripts, and tries to evaluate newly-set text - if ( nodeName === "script" && dest.text !== src.text ) { - disableScript( dest ).text = src.text; - restoreScript( dest ); - - // IE6-10 improperly clones children of object elements using classid. - // IE10 throws NoModificationAllowedError if parent is null, #12132. - } else if ( nodeName === "object" ) { - if ( dest.parentNode ) { - dest.outerHTML = src.outerHTML; - } - - // This path appears unavoidable for IE9. When cloning an object - // element in IE9, the outerHTML strategy above is not sufficient. - // If the src has innerHTML and the destination does not, - // copy the src.innerHTML into the dest.innerHTML. #10324 - if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { - dest.innerHTML = src.innerHTML; - } - - } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) { - // IE6-8 fails to persist the checked state of a cloned checkbox - // or radio button. Worse, IE6-7 fail to give the cloned element - // a checked appearance if the defaultChecked value isn't also set - - dest.defaultChecked = dest.checked = src.checked; - - // IE6-7 get confused and end up setting the value of a cloned - // checkbox/radio button to an empty string instead of "on" - if ( dest.value !== src.value ) { - dest.value = src.value; - } - - // IE6-8 fails to return the selected option to the default selected - // state when cloning options - } else if ( nodeName === "option" ) { - dest.defaultSelected = dest.selected = src.defaultSelected; - - // IE6-8 fails to set the defaultValue to the correct value when - // cloning other types of input fields - } else if ( nodeName === "input" || nodeName === "textarea" ) { - dest.defaultValue = src.defaultValue; - } -} - -jQuery.each({ - appendTo: "append", - prependTo: "prepend", - insertBefore: "before", - insertAfter: "after", - replaceAll: "replaceWith" -}, function( name, original ) { - jQuery.fn[ name ] = function( selector ) { - var elems, - i = 0, - ret = [], - insert = jQuery( selector ), - last = insert.length - 1; - - for ( ; i <= last; i++ ) { - elems = i === last ? this : this.clone(true); - jQuery( insert[i] )[ original ]( elems ); - - // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() - core_push.apply( ret, elems.get() ); - } - - return this.pushStack( ret ); - }; -}); - -function getAll( context, tag ) { - var elems, elem, - i = 0, - found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) : - typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) : - undefined; - - if ( !found ) { - for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) { - if ( !tag || jQuery.nodeName( elem, tag ) ) { - found.push( elem ); - } else { - jQuery.merge( found, getAll( elem, tag ) ); - } - } - } - - return tag === undefined || tag && jQuery.nodeName( context, tag ) ? - jQuery.merge( [ context ], found ) : - found; -} - -// Used in buildFragment, fixes the defaultChecked property -function fixDefaultChecked( elem ) { - if ( manipulation_rcheckableType.test( elem.type ) ) { - elem.defaultChecked = elem.checked; - } -} - -jQuery.extend({ - clone: function( elem, dataAndEvents, deepDataAndEvents ) { - var destElements, node, clone, i, srcElements, - inPage = jQuery.contains( elem.ownerDocument, elem ); - - if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { - clone = elem.cloneNode( true ); - - // IE<=8 does not properly clone detached, unknown element nodes - } else { - fragmentDiv.innerHTML = elem.outerHTML; - fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); - } - - if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && - (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { - - // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 - destElements = getAll( clone ); - srcElements = getAll( elem ); - - // Fix all IE cloning issues - for ( i = 0; (node = srcElements[i]) != null; ++i ) { - // Ensure that the destination node is not null; Fixes #9587 - if ( destElements[i] ) { - fixCloneNodeIssues( node, destElements[i] ); - } - } - } - - // Copy the events from the original to the clone - if ( dataAndEvents ) { - if ( deepDataAndEvents ) { - srcElements = srcElements || getAll( elem ); - destElements = destElements || getAll( clone ); - - for ( i = 0; (node = srcElements[i]) != null; i++ ) { - cloneCopyEvent( node, destElements[i] ); - } - } else { - cloneCopyEvent( elem, clone ); - } - } - - // Preserve script evaluation history - destElements = getAll( clone, "script" ); - if ( destElements.length > 0 ) { - setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); - } - - destElements = srcElements = node = null; - - // Return the cloned set - return clone; - }, - - buildFragment: function( elems, context, scripts, selection ) { - var j, elem, contains, - tmp, tag, tbody, wrap, - l = elems.length, - - // Ensure a safe fragment - safe = createSafeFragment( context ), - - nodes = [], - i = 0; - - for ( ; i < l; i++ ) { - elem = elems[ i ]; - - if ( elem || elem === 0 ) { - - // Add nodes directly - if ( jQuery.type( elem ) === "object" ) { - jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); - - // Convert non-html into a text node - } else if ( !rhtml.test( elem ) ) { - nodes.push( context.createTextNode( elem ) ); - - // Convert html into DOM nodes - } else { - tmp = tmp || safe.appendChild( context.createElement("div") ); - - // Deserialize a standard representation - tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); - wrap = wrapMap[ tag ] || wrapMap._default; - - tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[2]; - - // Descend through wrappers to the right content - j = wrap[0]; - while ( j-- ) { - tmp = tmp.lastChild; - } - - // Manually add leading whitespace removed by IE - if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { - nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); - } - - // Remove IE's autoinserted from table fragments - if ( !jQuery.support.tbody ) { - - // String was a , *may* have spurious - elem = tag === "table" && !rtbody.test( elem ) ? - tmp.firstChild : - - // String was a bare or - wrap[1] === "
" && !rtbody.test( elem ) ? - tmp : - 0; - - j = elem && elem.childNodes.length; - while ( j-- ) { - if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { - elem.removeChild( tbody ); - } - } - } - - jQuery.merge( nodes, tmp.childNodes ); - - // Fix #12392 for WebKit and IE > 9 - tmp.textContent = ""; - - // Fix #12392 for oldIE - while ( tmp.firstChild ) { - tmp.removeChild( tmp.firstChild ); - } - - // Remember the top-level container for proper cleanup - tmp = safe.lastChild; - } - } - } - - // Fix #11356: Clear elements from fragment - if ( tmp ) { - safe.removeChild( tmp ); - } - - // Reset defaultChecked for any radios and checkboxes - // about to be appended to the DOM in IE 6/7 (#8060) - if ( !jQuery.support.appendChecked ) { - jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); - } - - i = 0; - while ( (elem = nodes[ i++ ]) ) { - - // #4087 - If origin and destination elements are the same, and this is - // that element, do not do anything - if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { - continue; - } - - contains = jQuery.contains( elem.ownerDocument, elem ); - - // Append to fragment - tmp = getAll( safe.appendChild( elem ), "script" ); - - // Preserve script evaluation history - if ( contains ) { - setGlobalEval( tmp ); - } - - // Capture executables - if ( scripts ) { - j = 0; - while ( (elem = tmp[ j++ ]) ) { - if ( rscriptType.test( elem.type || "" ) ) { - scripts.push( elem ); - } - } - } - } - - tmp = null; - - return safe; - }, - - cleanData: function( elems, /* internal */ acceptData ) { - var elem, type, id, data, - i = 0, - internalKey = jQuery.expando, - cache = jQuery.cache, - deleteExpando = jQuery.support.deleteExpando, - special = jQuery.event.special; - - for ( ; (elem = elems[i]) != null; i++ ) { - - if ( acceptData || jQuery.acceptData( elem ) ) { - - id = elem[ internalKey ]; - data = id && cache[ id ]; - - if ( data ) { - if ( data.events ) { - for ( type in data.events ) { - if ( special[ type ] ) { - jQuery.event.remove( elem, type ); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent( elem, type, data.handle ); - } - } - } - - // Remove cache only if it was not already removed by jQuery.event.remove - if ( cache[ id ] ) { - - delete cache[ id ]; - - // IE does not allow us to delete expando properties from nodes, - // nor does it have a removeAttribute function on Document nodes; - // we must handle all of these cases - if ( deleteExpando ) { - delete elem[ internalKey ]; - - } else if ( typeof elem.removeAttribute !== core_strundefined ) { - elem.removeAttribute( internalKey ); - - } else { - elem[ internalKey ] = null; - } - - core_deletedIds.push( id ); - } - } - } - } - } -}); -var iframe, getStyles, curCSS, - ralpha = /alpha\([^)]*\)/i, - ropacity = /opacity\s*=\s*([^)]*)/, - rposition = /^(top|right|bottom|left)$/, - // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" - // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display - rdisplayswap = /^(none|table(?!-c[ea]).+)/, - rmargin = /^margin/, - rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), - rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), - rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ), - elemdisplay = { BODY: "block" }, - - cssShow = { position: "absolute", visibility: "hidden", display: "block" }, - cssNormalTransform = { - letterSpacing: 0, - fontWeight: 400 - }, - - cssExpand = [ "Top", "Right", "Bottom", "Left" ], - cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; - -// return a css property mapped to a potentially vendor prefixed property -function vendorPropName( style, name ) { - - // shortcut for names that are not vendor prefixed - if ( name in style ) { - return name; - } - - // check for vendor prefixed names - var capName = name.charAt(0).toUpperCase() + name.slice(1), - origName = name, - i = cssPrefixes.length; - - while ( i-- ) { - name = cssPrefixes[ i ] + capName; - if ( name in style ) { - return name; - } - } - - return origName; -} - -function isHidden( elem, el ) { - // isHidden might be called from jQuery#filter function; - // in that case, element will be second argument - elem = el || elem; - return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); -} - -function showHide( elements, show ) { - var display, elem, hidden, - values = [], - index = 0, - length = elements.length; - - for ( ; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - - values[ index ] = jQuery._data( elem, "olddisplay" ); - display = elem.style.display; - if ( show ) { - // Reset the inline display of this element to learn if it is - // being hidden by cascaded rules or not - if ( !values[ index ] && display === "none" ) { - elem.style.display = ""; - } - - // Set elements which have been overridden with display: none - // in a stylesheet to whatever the default browser style is - // for such an element - if ( elem.style.display === "" && isHidden( elem ) ) { - values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); - } - } else { - - if ( !values[ index ] ) { - hidden = isHidden( elem ); - - if ( display && display !== "none" || !hidden ) { - jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) ); - } - } - } - } - - // Set the display of most of the elements in a second loop - // to avoid the constant reflow - for ( index = 0; index < length; index++ ) { - elem = elements[ index ]; - if ( !elem.style ) { - continue; - } - if ( !show || elem.style.display === "none" || elem.style.display === "" ) { - elem.style.display = show ? values[ index ] || "" : "none"; - } - } - - return elements; -} - -jQuery.fn.extend({ - css: function( name, value ) { - return jQuery.access( this, function( elem, name, value ) { - var len, styles, - map = {}, - i = 0; - - if ( jQuery.isArray( name ) ) { - styles = getStyles( elem ); - len = name.length; - - for ( ; i < len; i++ ) { - map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); - } - - return map; - } - - return value !== undefined ? - jQuery.style( elem, name, value ) : - jQuery.css( elem, name ); - }, name, value, arguments.length > 1 ); - }, - show: function() { - return showHide( this, true ); - }, - hide: function() { - return showHide( this ); - }, - toggle: function( state ) { - var bool = typeof state === "boolean"; - - return this.each(function() { - if ( bool ? state : isHidden( this ) ) { - jQuery( this ).show(); - } else { - jQuery( this ).hide(); - } - }); - } -}); - -jQuery.extend({ - // Add in style property hooks for overriding the default - // behavior of getting and setting a style property - cssHooks: { - opacity: { - get: function( elem, computed ) { - if ( computed ) { - // We should always get a number back from opacity - var ret = curCSS( elem, "opacity" ); - return ret === "" ? "1" : ret; - } - } - } - }, - - // Exclude the following css properties to add px - cssNumber: { - "columnCount": true, - "fillOpacity": true, - "fontWeight": true, - "lineHeight": true, - "opacity": true, - "orphans": true, - "widows": true, - "zIndex": true, - "zoom": true - }, - - // Add in properties whose names you wish to fix before - // setting or getting the value - cssProps: { - // normalize float css property - "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" - }, - - // Get and set the style property on a DOM Node - style: function( elem, name, value, extra ) { - // Don't set styles on text and comment nodes - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { - return; - } - - // Make sure that we're working with the right name - var ret, type, hooks, - origName = jQuery.camelCase( name ), - style = elem.style; - - name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); - - // gets hook for the prefixed version - // followed by the unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // Check if we're setting a value - if ( value !== undefined ) { - type = typeof value; - - // convert relative number strings (+= or -=) to relative numbers. #7345 - if ( type === "string" && (ret = rrelNum.exec( value )) ) { - value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); - // Fixes bug #9237 - type = "number"; - } - - // Make sure that NaN and null values aren't set. See: #7116 - if ( value == null || type === "number" && isNaN( value ) ) { - return; - } - - // If a number was passed in, add 'px' to the (except for certain CSS properties) - if ( type === "number" && !jQuery.cssNumber[ origName ] ) { - value += "px"; - } - - // Fixes #8908, it can be done more correctly by specifing setters in cssHooks, - // but it would mean to define eight (for every problematic property) identical functions - if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) { - style[ name ] = "inherit"; - } - - // If a hook was provided, use that value, otherwise just set the specified value - if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { - - // Wrapped to prevent IE from throwing errors when 'invalid' values are provided - // Fixes bug #5509 - try { - style[ name ] = value; - } catch(e) {} - } - - } else { - // If a hook was provided get the non-computed value from there - if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { - return ret; - } - - // Otherwise just get the value from the style object - return style[ name ]; - } - }, - - css: function( elem, name, extra, styles ) { - var num, val, hooks, - origName = jQuery.camelCase( name ); - - // Make sure that we're working with the right name - name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); - - // gets hook for the prefixed version - // followed by the unprefixed version - hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; - - // If a hook was provided get the computed value from there - if ( hooks && "get" in hooks ) { - val = hooks.get( elem, true, extra ); - } - - // Otherwise, if a way to get the computed value exists, use that - if ( val === undefined ) { - val = curCSS( elem, name, styles ); - } - - //convert "normal" to computed value - if ( val === "normal" && name in cssNormalTransform ) { - val = cssNormalTransform[ name ]; - } - - // Return, converting to number if forced or a qualifier was provided and val looks numeric - if ( extra === "" || extra ) { - num = parseFloat( val ); - return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; - } - return val; - }, - - // A method for quickly swapping in/out CSS properties to get correct calculations - swap: function( elem, options, callback, args ) { - var ret, name, - old = {}; - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.apply( elem, args || [] ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; - } -}); - -// NOTE: we've included the "window" in window.getComputedStyle -// because jsdom on node.js will break without it. -if ( window.getComputedStyle ) { - getStyles = function( elem ) { - return window.getComputedStyle( elem, null ); - }; - - curCSS = function( elem, name, _computed ) { - var width, minWidth, maxWidth, - computed = _computed || getStyles( elem ), - - // getPropertyValue is only needed for .css('filter') in IE9, see #12537 - ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined, - style = elem.style; - - if ( computed ) { - - if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { - ret = jQuery.style( elem, name ); - } - - // A tribute to the "awesome hack by Dean Edwards" - // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right - // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels - // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values - if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { - - // Remember the original values - width = style.width; - minWidth = style.minWidth; - maxWidth = style.maxWidth; - - // Put in the new values to get a computed value out - style.minWidth = style.maxWidth = style.width = ret; - ret = computed.width; - - // Revert the changed values - style.width = width; - style.minWidth = minWidth; - style.maxWidth = maxWidth; - } - } - - return ret; - }; -} else if ( document.documentElement.currentStyle ) { - getStyles = function( elem ) { - return elem.currentStyle; - }; - - curCSS = function( elem, name, _computed ) { - var left, rs, rsLeft, - computed = _computed || getStyles( elem ), - ret = computed ? computed[ name ] : undefined, - style = elem.style; - - // Avoid setting ret to empty string here - // so we don't default to auto - if ( ret == null && style && style[ name ] ) { - ret = style[ name ]; - } - - // From the awesome hack by Dean Edwards - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 - - // If we're not dealing with a regular pixel number - // but a number that has a weird ending, we need to convert it to pixels - // but not position css attributes, as those are proportional to the parent element instead - // and we can't measure the parent instead because it might trigger a "stacking dolls" problem - if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { - - // Remember the original values - left = style.left; - rs = elem.runtimeStyle; - rsLeft = rs && rs.left; - - // Put in the new values to get a computed value out - if ( rsLeft ) { - rs.left = elem.currentStyle.left; - } - style.left = name === "fontSize" ? "1em" : ret; - ret = style.pixelLeft + "px"; - - // Revert the changed values - style.left = left; - if ( rsLeft ) { - rs.left = rsLeft; - } - } - - return ret === "" ? "auto" : ret; - }; -} - -function setPositiveNumber( elem, value, subtract ) { - var matches = rnumsplit.exec( value ); - return matches ? - // Guard against undefined "subtract", e.g., when used as in cssHooks - Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : - value; -} - -function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { - var i = extra === ( isBorderBox ? "border" : "content" ) ? - // If we already have the right measurement, avoid augmentation - 4 : - // Otherwise initialize for horizontal or vertical properties - name === "width" ? 1 : 0, - - val = 0; - - for ( ; i < 4; i += 2 ) { - // both box models exclude margin, so add it if we want it - if ( extra === "margin" ) { - val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); - } - - if ( isBorderBox ) { - // border-box includes padding, so remove it if we want content - if ( extra === "content" ) { - val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - } - - // at this point, extra isn't border nor margin, so remove border - if ( extra !== "margin" ) { - val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } - } else { - // at this point, extra isn't content, so add padding - val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); - - // at this point, extra isn't content nor padding, so add border - if ( extra !== "padding" ) { - val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); - } - } - } - - return val; -} - -function getWidthOrHeight( elem, name, extra ) { - - // Start with offset property, which is equivalent to the border-box value - var valueIsBorderBox = true, - val = name === "width" ? elem.offsetWidth : elem.offsetHeight, - styles = getStyles( elem ), - isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; - - // some non-html elements return undefined for offsetWidth, so check for null/undefined - // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 - // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 - if ( val <= 0 || val == null ) { - // Fall back to computed then uncomputed css if necessary - val = curCSS( elem, name, styles ); - if ( val < 0 || val == null ) { - val = elem.style[ name ]; - } - - // Computed unit is not pixels. Stop here and return. - if ( rnumnonpx.test(val) ) { - return val; - } - - // we need the check for style in case a browser which returns unreliable values - // for getComputedStyle silently falls back to the reliable elem.style - valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); - - // Normalize "", auto, and prepare for extra - val = parseFloat( val ) || 0; - } - - // use the active box-sizing model to add/subtract irrelevant styles - return ( val + - augmentWidthOrHeight( - elem, - name, - extra || ( isBorderBox ? "border" : "content" ), - valueIsBorderBox, - styles - ) - ) + "px"; -} - -// Try to determine the default display value of an element -function css_defaultDisplay( nodeName ) { - var doc = document, - display = elemdisplay[ nodeName ]; - - if ( !display ) { - display = actualDisplay( nodeName, doc ); - - // If the simple way fails, read from inside an iframe - if ( display === "none" || !display ) { - // Use the already-created iframe if possible - iframe = ( iframe || - jQuery("