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({
type: "bi.text_button",
cls: "state-editor-infinite-text tip-text-style",
cls: "bi-water-mark tip-text-style",
textAlign: "left",
height: o.height,
text: o.text,
@ -243,31 +243,31 @@ BI.StateEditor = BI.inherit(BI.Widget, {
if (BI.isNumber(v)) {
if (v === BI.Selection.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) {
this.text.setText(BI.i18nText("BI-Select_Part"));
this.text.element.removeClass("state-editor-infinite-text");
this.text.element.removeClass("bi-water-mark");
} else {
this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text");
this.text.element.addClass("bi-water-mark");
}
return;
}
if (BI.isString(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;
}
if (BI.isArray(v)) {
if (BI.isEmpty(v)) {
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) {
this.text.setText(v[0]);
this.text.element.removeClass("state-editor-infinite-text");
this.text.element.removeClass("bi-water-mark");
} else {
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({
type: "bi.text_button",
cls: "state-editor-infinite-text",
cls: "bi-water-mark",
textAlign: "left",
text: o.text,
height: o.height,
@ -229,26 +229,26 @@ BI.SimpleStateEditor = BI.inherit(BI.Widget, {
if (BI.isNumber(v)) {
if (v === BI.Selection.All) {
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) {
this.text.setText(BI.i18nText("BI-Already_Selected"));
this.text.element.removeClass("state-editor-infinite-text");
this.text.element.removeClass("bi-water-mark");
} else {
this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text");
this.text.element.addClass("bi-water-mark");
}
return;
}
if (!BI.isArray(v) || v.length === 1) {
this.text.setText(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)) {
this.text.setText(o.text);
this.text.element.addClass("state-editor-infinite-text");
this.text.element.addClass("bi-water-mark");
} else {
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",
height: 24,
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;
this.text = BI.createWidget({
type: "bi.label",
cls: "select-text-label",
cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""),
textAlign: "left",
height: o.height,
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) {
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",
element: this,
text: obj.text,
textCls: obj.textCls,
iconCls: obj.iconCls,
height: o.height,
iconHeight: o.iconHeight,
@ -48,11 +49,13 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
if (BI.isNotNull(result)) {
return {
text: result.text,
textCls: "",
iconCls: result.iconCls
};
} else {
return {
text: o.text,
textCls: "bi-water-mark",
iconCls: o.iconCls
};
}
@ -62,6 +65,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, {
var obj = this._digist(vals, this.options.items);
this.trigger.setText(obj.text);
this.trigger.setIcon(obj.iconCls);
this.trigger.setTextCls(obj.textCls);
},
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);
return BI.extend(conf, {
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;
this.text = BI.createWidget({
type: "bi.label",
cls: "select-text-label",
cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""),
textAlign: "left",
height: o.height,
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) {
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;
BI.SelectTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options;
var obj = this._digest(o.text, o.items);
this.trigger = BI.createWidget({
type: "bi.text_trigger",
element: this,
height: o.height,
readonly: o.readonly,
text: this._digest(o.value, o.items),
text: obj.text,
textCls: obj.textCls,
tipType: o.tipType,
warningTitle: o.warningTitle
});
@ -41,14 +43,22 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
});
if (result.length > 0) {
return result.join(",");
return {
textCls: "",
text: result.join(",")
}
} 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) {
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) {

Loading…
Cancel
Save