From ab1ae0da1678c6a3029efd971d1063d012e98587 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 25 Jul 2019 10:51:47 +0800 Subject: [PATCH] =?UTF-8?q?BI-48579=20refactor:=20=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=BB=98=E8=AE=A4=E5=80=BC=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E6=96=87=E6=9C=AC=E6=90=9E=E6=88=90=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/editor/editor.state.js | 16 ++++++++-------- src/case/editor/editor.state.simple.js | 14 +++++++------- src/case/trigger/trigger.icon.text.js | 10 ++++++++-- src/case/trigger/trigger.icon.text.select.js | 4 ++++ src/case/trigger/trigger.text.js | 10 ++++++++-- src/case/trigger/trigger.text.select.js | 18 ++++++++++++++---- 6 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js index 1de0de262..7514e6ad9 100644 --- a/src/case/editor/editor.state.js +++ b/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"); } } }, diff --git a/src/case/editor/editor.state.simple.js b/src/case/editor/editor.state.simple.js index 449e5e8bc..c95b160a0 100644 --- a/src/case/editor/editor.state.simple.js +++ b/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"); } } }); diff --git a/src/case/trigger/trigger.icon.text.js b/src/case/trigger/trigger.icon.text.js index c4ea4c27d..35005606c 100644 --- a/src/case/trigger/trigger.icon.text.js +++ b/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); } diff --git a/src/case/trigger/trigger.icon.text.select.js b/src/case/trigger/trigger.icon.text.select.js index 75d909ce5..752cde1c7 100644 --- a/src/case/trigger/trigger.icon.text.select.js +++ b/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) { diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index 80bce8ec3..80674c815 100644 --- a/src/case/trigger/trigger.text.js +++ b/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); }, diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index a5eae5e93..4c6b51943 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/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) {