Browse Source

context重构

es6
guy 4 years ago
parent
commit
dc66e666e6
  1. 2
      dist/fix/fix.compact.js
  2. 6
      src/base/collection/collection.js
  3. 6
      src/base/grid/grid.js
  4. 7
      src/core/shortcut.js

2
dist/fix/fix.compact.js vendored

@ -135,7 +135,7 @@
function createStore () {
var needPop = false;
if (_global.Fix && this._store) {
var store = findStore(this.options.context || this.options.element);
var store = findStore(this.options.context || this._parent || this.options.element || BI.Widget.context || this._context);
if (store) {
pushTarget(store);
needPop = true;

6
src/base/collection/collection.js

@ -32,7 +32,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this._debounceRelease = BI.debounce(function () {
self._scrollLock = false;
}, 1000 / 60);
this.container = BI.createWidget({
this.container = BI._lazyCreateWidget({
type: "bi.absolute"
});
this.element.scroll(function () {
@ -47,7 +47,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
scrollTop: o.scrollTop
});
});
BI.createWidget({
BI._lazyCreateWidget({
type: "bi.vertical",
element: this,
scrollable: o.overflowX === true && o.overflowY === true,
@ -176,7 +176,7 @@ BI.CollectionView = BI.inherit(BI.Widget, {
}
renderedCells.push(child = this.renderedCells[index]);
} else {
child = BI.createWidget(BI.extend({
child = BI._lazyCreateWidget(BI.extend({
type: "bi.label",
width: datum.width,
height: datum.height

6
src/base/grid/grid.js

@ -35,7 +35,7 @@ BI.GridView = BI.inherit(BI.Widget, {
this._debounceRelease = BI.debounce(function () {
self._scrollLock = false;
}, 1000 / 60);
this.container = BI.createWidget({
this.container = BI._lazyCreateWidget({
type: "bi.absolute"
});
this.element.scroll(function () {
@ -50,7 +50,7 @@ BI.GridView = BI.inherit(BI.Widget, {
scrollTop: o.scrollTop
});
});
BI.createWidget({
BI._lazyCreateWidget({
type: "bi.vertical",
element: this,
scrollable: o.overflowX === true && o.overflowY === true,
@ -153,7 +153,7 @@ BI.GridView = BI.inherit(BI.Widget, {
child = this.renderedCells[index].el;
renderedCells.push(this.renderedCells[index]);
} else {
child = BI.createWidget(BI.extend({
child = BI._lazyCreateWidget(BI.extend({
type: "bi.label",
width: columnDatum.size,
height: rowDatum.size

7
src/core/shortcut.js

@ -11,7 +11,7 @@
};
// 根据配置属性生成widget
var createWidget = function (config, lazy) {
var createWidget = function (config, context, lazy) {
var cls = kv[config.type];
if (!cls) {
@ -19,6 +19,7 @@
}
var widget = new cls();
widget._context = context;
BI.Widget.pushContext(widget);
widget._initProps(config);
widget._initRoot();
@ -57,7 +58,7 @@
BI.Plugin.getObject(el.type, this);
}
}]);
return w.type === el.type ? createWidget(w, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy);
return w.type === el.type ? createWidget(w, context, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy);
}
if (item.el && (item.el.type || options.type)) {
el = BI.extend({}, options, item.el);
@ -68,7 +69,7 @@
BI.Plugin.getObject(el.type, this);
}
}]);
return w.type === el.type ? createWidget(w, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy);
return w.type === el.type ? createWidget(w, context, lazy) : BI.createWidget(BI.extend({}, item, {type: w.type}), options, context, lazy);
}
if (BI.isWidget(item.el)) {
return item.el;

Loading…
Cancel
Save