Browse Source

Merge pull request #45 in FUI/fineui from ~GUY/fineui:master to master

* commit '7d42a339fd6b6765d755f59754ab3d47d2b3531d':
  add
  add
  update
  表格滚动极大优化
  add
es6
guy 8 years ago
parent
commit
91c3569c6b
  1. 66
      bi/base.js
  2. 54
      bi/core.js
  3. 66
      docs/base.js
  4. 54
      docs/core.js
  5. 25
      src/base/collection/collection.js
  6. 25
      src/base/grid/grid.js
  7. 8
      src/base/table/table.collection.js
  8. 8
      src/base/table/table.grid.js
  9. 2
      src/core/func/dom.js
  10. 2
      src/core/func/function.js
  11. 42
      src/core/widget.js
  12. 6
      src/core/wrapper/layout.js
  13. 2
      src/core/wrapper/layout/layout.card.js

66
bi/base.js

@ -2511,15 +2511,15 @@ BI.Canvas = BI.inherit(BI.Widget, {
} }
}); });
BI.shortcut("bi.canvas", BI.Canvas);/** BI.shortcut("bi.canvas", BI.Canvas);/**
* Collection * CollectionView
* *
* Created by GUY on 2016/1/15. * Created by GUY on 2016/1/15.
* @class BI.Collection * @class BI.CollectionView
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Collection = BI.inherit(BI.Widget, { BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () { _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", baseCls: "bi-collection",
width: 400, width: 400,
height: 300, height: 300,
@ -2535,7 +2535,7 @@ BI.Collection = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.Collection.superclass._init.apply(this, arguments); BI.CollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
@ -2554,7 +2554,7 @@ BI.Collection = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft(); o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.Collection.EVENT_SCROLL, { self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop
}); });
@ -2639,7 +2639,7 @@ BI.Collection = BI.inherit(BI.Widget, {
return; return;
} }
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
var renderedCells = [], renderedKeys = []; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
//存储所有的left和top //存储所有的left和top
var lefts = {}, tops = {}; var lefts = {}, tops = {};
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
@ -2722,6 +2722,7 @@ BI.Collection = BI.inherit(BI.Widget, {
} }
renderedKeys.push(datum.index); renderedKeys.push(datum.index);
renderedWidgets[i] = child;
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = []; var existSet = {}, addSet = {}, deleteArray = [];
@ -2742,13 +2743,17 @@ BI.Collection = BI.inherit(BI.Widget, {
deleteArray.push(i); deleteArray.push(i);
}); });
BI.each(deleteArray, function (i, index) { BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy(); //性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
}); });
var addedItems = []; var addedItems = [];
BI.each(addSet, function (index) { BI.each(addSet, function (index) {
addedItems.push(renderedCells[index]) addedItems.push(renderedCells[index])
}); });
this.container.addItems(addedItems); this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
@ -2859,8 +2864,8 @@ BI.Collection = BI.inherit(BI.Widget, {
this._populate(); this._populate();
} }
}); });
BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.Collection);/** BI.shortcut('bi.collection_view', BI.CollectionView);/**
* @class BI.Combo * @class BI.Combo
* @extends BI.Widget * @extends BI.Widget
*/ */
@ -14646,15 +14651,15 @@ $.extend(BI, {
}; };
}() }()
});/** });/**
* Grid * GridView
* *
* Created by GUY on 2016/1/11. * Created by GUY on 2016/1/11.
* @class BI.Grid * @class BI.GridView
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Grid = BI.inherit(BI.Widget, { BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () { _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", baseCls: "bi-grid-view",
width: 400, width: 400,
height: 300, height: 300,
@ -14673,7 +14678,7 @@ BI.Grid = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.Grid.superclass._init.apply(this, arguments); BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
@ -14692,7 +14697,7 @@ BI.Grid = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft(); o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.Grid.EVENT_SCROLL, { self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop
}); });
@ -14768,7 +14773,7 @@ BI.Grid = BI.inherit(BI.Widget, {
return; return;
} }
var renderedCells = [], renderedKeys = []; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14819,6 +14824,7 @@ BI.Grid = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key); renderedKeys.push(key);
renderedWidgets[i] = child;
} }
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
@ -14840,13 +14846,17 @@ BI.Grid = BI.inherit(BI.Widget, {
deleteArray.push(i); deleteArray.push(i);
}); });
BI.each(deleteArray, function (i, index) { BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy(); //性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
}); });
var addedItems = []; var addedItems = [];
BI.each(addSet, function (index) { BI.each(addSet, function (index) {
addedItems.push(renderedCells[index]) addedItems.push(renderedCells[index])
}); });
this.container.addItems(addedItems); this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
@ -14965,8 +14975,8 @@ BI.Grid = BI.inherit(BI.Widget, {
this._populate(); this._populate();
} }
}); });
BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.Grid);/** BI.shortcut('bi.grid_view', BI.GridView);/**
* floatBox弹出层 * floatBox弹出层
* @class BI.FloatBox * @class BI.FloatBox
* @extends BI.Widget * @extends BI.Widget
@ -28603,7 +28613,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topLeftItems[index]; 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.bottomLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28614,7 +28624,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topRightItems[index]; 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.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28625,7 +28635,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomLeftItems[index]; 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.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -28637,7 +28647,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomRightItems[index]; 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.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft); self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -29386,7 +29396,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter, 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.bottomLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29396,7 +29406,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter, 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.bottomRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29406,7 +29416,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter, 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.bottomRightGrid.setScrollTop(scroll.scrollTop);
self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self.topLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -29417,7 +29427,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter, 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.bottomLeftGrid.setScrollTop(scroll.scrollTop);
self.topRightGrid.setScrollLeft(scroll.scrollLeft); self.topRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();

54
bi/core.js

@ -4497,17 +4497,6 @@ BI.Widget = BI.inherit(BI.OB, {
_mountChildren: null, _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 () { isMounted: function () {
return this._isMounted; return this._isMounted;
}, },
@ -4587,7 +4576,7 @@ BI.Widget = BI.inherit(BI.OB, {
}, },
getWidgetByName: function (name) { getWidgetByName: function (name) {
if (!BI.isKey(name) || name == this.getName()) { if (!BI.isKey(name) || name === this.getName()) {
return this; return this;
} }
name = name + ""; name = name + "";
@ -4687,6 +4676,21 @@ BI.Widget = BI.inherit(BI.OB, {
this.setVisible(true); 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 () { isolate: function () {
if (this._parent) { if (this._parent) {
this._parent.removeWidget(this); this._parent.removeWidget(this);
@ -4702,13 +4706,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.element.empty(); this.element.empty();
}, },
_destroy: function () {
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.purgeListeners();
},
destroy: function () { destroy: function () {
BI.each(this._children, function (i, widget) { this.__d();
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this.element.destroy(); this.element.destroy();
this.fireEvent(BI.Events.DESTROY); this.fireEvent(BI.Events.DESTROY);
@ -11196,7 +11202,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = newItems; this.options.items = newItems;
this._children = newChildren; this._children = newChildren;
BI.each(deleted, function (i, c) { BI.each(deleted, function (i, c) {
c.destroy(); c._destroy();
}); });
}, },
@ -11221,7 +11227,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} else { } else {
w.element.prependTo(this._getWrapper()); w.element.prependTo(this._getWrapper());
} }
del.destroy(); del._destroy();
w._mount(); w._mount();
}, },
@ -11308,7 +11314,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
o.items.splice(items.length); o.items.splice(items.length);
BI.each(deleted, function (i, w) { BI.each(deleted, function (i, w) {
w.destroy(); w._destroy();
}) })
} else if (items.length > o.items.length) { } else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) { for (i = o.items.length; i < items.length; i++) {
@ -13037,7 +13043,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var child = this._children[cardName]; var child = this._children[cardName];
this._deleteCardByName(cardName); this._deleteCardByName(cardName);
child && child.destroy(); child && child._destroy();
}, },
addCardByName: function (cardName, cardItem) { addCardByName: function (cardName, cardItem) {
@ -16027,7 +16033,7 @@ BI.extend(jQuery.fn, {
if (!BI.isKey(keyword)) { if (!BI.isKey(keyword)) {
return this.text((text + "").replaceAll(" ", " ")); return this.text((text + "").replaceAll(" ", " "));
} }
keyword = BI.makeFirstPY(keyword + ""); keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var textLeft = (text || "") + ""; var textLeft = (text || "") + "";
py = (py || BI.makeFirstPY(text)) + ""; py = (py || BI.makeFirstPY(text)) + "";
@ -16618,7 +16624,7 @@ $(function () {
}; };
} }
var t, text, py; var t, text, py;
keyword = BI.makeFirstPY(keyword); keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {}; var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) { BI.each(items, function (i, item) {

66
docs/base.js

@ -2511,15 +2511,15 @@ BI.Canvas = BI.inherit(BI.Widget, {
} }
}); });
BI.shortcut("bi.canvas", BI.Canvas);/** BI.shortcut("bi.canvas", BI.Canvas);/**
* Collection * CollectionView
* *
* Created by GUY on 2016/1/15. * Created by GUY on 2016/1/15.
* @class BI.Collection * @class BI.CollectionView
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Collection = BI.inherit(BI.Widget, { BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () { _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", baseCls: "bi-collection",
width: 400, width: 400,
height: 300, height: 300,
@ -2535,7 +2535,7 @@ BI.Collection = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.Collection.superclass._init.apply(this, arguments); BI.CollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
@ -2554,7 +2554,7 @@ BI.Collection = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft(); o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.Collection.EVENT_SCROLL, { self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop
}); });
@ -2639,7 +2639,7 @@ BI.Collection = BI.inherit(BI.Widget, {
return; return;
} }
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
var renderedCells = [], renderedKeys = []; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
//存储所有的left和top //存储所有的left和top
var lefts = {}, tops = {}; var lefts = {}, tops = {};
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
@ -2722,6 +2722,7 @@ BI.Collection = BI.inherit(BI.Widget, {
} }
renderedKeys.push(datum.index); renderedKeys.push(datum.index);
renderedWidgets[i] = child;
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = []; var existSet = {}, addSet = {}, deleteArray = [];
@ -2742,13 +2743,17 @@ BI.Collection = BI.inherit(BI.Widget, {
deleteArray.push(i); deleteArray.push(i);
}); });
BI.each(deleteArray, function (i, index) { BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy(); //性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
}); });
var addedItems = []; var addedItems = [];
BI.each(addSet, function (index) { BI.each(addSet, function (index) {
addedItems.push(renderedCells[index]) addedItems.push(renderedCells[index])
}); });
this.container.addItems(addedItems); this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
@ -2859,8 +2864,8 @@ BI.Collection = BI.inherit(BI.Widget, {
this._populate(); this._populate();
} }
}); });
BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.Collection);/** BI.shortcut('bi.collection_view', BI.CollectionView);/**
* @class BI.Combo * @class BI.Combo
* @extends BI.Widget * @extends BI.Widget
*/ */
@ -14646,15 +14651,15 @@ $.extend(BI, {
}; };
}() }()
});/** });/**
* Grid * GridView
* *
* Created by GUY on 2016/1/11. * Created by GUY on 2016/1/11.
* @class BI.Grid * @class BI.GridView
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Grid = BI.inherit(BI.Widget, { BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () { _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", baseCls: "bi-grid-view",
width: 400, width: 400,
height: 300, height: 300,
@ -14673,7 +14678,7 @@ BI.Grid = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.Grid.superclass._init.apply(this, arguments); BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
@ -14692,7 +14697,7 @@ BI.Grid = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft(); o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.Grid.EVENT_SCROLL, { self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop
}); });
@ -14768,7 +14773,7 @@ BI.Grid = BI.inherit(BI.Widget, {
return; return;
} }
var renderedCells = [], renderedKeys = []; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -14819,6 +14824,7 @@ BI.Grid = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key); renderedKeys.push(key);
renderedWidgets[i] = child;
} }
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
@ -14840,13 +14846,17 @@ BI.Grid = BI.inherit(BI.Widget, {
deleteArray.push(i); deleteArray.push(i);
}); });
BI.each(deleteArray, function (i, index) { BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy(); //性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
}); });
var addedItems = []; var addedItems = [];
BI.each(addSet, function (index) { BI.each(addSet, function (index) {
addedItems.push(renderedCells[index]) addedItems.push(renderedCells[index])
}); });
this.container.addItems(addedItems); this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
@ -14965,8 +14975,8 @@ BI.Grid = BI.inherit(BI.Widget, {
this._populate(); this._populate();
} }
}); });
BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.Grid);/** BI.shortcut('bi.grid_view', BI.GridView);/**
* floatBox弹出层 * floatBox弹出层
* @class BI.FloatBox * @class BI.FloatBox
* @extends BI.Widget * @extends BI.Widget
@ -28603,7 +28613,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topLeftItems[index]; 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.bottomLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28614,7 +28624,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topRightItems[index]; 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.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -28625,7 +28635,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomLeftItems[index]; 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.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -28637,7 +28647,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomRightItems[index]; 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.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft); self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -29386,7 +29396,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter, 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.bottomLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29396,7 +29406,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter, 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.bottomRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -29406,7 +29416,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter, 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.bottomRightGrid.setScrollTop(scroll.scrollTop);
self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self.topLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -29417,7 +29427,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter, 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.bottomLeftGrid.setScrollTop(scroll.scrollTop);
self.topRightGrid.setScrollLeft(scroll.scrollLeft); self.topRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();

54
docs/core.js

@ -14492,17 +14492,6 @@ BI.Widget = BI.inherit(BI.OB, {
_mountChildren: null, _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 () { isMounted: function () {
return this._isMounted; return this._isMounted;
}, },
@ -14582,7 +14571,7 @@ BI.Widget = BI.inherit(BI.OB, {
}, },
getWidgetByName: function (name) { getWidgetByName: function (name) {
if (!BI.isKey(name) || name == this.getName()) { if (!BI.isKey(name) || name === this.getName()) {
return this; return this;
} }
name = name + ""; name = name + "";
@ -14682,6 +14671,21 @@ BI.Widget = BI.inherit(BI.OB, {
this.setVisible(true); 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 () { isolate: function () {
if (this._parent) { if (this._parent) {
this._parent.removeWidget(this); this._parent.removeWidget(this);
@ -14697,13 +14701,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.element.empty(); this.element.empty();
}, },
_destroy: function () {
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.purgeListeners();
},
destroy: function () { destroy: function () {
BI.each(this._children, function (i, widget) { this.__d();
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this.element.destroy(); this.element.destroy();
this.fireEvent(BI.Events.DESTROY); this.fireEvent(BI.Events.DESTROY);
@ -19581,7 +19587,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = newItems; this.options.items = newItems;
this._children = newChildren; this._children = newChildren;
BI.each(deleted, function (i, c) { BI.each(deleted, function (i, c) {
c.destroy(); c._destroy();
}); });
}, },
@ -19606,7 +19612,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} else { } else {
w.element.prependTo(this._getWrapper()); w.element.prependTo(this._getWrapper());
} }
del.destroy(); del._destroy();
w._mount(); w._mount();
}, },
@ -19693,7 +19699,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
o.items.splice(items.length); o.items.splice(items.length);
BI.each(deleted, function (i, w) { BI.each(deleted, function (i, w) {
w.destroy(); w._destroy();
}) })
} else if (items.length > o.items.length) { } else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) { for (i = o.items.length; i < items.length; i++) {
@ -22050,7 +22056,7 @@ BI.extend(jQuery.fn, {
if (!BI.isKey(keyword)) { if (!BI.isKey(keyword)) {
return this.text((text + "").replaceAll(" ", " ")); return this.text((text + "").replaceAll(" ", " "));
} }
keyword = BI.makeFirstPY(keyword + ""); keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var textLeft = (text || "") + ""; var textLeft = (text || "") + "";
py = (py || BI.makeFirstPY(text)) + ""; py = (py || BI.makeFirstPY(text)) + "";
@ -22641,7 +22647,7 @@ $(function () {
}; };
} }
var t, text, py; var t, text, py;
keyword = BI.makeFirstPY(keyword); keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {}; var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) { BI.each(items, function (i, item) {
@ -26551,7 +26557,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var child = this._children[cardName]; var child = this._children[cardName];
this._deleteCardByName(cardName); this._deleteCardByName(cardName);
child && child.destroy(); child && child._destroy();
}, },
addCardByName: function (cardName, cardItem) { addCardByName: function (cardName, cardItem) {

25
src/base/collection/collection.js

@ -1,13 +1,13 @@
/** /**
* Collection * CollectionView
* *
* Created by GUY on 2016/1/15. * Created by GUY on 2016/1/15.
* @class BI.Collection * @class BI.CollectionView
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Collection = BI.inherit(BI.Widget, { BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () { _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", baseCls: "bi-collection",
width: 400, width: 400,
height: 300, height: 300,
@ -23,7 +23,7 @@ BI.Collection = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.Collection.superclass._init.apply(this, arguments); BI.CollectionView.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
@ -42,7 +42,7 @@ BI.Collection = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft(); o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.Collection.EVENT_SCROLL, { self.fireEvent(BI.CollectionView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop
}); });
@ -127,7 +127,7 @@ BI.Collection = BI.inherit(BI.Widget, {
return; return;
} }
var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top); var childrenToDisplay = this._cellRenderers(bottom - top, right - left, left, top);
var renderedCells = [], renderedKeys = []; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
//存储所有的left和top //存储所有的left和top
var lefts = {}, tops = {}; var lefts = {}, tops = {};
for (var i = 0, len = childrenToDisplay.length; i < len; i++) { for (var i = 0, len = childrenToDisplay.length; i < len; i++) {
@ -210,6 +210,7 @@ BI.Collection = BI.inherit(BI.Widget, {
} }
renderedKeys.push(datum.index); renderedKeys.push(datum.index);
renderedWidgets[i] = child;
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
var existSet = {}, addSet = {}, deleteArray = []; var existSet = {}, addSet = {}, deleteArray = [];
@ -230,13 +231,17 @@ BI.Collection = BI.inherit(BI.Widget, {
deleteArray.push(i); deleteArray.push(i);
}); });
BI.each(deleteArray, function (i, index) { BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy(); //性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
}); });
var addedItems = []; var addedItems = [];
BI.each(addSet, function (index) { BI.each(addSet, function (index) {
addedItems.push(renderedCells[index]) addedItems.push(renderedCells[index])
}); });
this.container.addItems(addedItems); this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
@ -347,5 +352,5 @@ BI.Collection = BI.inherit(BI.Widget, {
this._populate(); this._populate();
} }
}); });
BI.Collection.EVENT_SCROLL = "EVENT_SCROLL"; BI.CollectionView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.collection_view', BI.Collection); BI.shortcut('bi.collection_view', BI.CollectionView);

25
src/base/grid/grid.js

@ -1,13 +1,13 @@
/** /**
* Grid * GridView
* *
* Created by GUY on 2016/1/11. * Created by GUY on 2016/1/11.
* @class BI.Grid * @class BI.GridView
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.Grid = BI.inherit(BI.Widget, { BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () { _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", baseCls: "bi-grid-view",
width: 400, width: 400,
height: 300, height: 300,
@ -26,7 +26,7 @@ BI.Grid = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.Grid.superclass._init.apply(this, arguments); BI.GridView.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.renderedCells = []; this.renderedCells = [];
this.renderedKeys = []; this.renderedKeys = [];
@ -45,7 +45,7 @@ BI.Grid = BI.inherit(BI.Widget, {
o.scrollLeft = self.element.scrollLeft(); o.scrollLeft = self.element.scrollLeft();
o.scrollTop = self.element.scrollTop(); o.scrollTop = self.element.scrollTop();
self._calculateChildrenToRender(); self._calculateChildrenToRender();
self.fireEvent(BI.Grid.EVENT_SCROLL, { self.fireEvent(BI.GridView.EVENT_SCROLL, {
scrollLeft: o.scrollLeft, scrollLeft: o.scrollLeft,
scrollTop: o.scrollTop scrollTop: o.scrollTop
}); });
@ -121,7 +121,7 @@ BI.Grid = BI.inherit(BI.Widget, {
return; return;
} }
var renderedCells = [], renderedKeys = []; var renderedCells = [], renderedKeys = [], renderedWidgets = {};
var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0; var minX = this._getMaxScrollLeft(), minY = this._getMaxScrollTop(), maxX = 0, maxY = 0;
for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) { for (var rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {
var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex); var rowDatum = this._rowSizeAndPositionManager.getSizeAndPositionOfCell(rowIndex);
@ -172,6 +172,7 @@ BI.Grid = BI.inherit(BI.Widget, {
minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment); minY = Math.min(minY, rowDatum.offset + verticalOffsetAdjustment);
maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size); maxY = Math.max(maxY, rowDatum.offset + verticalOffsetAdjustment + rowDatum.size);
renderedKeys.push(key); renderedKeys.push(key);
renderedWidgets[i] = child;
} }
} }
//已存在的, 需要添加的和需要删除的 //已存在的, 需要添加的和需要删除的
@ -193,13 +194,17 @@ BI.Grid = BI.inherit(BI.Widget, {
deleteArray.push(i); deleteArray.push(i);
}); });
BI.each(deleteArray, function (i, index) { BI.each(deleteArray, function (i, index) {
self.renderedCells[index].el.destroy(); //性能优化,不调用destroy方法防止触发destroy事件
self.renderedCells[index].el._destroy();
}); });
var addedItems = []; var addedItems = [];
BI.each(addSet, function (index) { BI.each(addSet, function (index) {
addedItems.push(renderedCells[index]) addedItems.push(renderedCells[index])
}); });
this.container.addItems(addedItems); this.container.addItems(addedItems);
//拦截父子级关系
this.container._children = renderedWidgets;
this.container.attr("items", renderedCells);
this.renderedCells = renderedCells; this.renderedCells = renderedCells;
this.renderedKeys = renderedKeys; this.renderedKeys = renderedKeys;
this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY}; this.renderRange = {minX: minX, minY: minY, maxX: maxX, maxY: maxY};
@ -318,5 +323,5 @@ BI.Grid = BI.inherit(BI.Widget, {
this._populate(); this._populate();
} }
}); });
BI.Grid.EVENT_SCROLL = "EVENT_SCROLL"; BI.GridView.EVENT_SCROLL = "EVENT_SCROLL";
BI.shortcut('bi.grid_view', BI.Grid); BI.shortcut('bi.grid_view', BI.GridView);

8
src/base/table/table.collection.js

@ -34,7 +34,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topLeftItems[index]; 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.bottomLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -45,7 +45,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.topRightItems[index]; 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.bottomRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -56,7 +56,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomLeftItems[index]; 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.bottomRightCollection.setScrollTop(scroll.scrollTop);
self.topLeftCollection.setScrollLeft(scroll.scrollLeft); self.topLeftCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -68,7 +68,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, {
return self.bottomRightItems[index]; 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.bottomLeftCollection.setScrollTop(scroll.scrollTop);
self.topRightCollection.setScrollLeft(scroll.scrollLeft); self.topRightCollection.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();

8
src/base/table/table.grid.js

@ -39,7 +39,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter, 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.bottomLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -49,7 +49,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter, 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.bottomRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments);
@ -59,7 +59,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnLeftWidthGetter, 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.bottomRightGrid.setScrollTop(scroll.scrollTop);
self.topLeftGrid.setScrollLeft(scroll.scrollLeft); self.topLeftGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();
@ -70,7 +70,7 @@ BI.GridTable = BI.inherit(BI.Widget, {
rowHeightGetter: rowHeightGetter, rowHeightGetter: rowHeightGetter,
columnWidthGetter: columnRightWidthGetter, 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.bottomLeftGrid.setScrollTop(scroll.scrollTop);
self.topRightGrid.setScrollLeft(scroll.scrollLeft); self.topRightGrid.setScrollLeft(scroll.scrollLeft);
self._populateScrollbar(); self._populateScrollbar();

2
src/core/func/dom.js

@ -22,7 +22,7 @@ BI.extend(jQuery.fn, {
if (!BI.isKey(keyword)) { if (!BI.isKey(keyword)) {
return this.text((text + "").replaceAll(" ", " ")); return this.text((text + "").replaceAll(" ", " "));
} }
keyword = BI.makeFirstPY(keyword + ""); keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var textLeft = (text || "") + ""; var textLeft = (text || "") + "";
py = (py || BI.makeFirstPY(text)) + ""; py = (py || BI.makeFirstPY(text)) + "";

2
src/core/func/function.js

@ -24,7 +24,7 @@ $(function () {
}; };
} }
var t, text, py; var t, text, py;
keyword = BI.makeFirstPY(keyword); keyword = keyword + "";
keyword = BI.toUpperCase(keyword); keyword = BI.toUpperCase(keyword);
var matched = isArray ? [] : {}, finded = isArray ? [] : {}; var matched = isArray ? [] : {}, finded = isArray ? [] : {};
BI.each(items, function (i, item) { BI.each(items, function (i, item) {

42
src/core/widget.js

@ -170,17 +170,6 @@ BI.Widget = BI.inherit(BI.OB, {
_mountChildren: null, _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 () { isMounted: function () {
return this._isMounted; return this._isMounted;
}, },
@ -260,7 +249,7 @@ BI.Widget = BI.inherit(BI.OB, {
}, },
getWidgetByName: function (name) { getWidgetByName: function (name) {
if (!BI.isKey(name) || name == this.getName()) { if (!BI.isKey(name) || name === this.getName()) {
return this; return this;
} }
name = name + ""; name = name + "";
@ -360,6 +349,21 @@ BI.Widget = BI.inherit(BI.OB, {
this.setVisible(true); 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 () { isolate: function () {
if (this._parent) { if (this._parent) {
this._parent.removeWidget(this); this._parent.removeWidget(this);
@ -375,13 +379,15 @@ BI.Widget = BI.inherit(BI.OB, {
this.element.empty(); this.element.empty();
}, },
_destroy: function () {
this.__d();
this.destroyed && this.destroyed();
this.element.destroy();
this.purgeListeners();
},
destroy: function () { destroy: function () {
BI.each(this._children, function (i, widget) { this.__d();
widget._unMount && widget._unMount();
});
this._children = {};
this._parent = null;
this._isMounted = false;
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this.element.destroy(); this.element.destroy();
this.fireEvent(BI.Events.DESTROY); this.fireEvent(BI.Events.DESTROY);

6
src/core/wrapper/layout.js

@ -252,7 +252,7 @@ BI.Layout = BI.inherit(BI.Widget, {
this.options.items = newItems; this.options.items = newItems;
this._children = newChildren; this._children = newChildren;
BI.each(deleted, function (i, c) { BI.each(deleted, function (i, c) {
c.destroy(); c._destroy();
}); });
}, },
@ -277,7 +277,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} else { } else {
w.element.prependTo(this._getWrapper()); w.element.prependTo(this._getWrapper());
} }
del.destroy(); del._destroy();
w._mount(); w._mount();
}, },
@ -364,7 +364,7 @@ BI.Layout = BI.inherit(BI.Widget, {
} }
o.items.splice(items.length); o.items.splice(items.length);
BI.each(deleted, function (i, w) { BI.each(deleted, function (i, w) {
w.destroy(); w._destroy();
}) })
} else if (items.length > o.items.length) { } else if (items.length > o.items.length) {
for (i = o.items.length; i < items.length; i++) { for (i = o.items.length; i < items.length; i++) {

2
src/core/wrapper/layout/layout.card.js

@ -91,7 +91,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
var child = this._children[cardName]; var child = this._children[cardName];
this._deleteCardByName(cardName); this._deleteCardByName(cardName);
child && child.destroy(); child && child._destroy();
}, },
addCardByName: function (cardName, cardItem) { addCardByName: function (cardName, cardItem) {

Loading…
Cancel
Save