Spinner: added a timer to mousewheel interaction which fires a change event when the mousewheel stops spinning.

Added a few missing options to test case.
This commit is contained in:
Ca-Phun Ung 2008-09-26 07:21:56 +00:00
parent b920e5893a
commit 24afc68d5b
3 changed files with 12 additions and 3 deletions

View File

@ -56,7 +56,7 @@ test("enable", function() {
});
test("defaults", function() {
expect(7);
expect(10);
el = $("#spin").spinner();
equals(el.data("currency.spinner"), false, "currency");
@ -66,6 +66,9 @@ test("defaults", function() {
equals(el.data("min.spinner"), undefined, "min");
equals(el.data("start.spinner"), 0, "start");
equals(el.data("stepping.spinner"), 1, "stepping");
equals(el.data("decimals.spinner"), 0, "decimals");
equals(el.data("format.spinner"), '%', "format");
equals(el.data("items.spinner"), false, "items");
});
@ -261,7 +264,6 @@ test("mouse click on buttons", function() {
equals(el.val(), 0, "mouse double click to down");
});
test("callback", function() {

View File

@ -6,6 +6,7 @@
<script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.spinner.js"></script>
<script type="text/javascript" src="../../jquery.mousewheel.js"></script>
<script type="text/javascript">

View File

@ -263,8 +263,14 @@ $.widget('ui.spinner', {
(/[0-9\-\.]/).test(String.fromCharCode(e.keyCode))) ? true : false;
},
_mousewheel: function(e, delta) {
var self = this;
delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);
(delta > 0 ? this._up(e) : this._down(e));
(delta > 0 ? self._up(e) : self._down(e));
if (self.timeout) {
window.clearTimeout(self.timeout);
self.timeout = 0;
}
self.timeout = window.setTimeout(function(){self._propagate('change', e)}, 500);
e.preventDefault();
},
_getValue: function() {