From 9d8436115a07d0236e76cdf770e638823b72701f Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Fri, 7 May 2021 16:37:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20chore:=20?= =?UTF-8?q?=E5=88=A0=E6=8E=89click-blur,=20=E6=97=A0=E4=BB=BB=E4=BD=95?= =?UTF-8?q?=E6=99=AE=E9=80=82=E6=80=A7=E7=9A=84=E4=B8=9C=E8=A5=BF=E4=B8=8D?= =?UTF-8?q?=E9=80=82=E5=90=88=E6=94=BE=E5=88=B0=E6=88=90=E7=86=9F=E7=9A=84?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 平台业务上要用平台自己封装了 click-blur的控件 --- src/base/combination/combo.js | 77 ++++++++--------------------------- 1 file changed, 18 insertions(+), 59 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 543d5fed7..1e63ec054 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -12,7 +12,7 @@ attributes: { tabIndex: -1 }, - trigger: "click", + trigger: "click", // click || hover || click-hover || "" toggle: true, direction: "bottom", // top||bottom||left||right||top,left||top,right||bottom,left||bottom,right||right,innerRight||right,innerLeft||innerRight||innerLeft logic: { @@ -182,62 +182,16 @@ }); break; case "click-hover": - case "click-blur": - // IE走click-hover逻辑 - if (BI.isIE() || ev === "click-hover") { - var debounce = BI.debounce(function (e) { - if (self.combo.element.__isMouseInBounds__(e)) { - if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) { - // if (self.isViewVisible()) { - // return; - // } - self._popupView(e); - if (self.isViewVisible()) { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); - self.fireEvent(BI.Combo.EVENT_EXPAND); - } - } - } - }, BI.EVENT_RESPONSE_TIME, { - "leading": true, - "trailing": false - }); - self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) { - debounce(e); - st(e); - }); - self.element.on("mouseleave." + self.getName(), function (e) { - if (self.popupView) { - self.popupView.element.on("mouseenter." + self.getName(), function (e) { - enterPopup = true; - self.popupView.element.on("mouseleave." + self.getName(), function (e) { - hide(e); - }); - self.popupView.element.off("mouseenter." + self.getName()); - }); - BI.defer(function () { - if (!enterPopup) { - hide(e); - } - }, 50); - } - }); - break; - } - var debounce = BI.debounce(function (e) { if (self.combo.element.__isMouseInBounds__(e)) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) { - // if (!o.toggle && self.isViewVisible()) { + // if (self.isViewVisible()) { // return; // } - o.toggle ? self._toggle(e) : self._popupView(e); + self._popupView(e); if (self.isViewVisible()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Combo.EVENT_EXPAND); - } else { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); - self.fireEvent(BI.Combo.EVENT_COLLAPSE); } } } @@ -247,18 +201,23 @@ }); self.element.off("click." + self.getName()).on("click." + self.getName(), function (e) { debounce(e); - try { - self.element[0].focus(); - } catch (e) { - - } st(e); }); - self.element.off("blur." + self.getName()).on("blur." + self.getName(), function (e) { - if (self.isViewVisible()) { - self._hideView(e); + self.element.on("mouseleave." + self.getName(), function (e) { + if (self.popupView) { + self.popupView.element.on("mouseenter." + self.getName(), function (e) { + enterPopup = true; + self.popupView.element.on("mouseleave." + self.getName(), function (e) { + hide(e); + }); + self.popupView.element.off("mouseenter." + self.getName()); + }); + BI.delay(function () { + if (!enterPopup) { + hide(e); + } + }, 50); } - st(e); }); break; } @@ -353,7 +312,7 @@ this._assertPopupViewRender(); this.fireEvent(BI.Combo.EVENT_BEFORE_POPUPVIEW); // popupVisible是为了获取其宽高, 放到可视范围之外以防止在IE下闪一下 - this.popupView.css({left: -999999999, top: -99999999}); + this.popupView.css({ left: -999999999, top: -99999999 }); this.popupView.visible(); BI.each(needHideWhenAnotherComboOpen, function (i, combo) { if (i !== self.getName()) {