|
|
@ -12,17 +12,25 @@ BI.TooltipsController = BI.inherit(BI.Controller, { |
|
|
|
this.showingTips = {};// 存储正在显示的tooltip
|
|
|
|
this.showingTips = {};// 存储正在显示的tooltip
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_createTooltip: function (text, level) { |
|
|
|
/** |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param opt |
|
|
|
|
|
|
|
* @param opt.text {String} 文本 |
|
|
|
|
|
|
|
* @param opt.level {String} 级别, success或warning |
|
|
|
|
|
|
|
* @param opt.textAlign {String} 文本对齐方式, left, center, right |
|
|
|
|
|
|
|
* @returns {*} |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_createTooltip: function (opt) { |
|
|
|
return BI.createWidget({ |
|
|
|
return BI.createWidget({ |
|
|
|
type: "bi.tooltip", |
|
|
|
type: "bi.tooltip", |
|
|
|
text: text, |
|
|
|
...opt, |
|
|
|
level: level, |
|
|
|
|
|
|
|
stopEvent: true |
|
|
|
stopEvent: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// opt: {container: '', belowMouse: false}
|
|
|
|
// opt: {container: '', belowMouse: false}
|
|
|
|
show: function (e, name, text, level, context, opt) { |
|
|
|
show: function (e, name, tooltipOpt, context, opt) { |
|
|
|
opt || (opt = {}); |
|
|
|
opt || (opt = {}); |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
BI.each(this.showingTips, function (i, tip) { |
|
|
|
BI.each(this.showingTips, function (i, tip) { |
|
|
@ -30,7 +38,7 @@ BI.TooltipsController = BI.inherit(BI.Controller, { |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.showingTips = {}; |
|
|
|
this.showingTips = {}; |
|
|
|
if (!this.has(name)) { |
|
|
|
if (!this.has(name)) { |
|
|
|
this.create(name, text, level, opt.container || "body"); |
|
|
|
this.create(name, tooltipOpt, opt.container || "body"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!opt.belowMouse) { |
|
|
|
if (!opt.belowMouse) { |
|
|
|
var offset = context.element.offset(); |
|
|
|
var offset = context.element.offset(); |
|
|
@ -41,7 +49,6 @@ BI.TooltipsController = BI.inherit(BI.Controller, { |
|
|
|
var top = offset.top + bounds.height + 5; |
|
|
|
var top = offset.top + bounds.height + 5; |
|
|
|
} |
|
|
|
} |
|
|
|
var tooltip = this.get(name); |
|
|
|
var tooltip = this.get(name); |
|
|
|
tooltip.setText(text); |
|
|
|
|
|
|
|
tooltip.element.css({ |
|
|
|
tooltip.element.css({ |
|
|
|
left: "0px", |
|
|
|
left: "0px", |
|
|
|
top: "0px" |
|
|
|
top: "0px" |
|
|
@ -84,9 +91,9 @@ BI.TooltipsController = BI.inherit(BI.Controller, { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
create: function (name, text, level, context) { |
|
|
|
create: function (name, tooltipOpt, context) { |
|
|
|
if (!this.has(name)) { |
|
|
|
if (!this.has(name)) { |
|
|
|
var tooltip = this._createTooltip(text, level); |
|
|
|
var tooltip = this._createTooltip(tooltipOpt); |
|
|
|
this.add(name, tooltip); |
|
|
|
this.add(name, tooltip); |
|
|
|
BI.createWidget({ |
|
|
|
BI.createWidget({ |
|
|
|
type: "bi.absolute", |
|
|
|
type: "bi.absolute", |
|
|
|