|
|
@ -5,12 +5,12 @@ |
|
|
|
* 2、title的控制 |
|
|
|
* 2、title的控制 |
|
|
|
* 3、文字超过边界显示3个点 |
|
|
|
* 3、文字超过边界显示3个点 |
|
|
|
* 4、cursor默认pointor |
|
|
|
* 4、cursor默认pointor |
|
|
|
* @class BI.Single |
|
|
|
* @class Single |
|
|
|
* @extends BI.Widget |
|
|
|
* @extends Widget |
|
|
|
* @abstract |
|
|
|
* @abstract |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import { Widget, shortcut } from "../../core"; |
|
|
|
import { Widget, shortcut, Actions, extend, isKey, isNotNull, isFunction, isPlainObject, isNull, delay } from "../../core"; |
|
|
|
import { Tooltips } from "../0.base"; |
|
|
|
import { Tooltips } from "../0.base"; |
|
|
|
|
|
|
|
|
|
|
|
@shortcut() |
|
|
|
@shortcut() |
|
|
@ -18,9 +18,9 @@ export class Single extends Widget { |
|
|
|
static xtype = "bi.single"; |
|
|
|
static xtype = "bi.single"; |
|
|
|
|
|
|
|
|
|
|
|
_defaultConfig() { |
|
|
|
_defaultConfig() { |
|
|
|
const conf = super._defaultConfig(arguments); |
|
|
|
const conf = super._defaultConfig(...arguments); |
|
|
|
|
|
|
|
|
|
|
|
return BI.extend(conf, { |
|
|
|
return extend(conf, { |
|
|
|
readonly: false, |
|
|
|
readonly: false, |
|
|
|
title: null, |
|
|
|
title: null, |
|
|
|
warningTitle: null, // deprecated
|
|
|
|
warningTitle: null, // deprecated
|
|
|
@ -36,12 +36,12 @@ export class Single extends Widget { |
|
|
|
const title = this.getTitle(); |
|
|
|
const title = this.getTitle(); |
|
|
|
|
|
|
|
|
|
|
|
const showToolTip = (tooltipOpt) => { |
|
|
|
const showToolTip = (tooltipOpt) => { |
|
|
|
if (BI.isKey(tooltipOpt.text) && !Tooltips.has(this.getName())) { |
|
|
|
if (isKey(tooltipOpt.text) && !Tooltips.has(this.getName())) { |
|
|
|
Tooltips.show(e, this.getName(), tooltipOpt, this, opt); |
|
|
|
Tooltips.show(e, this.getName(), tooltipOpt, this, opt); |
|
|
|
if (action) { |
|
|
|
if (action) { |
|
|
|
BI.Actions.runAction(action, "hover", this.options, this); |
|
|
|
Actions.runAction(action, "hover", this.options, this); |
|
|
|
} |
|
|
|
} |
|
|
|
BI.Actions.runGlobalAction("hover", this.options, this); |
|
|
|
Actions.runGlobalAction("hover", this.options, this); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ export class Single extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
_hideTooltip() { |
|
|
|
_hideTooltip() { |
|
|
|
const tooltip = Tooltips.get(this.getName()); |
|
|
|
const tooltip = Tooltips.get(this.getName()); |
|
|
|
if (BI.isNotNull(tooltip)) { |
|
|
|
if (isNotNull(tooltip)) { |
|
|
|
tooltip.element.fadeOut(200, () => { |
|
|
|
tooltip.element.fadeOut(200, () => { |
|
|
|
Tooltips.remove(this.getName()); |
|
|
|
Tooltips.remove(this.getName()); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -68,7 +68,7 @@ export class Single extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
_init() { |
|
|
|
_init() { |
|
|
|
const { value } = this.options; |
|
|
|
const { value } = this.options; |
|
|
|
this.options.value = BI.isFunction(value) ? this.__watch(value, (context, newValue) => { |
|
|
|
this.options.value = isFunction(value) ? this.__watch(value, (context, newValue) => { |
|
|
|
this.setValue(newValue); |
|
|
|
this.setValue(newValue); |
|
|
|
}) : value; |
|
|
|
}) : value; |
|
|
|
super._init(arguments); |
|
|
|
super._init(arguments); |
|
|
@ -76,8 +76,8 @@ export class Single extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
_mounted() { |
|
|
|
_mounted() { |
|
|
|
const { enableHover, title, warningTitle, belowMouse, container } = this.options; |
|
|
|
const { enableHover, title, warningTitle, belowMouse, container } = this.options; |
|
|
|
if (enableHover || BI.isKey(title) || BI.isKey(warningTitle) |
|
|
|
if (enableHover || isKey(title) || isKey(warningTitle) |
|
|
|
|| BI.isFunction(title) || BI.isFunction(warningTitle)) { |
|
|
|
|| isFunction(title) || isFunction(warningTitle)) { |
|
|
|
this.enableHover({ |
|
|
|
this.enableHover({ |
|
|
|
belowMouse, |
|
|
|
belowMouse, |
|
|
|
container, |
|
|
|
container, |
|
|
@ -86,11 +86,11 @@ export class Single extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_clearTimeOut() { |
|
|
|
_clearTimeOut() { |
|
|
|
if (BI.isNotNull(this.showTimeout)) { |
|
|
|
if (isNotNull(this.showTimeout)) { |
|
|
|
clearTimeout(this.showTimeout); |
|
|
|
clearTimeout(this.showTimeout); |
|
|
|
this.showTimeout = null; |
|
|
|
this.showTimeout = null; |
|
|
|
} |
|
|
|
} |
|
|
|
if (BI.isNotNull(this.hideTimeout)) { |
|
|
|
if (isNotNull(this.hideTimeout)) { |
|
|
|
clearTimeout(this.hideTimeout); |
|
|
|
clearTimeout(this.hideTimeout); |
|
|
|
this.hideTimeout = null; |
|
|
|
this.hideTimeout = null; |
|
|
|
} |
|
|
|
} |
|
|
@ -99,12 +99,12 @@ export class Single extends Widget { |
|
|
|
_getTooltipOptions(title) { |
|
|
|
_getTooltipOptions(title) { |
|
|
|
const { tipType } = this.options; |
|
|
|
const { tipType } = this.options; |
|
|
|
let tooltipOpt = {}; |
|
|
|
let tooltipOpt = {}; |
|
|
|
if (BI.isPlainObject(title)) { |
|
|
|
if (isPlainObject(title)) { |
|
|
|
tooltipOpt = title; |
|
|
|
tooltipOpt = title; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tooltipOpt.level = this.getTipType() || "success"; |
|
|
|
tooltipOpt.level = this.getTipType() || "success"; |
|
|
|
// 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况
|
|
|
|
// 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况
|
|
|
|
if (BI.isNull(tipType) && !this.isEnabled()) { |
|
|
|
if (isNull(tipType) && !this.isEnabled()) { |
|
|
|
tooltipOpt.text = (this.getWarningTitle() || title); |
|
|
|
tooltipOpt.text = (this.getWarningTitle() || title); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); |
|
|
|
tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title); |
|
|
@ -120,17 +120,17 @@ export class Single extends Widget { |
|
|
|
this.element.unbind("mouseenter.title").on("mouseenter.title", (e) => { |
|
|
|
this.element.unbind("mouseenter.title").on("mouseenter.title", (e) => { |
|
|
|
this._e = e; |
|
|
|
this._e = e; |
|
|
|
this.mouseOver = true; |
|
|
|
this.mouseOver = true; |
|
|
|
if (this.getTipType() === "warning" || (BI.isKey(this.getWarningTitle()) && !this.isEnabled())) { |
|
|
|
if (this.getTipType() === "warning" || (isKey(this.getWarningTitle()) && !this.isEnabled())) { |
|
|
|
delayingTooltips = this.getName(); |
|
|
|
delayingTooltips = this.getName(); |
|
|
|
this.showTimeout = BI.delay(() => { |
|
|
|
this.showTimeout = delay(() => { |
|
|
|
if (BI.isNotNull(this.showTimeout) && delayingTooltips === this.getName()) { |
|
|
|
if (isNotNull(this.showTimeout) && delayingTooltips === this.getName()) { |
|
|
|
this._showToolTip(this._e || e, opt); |
|
|
|
this._showToolTip(this._e || e, opt); |
|
|
|
} |
|
|
|
} |
|
|
|
}, 200); |
|
|
|
}, 200); |
|
|
|
} else if (this.getTipType() === "success" || this.isEnabled()) { |
|
|
|
} else if (this.getTipType() === "success" || this.isEnabled()) { |
|
|
|
delayingTooltips = this.getName(); |
|
|
|
delayingTooltips = this.getName(); |
|
|
|
this.showTimeout = BI.delay(() => { |
|
|
|
this.showTimeout = delay(() => { |
|
|
|
if (BI.isNotNull(this.showTimeout) && delayingTooltips === this.getName()) { |
|
|
|
if (isNotNull(this.showTimeout) && delayingTooltips === this.getName()) { |
|
|
|
this._showToolTip(this._e || e, opt); |
|
|
|
this._showToolTip(this._e || e, opt); |
|
|
|
} |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, 500); |
|
|
@ -138,22 +138,22 @@ export class Single extends Widget { |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.element.unbind("mousemove.title").on("mousemove.title", (e) => { |
|
|
|
this.element.unbind("mousemove.title").on("mousemove.title", (e) => { |
|
|
|
this._e = e; |
|
|
|
this._e = e; |
|
|
|
if (BI.isNotNull(this.showTimeout)) { |
|
|
|
if (isNotNull(this.showTimeout)) { |
|
|
|
clearTimeout(this.showTimeout); |
|
|
|
clearTimeout(this.showTimeout); |
|
|
|
this.showTimeout = null; |
|
|
|
this.showTimeout = null; |
|
|
|
} |
|
|
|
} |
|
|
|
if (BI.isNull(this.hideTimeout)) { |
|
|
|
if (isNull(this.hideTimeout)) { |
|
|
|
this.hideTimeout = BI.delay(() => { |
|
|
|
this.hideTimeout = delay(() => { |
|
|
|
if (BI.isNotNull(this.hideTimeout)) { |
|
|
|
if (isNotNull(this.hideTimeout)) { |
|
|
|
this._hideTooltip(); |
|
|
|
this._hideTooltip(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, 500); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.showTimeout = BI.delay(() => { |
|
|
|
this.showTimeout = delay(() => { |
|
|
|
// DEC-5321 IE下如果回调已经进入事件队列,clearTimeout将不会起作用
|
|
|
|
// DEC-5321 IE下如果回调已经进入事件队列,clearTimeout将不会起作用
|
|
|
|
if (BI.isNotNull(this.showTimeout)) { |
|
|
|
if (isNotNull(this.showTimeout)) { |
|
|
|
if (BI.isNotNull(this.hideTimeout)) { |
|
|
|
if (isNotNull(this.hideTimeout)) { |
|
|
|
clearTimeout(this.hideTimeout); |
|
|
|
clearTimeout(this.hideTimeout); |
|
|
|
this.hideTimeout = null; |
|
|
|
this.hideTimeout = null; |
|
|
|
} |
|
|
|
} |
|
|
@ -188,7 +188,7 @@ export class Single extends Widget { |
|
|
|
// opt: {container: '', belowMouse: false}
|
|
|
|
// opt: {container: '', belowMouse: false}
|
|
|
|
setTitle(title, opt) { |
|
|
|
setTitle(title, opt) { |
|
|
|
this.options.title = title; |
|
|
|
this.options.title = title; |
|
|
|
if (BI.isKey(title) || BI.isFunction(title)) { |
|
|
|
if (isKey(title) || isFunction(title)) { |
|
|
|
this.enableHover(opt); |
|
|
|
this.enableHover(opt); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.disabledHover(); |
|
|
|
this.disabledHover(); |
|
|
@ -197,7 +197,7 @@ export class Single extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
setWarningTitle(title, opt) { |
|
|
|
setWarningTitle(title, opt) { |
|
|
|
this.options.warningTitle = title; |
|
|
|
this.options.warningTitle = title; |
|
|
|
if (BI.isKey(title) || BI.isFunction(title)) { |
|
|
|
if (isKey(title) || isFunction(title)) { |
|
|
|
this.enableHover(opt); |
|
|
|
this.enableHover(opt); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.disabledHover(); |
|
|
|
this.disabledHover(); |
|
|
@ -218,7 +218,7 @@ export class Single extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
getTitle() { |
|
|
|
getTitle() { |
|
|
|
const title = this.options.title; |
|
|
|
const title = this.options.title; |
|
|
|
if (BI.isFunction(title)) { |
|
|
|
if (isFunction(title)) { |
|
|
|
return title(); |
|
|
|
return title(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -227,7 +227,7 @@ export class Single extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
getWarningTitle() { |
|
|
|
getWarningTitle() { |
|
|
|
const title = this.options.warningTitle; |
|
|
|
const title = this.options.warningTitle; |
|
|
|
if (BI.isFunction(title)) { |
|
|
|
if (isFunction(title)) { |
|
|
|
return title(); |
|
|
|
return title(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -246,7 +246,7 @@ export class Single extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_destroyed() { |
|
|
|
_destroyed() { |
|
|
|
if (BI.isNotNull(this.showTimeout)) { |
|
|
|
if (isNotNull(this.showTimeout)) { |
|
|
|
clearTimeout(this.showTimeout); |
|
|
|
clearTimeout(this.showTimeout); |
|
|
|
this.showTimeout = null; |
|
|
|
this.showTimeout = null; |
|
|
|
} |
|
|
|
} |
|
|
|