Skip to content
Permalink
Browse files

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.
  • Loading branch information...
Ca-Phun Ung
Ca-Phun Ung committed Sep 26, 2008
1 parent b920e58 commit 24afc68d5b4e2cca792980d41cef6f0a1e0fcdda
Showing with 12 additions and 3 deletions.
  1. +4 −2 tests/spinner.js
  2. +1 −0 tests/visual/spinner.html
  3. +7 −1 ui/ui.spinner.js
@@ -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() {
@@ -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">
@@ -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() {

0 comments on commit 24afc68

Please sign in to comment.
You can’t perform that action at this time.