]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Use _getCreateOptions() instead of custom _markupOptions(). 424/head
authorScott González <scott.gonzalez@gmail.com>
Sat, 6 Aug 2011 16:58:37 +0000 (12:58 -0400)
committerScott González <scott.gonzalez@gmail.com>
Sat, 6 Aug 2011 16:58:37 +0000 (12:58 -0400)
tests/unit/spinner/spinner_defaults.js
ui/jquery.ui.spinner.js

index c9a7d5f626aecceeff8a217f503a3bac6dda7d5d..078bd36c6a7176a7eeafd21cf7e620df74369d07 100644 (file)
@@ -2,11 +2,11 @@ commonWidgetTests( "spinner", {
        defaults: {\r
                disabled: false,\r
                incremental: true,\r
-               max: null,\r
-               min: null,\r
+               max: Number.MAX_VALUE,\r
+               min: -Number.MAX_VALUE,\r
                numberFormat: null,\r
                page: 10,\r
-               step: null,\r
+               step: 1,\r
                value: null,\r
 \r
                // callbacks\r
index 1b55d83743ceb74b1a2653390112a132dfd243bc..ed3b789c9c2b4074f34a05e05b08907b655b8459 100644 (file)
@@ -19,40 +19,33 @@ $.widget( "ui.spinner", {
        widgetEventPrefix: "spin",
        options: {
                incremental: true,
-               max: null,
-               min: null,
+               max: Number.MAX_VALUE,
+               min: -Number.MAX_VALUE,
                numberFormat: null,
                page: 10,
-               step: null,
+               step: 1,
                value: null
        },
 
        _create: function() {
-               this._markupOptions();
+               this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
                this._draw();
                this._mousewheel();
                this._aria();
        },
 
-       // TODO: should we use _getCreateOptions() now?
-       // would increase overhead of init when options are specified,
-       // but would move the defaults to the right location
-       // and use our API the way it's meant to be used
-       _markupOptions: function() {
-               var that = this;
-               $.each({
-                       min: -Number.MAX_VALUE,
-                       max: Number.MAX_VALUE,
-                       step: 1
-               }, function( attr, defaultValue ) {
-                       if ( that.options[ attr ] === null ) {
-                               var value = that.element.attr( attr );
-                               that.options[ attr ] = typeof value === "string" && value.length > 0 ?
-                                       that._parse( value ) :
-                                       defaultValue;
+       _getCreateOptions: function() {
+               var options = {},
+                       element = this.element;
+
+               $.each( [ "min", "max", "step" ], function( i, option ) {
+                       var value = element.attr( option );
+                       if ( value !== undefined ) {
+                               options[ option ] = value;
                        }
                });
-               this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
+
+               return options;
        },
 
        _draw: function() {