]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Introduce icons option to make button icons customizable, mostly for consistency
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 12 Jul 2012 15:59:43 +0000 (17:59 +0200)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 12 Jul 2012 16:07:40 +0000 (18:07 +0200)
tests/unit/spinner/spinner_common.js
tests/unit/spinner/spinner_options.js
ui/jquery.ui.spinner.js

index 4f05b1e63cd8175727a8be85e3437b2c060508a2..b494e3ca34d0960c025d7ba1464acda544e29ff9 100644 (file)
@@ -2,6 +2,10 @@ TestHelpers.commonWidgetTests( "spinner", {
        defaults: {
                culture: null,
                disabled: false,
+               icons: {
+                       down: "ui-icon-triangle-1-s",
+                       up: "ui-icon-triangle-1-n"
+               },
                incremental: true,
                max: null,
                min: null,
index e218526309029e0a4866b9b56fd80da9da422358..1f6646a33bb38806c1bac81e569fc2a2bdb81518 100644 (file)
@@ -6,6 +6,25 @@ 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" );
+});
+
+test( "icons: custom ", function() {
+       expect( 2 );
+       var element = $( "#spin" ).val( 0 ).spinner({
+               icons: {
+                       down: "custom-down",
+                       up: "custom-up"
+               }
+       }).spinner( "widget" );
+       equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon custom-up" );
+       equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon custom-down" );
+});
+
 test( "incremental, false", function() {
        expect( 100 );
 
index 6acb3693e2d1109ca9511dbe09ea9bf7a848e2a6..ead3b17bef727cb49047b00dc92bcf7bbe418cc4 100644 (file)
@@ -32,6 +32,10 @@ $.widget( "ui.spinner", {
        widgetEventPrefix: "spin",
        options: {
                culture: null,
+               icons: {
+                       down: "ui-icon-triangle-1-s",
+                       up: "ui-icon-triangle-1-n"
+               },
                incremental: true,
                max: null,
                min: null,
@@ -244,10 +248,10 @@ $.widget( "ui.spinner", {
        _buttonHtml: function() {
                return "" +
                        "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
-                               "<span class='ui-icon ui-icon-triangle-1-n'>&#9650;</span>" +
+                               "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
                        "</a>" +
                        "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
-                               "<span class='ui-icon ui-icon-triangle-1-s'>&#9660;</span>" +
+                               "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
                        "</a>";
        },