diff --git a/dist/base.js b/dist/base.js index 23d126675..9eebd0e85 100644 --- a/dist/base.js +++ b/dist/base.js @@ -21353,8 +21353,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { return; } - var items = this._packageItems(items, this._packageBtns(btns)); - BI.createWidget(BI.extend(this._packageLayout(items))).element.children().prependTo(this.element); + items = this._packageItems(items, this._packageBtns(btns)); + this.layouts.prependItems(this._packageLayout(items).items); }, addItems: function (items) { @@ -21369,8 +21369,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { return; } - var items = this._packageItems(items, this._packageBtns(btns)); - BI.createWidget(BI.extend(this._packageLayout(items))).element.children().appendTo(this.element); + items = this._packageItems(items, this._packageBtns(btns)); + this.layouts.addItems(this._packageLayout(items).items); }, removeItemAt: function (indexes) { diff --git a/dist/core.js b/dist/core.js index 41fda0c12..d86dd053a 100644 --- a/dist/core.js +++ b/dist/core.js @@ -19363,6 +19363,14 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + w._mount(); + this.options.items.unshift(item); + w.element.prependTo(this.element); + return w; + }, + addItems: function (items) { var self = this; BI.each(items, function (i, item) { @@ -19370,6 +19378,13 @@ BI.Layout = BI.inherit(BI.Widget, { }) }, + prependItems: function (items) { + var self = this; + BI.each(items, function (i, item) { + self.prependItem(item); + }) + }, + getValue: function () { var value = []; BI.each(this._children, function (i, wi) { @@ -26630,7 +26645,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { return widget; }, - showCardByName: function (name, action) { + showCardByName: function (name, action, callback) { var self = this; //name不存在的时候全部隐藏 var exist = this.hasWidget(this._getCardName(name)); @@ -26644,7 +26659,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); } else { - (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), el._mount()) + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) } }); }, @@ -26653,12 +26668,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var self = this; this.showIndex = this.lastShowIndex; BI.each(this._children, function (i, el) { - if (self.showIndex != i) { - el.element.hide(); - } else { - el.element.show(); - el._mount(); - } + el.setVisible(self.showIndex == i); }) }, diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index a1f36155e..b6ef3be0b 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -126,8 +126,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { return; } - var items = this._packageItems(items, this._packageBtns(btns)); - BI.createWidget(BI.extend(this._packageLayout(items))).element.children().prependTo(this.element); + items = this._packageItems(items, this._packageBtns(btns)); + this.layouts.prependItems(this._packageLayout(items).items); }, addItems: function (items) { @@ -142,8 +142,8 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { return; } - var items = this._packageItems(items, this._packageBtns(btns)); - BI.createWidget(BI.extend(this._packageLayout(items))).element.children().appendTo(this.element); + items = this._packageItems(items, this._packageBtns(btns)); + this.layouts.addItems(this._packageLayout(items).items); }, removeItemAt: function (indexes) { diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 76b9db127..5c19c92b5 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -106,6 +106,14 @@ BI.Layout = BI.inherit(BI.Widget, { return w; }, + prependItem: function (item) { + var w = this._addElement(this.options.items.length, item); + w._mount(); + this.options.items.unshift(item); + w.element.prependTo(this.element); + return w; + }, + addItems: function (items) { var self = this; BI.each(items, function (i, item) { @@ -113,6 +121,13 @@ BI.Layout = BI.inherit(BI.Widget, { }) }, + prependItems: function (items) { + var self = this; + BI.each(items, function (i, item) { + self.prependItem(item); + }) + }, + getValue: function () { var value = []; BI.each(this._children, function (i, wi) { diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index aa9db36c3..08869e4ab 100644 --- a/src/core/wrapper/layout/layout.card.js +++ b/src/core/wrapper/layout/layout.card.js @@ -86,7 +86,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { return widget; }, - showCardByName: function (name, action) { + showCardByName: function (name, action, callback) { var self = this; //name不存在的时候全部隐藏 var exist = this.hasWidget(this._getCardName(name)); @@ -100,7 +100,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.invisible(); } else { - (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), el._mount()) + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), callback && callback()) } }); }, @@ -109,12 +109,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { var self = this; this.showIndex = this.lastShowIndex; BI.each(this._children, function (i, el) { - if (self.showIndex != i) { - el.element.hide(); - } else { - el.element.show(); - el._mount(); - } + el.setVisible(self.showIndex == i); }) },