Browse Source

Pull request #3171: KERNEL-13158: 优化button

Merge in VISUAL/fineui from ~GUY/fineui:master to master

* commit 'cd0ce2d02abbb2c8f9abaf9cbbcb58e90aa03733':
  KERNEL-13158: 优化button
es6
guy-王川 2 years ago
parent
commit
918aba9723
  1. 23
      src/base/single/button/button.basic.js

23
src/base/single/button/button.basic.js

@ -184,7 +184,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
var mouseDown = false; var mouseDown = false;
var interval; var interval;
hand.mousedown(function (e) { hand.mousedown(function (e) {
BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function (e) { BI.Widget._renderEngine.createElement(document).bind("mouseup." + self.getName(), function () {
interval && clearInterval(interval); interval && clearInterval(interval);
interval = null; interval = null;
mouseDown = false; mouseDown = false;
@ -193,13 +193,14 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (mouseDown === true) { if (mouseDown === true) {
return; return;
} }
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || !self.isValid()) {
return; return;
} }
interval = setInterval(function () { if (self.isOnce() && self.isSelected()) {
if (self.isEnabled()) { return;
self.doClick();
} }
interval = setInterval(function () {
clk(e)
}, 180); }, 180);
mouseDown = true; mouseDown = true;
ev(e); ev(e);
@ -239,7 +240,10 @@ BI.BasicButton = BI.inherit(BI.Single, {
function clk(e) { function clk(e) {
ev(e); ev(e);
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { if (!self.isEnabled() || !self.isValid()) {
return;
}
if (self.isOnce() && self.isSelected()) {
return; return;
} }
if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) { if (BI.isKey(o.bubble) || BI.isFunction(o.bubble)) {
@ -335,16 +339,17 @@ BI.BasicButton = BI.inherit(BI.Single, {
}, },
_doClick: function (e) { _doClick: function (e) {
if (this.isValid()) { if (!this.isEnabled() || !this.isValid()) {
return;
}
var isIntercepted = this.beforeClick(e); var isIntercepted = this.beforeClick(e);
// 如果事件已经被消费掉了,就不再触发点击事件 // 如果事件已经被消费掉了,就不再触发点击事件
if (isIntercepted) { if (isIntercepted) {
return; return;
} }
}
this._trigger(e); this._trigger(e);
if (this.isValid()) { if (this.isEnabled() && this.isValid()) {
this.doClick(e); this.doClick(e);
} }
}, },

Loading…
Cancel
Save