diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index e0ad79943..ae287ca91 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -11,6 +11,9 @@ BI.CollectionView = BI.inherit(BI.Widget, { baseCls: "bi-collection", // width: 400, //必设 // height: 300, //必设 + scrollable: true, + scrollx: false, + scrolly: false, overflowX: true, overflowY: true, cellSizeAndPositionGetter: BI.emptyFn, @@ -49,14 +52,30 @@ BI.CollectionView = BI.inherit(BI.Widget, { scrollTop: o.scrollTop }); }); + // 兼容一下 + var scrollable = o.scrollable, scrollx = o.scrollx, scrolly = o.scrolly; + if (overflowX === false) { + if (overflowY === false) { + scrollable = false; + } else { + scrollable = "y" + } + } else { + if (overflowY === false) { + scrollable = "x"; + } + } BI._lazyCreateWidget({ type: "bi.vertical", element: this, - scrollable: o.overflowX === true && o.overflowY === true, - scrolly: o.overflowX === false && o.overflowY === true, - scrollx: o.overflowX === true && o.overflowY === false, + scrollable: scrollable, + scrolly: scrolly, + scrollx: scrollx, items: [this.container] }); + o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; if (o.items.length > 0) { this._calculateSizeAndPositionData(); this._populate(); diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 9f392411a..4df7b392e 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -21,7 +21,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { }, render: function () { - var o = this.options; + var self = this, o = this.options; var behaviors = {}; BI.each(o.behaviors, function (key, rule) { behaviors[key] = BI.BehaviorFactory.createBehavior(key, { @@ -29,7 +29,15 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { }); }); this.behaviors = behaviors; - this.populate(o.items); + var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; + this.populate(items); + if (BI.isFunction(o.value)) { + this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) + } if (BI.isKey(o.value) || BI.isNotEmptyArray(o.value)) { this.setValue(o.value); } diff --git a/src/base/combination/group.virtual.js b/src/base/combination/group.virtual.js index ab9b20c07..eb2b63b85 100644 --- a/src/base/combination/group.virtual.js +++ b/src/base/combination/group.virtual.js @@ -12,8 +12,16 @@ BI.VirtualGroup = BI.inherit(BI.Widget, { }, render: function () { - var o = this.options; - this.populate(o.items); + var self = this, o = this.options; + var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; + this.populate(items); + if (BI.isFunction(o.value)) { + this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) + } if (BI.isKey(o.value)) { this.setValue(o.value); } diff --git a/src/base/combination/loader.js b/src/base/combination/loader.js index a29ba45ce..a56e72708 100644 --- a/src/base/combination/loader.js +++ b/src/base/combination/loader.js @@ -109,8 +109,11 @@ BI.Loader = BI.inherit(BI.Widget, { o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () { o.isDefaultInit && BI.isEmpty(o.items) && this._populate(); }, this)); - if (BI.isNotEmptyArray(o.items)) { - this._populate(o.items); + var items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; + if (BI.isNotEmptyArray(items)) { + this._populate(items); } }, @@ -162,7 +165,6 @@ BI.Loader = BI.inherit(BI.Widget, { this.button_group.addItems.apply(this.button_group, arguments); }, - _populate: function (items) { var self = this, o = this.options; if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) { diff --git a/src/base/combination/navigation.js b/src/base/combination/navigation.js index 11b2e092d..b2d5ae867 100644 --- a/src/base/combination/navigation.js +++ b/src/base/combination/navigation.js @@ -50,6 +50,12 @@ BI.Navigation = BI.inherit(BI.Widget, { afterCardCreated: BI.bind(this.afterCardCreated, this), afterCardShow: BI.bind(this.afterCardShow, this) }); + + if (BI.isFunction(o.showIndex)) { + this.__watch(o.showIndex, function (context, newValue) { + self.setSelect(newValue); + }) + } }, created: function () { diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index 664b0c09a..0531d16c8 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -54,6 +54,12 @@ BI.Tab = BI.inherit(BI.Widget, { listener.on(BI.ShowListener.EVENT_CHANGE, function (value) { self.fireEvent(BI.Tab.EVENT_CHANGE, value, self); }); + + if (BI.isFunction(o.showIndex)) { + this.__watch(o.showIndex, function (context, newValue) { + self.setSelect(newValue); + }) + } }, _deleteOtherCards: function (currCardName) { diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 7052e0fbd..76a86ead8 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -11,6 +11,9 @@ BI.GridView = BI.inherit(BI.Widget, { baseCls: "bi-grid-view", // width: 400, //必设 // height: 300, //必设 + scrollable: true, + scrollx: false, + scrolly: false, overflowX: true, overflowY: true, overscanColumnCount: 0, @@ -52,14 +55,30 @@ BI.GridView = BI.inherit(BI.Widget, { scrollTop: o.scrollTop }); }); + // 兼容一下 + var scrollable = o.scrollable, scrollx = o.scrollx, scrolly = o.scrolly; + if (overflowX === false) { + if (overflowY === false) { + scrollable = false; + } else { + scrollable = "y" + } + } else { + if (overflowY === false) { + scrollable = "x"; + } + } BI._lazyCreateWidget({ type: "bi.vertical", element: this, - scrollable: o.overflowX === true && o.overflowY === true, - scrolly: o.overflowX === false && o.overflowY === true, - scrollx: o.overflowX === true && o.overflowY === false, + scrollable: scrollable, + scrolly: scrolly, + scrollx: scrollx, items: [this.container] }); + o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; if (o.items.length > 0) { this._calculateSizeAndPositionData(); this._populate(); diff --git a/src/base/list/listview.js b/src/base/list/listview.js index 3d936a028..052abc139 100644 --- a/src/base/list/listview.js +++ b/src/base/list/listview.js @@ -44,6 +44,9 @@ BI.ListView = BI.inherit(BI.Widget, { // mounted之后绑定事件 mounted: function () { var self = this, o = this.options; + o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; this._populate(); this.element.scroll(function (e) { o.scrollTop = self.element.scrollTop(); diff --git a/src/base/list/virtualgrouplist.js b/src/base/list/virtualgrouplist.js index 243f06fd8..c1aa416e5 100644 --- a/src/base/list/virtualgrouplist.js +++ b/src/base/list/virtualgrouplist.js @@ -57,6 +57,9 @@ BI.VirtualGroupList = BI.inherit(BI.Widget, { // mounted之后绑定事件 mounted: function () { var self = this, o = this.options; + o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; this._populate(); this.element.scroll(BI.debounce(function (e) { o.scrollTop = self.element.scrollTop(); diff --git a/src/base/list/virtuallist.js b/src/base/list/virtuallist.js index af61a6193..b7f2700c7 100644 --- a/src/base/list/virtuallist.js +++ b/src/base/list/virtuallist.js @@ -53,6 +53,9 @@ BI.VirtualList = BI.inherit(BI.Widget, { // mounted之后绑定事件 mounted: function () { var self = this, o = this.options; + o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { + self.populate(newValue); + }) : o.items; this._populate(); this.element.scroll(function (e) { o.scrollTop = self.element.scrollTop(); diff --git a/src/base/single/0.single.js b/src/base/single/0.single.js index 070935e24..a98736561 100644 --- a/src/base/single/0.single.js +++ b/src/base/single/0.single.js @@ -55,6 +55,9 @@ BI.Single = BI.inherit(BI.Widget, { container: o.container }); } + o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { + self.setValue(newValue); + }) : o.value; }, _clearTimeOut: function () { diff --git a/src/base/single/1.text.js b/src/base/single/1.text.js index 235a1a404..4a22bf531 100644 --- a/src/base/single/1.text.js +++ b/src/base/single/1.text.js @@ -78,8 +78,6 @@ var text = BI.isFunction(o.text) ? this.__watch(o.text, function (context, newValue) { self.setText(newValue); - }, { - deep: true }) : o.text; // 只要不是undefined就可以显示text值,否则显示value if (!BI.isUndefined(text)) { diff --git a/src/base/single/text.pure.js b/src/base/single/text.pure.js index eb7f6e323..7c4d93c0c 100644 --- a/src/base/single/text.pure.js +++ b/src/base/single/text.pure.js @@ -10,7 +10,9 @@ render: function () { var self = this, o = this.options; - var text = this._getShowText(); + var text = BI.isFunction(o.text) ? this.__watch(o.text, function (context, newValue) { + self.setText(newValue); + }) : o.text; if (BI.isKey(text)) { this.setText(text); } else if (BI.isKey(o.value)) { diff --git a/src/core/4.widget.js b/src/core/4.widget.js index 245a2491b..025447d68 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -224,8 +224,6 @@ } } self.element.css(css = newValue); - }, { - deep: true }); this.element.css(css); } else { @@ -242,7 +240,7 @@ return getter.call(self, self); }, (handler && function (v) { handler.call(self, self, v); - }) || BI.emptyFn, options); + }) || BI.emptyFn, BI.extend({deep: true}, options)); this._watchers.push(watcher); return watcher.value; } else { @@ -312,14 +310,10 @@ if (BI.isArray(o.effect)) { if (BI.isArray(o.effect[0])) { BI.each(o.effect, function (i, effect) { - self.__watch(effect[0], effect[1], { - deep: true - }); + self.__watch(effect[0], effect[1]); }); } else { - self.__watch(o.effect[0], o.effect[1], { - deep: true - }); + self.__watch(o.effect[0], o.effect[1]); } } else { this.__watch(o.effect); diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index c77145b73..e6ea4d58a 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -29,8 +29,6 @@ BI.Layout = BI.inherit(BI.Widget, { o.columnSize = this.__watch(columnSizeFn, function (context, newValue) { o.columnSize = newValue; self.resize(); - }, { - deep: true }); } if (BI.isFunction(o.rowSize)) { @@ -38,8 +36,6 @@ BI.Layout = BI.inherit(BI.Widget, { o.rowSize = this.__watch(rowSizeFn, function (context, newValue) { o.rowSize = newValue; self.resize(); - }, { - deep: true }); } },