Browse Source

revert

master
windy 6 years ago
parent
commit
8f54616667
  1. 16
      demo/js/component/demo.treevaluechoosercombo.js
  2. 2
      src/base/single/input/input.js
  3. 12
      src/less/widget/multiselect/trigger/editor.block.multiselect.less
  4. 197
      src/widget/multiselect/trigger/editor.block.multiselect.js
  5. 54
      src/widget/multitree/trigger/searcher.list.multi.tree.js

16
demo/js/component/demo.treevaluechoosercombo.js

@ -4,8 +4,8 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, {
}, },
render: function () { render: function () {
this.widget = BI.createWidget({ var widget = BI.createWidget({
type: "bi.list_tree_value_chooser_insert_combo", type: "bi.tree_value_chooser_combo",
width: 300, width: 300,
// items: BI.deepClone(Demo.CONSTANTS.TREEITEMS), // items: BI.deepClone(Demo.CONSTANTS.TREEITEMS),
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
@ -16,18 +16,8 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, {
type: "bi.vertical", type: "bi.vertical",
hgap: 200, hgap: 200,
vgap: 10, vgap: 10,
items: [this.widget] items: [widget]
}; };
},
mounted: function () {
this.widget.setValue([
["中国", "安徽省"],
["中国", "澳门特别行政区"],
["中国", "北京市"],
["中国", "福建省"],
["中国", "甘肃省"]
]);
} }
}); });
BI.shortcut("demo.tree_value_chooser_combo", Demo.TreeValueChooser); BI.shortcut("demo.tree_value_chooser_combo", Demo.TreeValueChooser);

2
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_BACKSPACE);
} }
} }
this.fireEvent(BI.Input.EVENT_KEY_DOWN, keyCode); this.fireEvent(BI.Input.EVENT_KEY_DOWN);
if (BI.isEndWithBlank(this.getValue())) { if (BI.isEndWithBlank(this.getValue())) {
this._pause = true; this._pause = true;

12
src/less/widget/multiselect/trigger/editor.block.multiselect.less

@ -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;
}
}

197
src/widget/multiselect/trigger/editor.block.multiselect.js

@ -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);

54
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); BI.MultiListTreeSearcher.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.multi_select_block_editor", type: "bi.multi_select_editor",
valueFormatter: o.valueFormatter,
height: o.height, height: o.height,
el: { el: {
type: "bi.simple_state_editor", type: "bi.simple_state_editor",
height: o.height height: o.height
},
listeners: [{
eventName: BI.MultiSelectBlockEditor.EVENT_STOP,
action: function (v) {
self.fireEvent(BI.MultiListTreeSearcher.EVENT_REMOVE, v);
} }
}]
}); });
this.searcher = BI.createWidget({ this.searcher = BI.createWidget({
@ -115,29 +108,28 @@ BI.MultiListTreeSearcher = BI.inherit(BI.Widget, {
}, },
setState: function (ob) { setState: function (ob) {
// var o = this.options; var o = this.options;
// ob || (ob = {}); ob || (ob = {});
// ob.value || (ob.value = []); ob.value || (ob.value = []);
// var count = 0; var count = 0;
// if (BI.isNumber(ob)) { if (BI.isNumber(ob)) {
// this.editor.setState(ob); this.editor.setState(ob);
// } else if (BI.size(ob.value) === 0) { } else if (BI.size(ob.value) === 0) {
// this.editor.setState(BI.Selection.None); this.editor.setState(BI.Selection.None);
// } else { } else {
// var text = ""; var text = "";
// BI.each(ob.value, function (idx, path) { BI.each(ob.value, function (idx, path) {
// var childValue = BI.last(path); var childValue = BI.last(path);
// text += (o.valueFormatter(childValue + "") || childValue) + "; "; text += (o.valueFormatter(childValue + "") || childValue) + "; ";
// count++; count++;
// }); });
//
// if (count > 20) { if (count > 20) {
// this.editor.setState(BI.Selection.Multi); this.editor.setState(BI.Selection.Multi);
// } else { } else {
// this.editor.setState(text); this.editor.setState(text);
// } }
// } }
this.editor.setState(ob.value);
}, },
setValue: function (ob) { setValue: function (ob) {

Loading…
Cancel
Save