From 9d7628fc0c057f64a557ac79de0b0c2867c1e545 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 12 Jun 2017 10:14:06 +0800 Subject: [PATCH] update --- bi/base.js | 4 +-- bi/core.js | 29 +++++++++++++++---- bi/widget.js | 8 ++--- docs/base.js | 4 +-- docs/core.js | 29 +++++++++++++++---- docs/widget.js | 8 ++--- src/core/controller/router.floatbox.js | 7 +++-- src/core/events.js | 6 ++++ src/core/view.js | 6 ++++ src/core/widget.js | 8 +++-- .../sequencetable/treenumber.sequencetable.js | 5 ++-- 11 files changed, 83 insertions(+), 31 deletions(-) diff --git a/bi/base.js b/bi/base.js index 34f5c5729..23c9a67c6 100644 --- a/bi/base.js +++ b/bi/base.js @@ -15079,9 +15079,9 @@ BI.FloatBox = BI.inherit(BI.Widget, { type: "bi.absolute", items: [{ el: this._center, - left: 20, + left: 10, top: 10, - right: 20, + right: 10, bottom: 10 }] } diff --git a/bi/core.js b/bi/core.js index 9c696303d..ece344eed 100644 --- a/bi/core.js +++ b/bi/core.js @@ -3184,7 +3184,7 @@ if (!window.BI) { if (numReg) { var num = numReg[0]; var orilen = num.length; - var newnum = BI.parseInt(num) + 1 + ''; + var newnum = parseInt(num) + 1 + ''; //进位到整数部分 if (newnum.length > orilen) { newnum = newnum.substr(1); @@ -3728,6 +3728,12 @@ _.extend(BI, { */ DESTROY: '_DESTROY', + /** + * @static + * @property 取消挂载事件 + */ + UNMOUNT: '_UNMOUNT', + /** * @static * @property 清除选择 @@ -4360,6 +4366,8 @@ BI.Widget = BI.inherit(BI.OB, { update: function () { }, + beforeDestroyed: null, + destroyed: null, _init: function () { @@ -4719,18 +4727,20 @@ BI.Widget = BI.inherit(BI.OB, { }, __d: function () { + this.beforeDestroyed && this.beforeDestroyed(); BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); this._children = {}; this._parent = null; this._isMounted = false; + this.destroyed && this.destroyed(); }, _unMount: function () { this.__d(); + this.fireEvent(BI.Events.UNMOUNT); this.purgeListeners(); - this.destroyed && this.destroyed(); }, isolate: function () { @@ -4750,14 +4760,12 @@ BI.Widget = BI.inherit(BI.OB, { _destroy: function () { this.__d(); - this.destroyed && this.destroyed(); this.element.destroy(); this.purgeListeners(); }, destroy: function () { this.__d(); - this.destroyed && this.destroyed(); this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); @@ -5253,6 +5261,8 @@ BI.View = BI.inherit(BI.V, { created: null, + beforeDestroyed: null, + destroyed: null, _init: function () { @@ -5742,18 +5752,22 @@ BI.View = BI.inherit(BI.V, { }, _unMount: function () { + this.beforeDestroyed && this.beforeDestroyed(); BI.each(this._cardLayouts, function (name, card) { card && card._unMount(); }); delete this._cardLayouts; delete this._cards; this.destroyed && this.destroyed(); + this.trigger(BI.Events.UNMOUNT); this.off(); }, _destroy: function () { + var self = this; BI.each(this._cardLayouts, function (name, card) { card && card._unMount(); + BI.Layers.remove(name + self.cid); }); delete this._cardLayouts; delete this._cards; @@ -15959,7 +15973,10 @@ BI.FloatBoxRouter = BI.inherit(BI.WRouter, { var view = this.createView(url, data, viewData, context); isValid && context.model.addChild(modelData, view.model); view.listenTo(view.model, "destroy", function () { - self.remove(url); + self.remove(url, context); + }); + context.on(BI.Events.UNMOUNT, function () { + self.remove(url, context); }); this.store[url].populate(view); this.views[url] = view; @@ -15998,7 +16015,7 @@ BI.FloatBoxRouter = BI.inherit(BI.WRouter, { remove: function (url, context) { url = context.rootURL + "/" + url; - if(this.controller){ + if (this.controller) { this.controller.remove(url); delete this.store[url]; this.views[url] && this.views[url].model.destroy(); diff --git a/bi/widget.js b/bi/widget.js index aab2005f3..05cbb17a1 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -103,12 +103,13 @@ BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { _getStart: function (nodes) { var self = this; var start = this.start; - BI.each(nodes, function (i, node) { + BI.some(nodes, function (i, node) { if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { + return BI.some(node.children, function (index, child) { if (index === 0) { if (self.cache[child.text || child.value]) { start = self.cache[child.text || child.value]; + return true; } } }); @@ -12681,8 +12682,7 @@ BI.NumericalInterval = BI.inherit(BI.Single, { }) }, - - isValid: function () { + isStateValid: function () { return this.options.validation === "valid"; }, diff --git a/docs/base.js b/docs/base.js index 34f5c5729..23c9a67c6 100644 --- a/docs/base.js +++ b/docs/base.js @@ -15079,9 +15079,9 @@ BI.FloatBox = BI.inherit(BI.Widget, { type: "bi.absolute", items: [{ el: this._center, - left: 20, + left: 10, top: 10, - right: 20, + right: 10, bottom: 10 }] } diff --git a/docs/core.js b/docs/core.js index 0136a2c07..be104363d 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14362,6 +14362,8 @@ BI.Widget = BI.inherit(BI.OB, { update: function () { }, + beforeDestroyed: null, + destroyed: null, _init: function () { @@ -14721,18 +14723,20 @@ BI.Widget = BI.inherit(BI.OB, { }, __d: function () { + this.beforeDestroyed && this.beforeDestroyed(); BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); this._children = {}; this._parent = null; this._isMounted = false; + this.destroyed && this.destroyed(); }, _unMount: function () { this.__d(); + this.fireEvent(BI.Events.UNMOUNT); this.purgeListeners(); - this.destroyed && this.destroyed(); }, isolate: function () { @@ -14752,14 +14756,12 @@ BI.Widget = BI.inherit(BI.OB, { _destroy: function () { this.__d(); - this.destroyed && this.destroyed(); this.element.destroy(); this.purgeListeners(); }, destroy: function () { this.__d(); - this.destroyed && this.destroyed(); this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); @@ -15255,6 +15257,8 @@ BI.View = BI.inherit(BI.V, { created: null, + beforeDestroyed: null, + destroyed: null, _init: function () { @@ -15744,18 +15748,22 @@ BI.View = BI.inherit(BI.V, { }, _unMount: function () { + this.beforeDestroyed && this.beforeDestroyed(); BI.each(this._cardLayouts, function (name, card) { card && card._unMount(); }); delete this._cardLayouts; delete this._cards; this.destroyed && this.destroyed(); + this.trigger(BI.Events.UNMOUNT); this.off(); }, _destroy: function () { + var self = this; BI.each(this._cardLayouts, function (name, card) { card && card._unMount(); + BI.Layers.remove(name + self.cid); }); delete this._cardLayouts; delete this._cards; @@ -20132,7 +20140,7 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { if (numReg) { var num = numReg[0]; var orilen = num.length; - var newnum = BI.parseInt(num) + 1 + ''; + var newnum = parseInt(num) + 1 + ''; //进位到整数部分 if (newnum.length > orilen) { newnum = newnum.substr(1); @@ -21552,7 +21560,10 @@ BI.FloatBoxRouter = BI.inherit(BI.WRouter, { var view = this.createView(url, data, viewData, context); isValid && context.model.addChild(modelData, view.model); view.listenTo(view.model, "destroy", function () { - self.remove(url); + self.remove(url, context); + }); + context.on(BI.Events.UNMOUNT, function () { + self.remove(url, context); }); this.store[url].populate(view); this.views[url] = view; @@ -21591,7 +21602,7 @@ BI.FloatBoxRouter = BI.inherit(BI.WRouter, { remove: function (url, context) { url = context.rootURL + "/" + url; - if(this.controller){ + if (this.controller) { this.controller.remove(url); delete this.store[url]; this.views[url] && this.views[url].model.destroy(); @@ -21758,6 +21769,12 @@ _.extend(BI, { */ DESTROY: '_DESTROY', + /** + * @static + * @property 取消挂载事件 + */ + UNMOUNT: '_UNMOUNT', + /** * @static * @property 清除选择 diff --git a/docs/widget.js b/docs/widget.js index aab2005f3..05cbb17a1 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -103,12 +103,13 @@ BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { _getStart: function (nodes) { var self = this; var start = this.start; - BI.each(nodes, function (i, node) { + BI.some(nodes, function (i, node) { if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { + return BI.some(node.children, function (index, child) { if (index === 0) { if (self.cache[child.text || child.value]) { start = self.cache[child.text || child.value]; + return true; } } }); @@ -12681,8 +12682,7 @@ BI.NumericalInterval = BI.inherit(BI.Single, { }) }, - - isValid: function () { + isStateValid: function () { return this.options.validation === "valid"; }, diff --git a/src/core/controller/router.floatbox.js b/src/core/controller/router.floatbox.js index 1076b0424..5707f34fc 100644 --- a/src/core/controller/router.floatbox.js +++ b/src/core/controller/router.floatbox.js @@ -45,7 +45,10 @@ BI.FloatBoxRouter = BI.inherit(BI.WRouter, { var view = this.createView(url, data, viewData, context); isValid && context.model.addChild(modelData, view.model); view.listenTo(view.model, "destroy", function () { - self.remove(url); + self.remove(url, context); + }); + context.on(BI.Events.UNMOUNT, function () { + self.remove(url, context); }); this.store[url].populate(view); this.views[url] = view; @@ -84,7 +87,7 @@ BI.FloatBoxRouter = BI.inherit(BI.WRouter, { remove: function (url, context) { url = context.rootURL + "/" + url; - if(this.controller){ + if (this.controller) { this.controller.remove(url); delete this.store[url]; this.views[url] && this.views[url].model.destroy(); diff --git a/src/core/events.js b/src/core/events.js index 91d0aa1a9..cbaf9f4af 100644 --- a/src/core/events.js +++ b/src/core/events.js @@ -53,6 +53,12 @@ _.extend(BI, { */ DESTROY: '_DESTROY', + /** + * @static + * @property 取消挂载事件 + */ + UNMOUNT: '_UNMOUNT', + /** * @static * @property 清除选择 diff --git a/src/core/view.js b/src/core/view.js index 5912819cd..21e9efb2e 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -10,6 +10,8 @@ BI.View = BI.inherit(BI.V, { created: null, + beforeDestroyed: null, + destroyed: null, _init: function () { @@ -499,18 +501,22 @@ BI.View = BI.inherit(BI.V, { }, _unMount: function () { + this.beforeDestroyed && this.beforeDestroyed(); BI.each(this._cardLayouts, function (name, card) { card && card._unMount(); }); delete this._cardLayouts; delete this._cards; this.destroyed && this.destroyed(); + this.trigger(BI.Events.UNMOUNT); this.off(); }, _destroy: function () { + var self = this; BI.each(this._cardLayouts, function (name, card) { card && card._unMount(); + BI.Layers.remove(name + self.cid); }); delete this._cardLayouts; delete this._cards; diff --git a/src/core/widget.js b/src/core/widget.js index cd4ae58be..62775547e 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -37,6 +37,8 @@ BI.Widget = BI.inherit(BI.OB, { update: function () { }, + beforeDestroyed: null, + destroyed: null, _init: function () { @@ -396,18 +398,20 @@ BI.Widget = BI.inherit(BI.OB, { }, __d: function () { + this.beforeDestroyed && this.beforeDestroyed(); BI.each(this._children, function (i, widget) { widget._unMount && widget._unMount(); }); this._children = {}; this._parent = null; this._isMounted = false; + this.destroyed && this.destroyed(); }, _unMount: function () { this.__d(); + this.fireEvent(BI.Events.UNMOUNT); this.purgeListeners(); - this.destroyed && this.destroyed(); }, isolate: function () { @@ -427,14 +431,12 @@ BI.Widget = BI.inherit(BI.OB, { _destroy: function () { this.__d(); - this.destroyed && this.destroyed(); this.element.destroy(); this.purgeListeners(); }, destroy: function () { this.__d(); - this.destroyed && this.destroyed(); this.element.destroy(); this.fireEvent(BI.Events.DESTROY); this.purgeListeners(); diff --git a/src/widget/sequencetable/treenumber.sequencetable.js b/src/widget/sequencetable/treenumber.sequencetable.js index 6a1fff133..057a5e6c2 100644 --- a/src/widget/sequencetable/treenumber.sequencetable.js +++ b/src/widget/sequencetable/treenumber.sequencetable.js @@ -103,12 +103,13 @@ BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { _getStart: function (nodes) { var self = this; var start = this.start; - BI.each(nodes, function (i, node) { + BI.some(nodes, function (i, node) { if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { + return BI.some(node.children, function (index, child) { if (index === 0) { if (self.cache[child.text || child.value]) { start = self.cache[child.text || child.value]; + return true; } } });