|
|
|
@ -19,8 +19,8 @@ BI.Single = BI.inherit(BI.Widget, {
|
|
|
|
|
return BI.extend(conf, { |
|
|
|
|
readonly: false, |
|
|
|
|
title: null, |
|
|
|
|
warningTitle: null, |
|
|
|
|
tipType: null, // success或warning
|
|
|
|
|
warningTitle: null, // deprecated
|
|
|
|
|
tipType: null, // deprecated success或warning
|
|
|
|
|
belowMouse: false, // title是否跟随鼠标
|
|
|
|
|
enableHover: false, |
|
|
|
|
}); |
|
|
|
@ -28,26 +28,26 @@ BI.Single = BI.inherit(BI.Widget, {
|
|
|
|
|
|
|
|
|
|
_showToolTip: function (e, opt) { |
|
|
|
|
opt || (opt = {}); |
|
|
|
|
var self = this; |
|
|
|
|
var o = this.options; |
|
|
|
|
var tooltipOpt = {}; |
|
|
|
|
var title = this.getTitle(); |
|
|
|
|
if (BI.isPlainObject(title)) { |
|
|
|
|
tooltipOpt = title; |
|
|
|
|
} else { |
|
|
|
|
tooltipOpt.level = this.getTipType() || "success"; |
|
|
|
|
// 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况
|
|
|
|
|
if (BI.isNull(o.tipType) && !this.isEnabled()) { |
|
|
|
|
tooltipOpt.text = (this.getWarningTitle() || title); |
|
|
|
|
|
|
|
|
|
if (title instanceof Promise) { |
|
|
|
|
title.then(resolvedTitle => { |
|
|
|
|
this.mouseOver && showToolTip(this._getTooltipOptions(resolvedTitle)); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); |
|
|
|
|
showToolTip(this._getTooltipOptions(title)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (BI.isKey(tooltipOpt.text)) { |
|
|
|
|
BI.Tooltips.show(e, this.getName(), tooltipOpt, this, opt); |
|
|
|
|
|
|
|
|
|
function showToolTip(tooltipOpt) { |
|
|
|
|
if (BI.isKey(tooltipOpt.text) && !BI.Tooltips.has(self.getName())) { |
|
|
|
|
BI.Tooltips.show(e, self.getName(), tooltipOpt, self, opt); |
|
|
|
|
if (o.action) { |
|
|
|
|
BI.Actions.runAction(o.action, "hover", o, this); |
|
|
|
|
BI.Actions.runAction(o.action, "hover", o, self); |
|
|
|
|
} |
|
|
|
|
BI.Actions.runGlobalAction("hover", o, self); |
|
|
|
|
} |
|
|
|
|
BI.Actions.runGlobalAction("hover", o, this); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -91,12 +91,30 @@ BI.Single = BI.inherit(BI.Widget, {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_getTooltipOptions: function (title) { |
|
|
|
|
var o = this.options; |
|
|
|
|
var tooltipOpt = {}; |
|
|
|
|
if (BI.isPlainObject(title)) { |
|
|
|
|
tooltipOpt = title; |
|
|
|
|
} else { |
|
|
|
|
tooltipOpt.level = this.getTipType() || "success"; |
|
|
|
|
// 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况
|
|
|
|
|
if (BI.isNull(o.tipType) && !this.isEnabled()) { |
|
|
|
|
tooltipOpt.text = (this.getWarningTitle() || title); |
|
|
|
|
} else { |
|
|
|
|
tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return tooltipOpt; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
enableHover: function (opt) { |
|
|
|
|
opt || (opt = {}); |
|
|
|
|
var self = this; |
|
|
|
|
if (!this._hoverBinded) { |
|
|
|
|
this.element.unbind("mouseenter.title").on("mouseenter.title", function (e) { |
|
|
|
|
self._e = e; |
|
|
|
|
self.mouseOver = true; |
|
|
|
|
if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { |
|
|
|
|
delayingTooltips = self.getName(); |
|
|
|
|
self.showTimeout = BI.delay(function () { |
|
|
|
@ -144,6 +162,7 @@ BI.Single = BI.inherit(BI.Widget, {
|
|
|
|
|
}); |
|
|
|
|
this.element.unbind("mouseleave.title").on("mouseleave.title", function (e) { |
|
|
|
|
self._e = null; |
|
|
|
|
self.mouseOver = false; |
|
|
|
|
self._clearTimeOut(); |
|
|
|
|
self._hideTooltip(); |
|
|
|
|
}); |
|
|
|
|