mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Use _getCreateOptions() instead of custom _markupOptions().
This commit is contained in:
parent
c1da941f9f
commit
e4c0f202c8
@ -2,11 +2,11 @@ commonWidgetTests( "spinner", {
|
|||||||
defaults: {
|
defaults: {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
incremental: true,
|
incremental: true,
|
||||||
max: null,
|
max: Number.MAX_VALUE,
|
||||||
min: null,
|
min: -Number.MAX_VALUE,
|
||||||
numberFormat: null,
|
numberFormat: null,
|
||||||
page: 10,
|
page: 10,
|
||||||
step: null,
|
step: 1,
|
||||||
value: null,
|
value: null,
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
|
35
ui/jquery.ui.spinner.js
vendored
35
ui/jquery.ui.spinner.js
vendored
@ -19,40 +19,33 @@ $.widget( "ui.spinner", {
|
|||||||
widgetEventPrefix: "spin",
|
widgetEventPrefix: "spin",
|
||||||
options: {
|
options: {
|
||||||
incremental: true,
|
incremental: true,
|
||||||
max: null,
|
max: Number.MAX_VALUE,
|
||||||
min: null,
|
min: -Number.MAX_VALUE,
|
||||||
numberFormat: null,
|
numberFormat: null,
|
||||||
page: 10,
|
page: 10,
|
||||||
step: null,
|
step: 1,
|
||||||
value: null
|
value: null
|
||||||
},
|
},
|
||||||
|
|
||||||
_create: function() {
|
_create: function() {
|
||||||
this._markupOptions();
|
this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
|
||||||
this._draw();
|
this._draw();
|
||||||
this._mousewheel();
|
this._mousewheel();
|
||||||
this._aria();
|
this._aria();
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: should we use _getCreateOptions() now?
|
_getCreateOptions: function() {
|
||||||
// would increase overhead of init when options are specified,
|
var options = {},
|
||||||
// but would move the defaults to the right location
|
element = this.element;
|
||||||
// and use our API the way it's meant to be used
|
|
||||||
_markupOptions: function() {
|
$.each( [ "min", "max", "step" ], function( i, option ) {
|
||||||
var that = this;
|
var value = element.attr( option );
|
||||||
$.each({
|
if ( value !== undefined ) {
|
||||||
min: -Number.MAX_VALUE,
|
options[ option ] = 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;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
|
|
||||||
|
return options;
|
||||||
},
|
},
|
||||||
|
|
||||||
_draw: function() {
|
_draw: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user