From 828d4b04fcdea047f396210eb65961c1905b012f Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Mar 2017 18:09:47 +0800 Subject: [PATCH] add --- demo.html | 2 -- dist/base.js | 11 ++++++++--- dist/core.js | 16 ++++++++-------- src/base/combination/tab.js | 10 +++++++--- src/base/single/bar/bar.loading.js | 1 + src/core/controller/controller.layer.js | 1 + src/core/widget.js | 5 +++-- src/core/wrapper/layout/layout.card.js | 10 ++++------ 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/demo.html b/demo.html index ffc2d3dfb..b58f30610 100644 --- a/demo.html +++ b/demo.html @@ -22,7 +22,5 @@
- \ No newline at end of file diff --git a/dist/base.js b/dist/base.js index bbb5ca2a2..23d126675 100644 --- a/dist/base.js +++ b/dist/base.js @@ -24962,9 +24962,6 @@ BI.Tab = BI.inherit(BI.Widget, { listener.on(BI.ShowListener.EVENT_CHANGE, function (value) { self.fireEvent(BI.Tab.EVENT_CHANGE, value, self); }); - if (o.defaultShowIndex !== false) { - this.setSelect(o.defaultShowIndex); - } }, _assertCard: function (v) { @@ -24975,6 +24972,13 @@ BI.Tab = BI.inherit(BI.Widget, { } }, + mounted: function () { + var o = this.options; + if (o.defaultShowIndex !== false) { + this.setSelect(o.defaultShowIndex); + } + }, + setSelect: function (v) { this.tab && this.tab.setValue(v); this._assertCard(v); @@ -36274,6 +36278,7 @@ BI.LoadingBar = BI.inherit(BI.Single, { this.loading = BI.createWidget({ type: "bi.layout", + width: this.options.height, height:this.options.height, cls: "loading-background cursor-default" }) diff --git a/dist/core.js b/dist/core.js index fc0061fc5..a3529c3a3 100644 --- a/dist/core.js +++ b/dist/core.js @@ -14434,7 +14434,7 @@ BI.Widget = BI.inherit(BI.OB, { }) }) } - if (this._isRoot === true) { + if (this._isRoot === true || (!(this instanceof BI.Layout) && (this._parent && this._parent._isMounted))) { this._mount(); } }, @@ -14446,7 +14446,7 @@ BI.Widget = BI.inherit(BI.OB, { _mount: function () { var self = this; var isMounted = this._isMounted; - if (isMounted) { + if (isMounted || !this.isVisible()) { return; } if (this._isRoot === true) { @@ -14515,6 +14515,7 @@ BI.Widget = BI.inherit(BI.OB, { if (visible === true) { this.options.invisible = false; this.element.show(); + this._mount(); } else if (visible === false) { this.options.invisible = true; this.element.hide(); @@ -20831,6 +20832,7 @@ BI.LayerController = BI.inherit(BI.Controller, { return this; } this._getLayout(name).visible(); + this._getLayout(name)._mount(); this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__"); return this; }, @@ -26629,7 +26631,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { return widget; }, - showCardByName: function (name, action, callback) { + showCardByName: function (name, action) { var self = this; //name不存在的时候全部隐藏 var exist = this.hasWidget(this._getCardName(name)); @@ -26641,12 +26643,9 @@ BI.CardLayout = BI.inherit(BI.Layout, { BI.each(this._children, function (i, el) { if (self._getCardName(name) != i) { //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 - !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.element.hide(); + !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.element.show(0, function () { - el._mount(); - callback && callback(); - }); + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), el._mount()) } }); }, @@ -26659,6 +26658,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { el.element.hide(); } else { el.element.show(); + el._mount(); } }) }, diff --git a/src/base/combination/tab.js b/src/base/combination/tab.js index f12d3a150..68fe75c1a 100644 --- a/src/base/combination/tab.js +++ b/src/base/combination/tab.js @@ -53,9 +53,6 @@ BI.Tab = BI.inherit(BI.Widget, { listener.on(BI.ShowListener.EVENT_CHANGE, function (value) { self.fireEvent(BI.Tab.EVENT_CHANGE, value, self); }); - if (o.defaultShowIndex !== false) { - this.setSelect(o.defaultShowIndex); - } }, _assertCard: function (v) { @@ -66,6 +63,13 @@ BI.Tab = BI.inherit(BI.Widget, { } }, + mounted: function () { + var o = this.options; + if (o.defaultShowIndex !== false) { + this.setSelect(o.defaultShowIndex); + } + }, + setSelect: function (v) { this.tab && this.tab.setValue(v); this._assertCard(v); diff --git a/src/base/single/bar/bar.loading.js b/src/base/single/bar/bar.loading.js index a02c8665e..ae88b834e 100644 --- a/src/base/single/bar/bar.loading.js +++ b/src/base/single/bar/bar.loading.js @@ -32,6 +32,7 @@ BI.LoadingBar = BI.inherit(BI.Single, { this.loading = BI.createWidget({ type: "bi.layout", + width: this.options.height, height:this.options.height, cls: "loading-background cursor-default" }) diff --git a/src/core/controller/controller.layer.js b/src/core/controller/controller.layer.js index ae798aca9..c1625653c 100644 --- a/src/core/controller/controller.layer.js +++ b/src/core/controller/controller.layer.js @@ -127,6 +127,7 @@ BI.LayerController = BI.inherit(BI.Controller, { return this; } this._getLayout(name).visible(); + this._getLayout(name)._mount(); this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__"); return this; }, diff --git a/src/core/widget.js b/src/core/widget.js index 54de57d74..859e21e1e 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -135,7 +135,7 @@ BI.Widget = BI.inherit(BI.OB, { }) }) } - if (this._isRoot === true) { + if (this._isRoot === true || (!(this instanceof BI.Layout) && (this._parent && this._parent._isMounted))) { this._mount(); } }, @@ -147,7 +147,7 @@ BI.Widget = BI.inherit(BI.OB, { _mount: function () { var self = this; var isMounted = this._isMounted; - if (isMounted) { + if (isMounted || !this.isVisible()) { return; } if (this._isRoot === true) { @@ -216,6 +216,7 @@ BI.Widget = BI.inherit(BI.OB, { if (visible === true) { this.options.invisible = false; this.element.show(); + this._mount(); } else if (visible === false) { this.options.invisible = true; this.element.hide(); diff --git a/src/core/wrapper/layout/layout.card.js b/src/core/wrapper/layout/layout.card.js index 910866da1..aa9db36c3 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, callback) { + showCardByName: function (name, action) { var self = this; //name不存在的时候全部隐藏 var exist = this.hasWidget(this._getCardName(name)); @@ -98,12 +98,9 @@ BI.CardLayout = BI.inherit(BI.Layout, { BI.each(this._children, function (i, el) { if (self._getCardName(name) != i) { //动画效果只有在全部都隐藏的时候才有意义,且只要执行一次动画操作就够了 - !flag && !exist && (BI.Action && action instanceof BI.Action) ? (action.actionBack(el), flag = true) : el.element.hide(); + !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.element.show(0, function () { - el._mount(); - callback && callback(); - }); + (BI.Action && action instanceof BI.Action) ? action.actionPerformed(void 0, el, callback) : (el.visible(), el._mount()) } }); }, @@ -116,6 +113,7 @@ BI.CardLayout = BI.inherit(BI.Layout, { el.element.hide(); } else { el.element.show(); + el._mount(); } }) },