r3126 committed - spinner: refactored _setData to switch statement and removed this.spin...

r3126 committed - spinner: refactored _setData to switch statement and removed this.spin...


Revision: 3126
Author: pazu2k@gmail.com
Date: Mon Aug 24 07:32:07 2009
Log: spinner: refactored _setData to switch statement and removed
this.spinnerClass property as it's not needed.
http://code.google.com/p/jquery-ui/source/detail?r=3126
Modified:
/branches/dev/spinner/ui/ui.spinner.js
=======================================
--- /branches/dev/spinner/ui/ui.spinner.js    Mon Aug 24 05:42:44 2009
+++ /branches/dev/spinner/ui/ui.spinner.js    Mon Aug 24 07:32:07 2009
@@ -32,8 +32,6 @@
        if (this.options.buttons !== buttonDefault) {
            this.buttons.hide();
        }
-
-        this.spinnerClass = this.options.spinnerClass;
    },
    _initOptions: function() {
        var self = this,
@@ -332,46 +330,39 @@
        this._setData('value', newVal);
        this.uiSpinner && this.uiSpinner.attr('aria-valuenow', this.value());
    },
-    _setData: function(key, value) {
-        $.widget.prototype._setData.call(this, key, value);
-
-        if (key === 'buttons') {
-            this._hide();
-            return;
-        }
-
-        if (/min|max|step/.test(key) && this.options[key] != null) {
-            // write attributes back to element if original exist
-            if (this.element.attr(key)) {
-                this.element.attr(key, value);
-            }
-
-            // add aria properties
-            if (/min|max/.test(key)) {
-                this.element.parent().attr('aria-value'+key, value);
-            }
-
-            return;
+    _setData: function(key, value) {
+        switch (key) {
+            case 'buttons':
+                this._hide();
+                break;
+            case 'max':
+            case 'min':
+            case 'step':
+                if (this.options[key] != null) {
+                    // write attributes back to element if original exist
+                    if (this.element.attr(key)) {
+                        this.element.attr(key, value);
+                    }
+                    // add aria properties
+                    if (/min|max/.test(key)) {
+                        this.element.parent().attr('aria-value'+key, value);
+                    }
+                }
+                break;
+            case 'value':
+                this._format(value);
+                break;
+            case 'width':
+                this.element.width(value);
+                break;
+            case 'spinnerClass':
+                this.uiSpinner
+                    .removeClass(this.options.spinnerClass)
+                    .addClass(value);
+                break;
        }
-        if (key === 'value') {
-            this._format(value);
-            return;
-        }
-
-        if (key === 'width') {
-            this.element.width(value);
-            return;
-        }
-
-        if (key === 'spinnerClass') {
-            if (this.spinnerClass) {
-                this.uiSpinner.removeClass(this.spinnerClass);
-            }
-            this.uiSpinner.addClass(value);
-            this.spinnerClass = value;
-            return;
-        }
+        $.widget.prototype._setData.call(this, key, value);
    },
    _validChars: function() {
        var radix = parseInt(this.options.radix);
@@ -407,7 +398,7 @@
            radix = options.radix,
            group = options.groupSeparator,
            pt = options.radixPoint;
-
+
        for (
            num = (
                isNaN(num)