aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-08-09 21:38:19 -0400
committerScott González <scott.gonzalez@gmail.com>2011-08-09 21:38:19 -0400
commit7c7d3df8e7b90785a6725cb74863e793d21fea1a (patch)
tree34d8d975e058a477e32506326d1c9e9ece619f97 /ui
parenta0eb042bcdb3a8028631e648269fefdad762f522 (diff)
downloadjquery-ui-7c7d3df8e7b90785a6725cb74863e793d21fea1a.tar.gz
jquery-ui-7c7d3df8e7b90785a6725cb74863e793d21fea1a.zip
Spinner: Return formatted value when using value method.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.spinner.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index fecaa9b05..4bbc1adf4 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -17,8 +17,7 @@ function modifier( fn ) {
return function() {
var previous = this.options.value;
fn.apply( this, arguments );
- this._format();
- this._aria();
+ this._refresh();
if ( previous !== this.options.value ) {
this._trigger( "change" );
}
@@ -48,7 +47,7 @@ $.widget( "ui.spinner", {
this._value( this.options.value );
this._draw();
this._mousewheel();
- this._aria();
+ this._refresh();
},
_getCreateOptions: function() {
@@ -307,14 +306,6 @@ $.widget( "ui.spinner", {
this._value( this._trimValue( this.options.value ) );
}),
- _aria: function() {
- this.element.attr({
- "aria-valuemin": this.options.min,
- "aria-valuemax": this.options.max,
- "aria-valuenow": this.options.value
- });
- },
-
_parse: function( val ) {
if ( typeof val === "string" ) {
val = $.global && this.options.numberFormat ? $.global.parseFloat( val ) : +val;
@@ -324,14 +315,23 @@ $.widget( "ui.spinner", {
_format: function() {
var num = this.options.value;
- this.element.val( $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num );
+ return $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num;
+ },
+
+ _refresh: function() {
+ this.element
+ .val( this._format() )
+ .attr({
+ "aria-valuemin": this.options.min,
+ "aria-valuemax": this.options.max,
+ "aria-valuenow": this.options.value
+ });
},
// update the value without triggering change
_value: function( value ) {
this.options.value = this._trimValue( this._parse(value) );
- this._format();
- this._aria();
+ this._refresh();
},
destroy: function() {
@@ -371,7 +371,7 @@ $.widget( "ui.spinner", {
value: function( newVal ) {
if ( !arguments.length ) {
- return this._parse( this.element.val() );
+ return this._format();
}
this.option( "value", newVal );
},