From ce809e81cc2d72d7f3863176cbbf684d6a6f175e Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 16 May 2017 16:40:43 +0800 Subject: [PATCH 1/9] BI-5304 --- bi/core.js | 20 +++++++++++++------- docs/core.js | 20 +++++++++++++------- src/core/func/dom.js | 19 ++++++++++++------- src/core/func/function.js | 1 + 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/bi/core.js b/bi/core.js index 304ef4664f..831f85dedd 100644 --- a/bi/core.js +++ b/bi/core.js @@ -16027,7 +16027,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = keyword + ""; + keyword = BI.makeFirstPY(keyword + ""); keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -16272,7 +16272,8 @@ BI.extend(jQuery, { getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top, adaptHeight; if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboOffset.top + extraHeight; @@ -16320,7 +16321,8 @@ BI.extend(jQuery, { getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top, adaptHeight; if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight; @@ -16346,7 +16348,8 @@ BI.extend(jQuery, { getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); if ($.isBottomSpaceEnough(combo, popup, extraHeight)) { return $.getBottomPosition(combo, popup, extraHeight); } @@ -16369,7 +16372,8 @@ BI.extend(jQuery, { getCenterAdaptPosition: function (combo, popup) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var left; if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) { left = windowBounds.width - popupBounds.width; @@ -16386,7 +16390,8 @@ BI.extend(jQuery, { getMiddleAdaptPosition: function (combo, popup) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top; if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) { top = windowBounds.height - popupBounds.height; @@ -16582,7 +16587,7 @@ BI.extend(jQuery, { } break; } - if(needAdaptHeight === true) { + if (needAdaptHeight === true) { popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight)); } return position; @@ -16613,6 +16618,7 @@ $(function () { }; } var t, text, py; + keyword = BI.makeFirstPY(keyword); keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { diff --git a/docs/core.js b/docs/core.js index c5b0bd7516..a2079958a0 100644 --- a/docs/core.js +++ b/docs/core.js @@ -22050,7 +22050,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = keyword + ""; + keyword = BI.makeFirstPY(keyword + ""); keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -22295,7 +22295,8 @@ BI.extend(jQuery, { getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top, adaptHeight; if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboOffset.top + extraHeight; @@ -22343,7 +22344,8 @@ BI.extend(jQuery, { getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top, adaptHeight; if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight; @@ -22369,7 +22371,8 @@ BI.extend(jQuery, { getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); if ($.isBottomSpaceEnough(combo, popup, extraHeight)) { return $.getBottomPosition(combo, popup, extraHeight); } @@ -22392,7 +22395,8 @@ BI.extend(jQuery, { getCenterAdaptPosition: function (combo, popup) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var left; if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) { left = windowBounds.width - popupBounds.width; @@ -22409,7 +22413,8 @@ BI.extend(jQuery, { getMiddleAdaptPosition: function (combo, popup) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top; if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) { top = windowBounds.height - popupBounds.height; @@ -22605,7 +22610,7 @@ BI.extend(jQuery, { } break; } - if(needAdaptHeight === true) { + if (needAdaptHeight === true) { popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight)); } return position; @@ -22636,6 +22641,7 @@ $(function () { }; } var t, text, py; + keyword = BI.makeFirstPY(keyword); keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { diff --git a/src/core/func/dom.js b/src/core/func/dom.js index b8c9d6505f..b2bbfa8c7f 100644 --- a/src/core/func/dom.js +++ b/src/core/func/dom.js @@ -22,7 +22,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = keyword + ""; + keyword = BI.makeFirstPY(keyword + ""); keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -267,7 +267,8 @@ BI.extend(jQuery, { getTopAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top, adaptHeight; if ($.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboOffset.top + extraHeight; @@ -315,7 +316,8 @@ BI.extend(jQuery, { getBottomAlignPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top, adaptHeight; if ($.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboOffset.top + comboBounds.height - popupBounds.height - extraHeight; @@ -341,7 +343,8 @@ BI.extend(jQuery, { getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); if ($.isBottomSpaceEnough(combo, popup, extraHeight)) { return $.getBottomPosition(combo, popup, extraHeight); } @@ -364,7 +367,8 @@ BI.extend(jQuery, { getCenterAdaptPosition: function (combo, popup) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var left; if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) { left = windowBounds.width - popupBounds.width; @@ -381,7 +385,8 @@ BI.extend(jQuery, { getMiddleAdaptPosition: function (combo, popup) { var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), windowBounds = $("body").bounds(); + var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), + windowBounds = $("body").bounds(); var top; if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) { top = windowBounds.height - popupBounds.height; @@ -577,7 +582,7 @@ BI.extend(jQuery, { } break; } - if(needAdaptHeight === true) { + if (needAdaptHeight === true) { popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top, maxHeight)); } return position; diff --git a/src/core/func/function.js b/src/core/func/function.js index d212ba5f4a..f388560c49 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -24,6 +24,7 @@ $(function () { }; } var t, text, py; + keyword = BI.makeFirstPY(keyword); keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { From 11f9fb0ddadde4996b357a07dc65405e121ac229 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 16 May 2017 20:09:34 +0800 Subject: [PATCH 2/9] add --- bi/core.js | 4 ++-- docs/core.js | 4 ++-- src/core/func/dom.js | 2 +- src/core/func/function.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bi/core.js b/bi/core.js index 831f85dedd..403f644434 100644 --- a/bi/core.js +++ b/bi/core.js @@ -16027,7 +16027,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = BI.makeFirstPY(keyword + ""); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -16618,7 +16618,7 @@ $(function () { }; } var t, text, py; - keyword = BI.makeFirstPY(keyword); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { diff --git a/docs/core.js b/docs/core.js index a2079958a0..993453b35a 100644 --- a/docs/core.js +++ b/docs/core.js @@ -22050,7 +22050,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = BI.makeFirstPY(keyword + ""); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; @@ -22641,7 +22641,7 @@ $(function () { }; } var t, text, py; - keyword = BI.makeFirstPY(keyword); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { diff --git a/src/core/func/dom.js b/src/core/func/dom.js index b2bbfa8c7f..979b7a64bc 100644 --- a/src/core/func/dom.js +++ b/src/core/func/dom.js @@ -22,7 +22,7 @@ BI.extend(jQuery.fn, { if (!BI.isKey(keyword)) { return this.text((text + "").replaceAll(" ", " ")); } - keyword = BI.makeFirstPY(keyword + ""); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var textLeft = (text || "") + ""; py = (py || BI.makeFirstPY(text)) + ""; diff --git a/src/core/func/function.js b/src/core/func/function.js index f388560c49..b6132b09c5 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -24,7 +24,7 @@ $(function () { }; } var t, text, py; - keyword = BI.makeFirstPY(keyword); + keyword = keyword + ""; keyword = BI.toUpperCase(keyword); var matched = isArray ? [] : {}, finded = isArray ? [] : {}; BI.each(items, function (i, item) { From 43d8ff77ddc8a160ae92022d54178f15418992aa Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 02:20:05 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9E=81=E5=A4=A7=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 58 ++++++++++++++++-------------- bi/core.js | 8 +++-- docs/base.js | 58 ++++++++++++++++-------------- docs/core.js | 8 +++-- src/base/collection/collection.js | 21 ++++++----- src/base/grid/grid.js | 21 ++++++----- src/base/table/table.collection.js | 8 ++--- src/base/table/table.grid.js | 8 ++--- src/core/widget.js | 8 +++-- 9 files changed, 114 insertions(+), 84 deletions(-) diff --git a/bi/base.js b/bi/base.js index 382be5a933..b9e75adb9a 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2511,15 +2511,15 @@ BI.Canvas = BI.inherit(BI.Widget, { } }); BI.shortcut("bi.canvas", BI.Canvas);/** - * Collection + * CollectionView * * Created by GUY on 2016/1/15. - * @class BI.Collection + * @class BI.CollectionView * @extends BI.Widget */ -BI.Collection = BI.inherit(BI.Widget, { +BI.CollectionView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-collection", width: 400, height: 300, @@ -2535,7 +2535,7 @@ BI.Collection = BI.inherit(BI.Widget, { }, _init: function () { - BI.Collection.superclass._init.apply(this, arguments); + BI.CollectionView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -2554,7 +2554,7 @@ BI.Collection = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Collection.EVENT_SCROLL, { + self.fireEvent(BI.CollectionView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -2742,13 +2742,16 @@ BI.Collection = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -2859,8 +2862,8 @@ BI.Collection = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.collection_view', BI.Collection);/** +BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.collection_view', BI.CollectionView);/** * @class BI.Combo * @extends BI.Widget */ @@ -14646,15 +14649,15 @@ $.extend(BI, { }; }() });/** - * Grid + * GridView * * Created by GUY on 2016/1/11. - * @class BI.Grid + * @class BI.GridView * @extends BI.Widget */ -BI.Grid = BI.inherit(BI.Widget, { +BI.GridView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-grid-view", width: 400, height: 300, @@ -14673,7 +14676,7 @@ BI.Grid = BI.inherit(BI.Widget, { }, _init: function () { - BI.Grid.superclass._init.apply(this, arguments); + BI.GridView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -14692,7 +14695,7 @@ BI.Grid = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Grid.EVENT_SCROLL, { + self.fireEvent(BI.GridView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -14840,13 +14843,16 @@ BI.Grid = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; @@ -14965,8 +14971,8 @@ BI.Grid = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.grid_view', BI.Grid);/** +BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.grid_view', BI.GridView);/** * floatBox弹出层, * @class BI.FloatBox * @extends BI.Widget @@ -28603,7 +28609,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topLeftItems[index]; } }); - this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28614,7 +28620,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topRightItems[index]; } }); - this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28625,7 +28631,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomLeftItems[index]; } }); - this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollTop(scroll.scrollTop); self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -28637,7 +28643,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomRightItems[index]; } }); - this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollTop(scroll.scrollTop); self.topRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29386,7 +29392,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29396,7 +29402,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29406,7 +29412,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29417,7 +29423,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); self.topRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/bi/core.js b/bi/core.js index 403f644434..9789108581 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4587,7 +4587,7 @@ BI.Widget = BI.inherit(BI.OB, { }, getWidgetByName: function (name) { - if (!BI.isKey(name) || name == this.getName()) { + if (!BI.isKey(name) || name === this.getName()) { return this; } name = name + ""; @@ -4702,7 +4702,7 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - destroy: function () { + _destroy: function(){ BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); @@ -4711,6 +4711,10 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = false; this.destroyed && this.destroyed(); this.element.destroy(); + }, + + destroy: function () { + this._destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/docs/base.js b/docs/base.js index 382be5a933..b9e75adb9a 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2511,15 +2511,15 @@ BI.Canvas = BI.inherit(BI.Widget, { } }); BI.shortcut("bi.canvas", BI.Canvas);/** - * Collection + * CollectionView * * Created by GUY on 2016/1/15. - * @class BI.Collection + * @class BI.CollectionView * @extends BI.Widget */ -BI.Collection = BI.inherit(BI.Widget, { +BI.CollectionView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-collection", width: 400, height: 300, @@ -2535,7 +2535,7 @@ BI.Collection = BI.inherit(BI.Widget, { }, _init: function () { - BI.Collection.superclass._init.apply(this, arguments); + BI.CollectionView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -2554,7 +2554,7 @@ BI.Collection = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Collection.EVENT_SCROLL, { + self.fireEvent(BI.CollectionView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -2742,13 +2742,16 @@ BI.Collection = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -2859,8 +2862,8 @@ BI.Collection = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.collection_view', BI.Collection);/** +BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.collection_view', BI.CollectionView);/** * @class BI.Combo * @extends BI.Widget */ @@ -14646,15 +14649,15 @@ $.extend(BI, { }; }() });/** - * Grid + * GridView * * Created by GUY on 2016/1/11. - * @class BI.Grid + * @class BI.GridView * @extends BI.Widget */ -BI.Grid = BI.inherit(BI.Widget, { +BI.GridView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-grid-view", width: 400, height: 300, @@ -14673,7 +14676,7 @@ BI.Grid = BI.inherit(BI.Widget, { }, _init: function () { - BI.Grid.superclass._init.apply(this, arguments); + BI.GridView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -14692,7 +14695,7 @@ BI.Grid = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Grid.EVENT_SCROLL, { + self.fireEvent(BI.GridView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -14840,13 +14843,16 @@ BI.Grid = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; @@ -14965,8 +14971,8 @@ BI.Grid = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.grid_view', BI.Grid);/** +BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.grid_view', BI.GridView);/** * floatBox弹出层, * @class BI.FloatBox * @extends BI.Widget @@ -28603,7 +28609,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topLeftItems[index]; } }); - this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28614,7 +28620,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topRightItems[index]; } }); - this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -28625,7 +28631,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomLeftItems[index]; } }); - this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollTop(scroll.scrollTop); self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -28637,7 +28643,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomRightItems[index]; } }); - this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollTop(scroll.scrollTop); self.topRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29386,7 +29392,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29396,7 +29402,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -29406,7 +29412,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -29417,7 +29423,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); self.topRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/docs/core.js b/docs/core.js index 993453b35a..c967d63bf5 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14582,7 +14582,7 @@ BI.Widget = BI.inherit(BI.OB, { }, getWidgetByName: function (name) { - if (!BI.isKey(name) || name == this.getName()) { + if (!BI.isKey(name) || name === this.getName()) { return this; } name = name + ""; @@ -14697,7 +14697,7 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - destroy: function () { + _destroy: function(){ BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); @@ -14706,6 +14706,10 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = false; this.destroyed && this.destroyed(); this.element.destroy(); + }, + + destroy: function () { + this._destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index f830cb050a..42a48ed83e 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -1,13 +1,13 @@ /** - * Collection + * CollectionView * * Created by GUY on 2016/1/15. - * @class BI.Collection + * @class BI.CollectionView * @extends BI.Widget */ -BI.Collection = BI.inherit(BI.Widget, { +BI.CollectionView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Collection.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-collection", width: 400, height: 300, @@ -23,7 +23,7 @@ BI.Collection = BI.inherit(BI.Widget, { }, _init: function () { - BI.Collection.superclass._init.apply(this, arguments); + BI.CollectionView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -42,7 +42,7 @@ BI.Collection = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Collection.EVENT_SCROLL, { + self.fireEvent(BI.CollectionView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -230,13 +230,16 @@ BI.Collection = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -347,5 +350,5 @@ BI.Collection = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.collection_view', BI.Collection); \ No newline at end of file +BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.collection_view', BI.CollectionView); \ No newline at end of file diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 43fa51746e..34eb81aa88 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -1,13 +1,13 @@ /** - * Grid + * GridView * * Created by GUY on 2016/1/11. - * @class BI.Grid + * @class BI.GridView * @extends BI.Widget */ -BI.Grid = BI.inherit(BI.Widget, { +BI.GridView = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.Grid.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-grid-view", width: 400, height: 300, @@ -26,7 +26,7 @@ BI.Grid = BI.inherit(BI.Widget, { }, _init: function () { - BI.Grid.superclass._init.apply(this, arguments); + BI.GridView.superclass._init.apply(this, arguments); var self = this, o = this.options; this.renderedCells = []; this.renderedKeys = []; @@ -45,7 +45,7 @@ BI.Grid = BI.inherit(BI.Widget, { o.scrollLeft = self.element.scrollLeft(); o.scrollTop = self.element.scrollTop(); self._calculateChildrenToRender(); - self.fireEvent(BI.Grid.EVENT_SCROLL, { + self.fireEvent(BI.GridView.EVENT_SCROLL, { scrollLeft: o.scrollLeft, scrollTop: o.scrollTop }); @@ -193,13 +193,16 @@ BI.Grid = BI.inherit(BI.Widget, { deleteArray.push(i); }); BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); + //性能优化,不调用destroy方法防止触发destroy事件 + self.renderedCells[index].el._destroy(); }); var addedItems = []; BI.each(addSet, function (index) { addedItems.push(renderedCells[index]) }); this.container.addItems(addedItems); + //拦截父子级关系 + this.container._children = renderedCells; this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; @@ -318,5 +321,5 @@ BI.Grid = BI.inherit(BI.Widget, { this._populate(); } }); -BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; -BI.shortcut('bi.grid_view', BI.Grid); \ No newline at end of file +BI.GridView.EVENT_SCROLL = "EVENT_SCROLL"; +BI.shortcut('bi.grid_view', BI.GridView); \ No newline at end of file diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index c60b8333a8..535b3e1aeb 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -34,7 +34,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topLeftItems[index]; } }); - this.topLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -45,7 +45,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.topRightItems[index]; } }); - this.topRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.topRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -56,7 +56,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomLeftItems[index]; } }); - this.bottomLeftCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomLeftCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomRightCollection.setScrollTop(scroll.scrollTop); self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -68,7 +68,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return self.bottomRightItems[index]; } }); - this.bottomRightCollection.on(BI.Collection.EVENT_SCROLL, function (scroll) { + this.bottomRightCollection.on(BI.CollectionView.EVENT_SCROLL, function (scroll) { self.bottomLeftCollection.setScrollTop(scroll.scrollTop); self.topRightCollection.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 1ddee09e40..873a581b83 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -39,7 +39,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.topLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -49,7 +49,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.topRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); @@ -59,7 +59,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnLeftWidthGetter, }); - this.bottomLeftGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); @@ -70,7 +70,7 @@ BI.GridTable = BI.inherit(BI.Widget, { rowHeightGetter: rowHeightGetter, columnWidthGetter: columnRightWidthGetter, }); - this.bottomRightGrid.on(BI.Grid.EVENT_SCROLL, function (scroll) { + this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); self.topRightGrid.setScrollLeft(scroll.scrollLeft); self._populateScrollbar(); diff --git a/src/core/widget.js b/src/core/widget.js index af3aed4ca5..464008cc73 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -260,7 +260,7 @@ BI.Widget = BI.inherit(BI.OB, { }, getWidgetByName: function (name) { - if (!BI.isKey(name) || name == this.getName()) { + if (!BI.isKey(name) || name === this.getName()) { return this; } name = name + ""; @@ -375,7 +375,7 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - destroy: function () { + _destroy: function(){ BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); @@ -384,6 +384,10 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = false; this.destroyed && this.destroyed(); this.element.destroy(); + }, + + destroy: function () { + this._destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } From 8963b05a4c9e22a130e4885ef141b2c74191bd06 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 02:28:51 +0800 Subject: [PATCH 4/9] update --- bi/core.js | 40 +++++++++++++++++++++------------------- docs/core.js | 40 +++++++++++++++++++++------------------- src/core/widget.js | 40 +++++++++++++++++++++------------------- 3 files changed, 63 insertions(+), 57 deletions(-) diff --git a/bi/core.js b/bi/core.js index 9789108581..698ed4b32e 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4497,17 +4497,6 @@ BI.Widget = BI.inherit(BI.OB, { _mountChildren: null, - _unMount: function () { - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.purgeListeners(); - this.destroyed && this.destroyed(); - }, - isMounted: function () { return this._isMounted; }, @@ -4687,6 +4676,21 @@ BI.Widget = BI.inherit(BI.OB, { this.setVisible(true); }, + __d: function () { + BI.each(this._children, function (i, widget) { + widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + }, + + _unMount: function () { + this.__d(); + this.purgeListeners(); + this.destroyed && this.destroyed(); + }, + isolate: function () { if (this._parent) { this._parent.removeWidget(this); @@ -4702,19 +4706,17 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - _destroy: function(){ - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; + _destroy: function () { + this.__d(); this.destroyed && this.destroyed(); this.element.destroy(); + this.purgeListeners(); }, destroy: function () { - this._destroy(); + this.__d(); + this.destroyed && this.destroyed(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/docs/core.js b/docs/core.js index c967d63bf5..b2b82e1829 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14492,17 +14492,6 @@ BI.Widget = BI.inherit(BI.OB, { _mountChildren: null, - _unMount: function () { - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.purgeListeners(); - this.destroyed && this.destroyed(); - }, - isMounted: function () { return this._isMounted; }, @@ -14682,6 +14671,21 @@ BI.Widget = BI.inherit(BI.OB, { this.setVisible(true); }, + __d: function () { + BI.each(this._children, function (i, widget) { + widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + }, + + _unMount: function () { + this.__d(); + this.purgeListeners(); + this.destroyed && this.destroyed(); + }, + isolate: function () { if (this._parent) { this._parent.removeWidget(this); @@ -14697,19 +14701,17 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - _destroy: function(){ - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; + _destroy: function () { + this.__d(); this.destroyed && this.destroyed(); this.element.destroy(); + this.purgeListeners(); }, destroy: function () { - this._destroy(); + this.__d(); + this.destroyed && this.destroyed(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } diff --git a/src/core/widget.js b/src/core/widget.js index 464008cc73..2ba806a879 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -170,17 +170,6 @@ BI.Widget = BI.inherit(BI.OB, { _mountChildren: null, - _unMount: function () { - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; - this.purgeListeners(); - this.destroyed && this.destroyed(); - }, - isMounted: function () { return this._isMounted; }, @@ -360,6 +349,21 @@ BI.Widget = BI.inherit(BI.OB, { this.setVisible(true); }, + __d: function () { + BI.each(this._children, function (i, widget) { + widget._unMount && widget._unMount(); + }); + this._children = {}; + this._parent = null; + this._isMounted = false; + }, + + _unMount: function () { + this.__d(); + this.purgeListeners(); + this.destroyed && this.destroyed(); + }, + isolate: function () { if (this._parent) { this._parent.removeWidget(this); @@ -375,19 +379,17 @@ BI.Widget = BI.inherit(BI.OB, { this.element.empty(); }, - _destroy: function(){ - BI.each(this._children, function (i, widget) { - widget._unMount && widget._unMount(); - }); - this._children = {}; - this._parent = null; - this._isMounted = false; + _destroy: function () { + this.__d(); this.destroyed && this.destroyed(); this.element.destroy(); + this.purgeListeners(); }, destroy: function () { - this._destroy(); + this.__d(); + this.destroyed && this.destroyed(); + this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); } From bd480eeac1ece05401f9199196759ef4c8592bf2 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 10:22:19 +0800 Subject: [PATCH 5/9] add --- bi/core.js | 6 +++--- docs/core.js | 6 +++--- src/core/wrapper/layout.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bi/core.js b/bi/core.js index 698ed4b32e..8baacfadef 100644 --- a/bi/core.js +++ b/bi/core.js @@ -11202,7 +11202,7 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = newItems; this._children = newChildren; BI.each(deleted, function (i, c) { - c.destroy(); + c._destroy(); }); }, @@ -11227,7 +11227,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { w.element.prependTo(this._getWrapper()); } - del.destroy(); + del._destroy(); w._mount(); }, @@ -11314,7 +11314,7 @@ BI.Layout = BI.inherit(BI.Widget, { } o.items.splice(items.length); BI.each(deleted, function (i, w) { - w.destroy(); + w._destroy(); }) } else if (items.length > o.items.length) { for (i = o.items.length; i < items.length; i++) { diff --git a/docs/core.js b/docs/core.js index b2b82e1829..89d8d30f36 100644 --- a/docs/core.js +++ b/docs/core.js @@ -19587,7 +19587,7 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = newItems; this._children = newChildren; BI.each(deleted, function (i, c) { - c.destroy(); + c._destroy(); }); }, @@ -19612,7 +19612,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { w.element.prependTo(this._getWrapper()); } - del.destroy(); + del._destroy(); w._mount(); }, @@ -19699,7 +19699,7 @@ BI.Layout = BI.inherit(BI.Widget, { } o.items.splice(items.length); BI.each(deleted, function (i, w) { - w.destroy(); + w._destroy(); }) } else if (items.length > o.items.length) { for (i = o.items.length; i < items.length; i++) { diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index abca6b0055..c24c70f806 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -252,7 +252,7 @@ BI.Layout = BI.inherit(BI.Widget, { this.options.items = newItems; this._children = newChildren; BI.each(deleted, function (i, c) { - c.destroy(); + c._destroy(); }); }, @@ -277,7 +277,7 @@ BI.Layout = BI.inherit(BI.Widget, { } else { w.element.prependTo(this._getWrapper()); } - del.destroy(); + del._destroy(); w._mount(); }, @@ -364,7 +364,7 @@ BI.Layout = BI.inherit(BI.Widget, { } o.items.splice(items.length); BI.each(deleted, function (i, w) { - w.destroy(); + w._destroy(); }) } else if (items.length > o.items.length) { for (i = o.items.length; i < items.length; i++) { From 7d42a339fd6b6765d755f59754ab3d47d2b3531d Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 11:31:12 +0800 Subject: [PATCH 6/9] add --- bi/base.js | 12 ++++++++---- bi/core.js | 2 +- docs/base.js | 12 ++++++++---- docs/core.js | 2 +- src/base/collection/collection.js | 6 ++++-- src/base/grid/grid.js | 6 ++++-- src/core/wrapper/layout/layout.card.js | 2 +- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/bi/base.js b/bi/base.js index b9e75adb9a..e65c5645fe 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2639,7 +2639,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { return; } var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; //存储所有的left和top var lefts = {}, tops = {}; for (var i = 0, len = childrenToDisplay.length; i < len; i++) { @@ -2722,6 +2722,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedKeys.push(datum.index); + renderedWidgets[i] = child; } //已存在的, 需要添加的和需要删除的 var existSet = {}, addSet = {}, deleteArray = []; @@ -2751,7 +2752,8 @@ BI.CollectionView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -14771,7 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, { return; } - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -14822,6 +14824,7 @@ BI.GridView = BI.inherit(BI.Widget, { minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); renderedKeys.push(key); + renderedWidgets[i] = child; } } //已存在的, 需要添加的和需要删除的 @@ -14852,7 +14855,8 @@ BI.GridView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; diff --git a/bi/core.js b/bi/core.js index 8baacfadef..ef35ce4519 100644 --- a/bi/core.js +++ b/bi/core.js @@ -13043,7 +13043,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var child = this._children[cardName]; this._deleteCardByName(cardName); - child && child.destroy(); + child && child._destroy(); }, addCardByName: function (cardName, cardItem) { diff --git a/docs/base.js b/docs/base.js index b9e75adb9a..e65c5645fe 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2639,7 +2639,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { return; } var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; //存储所有的left和top var lefts = {}, tops = {}; for (var i = 0, len = childrenToDisplay.length; i < len; i++) { @@ -2722,6 +2722,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedKeys.push(datum.index); + renderedWidgets[i] = child; } //已存在的, 需要添加的和需要删除的 var existSet = {}, addSet = {}, deleteArray = []; @@ -2751,7 +2752,8 @@ BI.CollectionView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; @@ -14771,7 +14773,7 @@ BI.GridView = BI.inherit(BI.Widget, { return; } - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -14822,6 +14824,7 @@ BI.GridView = BI.inherit(BI.Widget, { minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); renderedKeys.push(key); + renderedWidgets[i] = child; } } //已存在的, 需要添加的和需要删除的 @@ -14852,7 +14855,8 @@ BI.GridView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; diff --git a/docs/core.js b/docs/core.js index 89d8d30f36..ff511e2044 100644 --- a/docs/core.js +++ b/docs/core.js @@ -26557,7 +26557,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var child = this._children[cardName]; this._deleteCardByName(cardName); - child && child.destroy(); + child && child._destroy(); }, addCardByName: function (cardName, cardItem) { diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 42a48ed83e..111c833e88 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -127,7 +127,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { return; } var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; //存储所有的left和top var lefts = {}, tops = {}; for (var i = 0, len = childrenToDisplay.length; i < len; i++) { @@ -210,6 +210,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { } renderedKeys.push(datum.index); + renderedWidgets[i] = child; } //已存在的, 需要添加的和需要删除的 var existSet = {}, addSet = {}, deleteArray = []; @@ -239,7 +240,8 @@ BI.CollectionView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 34eb81aa88..82e00bad64 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -121,7 +121,7 @@ BI.GridView = BI.inherit(BI.Widget, { return; } - var renderedCells = [], renderedKeys = []; + var renderedCells = [], renderedKeys = [], renderedWidgets = {}; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); @@ -172,6 +172,7 @@ BI.GridView = BI.inherit(BI.Widget, { minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); renderedKeys.push(key); + renderedWidgets[i] = child; } } //已存在的, 需要添加的和需要删除的 @@ -202,7 +203,8 @@ BI.GridView = BI.inherit(BI.Widget, { }); this.container.addItems(addedItems); //拦截父子级关系 - this.container._children = renderedCells; + this.container._children = renderedWidgets; + this.container.attr("items", renderedCells); this.renderedCells = renderedCells; this.renderedKeys = renderedKeys; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index 201b3ccbf6..0a8447cadf 100644 --- a/src/core/wrapper/layout/layout.card.js +++ b/src/core/wrapper/layout/layout.card.js @@ -91,7 +91,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var child = this._children[cardName]; this._deleteCardByName(cardName); - child && child.destroy(); + child && child._destroy(); }, addCardByName: function (cardName, cardItem) { From e329062b5a49c47dddd0488b9d91ae6fa82b3414 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 17 May 2017 19:23:12 +0800 Subject: [PATCH 7/9] =?UTF-8?q?enable=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 89 ++++------------- bi/case.js | 97 ------------------- bi/core.css | 4 +- bi/core.js | 35 ++++--- bi/widget.js | 53 ---------- docs/base.js | 89 ++++------------- docs/case.js | 97 ------------------- docs/core.css | 4 +- docs/core.js | 35 ++++--- docs/widget.js | 53 ---------- src/base/combination/combo.js | 6 +- src/base/combination/expander.js | 10 +- src/base/combination/group.button.js | 7 -- src/base/combination/group.combo.js | 5 - src/base/combination/loader.js | 4 - src/base/combination/switcher.js | 8 +- src/base/layer/layer.popup.js | 5 - src/base/single/button/button.basic.js | 4 +- src/base/single/button/buttons/button.js | 6 -- src/base/single/editor/editor.code.js | 4 +- src/base/single/editor/editor.js | 6 -- src/base/single/editor/editor.multifile.js | 5 - src/base/single/editor/editor.textarea.js | 6 -- src/base/single/input/file.js | 4 +- src/base/single/input/input.js | 4 +- src/base/tree/customtree.js | 5 - src/case/button/icon/icon.change.js | 5 - src/case/button/item.multiselect.js | 5 - src/case/colorchooser/colorchooser.js | 4 - src/case/combo/bubblecombo/combo.bubble.js | 4 - .../combo.editoriconcheck.js | 5 - src/case/combo/iconcombo/combo.icon.js | 5 - .../combo.textvaluecheck.js | 5 - .../combo.textvaluechecksmall.js | 5 - .../combo/textvaluecombo/combo.textvalue.js | 5 - .../textvaluecombo/combo.textvaluesmall.js | 5 - .../combo.textvaluedownlist.js | 5 - src/case/editor/editor.search.js | 6 -- src/case/editor/editor.state.js | 5 - src/case/editor/editor.state.simple.js | 5 - src/case/editor/editor.text.js | 5 - src/case/segment/segment.js | 4 - src/case/toolbar/toolbar.multiselect.js | 7 -- src/case/trigger/trigger.text.js | 6 -- src/case/trigger/trigger.text.small.js | 6 -- src/core/widget.js | 35 ++++--- src/css/core/utils/common.css | 4 +- src/less/core/utils/common.less | 2 +- src/widget/multiselect/multiselect.loader.js | 4 - .../multiselect/multiselect.popup.view.js | 4 - src/widget/multiselect/multiselect.trigger.js | 4 - .../search/multiselect.search.loader.js | 4 - .../multiselect/trigger/editor.multiselect.js | 4 - .../trigger/searcher.multiselect.js | 4 - src/widget/multistringlist/multistringlist.js | 5 - src/widget/multitree/multi.tree.combo.js | 4 - src/widget/multitree/multi.tree.popup.js | 4 - .../multitree/trigger/searcher.multi.tree.js | 4 - src/widget/multitreelist/multitreelist.js | 5 - .../numericalinterval/numericalinterval.js | 7 -- 60 files changed, 130 insertions(+), 706 deletions(-) diff --git a/bi/base.js b/bi/base.js index e65c5645fe..a7fe770ab7 100644 --- a/bi/base.js +++ b/bi/base.js @@ -881,8 +881,8 @@ BI.BasicButton = BI.inherit(BI.Single, { return this.options.text; }, - setEnable: function (b) { - BI.BasicButton.superclass.setEnable.apply(this, arguments); + _setEnable: function (b) { + BI.BasicButton.superclass._setEnable.apply(this, arguments); if (!b) { if (this.options.shadow) { this.$mask && this.$mask.setVisible(false); @@ -1166,13 +1166,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); }, - setEnable: function (b) { - BI.ButtonGroup.superclass.setEnable.apply(this, arguments); - BI.each(this.buttons, function (i, item) { - item.setEnable(b); - }); - }, - setNotSelectedValue: function (v) { v = BI.isArray(v) ? v : [v]; BI.each(this.buttons, function (i, item) { @@ -3192,10 +3185,8 @@ BI.Combo = BI.inherit(BI.Widget, { this.combo.populate.apply(this.combo, arguments); }, - setEnable: function (arg) { - BI.Combo.superclass.setEnable.apply(this, arguments); - this.combo && this.combo.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); + _setEnable: function (arg) { + BI.Combo.superclass._setEnable.apply(this, arguments); !arg && this.isViewVisible() && this._hideView(); }, @@ -3304,7 +3295,7 @@ BI.Expander = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_EXPAND); } - if(type === BI.Events.COLLAPSE) { + if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_COLLAPSE); } @@ -3461,11 +3452,9 @@ BI.Expander = BI.inherit(BI.Widget, { this.expander.populate.apply(this.expander, arguments); }, - setEnable: function (arg) { - BI.Expander.superclass.setEnable.apply(this, arguments); - this.expander && this.expander.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); - !arg && this._hideView(); + _setEnable: function (arg) { + BI.Expander.superclass._setEnable.apply(this, arguments); + !arg && this.isViewVisible() && this._hideView(); }, setValue: function (v) { @@ -3625,11 +3614,6 @@ BI.ComboGroup = BI.inherit(BI.Widget, { }) }, - setEnable: function (b) { - BI.ComboGroup.superclass.setEnable.apply(this, arguments); - this.combo && this.combo.setEnable(b); - }, - getValue: function () { return this.combo.getValue(); }, @@ -3920,10 +3904,6 @@ BI.Loader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (v) { - this.button_group.setEnable(v); - }, - doBehavior: function () { this.button_group.doBehavior.apply(this.button_group, arguments); }, @@ -4629,11 +4609,9 @@ BI.Switcher = BI.inherit(BI.Widget, { this.switcher.populate.apply(this.switcher, arguments); }, - setEnable: function (arg) { - BI.Switcher.superclass.setEnable.apply(this, arguments); - this.switcher && this.switcher.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); - !arg && this._hideView(); + _setEnable: function (arg) { + BI.Switcher.superclass._setEnable.apply(this, arguments); + !arg && this.isViewVisible() && this._hideView(); }, setValue: function (v) { @@ -15281,11 +15259,6 @@ BI.PopupView = BI.inherit(BI.Widget, { this.view.element.css({"max-height": (h - tbHeight - tabHeight - toolHeight - 2) + "px"}) }, - setEnable: function (arg) { - BI.PopupView.superclass.setEnable.apply(this, arguments); - this.view && this.view.setEnable(arg); - }, - setValue: function (selectedValues) { this.tab && this.tab.setValue(selectedValues); this.button_group.setValue(selectedValues); @@ -16092,12 +16065,6 @@ BI.shortcut("bi.image_button", BI.ImageButton);(function ($) { } }, - setEnable: function (b) { - BI.Button.superclass.setEnable.apply(this, arguments); - // this.text.setEnable(b); - // this.icon && this.icon.setEnable(b); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, @@ -17470,8 +17437,8 @@ BI.CodeEditor = BI.inherit(BI.Single, { } }, - setEnable: function (b) { - BI.CodeEditor.superclass.setEnable.apply(this, arguments); + _setEnable: function (b) { + BI.CodeEditor.superclass._setEnable.apply(this, arguments); this.editor.setOption("readOnly", b === true ? false : "nocursor") }, @@ -17842,12 +17809,6 @@ BI.Editor = BI.inherit(BI.Single, { isValid: function () { return this.editor.isValid(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); - this.watermark && this.watermark.setEnable(b); } }); BI.Editor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -17950,11 +17911,6 @@ BI.MultifileEditor = BI.inherit(BI.Single, { reset: function () { this.file.reset(); - }, - - setEnable: function (enable) { - BI.MultiFile.superclass.setEnable.apply(this, arguments); - this.file.setEnable(enable); } }); BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE"; @@ -18117,12 +18073,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { BI.TextAreaEditor.superclass.setValid.apply(this, arguments); this.content.setValid(b); this.watermark && this.watermark.setValid(b); - }, - - setEnable: function (b) { - BI.TextAreaEditor.superclass.setEnable.apply(this, arguments); - this.content.setEnable(b); - this.watermark && this.watermark.setEnable(b); } }); BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -18857,8 +18807,8 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** this.wrap.attachNum = 0; }, - setEnable: function (enable) { - BI.File.superclass.setEnable.apply(this, arguments); + _setEnable: function (enable) { + BI.File.superclass._setEnable.apply(this, arguments); if (enable === true) { this.element.attr("disabled", "disabled"); } else { @@ -19130,8 +19080,8 @@ BI.Input = BI.inherit(BI.Single, { } }, - setEnable: function (b) { - BI.Input.superclass.setEnable.apply(this, [b]); + _setEnable: function (b) { + BI.Input.superclass._setEnable.apply(this, [b]); this.element[0].disabled = !b; } }); @@ -32563,11 +32513,6 @@ BI.CustomTree = BI.inherit(BI.Widget, { this.initTree(this.options.items); }, - setEnable: function (v) { - BI.CustomTree.superclass.setEnable.apply(this, arguments); - this.tree.setEnable(v) - }, - _formatItems: function (nodes) { var self = this, o = this.options; nodes = BI.Tree.transformToTreeFormat(nodes); diff --git a/bi/case.js b/bi/case.js index 039b4873e9..697267ae70 100644 --- a/bi/case.js +++ b/bi/case.js @@ -77,11 +77,6 @@ BI.IconChangeButton = BI.inherit(BI.Single, { this.element.removeClass(o.iconClass).addClass(cls); o.iconClass = cls; } - }, - - setEnable: function (b) { - BI.IconChangeButton.superclass.setEnable.apply(this, arguments); - this.button.setEnable(b); } }); BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE"; @@ -197,11 +192,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { })))); }, - setEnable: function (v) { - BI.MultiSelectItem.superclass.setEnable.apply(this, arguments); - this.checkbox.setEnable(v); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, @@ -2373,10 +2363,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, { return this.combo.isViewVisible(); }, - setEnable: function (v) { - this.combo.setEnable(v) - }, - setValue: function (color) { this.combo.setValue(color); }, @@ -3600,10 +3586,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { isViewVisible: function () { return this.combo.isViewVisible(); - }, - - setEnable: function (v) { - this.combo.setEnable(!!v); } }); @@ -3799,11 +3781,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, { this.editorIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.EditorIconCheckCombo.superclass.setEnable.apply(this, arguments); - this.editorIconCheckCombo.setEnable(v); - }, - getValue: function () { return this.trigger.getValue(); }, @@ -4141,11 +4118,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { this.iconCombo.setValue(v); }, - setEnable: function (v) { - BI.IconCombo.superclass.setEnable.apply(this, arguments); - this.iconCombo.setEnable(v); - }, - getValue: function () { return this.iconCombo.getValue(); }, @@ -4431,11 +4403,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { this.textIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.TextValueCheckCombo.superclass.setEnable.apply(this, arguments); - this.textIconCheckCombo.setEnable(v); - }, - setWarningTitle: function (title) { this.trigger.setWarningTitle(title); }, @@ -4503,11 +4470,6 @@ BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, { this.SmallTextIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.SmallTextValueCheckCombo.superclass.setEnable.apply(this, arguments); - this.SmallTextIconCheckCombo.setEnable(v); - }, - getValue: function () { return this.SmallTextIconCheckCombo.getValue(); }, @@ -4632,11 +4594,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { this.textIconCombo.setValue(v); }, - setEnable: function (v) { - BI.TextValueCombo.superclass.setEnable.apply(this, arguments); - this.textIconCombo.setEnable(v); - }, - getValue: function () { return this.textIconCombo.getValue(); }, @@ -4702,11 +4659,6 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, { this.SmallTextValueCombo.setValue(v); }, - setEnable: function (v) { - BI.SmallTextValueCombo.superclass.setEnable.apply(this, arguments); - this.SmallTextValueCombo.setEnable(v); - }, - getValue: function () { return this.SmallTextValueCombo.getValue(); }, @@ -4840,11 +4792,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { this.trigger.setValue(v.childValue || v.value); }, - setEnable: function (v) { - BI.TextValueDownListCombo.superclass.setEnable.apply(this, arguments); - this.combo.setEnable(v); - }, - getValue: function () { var v = this.combo.getValue()[0]; return [v.childValue || v.value]; @@ -5248,12 +5195,6 @@ BI.SearchEditor = BI.inherit(BI.Widget, { isValid: function () { return this.editor.isValid(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); - this.clear.setEnable(b); } }); BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -6186,11 +6127,6 @@ BI.StateEditor = BI.inherit(BI.Widget, { this.editor.setValue(k); }, - setEnable: function (v) { - this.text.setEnable(v); - this.editor.setEnable(v); - }, - getValue: function () { return this.editor.getValue(); }, @@ -6464,11 +6400,6 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, { this.editor.setValue(k); }, - setEnable: function(v){ - this.text.setEnable(v); - this.editor.setEnable(v); - }, - getValue: function () { return this.editor.getValue(); }, @@ -6666,11 +6597,6 @@ BI.TextEditor = BI.inherit(BI.Widget, { getValue: function () { return this.editor.getValue(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); } }); BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -8714,10 +8640,6 @@ BI.Segment = BI.inherit(BI.Widget, { this.buttonGroup.setEnabledValue(v); }, - setEnable: function (v) { - this.buttonGroup.setEnable(v); - }, - getValue: function () { return this.buttonGroup.getValue(); } @@ -10452,13 +10374,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); this.setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); - }, - - setEnable: function (b) { - BI.MultiSelectBar.superclass.setEnable.apply(this, arguments); - this.checkbox.setEnable(b); - this.half.setEnable(b); - this.text.setEnable(b); } }); BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE"; @@ -11157,12 +11072,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }); }, - setEnable: function (v) { - BI.TextTrigger.superclass.setEnable.apply(this, arguments); - this.trigerButton.setEnable(v); - this.text.setEnable(v); - }, - setValue: function (value) { this.text.setValue(value); this.text.setTitle(value); @@ -11327,12 +11236,6 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, { }); }, - setEnable: function (v) { - BI.SmallTextTrigger.superclass.setEnable.apply(this, arguments); - this.trigerButton.setEnable(v); - this.text.setEnable(v); - }, - setValue: function (value) { this.text.setValue(value); }, diff --git a/bi/core.css b/bi/core.css index 25c5635c63..ed35e89657 100644 --- a/bi/core.css +++ b/bi/core.css @@ -3078,8 +3078,8 @@ i { } .bi-z-index-mask { color: #ffffff; - background-color: rgba(26, 26, 26, 0.3); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d1a1a1a,endColorstr=#4d1a1a1a); + background-color: rgba(26, 26, 26, 0.5); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#801a1a1a,endColorstr=#801a1a1a); } .bi-list-item:hover, .bi-list-item.hover { diff --git a/bi/core.js b/bi/core.js index ef35ce4519..f311b8aeb5 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4432,17 +4432,18 @@ BI.Widget = BI.inherit(BI.OB, { _initVisualEffects: function () { var o = this.options; if (o.invisible) { - this.element.hide(); + //用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 + this.element.css("display", "none"); } if (o.disabled || o.invalid) { - BI.nextTick(BI.bind(function () { - if (this.options.disabled) { - this.setEnable(false); - } - if (this.options.invalid) { - this.setValid(false); - } - }, this)); + // BI.nextTick(BI.bind(function () { + if (this.options.disabled) { + this.setEnable(false); + } + if (this.options.invalid) { + this.setValid(false); + } + // }, this)); } }, @@ -4490,6 +4491,7 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = true; this._mountChildren && this._mountChildren(); BI.each(this._children, function (i, widget) { + !self.isEnabled() && widget._setEnable(false); widget._mount && widget._mount(); }); this.mounted && this.mounted(); @@ -4511,12 +4513,23 @@ BI.Widget = BI.inherit(BI.OB, { this._initElementHeight(); }, - setEnable: function (enable) { + _setEnable: function (enable) { if (enable === true) { this.options.disabled = false; - this.element.removeClass("base-disabled disabled"); } else if (enable === false) { this.options.disabled = true; + } + //递归将所有子组件使能 + BI.each(this._children, function (i, child) { + child._setEnable && child._setEnable(enable); + }); + }, + + setEnable: function (enable) { + this._setEnable(enable); + if (enable === true) { + this.element.removeClass("base-disabled disabled"); + } else if (enable === false) { this.element.addClass("base-disabled disabled"); } }, diff --git a/bi/widget.js b/bi/widget.js index 42fb0ced59..9ec134e1a4 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -10048,10 +10048,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (arg) { - this.button_group.setEnable(arg); - }, - resetHeight: function (h) { this.button_group.resetHeight(h); }, @@ -10138,10 +10134,6 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, { this.popupView.populate.apply(this.popupView, arguments); }, - setEnable: function (arg) { - this.popupView.setEnable(arg); - }, - resetHeight: function (h) { this.popupView.resetHeight(h); }, @@ -10291,10 +10283,6 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { this.numberCounter.setValue(ob); }, - setEnable: function (v) { - this.searcher.setEnable(v); - }, - getKey: function () { return this.searcher.getKey(); }, @@ -10454,10 +10442,6 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (arg) { - this.button_group.setEnable(arg); - }, - resetHeight: function (h) { this.button_group.resetHeight(h); }, @@ -10703,10 +10687,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, { this.editor.setValue(v); }, - setEnable: function(v){ - this.editor.setEnable(v); - }, - getValue: function () { var v = this.editor.getState(); if (BI.isArray(v) && v.length > 0) { @@ -10866,10 +10846,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { return this.searcher.getValue(); }, - setEnable: function (v) { - this.editor.setEnable(v); - }, - populate: function (items) { this.searcher.populate.apply(this.searcher, arguments); } @@ -11267,11 +11243,6 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this.trigger.getSearcher().adjustView(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); - }, - setValue: function (v) { this.storeValue = v || {}; this._assertValue(this.storeValue); @@ -11649,10 +11620,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { this.combo.hideView(); }, - setEnable: function (v) { - this.combo.setEnable(v); - }, - setValue: function (v) { this.storeValue.value = v || {}; this.combo.setValue({ @@ -11752,10 +11719,6 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, { return this.tree.hasChecked(); }, - setEnable: function (arg) { - this.popupView.setEnable(arg); - }, - resetHeight: function (h) { this.popupView.resetHeight(h); }, @@ -12030,10 +11993,6 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { return this.editor.getValue(); }, - setEnable: function(v){ - this.editor.setEnable(v); - }, - getValue: function () { return this.searcher.getValue(); }, @@ -12200,11 +12159,6 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { this.trigger.getSearcher().adjustView(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); - }, - setValue: function (v) { this.storeValue.value = v || {}; this.popup.setValue({ @@ -12704,13 +12658,6 @@ BI.NumericalInterval = BI.inherit(BI.Single, { return this.options.validation === "valid"; }, - setEnable: function (b) { - this.smallEditor.setEnable(b); - this.smallCombo.setEnable(b); - this.bigEditor.setEnable(b); - this.bigCombo.setEnable(b); - }, - setMinEnable: function (b) { this.smallEditor.setEnable(b); }, diff --git a/docs/base.js b/docs/base.js index e65c5645fe..a7fe770ab7 100644 --- a/docs/base.js +++ b/docs/base.js @@ -881,8 +881,8 @@ BI.BasicButton = BI.inherit(BI.Single, { return this.options.text; }, - setEnable: function (b) { - BI.BasicButton.superclass.setEnable.apply(this, arguments); + _setEnable: function (b) { + BI.BasicButton.superclass._setEnable.apply(this, arguments); if (!b) { if (this.options.shadow) { this.$mask && this.$mask.setVisible(false); @@ -1166,13 +1166,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); }, - setEnable: function (b) { - BI.ButtonGroup.superclass.setEnable.apply(this, arguments); - BI.each(this.buttons, function (i, item) { - item.setEnable(b); - }); - }, - setNotSelectedValue: function (v) { v = BI.isArray(v) ? v : [v]; BI.each(this.buttons, function (i, item) { @@ -3192,10 +3185,8 @@ BI.Combo = BI.inherit(BI.Widget, { this.combo.populate.apply(this.combo, arguments); }, - setEnable: function (arg) { - BI.Combo.superclass.setEnable.apply(this, arguments); - this.combo && this.combo.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); + _setEnable: function (arg) { + BI.Combo.superclass._setEnable.apply(this, arguments); !arg && this.isViewVisible() && this._hideView(); }, @@ -3304,7 +3295,7 @@ BI.Expander = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_EXPAND); } - if(type === BI.Events.COLLAPSE) { + if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_COLLAPSE); } @@ -3461,11 +3452,9 @@ BI.Expander = BI.inherit(BI.Widget, { this.expander.populate.apply(this.expander, arguments); }, - setEnable: function (arg) { - BI.Expander.superclass.setEnable.apply(this, arguments); - this.expander && this.expander.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); - !arg && this._hideView(); + _setEnable: function (arg) { + BI.Expander.superclass._setEnable.apply(this, arguments); + !arg && this.isViewVisible() && this._hideView(); }, setValue: function (v) { @@ -3625,11 +3614,6 @@ BI.ComboGroup = BI.inherit(BI.Widget, { }) }, - setEnable: function (b) { - BI.ComboGroup.superclass.setEnable.apply(this, arguments); - this.combo && this.combo.setEnable(b); - }, - getValue: function () { return this.combo.getValue(); }, @@ -3920,10 +3904,6 @@ BI.Loader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (v) { - this.button_group.setEnable(v); - }, - doBehavior: function () { this.button_group.doBehavior.apply(this.button_group, arguments); }, @@ -4629,11 +4609,9 @@ BI.Switcher = BI.inherit(BI.Widget, { this.switcher.populate.apply(this.switcher, arguments); }, - setEnable: function (arg) { - BI.Switcher.superclass.setEnable.apply(this, arguments); - this.switcher && this.switcher.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); - !arg && this._hideView(); + _setEnable: function (arg) { + BI.Switcher.superclass._setEnable.apply(this, arguments); + !arg && this.isViewVisible() && this._hideView(); }, setValue: function (v) { @@ -15281,11 +15259,6 @@ BI.PopupView = BI.inherit(BI.Widget, { this.view.element.css({"max-height": (h - tbHeight - tabHeight - toolHeight - 2) + "px"}) }, - setEnable: function (arg) { - BI.PopupView.superclass.setEnable.apply(this, arguments); - this.view && this.view.setEnable(arg); - }, - setValue: function (selectedValues) { this.tab && this.tab.setValue(selectedValues); this.button_group.setValue(selectedValues); @@ -16092,12 +16065,6 @@ BI.shortcut("bi.image_button", BI.ImageButton);(function ($) { } }, - setEnable: function (b) { - BI.Button.superclass.setEnable.apply(this, arguments); - // this.text.setEnable(b); - // this.icon && this.icon.setEnable(b); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, @@ -17470,8 +17437,8 @@ BI.CodeEditor = BI.inherit(BI.Single, { } }, - setEnable: function (b) { - BI.CodeEditor.superclass.setEnable.apply(this, arguments); + _setEnable: function (b) { + BI.CodeEditor.superclass._setEnable.apply(this, arguments); this.editor.setOption("readOnly", b === true ? false : "nocursor") }, @@ -17842,12 +17809,6 @@ BI.Editor = BI.inherit(BI.Single, { isValid: function () { return this.editor.isValid(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); - this.watermark && this.watermark.setEnable(b); } }); BI.Editor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -17950,11 +17911,6 @@ BI.MultifileEditor = BI.inherit(BI.Single, { reset: function () { this.file.reset(); - }, - - setEnable: function (enable) { - BI.MultiFile.superclass.setEnable.apply(this, arguments); - this.file.setEnable(enable); } }); BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE"; @@ -18117,12 +18073,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { BI.TextAreaEditor.superclass.setValid.apply(this, arguments); this.content.setValid(b); this.watermark && this.watermark.setValid(b); - }, - - setEnable: function (b) { - BI.TextAreaEditor.superclass.setEnable.apply(this, arguments); - this.content.setEnable(b); - this.watermark && this.watermark.setEnable(b); } }); BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -18857,8 +18807,8 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** this.wrap.attachNum = 0; }, - setEnable: function (enable) { - BI.File.superclass.setEnable.apply(this, arguments); + _setEnable: function (enable) { + BI.File.superclass._setEnable.apply(this, arguments); if (enable === true) { this.element.attr("disabled", "disabled"); } else { @@ -19130,8 +19080,8 @@ BI.Input = BI.inherit(BI.Single, { } }, - setEnable: function (b) { - BI.Input.superclass.setEnable.apply(this, [b]); + _setEnable: function (b) { + BI.Input.superclass._setEnable.apply(this, [b]); this.element[0].disabled = !b; } }); @@ -32563,11 +32513,6 @@ BI.CustomTree = BI.inherit(BI.Widget, { this.initTree(this.options.items); }, - setEnable: function (v) { - BI.CustomTree.superclass.setEnable.apply(this, arguments); - this.tree.setEnable(v) - }, - _formatItems: function (nodes) { var self = this, o = this.options; nodes = BI.Tree.transformToTreeFormat(nodes); diff --git a/docs/case.js b/docs/case.js index 039b4873e9..697267ae70 100644 --- a/docs/case.js +++ b/docs/case.js @@ -77,11 +77,6 @@ BI.IconChangeButton = BI.inherit(BI.Single, { this.element.removeClass(o.iconClass).addClass(cls); o.iconClass = cls; } - }, - - setEnable: function (b) { - BI.IconChangeButton.superclass.setEnable.apply(this, arguments); - this.button.setEnable(b); } }); BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE"; @@ -197,11 +192,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { })))); }, - setEnable: function (v) { - BI.MultiSelectItem.superclass.setEnable.apply(this, arguments); - this.checkbox.setEnable(v); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, @@ -2373,10 +2363,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, { return this.combo.isViewVisible(); }, - setEnable: function (v) { - this.combo.setEnable(v) - }, - setValue: function (color) { this.combo.setValue(color); }, @@ -3600,10 +3586,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { isViewVisible: function () { return this.combo.isViewVisible(); - }, - - setEnable: function (v) { - this.combo.setEnable(!!v); } }); @@ -3799,11 +3781,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, { this.editorIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.EditorIconCheckCombo.superclass.setEnable.apply(this, arguments); - this.editorIconCheckCombo.setEnable(v); - }, - getValue: function () { return this.trigger.getValue(); }, @@ -4141,11 +4118,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { this.iconCombo.setValue(v); }, - setEnable: function (v) { - BI.IconCombo.superclass.setEnable.apply(this, arguments); - this.iconCombo.setEnable(v); - }, - getValue: function () { return this.iconCombo.getValue(); }, @@ -4431,11 +4403,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { this.textIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.TextValueCheckCombo.superclass.setEnable.apply(this, arguments); - this.textIconCheckCombo.setEnable(v); - }, - setWarningTitle: function (title) { this.trigger.setWarningTitle(title); }, @@ -4503,11 +4470,6 @@ BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, { this.SmallTextIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.SmallTextValueCheckCombo.superclass.setEnable.apply(this, arguments); - this.SmallTextIconCheckCombo.setEnable(v); - }, - getValue: function () { return this.SmallTextIconCheckCombo.getValue(); }, @@ -4632,11 +4594,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { this.textIconCombo.setValue(v); }, - setEnable: function (v) { - BI.TextValueCombo.superclass.setEnable.apply(this, arguments); - this.textIconCombo.setEnable(v); - }, - getValue: function () { return this.textIconCombo.getValue(); }, @@ -4702,11 +4659,6 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, { this.SmallTextValueCombo.setValue(v); }, - setEnable: function (v) { - BI.SmallTextValueCombo.superclass.setEnable.apply(this, arguments); - this.SmallTextValueCombo.setEnable(v); - }, - getValue: function () { return this.SmallTextValueCombo.getValue(); }, @@ -4840,11 +4792,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { this.trigger.setValue(v.childValue || v.value); }, - setEnable: function (v) { - BI.TextValueDownListCombo.superclass.setEnable.apply(this, arguments); - this.combo.setEnable(v); - }, - getValue: function () { var v = this.combo.getValue()[0]; return [v.childValue || v.value]; @@ -5248,12 +5195,6 @@ BI.SearchEditor = BI.inherit(BI.Widget, { isValid: function () { return this.editor.isValid(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); - this.clear.setEnable(b); } }); BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -6186,11 +6127,6 @@ BI.StateEditor = BI.inherit(BI.Widget, { this.editor.setValue(k); }, - setEnable: function (v) { - this.text.setEnable(v); - this.editor.setEnable(v); - }, - getValue: function () { return this.editor.getValue(); }, @@ -6464,11 +6400,6 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, { this.editor.setValue(k); }, - setEnable: function(v){ - this.text.setEnable(v); - this.editor.setEnable(v); - }, - getValue: function () { return this.editor.getValue(); }, @@ -6666,11 +6597,6 @@ BI.TextEditor = BI.inherit(BI.Widget, { getValue: function () { return this.editor.getValue(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); } }); BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE"; @@ -8714,10 +8640,6 @@ BI.Segment = BI.inherit(BI.Widget, { this.buttonGroup.setEnabledValue(v); }, - setEnable: function (v) { - this.buttonGroup.setEnable(v); - }, - getValue: function () { return this.buttonGroup.getValue(); } @@ -10452,13 +10374,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); this.setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); - }, - - setEnable: function (b) { - BI.MultiSelectBar.superclass.setEnable.apply(this, arguments); - this.checkbox.setEnable(b); - this.half.setEnable(b); - this.text.setEnable(b); } }); BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE"; @@ -11157,12 +11072,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }); }, - setEnable: function (v) { - BI.TextTrigger.superclass.setEnable.apply(this, arguments); - this.trigerButton.setEnable(v); - this.text.setEnable(v); - }, - setValue: function (value) { this.text.setValue(value); this.text.setTitle(value); @@ -11327,12 +11236,6 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, { }); }, - setEnable: function (v) { - BI.SmallTextTrigger.superclass.setEnable.apply(this, arguments); - this.trigerButton.setEnable(v); - this.text.setEnable(v); - }, - setValue: function (value) { this.text.setValue(value); }, diff --git a/docs/core.css b/docs/core.css index 25c5635c63..ed35e89657 100644 --- a/docs/core.css +++ b/docs/core.css @@ -3078,8 +3078,8 @@ i { } .bi-z-index-mask { color: #ffffff; - background-color: rgba(26, 26, 26, 0.3); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d1a1a1a,endColorstr=#4d1a1a1a); + background-color: rgba(26, 26, 26, 0.5); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#801a1a1a,endColorstr=#801a1a1a); } .bi-list-item:hover, .bi-list-item.hover { diff --git a/docs/core.js b/docs/core.js index ff511e2044..1715d0032b 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14427,17 +14427,18 @@ BI.Widget = BI.inherit(BI.OB, { _initVisualEffects: function () { var o = this.options; if (o.invisible) { - this.element.hide(); + //用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 + this.element.css("display", "none"); } if (o.disabled || o.invalid) { - BI.nextTick(BI.bind(function () { - if (this.options.disabled) { - this.setEnable(false); - } - if (this.options.invalid) { - this.setValid(false); - } - }, this)); + // BI.nextTick(BI.bind(function () { + if (this.options.disabled) { + this.setEnable(false); + } + if (this.options.invalid) { + this.setValid(false); + } + // }, this)); } }, @@ -14485,6 +14486,7 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = true; this._mountChildren && this._mountChildren(); BI.each(this._children, function (i, widget) { + !self.isEnabled() && widget._setEnable(false); widget._mount && widget._mount(); }); this.mounted && this.mounted(); @@ -14506,12 +14508,23 @@ BI.Widget = BI.inherit(BI.OB, { this._initElementHeight(); }, - setEnable: function (enable) { + _setEnable: function (enable) { if (enable === true) { this.options.disabled = false; - this.element.removeClass("base-disabled disabled"); } else if (enable === false) { this.options.disabled = true; + } + //递归将所有子组件使能 + BI.each(this._children, function (i, child) { + child._setEnable && child._setEnable(enable); + }); + }, + + setEnable: function (enable) { + this._setEnable(enable); + if (enable === true) { + this.element.removeClass("base-disabled disabled"); + } else if (enable === false) { this.element.addClass("base-disabled disabled"); } }, diff --git a/docs/widget.js b/docs/widget.js index 42fb0ced59..9ec134e1a4 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -10048,10 +10048,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (arg) { - this.button_group.setEnable(arg); - }, - resetHeight: function (h) { this.button_group.resetHeight(h); }, @@ -10138,10 +10134,6 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, { this.popupView.populate.apply(this.popupView, arguments); }, - setEnable: function (arg) { - this.popupView.setEnable(arg); - }, - resetHeight: function (h) { this.popupView.resetHeight(h); }, @@ -10291,10 +10283,6 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { this.numberCounter.setValue(ob); }, - setEnable: function (v) { - this.searcher.setEnable(v); - }, - getKey: function () { return this.searcher.getKey(); }, @@ -10454,10 +10442,6 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (arg) { - this.button_group.setEnable(arg); - }, - resetHeight: function (h) { this.button_group.resetHeight(h); }, @@ -10703,10 +10687,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, { this.editor.setValue(v); }, - setEnable: function(v){ - this.editor.setEnable(v); - }, - getValue: function () { var v = this.editor.getState(); if (BI.isArray(v) && v.length > 0) { @@ -10866,10 +10846,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { return this.searcher.getValue(); }, - setEnable: function (v) { - this.editor.setEnable(v); - }, - populate: function (items) { this.searcher.populate.apply(this.searcher, arguments); } @@ -11267,11 +11243,6 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this.trigger.getSearcher().adjustView(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); - }, - setValue: function (v) { this.storeValue = v || {}; this._assertValue(this.storeValue); @@ -11649,10 +11620,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { this.combo.hideView(); }, - setEnable: function (v) { - this.combo.setEnable(v); - }, - setValue: function (v) { this.storeValue.value = v || {}; this.combo.setValue({ @@ -11752,10 +11719,6 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, { return this.tree.hasChecked(); }, - setEnable: function (arg) { - this.popupView.setEnable(arg); - }, - resetHeight: function (h) { this.popupView.resetHeight(h); }, @@ -12030,10 +11993,6 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { return this.editor.getValue(); }, - setEnable: function(v){ - this.editor.setEnable(v); - }, - getValue: function () { return this.searcher.getValue(); }, @@ -12200,11 +12159,6 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { this.trigger.getSearcher().adjustView(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); - }, - setValue: function (v) { this.storeValue.value = v || {}; this.popup.setValue({ @@ -12704,13 +12658,6 @@ BI.NumericalInterval = BI.inherit(BI.Single, { return this.options.validation === "valid"; }, - setEnable: function (b) { - this.smallEditor.setEnable(b); - this.smallCombo.setEnable(b); - this.bigEditor.setEnable(b); - this.bigCombo.setEnable(b); - }, - setMinEnable: function (b) { this.smallEditor.setEnable(b); }, diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index fae9df9728..7a43f70703 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -325,10 +325,8 @@ BI.Combo = BI.inherit(BI.Widget, { this.combo.populate.apply(this.combo, arguments); }, - setEnable: function (arg) { - BI.Combo.superclass.setEnable.apply(this, arguments); - this.combo && this.combo.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); + _setEnable: function (arg) { + BI.Combo.superclass._setEnable.apply(this, arguments); !arg && this.isViewVisible() && this._hideView(); }, diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index 34a7fa7fe5..5bfdb89a16 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -39,7 +39,7 @@ BI.Expander = BI.inherit(BI.Widget, { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_EXPAND); } - if(type === BI.Events.COLLAPSE) { + if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_COLLAPSE); } @@ -196,11 +196,9 @@ BI.Expander = BI.inherit(BI.Widget, { this.expander.populate.apply(this.expander, arguments); }, - setEnable: function (arg) { - BI.Expander.superclass.setEnable.apply(this, arguments); - this.expander && this.expander.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); - !arg && this._hideView(); + _setEnable: function (arg) { + BI.Expander.superclass._setEnable.apply(this, arguments); + !arg && this.isViewVisible() && this._hideView(); }, setValue: function (v) { diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 2da4ee7fdf..76be065fba 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -189,13 +189,6 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { this.layouts = BI.createWidget(BI.extend({element: this}, this._packageLayout(items))); }, - setEnable: function (b) { - BI.ButtonGroup.superclass.setEnable.apply(this, arguments); - BI.each(this.buttons, function (i, item) { - item.setEnable(b); - }); - }, - setNotSelectedValue: function (v) { v = BI.isArray(v) ? v : [v]; BI.each(this.buttons, function (i, item) { diff --git a/src/base/combination/group.combo.js b/src/base/combination/group.combo.js index 2d3314fd39..19339f13f9 100644 --- a/src/base/combination/group.combo.js +++ b/src/base/combination/group.combo.js @@ -83,11 +83,6 @@ BI.ComboGroup = BI.inherit(BI.Widget, { }) }, - setEnable: function (b) { - BI.ComboGroup.superclass.setEnable.apply(this, arguments); - this.combo && this.combo.setEnable(b); - }, - getValue: function () { return this.combo.getValue(); }, diff --git a/src/base/combination/loader.js b/src/base/combination/loader.js index 50ecdc3ffb..ee25cd4ae9 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); }, - setEnable: function (v) { - this.button_group.setEnable(v); - }, - doBehavior: function () { this.button_group.doBehavior.apply(this.button_group, arguments); }, diff --git a/src/base/combination/switcher.js b/src/base/combination/switcher.js index c72715b633..f279eaabb4 100644 --- a/src/base/combination/switcher.js +++ b/src/base/combination/switcher.js @@ -186,11 +186,9 @@ BI.Switcher = BI.inherit(BI.Widget, { this.switcher.populate.apply(this.switcher, arguments); }, - setEnable: function (arg) { - BI.Switcher.superclass.setEnable.apply(this, arguments); - this.switcher && this.switcher.setEnable(arg); - this.popupView && this.popupView.setEnable(arg); - !arg && this._hideView(); + _setEnable: function (arg) { + BI.Switcher.superclass._setEnable.apply(this, arguments); + !arg && this.isViewVisible() && this._hideView(); }, setValue: function (v) { diff --git a/src/base/layer/layer.popup.js b/src/base/layer/layer.popup.js index 2f86dad9a2..1af2125776 100644 --- a/src/base/layer/layer.popup.js +++ b/src/base/layer/layer.popup.js @@ -158,11 +158,6 @@ BI.PopupView = BI.inherit(BI.Widget, { this.view.element.css({"max-height": (h - tbHeight - tabHeight - toolHeight - 2) + "px"}) }, - setEnable: function (arg) { - BI.PopupView.superclass.setEnable.apply(this, arguments); - this.view && this.view.setEnable(arg); - }, - setValue: function (selectedValues) { this.tab && this.tab.setValue(selectedValues); this.button_group.setValue(selectedValues); diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 19aa8075d6..c35cbb5f7b 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -298,8 +298,8 @@ BI.BasicButton = BI.inherit(BI.Single, { return this.options.text; }, - setEnable: function (b) { - BI.BasicButton.superclass.setEnable.apply(this, arguments); + _setEnable: function (b) { + BI.BasicButton.superclass._setEnable.apply(this, arguments); if (!b) { if (this.options.shadow) { this.$mask && this.$mask.setVisible(false); diff --git a/src/base/single/button/buttons/button.js b/src/base/single/button/buttons/button.js index 51854f5c26..9e02af0481 100644 --- a/src/base/single/button/buttons/button.js +++ b/src/base/single/button/buttons/button.js @@ -119,12 +119,6 @@ } }, - setEnable: function (b) { - BI.Button.superclass.setEnable.apply(this, arguments); - // this.text.setEnable(b); - // this.icon && this.icon.setEnable(b); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/base/single/editor/editor.code.js b/src/base/single/editor/editor.code.js index e8beba8c86..3a8292d0ce 100644 --- a/src/base/single/editor/editor.code.js +++ b/src/base/single/editor/editor.code.js @@ -76,8 +76,8 @@ BI.CodeEditor = BI.inherit(BI.Single, { } }, - setEnable: function (b) { - BI.CodeEditor.superclass.setEnable.apply(this, arguments); + _setEnable: function (b) { + BI.CodeEditor.superclass._setEnable.apply(this, arguments); this.editor.setOption("readOnly", b === true ? false : "nocursor") }, diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 44b7781ec9..b352506e29 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -303,12 +303,6 @@ BI.Editor = BI.inherit(BI.Single, { isValid: function () { return this.editor.isValid(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); - this.watermark && this.watermark.setEnable(b); } }); BI.Editor.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index b2823a2f14..dd25c7c0e6 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/src/base/single/editor/editor.multifile.js @@ -79,11 +79,6 @@ BI.MultifileEditor = BI.inherit(BI.Single, { reset: function () { this.file.reset(); - }, - - setEnable: function (enable) { - BI.MultiFile.superclass.setEnable.apply(this, arguments); - this.file.setEnable(enable); } }); BI.MultifileEditor.EVENT_CHANGE = "MultifileEditor.EVENT_CHANGE"; diff --git a/src/base/single/editor/editor.textarea.js b/src/base/single/editor/editor.textarea.js index daa12f8a84..15c6bc7a15 100644 --- a/src/base/single/editor/editor.textarea.js +++ b/src/base/single/editor/editor.textarea.js @@ -153,12 +153,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, { BI.TextAreaEditor.superclass.setValid.apply(this, arguments); this.content.setValid(b); this.watermark && this.watermark.setValid(b); - }, - - setEnable: function (b) { - BI.TextAreaEditor.superclass.setEnable.apply(this, arguments); - this.content.setEnable(b); - this.watermark && this.watermark.setEnable(b); } }); BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index 6dc191f1a6..8b4d57a11a 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -601,8 +601,8 @@ this.wrap.attachNum = 0; }, - setEnable: function (enable) { - BI.File.superclass.setEnable.apply(this, arguments); + _setEnable: function (enable) { + BI.File.superclass._setEnable.apply(this, arguments); if (enable === true) { this.element.attr("disabled", "disabled"); } else { diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index af92d1ca42..06d59168ec 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -256,8 +256,8 @@ BI.Input = BI.inherit(BI.Single, { } }, - setEnable: function (b) { - BI.Input.superclass.setEnable.apply(this, [b]); + _setEnable: function (b) { + BI.Input.superclass._setEnable.apply(this, [b]); this.element[0].disabled = !b; } }); diff --git a/src/base/tree/customtree.js b/src/base/tree/customtree.js index 22e71e64a4..1d5342ae88 100644 --- a/src/base/tree/customtree.js +++ b/src/base/tree/customtree.js @@ -35,11 +35,6 @@ BI.CustomTree = BI.inherit(BI.Widget, { this.initTree(this.options.items); }, - setEnable: function (v) { - BI.CustomTree.superclass.setEnable.apply(this, arguments); - this.tree.setEnable(v) - }, - _formatItems: function (nodes) { var self = this, o = this.options; nodes = BI.Tree.transformToTreeFormat(nodes); diff --git a/src/case/button/icon/icon.change.js b/src/case/button/icon/icon.change.js index 2511072e51..69c050fdbc 100644 --- a/src/case/button/icon/icon.change.js +++ b/src/case/button/icon/icon.change.js @@ -77,11 +77,6 @@ BI.IconChangeButton = BI.inherit(BI.Single, { this.element.removeClass(o.iconClass).addClass(cls); o.iconClass = cls; } - }, - - setEnable: function (b) { - BI.IconChangeButton.superclass.setEnable.apply(this, arguments); - this.button.setEnable(b); } }); BI.IconChangeButton.EVENT_CHANGE = "IconChangeButton.EVENT_CHANGE"; diff --git a/src/case/button/item.multiselect.js b/src/case/button/item.multiselect.js index b7b7eed428..5a6ac20425 100644 --- a/src/case/button/item.multiselect.js +++ b/src/case/button/item.multiselect.js @@ -50,11 +50,6 @@ BI.MultiSelectItem = BI.inherit(BI.BasicButton, { })))); }, - setEnable: function (v) { - BI.MultiSelectItem.superclass.setEnable.apply(this, arguments); - this.checkbox.setEnable(v); - }, - doRedMark: function () { this.text.doRedMark.apply(this.text, arguments); }, diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index 302a54fb79..af97fa9547 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -70,10 +70,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, { return this.combo.isViewVisible(); }, - setEnable: function (v) { - this.combo.setEnable(v) - }, - setValue: function (color) { this.combo.setValue(color); }, diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 023872a577..8801475f27 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -201,10 +201,6 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { isViewVisible: function () { return this.combo.isViewVisible(); - }, - - setEnable: function (v) { - this.combo.setEnable(!!v); } }); diff --git a/src/case/combo/editoriconcheckcombo/combo.editoriconcheck.js b/src/case/combo/editoriconcheckcombo/combo.editoriconcheck.js index 1dc5259604..39c5bb11ef 100644 --- a/src/case/combo/editoriconcheckcombo/combo.editoriconcheck.js +++ b/src/case/combo/editoriconcheckcombo/combo.editoriconcheck.js @@ -62,11 +62,6 @@ BI.EditorIconCheckCombo = BI.inherit(BI.Widget, { this.editorIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.EditorIconCheckCombo.superclass.setEnable.apply(this, arguments); - this.editorIconCheckCombo.setEnable(v); - }, - getValue: function () { return this.trigger.getValue(); }, diff --git a/src/case/combo/iconcombo/combo.icon.js b/src/case/combo/iconcombo/combo.icon.js index 74ddacdc52..75666fc6ca 100644 --- a/src/case/combo/iconcombo/combo.icon.js +++ b/src/case/combo/iconcombo/combo.icon.js @@ -81,11 +81,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { this.iconCombo.setValue(v); }, - setEnable: function (v) { - BI.IconCombo.superclass.setEnable.apply(this, arguments); - this.iconCombo.setEnable(v); - }, - getValue: function () { return this.iconCombo.getValue(); }, diff --git a/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js b/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js index 352c6be785..47608a8caa 100644 --- a/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js +++ b/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js @@ -56,11 +56,6 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { this.textIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.TextValueCheckCombo.superclass.setEnable.apply(this, arguments); - this.textIconCheckCombo.setEnable(v); - }, - setWarningTitle: function (title) { this.trigger.setWarningTitle(title); }, diff --git a/src/case/combo/textvaluecheckcombo/combo.textvaluechecksmall.js b/src/case/combo/textvaluecheckcombo/combo.textvaluechecksmall.js index 0de03ef9ed..a5bcdcaa6f 100644 --- a/src/case/combo/textvaluecheckcombo/combo.textvaluechecksmall.js +++ b/src/case/combo/textvaluecheckcombo/combo.textvaluechecksmall.js @@ -51,11 +51,6 @@ BI.SmallTextValueCheckCombo = BI.inherit(BI.Widget, { this.SmallTextIconCheckCombo.setValue(v); }, - setEnable: function (v) { - BI.SmallTextValueCheckCombo.superclass.setEnable.apply(this, arguments); - this.SmallTextIconCheckCombo.setEnable(v); - }, - getValue: function () { return this.SmallTextIconCheckCombo.getValue(); }, diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 53e7c95942..3e58873df6 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -53,11 +53,6 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { this.textIconCombo.setValue(v); }, - setEnable: function (v) { - BI.TextValueCombo.superclass.setEnable.apply(this, arguments); - this.textIconCombo.setEnable(v); - }, - getValue: function () { return this.textIconCombo.getValue(); }, diff --git a/src/case/combo/textvaluecombo/combo.textvaluesmall.js b/src/case/combo/textvaluecombo/combo.textvaluesmall.js index 54e6a9cce7..3a6c86057f 100644 --- a/src/case/combo/textvaluecombo/combo.textvaluesmall.js +++ b/src/case/combo/textvaluecombo/combo.textvaluesmall.js @@ -53,11 +53,6 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, { this.SmallTextValueCombo.setValue(v); }, - setEnable: function (v) { - BI.SmallTextValueCombo.superclass.setEnable.apply(this, arguments); - this.SmallTextValueCombo.setEnable(v); - }, - getValue: function () { return this.SmallTextValueCombo.getValue(); }, diff --git a/src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js b/src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js index 95247087bb..94c69b8d0f 100644 --- a/src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js +++ b/src/case/combo/textvaluedownlistcombo/combo.textvaluedownlist.js @@ -64,11 +64,6 @@ BI.TextValueDownListCombo = BI.inherit(BI.Widget, { this.trigger.setValue(v.childValue || v.value); }, - setEnable: function (v) { - BI.TextValueDownListCombo.superclass.setEnable.apply(this, arguments); - this.combo.setEnable(v); - }, - getValue: function () { var v = this.combo.getValue()[0]; return [v.childValue || v.value]; diff --git a/src/case/editor/editor.search.js b/src/case/editor/editor.search.js index f4f5218eb9..1cad5eb312 100644 --- a/src/case/editor/editor.search.js +++ b/src/case/editor/editor.search.js @@ -168,12 +168,6 @@ BI.SearchEditor = BI.inherit(BI.Widget, { isValid: function () { return this.editor.isValid(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); - this.clear.setEnable(b); } }); BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js index 129bd274bc..8156f33444 100644 --- a/src/case/editor/editor.state.js +++ b/src/case/editor/editor.state.js @@ -201,11 +201,6 @@ BI.StateEditor = BI.inherit(BI.Widget, { this.editor.setValue(k); }, - setEnable: function (v) { - this.text.setEnable(v); - this.editor.setEnable(v); - }, - getValue: function () { return this.editor.getValue(); }, diff --git a/src/case/editor/editor.state.simple.js b/src/case/editor/editor.state.simple.js index f343a8cda8..2d89d53ca4 100644 --- a/src/case/editor/editor.state.simple.js +++ b/src/case/editor/editor.state.simple.js @@ -199,11 +199,6 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, { this.editor.setValue(k); }, - setEnable: function(v){ - this.text.setEnable(v); - this.editor.setEnable(v); - }, - getValue: function () { return this.editor.getValue(); }, diff --git a/src/case/editor/editor.text.js b/src/case/editor/editor.text.js index ad8cc8789e..d610ab1c2f 100644 --- a/src/case/editor/editor.text.js +++ b/src/case/editor/editor.text.js @@ -141,11 +141,6 @@ BI.TextEditor = BI.inherit(BI.Widget, { getValue: function () { return this.editor.getValue(); - }, - - setEnable: function (b) { - BI.Editor.superclass.setEnable.apply(this, arguments); - this.editor && this.editor.setEnable(b); } }); BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/segment/segment.js b/src/case/segment/segment.js index 0979baaa09..7a8f1fad0b 100644 --- a/src/case/segment/segment.js +++ b/src/case/segment/segment.js @@ -46,10 +46,6 @@ BI.Segment = BI.inherit(BI.Widget, { this.buttonGroup.setEnabledValue(v); }, - setEnable: function (v) { - this.buttonGroup.setEnable(v); - }, - getValue: function () { return this.buttonGroup.getValue(); } diff --git a/src/case/toolbar/toolbar.multiselect.js b/src/case/toolbar/toolbar.multiselect.js index 262167d246..78c4b049b3 100644 --- a/src/case/toolbar/toolbar.multiselect.js +++ b/src/case/toolbar/toolbar.multiselect.js @@ -121,13 +121,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); this.setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); - }, - - setEnable: function (b) { - BI.MultiSelectBar.superclass.setEnable.apply(this, arguments); - this.checkbox.setEnable(b); - this.half.setEnable(b); - this.text.setEnable(b); } }); BI.MultiSelectBar.EVENT_CHANGE = "MultiSelectBar.EVENT_CHANGE"; diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index 91b73742c0..46681eba90 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -48,12 +48,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { }); }, - setEnable: function (v) { - BI.TextTrigger.superclass.setEnable.apply(this, arguments); - this.trigerButton.setEnable(v); - this.text.setEnable(v); - }, - setValue: function (value) { this.text.setValue(value); this.text.setTitle(value); diff --git a/src/case/trigger/trigger.text.small.js b/src/case/trigger/trigger.text.small.js index b524e9a6ad..3fb1c39fe9 100644 --- a/src/case/trigger/trigger.text.small.js +++ b/src/case/trigger/trigger.text.small.js @@ -47,12 +47,6 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, { }); }, - setEnable: function (v) { - BI.SmallTextTrigger.superclass.setEnable.apply(this, arguments); - this.trigerButton.setEnable(v); - this.text.setEnable(v); - }, - setValue: function (value) { this.text.setValue(value); }, diff --git a/src/core/widget.js b/src/core/widget.js index 2ba806a879..83e63c84dc 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -105,17 +105,18 @@ BI.Widget = BI.inherit(BI.OB, { _initVisualEffects: function () { var o = this.options; if (o.invisible) { - this.element.hide(); + //用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 + this.element.css("display", "none"); } if (o.disabled || o.invalid) { - BI.nextTick(BI.bind(function () { - if (this.options.disabled) { - this.setEnable(false); - } - if (this.options.invalid) { - this.setValid(false); - } - }, this)); + // BI.nextTick(BI.bind(function () { + if (this.options.disabled) { + this.setEnable(false); + } + if (this.options.invalid) { + this.setValid(false); + } + // }, this)); } }, @@ -163,6 +164,7 @@ BI.Widget = BI.inherit(BI.OB, { this._isMounted = true; this._mountChildren && this._mountChildren(); BI.each(this._children, function (i, widget) { + !self.isEnabled() && widget._setEnable(false); widget._mount && widget._mount(); }); this.mounted && this.mounted(); @@ -184,12 +186,23 @@ BI.Widget = BI.inherit(BI.OB, { this._initElementHeight(); }, - setEnable: function (enable) { + _setEnable: function (enable) { if (enable === true) { this.options.disabled = false; - this.element.removeClass("base-disabled disabled"); } else if (enable === false) { this.options.disabled = true; + } + //递归将所有子组件使能 + BI.each(this._children, function (i, child) { + child._setEnable && child._setEnable(enable); + }); + }, + + setEnable: function (enable) { + this._setEnable(enable); + if (enable === true) { + this.element.removeClass("base-disabled disabled"); + } else if (enable === false) { this.element.addClass("base-disabled disabled"); } }, diff --git a/src/css/core/utils/common.css b/src/css/core/utils/common.css index fb4f4a5755..23ca02db36 100644 --- a/src/css/core/utils/common.css +++ b/src/css/core/utils/common.css @@ -125,8 +125,8 @@ } .bi-z-index-mask { color: #ffffff; - background-color: rgba(26, 26, 26, 0.3); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d1a1a1a,endColorstr=#4d1a1a1a); + background-color: rgba(26, 26, 26, 0.5); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#801a1a1a,endColorstr=#801a1a1a); } .bi-list-item:hover, .bi-list-item.hover { diff --git a/src/less/core/utils/common.less b/src/less/core/utils/common.less index 2217968708..6537c9d8e1 100644 --- a/src/less/core/utils/common.less +++ b/src/less/core/utils/common.less @@ -175,7 +175,7 @@ .bi-z-index-mask { color: @color-bi-background-default; - .background-color(@color-bi-background-black, 30%); + .background-color(@color-bi-background-black, 50%); } //只有背景变化 diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index a6ccffdd61..febe158009 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -155,10 +155,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (arg) { - this.button_group.setEnable(arg); - }, - resetHeight: function (h) { this.button_group.resetHeight(h); }, diff --git a/src/widget/multiselect/multiselect.popup.view.js b/src/widget/multiselect/multiselect.popup.view.js index ef9789f6b8..cfbd6aca15 100644 --- a/src/widget/multiselect/multiselect.popup.view.js +++ b/src/widget/multiselect/multiselect.popup.view.js @@ -74,10 +74,6 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, { this.popupView.populate.apply(this.popupView, arguments); }, - setEnable: function (arg) { - this.popupView.setEnable(arg); - }, - resetHeight: function (h) { this.popupView.resetHeight(h); }, diff --git a/src/widget/multiselect/multiselect.trigger.js b/src/widget/multiselect/multiselect.trigger.js index e9a1dda38f..0da496a64e 100644 --- a/src/widget/multiselect/multiselect.trigger.js +++ b/src/widget/multiselect/multiselect.trigger.js @@ -133,10 +133,6 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { this.numberCounter.setValue(ob); }, - setEnable: function (v) { - this.searcher.setEnable(v); - }, - getKey: function () { return this.searcher.getKey(); }, diff --git a/src/widget/multiselect/search/multiselect.search.loader.js b/src/widget/multiselect/search/multiselect.search.loader.js index d901487e39..20c74c61a1 100644 --- a/src/widget/multiselect/search/multiselect.search.loader.js +++ b/src/widget/multiselect/search/multiselect.search.loader.js @@ -139,10 +139,6 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { this.button_group.populate.apply(this.button_group, arguments); }, - setEnable: function (arg) { - this.button_group.setEnable(arg); - }, - resetHeight: function (h) { this.button_group.resetHeight(h); }, diff --git a/src/widget/multiselect/trigger/editor.multiselect.js b/src/widget/multiselect/trigger/editor.multiselect.js index 5d35a3a796..368509fa4a 100644 --- a/src/widget/multiselect/trigger/editor.multiselect.js +++ b/src/widget/multiselect/trigger/editor.multiselect.js @@ -56,10 +56,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, { this.editor.setValue(v); }, - setEnable: function(v){ - this.editor.setEnable(v); - }, - getValue: function () { var v = this.editor.getState(); if (BI.isArray(v) && v.length > 0) { diff --git a/src/widget/multiselect/trigger/searcher.multiselect.js b/src/widget/multiselect/trigger/searcher.multiselect.js index 337749a6ee..166b79117c 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.js @@ -134,10 +134,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { return this.searcher.getValue(); }, - setEnable: function (v) { - this.editor.setEnable(v); - }, - populate: function (items) { this.searcher.populate.apply(this.searcher, arguments); } diff --git a/src/widget/multistringlist/multistringlist.js b/src/widget/multistringlist/multistringlist.js index c9f39b780f..5ca2696795 100644 --- a/src/widget/multistringlist/multistringlist.js +++ b/src/widget/multistringlist/multistringlist.js @@ -287,11 +287,6 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this.trigger.getSearcher().adjustView(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); - }, - setValue: function (v) { this.storeValue = v || {}; this._assertValue(this.storeValue); diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js index 7c302e9cd2..d2bd72edf4 100644 --- a/src/widget/multitree/multi.tree.combo.js +++ b/src/widget/multitree/multi.tree.combo.js @@ -236,10 +236,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { this.combo.hideView(); }, - setEnable: function (v) { - this.combo.setEnable(v); - }, - setValue: function (v) { this.storeValue.value = v || {}; this.combo.setValue({ diff --git a/src/widget/multitree/multi.tree.popup.js b/src/widget/multitree/multi.tree.popup.js index 542a339b61..e8c5cded0e 100644 --- a/src/widget/multitree/multi.tree.popup.js +++ b/src/widget/multitree/multi.tree.popup.js @@ -79,10 +79,6 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, { return this.tree.hasChecked(); }, - setEnable: function (arg) { - this.popupView.setEnable(arg); - }, - resetHeight: function (h) { this.popupView.resetHeight(h); }, diff --git a/src/widget/multitree/trigger/searcher.multi.tree.js b/src/widget/multitree/trigger/searcher.multi.tree.js index 5c07c576cc..e63eed7cb0 100644 --- a/src/widget/multitree/trigger/searcher.multi.tree.js +++ b/src/widget/multitree/trigger/searcher.multi.tree.js @@ -119,10 +119,6 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, { return this.editor.getValue(); }, - setEnable: function(v){ - this.editor.setEnable(v); - }, - getValue: function () { return this.searcher.getValue(); }, diff --git a/src/widget/multitreelist/multitreelist.js b/src/widget/multitreelist/multitreelist.js index d530e20453..52182c0dce 100644 --- a/src/widget/multitreelist/multitreelist.js +++ b/src/widget/multitreelist/multitreelist.js @@ -150,11 +150,6 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { this.trigger.getSearcher().adjustView(); }, - setEnable: function (v) { - this.trigger.setEnable(v); - this.popup.setEnable(v); - }, - setValue: function (v) { this.storeValue.value = v || {}; this.popup.setValue({ diff --git a/src/widget/numericalinterval/numericalinterval.js b/src/widget/numericalinterval/numericalinterval.js index e02ed03b56..f7231708d0 100644 --- a/src/widget/numericalinterval/numericalinterval.js +++ b/src/widget/numericalinterval/numericalinterval.js @@ -430,13 +430,6 @@ BI.NumericalInterval = BI.inherit(BI.Single, { return this.options.validation === "valid"; }, - setEnable: function (b) { - this.smallEditor.setEnable(b); - this.smallCombo.setEnable(b); - this.bigEditor.setEnable(b); - this.bigCombo.setEnable(b); - }, - setMinEnable: function (b) { this.smallEditor.setEnable(b); }, From 8b7926641fb0b4a6bcc9d8b21b71824489f344eb Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 18 May 2017 09:28:38 +0800 Subject: [PATCH 8/9] enable --- bi/base.js | 9 +- bi/core.js | 253 ++++++++++++------------- docs/base.js | 9 +- docs/core.js | 253 ++++++++++++------------- src/base/single/button/button.basic.js | 9 +- src/core/alias.js | 249 ++++++++++++------------ src/core/proto/date.js | 3 +- 7 files changed, 389 insertions(+), 396 deletions(-) diff --git a/bi/base.js b/bi/base.js index a7fe770ab7..9c789c2538 100644 --- a/bi/base.js +++ b/bi/base.js @@ -881,9 +881,14 @@ BI.BasicButton = BI.inherit(BI.Single, { return this.options.text; }, - _setEnable: function (b) { + _setEnable: function (enable) { BI.BasicButton.superclass._setEnable.apply(this, arguments); - if (!b) { + 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); } diff --git a/bi/core.js b/bi/core.js index f311b8aeb5..5d1435197c 100644 --- a/bi/core.js +++ b/bi/core.js @@ -3042,6 +3042,9 @@ if (!window.BI) { } }); })(jQuery);;(function () { + if (!window.BI) { + window.BI = {}; + } function isEmpty(value) { // 判断是否为空值 var result = value === "" || value === null || value === undefined; @@ -3102,124 +3105,6 @@ if (!window.BI) { return text; } - /** - * 把日期对象按照指定格式转化成字符串 - * - * @example - * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800'); - * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12 - * - * @class BI.date2Str - * @param date 日期 - * @param format 日期格式 - * @returns {String} - */ - function date2Str(date, format) { - if (!date) { - return ''; - } - // O(len(format)) - var len = format.length, result = ''; - if (len > 0) { - var flagch = format.charAt(0), start = 0, str = flagch; - for (var i = 1; i < len; i++) { - var ch = format.charAt(i); - if (flagch !== ch) { - result += compileJFmt({ - 'char': flagch, - 'str': str, - 'len': i - start - }, date); - flagch = ch; - start = i; - str = flagch; - } else { - str += ch; - } - } - result += compileJFmt({ - 'char': flagch, - 'str': str, - 'len': len - start - }, date); - } - return result; - - function compileJFmt(jfmt, date) { - var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; - switch (ch) { - case 'E': //星期 - str = Date._DN[date.getDay()]; - break; - case 'y': //年 - if (len <= 3) { - str = (date.getFullYear() + '').slice(2, 4); - } else { - str = date.getFullYear(); - } - break; - case 'M': //月 - if (len > 2) { - str = Date._MN[date.getMonth()]; - } else if (len < 2) { - str = date.getMonth() + 1; - } else { - str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); - } - break; - case 'd': //日 - if (len > 1) { - str = String.leftPad(date.getDate() + '', 2, '0'); - } else { - str = date.getDate(); - } - break; - case 'h': //时(12) - var hour = date.getHours() % 12; - if (hour === 0) { - hour = 12; - } - if (len > 1) { - str = String.leftPad(hour + '', 2, '0'); - } else { - str = hour; - } - break; - case 'H': //时(24) - if (len > 1) { - str = String.leftPad(date.getHours() + '', 2, '0'); - } else { - str = date.getHours(); - } - break; - case 'm': - if (len > 1) { - str = String.leftPad(date.getMinutes() + '', 2, '0'); - } else { - str = date.getMinutes(); - } - break; - case 's': - if (len > 1) { - str = String.leftPad(date.getSeconds() + '', 2, '0'); - } else { - str = date.getSeconds(); - } - break; - case 'a': - str = date.getHours() < 12 ? 'am' : 'pm'; - break; - case 'z': - str = date.getTimezone(); - break; - default: - str = jfmt.str; - break; - } - return str; - } - }; - /** * 数字格式 */ @@ -3262,7 +3147,8 @@ if (!window.BI) { } else { return left + '.' + right; } - }; + } + /** * 处理小数点右边小数部分 * @param tright 右边内容 @@ -3306,7 +3192,7 @@ if (!window.BI) { if (newnum.length > orilen) { newnum = newnum.substr(1); } else { - newnum = BI.leftPad(newnum, orilen, '0'); + newnum = String.leftPad(newnum, orilen, '0'); result.leftPlus = false; } right = right.replace(/^[0-9]+/, newnum); @@ -3567,7 +3453,7 @@ if (!window.BI) { return o; })(jo); - } + }; BI.contentFormat = function (cv, fmt) { if (isEmpty(cv)) { @@ -3609,15 +3495,122 @@ if (!window.BI) { return text; }; - BI.leftPad = function (val, size, ch) { - var result = String(val); - if (!ch) { - ch = " "; + /** + * 把日期对象按照指定格式转化成字符串 + * + * @example + * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800'); + * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12 + * + * @class BI.date2Str + * @param date 日期 + * @param format 日期格式 + * @returns {String} + */ + BI.date2Str = function (date, format) { + if (!date) { + return ''; } - while (result.length < size) { - result = ch + result; + // O(len(format)) + var len = format.length, result = ''; + if (len > 0) { + var flagch = format.charAt(0), start = 0, str = flagch; + for (var i = 1; i < len; i++) { + var ch = format.charAt(i); + if (flagch !== ch) { + result += compileJFmt({ + 'char': flagch, + 'str': str, + 'len': i - start + }, date); + flagch = ch; + start = i; + str = flagch; + } else { + str += ch; + } + } + result += compileJFmt({ + 'char': flagch, + 'str': str, + 'len': len - start + }, date); + } + return result; + + function compileJFmt(jfmt, date) { + var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; + switch (ch) { + case 'E': //星期 + str = Date._DN[date.getDay()]; + break; + case 'y': //年 + if (len <= 3) { + str = (date.getFullYear() + '').slice(2, 4); + } else { + str = date.getFullYear(); + } + break; + case 'M': //月 + if (len > 2) { + str = Date._MN[date.getMonth()]; + } else if (len < 2) { + str = date.getMonth() + 1; + } else { + str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); + } + break; + case 'd': //日 + if (len > 1) { + str = String.leftPad(date.getDate() + '', 2, '0'); + } else { + str = date.getDate(); + } + break; + case 'h': //时(12) + var hour = date.getHours() % 12; + if (hour === 0) { + hour = 12; + } + if (len > 1) { + str = String.leftPad(hour + '', 2, '0'); + } else { + str = hour; + } + break; + case 'H': //时(24) + if (len > 1) { + str = String.leftPad(date.getHours() + '', 2, '0'); + } else { + str = date.getHours(); + } + break; + case 'm': + if (len > 1) { + str = String.leftPad(date.getMinutes() + '', 2, '0'); + } else { + str = date.getMinutes(); + } + break; + case 's': + if (len > 1) { + str = String.leftPad(date.getSeconds() + '', 2, '0'); + } else { + str = date.getSeconds(); + } + break; + case 'a': + str = date.getHours() < 12 ? 'am' : 'pm'; + break; + case 'z': + str = date.getTimezone(); + break; + default: + str = jfmt.str; + break; + } + return str; } - return result.toString(); }; BI.object2Number = function (value) { @@ -6026,7 +6019,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"), BI.i18nText("BI-Quarter_3"), BI.i18nText("BI-Quarter_4")]; - /** Adds the number of days array to the Date object. */ Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; @@ -6500,7 +6492,8 @@ Date.parseDateTime = function (str, fmt) { return new Date(y, m, d, hr, min, sec); } return today; -};/* +}; +/* * 给jQuery.Event对象添加的工具方法 */ $.extend($.Event.prototype, { diff --git a/docs/base.js b/docs/base.js index a7fe770ab7..9c789c2538 100644 --- a/docs/base.js +++ b/docs/base.js @@ -881,9 +881,14 @@ BI.BasicButton = BI.inherit(BI.Single, { return this.options.text; }, - _setEnable: function (b) { + _setEnable: function (enable) { BI.BasicButton.superclass._setEnable.apply(this, arguments); - if (!b) { + 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); } diff --git a/docs/core.js b/docs/core.js index 1715d0032b..ede23ef0b3 100644 --- a/docs/core.js +++ b/docs/core.js @@ -19906,6 +19906,9 @@ BI.PopoverSection = BI.inherit(BI.Widget, { } }); BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { + if (!window.BI) { + window.BI = {}; + } function isEmpty(value) { // 判断是否为空值 var result = value === "" || value === null || value === undefined; @@ -19966,124 +19969,6 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { return text; } - /** - * 把日期对象按照指定格式转化成字符串 - * - * @example - * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800'); - * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12 - * - * @class BI.date2Str - * @param date 日期 - * @param format 日期格式 - * @returns {String} - */ - function date2Str(date, format) { - if (!date) { - return ''; - } - // O(len(format)) - var len = format.length, result = ''; - if (len > 0) { - var flagch = format.charAt(0), start = 0, str = flagch; - for (var i = 1; i < len; i++) { - var ch = format.charAt(i); - if (flagch !== ch) { - result += compileJFmt({ - 'char': flagch, - 'str': str, - 'len': i - start - }, date); - flagch = ch; - start = i; - str = flagch; - } else { - str += ch; - } - } - result += compileJFmt({ - 'char': flagch, - 'str': str, - 'len': len - start - }, date); - } - return result; - - function compileJFmt(jfmt, date) { - var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; - switch (ch) { - case 'E': //星期 - str = Date._DN[date.getDay()]; - break; - case 'y': //年 - if (len <= 3) { - str = (date.getFullYear() + '').slice(2, 4); - } else { - str = date.getFullYear(); - } - break; - case 'M': //月 - if (len > 2) { - str = Date._MN[date.getMonth()]; - } else if (len < 2) { - str = date.getMonth() + 1; - } else { - str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); - } - break; - case 'd': //日 - if (len > 1) { - str = String.leftPad(date.getDate() + '', 2, '0'); - } else { - str = date.getDate(); - } - break; - case 'h': //时(12) - var hour = date.getHours() % 12; - if (hour === 0) { - hour = 12; - } - if (len > 1) { - str = String.leftPad(hour + '', 2, '0'); - } else { - str = hour; - } - break; - case 'H': //时(24) - if (len > 1) { - str = String.leftPad(date.getHours() + '', 2, '0'); - } else { - str = date.getHours(); - } - break; - case 'm': - if (len > 1) { - str = String.leftPad(date.getMinutes() + '', 2, '0'); - } else { - str = date.getMinutes(); - } - break; - case 's': - if (len > 1) { - str = String.leftPad(date.getSeconds() + '', 2, '0'); - } else { - str = date.getSeconds(); - } - break; - case 'a': - str = date.getHours() < 12 ? 'am' : 'pm'; - break; - case 'z': - str = date.getTimezone(); - break; - default: - str = jfmt.str; - break; - } - return str; - } - }; - /** * 数字格式 */ @@ -20126,7 +20011,8 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { } else { return left + '.' + right; } - }; + } + /** * 处理小数点右边小数部分 * @param tright 右边内容 @@ -20170,7 +20056,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { if (newnum.length > orilen) { newnum = newnum.substr(1); } else { - newnum = BI.leftPad(newnum, orilen, '0'); + newnum = String.leftPad(newnum, orilen, '0'); result.leftPlus = false; } right = right.replace(/^[0-9]+/, newnum); @@ -20431,7 +20317,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { return o; })(jo); - } + }; BI.contentFormat = function (cv, fmt) { if (isEmpty(cv)) { @@ -20473,15 +20359,122 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { return text; }; - BI.leftPad = function (val, size, ch) { - var result = String(val); - if (!ch) { - ch = " "; + /** + * 把日期对象按照指定格式转化成字符串 + * + * @example + * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800'); + * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12 + * + * @class BI.date2Str + * @param date 日期 + * @param format 日期格式 + * @returns {String} + */ + BI.date2Str = function (date, format) { + if (!date) { + return ''; } - while (result.length < size) { - result = ch + result; + // O(len(format)) + var len = format.length, result = ''; + if (len > 0) { + var flagch = format.charAt(0), start = 0, str = flagch; + for (var i = 1; i < len; i++) { + var ch = format.charAt(i); + if (flagch !== ch) { + result += compileJFmt({ + 'char': flagch, + 'str': str, + 'len': i - start + }, date); + flagch = ch; + start = i; + str = flagch; + } else { + str += ch; + } + } + result += compileJFmt({ + 'char': flagch, + 'str': str, + 'len': len - start + }, date); + } + return result; + + function compileJFmt(jfmt, date) { + var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; + switch (ch) { + case 'E': //星期 + str = Date._DN[date.getDay()]; + break; + case 'y': //年 + if (len <= 3) { + str = (date.getFullYear() + '').slice(2, 4); + } else { + str = date.getFullYear(); + } + break; + case 'M': //月 + if (len > 2) { + str = Date._MN[date.getMonth()]; + } else if (len < 2) { + str = date.getMonth() + 1; + } else { + str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); + } + break; + case 'd': //日 + if (len > 1) { + str = String.leftPad(date.getDate() + '', 2, '0'); + } else { + str = date.getDate(); + } + break; + case 'h': //时(12) + var hour = date.getHours() % 12; + if (hour === 0) { + hour = 12; + } + if (len > 1) { + str = String.leftPad(hour + '', 2, '0'); + } else { + str = hour; + } + break; + case 'H': //时(24) + if (len > 1) { + str = String.leftPad(date.getHours() + '', 2, '0'); + } else { + str = date.getHours(); + } + break; + case 'm': + if (len > 1) { + str = String.leftPad(date.getMinutes() + '', 2, '0'); + } else { + str = date.getMinutes(); + } + break; + case 's': + if (len > 1) { + str = String.leftPad(date.getSeconds() + '', 2, '0'); + } else { + str = date.getSeconds(); + } + break; + case 'a': + str = date.getHours() < 12 ? 'am' : 'pm'; + break; + case 'z': + str = date.getTimezone(); + break; + default: + str = jfmt.str; + break; + } + return str; } - return result.toString(); }; BI.object2Number = function (value) { @@ -23528,7 +23521,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"), BI.i18nText("BI-Quarter_3"), BI.i18nText("BI-Quarter_4")]; - /** Adds the number of days array to the Date object. */ Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; @@ -24002,7 +23994,8 @@ Date.parseDateTime = function (str, fmt) { return new Date(y, m, d, hr, min, sec); } return today; -};/* +}; +/* * 给jQuery.Event对象添加的工具方法 */ $.extend($.Event.prototype, { diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index c35cbb5f7b..80b513862d 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -298,9 +298,14 @@ BI.BasicButton = BI.inherit(BI.Single, { return this.options.text; }, - _setEnable: function (b) { + _setEnable: function (enable) { BI.BasicButton.superclass._setEnable.apply(this, arguments); - if (!b) { + 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); } diff --git a/src/core/alias.js b/src/core/alias.js index 0abe30e403..59f7c55422 100644 --- a/src/core/alias.js +++ b/src/core/alias.js @@ -1,4 +1,7 @@ ;(function () { + if (!window.BI) { + window.BI = {}; + } function isEmpty(value) { // 判断是否为空值 var result = value === "" || value === null || value === undefined; @@ -59,124 +62,6 @@ return text; } - /** - * 把日期对象按照指定格式转化成字符串 - * - * @example - * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800'); - * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12 - * - * @class BI.date2Str - * @param date 日期 - * @param format 日期格式 - * @returns {String} - */ - function date2Str(date, format) { - if (!date) { - return ''; - } - // O(len(format)) - var len = format.length, result = ''; - if (len > 0) { - var flagch = format.charAt(0), start = 0, str = flagch; - for (var i = 1; i < len; i++) { - var ch = format.charAt(i); - if (flagch !== ch) { - result += compileJFmt({ - 'char': flagch, - 'str': str, - 'len': i - start - }, date); - flagch = ch; - start = i; - str = flagch; - } else { - str += ch; - } - } - result += compileJFmt({ - 'char': flagch, - 'str': str, - 'len': len - start - }, date); - } - return result; - - function compileJFmt(jfmt, date) { - var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; - switch (ch) { - case 'E': //星期 - str = Date._DN[date.getDay()]; - break; - case 'y': //年 - if (len <= 3) { - str = (date.getFullYear() + '').slice(2, 4); - } else { - str = date.getFullYear(); - } - break; - case 'M': //月 - if (len > 2) { - str = Date._MN[date.getMonth()]; - } else if (len < 2) { - str = date.getMonth() + 1; - } else { - str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); - } - break; - case 'd': //日 - if (len > 1) { - str = String.leftPad(date.getDate() + '', 2, '0'); - } else { - str = date.getDate(); - } - break; - case 'h': //时(12) - var hour = date.getHours() % 12; - if (hour === 0) { - hour = 12; - } - if (len > 1) { - str = String.leftPad(hour + '', 2, '0'); - } else { - str = hour; - } - break; - case 'H': //时(24) - if (len > 1) { - str = String.leftPad(date.getHours() + '', 2, '0'); - } else { - str = date.getHours(); - } - break; - case 'm': - if (len > 1) { - str = String.leftPad(date.getMinutes() + '', 2, '0'); - } else { - str = date.getMinutes(); - } - break; - case 's': - if (len > 1) { - str = String.leftPad(date.getSeconds() + '', 2, '0'); - } else { - str = date.getSeconds(); - } - break; - case 'a': - str = date.getHours() < 12 ? 'am' : 'pm'; - break; - case 'z': - str = date.getTimezone(); - break; - default: - str = jfmt.str; - break; - } - return str; - } - }; - /** * 数字格式 */ @@ -219,7 +104,8 @@ } else { return left + '.' + right; } - }; + } + /** * 处理小数点右边小数部分 * @param tright 右边内容 @@ -263,7 +149,7 @@ if (newnum.length > orilen) { newnum = newnum.substr(1); } else { - newnum = BI.leftPad(newnum, orilen, '0'); + newnum = String.leftPad(newnum, orilen, '0'); result.leftPlus = false; } right = right.replace(/^[0-9]+/, newnum); @@ -524,7 +410,7 @@ return o; })(jo); - } + }; BI.contentFormat = function (cv, fmt) { if (isEmpty(cv)) { @@ -566,15 +452,122 @@ return text; }; - BI.leftPad = function (val, size, ch) { - var result = String(val); - if (!ch) { - ch = " "; + /** + * 把日期对象按照指定格式转化成字符串 + * + * @example + * var date = new Date('Thu Dec 12 2013 00:00:00 GMT+0800'); + * var result = BI.date2Str(date, 'yyyy-MM-dd');//2013-12-12 + * + * @class BI.date2Str + * @param date 日期 + * @param format 日期格式 + * @returns {String} + */ + BI.date2Str = function (date, format) { + if (!date) { + return ''; } - while (result.length < size) { - result = ch + result; + // O(len(format)) + var len = format.length, result = ''; + if (len > 0) { + var flagch = format.charAt(0), start = 0, str = flagch; + for (var i = 1; i < len; i++) { + var ch = format.charAt(i); + if (flagch !== ch) { + result += compileJFmt({ + 'char': flagch, + 'str': str, + 'len': i - start + }, date); + flagch = ch; + start = i; + str = flagch; + } else { + str += ch; + } + } + result += compileJFmt({ + 'char': flagch, + 'str': str, + 'len': len - start + }, date); + } + return result; + + function compileJFmt(jfmt, date) { + var str = jfmt.str, len = jfmt.len, ch = jfmt['char']; + switch (ch) { + case 'E': //星期 + str = Date._DN[date.getDay()]; + break; + case 'y': //年 + if (len <= 3) { + str = (date.getFullYear() + '').slice(2, 4); + } else { + str = date.getFullYear(); + } + break; + case 'M': //月 + if (len > 2) { + str = Date._MN[date.getMonth()]; + } else if (len < 2) { + str = date.getMonth() + 1; + } else { + str = String.leftPad(date.getMonth() + 1 + '', 2, '0'); + } + break; + case 'd': //日 + if (len > 1) { + str = String.leftPad(date.getDate() + '', 2, '0'); + } else { + str = date.getDate(); + } + break; + case 'h': //时(12) + var hour = date.getHours() % 12; + if (hour === 0) { + hour = 12; + } + if (len > 1) { + str = String.leftPad(hour + '', 2, '0'); + } else { + str = hour; + } + break; + case 'H': //时(24) + if (len > 1) { + str = String.leftPad(date.getHours() + '', 2, '0'); + } else { + str = date.getHours(); + } + break; + case 'm': + if (len > 1) { + str = String.leftPad(date.getMinutes() + '', 2, '0'); + } else { + str = date.getMinutes(); + } + break; + case 's': + if (len > 1) { + str = String.leftPad(date.getSeconds() + '', 2, '0'); + } else { + str = date.getSeconds(); + } + break; + case 'a': + str = date.getHours() < 12 ? 'am' : 'pm'; + break; + case 'z': + str = date.getTimezone(); + break; + default: + str = jfmt.str; + break; + } + return str; } - return result.toString(); }; BI.object2Number = function (value) { diff --git a/src/core/proto/date.js b/src/core/proto/date.js index c8292a94dc..ed5eeb3d0b 100644 --- a/src/core/proto/date.js +++ b/src/core/proto/date.js @@ -55,7 +55,6 @@ Date._QN = ["", BI.i18nText("BI-Quarter_1"), BI.i18nText("BI-Quarter_3"), BI.i18nText("BI-Quarter_4")]; - /** Adds the number of days array to the Date object. */ Date._MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; @@ -529,4 +528,4 @@ Date.parseDateTime = function (str, fmt) { return new Date(y, m, d, hr, min, sec); } return today; -}; \ No newline at end of file +}; From 54797eaef9c22a1e743a2cfaa69a2b28379ae609 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 18 May 2017 10:16:49 +0800 Subject: [PATCH 9/9] add --- bi/core.js | 2 +- docs/core.js | 2 +- src/core/view.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bi/core.js b/bi/core.js index 5d1435197c..3d3ab264a0 100644 --- a/bi/core.js +++ b/bi/core.js @@ -5370,7 +5370,7 @@ BI.View = BI.inherit(BI.V, { BI.each(cardNames, function (i, name) { delete self._cards[name]; }); - this._cardLayouts[key] && this._cardLayouts[key].destroy(); + this._cardLayouts[key] && this._cardLayouts[key]._destroy(); return this; }, diff --git a/docs/core.js b/docs/core.js index ede23ef0b3..acd8075bc6 100644 --- a/docs/core.js +++ b/docs/core.js @@ -15372,7 +15372,7 @@ BI.View = BI.inherit(BI.V, { BI.each(cardNames, function (i, name) { delete self._cards[name]; }); - this._cardLayouts[key] && this._cardLayouts[key].destroy(); + this._cardLayouts[key] && this._cardLayouts[key]._destroy(); return this; }, diff --git a/src/core/view.js b/src/core/view.js index cfeaa5a53d..f5e5f23115 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -168,7 +168,7 @@ BI.View = BI.inherit(BI.V, { BI.each(cardNames, function (i, name) { delete self._cards[name]; }); - this._cardLayouts[key] && this._cardLayouts[key].destroy(); + this._cardLayouts[key] && this._cardLayouts[key]._destroy(); return this; },