]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Update button icons when option changes. Fixes #8926 - Spinner: Can't change... 868/head
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 27 Dec 2012 11:50:04 +0000 (12:50 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 27 Dec 2012 11:50:04 +0000 (12:50 +0100)
tests/unit/spinner/spinner_options.js
ui/jquery.ui.spinner.js

index 284e03a3e3b622dbc338236eaa0fa4d5616ff025..6f3650f923aab07896c295ada4d42cc40622315c 100644 (file)
@@ -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() {
index 406eefb9158c7627f1da621f4d10a39a2df15986..aeffe0a3e340339d45bf6fec5f9fbf51475899d7 100644 (file)
@@ -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 );