Browse Source

Merge pull request #27 in ~GUY/fineui from ~WINDY/fineui:master to master

* commit '9b446078cb656f62c09046b3106afc447e28eb4d':
  长按button
es6
windy 8 years ago
parent
commit
6e3b8ff49b
  1. 168
      bi/base.js
  2. 4
      bi/widget.js
  3. 168
      docs/base.js
  4. 4
      docs/widget.js
  5. 168
      src/base/single/button/button.basic.js
  6. 4
      src/widget/finetuningnumbereditor/finetuning.number.editor.js

168
bi/base.js

@ -685,95 +685,99 @@ BI.BasicButton = BI.inherit(BI.Single, {
return; return;
} }
hand = hand.element; hand = hand.element;
switch (o.trigger) { var triggerArr = (o.trigger || "").split(",");
case "mouseup": BI.each(triggerArr, function (idx, trigger) {
var mouseDown = false; switch (trigger) {
hand.mousedown(function () { case "mouseup":
mouseDown = true; var mouseDown = false;
ev(e); hand.mousedown(function () {
}); mouseDown = true;
hand.mouseup(function (e) { ev(e);
if (mouseDown === true) { });
clk(e); hand.mouseup(function (e) {
} if (mouseDown === true) {
mouseDown = false; clk(e);
ev(e);
});
break;
case "mousedown":
var mouseDown = false;
var selected = false;
hand.mousedown(function (e) {
// if (e.button === 0) {
$(document).bind("mouseup." + self.getName(), function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
self.setSelected(!self.isSelected());
self._trigger();
} }
mouseDown = false; mouseDown = false;
$(document).unbind("mouseup." + self.getName()); ev(e);
});
break;
case "mousedown":
var mouseDown = false;
var selected = false;
hand.mousedown(function (e) {
// if (e.button === 0) {
$(document).bind("mouseup." + self.getName(), function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
self.setSelected(!self.isSelected());
self._trigger();
}
mouseDown = false;
$(document).unbind("mouseup." + self.getName());
// }
});
if (mouseDown === true) {
return;
}
if (self.isSelected()) {
selected = true;
} else {
clk(e);
}
mouseDown = true;
ev(e);
// } // }
}); });
if (mouseDown === true) { hand.mouseup(function (e) {
return; // if (e.button === 0) {
} if (BI.DOM.isExist(self) && mouseDown === true && selected === true) {
if (self.isSelected()) { clk(e);
selected = true; }
} else {
clk(e);
}
mouseDown = true;
ev(e);
// }
});
hand.mouseup(function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && mouseDown === true && selected === true) {
clk(e);
}
mouseDown = false;
selected = false;
$(document).unbind("mouseup." + self.getName());
// }
});
break;
case "dblclick":
hand.dblclick(clk);
break;
case "lclick":
var mouseDown = false;
var interval;
hand.mousedown(function (e) {
$(document).bind("mouseup." + self.getName(), function (e) {
interval && clearInterval(interval);
interval = null;
mouseDown = false; mouseDown = false;
selected = false;
$(document).unbind("mouseup." + self.getName()); $(document).unbind("mouseup." + self.getName());
// }
}); });
if (mouseDown === true) { break;
return; case "dblclick":
} hand.dblclick(clk);
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { break;
return; case "lclick":
} var mouseDown = false;
interval = setInterval(function () { var interval;
self.doClick(); hand.mousedown(function (e) {
}, 100); $(document).bind("mouseup." + self.getName(), function (e) {
mouseDown = true; interval && clearInterval(interval);
ev(e); interval = null;
}); mouseDown = false;
break; $(document).unbind("mouseup." + self.getName());
default: });
hand.mousedown(function (e) { if (mouseDown === true) {
ev(e); return;
}); }
hand.mouseup(function (e) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
ev(e); return;
}); }
hand.click(clk); interval = setInterval(function () {
break; self.doClick();
} }, 100);
mouseDown = true;
ev(e);
});
break;
default:
hand.mousedown(function (e) {
ev(e);
});
hand.mouseup(function (e) {
ev(e);
});
hand.click(clk);
break;
}
});
//之后的300ms点击无效 //之后的300ms点击无效
var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true); var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true);

4
bi/widget.js

