r2928 - spinner: _spin direction is now determined by pos/neg step value.

r2928 - spinner: _spin direction is now determined by pos/neg step value.


Author: pazu2k@gmail.com
Date: Thu Jul 16 01:18:54 2009
New Revision: 2928
Modified:
branches/dev/spinner/ui/ui.spinner.js
Log:
spinner: _spin direction is now determined by pos/neg step value.
Modified: branches/dev/spinner/ui/ui.spinner.js
==============================================================================
--- branches/dev/spinner/ui/ui.spinner.js    (original)
+++ branches/dev/spinner/ui/ui.spinner.js    Thu Jul 16 01:18:54 2009
@@ -159,7 +159,7 @@
                if (!self.counter) {
                    self.counter = 1;
                }
-                self._mousedown(100,
$(this).hasClass('ui-spinner-up') ? 'up' : 'down', event);
+                self._mousedown(100, $(this).hasClass('ui-spinner-up') ? 1 : -1,
event);
                
                if (!self.disabled) {
                    $(this).addClass(active);
@@ -170,7 +170,7 @@
            })
            .bind('mouseup', function(event) {
                if (self.counter == 1) {
-                    self._spin($(this).hasClass('ui-spinner-up') ? 'up' : 'down',
options.step, event);
+                    self._spin(($(this).hasClass('ui-spinner-up') ? 1 : -1) *
options.step, event);
                }
                self._mouseup(event);
                
@@ -180,7 +180,7 @@
            .bind('dblclick', function(event) {
                if ($.browser.msie) {
                    $(this).removeClass(active);
-                    self._spin($(this).hasClass('ui-spinner-up') ? 'up' : 'down',
options.step, event);
+                    self._spin(($(this).hasClass('ui-spinner-up') ? 1 : -1) *
options.step, event);
                    self._mouseup(event);
                }
            })
@@ -242,7 +242,7 @@
        this._setValue(this._getValue());
        this._constrain();
    },
-    _spin: function(d, step, event) {
+    _spin: function(step, event) {
        if (this.disabled) {
            return;
        }
@@ -254,7 +254,7 @@
        if (isNaN(value)) {
            value = this.options.value;
        }
-        this._setValue(value + (d == 'up' ? 1:-1) *(this.options.incremental &&
this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * step);
+        this._setValue(value + (this.options.incremental && this.counter > 100 ?
(this.counter > 200 ? 100 : 10) : 1) * step);
        this._constrain();
        if (this.counter) {
            this.counter++;
@@ -271,7 +271,7 @@
            this.timer = 0;
        }
        this.timer = window.setInterval(function() {
-            self._spin(d, self.options.step, event);
+            self._spin(d*self.options.step, event);
            if (self.options.incremental && self.counter > 20) {
                self._mousedown(20, d, event);
            }
@@ -292,16 +292,16 @@
            KEYS = $.ui.keyCode;
        if (event.keyCode == KEYS.UP) {
-            this._spin('up', event.shiftKey ? jump : o.step, event);
+            this._spin(event.shiftKey ? jump : o.step, event);
        }
        if (event.keyCode == KEYS.DOWN) {
-            this._spin('down', event.shiftKey ? jump : o.step, event);
+            this._spin(event.shiftKey ? -jump : -o.step, event);
        }
        if (event.keyCode == KEYS.PAGE_UP) {
-            this._spin('up', jump, event);
+            this._spin(jump, event);
        }
        if (event.keyCode == KEYS.PAGE_DOWN) {
-            this._spin('down', jump, event);
+            this._spin(-jump, event);
        }
        if (event.keyCode == KEYS.HOME) {
            //Home key goes to min
@@ -323,7 +323,7 @@
        var self = $.data(this, 'spinner');
        
        delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);
-        self._spin(delta > 0 ? 'up' : 'down', self.options.step, event);
+        self._spin((delta > 0 ? 1 : -1) * self.options.step, event);
        if (self.timeout) {
            window.clearTimeout(self.timeout);
            self.timeout = 0;
@@ -474,11 +474,11 @@
        this._setValue(newVal);
    },
    stepUp: function(steps) {
-        this._spin('up', (steps || 1) * this.options.step, null);
+        this._spin((steps || 1) * this.options.step, null);
        return this;
    },
    stepDown: function(steps) {
-        this._spin('down', (steps || 1) * this.options.step, null);    
+        this._spin((steps || 1) * -this.options.step, null);    
        return this;
    },
    pageUp: function(pages) {