Browse Source

Pull request #2083: 无JIRA任务 整理代码

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit '102803a83ec7ea51b4e220cbb148e1335166284e':
  整理代码
es6
guy 3 years ago
parent
commit
3e4c2b0b7d
  1. 8
      src/core/controller/controller.bubbles.js
  2. 12
      src/core/controller/controller.layer.js
  3. 106
      src/core/controller/controller.popover.js
  4. 61
      src/core/controller/controller.tooltips.js

8
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;
}
});

12
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;
},

106
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;

61
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;
}
});

Loading…
Cancel
Save