Browse Source

Pull request #1500: 无JIRA任务 bugfix

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

* commit '79cfe94244f98500ea3dfe176f9c73b9afd50b55':
  bugfix
es6
guy 4 years ago
parent
commit
f7d5a80821
  1. 88
      src/core/controller/controller.bubbles.js

88
src/core/controller/controller.bubbles.js

@ -17,14 +17,16 @@ BI.BubblesController = BI.inherit(BI.Controller, {
_init: function () { _init: function () {
BI.BubblesController.superclass._init.apply(this, arguments); BI.BubblesController.superclass._init.apply(this, arguments);
var self = this; var self = this;
this.fixedBubblesManager = {};
this.fixedStoreBubbles = {};
this.bubblesManager = {}; this.bubblesManager = {};
this.storeBubbles = {}; this.storeBubbles = {};
BI.Resizers.add("bubbleController" + BI.uniqueId(), function () { BI.Resizers.add("bubbleController" + BI.uniqueId(), function () {
BI.each(self.bubblesManager, function (name) { BI.each(self.fixedBubblesManager, function (name) {
self.remove(name); self.remove(name);
}); });
self.bubblesManager = {}; self.fixedBubblesManager = {};
self.storeBubbles = {}; self.fixedStoreBubbles = {};
}); });
}, },
@ -115,23 +117,22 @@ BI.BubblesController = BI.inherit(BI.Controller, {
var adjustYOffset = opt.adjustYOffset || 0; var adjustYOffset = opt.adjustYOffset || 0;
var adjustXOffset = opt.adjustXOffset || 0; var adjustXOffset = opt.adjustXOffset || 0;
var fixed = opt.fixed !== false; var fixed = opt.fixed !== false;
if (!this.storeBubbles[name]) {
this.storeBubbles[name] = {};
}
if (!this.storeBubbles[name]["top"]) {
this.storeBubbles[name]["top"] = this._createBubble("top", text, level, null, fixed);
}
BI.createWidget({
type: "bi.absolute",
element: container,
items: [{
el: this.storeBubbles[name]["top"]
}]
});
this.set(name, this.storeBubbles[name]["top"]);
// 如果是非固定位置(fixed)的bubble // 如果是非固定位置(fixed)的bubble
if (fixed === false) { if (fixed === false) {
if (!this.storeBubbles[name]) {
this.storeBubbles[name] = {};
}
if (!this.storeBubbles[name]["top"]) {
this.storeBubbles[name]["top"] = this._createBubble("top", text, level, null, fixed);
}
BI.createWidget({
type: "bi.absolute",
element: container,
items: [{
el: this.storeBubbles[name]["top"]
}]
});
this.set(name, this.storeBubbles[name]["top"]);
var bubble = this.storeBubbles[name]["top"]; var bubble = this.storeBubbles[name]["top"];
var bounds = bubble.element.bounds(); var bounds = bubble.element.bounds();
if (BI.DOM.isTopSpaceEnough(context, this.get(name), adjustYOffset)) { if (BI.DOM.isTopSpaceEnough(context, this.get(name), adjustYOffset)) {
@ -180,36 +181,50 @@ BI.BubblesController = BI.inherit(BI.Controller, {
} }
} }
} else { } else {
if (!this.fixedStoreBubbles[name]) {
this.fixedStoreBubbles[name] = {};
}
if (!this.fixedStoreBubbles[name]["top"]) {
this.fixedStoreBubbles[name]["top"] = this._createBubble("top", text, level, null, fixed);
}
BI.createWidget({
type: "bi.absolute",
element: container,
items: [{
el: this.fixedStoreBubbles[name]["top"]
}]
});
this.set(name, this.fixedStoreBubbles[name]["top"]);
var position = this._getTopPosition(name, context, offsetStyle); var position = this._getTopPosition(name, context, offsetStyle);
this.get(name).element.css({left: position.left + adjustXOffset, top: position.top - adjustYOffset}); this.get(name).element.css({left: position.left + adjustXOffset, top: position.top - adjustYOffset});
if (!BI.DOM.isTopSpaceEnough(context, this.get(name), adjustYOffset)) { if (!BI.DOM.isTopSpaceEnough(context, this.get(name), adjustYOffset)) {
this.get(name).invisible(); this.get(name).invisible();
if (!this.storeBubbles[name]["bottom"]) { if (!this.fixedStoreBubbles[name]["bottom"]) {
this.storeBubbles[name]["bottom"] = this._createBubble("bottom", text, level); this.fixedStoreBubbles[name]["bottom"] = this._createBubble("bottom", text, level);
} }
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: container, element: container,
items: [{ items: [{
el: this.storeBubbles[name]["bottom"] el: this.fixedStoreBubbles[name]["bottom"]
}] }]
}); });
this.set(name, this.storeBubbles[name]["bottom"]); this.set(name, this.fixedStoreBubbles[name]["bottom"]);
var position = this._getBottomPosition(name, context, offsetStyle); var position = this._getBottomPosition(name, context, offsetStyle);
this.get(name).element.css({left: position.left + adjustXOffset, top: position.top + adjustYOffset}); this.get(name).element.css({left: position.left + adjustXOffset, top: position.top + adjustYOffset});
if (!BI.DOM.isBottomSpaceEnough(context, this.get(name), adjustYOffset)) { if (!BI.DOM.isBottomSpaceEnough(context, this.get(name), adjustYOffset)) {
this.get(name).invisible(); this.get(name).invisible();
if (!this.storeBubbles[name]["right"]) { if (!this.fixedStoreBubbles[name]["right"]) {
this.storeBubbles[name]["right"] = this._createBubble("right", text, level); this.fixedStoreBubbles[name]["right"] = this._createBubble("right", text, level);
} }
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: container, element: container,
items: [{ items: [{
el: this.storeBubbles[name]["right"] el: this.fixedStoreBubbles[name]["right"]
}] }]
}); });
this.set(name, this.storeBubbles[name]["right"]); this.set(name, this.fixedStoreBubbles[name]["right"]);
var position = this._getRightPosition(name, context, offsetStyle); var position = this._getRightPosition(name, context, offsetStyle);
this.get(name).element.css({ this.get(name).element.css({
left: position.left + adjustXOffset, left: position.left + adjustXOffset,
@ -217,17 +232,17 @@ BI.BubblesController = BI.inherit(BI.Controller, {
}); });
if (!BI.DOM.isRightSpaceEnough(context, this.get(name), adjustXOffset)) { if (!BI.DOM.isRightSpaceEnough(context, this.get(name), adjustXOffset)) {
this.get(name).invisible(); this.get(name).invisible();
if (!this.storeBubbles[name]["left"]) { if (!this.fixedStoreBubbles[name]["left"]) {
this.storeBubbles[name]["left"] = this._createBubble("left", text, level, 30); this.fixedStoreBubbles[name]["left"] = this._createBubble("left", text, level, 30);
} }
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: container, element: container,
items: [{ items: [{
el: this.storeBubbles[name]["left"] el: this.fixedStoreBubbles[name]["left"]
}] }]
}); });
this.set(name, this.storeBubbles[name]["left"]); this.set(name, this.fixedStoreBubbles[name]["left"]);
var position = this._getLeftPosition(name, context, offsetStyle); var position = this._getLeftPosition(name, context, offsetStyle);
this.get(name).element.css({ this.get(name).element.css({
left: position.left - adjustXOffset, left: position.left - adjustXOffset,
@ -259,21 +274,26 @@ BI.BubblesController = BI.inherit(BI.Controller, {
}, },
get: function (name) { get: function (name) {
return this.bubblesManager[name]; return this.fixedBubblesManager[name] || this.bubblesManager[name];
}, },
set: function (name, bubble) { set: function (name, bubble, fixed) {
this.bubblesManager[name] = bubble; fixed === false ? (this.bubblesManager[name] = bubble) : (this.fixedBubblesManager[name] = bubble);
}, },
has: function (name) { has: function (name) {
return this.bubblesManager[name] != null; return this.fixedBubblesManager[name] != null || this.bubblesManager[name] != null;
}, },
remove: function (name) { remove: function (name) {
if (!this.has(name)) { if (!this.has(name)) {
return this; return this;
} }
BI.each(this.fixedStoreBubbles[name], function (dir, bubble) {
bubble.destroy();
});
delete this.fixedStoreBubbles[name];
delete this.fixedBubblesManager[name];
BI.each(this.storeBubbles[name], function (dir, bubble) { BI.each(this.storeBubbles[name], function (dir, bubble) {
bubble.destroy(); bubble.destroy();
}); });

Loading…
Cancel
Save