diff --git a/dist/base.css b/dist/base.css index 28a218f98..693b8e67d 100644 --- a/dist/base.css +++ b/dist/base.css @@ -653,350 +653,6 @@ -moz-border-radius: 2px; border-radius: 2px; } -.farbtastic .wheel { - background: url('images/1x/background/wheel.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/wheel.png'); - _background: none; -} -.farbtastic .overlay { - background: url('images/1x/background/mask.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/mask.png'); - _background: none; -} -.farbtastic .marker { - background: url('images/1x/background/marker.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/marker.png'); - _background: none; -} -.bi-display-tree .ztree li span.button.switch.center_open { - background: url('images/1x/icon/tree_vertical_line_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_3.png'); - _background: none; -} -.bi-display-tree .ztree li span.button.switch.roots_open { - background: url('images/1x/icon/tree_vertical_line_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_2.png'); - _background: none; -} -.bi-display-tree .ztree li span.button.switch.bottom_open { - background: url('images/1x/icon/tree_vertical_line_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_4.png'); - _background: none; -} -.ztree li ul.line { - background: url('images/1x/icon/tree_vertical_line_1.png') repeat-y 1px 0; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_1.png'); - _background: none; -} -.bi-theme-dark .ztree li ul.line { - background: url('images/1x/icon/dark/tree_vertical_line_1.png') repeat-y 1px 0; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_1.png'); - _background: none; -} -.ztree li span.button.chk.checkbox_false_full { - background: url('images/2x/icon/check_box_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/check_box_normal.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_false_full_focus { - background: url('images/2x/icon/check_box_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/check_box_normal.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_false_part { - background: url('images/2x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/half_selected.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_false_part_focus { - background: url('images/2x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/half_selected.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_true_full { - background: url('images/2x/icon/check_box_active.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/check_box_active.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_true_full_focus { - background: url('images/2x/icon/check_box_active.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/check_box_active.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_true_part { - background: url('images/2x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/half_selected.png'); - background-size: contain; - _background: none; -} -.ztree li span.button.chk.checkbox_true_part_focus { - background: url('images/2x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/half_selected.png'); - background-size: contain; - _background: none; -} -.ztree.hack li span.button.chk.checkbox_false_full { - background: url('images/1x/icon/check_box_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/check_box_normal.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_false_full_focus { - background: url('images/1x/icon/check_box_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/check_box_normal.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_false_part { - background: url('images/1x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/half_selected.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_false_part_focus { - background: url('images/1x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/half_selected.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_true_full { - background: url('images/1x/icon/check_box_active.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/check_box_active.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_true_full_focus { - background: url('images/1x/icon/check_box_active.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/check_box_active.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_true_part { - background: url('images/1x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/half_selected.png'); - _background: none; -} -.ztree.hack li span.button.chk.checkbox_true_part_focus { - background: url('images/1x/icon/half_selected.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/half_selected.png'); - _background: none; -} -.ztree li span.button.root_open { - background: url('images/1x/icon/tree_expand_1.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_expand_1.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.root_open { - background: url('images/1x/icon/dark/tree_expand_1.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_expand_1.png'); - _background: none; -} -.ztree li span.button.root_close { - background: url('images/1x/icon/tree_collapse_1.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_collapse_1.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.root_close { - background: url('images/1x/icon/dark/tree_collapse_1.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_collapse_1.png'); - _background: none; -} -.ztree li span.button.roots_open { - background: url('images/1x/icon/tree_expand_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_expand_2.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.roots_open { - background: url('images/1x/icon/dark/tree_expand_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_expand_2.png'); - _background: none; -} -.ztree li span.button.roots_close { - background: url('images/1x/icon/tree_collapse_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_collapse_2.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.roots_close { - background: url('images/1x/icon/dark/tree_collapse_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_collapse_2.png'); - _background: none; -} -.ztree li span.button.center_open { - background: url('images/1x/icon/tree_expand_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_expand_3.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.center_open { - background: url('images/1x/icon/dark/tree_expand_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_expand_3.png'); - _background: none; -} -.ztree li span.button.center_close { - background: url('images/1x/icon/tree_collapse_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_collapse_3.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.center_close { - background: url('images/1x/icon/dark/tree_collapse_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_collapse_3.png'); - _background: none; -} -.ztree li span.button.bottom_open { - background: url('images/1x/icon/tree_expand_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_expand_4.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.bottom_open { - background: url('images/1x/icon/dark/tree_expand_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_expand_4.png'); - _background: none; -} -.ztree li span.button.bottom_close { - background: url('images/1x/icon/tree_collapse_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_collapse_4.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.bottom_close { - background: url('images/1x/icon/dark/tree_collapse_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_collapse_4.png'); - _background: none; -} -.ztree li span.button.roots_docu { - background: url('images/1x/icon/tree_vertical_line_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_2.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.roots_docu { - background: url('images/1x/icon/dark/tree_vertical_line_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_2.png'); - _background: none; -} -.ztree li span.button.center_docu { - background: url('images/1x/icon/tree_vertical_line_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_3.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.center_docu { - background: url('images/1x/icon/dark/tree_vertical_line_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_3.png'); - _background: none; -} -.ztree li span.button.bottom_docu { - background: url('images/1x/icon/tree_vertical_line_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_4.png'); - _background: none; -} -.bi-theme-dark .ztree li span.button.bottom_docu { - background: url('images/1x/icon/dark/tree_vertical_line_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_4.png'); - _background: none; -} -.ztree li span.button.ico_loading { - background: url('images/1x/icon/loading.gif') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/loading.gif'); - _background: none; -} -.base-line-conn-background { - background: url('images/1x/icon/tree_vertical_line_1.png') repeat-y 0 0; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_1.png'); - _background: none; -} -.bi-theme-dark .base-line-conn-background { - background: url('images/1x/icon/dark/tree_vertical_line_1.png') repeat-y 0 0; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_1.png'); - _background: none; -} -.first-line-conn-background { - background: url('images/1x/icon/tree_vertical_line_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_2.png'); - _background: none; -} -.bi-theme-dark .first-line-conn-background { - background: url('images/1x/icon/dark/tree_vertical_line_2.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_2.png'); - _background: none; -} -.mid-line-conn-background { - background: url('images/1x/icon/tree_vertical_line_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_3.png'); - _background: none; -} -.bi-theme-dark .mid-line-conn-background { - background: url('images/1x/icon/dark/tree_vertical_line_3.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_3.png'); - _background: none; -} -.last-line-conn-background { - background: url('images/1x/icon/tree_vertical_line_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/tree_vertical_line_4.png'); - _background: none; -} -.bi-theme-dark .last-line-conn-background { - background: url('images/1x/icon/dark/tree_vertical_line_4.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/dark/tree_vertical_line_4.png'); - _background: none; -} -.loading-background { - background: url('images/2x/icon/loading.gif') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/loading.gif'); - background-size: contain; - _background: none; -} -.auto-color-background { - background: url('images/2x/background/auto_color.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/background/auto_color.png'); - background-size: contain; - _background: none; -} -.auto-color-normal-background { - background: url('images/2x/background/auto_color_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/background/auto_color_normal.png'); - background-size: contain; - _background: none; -} -.auto-color-normal-disabled-background { - background: url('images/2x/background/auto_color_normal_disable.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/background/auto_color_normal_disable.png'); - background-size: contain; - _background: none; -} -.trans-color-background { - background: url('images/2x/background/trans_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/background/trans_normal.png'); - background-size: contain; - _background: none; -} -.trans-color-disabled-background { - background: url('images/2x/background/trans_disable.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/background/trans_disable.png'); - background-size: contain; - _background: none; -} -.auto-color-background.hack { - background: url('images/1x/background/auto_color.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/auto_color.png'); - _background: none; -} -.auto-color-normal-background.hack { - background: url('images/1x/background/auto_color_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/auto_color_normal.png'); - _background: none; -} -.auto-color-normal-disabled-background.hack { - background: url('images/1x/background/auto_color_normal_disable.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/auto_color_normal_disable.png'); - _background: none; -} -.trans-color-background.hack { - background: url('images/1x/background/trans_normal.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/trans_normal.png'); - _background: none; -} -.trans-color-disabled-background.hack { - background: url('images/1x/background/trans_disable.png') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/background/trans_disable.png'); - _background: none; -} .bi-pane { min-height: 55px; } @@ -1004,12 +660,15 @@ background-color: rgba(247, 248, 250, 0); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00f7f8fa,endColorstr=#00f7f8fa); } +.bi-loading-widget { + font-size: 0; +} .bi-loading-widget div { background-color: rgba(54, 133, 242, 0.9); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#e63685f2,endColorstr=#e63685f2); - -webkit-border-radius: 2.5px; - -moz-border-radius: 2.5px; - border-radius: 2.5px; + -webkit-border-radius: 1.5px; + -moz-border-radius: 1.5px; + border-radius: 1.5px; -webkit-animation: loading-widget 0.8s infinite linear; -moz-animation: loading-widget 0.8s infinite linear; -ms-animation: loading-widget 0.8s infinite linear; @@ -1116,9 +775,8 @@ } } .bi-loading-widget.hack { - background: url('images/2x/icon/loading.gif') no-repeat center center; - _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/2x/icon/loading.gif'); - background-size: contain; + background: url('images/1x/icon/wave_loading.gif') no-repeat center center; + _filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/1x/icon/wave_loading.gif'); _background: none; } .bi-loading-widget.hack div { diff --git a/dist/base.js b/dist/base.js index d46848618..112e11570 100644 --- a/dist/base.js +++ b/dist/base.js @@ -199,145 +199,145 @@ return special.settings.adjustOldDeltas && orgEvent.type === "mousewheel" && absDelta % 120 === 0; } -}));/** - * 当没有元素时有提示信息的view - * - * Created by GUY on 2015/9/8. - * @class BI.Pane - * @extends BI.Widget - * @abstract - */ -BI.Pane = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.Pane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-pane", - tipText: BI.i18nText("BI-No_Selected_Item"), - overlap: true, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.Pane.superclass._init.apply(this, arguments); - if (this.__async) { - this.loading(); - } - }, - - _render: function () { - BI.Pane.superclass._render.apply(this, arguments); - if (this.__async) { - this.loaded(); - } - }, - - _assertTip: function () { - var o = this.options; - if (!this._tipText) { - this._tipText = BI.createWidget({ - type: "bi.label", - cls: "bi-tips", - text: o.tipText, - height: 25 - }); - BI.createWidget({ - type: "bi.absolute_center_adapt", - element: this, - items: [this._tipText] - }); - } - }, - - loading: function () { - var self = this, o = this.options; - var loadingAnimation = BI.createWidget({ - type: "bi.horizontal", - cls: "bi-loading-widget" + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), - height: 30, - width: 30, - hgap: 5.625, - vgap: 2.5, - items: [{ - type: "bi.layout", - cls: "rect1", - height: 25, - width: 2.5 - }, { - type: "bi.layout", - cls: "rect2", - height: 25, - width: 2.5 - }, { - type: "bi.layout", - cls: "rect3", - height: 25, - width: 2.5 - }] - }); - // pane在同步方式下由items决定tipText的显示与否 - // loading的异步情况下由loaded后对面板的populate的时机决定 - this.setTipVisible(false); - if (o.overlap === true) { - if (!BI.Layers.has(this.getName())) { - BI.createWidget({ - type: "bi.absolute_center_adapt", - cls: "loading-container", - items: [{ - el: loadingAnimation - }], - element: BI.Layers.make(this.getName(), this) - }); - } - BI.Layers.show(self.getName()); - } else if (BI.isNull(this._loading)) { - this._loading = loadingAnimation; - this._loading.element.css("zIndex", 1); - BI.createWidget({ - type: "bi.absolute_center_adapt", - element: this, - cls: "loading-container", - items: [{ - el: this._loading, - left: 0, - right: 0, - top: 0 - }] - }); - } - }, - - loaded: function () { - var self = this, o = this.options; - BI.Layers.remove(self.getName()); - this._loading && this._loading.destroy(); - this._loading && (this._loading = null); - o.onLoaded(); - self.fireEvent(BI.Pane.EVENT_LOADED); - }, - - check: function () { - this.setTipVisible(BI.isEmpty(this.options.items)); - }, - - setTipVisible: function (b) { - if (b === true) { - this._assertTip(); - this._tipText.setVisible(true); - } else { - this._tipText && this._tipText.setVisible(false); - } - }, - - populate: function (items) { - this.options.items = items || []; - this.check(); - }, - - empty: function () { - - } -}); +}));/** + * 当没有元素时有提示信息的view + * + * Created by GUY on 2015/9/8. + * @class BI.Pane + * @extends BI.Widget + * @abstract + */ +BI.Pane = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.Pane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-pane", + tipText: BI.i18nText("BI-No_Selected_Item"), + overlap: true, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.Pane.superclass._init.apply(this, arguments); + if (this.__async) { + this.loading(); + } + }, + + _render: function () { + BI.Pane.superclass._render.apply(this, arguments); + if (this.__async) { + this.loaded(); + } + }, + + _assertTip: function () { + var o = this.options; + if (!this._tipText) { + this._tipText = BI.createWidget({ + type: "bi.label", + cls: "bi-tips", + text: o.tipText, + height: 25 + }); + BI.createWidget({ + type: "bi.absolute_center_adapt", + element: this, + items: [this._tipText] + }); + } + }, + + loading: function () { + var self = this, o = this.options; + var loadingAnimation = BI.createWidget({ + type: "bi.horizontal", + cls: "bi-loading-widget" + ((BI.isIE() && BI.getIEVersion() < 10) ? " hack" : ""), + height: 30, + width: 30, + hgap: 5.25, + vgap: 2.5, + items: [{ + type: "bi.layout", + cls: "rect1", + height: 25, + width: 3 + }, { + type: "bi.layout", + cls: "rect2", + height: 25, + width: 3 + }, { + type: "bi.layout", + cls: "rect3", + height: 25, + width: 3 + }] + }); + // pane在同步方式下由items决定tipText的显示与否 + // loading的异步情况下由loaded后对面板的populate的时机决定 + this.setTipVisible(false); + if (o.overlap === true) { + if (!BI.Layers.has(this.getName())) { + BI.createWidget({ + type: "bi.absolute_center_adapt", + cls: "loading-container", + items: [{ + el: loadingAnimation + }], + element: BI.Layers.make(this.getName(), this) + }); + } + BI.Layers.show(self.getName()); + } else if (BI.isNull(this._loading)) { + this._loading = loadingAnimation; + this._loading.element.css("zIndex", 1); + BI.createWidget({ + type: "bi.absolute_center_adapt", + element: this, + cls: "loading-container", + items: [{ + el: this._loading, + left: 0, + right: 0, + top: 0 + }] + }); + } + }, + + loaded: function () { + var self = this, o = this.options; + BI.Layers.remove(self.getName()); + this._loading && this._loading.destroy(); + this._loading && (this._loading = null); + o.onLoaded(); + self.fireEvent(BI.Pane.EVENT_LOADED); + }, + + check: function () { + this.setTipVisible(BI.isEmpty(this.options.items)); + }, + + setTipVisible: function (b) { + if (b === true) { + this._assertTip(); + this._tipText.setVisible(true); + } else { + this._tipText && this._tipText.setVisible(false); + } + }, + + populate: function (items) { + this.options.items = items || []; + this.check(); + }, + + empty: function () { + + } +}); BI.Pane.EVENT_LOADED = "EVENT_LOADED";/** * guy * 这仅仅只是一个超类, 所有简单控件的基类 @@ -628,1525 +628,1525 @@ BI.Text = BI.inherit(BI.Single, { } }); -BI.shortcut("bi.text", BI.Text);/** - * guy - * @class BI.BasicButton - * @extends BI.Single - * - * 一般的button父级 - */ -BI.BasicButton = BI.inherit(BI.Single, { - _defaultConfig: function () { - var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer"), - value: "", - text: "", - stopEvent: false, - stopPropagation: false, - selected: false, - once: false, // 点击一次选中有效,再点无效 - forceSelected: false, // 点击即选中, 选中了就不会被取消,与once的区别是forceSelected不影响事件的触发 - forceNotSelected: false, // 无论怎么点击都不会被选中 - disableSelected: false, // 使能选中 - - shadow: false, - isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 - trigger: null, - handler: BI.emptyFn, - bubble: null - }); - }, - _init: function () { - BI.BasicButton.superclass._init.apply(this, arguments); - var opts = this.options; - if (opts.selected === true) { - BI.nextTick(BI.bind(function () { - this.setSelected(opts.selected); - }, this)); - } - BI.nextTick(BI.bind(this.bindEvent, this)); - - if (opts.shadow) { - this._createShadow(); - } - if (opts.level) { - this.element.addClass("button-" + opts.level); - } - }, - - _createShadow: function () { - var self = this, o = this.options; - - var assertMask = function () { - if (!self.$mask) { - self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, { - type: "bi.layout", - cls: "bi-button-mask" - }); - self.$mask.invisible(); - BI.createWidget({ - type: "bi.absolute", - element: self, - items: [{ - el: self.$mask, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - } - }; - - this.element.mouseup(function () { - if (!self._hover && !o.isShadowShowingOnSelected) { - assertMask(); - self.$mask.invisible(); - } - }); - this.element.on("mouseenter." + this.getName(), function (e) { - if (self.element.__isMouseInBounds__(e)) { - if (self.isEnabled() && !self._hover && (o.isShadowShowingOnSelected || !self.isSelected())) { - assertMask(); - self.$mask.visible(); - } - } - }); - this.element.on("mousemove." + this.getName(), function (e) { - if (!self.element.__isMouseInBounds__(e)) { - if (self.isEnabled() && !self._hover) { - assertMask(); - self.$mask.invisible(); - } - } - }); - this.element.on("mouseleave." + this.getName(), function () { - if (self.isEnabled() && !self._hover) { - assertMask(); - self.$mask.invisible(); - } - }); - }, - - bindEvent: function () { - var self = this; - var o = this.options, hand = this.handle(); - if (!hand) { - return; - } - hand = hand.element; - var triggerArr = (o.trigger || "").split(","); - BI.each(triggerArr, function (idx, trigger) { - switch (trigger) { - case "mouseup": - var mouseDown = false; - hand.mousedown(function () { - mouseDown = true; - }); - hand.mouseup(function (e) { - if (mouseDown === true) { - clk(e); - } - mouseDown = false; - ev(e); - }); - break; - case "mousedown": - var mouseDown = false; - var selected = false; - hand.mousedown(function (e) { - // if (e.button === 0) { - BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { - // if (e.button === 0) { - if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { - // self.setSelected(!self.isSelected()); - self._trigger(); - } - mouseDown = false; - BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); - // } - }); - if (mouseDown === true) { - return; - } - if (self.isSelected()) { - selected = true; - } else { - clk(e); - } - mouseDown = true; - ev(e); - // } - }); - hand.mouseup(function (e) { - // if (e.button === 0) { - if (BI.DOM.isExist(self) && mouseDown === true && selected === true) { - clk(e); - } - mouseDown = false; - selected = false; - BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); - // } - }); - break; - case "dblclick": - hand.dblclick(clk); - break; - case "lclick": - var mouseDown = false; - var interval; - hand.mousedown(function (e) { - BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { - interval && clearInterval(interval); - interval = null; - mouseDown = false; - BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); - }); - if (mouseDown === true) { - return; - } - if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { - return; - } - interval = setInterval(function () { - if (self.isEnabled()) { - self.doClick(); - } - }, 180); - mouseDown = true; - ev(e); - }); - break; - default: - if (o.stopEvent || o.stopPropagation) { - hand.mousedown(function (e) { - ev(e); - }); - } - hand.click(clk); - break; - } - }); - - // 之后的300ms点击无效 - var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { - "leading": true, - "trailing": false - }); - - function ev (e) { - if (o.stopEvent) { - e.stopEvent(); - } - if (o.stopPropagation) { - e.stopPropagation(); - } - } - - function clk (e) { - ev(e); - if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { - return; - } - if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { - if (BI.isNull(self.combo)) { - var popup; - BI.createWidget({ - type: "bi.absolute", - element: self, - items: [{ - el: { - type: "bi.bubble_combo", - trigger: "", - ref: function () { - self.combo = this; - }, - el: { - type: "bi.layout", - height: "100%" - }, - popup: { - type: "bi.text_bubble_bar_popup_view", - text: getBubble(), - ref: function () { - popup = this; - }, - listeners: [{ - eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, - action: function (v) { - self.combo.hideView(); - if (v) { - onClick.apply(self, arguments); - } - } - }] - }, - listeners: [{ - eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, - action: function () { - popup.populate(getBubble()); - } - }] - }, - left: 0, - right: 0, - bottom: 0, - top: 0 - }] - }); - } - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - return; - } - onClick.apply(self, arguments); - } - - function getBubble () { - var bubble = self.options.bubble; - if (BI.isFunction(bubble)) { - return bubble(); - } - return bubble; - } - }, - - _trigger: function () { - var o = this.options; - if (!this.isEnabled()) { - return; - } - if (!this.isDisableSelected()) { - this.isForceSelected() ? this.setSelected(true) : - (this.isForceNotSelected() ? this.setSelected(false) : - this.setSelected(!this.isSelected())); - } - if (this.isValid()) { - o.handler.call(this, this.getValue(), this); - var v = this.getValue(); - this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, v, this); - this.fireEvent(BI.BasicButton.EVENT_CHANGE, v, this); - if (o.action) { - BI.Actions.runAction(o.action, "click", o); - } - BI.Actions.runGlobalAction("click", o); - } - }, - - _doClick: function (e) { - if (this.isValid()) { - this.beforeClick(e); - } - this._trigger(); - if (this.isValid()) { - this.doClick(e); - } - }, - - beforeClick: function () { - - }, - - doClick: function () { - - }, - - handle: function () { - return this; - }, - - hover: function () { - this._hover = true; - this.handle().element.addClass("hover"); - if (this.options.shadow) { - this.$mask && this.$mask.setVisible(true); - } - }, - - dishover: function () { - this._hover = false; - this.handle().element.removeClass("hover"); - if (this.options.shadow) { - this.$mask && this.$mask.setVisible(false); - } - }, - - setSelected: function (b) { - var o = this.options; - o.selected = b; - if (b) { - this.handle().element.addClass("active"); - } else { - this.handle().element.removeClass("active"); - } - if (o.shadow && !o.isShadowShowingOnSelected) { - this.$mask && this.$mask.setVisible(false); - } - }, - - isSelected: function () { - return this.options.selected; - }, - - isOnce: function () { - return this.options.once; - }, - - isForceSelected: function () { - return this.options.forceSelected; - }, - - isForceNotSelected: function () { - return this.options.forceNotSelected; - }, - - isDisableSelected: function () { - return this.options.disableSelected; - }, - - setText: function (text) { - this.options.text = text; - }, - - getText: function () { - return this.options.text; - }, - - _setEnable: function (enable) { - BI.BasicButton.superclass._setEnable.apply(this, arguments); - if (enable === true) { - this.element.removeClass("base-disabled disabled"); - } else if (enable === false) { - this.element.addClass("base-disabled disabled"); - } - if (!enable) { - if (this.options.shadow) { - this.$mask && this.$mask.setVisible(false); - } - } - }, - - empty: function () { - BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); - BI.BasicButton.superclass.empty.apply(this, arguments); - }, - - destroy: function () { - BI.BasicButton.superclass.destroy.apply(this, arguments); - } -}); -BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";/** - * 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 - * - * Created by GUY on 2015/9/9. - * @class BI.NodeButton - * @extends BI.BasicButton - * @abstract - */ -BI.NodeButton = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); - return BI.extend( conf, { - baseCls: (conf.baseCls || "") + " bi-node", - open: false - }); - }, - - _init: function () { - BI.NodeButton.superclass._init.apply(this, arguments); - var self = this; - BI.nextTick(function () { - self.setOpened(self.isOpened()); - }); - }, - - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); - this.setOpened(!this.isOpened()); - }, - - isOnce: function () { - return false; - }, - - isOpened: function () { - return !!this.options.open; - }, - - setOpened: function (b) { - this.options.open = !!b; - }, - - triggerCollapse: function () { - if(this.isOpened()) { - this.setOpened(false); - this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); - } - }, - - triggerExpand: function () { - if(!this.isOpened()) { - this.setOpened(true); - this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); - } - } -});/** +BI.shortcut("bi.text", BI.Text);/** * guy - * tip提示 - * zIndex在10亿级别 - * @class BI.Tip + * @class BI.BasicButton * @extends BI.Single - * @abstract + * + * 一般的button父级 */ -BI.Tip = BI.inherit(BI.Single, { +BI.BasicButton = BI.inherit(BI.Single, { _defaultConfig: function () { - var conf = BI.Link.superclass._defaultConfig.apply(this, arguments); + var conf = BI.BasicButton.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-tip", - zIndex: BI.zIndex_tip - }); - }, - - _init: function () { - BI.Tip.superclass._init.apply(this, arguments); - this.element.css({zIndex: this.options.zIndex}); - } -});/** - * Created by GUY on 2015/6/26. - * @class BI.ButtonGroup - * @extends BI.Widget - */ - -BI.ButtonGroup = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.ButtonGroup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-button-group", - behaviors: {}, - items: [], + baseCls: (conf.baseCls || "") + " bi-basic-button" + (conf.invalid ? "" : " cursor-pointer"), value: "", - chooseType: BI.Selection.Single, - layouts: [{ - type: "bi.center", - hgap: 0, - vgap: 0 - }] + text: "", + stopEvent: false, + stopPropagation: false, + selected: false, + once: false, // 点击一次选中有效,再点无效 + forceSelected: false, // 点击即选中, 选中了就不会被取消,与once的区别是forceSelected不影响事件的触发 + forceNotSelected: false, // 无论怎么点击都不会被选中 + disableSelected: false, // 使能选中 + + shadow: false, + isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 + trigger: null, + handler: BI.emptyFn, + bubble: null }); }, - _init: function () { - BI.ButtonGroup.superclass._init.apply(this, arguments); - var o = this.options; - var behaviors = {}; - BI.each(o.behaviors, function (key, rule) { - behaviors[key] = BI.BehaviorFactory.createBehavior(key, { - rule: rule - }); - }); - this.behaviors = behaviors; - this.populate(o.items); - if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ - this.setValue(o.value); + BI.BasicButton.superclass._init.apply(this, arguments); + var opts = this.options; + if (opts.selected === true) { + BI.nextTick(BI.bind(function () { + this.setSelected(opts.selected); + }, this)); } - }, + BI.nextTick(BI.bind(this.bindEvent, this)); - _createBtns: function (items) { - var o = this.options; - return BI.createWidgets(BI.createItems(items, { - type: "bi.text_button" - })); + if (opts.shadow) { + this._createShadow(); + } + if (opts.level) { + this.element.addClass("button-" + opts.level); + } }, - _btnsCreator: function (items) { - var self = this, args = Array.prototype.slice.call(arguments), o = this.options; - var buttons = this._createBtns(items); - args[0] = buttons; + _createShadow: function () { + var self = this, o = this.options; - BI.each(this.behaviors, function (i, behavior) { - behavior.doBehavior.apply(behavior, args); + var assertMask = function () { + if (!self.$mask) { + self.$mask = BI.createWidget(BI.isObject(o.shadow) ? o.shadow : {}, { + type: "bi.layout", + cls: "bi-button-mask" + }); + self.$mask.invisible(); + BI.createWidget({ + type: "bi.absolute", + element: self, + items: [{ + el: self.$mask, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + } + }; + + this.element.mouseup(function () { + if (!self._hover && !o.isShadowShowingOnSelected) { + assertMask(); + self.$mask.invisible(); + } }); - BI.each(buttons, function (i, btn) { - btn.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (type === BI.Events.CLICK) { - switch (o.chooseType) { - case BI.ButtonGroup.CHOOSE_TYPE_SINGLE: - self.setValue(btn.getValue()); - break; - case BI.ButtonGroup.CHOOSE_TYPE_NONE: - self.setValue([]); - break; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); - } else { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + this.element.on("mouseenter." + this.getName(), function (e) { + if (self.element.__isMouseInBounds__(e)) { + if (self.isEnabled() && !self._hover && (o.isShadowShowingOnSelected || !self.isSelected())) { + assertMask(); + self.$mask.visible(); } - }); - btn.on(BI.Events.DESTROY, function () { - BI.remove(self.buttons, btn); - }); + } + }); + this.element.on("mousemove." + this.getName(), function (e) { + if (!self.element.__isMouseInBounds__(e)) { + if (self.isEnabled() && !self._hover) { + assertMask(); + self.$mask.invisible(); + } + } + }); + this.element.on("mouseleave." + this.getName(), function () { + if (self.isEnabled() && !self._hover) { + assertMask(); + self.$mask.invisible(); + } }); - - return buttons; }, - _packageBtns: function (btns) { - var o = this.options; - for (var i = o.layouts.length - 1; i > 0; i--) { - btns = BI.map(btns, function (k, it) { - return BI.extend({}, o.layouts[i], { - items: [ - BI.extend({}, o.layouts[i].el, { - el: it - }) - ] - }); - }); + bindEvent: function () { + var self = this; + var o = this.options, hand = this.handle(); + if (!hand) { + return; } - return btns; - }, - - _packageSimpleItems: function (btns) { - var o = this.options; - return BI.map(o.items, function (i, item) { - if (BI.stripEL(item) === item) { - return btns[i]; + hand = hand.element; + var triggerArr = (o.trigger || "").split(","); + BI.each(triggerArr, function (idx, trigger) { + switch (trigger) { + case "mouseup": + var mouseDown = false; + hand.mousedown(function () { + mouseDown = true; + }); + hand.mouseup(function (e) { + if (mouseDown === true) { + clk(e); + } + mouseDown = false; + ev(e); + }); + break; + case "mousedown": + var mouseDown = false; + var selected = false; + hand.mousedown(function (e) { + // if (e.button === 0) { + BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { + // if (e.button === 0) { + if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { + // self.setSelected(!self.isSelected()); + self._trigger(); + } + mouseDown = false; + BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); + // } + }); + if (mouseDown === true) { + return; + } + if (self.isSelected()) { + selected = true; + } else { + clk(e); + } + mouseDown = true; + ev(e); + // } + }); + hand.mouseup(function (e) { + // if (e.button === 0) { + if (BI.DOM.isExist(self) && mouseDown === true && selected === true) { + clk(e); + } + mouseDown = false; + selected = false; + BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); + // } + }); + break; + case "dblclick": + hand.dblclick(clk); + break; + case "lclick": + var mouseDown = false; + var interval; + hand.mousedown(function (e) { + BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { + interval && clearInterval(interval); + interval = null; + mouseDown = false; + BI.Widget._renderEngine.createElement(document).unbind("mouseup." + self.getName()); + }); + if (mouseDown === true) { + return; + } + if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { + return; + } + interval = setInterval(function () { + if (self.isEnabled()) { + self.doClick(); + } + }, 180); + mouseDown = true; + ev(e); + }); + break; + default: + if (o.stopEvent || o.stopPropagation) { + hand.mousedown(function (e) { + ev(e); + }); + } + hand.click(clk); + break; } - return BI.extend({}, item, { - el: btns[i] - }); }); - }, - - _packageItems: function (items, packBtns) { - return BI.createItems(BI.makeArrayByArray(items, {}), BI.clone(packBtns)); - }, - _packageLayout: function (items) { - var o = this.options, layout = BI.deepClone(o.layouts[0]); + // 之后的300ms点击无效 + var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, { + "leading": true, + "trailing": false + }); - var lay = BI.formatEL(layout).el; - while (lay && lay.items && !BI.isEmpty(lay.items)) { - lay = BI.formatEL(lay.items[0]).el; + function ev (e) { + if (o.stopEvent) { + e.stopEvent(); + } + if (o.stopPropagation) { + e.stopPropagation(); + } } - lay.items = items; - return layout; - }, - - // 如果是一个简单的layout - _isSimpleLayout: function () { - var o = this.options; - return o.layouts.length === 1 && !BI.isArray(o.items[0]); - }, - - doBehavior: function () { - var args = Array.prototype.slice.call(arguments); - args.unshift(this.buttons); - BI.each(this.behaviors, function (i, behavior) { - behavior.doBehavior.apply(behavior, args); - }); - }, - prependItems: function (items) { - var o = this.options; - var btns = this._btnsCreator.apply(this, arguments); - this.buttons = BI.concat(btns, this.buttons); - - if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) { - this.layouts.prependItems(btns); - return; + function clk (e) { + ev(e); + if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { + return; + } + if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { + if (BI.isNull(self.combo)) { + var popup; + BI.createWidget({ + type: "bi.absolute", + element: self, + items: [{ + el: { + type: "bi.bubble_combo", + trigger: "", + ref: function () { + self.combo = this; + }, + el: { + type: "bi.layout", + height: "100%" + }, + popup: { + type: "bi.text_bubble_bar_popup_view", + text: getBubble(), + ref: function () { + popup = this; + }, + listeners: [{ + eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, + action: function (v) { + self.combo.hideView(); + if (v) { + onClick.apply(self, arguments); + } + } + }] + }, + listeners: [{ + eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, + action: function () { + popup.populate(getBubble()); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }] + }); + } + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + return; + } + onClick.apply(self, arguments); } - items = this._packageItems(items, this._packageBtns(btns)); - this.layouts.prependItems(this._packageLayout(items).items); + function getBubble () { + var bubble = self.options.bubble; + if (BI.isFunction(bubble)) { + return bubble(); + } + return bubble; + } }, - addItems: function (items) { + _trigger: function () { var o = this.options; - var btns = this._btnsCreator.apply(this, arguments); - this.buttons = BI.concat(this.buttons, btns); - - // 如果是一个简单的layout - if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) { - this.layouts.addItems(btns); + if (!this.isEnabled()) { return; } - - items = this._packageItems(items, this._packageBtns(btns)); - this.layouts.addItems(this._packageLayout(items).items); + if (!this.isDisableSelected()) { + this.isForceSelected() ? this.setSelected(true) : + (this.isForceNotSelected() ? this.setSelected(false) : + this.setSelected(!this.isSelected())); + } + if (this.isValid()) { + o.handler.call(this, this.getValue(), this); + var v = this.getValue(); + this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, v, this); + this.fireEvent(BI.BasicButton.EVENT_CHANGE, v, this); + if (o.action) { + BI.Actions.runAction(o.action, "click", o); + } + BI.Actions.runGlobalAction("click", o); + } }, - removeItemAt: function (indexes) { - BI.removeAt(this.buttons, indexes); - this.layouts.removeItemAt(indexes); + _doClick: function (e) { + if (this.isValid()) { + this.beforeClick(e); + } + this._trigger(); + if (this.isValid()) { + this.doClick(e); + } }, - removeItems: function (values) { - values = BI.isArray(values) ? values : [values]; - var deleted = []; - BI.each(this.buttons, function (i, button) { - if (BI.deepContains(values, button.getValue())) { - deleted.push(i); - } - }); - BI.removeAt(this.buttons, deleted); - this.layouts.removeItemAt(deleted); - }, + beforeClick: function () { - populate: function (items) { - items = items || []; - this.empty(); - this.options.items = items; + }, - this.buttons = this._btnsCreator.apply(this, arguments); - if (this._isSimpleLayout()) { - items = this._packageSimpleItems(this.buttons); - } else { - items = this._packageItems(items, this._packageBtns(this.buttons)); - } + doClick: function () { - this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); }, - setNotSelectedValue: function (v) { - v = BI.isArray(v) ? v : [v]; - BI.each(this.buttons, function (i, item) { - if (BI.deepContains(v, item.getValue())) { - item.setSelected && item.setSelected(false); - } else { - item.setSelected && item.setSelected(true); - } - }); + handle: function () { + return this; }, - setEnabledValue: function (v) { - v = BI.isArray(v) ? v : [v]; - BI.each(this.buttons, function (i, item) { - if (BI.deepContains(v, item.getValue())) { - item.setEnable(true); - } else { - item.setEnable(false); - } - }); + hover: function () { + this._hover = true; + this.handle().element.addClass("hover"); + if (this.options.shadow) { + this.$mask && this.$mask.setVisible(true); + } }, - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - BI.each(this.buttons, function (i, item) { - if (BI.deepContains(v, item.getValue())) { - item.setSelected && item.setSelected(true); - } else { - item.setSelected && item.setSelected(false); - } - }); + dishover: function () { + this._hover = false; + this.handle().element.removeClass("hover"); + if (this.options.shadow) { + this.$mask && this.$mask.setVisible(false); + } }, - getNotSelectedValue: function () { - var v = []; - BI.each(this.buttons, function (i, item) { - if (item.isEnabled() && !(item.isSelected && item.isSelected())) { - v.push(item.getValue()); - } - }); - return v; + setSelected: function (b) { + var o = this.options; + o.selected = b; + if (b) { + this.handle().element.addClass("active"); + } else { + this.handle().element.removeClass("active"); + } + if (o.shadow && !o.isShadowShowingOnSelected) { + this.$mask && this.$mask.setVisible(false); + } }, - getValue: function () { - var v = []; - BI.each(this.buttons, function (i, item) { - if (item.isEnabled() && item.isSelected && item.isSelected()) { - v.push(item.getValue()); - } - }); - return v; + isSelected: function () { + return this.options.selected; }, - getAllButtons: function () { - return this.buttons; + isOnce: function () { + return this.options.once; }, - getAllLeaves: function () { - return this.buttons; + isForceSelected: function () { + return this.options.forceSelected; }, - getSelectedButtons: function () { - var btns = []; - BI.each(this.buttons, function (i, item) { - if (item.isSelected && item.isSelected()) { - btns.push(item); - } - }); - return btns; + isForceNotSelected: function () { + return this.options.forceNotSelected; }, - getNotSelectedButtons: function () { - var btns = []; - BI.each(this.buttons, function (i, item) { - if (item.isSelected && !item.isSelected()) { - btns.push(item); - } - }); - return btns; + isDisableSelected: function () { + return this.options.disableSelected; }, - getIndexByValue: function (value) { - var index = -1; - BI.any(this.buttons, function (i, item) { - if (item.isEnabled() && item.getValue() === value) { - index = i; - return true; - } - }); - return index; + setText: function (text) { + this.options.text = text; }, - getNodeById: function (id) { - var node; - BI.any(this.buttons, function (i, item) { - if (item.isEnabled() && item.options.id === id) { - node = item; - return true; - } - }); - return node; + getText: function () { + return this.options.text; }, - getNodeByValue: function (value) { - var node; - BI.any(this.buttons, function (i, item) { - if (item.isEnabled() && item.getValue() === value) { - node = item; - return true; + _setEnable: function (enable) { + BI.BasicButton.superclass._setEnable.apply(this, arguments); + if (enable === true) { + this.element.removeClass("base-disabled disabled"); + } else if (enable === false) { + this.element.addClass("base-disabled disabled"); + } + if (!enable) { + if (this.options.shadow) { + this.$mask && this.$mask.setVisible(false); } - }); - return node; + } }, empty: function () { - BI.ButtonGroup.superclass.empty.apply(this, arguments); - this.options.items = []; + BI.Widget._renderEngine.createElement(document).unbind("mouseup." + this.getName()); + BI.BasicButton.superclass.empty.apply(this, arguments); }, destroy: function () { - BI.ButtonGroup.superclass.destroy.apply(this, arguments); - this.options.items = []; + BI.BasicButton.superclass.destroy.apply(this, arguments); } }); -BI.extend(BI.ButtonGroup, { - CHOOSE_TYPE_SINGLE: BI.Selection.Single, - CHOOSE_TYPE_MULTI: BI.Selection.Multi, - CHOOSE_TYPE_ALL: BI.Selection.All, - CHOOSE_TYPE_NONE: BI.Selection.None, - CHOOSE_TYPE_DEFAULT: BI.Selection.Default -}); -BI.ButtonGroup.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.button_group", BI.ButtonGroup);/** - * Created by GUY on 2015/8/10. - * @class BI.ButtonTree - * @extends BI.ButtonGroup +BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";/** + * 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 + * + * Created by GUY on 2015/9/9. + * @class BI.NodeButton + * @extends BI.BasicButton + * @abstract */ - -BI.ButtonTree = BI.inherit(BI.ButtonGroup, { +BI.NodeButton = BI.inherit(BI.BasicButton, { _defaultConfig: function () { - return BI.extend(BI.ButtonTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-button-tree" + var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); + return BI.extend( conf, { + baseCls: (conf.baseCls || "") + " bi-node", + open: false }); }, _init: function () { - BI.ButtonTree.superclass._init.apply(this, arguments); + BI.NodeButton.superclass._init.apply(this, arguments); + var self = this; + BI.nextTick(function () { + self.setOpened(self.isOpened()); + }); }, - setNotSelectedValue: function (v) { - v = BI.isArray(v) ? v : [v]; - BI.each(this.buttons, function (i, item) { - if (!BI.isFunction(item.setSelected)) { - item.setNotSelectedValue(v); - return; - } - if (BI.deepContains(v, item.getValue())) { - item.setSelected(false); - } else { - item.setSelected(true); - } - }); + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + this.setOpened(!this.isOpened()); }, - setEnabledValue: function (v) { - v = BI.isArray(v) ? v : [v]; - BI.each(this.buttons, function (i, item) { - if (BI.isFunction(item.setEnabledValue)) { - item.setEnabledValue(v); - return; - } - if (BI.deepContains(v, item.getValue())) { - item.setEnable(true); - } else { - item.setEnable(false); - } - }); + isOnce: function () { + return false; }, - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - BI.each(this.buttons, function (i, item) { - if (!BI.isFunction(item.setSelected)) { - item.setValue(v); - return; - } - if (BI.deepContains(v, item.getValue())) { - item.setSelected(true); - } else { - item.setSelected(false); - } - }); + isOpened: function () { + return !!this.options.open; + }, + + setOpened: function (b) { + this.options.open = !!b; }, - getNotSelectedValue: function () { - var v = []; - BI.each(this.buttons, function (i, item) { - if (item.isEnabled() && !BI.isFunction(item.setSelected)) { - v = BI.concat(v, item.getNotSelectedValue()); - return; - } - if (item.isEnabled() && item.isSelected && !item.isSelected()) { - v.push(item.getValue()); - } + triggerCollapse: function () { + if(this.isOpened()) { + this.setOpened(false); + this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); + } + }, + + triggerExpand: function () { + if(!this.isOpened()) { + this.setOpened(true); + this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); + } + } +});/** + * guy + * tip提示 + * zIndex在10亿级别 + * @class BI.Tip + * @extends BI.Single + * @abstract + */ +BI.Tip = BI.inherit(BI.Single, { + _defaultConfig: function () { + var conf = BI.Link.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-tip", + zIndex: BI.zIndex_tip + }); + }, + + _init: function () { + BI.Tip.superclass._init.apply(this, arguments); + this.element.css({zIndex: this.options.zIndex}); + } +});/** + * Created by GUY on 2015/6/26. + * @class BI.ButtonGroup + * @extends BI.Widget + */ + +BI.ButtonGroup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.ButtonGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-button-group", + behaviors: {}, + items: [], + value: "", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.center", + hgap: 0, + vgap: 0 + }] + }); + }, + + _init: function () { + BI.ButtonGroup.superclass._init.apply(this, arguments); + var o = this.options; + var behaviors = {}; + BI.each(o.behaviors, function (key, rule) { + behaviors[key] = BI.BehaviorFactory.createBehavior(key, { + rule: rule + }); + }); + this.behaviors = behaviors; + this.populate(o.items); + if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + this.setValue(o.value); + } + }, + + _createBtns: function (items) { + var o = this.options; + return BI.createWidgets(BI.createItems(items, { + type: "bi.text_button" + })); + }, + + _btnsCreator: function (items) { + var self = this, args = Array.prototype.slice.call(arguments), o = this.options; + var buttons = this._createBtns(items); + args[0] = buttons; + + BI.each(this.behaviors, function (i, behavior) { + behavior.doBehavior.apply(behavior, args); + }); + BI.each(buttons, function (i, btn) { + btn.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { + if (type === BI.Events.CLICK) { + switch (o.chooseType) { + case BI.ButtonGroup.CHOOSE_TYPE_SINGLE: + self.setValue(btn.getValue()); + break; + case BI.ButtonGroup.CHOOSE_TYPE_NONE: + self.setValue([]); + break; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.ButtonGroup.EVENT_CHANGE, value, obj); + } else { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + } + }); + btn.on(BI.Events.DESTROY, function () { + BI.remove(self.buttons, btn); + }); + }); + + return buttons; + }, + + _packageBtns: function (btns) { + var o = this.options; + for (var i = o.layouts.length - 1; i > 0; i--) { + btns = BI.map(btns, function (k, it) { + return BI.extend({}, o.layouts[i], { + items: [ + BI.extend({}, o.layouts[i].el, { + el: it + }) + ] + }); + }); + } + return btns; + }, + + _packageSimpleItems: function (btns) { + var o = this.options; + return BI.map(o.items, function (i, item) { + if (BI.stripEL(item) === item) { + return btns[i]; + } + return BI.extend({}, item, { + el: btns[i] + }); + }); + }, + + _packageItems: function (items, packBtns) { + return BI.createItems(BI.makeArrayByArray(items, {}), BI.clone(packBtns)); + }, + + _packageLayout: function (items) { + var o = this.options, layout = BI.deepClone(o.layouts[0]); + + var lay = BI.formatEL(layout).el; + while (lay && lay.items && !BI.isEmpty(lay.items)) { + lay = BI.formatEL(lay.items[0]).el; + } + lay.items = items; + return layout; + }, + + // 如果是一个简单的layout + _isSimpleLayout: function () { + var o = this.options; + return o.layouts.length === 1 && !BI.isArray(o.items[0]); + }, + + doBehavior: function () { + var args = Array.prototype.slice.call(arguments); + args.unshift(this.buttons); + BI.each(this.behaviors, function (i, behavior) { + behavior.doBehavior.apply(behavior, args); + }); + }, + + prependItems: function (items) { + var o = this.options; + var btns = this._btnsCreator.apply(this, arguments); + this.buttons = BI.concat(btns, this.buttons); + + if (this._isSimpleLayout() && this.layouts && this.layouts.prependItems) { + this.layouts.prependItems(btns); + return; + } + + items = this._packageItems(items, this._packageBtns(btns)); + this.layouts.prependItems(this._packageLayout(items).items); + }, + + addItems: function (items) { + var o = this.options; + var btns = this._btnsCreator.apply(this, arguments); + this.buttons = BI.concat(this.buttons, btns); + + // 如果是一个简单的layout + if (this._isSimpleLayout() && this.layouts && this.layouts.addItems) { + this.layouts.addItems(btns); + return; + } + + items = this._packageItems(items, this._packageBtns(btns)); + this.layouts.addItems(this._packageLayout(items).items); + }, + + removeItemAt: function (indexes) { + BI.removeAt(this.buttons, indexes); + this.layouts.removeItemAt(indexes); + }, + + removeItems: function (values) { + values = BI.isArray(values) ? values : [values]; + var deleted = []; + BI.each(this.buttons, function (i, button) { + if (BI.deepContains(values, button.getValue())) { + deleted.push(i); + } + }); + BI.removeAt(this.buttons, deleted); + this.layouts.removeItemAt(deleted); + }, + + populate: function (items) { + items = items || []; + this.empty(); + this.options.items = items; + + this.buttons = this._btnsCreator.apply(this, arguments); + if (this._isSimpleLayout()) { + items = this._packageSimpleItems(this.buttons); + } else { + items = this._packageItems(items, this._packageBtns(this.buttons)); + } + + this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); + }, + + setNotSelectedValue: function (v) { + v = BI.isArray(v) ? v : [v]; + BI.each(this.buttons, function (i, item) { + if (BI.deepContains(v, item.getValue())) { + item.setSelected && item.setSelected(false); + } else { + item.setSelected && item.setSelected(true); + } + }); + }, + + setEnabledValue: function (v) { + v = BI.isArray(v) ? v : [v]; + BI.each(this.buttons, function (i, item) { + if (BI.deepContains(v, item.getValue())) { + item.setEnable(true); + } else { + item.setEnable(false); + } + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + BI.each(this.buttons, function (i, item) { + if (BI.deepContains(v, item.getValue())) { + item.setSelected && item.setSelected(true); + } else { + item.setSelected && item.setSelected(false); + } + }); + }, + + getNotSelectedValue: function () { + var v = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && !(item.isSelected && item.isSelected())) { + v.push(item.getValue()); + } + }); + return v; + }, + + getValue: function () { + var v = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && item.isSelected && item.isSelected()) { + v.push(item.getValue()); + } + }); + return v; + }, + + getAllButtons: function () { + return this.buttons; + }, + + getAllLeaves: function () { + return this.buttons; + }, + + getSelectedButtons: function () { + var btns = []; + BI.each(this.buttons, function (i, item) { + if (item.isSelected && item.isSelected()) { + btns.push(item); + } + }); + return btns; + }, + + getNotSelectedButtons: function () { + var btns = []; + BI.each(this.buttons, function (i, item) { + if (item.isSelected && !item.isSelected()) { + btns.push(item); + } + }); + return btns; + }, + + getIndexByValue: function (value) { + var index = -1; + BI.any(this.buttons, function (i, item) { + if (item.isEnabled() && item.getValue() === value) { + index = i; + return true; + } + }); + return index; + }, + + getNodeById: function (id) { + var node; + BI.any(this.buttons, function (i, item) { + if (item.isEnabled() && item.options.id === id) { + node = item; + return true; + } + }); + return node; + }, + + getNodeByValue: function (value) { + var node; + BI.any(this.buttons, function (i, item) { + if (item.isEnabled() && item.getValue() === value) { + node = item; + return true; + } + }); + return node; + }, + + empty: function () { + BI.ButtonGroup.superclass.empty.apply(this, arguments); + this.options.items = []; + }, + + destroy: function () { + BI.ButtonGroup.superclass.destroy.apply(this, arguments); + this.options.items = []; + } +}); +BI.extend(BI.ButtonGroup, { + CHOOSE_TYPE_SINGLE: BI.Selection.Single, + CHOOSE_TYPE_MULTI: BI.Selection.Multi, + CHOOSE_TYPE_ALL: BI.Selection.All, + CHOOSE_TYPE_NONE: BI.Selection.None, + CHOOSE_TYPE_DEFAULT: BI.Selection.Default +}); +BI.ButtonGroup.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.button_group", BI.ButtonGroup);/** + * Created by GUY on 2015/8/10. + * @class BI.ButtonTree + * @extends BI.ButtonGroup + */ + +BI.ButtonTree = BI.inherit(BI.ButtonGroup, { + _defaultConfig: function () { + return BI.extend(BI.ButtonTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-button-tree" + }); + }, + + _init: function () { + BI.ButtonTree.superclass._init.apply(this, arguments); + }, + + setNotSelectedValue: function (v) { + v = BI.isArray(v) ? v : [v]; + BI.each(this.buttons, function (i, item) { + if (!BI.isFunction(item.setSelected)) { + item.setNotSelectedValue(v); + return; + } + if (BI.deepContains(v, item.getValue())) { + item.setSelected(false); + } else { + item.setSelected(true); + } + }); + }, + + setEnabledValue: function (v) { + v = BI.isArray(v) ? v : [v]; + BI.each(this.buttons, function (i, item) { + if (BI.isFunction(item.setEnabledValue)) { + item.setEnabledValue(v); + return; + } + if (BI.deepContains(v, item.getValue())) { + item.setEnable(true); + } else { + item.setEnable(false); + } + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + BI.each(this.buttons, function (i, item) { + if (!BI.isFunction(item.setSelected)) { + item.setValue(v); + return; + } + if (BI.deepContains(v, item.getValue())) { + item.setSelected(true); + } else { + item.setSelected(false); + } + }); + }, + + getNotSelectedValue: function () { + var v = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && !BI.isFunction(item.setSelected)) { + v = BI.concat(v, item.getNotSelectedValue()); + return; + } + if (item.isEnabled() && item.isSelected && !item.isSelected()) { + v.push(item.getValue()); + } + }); + return v; + }, + + getValue: function () { + var v = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && !BI.isFunction(item.setSelected)) { + v = BI.concat(v, item.getValue()); + return; + } + if (item.isEnabled() && item.isSelected && item.isSelected()) { + v.push(item.getValue()); + } + }); + return v; + }, + + getSelectedButtons: function () { + var btns = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && !BI.isFunction(item.setSelected)) { + btns = btns.concat(item.getSelectedButtons()); + return; + } + if (item.isSelected && item.isSelected()) { + btns.push(item); + } + }); + return btns; + }, + + getNotSelectedButtons: function () { + var btns = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && !BI.isFunction(item.setSelected)) { + btns = btns.concat(item.getNotSelectedButtons()); + return; + } + if (item.isSelected && !item.isSelected()) { + btns.push(item); + } + }); + return btns; + }, + + // 获取所有的叶子节点 + getAllLeaves: function () { + var leaves = []; + BI.each(this.buttons, function (i, item) { + if (item.isEnabled() && !BI.isFunction(item.setSelected)) { + leaves = leaves.concat(item.getAllLeaves()); + return; + } + if (item.isEnabled()) { + leaves.push(item); + } + }); + return leaves; + }, + + getIndexByValue: function (value) { + var index = -1; + BI.any(this.buttons, function (i, item) { + var vs = item.getValue(); + if (item.isEnabled() && (vs === value || BI.contains(vs, value))) { + index = i; + return true; + } + }); + return index; + }, + + getNodeById: function (id) { + var node; + BI.any(this.buttons, function (i, item) { + if (item.isEnabled()) { + if (item.attr("id") === id) { + node = item; + return true; + } else if (BI.isFunction(item.getNodeById)) { + if (node = item.getNodeById(id)) { + return true; + } + } + } + }); + return node; + }, + + getNodeByValue: function (value) { + var node; + BI.any(this.buttons, function (i, item) { + if (item.isEnabled()) { + if (BI.isFunction(item.getNodeByValue)) { + if (node = item.getNodeByValue(value)) { + return true; + } + } else if (item.attr("value") === value) { + node = item; + return true; + } + } + }); + return node; + } +}); +BI.ButtonTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.button_tree", BI.ButtonTree);/** + * guy + * 异步树 + * @class BI.TreeView + * @extends BI.Pane + */ +BI.TreeView = BI.inherit(BI.Pane, { + _defaultConfig: function () { + return BI.extend(BI.TreeView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-tree", + paras: {}, + itemsCreator: BI.emptyFn + }); + }, + _init: function () { + BI.TreeView.superclass._init.apply(this, arguments); + var o = this.options; + this._stop = false; + + this._createTree(); + this.tip = BI.createWidget({ + type: "bi.loading_bar", + invisible: true, + handler: BI.bind(this._loadMore, this) + }); + BI.createWidget({ + type: "bi.vertical", + scrollable: true, + scrolly: false, + element: this, + items: [this.tip] + }); + if(BI.isNotNull(o.value)) { + this.setSelectedValue(o.value); + } + if (BI.isIE9Below && BI.isIE9Below()) { + this.element.addClass("hack"); + } + }, + + _createTree: function () { + this.id = "bi-tree" + BI.UUID(); + if (this.nodes) { + this.nodes.destroy(); + } + if (this.tree) { + this.tree.destroy(); + } + this.tree = BI.createWidget({ + type: "bi.layout", + element: "