Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Spinner: Update button icons when option changes. Fixes #8926 - Spinn…

…er: Can't change icons option after init
  • Loading branch information...
commit 04d668b7171e14292af9f4de1b6bfbbe1a6e990c 1 parent 0d4022b
@jzaefferer jzaefferer authored
Showing with 19 additions and 4 deletions.
  1. +11 −4 tests/unit/spinner/spinner_options.js
  2. +8 −0 ui/jquery.ui.spinner.js
View
15 tests/unit/spinner/spinner_options.js
@@ -5,10 +5,17 @@ module( "spinner: options" );
// culture is tested after numberFormat, since it depends on numberFormat
test( "icons: default ", function() {
- expect( 2 );
- var element = $( "#spin" ).val( 0 ).spinner().spinner( "widget" );
- equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
- equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
+ expect( 4 );
+ var element = $( "#spin" ).val( 0 ).spinner();
+ equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
+ equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
+
+ element.spinner( "option", "icons", {
+ up: "ui-icon-carat-1-n",
+ down: "ui-icon-carat-1-s"
+ });
+ equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-carat-1-n" );
+ equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-carat-1-s" );
});
test( "icons: custom ", function() {
View
8 ui/jquery.ui.spinner.js
@@ -368,6 +368,14 @@ $.widget( "ui.spinner", {
value = this._parse( value );
}
}
+ if ( key === "icons" ) {
+ this.buttons.first().find( ".ui-icon" )
+ .removeClass( this.options.icons.up )
+ .addClass( value.up );
+ this.buttons.last().find( ".ui-icon" )
+ .removeClass( this.options.icons.down )
+ .addClass( value.down );
+ }
this._super( key, value );
Please sign in to comment.
Something went wrong with that request. Please try again.