diff --git a/demo/js/component/demo.treevaluechoosercombo.js b/demo/js/component/demo.treevaluechoosercombo.js index e104e9edac..8fa557ee1e 100644 --- a/demo/js/component/demo.treevaluechoosercombo.js +++ b/demo/js/component/demo.treevaluechoosercombo.js @@ -4,8 +4,8 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, { }, render: function () { - this.widget = BI.createWidget({ - type: "bi.list_tree_value_chooser_insert_combo", + var widget = BI.createWidget({ + type: "bi.tree_value_chooser_combo", width: 300, // items: BI.deepClone(Demo.CONSTANTS.TREEITEMS), itemsCreator: function (op, callback) { @@ -16,18 +16,8 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, { type: "bi.vertical", hgap: 200, vgap: 10, - items: [this.widget] + items: [widget] }; - }, - - mounted: function () { - this.widget.setValue([ - ["中国", "安徽省"], - ["中国", "澳门特别行政区"], - ["中国", "北京市"], - ["中国", "福建省"], - ["中国", "甘肃省"] - ]); } }); BI.shortcut("demo.tree_value_chooser_combo", Demo.TreeValueChooser); diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index e544b5bf67..4cf79ae898 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -168,7 +168,7 @@ BI.Input = BI.inherit(BI.Single, { this.fireEvent(BI.Input.EVENT_BACKSPACE); } } - this.fireEvent(BI.Input.EVENT_KEY_DOWN, keyCode); + this.fireEvent(BI.Input.EVENT_KEY_DOWN); if (BI.isEndWithBlank(this.getValue())) { this._pause = true; diff --git a/src/less/widget/multiselect/trigger/editor.block.multiselect.less b/src/less/widget/multiselect/trigger/editor.block.multiselect.less deleted file mode 100644 index c7383d3f28..0000000000 --- a/src/less/widget/multiselect/trigger/editor.block.multiselect.less +++ /dev/null @@ -1,12 +0,0 @@ -@import "../../../index"; - -.bi-multi-select-block-editor { - & .label-wrapper { - & .label-item { - .background-color(@color-bi-background-highlight, 6%); - } - } - & .search-editor { - min-width: 25px; - } -} \ No newline at end of file diff --git a/src/widget/multiselect/trigger/editor.block.multiselect.js b/src/widget/multiselect/trigger/editor.block.multiselect.js deleted file mode 100644 index d884fc5647..0000000000 --- a/src/widget/multiselect/trigger/editor.block.multiselect.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * 多选输入框, 选中项将会以块状形式出现, 可以在触发器中删除item - * @author windy - * @class BI.MultiSelectBlockEditor - * @extends Widget - */ -BI.MultiSelectBlockEditor = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-multi-select-block-editor", - el: {}, - valueFormatter: function (v) { - return v; - } - }, - - render: function () { - var self = this; - return { - type: "bi.inline_vertical_adapt", - scrollx: false, - items: [{ - type: "bi.button_group", - cls: "label-wrapper", - ref: function (_ref) { - self.labelWrapper = _ref; - }, - items: [], - layouts: [{ - type: "bi.inline_vertical_adapt", - scrollable: false, - tagName: "ul", - hgap: 5 - }], - listeners: [{ - eventName: BI.ButtonGroup.EVENT_CHANGE, - action: function () { - self.selection = this.getIndexByValue(this.getValue()[0]); - self._bindKeyDownEvent(); - } - }] - }, { - type: "bi.sign_editor", - allowBlank: true, - cls: "search-editor", - ref: function (_ref) { - self.editor = _ref; - }, - listeners: [{ - eventName: BI.Controller.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.Controller.EVENT_CHANGE); - } - }, { - eventName: BI.SignEditor.EVENT_PAUSE, - action: function () { - self.fireEvent(BI.MultiSelectBlockEditor.EVENT_PAUSE); - } - }, { - eventName: BI.SignEditor.EVENT_STOP, - action: function () { - self.fireEvent(BI.MultiSelectBlockEditor.EVENT_STOP); - } - }, { - eventName: BI.SignEditor.EVENT_FOCUS, - action: function () { - // self._bindKeyDownEvent(); - } - }, { - eventName: BI.SignEditor.EVENT_BLUR, - action: function () { - self._unbindKeyDownEvent(); - } - }], - height: 22 - }] - }; - }, - - _bindKeyDownEvent: function () { - console.log("bind"); - BI.Widget._renderEngine.createElement(document).unbind("keydown." + this.getName()); - BI.Widget._renderEngine.createElement(document).bind("keydown." + this.getName(), BI.bind(this._dealBlockByKey, this)); - }, - - _unbindKeyDownEvent: function () { - console.log("unbind"); - BI.Widget._renderEngine.createElement(document).unbind("keydown." + this.getName()); - }, - - _dealBlockByKey: function (e) { - switch (e.keyCode) { - case BI.KeyCode.LEFT: - this._selectBlock(-1); - break; - case BI.KeyCode.RIGHT: - this._selectBlock(1); - break; - case BI.KeyCode.BACKSPACE: - case BI.KeyCode.DELETE: - !this.editor.isEditing() && this._deleteBlock(); - break; - default: - break; - } - }, - - _deleteBlock: function () { - this.fireEvent(BI.MultiSelectBlockEditor.EVENT_DELETE); - }, - - _selectBlock: function (direction) { - var self = this; - var length = this._getBlocksLength(); - if (length === 0) { - this.selection = null; - } else { - this.selection = BI.clamp(BI.isNull(this.selection) ? length - 1 : this.selection + direction, 0, length - 1); - } - var button = BI.find(this.labelWrapper.getAllButtons(), function (idx) { - return idx === self.selection; - }); - BI.isNotNull(button) && this.labelWrapper.setValue(button.getValue()); - }, - - _getBlocksLength: function () { - return this.labelWrapper.getAllButtons().length; - }, - - _checkPosition: function () { - var width = this.element.width(); - var blockRegionWidth = width - 25 > 0 ? width - 25 : 0; - var blockWrapWidth = this.labelWrapper.element.width(); - if (blockRegionWidth < blockWrapWidth) { - this.labelWrapper.element.width(blockRegionWidth); - } - }, - - focus: function () { - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - }, - - setState: function (state) { - var self = this, o = this.options; - this.selection = null; - this.editor.isEditing() ? this._bindKeyDownEvent() : this._unbindKeyDownEvent(); - var values = BI.map(state, function (idx, path) { - return BI.last(path); - }); - this.labelWrapper.populate(BI.map(values, function (idx, value) { - return { - type: "bi.text_button", - tagName: "li", - cls: "bi-border-radius bi-list-item-select", - text: o.valueFormatter(value), - value: value, - stopPropagation: true - }; - })); - BI.defer(function () { - self._checkPosition(); - }); - }, - - setValue: function (v) { - this.editor.setValue(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 = "EVENT_PAUSE"; -BI.MultiSelectBlockEditor.EVENT_STOP = "EVENT_STOP"; -BI.MultiSelectBlockEditor.EVENT_DELETE = "EVENT_DELETE"; -BI.shortcut("bi.multi_select_block_editor", BI.MultiSelectBlockEditor); diff --git a/src/widget/multitree/trigger/searcher.list.multi.tree.js b/src/widget/multitree/trigger/searcher.list.multi.tree.js index 4cd242909f..acfe1cf450 100644 --- a/src/widget/multitree/trigger/searcher.list.multi.tree.js +++ b/src/widget/multitree/trigger/searcher.list.multi.tree.js @@ -24,19 +24,12 @@ BI.MultiListTreeSearcher = BI.inherit(BI.Widget, { BI.MultiListTreeSearcher.superclass._init.apply(this, arguments); var self = this, o = this.options; this.editor = BI.createWidget({ - type: "bi.multi_select_block_editor", - valueFormatter: o.valueFormatter, + type: "bi.multi_select_editor", height: o.height, el: { type: "bi.simple_state_editor", height: o.height - }, - listeners: [{ - eventName: BI.MultiSelectBlockEditor.EVENT_STOP, - action: function (v) { - self.fireEvent(BI.MultiListTreeSearcher.EVENT_REMOVE, v); - } - }] + } }); this.searcher = BI.createWidget({ @@ -115,29 +108,28 @@ BI.MultiListTreeSearcher = BI.inherit(BI.Widget, { }, setState: function (ob) { - // var o = this.options; - // ob || (ob = {}); - // ob.value || (ob.value = []); - // var count = 0; - // if (BI.isNumber(ob)) { - // this.editor.setState(ob); - // } else if (BI.size(ob.value) === 0) { - // this.editor.setState(BI.Selection.None); - // } else { - // var text = ""; - // BI.each(ob.value, function (idx, path) { - // var childValue = BI.last(path); - // text += (o.valueFormatter(childValue + "") || childValue) + "; "; - // count++; - // }); - // - // if (count > 20) { - // this.editor.setState(BI.Selection.Multi); - // } else { - // this.editor.setState(text); - // } - // } - this.editor.setState(ob.value); + var o = this.options; + ob || (ob = {}); + ob.value || (ob.value = []); + var count = 0; + if (BI.isNumber(ob)) { + this.editor.setState(ob); + } else if (BI.size(ob.value) === 0) { + this.editor.setState(BI.Selection.None); + } else { + var text = ""; + BI.each(ob.value, function (idx, path) { + var childValue = BI.last(path); + text += (o.valueFormatter(childValue + "") || childValue) + "; "; + count++; + }); + + if (count > 20) { + this.editor.setState(BI.Selection.Multi); + } else { + this.editor.setState(text); + } + } }, setValue: function (ob) {