Browse Source

context重构

es6
guy 4 years ago
parent
commit
dc66e666e6
  1. 2
      dist/fix/fix.compact.js
  2. 8
      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 () { function createStore () {
var needPop = false; var needPop = false;
if (_global.Fix && this._store) { 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) { if (store) {
pushTarget(store); pushTarget(store);
needPop = true; needPop = true;

8
src/base/collection/collection.js

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

6
src/base/grid/grid.js

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

7
src/core/shortcut.js

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

Loading…
Cancel
Save