From 18efc094f2435e582caf4fe44eeea50025d14871 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 8 May 2019 09:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E8=AF=95=E6=8E=A2=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trigger/editor.block.multiselect.js | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/widget/multiselect/trigger/editor.block.multiselect.js diff --git a/src/widget/multiselect/trigger/editor.block.multiselect.js b/src/widget/multiselect/trigger/editor.block.multiselect.js new file mode 100644 index 000000000..1f42f8d36 --- /dev/null +++ b/src/widget/multiselect/trigger/editor.block.multiselect.js @@ -0,0 +1,113 @@ +/** + * 多选输入框, 选中项将会以块状形式出现, 可以在触发器中删除item + * @author windy + * @class BI.MultiSelectBlockEditor + * @extends Widget + */ +BI.MultiSelectBlockEditor = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-multi-select-editor", + el: {} + }, + + render: function () { + return { + type: "bi.htape", + items: [{ + type: "bi.vertical_adapt", + items: [], + width: 24 + }, { + el: { + type: "bi.editor" + }, + + }] + }; + }, + + mounted: function () { + this._checkSize(); + }, + + getBlockSize: function() { + // return BI.redu + }, + + _checkSize: function () { + this.comboWrapper.attr("items")[0].width = o.height; + this.comboWrapper.resize(); + }, + + _init: function () { + BI.MultiSelectBlockEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.state_editor", + element: this, + height: o.height, + watermark: BI.i18nText("BI-Basic_Search"), + allowBlank: true, + value: o.value, + text: o.text, + tipType: o.tipType, + warningTitle: o.warningTitle, + }); + + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectBlockEditor.EVENT_PAUSE); + }); + this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { + + }); + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + setState: function (state) { + this.editor.setState(state); + }, + + setValue: function (v) { + this.editor.setValue(v); + }, + + setTipType: function (v) { + this.editor.setTipType(v); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } + return ""; + + }, + + getKeywords: function () { + var val = this.editor.getLastValidValue(); + var keywords = val.match(/[\S]+/g); + if (BI.isEndWithBlank(val)) { + return keywords.concat([" "]); + } + return keywords; + }, + + populate: function (items) { + + } +}); +BI.MultiSelectBlockEditor.EVENT_PAUSE = "MultiSelectBlockEditor.EVENT_PAUSE"; +BI.shortcut("bi.multi_select_block_editor", BI.MultiSelectBlockEditor);