From 53ead60e28fc918e0ccb71e1adf65ae7eaf66690 Mon Sep 17 00:00:00 2001 From: qcc Date: Tue, 11 Sep 2018 10:22:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=E5=9C=A8=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=E6=8C=89=E4=B8=8Btab=E9=94=AE=EF=BC=8Cwatermark=E6=B6=88?= =?UTF-8?q?=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/editor/editor.js | 5 +++-- src/base/single/input/input.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 14a7dc4e5..d76838265 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -120,8 +120,9 @@ BI.Editor = BI.inherit(BI.Single, { this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) { self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments); }); - this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) { - self.watermark && self.watermark.invisible(); + this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) { + // tab键就不要隐藏了 + self.watermark && e.keyCode !== 9 && self.watermark.invisible(); }); this.editor.on(BI.Input.EVENT_VALID, function () { diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index e3bc8367c..dc59b08a9 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -37,7 +37,7 @@ BI.Input = BI.inherit(BI.Single, { .keydown(function (e) { inputEventValid = false; ctrlKey = e.ctrlKey; - self.fireEvent(BI.Input.EVENT_QUICK_DOWN); + self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments); }) .keyup(function (e) { if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) { From f52fa96a959d7e47419ef57fb439fe458d23c264 Mon Sep 17 00:00:00 2001 From: qcc Date: Tue, 11 Sep 2018 10:40:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=9B=91=E5=90=ACjq?= =?UTF-8?q?=E7=9A=84focus=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/base.js | 16 +++++++++++----- src/base/single/input/input.js | 9 +++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/dist/base.js b/dist/base.js index e09a8a02a..255e9cdad 100644 --- a/dist/base.js +++ b/dist/base.js @@ -8490,8 +8490,9 @@ BI.Editor = BI.inherit(BI.Single, { this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) { self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments); }); - this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) { - self.watermark && self.watermark.invisible(); + this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) { + // tab键就不要隐藏了 + self.watermark && e.keyCode !== 9 && self.watermark.invisible(); }); this.editor.on(BI.Input.EVENT_VALID, function () { @@ -9731,6 +9732,10 @@ BI.Input = BI.inherit(BI.Single, { "leading": true, "trailing": false }); + this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, { + "leading": true, + "trailing": false + }); this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { "leading": true, "trailing": false @@ -9739,7 +9744,7 @@ BI.Input = BI.inherit(BI.Single, { .keydown(function (e) { inputEventValid = false; ctrlKey = e.ctrlKey; - self.fireEvent(BI.Input.EVENT_QUICK_DOWN); + self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments); }) .keyup(function (e) { if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) { @@ -9762,6 +9767,9 @@ BI.Input = BI.inherit(BI.Single, { .mousedown(function (e) { self.element.val(self.element.val()); }) + .focus(function (e) { // 可以不用冒泡 + self._focusDebounce(); + }) .focusout(function (e) { self._blurDebounce(); }); @@ -9809,7 +9817,6 @@ BI.Input = BI.inherit(BI.Single, { _click: function () { if (this._isEditing !== true) { - this._focus(); this.selectAll(); this.fireEvent(BI.Input.EVENT_CLICK); } @@ -9910,7 +9917,6 @@ BI.Input = BI.inherit(BI.Single, { } if (!this._isEditing === true) { this.element.focus(); - this._focus(); this.selectAll(); } }, diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index dc59b08a9..6a15ab788 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -29,6 +29,10 @@ BI.Input = BI.inherit(BI.Single, { "leading": true, "trailing": false }); + this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, { + "leading": true, + "trailing": false + }); this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { "leading": true, "trailing": false @@ -60,6 +64,9 @@ BI.Input = BI.inherit(BI.Single, { .mousedown(function (e) { self.element.val(self.element.val()); }) + .focus(function (e) { // 可以不用冒泡 + self._focusDebounce(); + }) .focusout(function (e) { self._blurDebounce(); }); @@ -107,7 +114,6 @@ BI.Input = BI.inherit(BI.Single, { _click: function () { if (this._isEditing !== true) { - this._focus(); this.selectAll(); this.fireEvent(BI.Input.EVENT_CLICK); } @@ -208,7 +214,6 @@ BI.Input = BI.inherit(BI.Single, { } if (!this._isEditing === true) { this.element.focus(); - this._focus(); this.selectAll(); } }, From 20504c71ad464ed5ab8946f26cc4304021961516 Mon Sep 17 00:00:00 2001 From: qcc Date: Wed, 12 Sep 2018 14:19:42 +0800 Subject: [PATCH 3/4] =?UTF-8?q?tab=E9=94=AE=E4=B8=8D=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/base.js | 4 +++- src/base/single/editor/editor.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/base.js b/dist/base.js index 255e9cdad..5ed28943c 100644 --- a/dist/base.js +++ b/dist/base.js @@ -8492,7 +8492,9 @@ BI.Editor = BI.inherit(BI.Single, { }); this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) { // tab键就不要隐藏了 - self.watermark && e.keyCode !== 9 && self.watermark.invisible(); + if (e.keyCode !== BI.KeyCode.TAB && self.watermark) { + self.watermark.invisible(); + } }); this.editor.on(BI.Input.EVENT_VALID, function () { diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index d76838265..95e50a201 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -122,7 +122,9 @@ BI.Editor = BI.inherit(BI.Single, { }); this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) { // tab键就不要隐藏了 - self.watermark && e.keyCode !== 9 && self.watermark.invisible(); + if (e.keyCode !== BI.KeyCode.TAB && self.watermark) { + self.watermark.invisible(); + } }); this.editor.on(BI.Input.EVENT_VALID, function () { From 3c8b326cd63f3611f92e722737d6d58852631dfb Mon Sep 17 00:00:00 2001 From: qcc Date: Thu, 13 Sep 2018 20:04:24 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=A7=A3=E5=86=B3IE=E4=B8=8B=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E8=8E=B7=E5=BE=97=E5=85=89=E6=A0=87=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/base.js | 28 ++++++++++++++++++++-------- src/base/single/editor/editor.js | 28 ++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/dist/base.js b/dist/base.js index 5ed28943c..081618825 100644 --- a/dist/base.js +++ b/dist/base.js @@ -8444,18 +8444,30 @@ BI.Editor = BI.inherit(BI.Single, { } e.stopEvent(); }); - this.watermark.element.css({ - position: "absolute", - left: "3px", - right: "3px", - top: "0px", - bottom: "0px" + } + + var _items = []; + if (this.watermark) { + _items.push({ + el: this.watermark, + left: 3, + right: 3, + top: 0, + bottom: 0 }); } + _items.push({ + el: this.editor, + left: 0, + right: 0, + top: 0, + bottom: 0 + }); + var items = [{ el: { - type: "bi.default", - items: this.watermark ? [this.editor, this.watermark] : [this.editor] + type: "bi.absolute", + items: _items }, left: o.hgap + o.lgap, right: o.hgap + o.rgap, diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 95e50a201..7941567eb 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -74,18 +74,30 @@ BI.Editor = BI.inherit(BI.Single, { } e.stopEvent(); }); - this.watermark.element.css({ - position: "absolute", - left: "3px", - right: "3px", - top: "0px", - bottom: "0px" + } + + var _items = []; + if (this.watermark) { + _items.push({ + el: this.watermark, + left: 3, + right: 3, + top: 0, + bottom: 0 }); } + _items.push({ + el: this.editor, + left: 0, + right: 0, + top: 0, + bottom: 0 + }); + var items = [{ el: { - type: "bi.default", - items: this.watermark ? [this.editor, this.watermark] : [this.editor] + type: "bi.absolute", + items: _items }, left: o.hgap + o.lgap, right: o.hgap + o.rgap,