From 3590e340c2428ad3b1cea2b44ab7bb1c5b8d5e2c Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 1 Jul 2019 15:12:23 +0800 Subject: [PATCH] =?UTF-8?q?BI-47035=20fix:=20=E5=8D=95=E7=8B=AC=E4=BD=BF?= =?UTF-8?q?=E7=94=A8color=5Fpopup=E6=B2=A1=E6=9C=89=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/colorchooser/colorchooser.js | 6 -- src/case/colorchooser/colorchooser.popup.js | 70 ++++++++++----------- 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index d1fc4a74d1..b2e1f69996 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -64,12 +64,6 @@ BI.ColorChooser = BI.inherit(BI.Widget, { var fn = function () { var color = self.colorPicker.getValue(); self.trigger.setValue(color); - var colors = BI.string2Array(BI.Cache.getItem("colors") || ""); - var que = new BI.Queue(8); - que.fromArray(colors); - que.remove(color); - que.unshift(color); - BI.Cache.setItem("colors", BI.array2String(que.toArray())); }; this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { self.colorPicker.setStoreColors(BI.string2Array(BI.Cache.getItem("colors") || "")); diff --git a/src/case/colorchooser/colorchooser.popup.js b/src/case/colorchooser/colorchooser.popup.js index 5e4f0b87ed..2931c80a02 100644 --- a/src/case/colorchooser/colorchooser.popup.js +++ b/src/case/colorchooser/colorchooser.popup.js @@ -24,43 +24,21 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { this.colorEditor.on(BI.ColorPickerEditor.EVENT_CHANGE, function () { self.setValue(this.getValue()); + self._dealStoreColors(); self.fireEvent(BI.ColorChooserPopup.EVENT_VALUE_CHANGE, arguments); }); this.storeColors = BI.createWidget({ type: "bi.color_picker", cls: "bi-border-bottom bi-border-right", - items: [[{ - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }, { - value: "", - disabled: true - }]], + items: [this._digestStoreColors(BI.string2Array(BI.Cache.getItem("colors") || ""))], width: 210, height: 24, value: o.value }); this.storeColors.on(BI.ColorPicker.EVENT_CHANGE, function () { self.setValue(this.getValue()[0]); + self._dealStoreColors(); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); }); @@ -73,6 +51,7 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { this.colorPicker.on(BI.ColorPicker.EVENT_CHANGE, function () { self.setValue(this.getValue()[0]); + self._dealStoreColors(); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); }); @@ -120,6 +99,7 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { break; case 1: self.setValue(self.customColorChooser.getValue()); + self._dealStoreColors(); self.more.hideView(); self.fireEvent(BI.ColorChooserPopup.EVENT_CHANGE, arguments); break; @@ -193,20 +173,36 @@ BI.ColorChooserPopup = BI.inherit(BI.Widget, { this.mask.setVisible(!enable); }, + _dealStoreColors: function () { + var color = this.getValue(); + var colors = BI.string2Array(BI.Cache.getItem("colors") || ""); + var que = new BI.Queue(8); + que.fromArray(colors); + que.remove(color); + que.unshift(color); + var array = que.toArray(); + BI.Cache.setItem("colors", BI.array2String(array)); + this.setStoreColors(array); + }, + + _digestStoreColors: function (colors) { + var items = BI.map(colors, function (i, color) { + return { + value: color + }; + }); + BI.count(colors.length, 8, function (i) { + items.push({ + value: "", + disabled: true + }); + }); + return items; + }, + setStoreColors: function (colors) { if (BI.isArray(colors)) { - var items = BI.map(colors, function (i, color) { - return { - value: color - }; - }); - BI.count(colors.length, 8, function (i) { - items.push({ - value: "", - disabled: true - }); - }); - this.storeColors.populate([items]); + this.storeColors.populate([this._digestStoreColors(colors)]); } },