From 102803a83ec7ea51b4e220cbb148e1335166284e Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 5 Aug 2021 12:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/controller/controller.bubbles.js | 8 ++ src/core/controller/controller.layer.js | 12 +-- src/core/controller/controller.popover.js | 106 ++++++++++++--------- src/core/controller/controller.tooltips.js | 61 +++++++----- 4 files changed, 108 insertions(+), 79 deletions(-) diff --git a/src/core/controller/controller.bubbles.js b/src/core/controller/controller.bubbles.js index 61e59bf8b..5c38994c8 100644 --- a/src/core/controller/controller.bubbles.js +++ b/src/core/controller/controller.bubbles.js @@ -83,5 +83,13 @@ BI.BubblesController = BI.inherit(BI.Controller, { this.storeBubbles[name].destroy(); delete this.storeBubbles[name]; return this; + }, + + removeAll: function () { + BI.each(this.storeBubbles, function (name, bubble) { + bubble.destroy(); + }); + this.storeBubbles = {}; + return this; } }); diff --git a/src/core/controller/controller.layer.js b/src/core/controller/controller.layer.js index d8bb9d2d0..98470c5a9 100644 --- a/src/core/controller/controller.layer.js +++ b/src/core/controller/controller.layer.js @@ -100,21 +100,21 @@ BI.LayerController = BI.inherit(BI.Controller, { return widget; }, - hide: function (name, callback) { + show: function (name, callback) { if (!this.has(name)) { return this; } - this._getLayout(name).invisible(); - this._getLayout(name).element.hide(0, callback); + this._getLayout(name).visible(); + this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__"); return this; }, - show: function (name, callback) { + hide: function (name, callback) { if (!this.has(name)) { return this; } - this._getLayout(name).visible(); - this._getLayout(name).element.css("z-index", this.zindex++).show(0, callback).trigger("__resize__"); + this._getLayout(name).invisible(); + this._getLayout(name).element.hide(0, callback); return this; }, diff --git a/src/core/controller/controller.popover.js b/src/core/controller/controller.popover.js index 8f53bd5ff..6c88a3e56 100644 --- a/src/core/controller/controller.popover.js +++ b/src/core/controller/controller.popover.js @@ -22,12 +22,8 @@ BI.PopoverController = BI.inherit(BI.Controller, { this.zindexMap = {}; }, - _check: function (name) { - return BI.isNotNull(this.floatManager[name]); - }, - create: function (name, options, context) { - if (this._check(name)) { + if (this.has(name)) { return this; } var popover = BI.createWidget(options || {}, { @@ -37,48 +33,8 @@ BI.PopoverController = BI.inherit(BI.Controller, { return this; }, - add: function (name, popover, options, context) { - var self = this; - options || (options = {}); - if (this._check(name)) { - return this; - } - this.floatContainer[name] = BI.createWidget({ - type: "bi.absolute", - cls: "bi-popup-view", - items: [{ - el: (this.floatLayer[name] = BI.createWidget({ - type: "bi.absolute", - items: [popover] - }, context)), - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.floatManager[name] = popover; - (function (key) { - popover.on(BI.Popover.EVENT_CLOSE, function () { - self.close(key); - }); - })(name); - BI.createWidget({ - type: "bi.absolute", - element: options.container || this.options.render, - items: [{ - el: this.floatContainer[name], - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - return this; - }, - open: function (name) { - if (!this._check(name)) { + if (!this.has(name)) { return this; } if (!this.floatOpened[name]) { @@ -110,7 +66,7 @@ BI.PopoverController = BI.inherit(BI.Controller, { }, close: function (name) { - if (!this._check(name)) { + if (!this.has(name)) { return this; } if (this.floatOpened[name]) { @@ -121,10 +77,66 @@ BI.PopoverController = BI.inherit(BI.Controller, { return this; }, + show: function (name) { + return this.open(name); + }, + + hide: function (name) { + return this.close(name); + }, + + isVisible: function (name) { + return this.has(name) && this.floatOpened[name] === true; + }, + + add: function (name, popover, options, context) { + var self = this; + options || (options = {}); + if (this.has(name)) { + return this; + } + this.floatContainer[name] = BI.createWidget({ + type: "bi.absolute", + cls: "bi-popup-view", + items: [{ + el: (this.floatLayer[name] = BI.createWidget({ + type: "bi.absolute", + items: [popover] + }, context)), + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + this.floatManager[name] = popover; + (function (key) { + popover.on(BI.Popover.EVENT_CLOSE, function () { + self.close(key); + }); + })(name); + BI.createWidget({ + type: "bi.absolute", + element: options.container || this.options.render, + items: [{ + el: this.floatContainer[name], + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + return this; + }, + get: function (name) { return this.floatManager[name]; }, + has: function (name) { + return BI.isNotNull(this.floatManager[name]); + }, + remove: function (name) { if (!this._check(name)) { return this; diff --git a/src/core/controller/controller.tooltips.js b/src/core/controller/controller.tooltips.js index a6722b560..5e4db152b 100644 --- a/src/core/controller/controller.tooltips.js +++ b/src/core/controller/controller.tooltips.js @@ -21,32 +21,6 @@ BI.TooltipsController = BI.inherit(BI.Controller, { }); }, - hide: function (name, callback) { - if (!this.has(name)) { - return this; - } - delete this.showingTips[name]; - this.get(name).element.hide(0, callback); - this.get(name).invisible(); - return this; - }, - - create: function (name, text, level, context) { - if (!this.has(name)) { - var tooltip = this._createTooltip(text, level); - this.add(name, tooltip); - BI.createWidget({ - type: "bi.absolute", - element: context || "body", - items: [{ - el: tooltip - }] - }); - tooltip.invisible(); - } - return this.get(name); - }, - // opt: {container: '', belowMouse: false} show: function (e, name, text, level, context, opt) { opt || (opt = {}); @@ -100,6 +74,32 @@ BI.TooltipsController = BI.inherit(BI.Controller, { return this; }, + hide: function (name, callback) { + if (!this.has(name)) { + return this; + } + delete this.showingTips[name]; + this.get(name).element.hide(0, callback); + this.get(name).invisible(); + return this; + }, + + create: function (name, text, level, context) { + if (!this.has(name)) { + var tooltip = this._createTooltip(text, level); + this.add(name, tooltip); + BI.createWidget({ + type: "bi.absolute", + element: context || "body", + items: [{ + el: tooltip + }] + }); + tooltip.invisible(); + } + return this.get(name); + }, + add: function (name, bubble) { if (this.has(name)) { return this; @@ -127,5 +127,14 @@ BI.TooltipsController = BI.inherit(BI.Controller, { this.tooltipsManager[name].destroy(); delete this.tooltipsManager[name]; return this; + }, + + removeAll: function () { + BI.each(this.tooltipsManager, function (name, tooltip) { + tooltip.destroy(); + }); + this.tooltipsManager = {}; + this.showingTips = {}; + return this; } });