@ -7055,6 +7055,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
@ -7063,6 +7064,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
@ -7105,7 +7107,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_finetuning: function(add){ _finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add)); this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) !== -1); this.bottomBtn.setEnable((v + add) > -1);
}, },
getValue: function () { getValue: function () {

168
docs/base.js

@ -685,95 +685,99 @@ BI.BasicButton = BI.inherit(BI.Single, {
return; return;
} }
hand = hand.element; hand = hand.element;
switch (o.trigger) { var triggerArr = (o.trigger || "").split(",");
case "mouseup": BI.each(triggerArr, function (idx, trigger) {
var mouseDown = false; switch (trigger) {
hand.mousedown(function () { case "mouseup":
mouseDown = true; var mouseDown = false;
ev(e); hand.mousedown(function () {
}); mouseDown = true;
hand.mouseup(function (e) { ev(e);
if (mouseDown === true) { });
clk(e); hand.mouseup(function (e) {
} if (mouseDown === true) {
mouseDown = false; clk(e);
ev(e);
});
break;
case "mousedown":
var mouseDown = false;
var selected = false;
hand.mousedown(function (e) {
// if (e.button === 0) {
$(document).bind("mouseup." + self.getName(), function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
self.setSelected(!self.isSelected());
self._trigger();
} }
mouseDown = false; mouseDown = false;
$(document).unbind("mouseup." + self.getName()); ev(e);
});
break;
case "mousedown":
var mouseDown = false;
var selected = false;
hand.mousedown(function (e) {
// if (e.button === 0) {
$(document).bind("mouseup." + self.getName(), function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
self.setSelected(!self.isSelected());
self._trigger();
}
mouseDown = false;
$(document).unbind("mouseup." + self.getName());
// }
});
if (mouseDown === true) {
return;
}
if (self.isSelected()) {
selected = true;
} else {
clk(e);
}
mouseDown = true;
ev(e);
// } // }
}); });
if (mouseDown === true) { hand.mouseup(function (e) {
return; // if (e.button === 0) {
} if (BI.DOM.isExist(self) && mouseDown === true && selected === true) {
if (self.isSelected()) { clk(e);
selected = true; }
} else {
clk(e);
}
mouseDown = true;
ev(e);
// }
});
hand.mouseup(function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && mouseDown === true && selected === true) {
clk(e);
}
mouseDown = false;
selected = false;
$(document).unbind("mouseup." + self.getName());
// }
});
break;
case "dblclick":
hand.dblclick(clk);
break;
case "lclick":
var mouseDown = false;
var interval;
hand.mousedown(function (e) {
$(document).bind("mouseup." + self.getName(), function (e) {
interval && clearInterval(interval);
interval = null;
mouseDown = false; mouseDown = false;
selected = false;
$(document).unbind("mouseup." + self.getName()); $(document).unbind("mouseup." + self.getName());
// }
}); });
if (mouseDown === true) { break;
return; case "dblclick":
} hand.dblclick(clk);
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { break;
return; case "lclick":
} var mouseDown = false;
interval = setInterval(function () { var interval;
self.doClick(); hand.mousedown(function (e) {
}, 100); $(document).bind("mouseup." + self.getName(), function (e) {
mouseDown = true; interval && clearInterval(interval);
ev(e); interval = null;
}); mouseDown = false;
break; $(document).unbind("mouseup." + self.getName());
default: });
hand.mousedown(function (e) { if (mouseDown === true) {
ev(e); return;
}); }
hand.mouseup(function (e) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
ev(e); return;
}); }
hand.click(clk); interval = setInterval(function () {
break; self.doClick();
} }, 100);
mouseDown = true;
ev(e);
});
break;
default:
hand.mousedown(function (e) {
ev(e);
});
hand.mouseup(function (e) {
ev(e);
});
hand.click(clk);
break;
}
});
//之后的300ms点击无效 //之后的300ms点击无效
var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true); var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true);

4
docs/widget.js

