Browse Source

Pull request #2909: KERNEL-11911 feat: label组件默认使用text作为tooltip

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

* commit 'e5512119ee9f7a90b10ab6c10a4f232980fab1c3':
  KERNEL-11911 feat: label组件默认使用text作为tooltip
es6
Dailer 2 years ago
parent
commit
dd00621140
  1. 5
      src/base/single/0.single.js
  2. 20
      src/base/single/label/abstract.label.js

5
src/base/single/0.single.js

@ -17,7 +17,8 @@ BI.Single = BI.inherit(BI.Widget, {
title: null, title: null,
warningTitle: null, warningTitle: null,
tipType: null, // success或warning tipType: null, // success或warning
belowMouse: false // title是否跟随鼠标 belowMouse: false, // title是否跟随鼠标
enableHover: false
}); });
}, },
@ -57,7 +58,7 @@ BI.Single = BI.inherit(BI.Widget, {
self.setValue(newValue); self.setValue(newValue);
}) : o.value; }) : o.value;
BI.Single.superclass._init.apply(this, arguments); BI.Single.superclass._init.apply(this, arguments);
if (BI.isKey(o.title) || BI.isKey(o.warningTitle) if (o.enableHover || BI.isKey(o.title) || BI.isKey(o.warningTitle)
|| BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) { || BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover({ this.enableHover({
belowMouse: o.belowMouse, belowMouse: o.belowMouse,

20
src/base/single/label/abstract.label.js

@ -18,10 +18,27 @@
tgap: 0, tgap: 0,
bgap: 0, bgap: 0,
highLight: false, highLight: false,
handler: null handler: null,
enableHover: props.title !== null,
}); });
}, },
getTitle: function () {
var title = this.options.title;
var text = this.options.text;
if (BI.isFunction(title)) {
return title();
}
if (BI.isNotNull(title)) {
return title;
}
if (BI.isFunction(text)) {
return text();
}
return text;
},
_createJson: function () { _createJson: function () {
var o = this.options; var o = this.options;
return { return {
@ -374,6 +391,7 @@
setValue: function (v) { setValue: function (v) {
BI.AbstractLabel.superclass.setValue.apply(this, arguments); BI.AbstractLabel.superclass.setValue.apply(this, arguments);
if (!this.isReadOnly()) { if (!this.isReadOnly()) {
this.options.text = v;
this.text.setValue(v); this.text.setValue(v);
} }
} }

Loading…
Cancel
Save