Browse Source

BI-48579 refactor: 下拉显示默认值的时候文本搞成水印色

es6
windy 5 years ago
parent
commit
ab1ae0da16
  1. 16
      src/case/editor/editor.state.js
  2. 14
      src/case/editor/editor.state.simple.js
  3. 10
      src/case/trigger/trigger.icon.text.js
  4. 4
      src/case/trigger/trigger.icon.text.select.js
  5. 10
      src/case/trigger/trigger.text.js
  6. 18
      src/case/trigger/trigger.text.select.js

16
src/case/editor/editor.state.js

@ -46,7 +46,7 @@ BI.StateEditor = BI.inherit(BI.Widget, {
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "state-editor-infinite-text tip-text-style", cls: "bi-water-mark tip-text-style",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text, text: o.text,
@ -243,31 +243,31 @@ BI.StateEditor = BI.inherit(BI.Widget, {
if (BI.isNumber(v)) { if (BI.isNumber(v)) {
if (v === BI.Selection.All) { if (v === BI.Selection.All) {
this.text.setText(BI.i18nText("BI-Select_All")); this.text.setText(BI.i18nText("BI-Select_All"));
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} else if (v === BI.Selection.Multi) { } else if (v === BI.Selection.Multi) {
this.text.setText(BI.i18nText("BI-Select_Part")); this.text.setText(BI.i18nText("BI-Select_Part"));
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} else { } else {
this.text.setText(o.text); this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text"); this.text.element.addClass("bi-water-mark");
} }
return; return;
} }
if (BI.isString(v)) { if (BI.isString(v)) {
this.text.setText(v); this.text.setText(v);
this.text.element.removeClass("state-editor-infinite-text"); v === o.text ? this.text.element.addClass("bi-water-mark") : this.text.element.removeClass("bi-water-mark");
return; return;
} }
if (BI.isArray(v)) { if (BI.isArray(v)) {
if (BI.isEmpty(v)) { if (BI.isEmpty(v)) {
this.text.setText(o.text); this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text"); this.text.element.addClass("bi-water-mark");
} else if (v.length === 1) { } else if (v.length === 1) {
this.text.setText(v[0]); this.text.setText(v[0]);
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} else { } else {
this.text.setText(BI.i18nText("BI-Select_Part")); this.text.setText(BI.i18nText("BI-Select_Part"));
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} }
} }
}, },

14
src/case/editor/editor.state.simple.js

@ -47,7 +47,7 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
}); });
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.text_button", type: "bi.text_button",
cls: "state-editor-infinite-text", cls: "bi-water-mark",
textAlign: "left", textAlign: "left",
text: o.text, text: o.text,
height: o.height, height: o.height,
@ -229,26 +229,26 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
if (BI.isNumber(v)) { if (BI.isNumber(v)) {
if (v === BI.Selection.All) { if (v === BI.Selection.All) {
this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.setText(BI.i18nText("BI-Already_Selected"));
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} else if (v === BI.Selection.Multi) { } else if (v === BI.Selection.Multi) {
this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.setText(BI.i18nText("BI-Already_Selected"));
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} else { } else {
this.text.setText(o.text); this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text"); this.text.element.addClass("bi-water-mark");
} }
return; return;
} }
if (!BI.isArray(v) || v.length === 1) { if (!BI.isArray(v) || v.length === 1) {
this.text.setText(v); this.text.setText(v);
this.text.setTitle(v); this.text.setTitle(v);
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} else if (BI.isEmpty(v)) { } else if (BI.isEmpty(v)) {
this.text.setText(o.text); this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text"); this.text.element.addClass("bi-water-mark");
} else { } else {
this.text.setText(BI.i18nText("BI-Already_Selected")); this.text.setText(BI.i18nText("BI-Already_Selected"));
this.text.element.removeClass("state-editor-infinite-text"); this.text.element.removeClass("bi-water-mark");
} }
} }
}); });

10
src/case/trigger/trigger.icon.text.js

@ -16,7 +16,8 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 24, height: 24,
iconHeight: null, iconHeight: null,
iconWidth: null iconWidth: null,
textCls: ""
}); });
}, },
@ -25,7 +26,7 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
cls: "select-text-label", cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""),
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text text: o.text
@ -90,6 +91,11 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, {
} }
}, },
setTextCls: function(cls) {
var o = this.options;
this.text.element.removeClass(o.textCls).addClass(cls);
},
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
} }

4
src/case/trigger/trigger.icon.text.select.js

@ -22,6 +22,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
type: "bi.icon_text_trigger", type: "bi.icon_text_trigger",
element: this, element: this,
text: obj.text, text: obj.text,
textCls: obj.textCls,
iconCls: obj.iconCls, iconCls: obj.iconCls,
height: o.height, height: o.height,
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
@ -48,11 +49,13 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
if (BI.isNotNull(result)) { if (BI.isNotNull(result)) {
return { return {
text: result.text, text: result.text,
textCls: "",
iconCls: result.iconCls iconCls: result.iconCls
}; };
} else { } else {
return { return {
text: o.text, text: o.text,
textCls: "bi-water-mark",
iconCls: o.iconCls iconCls: o.iconCls
}; };
} }
@ -62,6 +65,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
var obj = this._digist(vals, this.options.items); var obj = this._digist(vals, this.options.items);
this.trigger.setText(obj.text); this.trigger.setText(obj.text);
this.trigger.setIcon(obj.iconCls); this.trigger.setIcon(obj.iconCls);
this.trigger.setTextCls(obj.textCls);
}, },
populate: function (items) { populate: function (items) {

10
src/case/trigger/trigger.text.js

@ -14,7 +14,8 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 24 height: 24,
textCls: ""
}); });
}, },
@ -23,7 +24,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
cls: "select-text-label", cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""),
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text, text: o.text,
@ -54,6 +55,11 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
}); });
}, },
setTextCls: function(cls) {
var o = this.options;
this.text.element.removeClass(o.textCls).addClass(cls);
},
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
}, },

18
src/case/trigger/trigger.text.select.js

@ -18,12 +18,14 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
this.options.height -= 2; this.options.height -= 2;
BI.SelectTextTrigger.superclass._init.apply(this, arguments); BI.SelectTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var obj = this._digest(o.text, o.items);
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
element: this, element: this,
height: o.height, height: o.height,
readonly: o.readonly, readonly: o.readonly,
text: this._digest(o.value, o.items), text: obj.text,
textCls: obj.textCls,
tipType: o.tipType, tipType: o.tipType,
warningTitle: o.warningTitle warningTitle: o.warningTitle
}); });
@ -41,14 +43,22 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
}); });
if (result.length > 0) { if (result.length > 0) {
return result.join(","); return {
textCls: "",
text: result.join(",")
}
} else { } else {
return BI.isFunction(o.text) ? o.text() : o.text; return {
textCls: "bi-water-mark",
text: BI.isFunction(o.text) ? o.text() : o.text
}
} }
}, },
setValue: function (vals) { setValue: function (vals) {
this.trigger.setText(this._digest(vals, this.options.items)); var formatValue = this._digest(vals, this.options.items);
this.trigger.setTextCls(formatValue.textCls);
this.trigger.setText(formatValue.text);
}, },
setTipType: function (v) { setTipType: function (v) {

Loading…
Cancel
Save