From e054e28836e616ed03561d5a8195bbea525866d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Thu, 12 Jul 2012 17:59:43 +0200 Subject: [PATCH] Spinner: Introduce icons option to make button icons customizable, mostly for consistency --- tests/unit/spinner/spinner_common.js | 4 ++++ tests/unit/spinner/spinner_options.js | 19 +++++++++++++++++++ ui/jquery.ui.spinner.js | 8 ++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/unit/spinner/spinner_common.js b/tests/unit/spinner/spinner_common.js index 4f05b1e63..b494e3ca3 100644 --- a/tests/unit/spinner/spinner_common.js +++ b/tests/unit/spinner/spinner_common.js @@ -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, diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index e21852630..1f6646a33 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -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 ); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 6acb3693e..ead3b17be 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -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 "" + "" + - "" + + "" + "" + "" + - "" + + "" + ""; }, -- 2.39.5