From 8f9c70f5428141526fc3b2f4eaf4d38b6d76e70e Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 31 Mar 2017 12:59:45 +0800 Subject: [PATCH] add --- bi/core.js | 14 ++++++++++---- dist/core.js | 14 ++++++++++---- src/core/alias.js | 4 ++-- src/core/controller/controller.broadcast.js | 5 ++++- src/core/controller/controller.resizer.js | 5 ++++- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/bi/core.js b/bi/core.js index 05d821f9b..e47cc4482 100644 --- a/bi/core.js +++ b/bi/core.js @@ -3198,9 +3198,9 @@ if (!window.BI) { var numMod = format.indexOf(';'); if (numMod > -1) { if (text >= 0) { - return BI._numberFormat(text + "", format.substring(0, numMod)); + return _numberFormat(text + "", format.substring(0, numMod)); } else { - return BI._numberFormat((-text) + "", format.substr(numMod + 1)); + return _numberFormat((-text) + "", format.substr(numMod + 1)); } } var tp = text.split('.'), fp = format.split('.'), @@ -15368,7 +15368,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { } this._broadcasts[name].push(fn); return function () { - self._broadcasts[name].remove(fn); + self.remove(name, fn); } }, @@ -15382,6 +15382,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { this._broadcasts[name].remove(fn); + if (this._broadcasts[name].length === 0) { + delete this._broadcasts[name]; + } } else { delete this._broadcasts[name]; } @@ -15968,11 +15971,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { }, add: function (name, resizer) { + var self = this; if (this.has(name)) { return this; } this.resizerManger[name] = resizer; - return this; + return function () { + self.remove(name); + }; }, get: function (name) { diff --git a/dist/core.js b/dist/core.js index ee87da960..9c8a9f4bf 100644 --- a/dist/core.js +++ b/dist/core.js @@ -19876,9 +19876,9 @@ BI.PopoverSection.EVENT_CLOSE = "EVENT_CLOSE";;(function () { var numMod = format.indexOf(';'); if (numMod > -1) { if (text >= 0) { - return BI._numberFormat(text + "", format.substring(0, numMod)); + return _numberFormat(text + "", format.substring(0, numMod)); } else { - return BI._numberFormat((-text) + "", format.substr(numMod + 1)); + return _numberFormat((-text) + "", format.substr(numMod + 1)); } } var tp = text.split('.'), fp = format.split('.'), @@ -20441,7 +20441,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { } this._broadcasts[name].push(fn); return function () { - self._broadcasts[name].remove(fn); + self.remove(name, fn); } }, @@ -20455,6 +20455,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { this._broadcasts[name].remove(fn); + if (this._broadcasts[name].length === 0) { + delete this._broadcasts[name]; + } } else { delete this._broadcasts[name]; } @@ -21041,11 +21044,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { }, add: function (name, resizer) { + var self = this; if (this.has(name)) { return this; } this.resizerManger[name] = resizer; - return this; + return function () { + self.remove(name); + }; }, get: function (name) { diff --git a/src/core/alias.js b/src/core/alias.js index d86d76af8..0abe30e40 100644 --- a/src/core/alias.js +++ b/src/core/alias.js @@ -186,9 +186,9 @@ var numMod = format.indexOf(';'); if (numMod > -1) { if (text >= 0) { - return BI._numberFormat(text + "", format.substring(0, numMod)); + return _numberFormat(text + "", format.substring(0, numMod)); } else { - return BI._numberFormat((-text) + "", format.substr(numMod + 1)); + return _numberFormat((-text) + "", format.substr(numMod + 1)); } } var tp = text.split('.'), fp = format.split('.'), diff --git a/src/core/controller/controller.broadcast.js b/src/core/controller/controller.broadcast.js index 7b7c43984..202f2432e 100644 --- a/src/core/controller/controller.broadcast.js +++ b/src/core/controller/controller.broadcast.js @@ -21,7 +21,7 @@ BI.BroadcastController = BI.inherit(BI.Controller, { } this._broadcasts[name].push(fn); return function () { - self._broadcasts[name].remove(fn); + self.remove(name, fn); } }, @@ -35,6 +35,9 @@ BI.BroadcastController = BI.inherit(BI.Controller, { remove: function (name, fn) { if (fn) { this._broadcasts[name].remove(fn); + if (this._broadcasts[name].length === 0) { + delete this._broadcasts[name]; + } } else { delete this._broadcasts[name]; } diff --git a/src/core/controller/controller.resizer.js b/src/core/controller/controller.resizer.js index 04ad57869..d45b13bc9 100644 --- a/src/core/controller/controller.resizer.js +++ b/src/core/controller/controller.resizer.js @@ -41,11 +41,14 @@ BI.ResizeController = BI.inherit(BI.Controller, { }, add: function (name, resizer) { + var self = this; if (this.has(name)) { return this; } this.resizerManger[name] = resizer; - return this; + return function () { + self.remove(name); + }; }, get: function (name) {