Browse Source

KERNEL-13158: 优化button

es6
guy 2 years ago
parent
commit
cd0ce2d02a
  1. 31
      src/base/single/button/button.basic.js

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

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

Loading…
Cancel
Save