@ -7055,6 +7055,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
@ -7063,6 +7064,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
@ -7105,7 +7107,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_finetuning: function(add){ _finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add)); this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) !== -1); this.bottomBtn.setEnable((v + add) > -1);
}, },
getValue: function () { getValue: function () {

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

@ -102,95 +102,99 @@ BI.BasicButton = BI.inherit(BI.Single, {
return; return;
} }
hand = hand.element; hand = hand.element;
switch (o.trigger) { var triggerArr = (o.trigger || "").split(",");
case "mouseup": BI.each(triggerArr, function (idx, trigger) {
var mouseDown = false; switch (trigger) {
hand.mousedown(function () { case "mouseup":
mouseDown = true; var mouseDown = false;
ev(e); hand.mousedown(function () {
}); mouseDown = true;
hand.mouseup(function (e) { ev(e);
if (mouseDown === true) { });
clk(e); hand.mouseup(function (e) {
} if (mouseDown === true) {
mouseDown = false; clk(e);
ev(e);
});
break;
case "mousedown":
var mouseDown = false;
var selected = false;
hand.mousedown(function (e) {
// if (e.button === 0) {
$(document).bind("mouseup." + self.getName(), function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
self.setSelected(!self.isSelected());
self._trigger();
} }
mouseDown = false; mouseDown = false;
$(document).unbind("mouseup." + self.getName()); ev(e);
});
break;
case "mousedown":
var mouseDown = false;
var selected = false;
hand.mousedown(function (e) {
// if (e.button === 0) {
$(document).bind("mouseup." + self.getName(), function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) {
self.setSelected(!self.isSelected());
self._trigger();
}
mouseDown = false;
$(document).unbind("mouseup." + self.getName());
// }
});
if (mouseDown === true) {
return;
}
if (self.isSelected()) {
selected = true;
} else {
clk(e);
}
mouseDown = true;
ev(e);
// } // }
}); });
if (mouseDown === true) { hand.mouseup(function (e) {
return; // if (e.button === 0) {
} if (BI.DOM.isExist(self) && mouseDown === true && selected === true) {
if (self.isSelected()) { clk(e);
selected = true; }
} else {
clk(e);
}
mouseDown = true;
ev(e);
// }
});
hand.mouseup(function (e) {
// if (e.button === 0) {
if (BI.DOM.isExist(self) && mouseDown === true && selected === true) {
clk(e);
}
mouseDown = false;
selected = false;
$(document).unbind("mouseup." + self.getName());
// }
});
break;
case "dblclick":
hand.dblclick(clk);
break;
case "lclick":
var mouseDown = false;
var interval;
hand.mousedown(function (e) {
$(document).bind("mouseup." + self.getName(), function (e) {
interval && clearInterval(interval);
interval = null;
mouseDown = false; mouseDown = false;
selected = false;
$(document).unbind("mouseup." + self.getName()); $(document).unbind("mouseup." + self.getName());
// }
}); });
if (mouseDown === true) { break;
return; case "dblclick":
} hand.dblclick(clk);
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) { break;
return; case "lclick":
} var mouseDown = false;
interval = setInterval(function () { var interval;
self.doClick(); hand.mousedown(function (e) {
}, 100); $(document).bind("mouseup." + self.getName(), function (e) {
mouseDown = true; interval && clearInterval(interval);
ev(e); interval = null;
}); mouseDown = false;
break; $(document).unbind("mouseup." + self.getName());
default: });
hand.mousedown(function (e) { if (mouseDown === true) {
ev(e); return;
}); }
hand.mouseup(function (e) { if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
ev(e); return;
}); }
hand.click(clk); interval = setInterval(function () {
break; self.doClick();
} }, 100);
mouseDown = true;
ev(e);
});
break;
default:
hand.mousedown(function (e) {
ev(e);
});
hand.mouseup(function (e) {
ev(e);
});
hand.click(clk);
break;
}
});
//之后的300ms点击无效 //之后的300ms点击无效
var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true); var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true);

4
src/widget/finetuningnumbereditor/finetuning.number.editor.js

@ -27,6 +27,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.topBtn = BI.createWidget({ this.topBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
trigger: "lclick,",
cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom"
}); });
this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.topBtn.on(BI.IconButton.EVENT_CHANGE, function(){
@ -35,6 +36,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
}); });
this.bottomBtn = BI.createWidget({ this.bottomBtn = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
trigger: "lclick,",
cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top"
}); });
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){ this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
@ -77,7 +79,7 @@ BI.FineTuningNumberEditor = BI.inherit(BI.Widget, {
_finetuning: function(add){ _finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add)); this.editor.setValue(this._alertInEditorValue(v + add));
this.bottomBtn.setEnable((v + add) !== -1); this.bottomBtn.setEnable((v + add) > -1);
}, },
getValue: function () { getValue: function () {

Loading…
Cancel
Save