From 1ca816251f6d04e1752841adff752f239c6a2a15 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 18 Jan 2018 08:51:12 +0800 Subject: [PATCH] =?UTF-8?q?icon=5Fcombo=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/case/combo/demo.icon_combo.js | 2 +- dist/base.js | 4 +- dist/bundle.js | 53 ++++++++++++------- dist/case.js | 49 ++++++++++------- dist/demo.js | 2 +- dist/fineui.js | 53 ++++++++++++------- src/base/combination/combo.js | 4 +- src/case/combo/iconcombo/combo.icon.js | 7 +-- src/case/combo/iconcombo/popup.iconcombo.js | 3 +- src/case/combo/iconcombo/trigger.iconcombo.js | 39 +++++++++----- 10 files changed, 138 insertions(+), 78 deletions(-) diff --git a/demo/js/case/combo/demo.icon_combo.js b/demo/js/case/combo/demo.icon_combo.js index 6aee330c9..bdd90d423 100644 --- a/demo/js/case/combo/demo.icon_combo.js +++ b/demo/js/case/combo/demo.icon_combo.js @@ -19,7 +19,7 @@ Demo.IconCombo = BI.inherit(BI.Widget, { ref: function (_ref) { self.refs = _ref; }, - iconCls: "search-font", + value: "第二项", items: [{ value: "第一项", iconCls: "close-font" diff --git a/dist/base.js b/dist/base.js index 0b650c665..36476b086 100644 --- a/dist/base.js +++ b/dist/base.js @@ -3179,7 +3179,9 @@ BI.Combo = BI.inherit(BI.Widget, { // return; // } // BI-10290 公式combo双击公式内容会收起 - if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 + if (this.element.find(e.target).length > 0 + || (this.popupView && this.popupView.element.find(e.target).length > 0) + || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 return; } var isHide = this.options.hideChecker.apply(this, [e]); diff --git a/dist/bundle.js b/dist/bundle.js index 04ac76115..4aa53b333 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -29052,7 +29052,9 @@ BI.Combo = BI.inherit(BI.Widget, { // return; // } // BI-10290 公式combo双击公式内容会收起 - if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 + if (this.element.find(e.target).length > 0 + || (this.popupView && this.popupView.element.find(e.target).length > 0) + || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 return; } var isHide = this.options.hideChecker.apply(this, [e]); @@ -67494,7 +67496,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { baseCls: "bi-icon-combo", width: 24, height: 24, - iconCls: "", el: {}, popup: {}, minWidth: 100, @@ -67520,12 +67521,14 @@ BI.IconCombo = BI.inherit(BI.Widget, { width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + value: o.value }); this.popup = BI.createWidget(o.popup, { type: "bi.icon_combo_popup", chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -67603,7 +67606,8 @@ BI.IconComboPopup = BI.inherit(BI.Pane, { chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -67654,28 +67658,35 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { iconCls: "", width: 25, height: 25, - isShowDown: true + isShowDown: true, + value: "" }); }, _init: function () { BI.IconComboTrigger.superclass._init.apply(this, arguments); var o = this.options, self = this; + var iconCls = ""; + if(BI.isKey(o.value)){ + iconCls = this._digest(o.value, o.items); + } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + o.iconCls, + cls: "icon-combo-trigger-icon " + iconCls, disableSelected: true, width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + selected: BI.isNotEmptyString(iconCls) }); this.down = BI.createWidget({ type: "bi.icon_button", disableSelected: true, cls: "icon-combo-down-icon trigger-triangle-font", width: 12, - height: 8 + height: 8, + selected: BI.isNotEmptyString(iconCls) }); this.down.setVisible(o.isShowDown); BI.createWidget({ @@ -67693,9 +67704,18 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { bottom: 0 }] }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } + }, + + _digest: function (v, items) { + var iconCls = ""; + v = BI.isArray(v) ? v[0] : v; + BI.any(items, function (i, item) { + if (v === item.value) { + iconCls = item.iconCls; + return true; + } + }); + return iconCls; }, populate: function (items) { @@ -67709,14 +67729,9 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { setValue: function (v) { BI.IconComboTrigger.superclass.setValue.apply(this, arguments); var o = this.options; - var iconCls = ""; + var iconCls = this._digest(v, this.options.items); v = BI.isArray(v) ? v[0] : v; - if (BI.any(this.options.items, function (i, item) { - if (v === item.value) { - iconCls = item.iconCls; - return true; - } - })) { + if (BI.isNotEmptyString(iconCls)) { this.button.setIcon(iconCls); this.button.setSelected(true); this.down.setSelected(true); diff --git a/dist/case.js b/dist/case.js index ed169fcb2..8ad70c5e8 100644 --- a/dist/case.js +++ b/dist/case.js @@ -5214,7 +5214,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { baseCls: "bi-icon-combo", width: 24, height: 24, - iconCls: "", el: {}, popup: {}, minWidth: 100, @@ -5240,12 +5239,14 @@ BI.IconCombo = BI.inherit(BI.Widget, { width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + value: o.value }); this.popup = BI.createWidget(o.popup, { type: "bi.icon_combo_popup", chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -5323,7 +5324,8 @@ BI.IconComboPopup = BI.inherit(BI.Pane, { chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -5374,28 +5376,35 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { iconCls: "", width: 25, height: 25, - isShowDown: true + isShowDown: true, + value: "" }); }, _init: function () { BI.IconComboTrigger.superclass._init.apply(this, arguments); var o = this.options, self = this; + var iconCls = ""; + if(BI.isKey(o.value)){ + iconCls = this._digest(o.value, o.items); + } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + o.iconCls, + cls: "icon-combo-trigger-icon " + iconCls, disableSelected: true, width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + selected: BI.isNotEmptyString(iconCls) }); this.down = BI.createWidget({ type: "bi.icon_button", disableSelected: true, cls: "icon-combo-down-icon trigger-triangle-font", width: 12, - height: 8 + height: 8, + selected: BI.isNotEmptyString(iconCls) }); this.down.setVisible(o.isShowDown); BI.createWidget({ @@ -5413,9 +5422,18 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { bottom: 0 }] }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } + }, + + _digest: function (v, items) { + var iconCls = ""; + v = BI.isArray(v) ? v[0] : v; + BI.any(items, function (i, item) { + if (v === item.value) { + iconCls = item.iconCls; + return true; + } + }); + return iconCls; }, populate: function (items) { @@ -5429,14 +5447,9 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { setValue: function (v) { BI.IconComboTrigger.superclass.setValue.apply(this, arguments); var o = this.options; - var iconCls = ""; + var iconCls = this._digest(v, this.options.items); v = BI.isArray(v) ? v[0] : v; - if (BI.any(this.options.items, function (i, item) { - if (v === item.value) { - iconCls = item.iconCls; - return true; - } - })) { + if (BI.isNotEmptyString(iconCls)) { this.button.setIcon(iconCls); this.button.setSelected(true); this.down.setSelected(true); diff --git a/dist/demo.js b/dist/demo.js index 21e78b236..58269ed2a 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -1801,7 +1801,7 @@ Demo.IconCombo = BI.inherit(BI.Widget, { ref: function (_ref) { self.refs = _ref; }, - iconCls: "search-font", + value: "第二项", items: [{ value: "第一项", iconCls: "close-font" diff --git a/dist/fineui.js b/dist/fineui.js index 8743bd607..328742b88 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -30746,7 +30746,9 @@ BI.Combo = BI.inherit(BI.Widget, { // return; // } // BI-10290 公式combo双击公式内容会收起 - if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 + if (this.element.find(e.target).length > 0 + || (this.popupView && this.popupView.element.find(e.target).length > 0) + || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 return; } var isHide = this.options.hideChecker.apply(this, [e]); @@ -69188,7 +69190,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { baseCls: "bi-icon-combo", width: 24, height: 24, - iconCls: "", el: {}, popup: {}, minWidth: 100, @@ -69214,12 +69215,14 @@ BI.IconCombo = BI.inherit(BI.Widget, { width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + value: o.value }); this.popup = BI.createWidget(o.popup, { type: "bi.icon_combo_popup", chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -69297,7 +69300,8 @@ BI.IconComboPopup = BI.inherit(BI.Pane, { chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -69348,28 +69352,35 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { iconCls: "", width: 25, height: 25, - isShowDown: true + isShowDown: true, + value: "" }); }, _init: function () { BI.IconComboTrigger.superclass._init.apply(this, arguments); var o = this.options, self = this; + var iconCls = ""; + if(BI.isKey(o.value)){ + iconCls = this._digest(o.value, o.items); + } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + o.iconCls, + cls: "icon-combo-trigger-icon " + iconCls, disableSelected: true, width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + selected: BI.isNotEmptyString(iconCls) }); this.down = BI.createWidget({ type: "bi.icon_button", disableSelected: true, cls: "icon-combo-down-icon trigger-triangle-font", width: 12, - height: 8 + height: 8, + selected: BI.isNotEmptyString(iconCls) }); this.down.setVisible(o.isShowDown); BI.createWidget({ @@ -69387,9 +69398,18 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { bottom: 0 }] }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } + }, + + _digest: function (v, items) { + var iconCls = ""; + v = BI.isArray(v) ? v[0] : v; + BI.any(items, function (i, item) { + if (v === item.value) { + iconCls = item.iconCls; + return true; + } + }); + return iconCls; }, populate: function (items) { @@ -69403,14 +69423,9 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { setValue: function (v) { BI.IconComboTrigger.superclass.setValue.apply(this, arguments); var o = this.options; - var iconCls = ""; + var iconCls = this._digest(v, this.options.items); v = BI.isArray(v) ? v[0] : v; - if (BI.any(this.options.items, function (i, item) { - if (v === item.value) { - iconCls = item.iconCls; - return true; - } - })) { + if (BI.isNotEmptyString(iconCls)) { this.button.setIcon(iconCls); this.button.setSelected(true); this.down.setSelected(true); diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index e6ac9d0a3..3ea38211a 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -255,7 +255,9 @@ BI.Combo = BI.inherit(BI.Widget, { // return; // } // BI-10290 公式combo双击公式内容会收起 - if (this.element.find(e.target).length > 0 || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 + if (this.element.find(e.target).length > 0 + || (this.popupView && this.popupView.element.find(e.target).length > 0) + || e.target.className === "CodeMirror-cursor" || $(e.target).closest(".CodeMirror-hints").length > 0) {// BI-9887 CodeMirror的公式弹框需要特殊处理下 return; } var isHide = this.options.hideChecker.apply(this, [e]); diff --git a/src/case/combo/iconcombo/combo.icon.js b/src/case/combo/iconcombo/combo.icon.js index 00f556c2d..39799527f 100644 --- a/src/case/combo/iconcombo/combo.icon.js +++ b/src/case/combo/iconcombo/combo.icon.js @@ -10,7 +10,6 @@ BI.IconCombo = BI.inherit(BI.Widget, { baseCls: "bi-icon-combo", width: 24, height: 24, - iconCls: "", el: {}, popup: {}, minWidth: 100, @@ -36,12 +35,14 @@ BI.IconCombo = BI.inherit(BI.Widget, { width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + value: o.value }); this.popup = BI.createWidget(o.popup, { type: "bi.icon_combo_popup", chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); diff --git a/src/case/combo/iconcombo/popup.iconcombo.js b/src/case/combo/iconcombo/popup.iconcombo.js index 419c85d41..1bcccefa7 100644 --- a/src/case/combo/iconcombo/popup.iconcombo.js +++ b/src/case/combo/iconcombo/popup.iconcombo.js @@ -24,7 +24,8 @@ BI.IconComboPopup = BI.inherit(BI.Pane, { chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { diff --git a/src/case/combo/iconcombo/trigger.iconcombo.js b/src/case/combo/iconcombo/trigger.iconcombo.js index 09d0f66d8..0f3f7d635 100644 --- a/src/case/combo/iconcombo/trigger.iconcombo.js +++ b/src/case/combo/iconcombo/trigger.iconcombo.js @@ -13,28 +13,35 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { iconCls: "", width: 25, height: 25, - isShowDown: true + isShowDown: true, + value: "" }); }, _init: function () { BI.IconComboTrigger.superclass._init.apply(this, arguments); var o = this.options, self = this; + var iconCls = ""; + if(BI.isKey(o.value)){ + iconCls = this._digest(o.value, o.items); + } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + o.iconCls, + cls: "icon-combo-trigger-icon " + iconCls, disableSelected: true, width: o.width, height: o.height, iconWidth: o.iconWidth, - iconHeight: o.iconHeight + iconHeight: o.iconHeight, + selected: BI.isNotEmptyString(iconCls) }); this.down = BI.createWidget({ type: "bi.icon_button", disableSelected: true, cls: "icon-combo-down-icon trigger-triangle-font", width: 12, - height: 8 + height: 8, + selected: BI.isNotEmptyString(iconCls) }); this.down.setVisible(o.isShowDown); BI.createWidget({ @@ -52,9 +59,18 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { bottom: 0 }] }); - if (BI.isKey(o.value)) { - this.setValue(o.value); - } + }, + + _digest: function (v, items) { + var iconCls = ""; + v = BI.isArray(v) ? v[0] : v; + BI.any(items, function (i, item) { + if (v === item.value) { + iconCls = item.iconCls; + return true; + } + }); + return iconCls; }, populate: function (items) { @@ -68,14 +84,9 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { setValue: function (v) { BI.IconComboTrigger.superclass.setValue.apply(this, arguments); var o = this.options; - var iconCls = ""; + var iconCls = this._digest(v, this.options.items); v = BI.isArray(v) ? v[0] : v; - if (BI.any(this.options.items, function (i, item) { - if (v === item.value) { - iconCls = item.iconCls; - return true; - } - })) { + if (BI.isNotEmptyString(iconCls)) { this.button.setIcon(iconCls); this.button.setSelected(true); this.down.setSelected(true);