diff --git a/bi/case.js b/bi/case.js index 13a56df0b5..eba3582de6 100644 --- a/bi/case.js +++ b/bi/case.js @@ -5458,6 +5458,125 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { }); BI.IconComboTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_combo_trigger", BI.IconComboTrigger);/** + * Created by Windy on 2017/12/12. + * combo : icon + text + icon, popup : icon + text + */ +BI.IconTextValueCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { + baseClass: "bi-icon-text-value-combo", + height: 30, + text: "", + el: {} + }) + }, + + _init: function () { + BI.IconTextValueCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget(o.el, { + type: "bi.select_icon_text_trigger", + items: o.items, + height: o.height, + text: o.text + }); + this.popup = BI.createWidget({ + type: "bi.icon_text_value_combo_popup", + items: o.items + }); + this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.textIconCombo.hideView(); + self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments); + }); + this.popup.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.textIconCombo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup, + maxHeight: 300 + } + }); + }, + + setValue: function (v) { + this.textIconCombo.setValue(v); + }, + + getValue: function () { + return this.textIconCombo.getValue(); + }, + + populate: function (items) { + this.options.items = items; + this.textIconCombo.populate(items); + } +}); +BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo);/** + * Created by Windy on 2017/12/12. + */ +BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-icon-text-icon-popup" + }); + }, + + _init: function () { + BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + this.popup = BI.createWidget({ + type: "bi.button_group", + items: BI.createItems(o.items, { + type: "bi.single_select_icon_text_item", + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }] + }); + + this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); + } + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + }, + + populate: function (items) { + BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); + items = BI.createItems(items, { + type: "bi.single_select_icon_text_item", + height: 30 + }); + this.popup.populate(items); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** * 单选combo * * @class BI.StaticCombo @@ -13544,6 +13663,60 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, { } }); BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/** + * Created by Windy on 2017/12/12. + */ +BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SelectIconTextTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-text-trigger bi-border", + height: 24 + }); + }, + + _init: function () { + this.options.height -= 2; + BI.SelectIconTextTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget({ + type: "bi.icon_text_trigger", + element: this, + height: o.height + }); + if (BI.isKey(o.text)) { + this.setValue(o.text); + } + }, + + setValue: function (vals) { + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result; + var items = BI.Tree.transformToArrayFormat(this.options.items); + BI.any(items, function (i, item) { + if (BI.deepContains(vals, item.value)) { + result = { + text: item.text || item.value, + iconClass: item.iconClass + }; + return true; + } + }); + + if (BI.isNotNull(result)) { + this.trigger.setText(result.text); + this.trigger.setIcon(result.iconClass); + } else { + this.trigger.setText(o.text); + this.trigger.setIcon(""); + } + }, + + populate: function (items) { + this.options.items = items; + } +}); +BI.shortcut("bi.select_icon_text_trigger", BI.SelectIconTextTrigger);/** * 文字trigger * * Created by GUY on 2015/9/15. diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 118c8a6178..4e3fe9fc07 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -10,17 +10,20 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { return { type: "bi.horizontal_auto", items: [{ - type: "bi.text_value_combo", + type: "bi.icon_text_value_combo", text: "默认值", width: 300, items: [{ text: "MVC-1", + iconClass: "date-font", value: 1 }, { text: "MVC-2", + iconClass: "search-font", value: 2 }, { text: "MVC-3", + iconClass: "pull-right-font", value: 3 }] }], diff --git a/dist/bundle.js b/dist/bundle.js index cfdb6c9f36..ea0a5768bd 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -66934,6 +66934,125 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { }); BI.IconComboTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_combo_trigger", BI.IconComboTrigger);/** + * Created by Windy on 2017/12/12. + * combo : icon + text + icon, popup : icon + text + */ +BI.IconTextValueCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { + baseClass: "bi-icon-text-value-combo", + height: 30, + text: "", + el: {} + }) + }, + + _init: function () { + BI.IconTextValueCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget(o.el, { + type: "bi.select_icon_text_trigger", + items: o.items, + height: o.height, + text: o.text + }); + this.popup = BI.createWidget({ + type: "bi.icon_text_value_combo_popup", + items: o.items + }); + this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.textIconCombo.hideView(); + self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments); + }); + this.popup.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.textIconCombo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup, + maxHeight: 300 + } + }); + }, + + setValue: function (v) { + this.textIconCombo.setValue(v); + }, + + getValue: function () { + return this.textIconCombo.getValue(); + }, + + populate: function (items) { + this.options.items = items; + this.textIconCombo.populate(items); + } +}); +BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo);/** + * Created by Windy on 2017/12/12. + */ +BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-icon-text-icon-popup" + }); + }, + + _init: function () { + BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + this.popup = BI.createWidget({ + type: "bi.button_group", + items: BI.createItems(o.items, { + type: "bi.single_select_icon_text_item", + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }] + }); + + this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); + } + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + }, + + populate: function (items) { + BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); + items = BI.createItems(items, { + type: "bi.single_select_icon_text_item", + height: 30 + }); + this.popup.populate(items); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** * 单选combo * * @class BI.StaticCombo @@ -75020,6 +75139,60 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, { } }); BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/** + * Created by Windy on 2017/12/12. + */ +BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SelectIconTextTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-text-trigger bi-border", + height: 24 + }); + }, + + _init: function () { + this.options.height -= 2; + BI.SelectIconTextTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget({ + type: "bi.icon_text_trigger", + element: this, + height: o.height + }); + if (BI.isKey(o.text)) { + this.setValue(o.text); + } + }, + + setValue: function (vals) { + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result; + var items = BI.Tree.transformToArrayFormat(this.options.items); + BI.any(items, function (i, item) { + if (BI.deepContains(vals, item.value)) { + result = { + text: item.text || item.value, + iconClass: item.iconClass + }; + return true; + } + }); + + if (BI.isNotNull(result)) { + this.trigger.setText(result.text); + this.trigger.setIcon(result.iconClass); + } else { + this.trigger.setText(o.text); + this.trigger.setIcon(""); + } + }, + + populate: function (items) { + this.options.items = items; + } +}); +BI.shortcut("bi.select_icon_text_trigger", BI.SelectIconTextTrigger);/** * 文字trigger * * Created by GUY on 2015/9/15. diff --git a/dist/case.js b/dist/case.js index 13a56df0b5..eba3582de6 100644 --- a/dist/case.js +++ b/dist/case.js @@ -5458,6 +5458,125 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { }); BI.IconComboTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.shortcut("bi.icon_combo_trigger", BI.IconComboTrigger);/** + * Created by Windy on 2017/12/12. + * combo : icon + text + icon, popup : icon + text + */ +BI.IconTextValueCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { + baseClass: "bi-icon-text-value-combo", + height: 30, + text: "", + el: {} + }) + }, + + _init: function () { + BI.IconTextValueCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget(o.el, { + type: "bi.select_icon_text_trigger", + items: o.items, + height: o.height, + text: o.text + }); + this.popup = BI.createWidget({ + type: "bi.icon_text_value_combo_popup", + items: o.items + }); + this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.textIconCombo.hideView(); + self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments); + }); + this.popup.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.textIconCombo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup, + maxHeight: 300 + } + }); + }, + + setValue: function (v) { + this.textIconCombo.setValue(v); + }, + + getValue: function () { + return this.textIconCombo.getValue(); + }, + + populate: function (items) { + this.options.items = items; + this.textIconCombo.populate(items); + } +}); +BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo);/** + * Created by Windy on 2017/12/12. + */ +BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-icon-text-icon-popup" + }); + }, + + _init: function () { + BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + this.popup = BI.createWidget({ + type: "bi.button_group", + items: BI.createItems(o.items, { + type: "bi.single_select_icon_text_item", + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }] + }); + + this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); + } + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + }, + + populate: function (items) { + BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); + items = BI.createItems(items, { + type: "bi.single_select_icon_text_item", + height: 30 + }); + this.popup.populate(items); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup);/** * 单选combo * * @class BI.StaticCombo @@ -13544,6 +13663,60 @@ BI.IconTextTrigger = BI.inherit(BI.Trigger, { } }); BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/** + * Created by Windy on 2017/12/12. + */ +BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SelectIconTextTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-text-trigger bi-border", + height: 24 + }); + }, + + _init: function () { + this.options.height -= 2; + BI.SelectIconTextTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget({ + type: "bi.icon_text_trigger", + element: this, + height: o.height + }); + if (BI.isKey(o.text)) { + this.setValue(o.text); + } + }, + + setValue: function (vals) { + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result; + var items = BI.Tree.transformToArrayFormat(this.options.items); + BI.any(items, function (i, item) { + if (BI.deepContains(vals, item.value)) { + result = { + text: item.text || item.value, + iconClass: item.iconClass + }; + return true; + } + }); + + if (BI.isNotNull(result)) { + this.trigger.setText(result.text); + this.trigger.setIcon(result.iconClass); + } else { + this.trigger.setText(o.text); + this.trigger.setIcon(""); + } + }, + + populate: function (items) { + this.options.items = items; + } +}); +BI.shortcut("bi.select_icon_text_trigger", BI.SelectIconTextTrigger);/** * 文字trigger * * Created by GUY on 2015/9/15. diff --git a/dist/demo.js b/dist/demo.js index 8c79fc06b6..6868997399 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -1820,17 +1820,20 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { return { type: "bi.horizontal_auto", items: [{ - type: "bi.text_value_combo", + type: "bi.icon_text_value_combo", text: "默认值", width: 300, items: [{ text: "MVC-1", + iconClass: "date-font", value: 1 }, { text: "MVC-2", + iconClass: "search-font", value: 2 }, { text: "MVC-3", + iconClass: "pull-right-font", value: 3 }] }], diff --git a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js new file mode 100644 index 0000000000..d2d9fadf26 --- /dev/null +++ b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js @@ -0,0 +1,62 @@ +/** + * Created by Windy on 2017/12/12. + * combo : icon + text + icon, popup : icon + text + */ +BI.IconTextValueCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueCombo.superclass._defaultConfig.apply(this, arguments), { + baseClass: "bi-icon-text-value-combo", + height: 30, + text: "", + el: {} + }) + }, + + _init: function () { + BI.IconTextValueCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget(o.el, { + type: "bi.select_icon_text_trigger", + items: o.items, + height: o.height, + text: o.text + }); + this.popup = BI.createWidget({ + type: "bi.icon_text_value_combo_popup", + items: o.items + }); + this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.textIconCombo.hideView(); + self.fireEvent(BI.IconTextValueCombo.EVENT_CHANGE, arguments); + }); + this.popup.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.textIconCombo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup, + maxHeight: 300 + } + }); + }, + + setValue: function (v) { + this.textIconCombo.setValue(v); + }, + + getValue: function () { + return this.textIconCombo.getValue(); + }, + + populate: function (items) { + this.options.items = items; + this.textIconCombo.populate(items); + } +}); +BI.IconTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo", BI.IconTextValueCombo); \ No newline at end of file diff --git a/src/case/combo/icontextvaluecombo/popup.icontextvalue.js b/src/case/combo/icontextvaluecombo/popup.icontextvalue.js new file mode 100644 index 0000000000..2f1c30537c --- /dev/null +++ b/src/case/combo/icontextvaluecombo/popup.icontextvalue.js @@ -0,0 +1,59 @@ +/** + * Created by Windy on 2017/12/12. + */ +BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { + _defaultConfig: function () { + return BI.extend(BI.IconTextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-icon-text-icon-popup" + }); + }, + + _init: function () { + BI.IconTextValueComboPopup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + this.popup = BI.createWidget({ + type: "bi.button_group", + items: BI.createItems(o.items, { + type: "bi.single_select_icon_text_item", + height: 30 + }), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + layouts: [{ + type: "bi.vertical" + }] + }); + + this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.IconTextValueComboPopup.EVENT_CHANGE, val, obj); + } + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + }, + + populate: function (items) { + BI.IconTextValueComboPopup.superclass.populate.apply(this, arguments); + items = BI.createItems(items, { + type: "bi.single_select_icon_text_item", + height: 30 + }); + this.popup.populate(items); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + this.popup.setValue(v); + } + +}); +BI.IconTextValueComboPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.icon_text_value_combo_popup", BI.IconTextValueComboPopup); \ No newline at end of file diff --git a/src/case/trigger/trigger.icon.text.select.js b/src/case/trigger/trigger.icon.text.select.js new file mode 100644 index 0000000000..984b920ecf --- /dev/null +++ b/src/case/trigger/trigger.icon.text.select.js @@ -0,0 +1,55 @@ +/** + * Created by Windy on 2017/12/12. + */ +BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SelectIconTextTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-text-trigger bi-border", + height: 24 + }); + }, + + _init: function () { + this.options.height -= 2; + BI.SelectIconTextTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.trigger = BI.createWidget({ + type: "bi.icon_text_trigger", + element: this, + height: o.height + }); + if (BI.isKey(o.text)) { + this.setValue(o.text); + } + }, + + setValue: function (vals) { + var o = this.options; + vals = BI.isArray(vals) ? vals : [vals]; + var result; + var items = BI.Tree.transformToArrayFormat(this.options.items); + BI.any(items, function (i, item) { + if (BI.deepContains(vals, item.value)) { + result = { + text: item.text || item.value, + iconClass: item.iconClass + }; + return true; + } + }); + + if (BI.isNotNull(result)) { + this.trigger.setText(result.text); + this.trigger.setIcon(result.iconClass); + } else { + this.trigger.setText(o.text); + this.trigger.setIcon(""); + } + }, + + populate: function (items) { + this.options.items = items; + } +}); +BI.shortcut("bi.select_icon_text_trigger", BI.SelectIconTextTrigger); \ No newline at end of file