diff --git a/bi/base.js b/bi/base.js index c5c7353c3..460bfb704 100644 --- a/bi/base.js +++ b/bi/base.js @@ -3264,11 +3264,6 @@ BI.Combo = BI.inherit(BI.Widget, { return this.position; }, - doBehavior: function () { - this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - toggle: function () { this._toggle(); }, @@ -3532,11 +3527,6 @@ BI.Expander = BI.inherit(BI.Widget, { return this.popupView; }, - doBehavior: function () { - //this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - getAllLeaves: function () { return this.popupView && this.popupView.getAllLeaves(); }, @@ -3946,10 +3936,6 @@ BI.Loader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, @@ -4704,11 +4690,6 @@ BI.Switcher = BI.inherit(BI.Widget, { this.isViewVisible() && BI.Maskers.show(this.getName()); }, - doBehavior: function () { - this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - getAllLeaves: function () { return this.popupView && this.popupView.getAllLeaves(); }, @@ -19638,7 +19619,7 @@ BI.Label = BI.inherit(BI.Single, { } if (o.whiteSpace == "normal") { this.text = BI.createWidget(json); - this.text = BI.createWidget({ + BI.createWidget({ type: "bi.center_adapt", hgap: o.hgap, vgap: o.vgap, @@ -19836,7 +19817,7 @@ BI.Label = BI.inherit(BI.Single, { } if (o.whiteSpace == "normal") { this.text = BI.createWidget(json) - this.text = BI.createWidget({ + BI.createWidget({ type: "bi.vertical_adapt", scrollable: o.whiteSpace === "normal", hgap: o.hgap, @@ -33019,10 +33000,6 @@ BI.CustomTree = BI.inherit(BI.Widget, { this.tree.populate.apply(this.tree, args); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree && this.tree.setValue(v); }, diff --git a/bi/case.js b/bi/case.js index 7090b6ee8..060b96bfe 100644 --- a/bi/case.js +++ b/bi/case.js @@ -1820,6 +1820,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { var conf = BI.YearCalendar.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: "bi-year-calendar", + behaviors: {}, logic: { dynamic: false }, @@ -1884,6 +1885,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { 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, @@ -8360,10 +8362,6 @@ BI.ListPane = BI.inherit(BI.Pane, { this.button_group.empty(); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, @@ -8653,10 +8651,6 @@ BI.SelectList = BI.inherit(BI.Widget, { this.list.element.css({"max-height": h - toolHeight + "px"}) }, - doBehavior: function () { - this.list.doBehavior.apply(this.list, arguments); - }, - setNotSelectedValue: function () { this.list.setNotSelectedValue.apply(this.list, arguments); this._checkAllSelected(); @@ -8751,10 +8745,6 @@ BI.LazyLoader = BI.inherit(BI.Widget, { this.loader.empty(); }, - doBehavior: function () { - this.loader.doBehavior(); - }, - setNotSelectedValue: function () { this.loader.setNotSelectedValue.apply(this.loader, arguments); }, @@ -8950,10 +8940,6 @@ BI.ListLoader = BI.inherit(BI.Widget, { }); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, @@ -9122,10 +9108,6 @@ BI.SortList = BI.inherit(BI.Widget, { this.loader.empty(); }, - doBehavior: function () { - this.loader.doBehavior.apply(this.loader, arguments); - }, - setNotSelectedValue: function () { this.loader.setNotSelectedValue.apply(this.loader, arguments); }, @@ -12126,10 +12108,6 @@ BI.LevelTree = BI.inherit(BI.Widget, { this.tree.populate(items); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, diff --git a/bi/core.js b/bi/core.js index 87cdaf46e..dd9d00130 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4577,6 +4577,14 @@ BI.Widget = BI.inherit(BI.OB, { } }, + doBehavior: function () { + var args = arguments; + //递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + child.doBehavior && child.doBehavior.apply(child, args); + }); + }, + getWidth: function () { return this.options.width; }, @@ -10973,26 +10981,34 @@ BI.Behavior = BI.inherit(BI.OB, { * @extends BI.Behavior */ BI.HighlightBehavior = BI.inherit(BI.Behavior, { - _defaultConfig: function() { - return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), { - - }); + _defaultConfig: function () { + return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), {}); }, - _init : function() { + _init: function () { BI.HighlightBehavior.superclass._init.apply(this, arguments); }, - doBehavior: function(items){ + doBehavior: function (items) { var args = Array.prototype.slice.call(arguments, 1), o = this.options; - BI.each(items, function(i, item){ - if(item instanceof BI.Single) { - if (o.rule(item.getValue(), item)) { - item.doHighLight.apply(item, args); + BI.each(items, function (i, item) { + if (item instanceof BI.Single) { + var rule = o.rule(item.getValue(), item); + + function doBe(run) { + if (run === true) { + item.doHighLight.apply(item, args); + } else { + item.unHighLight.apply(item, args); + } + } + + if (BI.isFunction(rule)) { + rule(doBe); } else { - item.unHighLight.apply(item, args); + doBe(rule); } } else { item.doBehavior.apply(item, args); diff --git a/bi/widget.css b/bi/widget.css index 474396fdf..85b1f4c3e 100644 --- a/bi/widget.css +++ b/bi/widget.css @@ -516,7 +516,6 @@ /**** custom color(自定义颜色,用于特定场景) ****/ .bi-year-popup .year-popup-navigation { line-height: 30px; - color: #3f8ce8; } .bi-year-popup .year-popup-navigation > .center-element { border-left: 1px solid #d4dadd; diff --git a/bi/widget.js b/bi/widget.js index dd99f936f..899371cdd 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -7739,6 +7739,7 @@ BI.MonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-month-combo", + behaviors: {}, height: 25 }); }, @@ -7751,9 +7752,9 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { - if(this.getKey() && this.getKey() !== self.storeValue) { + if (this.getKey() && this.getKey() !== self.storeValue) { self.setValue(this.getValue()); - }else if(!this.getKey()){ + } else if (!this.getKey()) { self.setValue(); } self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); @@ -7774,7 +7775,8 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ - type: "bi.month_popup" + type: "bi.month_popup", + behaviors: o.behaviors }); this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -7792,7 +7794,10 @@ BI.MonthCombo = BI.inherit(BI.Widget, { minWidth: 85, el: this.popup } - }) + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); + }); }, setValue: function (v) { @@ -7806,6 +7811,7 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.month_combo', BI.MonthCombo);/** * 月份展示面板 * @@ -7817,13 +7823,14 @@ BI.MonthPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-popup" + baseCls: "bi-month-popup", + behaviors: {} }); }, _init: function () { BI.MonthPopup.superclass._init.apply(this, arguments); - var self = this; + var self = this, o = this.options; //纵向排列月 var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; @@ -7854,6 +7861,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, { this.month = BI.createWidget({ type: "bi.button_group", element: this, + behaviors: o.behaviors, items: BI.createItems(items, {}), layouts: [BI.LogicFactory.createLogic("table", BI.extend({ dynamic: true @@ -8170,10 +8178,6 @@ BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, @@ -8715,10 +8719,6 @@ BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, @@ -13976,6 +13976,7 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-quarter-combo", + behaviors: {}, height: 25 }); }, @@ -13996,24 +13997,25 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { self.combo.isViewVisible() && self.combo.hideView(); }); - this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function(){ + this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { if (!self.combo.isViewVisible()) { self.combo.showView(); } }); this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { - if(self.combo.isViewVisible()) { + if (self.combo.isViewVisible()) { return; } - if(this.getKey() && this.getKey() !== self.storeValue) { + if (this.getKey() && this.getKey() !== self.storeValue) { self.setValue(this.getKey()); - }else if(!this.getKey()){ + } else if (!this.getKey()) { self.setValue(); } self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); }); this.popup = BI.createWidget({ - type: "bi.quarter_popup" + type: "bi.quarter_popup", + behaviors: o.behaviors }); this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { @@ -14033,6 +14035,9 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { el: this.popup } }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); }, setValue: function (v) { @@ -14046,6 +14051,7 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { }); BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/** * 季度展示面板 * @@ -14057,13 +14063,14 @@ BI.QuarterPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-quarter-popup" + baseCls: "bi-quarter-popup", + behaviors: {} }); }, _init: function () { BI.QuarterPopup.superclass._init.apply(this, arguments); - var self = this; + var self = this, o = this.options; var items = [{ text: Date._QN[01], @@ -14093,6 +14100,7 @@ BI.QuarterPopup = BI.inherit(BI.Widget, { this.quarter = BI.createWidget({ type: "bi.button_group", element: this, + behaviors: o.behaviors, items: BI.createItems(items, {}), layouts: [{ type: "bi.vertical" @@ -16581,6 +16589,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-combo", + behaviors: {}, min: '1900-01-01', //最小日期 max: '2099-12-31', //最大日期 height: 25 @@ -16608,7 +16617,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { self.combo.isViewVisible() && self.combo.hideView(); }); this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () { - if(self.combo.isViewVisible()) { + if (self.combo.isViewVisible()) { return; } if (this.getKey() && this.getKey() !== self.storeValue) { @@ -16619,45 +16628,50 @@ BI.YearCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.YearCombo.EVENT_CONFIRM); }); - this.popup = BI.createWidget({ - type: "bi.year_popup", - min: o.min, - max: o.max - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.YearCombo.EVENT_CONFIRM); - }); - this.combo = BI.createWidget({ type: "bi.combo", element: this, + destroyWhenHide: true, isNeedAdjustHeight: false, isNeedAdjustWidth: false, el: this.trigger, popup: { minWidth: 85, stopPropagation: false, - el: this.popup + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } } }); this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { var value = self.trigger.getKey(); if (BI.isNotNull(value)) { self.popup.setValue(value); - } else if(!value && value !== self.storeValue){ + } else if (!value && value !== self.storeValue) { self.popup.setValue(self.storeValue); - }else { + } else { self.setValue(); } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); }); }, setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); + this.combo.setValue(v); }, getValue: function () { @@ -16665,6 +16679,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { } }); BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_combo', BI.YearCombo);/** * 年份展示面板 * @@ -16677,6 +16692,7 @@ BI.YearPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-popup", + behaviors: {}, min: '1900-01-01', //最小日期 max: '2099-12-31' //最大日期 }); @@ -16687,6 +16703,7 @@ BI.YearPopup = BI.inherit(BI.Widget, { var calendar = BI.createWidget({ type: "bi.year_calendar", + behaviors: o.behaviors, min: o.min, max: o.max, logic: { @@ -16723,11 +16740,12 @@ BI.YearPopup = BI.inherit(BI.Widget, { this.navigation = BI.createWidget({ type: "bi.navigation", element: this, + single: true, logic: { dynamic: true }, tab: { - cls: "year-popup-navigation bi-border-top", + cls: "year-popup-navigation bi-high-light bi-border-top", height: 25, items: [backBtn, preBtn] }, @@ -16882,6 +16900,8 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, height: 25 }); }, @@ -16890,20 +16910,28 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; this.year = BI.createWidget({ - type: "bi.year_combo" + type: "bi.year_combo", + behaviors: o.yearBehaviors }); this.month = BI.createWidget({ - type: "bi.month_combo" + type: "bi.month_combo", + behaviors: o.monthBehaviors }); - this.year.on(BI.YearCombo.EVENT_CONFIRM, function(){ + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); - this.month.on(BI.MonthCombo.EVENT_CONFIRM, function(){ + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); BI.createWidget({ type: "bi.center", @@ -16928,6 +16956,7 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { } }); BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** * 年份 + 月份下拉框 * @@ -16938,6 +16967,8 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, height: 25 }); }, @@ -16946,20 +16977,28 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; this.year = BI.createWidget({ - type: "bi.year_combo" + type: "bi.year_combo", + behaviors: o.yearBehaviors }); this.quarter = BI.createWidget({ - type: "bi.quarter_combo" + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors }); - this.year.on(BI.YearCombo.EVENT_CONFIRM, function(){ + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); - this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function(){ + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); BI.createWidget({ type: "bi.center", @@ -16984,6 +17023,7 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { } }); BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 * 封装了字段处理逻辑 diff --git a/docs/base.js b/docs/base.js index c5c7353c3..460bfb704 100644 --- a/docs/base.js +++ b/docs/base.js @@ -3264,11 +3264,6 @@ BI.Combo = BI.inherit(BI.Widget, { return this.position; }, - doBehavior: function () { - this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - toggle: function () { this._toggle(); }, @@ -3532,11 +3527,6 @@ BI.Expander = BI.inherit(BI.Widget, { return this.popupView; }, - doBehavior: function () { - //this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - getAllLeaves: function () { return this.popupView && this.popupView.getAllLeaves(); }, @@ -3946,10 +3936,6 @@ BI.Loader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, @@ -4704,11 +4690,6 @@ BI.Switcher = BI.inherit(BI.Widget, { this.isViewVisible() && BI.Maskers.show(this.getName()); }, - doBehavior: function () { - this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - getAllLeaves: function () { return this.popupView && this.popupView.getAllLeaves(); }, @@ -19638,7 +19619,7 @@ BI.Label = BI.inherit(BI.Single, { } if (o.whiteSpace == "normal") { this.text = BI.createWidget(json); - this.text = BI.createWidget({ + BI.createWidget({ type: "bi.center_adapt", hgap: o.hgap, vgap: o.vgap, @@ -19836,7 +19817,7 @@ BI.Label = BI.inherit(BI.Single, { } if (o.whiteSpace == "normal") { this.text = BI.createWidget(json) - this.text = BI.createWidget({ + BI.createWidget({ type: "bi.vertical_adapt", scrollable: o.whiteSpace === "normal", hgap: o.hgap, @@ -33019,10 +33000,6 @@ BI.CustomTree = BI.inherit(BI.Widget, { this.tree.populate.apply(this.tree, args); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree && this.tree.setValue(v); }, diff --git a/docs/case.js b/docs/case.js index 7090b6ee8..060b96bfe 100644 --- a/docs/case.js +++ b/docs/case.js @@ -1820,6 +1820,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { var conf = BI.YearCalendar.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: "bi-year-calendar", + behaviors: {}, logic: { dynamic: false }, @@ -1884,6 +1885,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { 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, @@ -8360,10 +8362,6 @@ BI.ListPane = BI.inherit(BI.Pane, { this.button_group.empty(); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, @@ -8653,10 +8651,6 @@ BI.SelectList = BI.inherit(BI.Widget, { this.list.element.css({"max-height": h - toolHeight + "px"}) }, - doBehavior: function () { - this.list.doBehavior.apply(this.list, arguments); - }, - setNotSelectedValue: function () { this.list.setNotSelectedValue.apply(this.list, arguments); this._checkAllSelected(); @@ -8751,10 +8745,6 @@ BI.LazyLoader = BI.inherit(BI.Widget, { this.loader.empty(); }, - doBehavior: function () { - this.loader.doBehavior(); - }, - setNotSelectedValue: function () { this.loader.setNotSelectedValue.apply(this.loader, arguments); }, @@ -8950,10 +8940,6 @@ BI.ListLoader = BI.inherit(BI.Widget, { }); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, @@ -9122,10 +9108,6 @@ BI.SortList = BI.inherit(BI.Widget, { this.loader.empty(); }, - doBehavior: function () { - this.loader.doBehavior.apply(this.loader, arguments); - }, - setNotSelectedValue: function () { this.loader.setNotSelectedValue.apply(this.loader, arguments); }, @@ -12126,10 +12108,6 @@ BI.LevelTree = BI.inherit(BI.Widget, { this.tree.populate(items); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, diff --git a/docs/core.js b/docs/core.js index b89a7f08d..44cbced69 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14579,6 +14579,14 @@ BI.Widget = BI.inherit(BI.OB, { } }, + doBehavior: function () { + var args = arguments; + //递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + child.doBehavior && child.doBehavior.apply(child, args); + }); + }, + getWidth: function () { return this.options.width; }, @@ -20620,26 +20628,34 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { * @extends BI.Behavior */ BI.HighlightBehavior = BI.inherit(BI.Behavior, { - _defaultConfig: function() { - return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), { - - }); + _defaultConfig: function () { + return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), {}); }, - _init : function() { + _init: function () { BI.HighlightBehavior.superclass._init.apply(this, arguments); }, - doBehavior: function(items){ + doBehavior: function (items) { var args = Array.prototype.slice.call(arguments, 1), o = this.options; - BI.each(items, function(i, item){ - if(item instanceof BI.Single) { - if (o.rule(item.getValue(), item)) { - item.doHighLight.apply(item, args); + BI.each(items, function (i, item) { + if (item instanceof BI.Single) { + var rule = o.rule(item.getValue(), item); + + function doBe(run) { + if (run === true) { + item.doHighLight.apply(item, args); + } else { + item.unHighLight.apply(item, args); + } + } + + if (BI.isFunction(rule)) { + rule(doBe); } else { - item.unHighLight.apply(item, args); + doBe(rule); } } else { item.doBehavior.apply(item, args); diff --git a/docs/widget.css b/docs/widget.css index 474396fdf..85b1f4c3e 100644 --- a/docs/widget.css +++ b/docs/widget.css @@ -516,7 +516,6 @@ /**** custom color(自定义颜色,用于特定场景) ****/ .bi-year-popup .year-popup-navigation { line-height: 30px; - color: #3f8ce8; } .bi-year-popup .year-popup-navigation > .center-element { border-left: 1px solid #d4dadd; diff --git a/docs/widget.js b/docs/widget.js index dd99f936f..899371cdd 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -7739,6 +7739,7 @@ BI.MonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-month-combo", + behaviors: {}, height: 25 }); }, @@ -7751,9 +7752,9 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { - if(this.getKey() && this.getKey() !== self.storeValue) { + if (this.getKey() && this.getKey() !== self.storeValue) { self.setValue(this.getValue()); - }else if(!this.getKey()){ + } else if (!this.getKey()) { self.setValue(); } self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); @@ -7774,7 +7775,8 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ - type: "bi.month_popup" + type: "bi.month_popup", + behaviors: o.behaviors }); this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -7792,7 +7794,10 @@ BI.MonthCombo = BI.inherit(BI.Widget, { minWidth: 85, el: this.popup } - }) + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); + }); }, setValue: function (v) { @@ -7806,6 +7811,7 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.month_combo', BI.MonthCombo);/** * 月份展示面板 * @@ -7817,13 +7823,14 @@ BI.MonthPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-popup" + baseCls: "bi-month-popup", + behaviors: {} }); }, _init: function () { BI.MonthPopup.superclass._init.apply(this, arguments); - var self = this; + var self = this, o = this.options; //纵向排列月 var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; @@ -7854,6 +7861,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, { this.month = BI.createWidget({ type: "bi.button_group", element: this, + behaviors: o.behaviors, items: BI.createItems(items, {}), layouts: [BI.LogicFactory.createLogic("table", BI.extend({ dynamic: true @@ -8170,10 +8178,6 @@ BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, @@ -8715,10 +8719,6 @@ BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, @@ -13976,6 +13976,7 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-quarter-combo", + behaviors: {}, height: 25 }); }, @@ -13996,24 +13997,25 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { self.combo.isViewVisible() && self.combo.hideView(); }); - this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function(){ + this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { if (!self.combo.isViewVisible()) { self.combo.showView(); } }); this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { - if(self.combo.isViewVisible()) { + if (self.combo.isViewVisible()) { return; } - if(this.getKey() && this.getKey() !== self.storeValue) { + if (this.getKey() && this.getKey() !== self.storeValue) { self.setValue(this.getKey()); - }else if(!this.getKey()){ + } else if (!this.getKey()) { self.setValue(); } self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); }); this.popup = BI.createWidget({ - type: "bi.quarter_popup" + type: "bi.quarter_popup", + behaviors: o.behaviors }); this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { @@ -14033,6 +14035,9 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { el: this.popup } }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); }, setValue: function (v) { @@ -14046,6 +14051,7 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { }); BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.quarter_combo', BI.QuarterCombo);/** * 季度展示面板 * @@ -14057,13 +14063,14 @@ BI.QuarterPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-quarter-popup" + baseCls: "bi-quarter-popup", + behaviors: {} }); }, _init: function () { BI.QuarterPopup.superclass._init.apply(this, arguments); - var self = this; + var self = this, o = this.options; var items = [{ text: Date._QN[01], @@ -14093,6 +14100,7 @@ BI.QuarterPopup = BI.inherit(BI.Widget, { this.quarter = BI.createWidget({ type: "bi.button_group", element: this, + behaviors: o.behaviors, items: BI.createItems(items, {}), layouts: [{ type: "bi.vertical" @@ -16581,6 +16589,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-combo", + behaviors: {}, min: '1900-01-01', //最小日期 max: '2099-12-31', //最大日期 height: 25 @@ -16608,7 +16617,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { self.combo.isViewVisible() && self.combo.hideView(); }); this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () { - if(self.combo.isViewVisible()) { + if (self.combo.isViewVisible()) { return; } if (this.getKey() && this.getKey() !== self.storeValue) { @@ -16619,45 +16628,50 @@ BI.YearCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.YearCombo.EVENT_CONFIRM); }); - this.popup = BI.createWidget({ - type: "bi.year_popup", - min: o.min, - max: o.max - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.YearCombo.EVENT_CONFIRM); - }); - this.combo = BI.createWidget({ type: "bi.combo", element: this, + destroyWhenHide: true, isNeedAdjustHeight: false, isNeedAdjustWidth: false, el: this.trigger, popup: { minWidth: 85, stopPropagation: false, - el: this.popup + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } } }); this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { var value = self.trigger.getKey(); if (BI.isNotNull(value)) { self.popup.setValue(value); - } else if(!value && value !== self.storeValue){ + } else if (!value && value !== self.storeValue) { self.popup.setValue(self.storeValue); - }else { + } else { self.setValue(); } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); }); }, setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); + this.combo.setValue(v); }, getValue: function () { @@ -16665,6 +16679,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { } }); BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_combo', BI.YearCombo);/** * 年份展示面板 * @@ -16677,6 +16692,7 @@ BI.YearPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-popup", + behaviors: {}, min: '1900-01-01', //最小日期 max: '2099-12-31' //最大日期 }); @@ -16687,6 +16703,7 @@ BI.YearPopup = BI.inherit(BI.Widget, { var calendar = BI.createWidget({ type: "bi.year_calendar", + behaviors: o.behaviors, min: o.min, max: o.max, logic: { @@ -16723,11 +16740,12 @@ BI.YearPopup = BI.inherit(BI.Widget, { this.navigation = BI.createWidget({ type: "bi.navigation", element: this, + single: true, logic: { dynamic: true }, tab: { - cls: "year-popup-navigation bi-border-top", + cls: "year-popup-navigation bi-high-light bi-border-top", height: 25, items: [backBtn, preBtn] }, @@ -16882,6 +16900,8 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, height: 25 }); }, @@ -16890,20 +16910,28 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; this.year = BI.createWidget({ - type: "bi.year_combo" + type: "bi.year_combo", + behaviors: o.yearBehaviors }); this.month = BI.createWidget({ - type: "bi.month_combo" + type: "bi.month_combo", + behaviors: o.monthBehaviors }); - this.year.on(BI.YearCombo.EVENT_CONFIRM, function(){ + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); - this.month.on(BI.MonthCombo.EVENT_CONFIRM, function(){ + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); BI.createWidget({ type: "bi.center", @@ -16928,6 +16956,7 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { } }); BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_month_combo', BI.YearMonthCombo);/** * 年份 + 月份下拉框 * @@ -16938,6 +16967,8 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, height: 25 }); }, @@ -16946,20 +16977,28 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; this.year = BI.createWidget({ - type: "bi.year_combo" + type: "bi.year_combo", + behaviors: o.yearBehaviors }); this.quarter = BI.createWidget({ - type: "bi.quarter_combo" + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors }); - this.year.on(BI.YearCombo.EVENT_CONFIRM, function(){ + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); - this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function(){ + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); BI.createWidget({ type: "bi.center", @@ -16984,6 +17023,7 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { } }); BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/** * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 * 封装了字段处理逻辑 diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 2f79b2930..4b20149d7 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -375,11 +375,6 @@ BI.Combo = BI.inherit(BI.Widget, { return this.position; }, - doBehavior: function () { - this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - toggle: function () { this._toggle(); }, diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index 8c57326af..55b9c2b61 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -235,11 +235,6 @@ BI.Expander = BI.inherit(BI.Widget, { return this.popupView; }, - doBehavior: function () { - //this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - getAllLeaves: function () { return this.popupView && this.popupView.getAllLeaves(); }, diff --git a/src/base/combination/loader.js b/src/base/combination/loader.js index ee25cd4ae..9b6acbb9f 100644 --- a/src/base/combination/loader.js +++ b/src/base/combination/loader.js @@ -195,10 +195,6 @@ BI.Loader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, diff --git a/src/base/combination/switcher.js b/src/base/combination/switcher.js index a4edaec70..650d91943 100644 --- a/src/base/combination/switcher.js +++ b/src/base/combination/switcher.js @@ -239,11 +239,6 @@ BI.Switcher = BI.inherit(BI.Widget, { this.isViewVisible() && BI.Maskers.show(this.getName()); }, - doBehavior: function () { - this._assertPopupView(); - this.popupView && this.popupView.doBehavior.apply(this.popupView, arguments); - }, - getAllLeaves: function () { return this.popupView && this.popupView.getAllLeaves(); }, diff --git a/src/base/single/label/label.js b/src/base/single/label/label.js index 458ac5a11..bbb0deb48 100644 --- a/src/base/single/label/label.js +++ b/src/base/single/label/label.js @@ -147,7 +147,7 @@ BI.Label = BI.inherit(BI.Single, { } if (o.whiteSpace == "normal") { this.text = BI.createWidget(json); - this.text = BI.createWidget({ + BI.createWidget({ type: "bi.center_adapt", hgap: o.hgap, vgap: o.vgap, @@ -345,7 +345,7 @@ BI.Label = BI.inherit(BI.Single, { } if (o.whiteSpace == "normal") { this.text = BI.createWidget(json) - this.text = BI.createWidget({ + BI.createWidget({ type: "bi.vertical_adapt", scrollable: o.whiteSpace === "normal", hgap: o.hgap, diff --git a/src/base/tree/customtree.js b/src/base/tree/customtree.js index 1d5342ae8..96a692fe0 100644 --- a/src/base/tree/customtree.js +++ b/src/base/tree/customtree.js @@ -113,10 +113,6 @@ BI.CustomTree = BI.inherit(BI.Widget, { this.tree.populate.apply(this.tree, args); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree && this.tree.setValue(v); }, diff --git a/src/case/calendar/calendar.year.js b/src/case/calendar/calendar.year.js index 1d9467a86..b9ca8a14f 100644 --- a/src/case/calendar/calendar.year.js +++ b/src/case/calendar/calendar.year.js @@ -9,6 +9,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { var conf = BI.YearCalendar.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { baseCls: "bi-year-calendar", + behaviors: {}, logic: { dynamic: false }, @@ -73,6 +74,7 @@ BI.YearCalendar = BI.inherit(BI.Widget, { 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, diff --git a/src/case/layer/pane.list.js b/src/case/layer/pane.list.js index fcedfc8b3..2e1782635 100644 --- a/src/case/layer/pane.list.js +++ b/src/case/layer/pane.list.js @@ -127,10 +127,6 @@ BI.ListPane = BI.inherit(BI.Pane, { this.button_group.empty(); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, diff --git a/src/case/list/list.select.js b/src/case/list/list.select.js index 4c3ad99d4..26d1297b8 100644 --- a/src/case/list/list.select.js +++ b/src/case/list/list.select.js @@ -164,10 +164,6 @@ BI.SelectList = BI.inherit(BI.Widget, { this.list.element.css({"max-height": h - toolHeight + "px"}) }, - doBehavior: function () { - this.list.doBehavior.apply(this.list, arguments); - }, - setNotSelectedValue: function () { this.list.setNotSelectedValue.apply(this.list, arguments); this._checkAllSelected(); diff --git a/src/case/loader/loader.lazy.js b/src/case/loader/loader.lazy.js index 76fa3ea99..2f3d6859c 100644 --- a/src/case/loader/loader.lazy.js +++ b/src/case/loader/loader.lazy.js @@ -54,10 +54,6 @@ BI.LazyLoader = BI.inherit(BI.Widget, { this.loader.empty(); }, - doBehavior: function () { - this.loader.doBehavior(); - }, - setNotSelectedValue: function () { this.loader.setNotSelectedValue.apply(this.loader, arguments); }, diff --git a/src/case/loader/loader.list.js b/src/case/loader/loader.list.js index 22c81eb1f..b855c34a2 100644 --- a/src/case/loader/loader.list.js +++ b/src/case/loader/loader.list.js @@ -148,10 +148,6 @@ BI.ListLoader = BI.inherit(BI.Widget, { }); }, - doBehavior: function () { - this.button_group.doBehavior.apply(this.button_group, arguments); - }, - setNotSelectedValue: function () { this.button_group.setNotSelectedValue.apply(this.button_group, arguments); }, diff --git a/src/case/loader/sort.list.js b/src/case/loader/sort.list.js index 776434140..c452307ff 100644 --- a/src/case/loader/sort.list.js +++ b/src/case/loader/sort.list.js @@ -121,10 +121,6 @@ BI.SortList = BI.inherit(BI.Widget, { this.loader.empty(); }, - doBehavior: function () { - this.loader.doBehavior.apply(this.loader, arguments); - }, - setNotSelectedValue: function () { this.loader.setNotSelectedValue.apply(this.loader, arguments); }, diff --git a/src/case/tree/tree.level.js b/src/case/tree/tree.level.js index 290dc1462..3ca6a75dc 100644 --- a/src/case/tree/tree.level.js +++ b/src/case/tree/tree.level.js @@ -108,10 +108,6 @@ BI.LevelTree = BI.inherit(BI.Widget, { this.tree.populate(items); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, diff --git a/src/core/behavior/behavior.highlight.js b/src/core/behavior/behavior.highlight.js index e91c2af2f..2dfe3f10e 100644 --- a/src/core/behavior/behavior.highlight.js +++ b/src/core/behavior/behavior.highlight.js @@ -5,26 +5,34 @@ * @extends BI.Behavior */ BI.HighlightBehavior = BI.inherit(BI.Behavior, { - _defaultConfig: function() { - return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), { - - }); + _defaultConfig: function () { + return BI.extend(BI.HighlightBehavior.superclass._defaultConfig.apply(this, arguments), {}); }, - _init : function() { + _init: function () { BI.HighlightBehavior.superclass._init.apply(this, arguments); }, - doBehavior: function(items){ + doBehavior: function (items) { var args = Array.prototype.slice.call(arguments, 1), o = this.options; - BI.each(items, function(i, item){ - if(item instanceof BI.Single) { - if (o.rule(item.getValue(), item)) { - item.doHighLight.apply(item, args); + BI.each(items, function (i, item) { + if (item instanceof BI.Single) { + var rule = o.rule(item.getValue(), item); + + function doBe(run) { + if (run === true) { + item.doHighLight.apply(item, args); + } else { + item.unHighLight.apply(item, args); + } + } + + if (BI.isFunction(rule)) { + rule(doBe); } else { - item.unHighLight.apply(item, args); + doBe(rule); } } else { item.doBehavior.apply(item, args); diff --git a/src/core/widget.js b/src/core/widget.js index 610b38492..cd4ae58be 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -254,6 +254,14 @@ BI.Widget = BI.inherit(BI.OB, { } }, + doBehavior: function () { + var args = arguments; + //递归将所有子组件使有效 + BI.each(this._children, function (i, child) { + child.doBehavior && child.doBehavior.apply(child, args); + }); + }, + getWidth: function () { return this.options.width; }, diff --git a/src/css/widget/year/popup.year.css b/src/css/widget/year/popup.year.css index fa13c362d..f68a42e69 100644 --- a/src/css/widget/year/popup.year.css +++ b/src/css/widget/year/popup.year.css @@ -3,7 +3,6 @@ /**** custom color(自定义颜色,用于特定场景) ****/ .bi-year-popup .year-popup-navigation { line-height: 30px; - color: #3f8ce8; } .bi-year-popup .year-popup-navigation > .center-element { border-left: 1px solid #d4dadd; diff --git a/src/less/widget/year/popup.year.less b/src/less/widget/year/popup.year.less index 949f7c516..5ef0f5bc0 100644 --- a/src/less/widget/year/popup.year.less +++ b/src/less/widget/year/popup.year.less @@ -3,7 +3,6 @@ .bi-year-popup { & .year-popup-navigation { line-height: 30px; - color: @color-bi-text-highlight; & > .center-element { border-left: 1px solid @color-bi-border-line; } diff --git a/src/widget/month/combo.month.js b/src/widget/month/combo.month.js index 6e2e719e6..db44f7953 100644 --- a/src/widget/month/combo.month.js +++ b/src/widget/month/combo.month.js @@ -9,6 +9,7 @@ BI.MonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-month-combo", + behaviors: {}, height: 25 }); }, @@ -21,9 +22,9 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { - if(this.getKey() && this.getKey() !== self.storeValue) { + if (this.getKey() && this.getKey() !== self.storeValue) { self.setValue(this.getValue()); - }else if(!this.getKey()){ + } else if (!this.getKey()) { self.setValue(); } self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); @@ -44,7 +45,8 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ - type: "bi.month_popup" + type: "bi.month_popup", + behaviors: o.behaviors }); this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -62,7 +64,10 @@ BI.MonthCombo = BI.inherit(BI.Widget, { minWidth: 85, el: this.popup } - }) + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); + }); }, setValue: function (v) { @@ -76,4 +81,5 @@ BI.MonthCombo = BI.inherit(BI.Widget, { }); BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.month_combo', BI.MonthCombo); \ No newline at end of file diff --git a/src/widget/month/popup.month.js b/src/widget/month/popup.month.js index 1ad5e7743..16373e113 100644 --- a/src/widget/month/popup.month.js +++ b/src/widget/month/popup.month.js @@ -9,13 +9,14 @@ BI.MonthPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-popup" + baseCls: "bi-month-popup", + behaviors: {} }); }, _init: function () { BI.MonthPopup.superclass._init.apply(this, arguments); - var self = this; + var self = this, o = this.options; //纵向排列月 var month = [0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11]; @@ -46,6 +47,7 @@ BI.MonthPopup = BI.inherit(BI.Widget, { this.month = BI.createWidget({ type: "bi.button_group", element: this, + behaviors: o.behaviors, items: BI.createItems(items, {}), layouts: [BI.LogicFactory.createLogic("table", BI.extend({ dynamic: true diff --git a/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js b/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js index edcbb12e3..30a5ec2de 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.leveltree.js @@ -103,10 +103,6 @@ BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, diff --git a/src/widget/multilayersingletree/multilayersingletree.leveltree.js b/src/widget/multilayersingletree/multilayersingletree.leveltree.js index ad02ec40f..057b41d2f 100644 --- a/src/widget/multilayersingletree/multilayersingletree.leveltree.js +++ b/src/widget/multilayersingletree/multilayersingletree.leveltree.js @@ -106,10 +106,6 @@ BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); }, - doBehavior: function () { - this.tree.doBehavior.apply(this.tree, arguments); - }, - setValue: function (v) { this.tree.setValue(v); }, diff --git a/src/widget/quarter/combo.quarter.js b/src/widget/quarter/combo.quarter.js index 0d31ba6aa..662f72267 100644 --- a/src/widget/quarter/combo.quarter.js +++ b/src/widget/quarter/combo.quarter.js @@ -9,6 +9,7 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-quarter-combo", + behaviors: {}, height: 25 }); }, @@ -29,24 +30,25 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { self.combo.isViewVisible() && self.combo.hideView(); }); - this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function(){ + this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { if (!self.combo.isViewVisible()) { self.combo.showView(); } }); this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { - if(self.combo.isViewVisible()) { + if (self.combo.isViewVisible()) { return; } - if(this.getKey() && this.getKey() !== self.storeValue) { + if (this.getKey() && this.getKey() !== self.storeValue) { self.setValue(this.getKey()); - }else if(!this.getKey()){ + } else if (!this.getKey()) { self.setValue(); } self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); }); this.popup = BI.createWidget({ - type: "bi.quarter_popup" + type: "bi.quarter_popup", + behaviors: o.behaviors }); this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { @@ -66,6 +68,9 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { el: this.popup } }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); }, setValue: function (v) { @@ -79,4 +84,5 @@ BI.QuarterCombo = BI.inherit(BI.Widget, { }); BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.quarter_combo', BI.QuarterCombo); \ No newline at end of file diff --git a/src/widget/quarter/popup.quarter.js b/src/widget/quarter/popup.quarter.js index 1deeb8e1d..4fedb4e6a 100644 --- a/src/widget/quarter/popup.quarter.js +++ b/src/widget/quarter/popup.quarter.js @@ -9,13 +9,14 @@ BI.QuarterPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-quarter-popup" + baseCls: "bi-quarter-popup", + behaviors: {} }); }, _init: function () { BI.QuarterPopup.superclass._init.apply(this, arguments); - var self = this; + var self = this, o = this.options; var items = [{ text: Date._QN[01], @@ -45,6 +46,7 @@ BI.QuarterPopup = BI.inherit(BI.Widget, { this.quarter = BI.createWidget({ type: "bi.button_group", element: this, + behaviors: o.behaviors, items: BI.createItems(items, {}), layouts: [{ type: "bi.vertical" diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index d789c84a1..ad7bdedb4 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -9,6 +9,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-combo", + behaviors: {}, min: '1900-01-01', //最小日期 max: '2099-12-31', //最大日期 height: 25 @@ -36,7 +37,7 @@ BI.YearCombo = BI.inherit(BI.Widget, { self.combo.isViewVisible() && self.combo.hideView(); }); this.trigger.on(BI.YearTrigger.EVENT_CONFIRM, function () { - if(self.combo.isViewVisible()) { + if (self.combo.isViewVisible()) { return; } if (this.getKey() && this.getKey() !== self.storeValue) { @@ -47,45 +48,50 @@ BI.YearCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.YearCombo.EVENT_CONFIRM); }); - this.popup = BI.createWidget({ - type: "bi.year_popup", - min: o.min, - max: o.max - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.YearCombo.EVENT_CONFIRM); - }); - this.combo = BI.createWidget({ type: "bi.combo", element: this, + destroyWhenHide: true, isNeedAdjustHeight: false, isNeedAdjustWidth: false, el: this.trigger, popup: { minWidth: 85, stopPropagation: false, - el: this.popup + el: { + type: "bi.year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.YearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + } } }); this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { var value = self.trigger.getKey(); if (BI.isNotNull(value)) { self.popup.setValue(value); - } else if(!value && value !== self.storeValue){ + } else if (!value && value !== self.storeValue) { self.popup.setValue(self.storeValue); - }else { + } else { self.setValue(); } + self.fireEvent(BI.YearCombo.EVENT_BEFORE_POPUPVIEW); }); }, setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); + this.combo.setValue(v); }, getValue: function () { @@ -93,4 +99,5 @@ BI.YearCombo = BI.inherit(BI.Widget, { } }); BI.YearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_combo', BI.YearCombo); \ No newline at end of file diff --git a/src/widget/year/popup.year.js b/src/widget/year/popup.year.js index cda353b12..bbee27655 100644 --- a/src/widget/year/popup.year.js +++ b/src/widget/year/popup.year.js @@ -10,6 +10,7 @@ BI.YearPopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-popup", + behaviors: {}, min: '1900-01-01', //最小日期 max: '2099-12-31' //最大日期 }); @@ -20,6 +21,7 @@ BI.YearPopup = BI.inherit(BI.Widget, { var calendar = BI.createWidget({ type: "bi.year_calendar", + behaviors: o.behaviors, min: o.min, max: o.max, logic: { @@ -56,11 +58,12 @@ BI.YearPopup = BI.inherit(BI.Widget, { this.navigation = BI.createWidget({ type: "bi.navigation", element: this, + single: true, logic: { dynamic: true }, tab: { - cls: "year-popup-navigation bi-border-top", + cls: "year-popup-navigation bi-high-light bi-border-top", height: 25, items: [backBtn, preBtn] }, diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 169c96862..5780cc57d 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -8,6 +8,8 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearMonthCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-month-combo", + yearBehaviors: {}, + monthBehaviors: {}, height: 25 }); }, @@ -16,20 +18,28 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; this.year = BI.createWidget({ - type: "bi.year_combo" + type: "bi.year_combo", + behaviors: o.yearBehaviors }); this.month = BI.createWidget({ - type: "bi.month_combo" + type: "bi.month_combo", + behaviors: o.monthBehaviors }); - this.year.on(BI.YearCombo.EVENT_CONFIRM, function(){ + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); - this.month.on(BI.MonthCombo.EVENT_CONFIRM, function(){ + this.month.on(BI.MonthCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearMonthCombo.EVENT_CONFIRM); }); + this.month.on(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); BI.createWidget({ type: "bi.center", @@ -54,4 +64,5 @@ BI.YearMonthCombo = BI.inherit(BI.Widget, { } }); BI.YearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_month_combo', BI.YearMonthCombo); \ No newline at end of file diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js index 3cb47364c..4671edb1c 100644 --- a/src/widget/yearquarter/combo.yearquarter.js +++ b/src/widget/yearquarter/combo.yearquarter.js @@ -8,6 +8,8 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.YearQuarterCombo.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-year-quarter-combo", + yearBehaviors: {}, + quarterBehaviors: {}, height: 25 }); }, @@ -16,20 +18,28 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; this.year = BI.createWidget({ - type: "bi.year_combo" + type: "bi.year_combo", + behaviors: o.yearBehaviors }); this.quarter = BI.createWidget({ - type: "bi.quarter_combo" + type: "bi.quarter_combo", + behaviors: o.quarterBehaviors }); - this.year.on(BI.YearCombo.EVENT_CONFIRM, function(){ + this.year.on(BI.YearCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); }); + this.year.on(BI.YearCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); - this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function(){ + this.quarter.on(BI.QuarterCombo.EVENT_CONFIRM, function () { self.fireEvent(BI.YearQuarterCombo.EVENT_CONFIRM); }); + this.quarter.on(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); BI.createWidget({ type: "bi.center", @@ -54,4 +64,5 @@ BI.YearQuarterCombo = BI.inherit(BI.Widget, { } }); BI.YearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.YearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo); \ No newline at end of file