From 6002b212d6864bed0367b111e9fd93f44b8c8bb9 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 5 Feb 2018 15:15:25 +0800 Subject: [PATCH] =?UTF-8?q?button=E5=8F=AF=E9=85=8Dbubble&=E5=8F=AF?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E5=8D=95=E9=80=89=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/base/button/demo.button.js | 12 + .../combo/demo.search_text_value_combo.js | 74 ++++ demo/js/config/case.js | 4 + dist/base.js | 65 +++- dist/bundle.js | 346 +++++++++++++++++- dist/case.js | 281 +++++++++++++- dist/demo.js | 89 +++++ dist/fineui.js | 346 +++++++++++++++++- src/base/single/button/button.basic.js | 65 +++- .../combo.searchtextvalue.js | 108 ++++++ .../popup.searchtextvalue.js | 67 ++++ .../trigger.searchtextvalue.js | 107 ++++++ src/case/editor/editor.state.js | 2 +- 13 files changed, 1558 insertions(+), 8 deletions(-) create mode 100644 demo/js/case/combo/demo.search_text_value_combo.js create mode 100644 src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js create mode 100644 src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js create mode 100644 src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 99ef9032b..92a6a785c 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -204,6 +204,18 @@ Demo.Button = BI.inherit(BI.Widget, { ghost: true, height: 30 } + }, { + el: { + type: "bi.button", + text: "弹出bubble", + bubble: function () { + return BI.parseInt(Math.random() * 100) % 10 + "提示" + }, + handler: function () { + BI.Msg.toast("1111"); + }, + height: 30 + } } ]; // BI.each(items, function (i, item) { diff --git a/demo/js/case/combo/demo.search_text_value_combo.js b/demo/js/case/combo/demo.search_text_value_combo.js new file mode 100644 index 000000000..6b50234d7 --- /dev/null +++ b/demo/js/case/combo/demo.search_text_value_combo.js @@ -0,0 +1,74 @@ +/** + * Created by Windy on 2018/2/4. + */ +Demo.SearchTextValueCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + var combo; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.search_text_value_combo", + ref: function () { + combo = this; + }, + text: "默认值", + value: 2, + width: 300, + items: [{ + text: "ABC-1", + iconCls: "date-font", + value: 1 + }, { + text: "BCD-2", + iconCls: "search-font", + value: 2 + }, { + text: "CDE-3", + iconCls: "pull-right-font", + value: 3 + }, { + text: "DEF-3", + iconCls: "pull-right-font", + value: 4 + }, { + text: "FEG-3", + iconCls: "pull-right-font", + value: 5 + }, { + text: "FGH-3", + iconCls: "pull-right-font", + value: 6 + }, { + text: "GHI-3", + iconCls: "pull-right-font", + value: 7 + }, { + text: "HIJ-3", + iconCls: "pull-right-font", + value: 8 + }, { + text: "IJK-3", + iconCls: "pull-right-font", + value: 9 + }, { + text: "JKL-3", + iconCls: "pull-right-font", + value: 10 + }] + }, { + type: "bi.button", + width: 90, + height: 25, + handler: function () { + combo.setValue(3); + } + }], + vgap: 20 + }; + } +}); + +BI.shortcut("demo.search_text_value_combo", Demo.SearchTextValueCombo); \ No newline at end of file diff --git a/demo/js/config/case.js b/demo/js/config/case.js index 55ca22caa..900fb5b34 100644 --- a/demo/js/config/case.js +++ b/demo/js/config/case.js @@ -130,6 +130,10 @@ Demo.CASE_CONFIG = [{ pId: 306, text: "bi.text_value_combo", value: "demo.text_value_combo" +}, { + pId: 306, + text: "bi.search_text_value_combo", + value: "demo.search_text_value_combo" }, { pId: 306, text: "bi.icon_text_value_combo", diff --git a/dist/base.js b/dist/base.js index 0f9a66864..76118b0a5 100644 --- a/dist/base.js +++ b/dist/base.js @@ -624,7 +624,8 @@ BI.BasicButton = BI.inherit(BI.Single, { shadow: false, isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 trigger: null, - handler: BI.emptyFn + handler: BI.emptyFn, + bubble: null }); }, _init: function () { @@ -816,8 +817,70 @@ BI.BasicButton = BI.inherit(BI.Single, { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { return; } + if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { + if(BI.isNull(self.combo)){ + var popup; + BI.createWidget({ + type: "bi.absolute", + element: self, + items: [{ + el: { + type: "bi.bubble_combo", + trigger: "", + ref: function () { + self.combo = this; + }, + el: { + type: "bi.layout", + height: "100%" + }, + popup: { + type: "bi.text_bubble_bar_popup_view", + text: getBubble(), + ref: function () { + popup = this; + }, + listeners: [{ + eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, + action: function (v) { + self.combo.hideView(); + if(v){ + onClick.apply(self, arguments); + } + } + }] + }, + listeners: [{ + eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, + action: function () { + popup.populate(getBubble()); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }] + }); + } + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + return; + } onClick.apply(self, arguments); } + + function getBubble() { + var bubble = self.options.bubble; + if(BI.isFunction(bubble)) { + return bubble(); + } + return bubble; + } }, _trigger: function () { diff --git a/dist/bundle.js b/dist/bundle.js index 30d4e2feb..7b1e6aafb 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -26676,7 +26676,8 @@ BI.BasicButton = BI.inherit(BI.Single, { shadow: false, isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 trigger: null, - handler: BI.emptyFn + handler: BI.emptyFn, + bubble: null }); }, _init: function () { @@ -26868,8 +26869,70 @@ BI.BasicButton = BI.inherit(BI.Single, { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { return; } + if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { + if(BI.isNull(self.combo)){ + var popup; + BI.createWidget({ + type: "bi.absolute", + element: self, + items: [{ + el: { + type: "bi.bubble_combo", + trigger: "", + ref: function () { + self.combo = this; + }, + el: { + type: "bi.layout", + height: "100%" + }, + popup: { + type: "bi.text_bubble_bar_popup_view", + text: getBubble(), + ref: function () { + popup = this; + }, + listeners: [{ + eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, + action: function (v) { + self.combo.hideView(); + if(v){ + onClick.apply(self, arguments); + } + } + }] + }, + listeners: [{ + eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, + action: function () { + popup.populate(getBubble()); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }] + }); + } + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + return; + } onClick.apply(self, arguments); } + + function getBubble() { + var bubble = self.options.bubble; + if(BI.isFunction(bubble)) { + return bubble(); + } + return bubble; + } }, _trigger: function () { @@ -68180,6 +68243,285 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { }); BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueCombo = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-search-text-value-combo", + height: 30, + text: "", + items: [] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.combo", + adjustLength: 2, + toggle: false, + ref: function () { + self.combo = this; + }, + el: { + type: "bi.search_text_value_trigger", + ref: function () { + self.trigger = this; + }, + items: o.items, + height: o.height - 2, + text: o.text, + value: o.value, + listeners: [{ + eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + popup: { + el:{ + type: "bi.text_value_combo_popup", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + value: o.value, + items: o.items, + ref: function () { + self.popup = this; + self.trigger.getSearcher().setAdapter(self.popup); + }, + listeners: [{ + eventName: BI.TextValueComboPopup.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + maxHeight: 300 + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function(){ + self.trigger.stopEditing(); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height, + handler: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + }, + right: 0, + bottom: 0, + top: 0 + }] + } + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + var value = this.popup.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); + } +}); +BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);/** + * Created by Windy on 2018/2/5. + */ +BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, { + + props: { + baseCls: "bi-search-text-value-popup" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.button_group", + ref: function () { + self.popup = this; + }, + items: BI.createItems(o.items, { + type: "bi.single_select_item", + textAlign: o.textAlign, + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }], + behaviors: { + redmark: function () { + return true; + } + }, + value: o.value, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + }] + }] + }; + }, + + populate: function (finded, matched, keyword) { + var items = BI.concat(finded, matched); + BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); + items = BI.createItems(items, { + type: "bi.single_select_item", + height: 30 + }); + this.popup.populate(items, keyword); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { + + props: { + baseCls: "bi-search-text-value-trigger bi-border", + height: 30 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.htape", + items: [ + { + el: { + type: "bi.searcher", + ref: function () { + self.searcher = this; + }, + isAutoSearch: false, + el: { + type: "bi.state_editor", + ref: function () { + self.editor = this; + }, + text: this._digest(o.value, o.items), + value: o.value, + height: o.height + }, + popup: { + type: "bi.search_text_value_combo_popup", + cls: "bi-card", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE + }, + onSearch: function (obj, callback) { + var keyword = obj.keyword; + var finding = BI.Func.getSearchResult(o.items, keyword); + var matched = finding.matched, finded = finding.finded; + callback(finded, matched); + }, + listeners: [{ + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE); + } + }] + } + }, { + el: { + type: "bi.layout", + width: 30 + }, + width: 30 + } + ] + } + }, + + _setState: function (v) { + this.editor.setState(v); + }, + + _digest: function(vals, items){ + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result = []; + var formatItems = BI.Tree.transformToArrayFormat(items); + BI.each(formatItems, function (i, item) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { + result.push(item.text || item.value); + } + }); + + if (result.length > 0) { + return result.join(","); + } else { + return o.text; + } + }, + + stopEditing: function () { + this.searcher.stopSearch(); + }, + + getSearcher: function () { + return this.searcher; + }, + + populate: function (items) { + this.options.items = items; + }, + + setValue: function (vals) { + this._setState(this._digest(vals, this.options.items)); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); +BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; +BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; +BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/** * 单选combo * * @class BI.StaticCombo @@ -69785,7 +70127,7 @@ BI.StateEditor = BI.inherit(BI.Widget, { }); this.text = BI.createWidget({ type: "bi.text_button", - cls: "state-editor-infinite-text bi-disabled", + cls: "state-editor-infinite-text", textAlign: "left", height: o.height, text: BI.i18nText("BI-Basic_Unrestricted"), diff --git a/dist/case.js b/dist/case.js index ca10b94ba..9267e7fd0 100644 --- a/dist/case.js +++ b/dist/case.js @@ -5611,6 +5611,285 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { }); BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueCombo = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-search-text-value-combo", + height: 30, + text: "", + items: [] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.combo", + adjustLength: 2, + toggle: false, + ref: function () { + self.combo = this; + }, + el: { + type: "bi.search_text_value_trigger", + ref: function () { + self.trigger = this; + }, + items: o.items, + height: o.height - 2, + text: o.text, + value: o.value, + listeners: [{ + eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + popup: { + el:{ + type: "bi.text_value_combo_popup", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + value: o.value, + items: o.items, + ref: function () { + self.popup = this; + self.trigger.getSearcher().setAdapter(self.popup); + }, + listeners: [{ + eventName: BI.TextValueComboPopup.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + maxHeight: 300 + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function(){ + self.trigger.stopEditing(); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height, + handler: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + }, + right: 0, + bottom: 0, + top: 0 + }] + } + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + var value = this.popup.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); + } +}); +BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);/** + * Created by Windy on 2018/2/5. + */ +BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, { + + props: { + baseCls: "bi-search-text-value-popup" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.button_group", + ref: function () { + self.popup = this; + }, + items: BI.createItems(o.items, { + type: "bi.single_select_item", + textAlign: o.textAlign, + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }], + behaviors: { + redmark: function () { + return true; + } + }, + value: o.value, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + }] + }] + }; + }, + + populate: function (finded, matched, keyword) { + var items = BI.concat(finded, matched); + BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); + items = BI.createItems(items, { + type: "bi.single_select_item", + height: 30 + }); + this.popup.populate(items, keyword); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { + + props: { + baseCls: "bi-search-text-value-trigger bi-border", + height: 30 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.htape", + items: [ + { + el: { + type: "bi.searcher", + ref: function () { + self.searcher = this; + }, + isAutoSearch: false, + el: { + type: "bi.state_editor", + ref: function () { + self.editor = this; + }, + text: this._digest(o.value, o.items), + value: o.value, + height: o.height + }, + popup: { + type: "bi.search_text_value_combo_popup", + cls: "bi-card", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE + }, + onSearch: function (obj, callback) { + var keyword = obj.keyword; + var finding = BI.Func.getSearchResult(o.items, keyword); + var matched = finding.matched, finded = finding.finded; + callback(finded, matched); + }, + listeners: [{ + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE); + } + }] + } + }, { + el: { + type: "bi.layout", + width: 30 + }, + width: 30 + } + ] + } + }, + + _setState: function (v) { + this.editor.setState(v); + }, + + _digest: function(vals, items){ + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result = []; + var formatItems = BI.Tree.transformToArrayFormat(items); + BI.each(formatItems, function (i, item) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { + result.push(item.text || item.value); + } + }); + + if (result.length > 0) { + return result.join(","); + } else { + return o.text; + } + }, + + stopEditing: function () { + this.searcher.stopSearch(); + }, + + getSearcher: function () { + return this.searcher; + }, + + populate: function (items) { + this.options.items = items; + }, + + setValue: function (vals) { + this._setState(this._digest(vals, this.options.items)); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); +BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; +BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; +BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/** * 单选combo * * @class BI.StaticCombo @@ -7216,7 +7495,7 @@ BI.StateEditor = BI.inherit(BI.Widget, { }); this.text = BI.createWidget({ type: "bi.text_button", - cls: "state-editor-infinite-text bi-disabled", + cls: "state-editor-infinite-text", textAlign: "left", height: o.height, text: BI.i18nText("BI-Basic_Unrestricted"), diff --git a/dist/demo.js b/dist/demo.js index 74a5ed21c..c164ef0ba 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -223,6 +223,18 @@ $(function () { ghost: true, height: 30 } + }, { + el: { + type: "bi.button", + text: "弹出bubble", + bubble: function () { + return BI.parseInt(Math.random() * 100) % 10 + "提示" + }, + handler: function () { + BI.Msg.toast("1111"); + }, + height: 30 + } } ]; // BI.each(items, function (i, item) { @@ -1944,6 +1956,79 @@ Demo.IconTextValueCombo = BI.inherit(BI.Widget, { }); BI.shortcut("demo.icon_text_value_combo", Demo.IconTextValueCombo);/** + * Created by Windy on 2018/2/4. + */ +Demo.SearchTextValueCombo = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + render: function () { + var combo; + return { + type: "bi.horizontal_auto", + items: [{ + type: "bi.search_text_value_combo", + ref: function () { + combo = this; + }, + text: "默认值", + value: 2, + width: 300, + items: [{ + text: "ABC-1", + iconCls: "date-font", + value: 1 + }, { + text: "BCD-2", + iconCls: "search-font", + value: 2 + }, { + text: "CDE-3", + iconCls: "pull-right-font", + value: 3 + }, { + text: "DEF-3", + iconCls: "pull-right-font", + value: 4 + }, { + text: "FEG-3", + iconCls: "pull-right-font", + value: 5 + }, { + text: "FGH-3", + iconCls: "pull-right-font", + value: 6 + }, { + text: "GHI-3", + iconCls: "pull-right-font", + value: 7 + }, { + text: "HIJ-3", + iconCls: "pull-right-font", + value: 8 + }, { + text: "IJK-3", + iconCls: "pull-right-font", + value: 9 + }, { + text: "JKL-3", + iconCls: "pull-right-font", + value: 10 + }] + }, { + type: "bi.button", + width: 90, + height: 25, + handler: function () { + combo.setValue(3); + } + }], + vgap: 20 + }; + } +}); + +BI.shortcut("demo.search_text_value_combo", Demo.SearchTextValueCombo);/** * Created by Dailer on 2017/7/11. */ Demo.StaticCombo = BI.inherit(BI.Widget, { @@ -5118,6 +5203,10 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.ADDONS_CONFIG pId: 306, text: "bi.text_value_combo", value: "demo.text_value_combo" +}, { + pId: 306, + text: "bi.search_text_value_combo", + value: "demo.search_text_value_combo" }, { pId: 306, text: "bi.icon_text_value_combo", diff --git a/dist/fineui.js b/dist/fineui.js index 3ec68aadc..60526b86b 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -28440,7 +28440,8 @@ BI.BasicButton = BI.inherit(BI.Single, { shadow: false, isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 trigger: null, - handler: BI.emptyFn + handler: BI.emptyFn, + bubble: null }); }, _init: function () { @@ -28632,8 +28633,70 @@ BI.BasicButton = BI.inherit(BI.Single, { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { return; } + if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { + if(BI.isNull(self.combo)){ + var popup; + BI.createWidget({ + type: "bi.absolute", + element: self, + items: [{ + el: { + type: "bi.bubble_combo", + trigger: "", + ref: function () { + self.combo = this; + }, + el: { + type: "bi.layout", + height: "100%" + }, + popup: { + type: "bi.text_bubble_bar_popup_view", + text: getBubble(), + ref: function () { + popup = this; + }, + listeners: [{ + eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, + action: function (v) { + self.combo.hideView(); + if(v){ + onClick.apply(self, arguments); + } + } + }] + }, + listeners: [{ + eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, + action: function () { + popup.populate(getBubble()); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }] + }); + } + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + return; + } onClick.apply(self, arguments); } + + function getBubble() { + var bubble = self.options.bubble; + if(BI.isFunction(bubble)) { + return bubble(); + } + return bubble; + } }, _trigger: function () { @@ -69944,6 +70007,285 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { }); BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueCombo = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-search-text-value-combo", + height: 30, + text: "", + items: [] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.combo", + adjustLength: 2, + toggle: false, + ref: function () { + self.combo = this; + }, + el: { + type: "bi.search_text_value_trigger", + ref: function () { + self.trigger = this; + }, + items: o.items, + height: o.height - 2, + text: o.text, + value: o.value, + listeners: [{ + eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + popup: { + el:{ + type: "bi.text_value_combo_popup", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + value: o.value, + items: o.items, + ref: function () { + self.popup = this; + self.trigger.getSearcher().setAdapter(self.popup); + }, + listeners: [{ + eventName: BI.TextValueComboPopup.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + maxHeight: 300 + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function(){ + self.trigger.stopEditing(); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height, + handler: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + }, + right: 0, + bottom: 0, + top: 0 + }] + } + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + var value = this.popup.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); + } +}); +BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo);/** + * Created by Windy on 2018/2/5. + */ +BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, { + + props: { + baseCls: "bi-search-text-value-popup" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.button_group", + ref: function () { + self.popup = this; + }, + items: BI.createItems(o.items, { + type: "bi.single_select_item", + textAlign: o.textAlign, + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }], + behaviors: { + redmark: function () { + return true; + } + }, + value: o.value, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + }] + }] + }; + }, + + populate: function (finded, matched, keyword) { + var items = BI.concat(finded, matched); + BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); + items = BI.createItems(items, { + type: "bi.single_select_item", + height: 30 + }); + this.popup.populate(items, keyword); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup);/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { + + props: { + baseCls: "bi-search-text-value-trigger bi-border", + height: 30 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.htape", + items: [ + { + el: { + type: "bi.searcher", + ref: function () { + self.searcher = this; + }, + isAutoSearch: false, + el: { + type: "bi.state_editor", + ref: function () { + self.editor = this; + }, + text: this._digest(o.value, o.items), + value: o.value, + height: o.height + }, + popup: { + type: "bi.search_text_value_combo_popup", + cls: "bi-card", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE + }, + onSearch: function (obj, callback) { + var keyword = obj.keyword; + var finding = BI.Func.getSearchResult(o.items, keyword); + var matched = finding.matched, finded = finding.finded; + callback(finded, matched); + }, + listeners: [{ + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE); + } + }] + } + }, { + el: { + type: "bi.layout", + width: 30 + }, + width: 30 + } + ] + } + }, + + _setState: function (v) { + this.editor.setState(v); + }, + + _digest: function(vals, items){ + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result = []; + var formatItems = BI.Tree.transformToArrayFormat(items); + BI.each(formatItems, function (i, item) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { + result.push(item.text || item.value); + } + }); + + if (result.length > 0) { + return result.join(","); + } else { + return o.text; + } + }, + + stopEditing: function () { + this.searcher.stopSearch(); + }, + + getSearcher: function () { + return this.searcher; + }, + + populate: function (items) { + this.options.items = items; + }, + + setValue: function (vals) { + this._setState(this._digest(vals, this.options.items)); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); +BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; +BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; +BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger);/** * 单选combo * * @class BI.StaticCombo @@ -71549,7 +71891,7 @@ BI.StateEditor = BI.inherit(BI.Widget, { }); this.text = BI.createWidget({ type: "bi.text_button", - cls: "state-editor-infinite-text bi-disabled", + cls: "state-editor-infinite-text", textAlign: "left", height: o.height, text: BI.i18nText("BI-Basic_Unrestricted"), diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 2a2d6035d..22e3c2ac5 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -23,7 +23,8 @@ BI.BasicButton = BI.inherit(BI.Single, { shadow: false, isShadowShowingOnSelected: false, // 选中状态下是否显示阴影 trigger: null, - handler: BI.emptyFn + handler: BI.emptyFn, + bubble: null }); }, _init: function () { @@ -215,8 +216,70 @@ BI.BasicButton = BI.inherit(BI.Single, { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { return; } + if(BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { + if(BI.isNull(self.combo)){ + var popup; + BI.createWidget({ + type: "bi.absolute", + element: self, + items: [{ + el: { + type: "bi.bubble_combo", + trigger: "", + ref: function () { + self.combo = this; + }, + el: { + type: "bi.layout", + height: "100%" + }, + popup: { + type: "bi.text_bubble_bar_popup_view", + text: getBubble(), + ref: function () { + popup = this; + }, + listeners: [{ + eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, + action: function (v) { + self.combo.hideView(); + if(v){ + onClick.apply(self, arguments); + } + } + }] + }, + listeners: [{ + eventName: BI.BubbleCombo.EVENT_BEFORE_POPUPVIEW, + action: function () { + popup.populate(getBubble()); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }] + }); + } + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + return; + } onClick.apply(self, arguments); } + + function getBubble() { + var bubble = self.options.bubble; + if(BI.isFunction(bubble)) { + return bubble(); + } + return bubble; + } }, _trigger: function () { diff --git a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js new file mode 100644 index 000000000..370adb5f5 --- /dev/null +++ b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js @@ -0,0 +1,108 @@ +/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueCombo = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-search-text-value-combo", + height: 30, + text: "", + items: [] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.combo", + adjustLength: 2, + toggle: false, + ref: function () { + self.combo = this; + }, + el: { + type: "bi.search_text_value_trigger", + ref: function () { + self.trigger = this; + }, + items: o.items, + height: o.height - 2, + text: o.text, + value: o.value, + listeners: [{ + eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + popup: { + el:{ + type: "bi.text_value_combo_popup", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + value: o.value, + items: o.items, + ref: function () { + self.popup = this; + self.trigger.getSearcher().setAdapter(self.popup); + }, + listeners: [{ + eventName: BI.TextValueComboPopup.EVENT_CHANGE, + action: function () { + self.setValue(this.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } + }] + }, + maxHeight: 300 + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: function(){ + self.trigger.stopEditing(); + } + }] + }, + left: 0, + right: 0, + bottom: 0, + top: 0 + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height, + handler: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + }, + right: 0, + bottom: 0, + top: 0 + }] + } + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + var value = this.popup.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); + } +}); +BI.SearchTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo", BI.SearchTextValueCombo); \ No newline at end of file diff --git a/src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js new file mode 100644 index 000000000..e9da05b80 --- /dev/null +++ b/src/case/combo/searchtextvaluecombo/popup.searchtextvalue.js @@ -0,0 +1,67 @@ +/** + * Created by Windy on 2018/2/5. + */ +BI.SearchTextValueComboPopup = BI.inherit(BI.Pane, { + + props: { + baseCls: "bi-search-text-value-popup" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.button_group", + ref: function () { + self.popup = this; + }, + items: BI.createItems(o.items, { + type: "bi.single_select_item", + textAlign: o.textAlign, + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }], + behaviors: { + redmark: function () { + return true; + } + }, + value: o.value, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.SearchTextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + }] + }] + }; + }, + + populate: function (finded, matched, keyword) { + var items = BI.concat(finded, matched); + BI.SearchTextValueComboPopup.superclass.populate.apply(this, items); + items = BI.createItems(items, { + type: "bi.single_select_item", + height: 30 + }); + this.popup.populate(items, keyword); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.SearchTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_combo_popup", BI.SearchTextValueComboPopup); \ No newline at end of file diff --git a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js new file mode 100644 index 000000000..c7a3ce9f0 --- /dev/null +++ b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js @@ -0,0 +1,107 @@ +/** + * Created by Windy on 2018/2/2. + */ +BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { + + props: { + baseCls: "bi-search-text-value-trigger bi-border", + height: 30 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.htape", + items: [ + { + el: { + type: "bi.searcher", + ref: function () { + self.searcher = this; + }, + isAutoSearch: false, + el: { + type: "bi.state_editor", + ref: function () { + self.editor = this; + }, + text: this._digest(o.value, o.items), + value: o.value, + height: o.height + }, + popup: { + type: "bi.search_text_value_combo_popup", + cls: "bi-card", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE + }, + onSearch: function (obj, callback) { + var keyword = obj.keyword; + var finding = BI.Func.getSearchResult(o.items, keyword); + var matched = finding.matched, finded = finding.finded; + callback(finded, matched); + }, + listeners: [{ + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.SearchTextValueTrigger.EVENT_CHANGE); + } + }] + } + }, { + el: { + type: "bi.layout", + width: 30 + }, + width: 30 + } + ] + } + }, + + _setState: function (v) { + this.editor.setState(v); + }, + + _digest: function(vals, items){ + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result = []; + var formatItems = BI.Tree.transformToArrayFormat(items); + BI.each(formatItems, function (i, item) { + if (BI.deepContains(vals, item.value) && !result.contains(item.text || item.value)) { + result.push(item.text || item.value); + } + }); + + if (result.length > 0) { + return result.join(","); + } else { + return o.text; + } + }, + + stopEditing: function () { + this.searcher.stopSearch(); + }, + + getSearcher: function () { + return this.searcher; + }, + + populate: function (items) { + this.options.items = items; + }, + + setValue: function (vals) { + this._setState(this._digest(vals, this.options.items)); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); +BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; +BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; +BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger); \ No newline at end of file diff --git a/src/case/editor/editor.state.js b/src/case/editor/editor.state.js index bcdaf8e43..4c5a0cc03 100644 --- a/src/case/editor/editor.state.js +++ b/src/case/editor/editor.state.js @@ -45,7 +45,7 @@ BI.StateEditor = BI.inherit(BI.Widget, { }); this.text = BI.createWidget({ type: "bi.text_button", - cls: "state-editor-infinite-text bi-disabled", + cls: "state-editor-infinite-text", textAlign: "left", height: o.height, text: BI.i18nText("BI-Basic_Unrestricted"),