From 02033262ee0fb1d9f33c361b3c2ddfa168604854 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 22 Jan 2014 12:02:32 -0500 Subject: Button: Initial commit of button re-factor Move to using element stats rather then js class states remove ui-button-text spans. Removed button set --- tests/unit/button/deprecated.js | 196 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 tests/unit/button/deprecated.js (limited to 'tests/unit/button/deprecated.js') diff --git a/tests/unit/button/deprecated.js b/tests/unit/button/deprecated.js new file mode 100644 index 000000000..bb023ab4f --- /dev/null +++ b/tests/unit/button/deprecated.js @@ -0,0 +1,196 @@ +define( [ + "jquery", + "ui/button" +], function( $ ) { + +module( "Button (deprecated): core" ); + +test( "Calling button on a checkbox input calls checkboxradio widget", function() { + var checkbox = $( "#checkbox01" ); + + expect( 2 ); + checkbox.button(); + + ok( !!checkbox.checkboxradio( "instance" ), + "Calling button on a checkbox creates checkboxradio instance" ); + ok( !checkbox.checkboxradio( "option", "icon" ), + "Calling button on a checkbox sets the checkboxradio icon option to false" ); +} ); + +test( "Calling buttonset calls controlgroup", function() { + var controlgroup = $( ".buttonset" ); + + expect( 1 ); + controlgroup.buttonset(); + + ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" ); +} ); + +module( "Button (deprecated): methods" ); + +test( "destroy", function( assert ) { + expect( 1 ); + assert.domEqual( "#checkbox02", function() { + $( "#checkbox02" ).button().button( "destroy" ); + } ); +} ); + +test( "refresh: Ensure disabled state is preserved correctly.", function() { + expect( 5 ); + var element = null; + + element = $( "#checkbox02" ); + element.button( { disabled: true } ).button( "refresh" ); + ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh" ); + ok( element.prop( "disabled" ), "Input remains disabled after refresh" ); + + element = $( "#radio02" ); + element.button( { disabled: true } ).button( "refresh" ); + ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh" ); + + element = $( "#checkbox02" ); + element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" ); + ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh." ); + + element = $( "#radio02" ); + element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" ); + ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh." ); + +} ); + +module( "button (deprecated): options" ); + +test( "Setting items option on buttonset sets the button properties on the items option", function() { + expect( 2 ); + + var controlgroup = $( ".buttonset" ); + + controlgroup.buttonset( { items: "bar" } ); + equal( controlgroup.controlgroup( "option", "items.button" ), "bar", + "items.button set when setting items option on init on buttonset" ); + + controlgroup.buttonset( "option", "items", "foo" ); + equal( controlgroup.controlgroup( "option", "items.button" ), "foo", + "items.button set when setting items option on buttonset" ); +} ); + +test( "disabled, null", function() { + expect( 2 ); + + $( "#radio02" ).prop( "disabled", true ).button( { disabled: null } ); + deepEqual( $( "#radio02" ).button( "option", "disabled" ), true, + "disabled option set to true" ); + deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" ); +} ); + +test( "text / showLabel options proxied", function() { + expect( 8 ); + var button = $( "#button" ); + button.button( { + text: false, + icon: "ui-icon-gear" + } ); + equal( button.button( "option", "showLabel" ), false, + "Setting the text option to false sets the showLabel option to false on init" ); + button.button( "option", "showLabel", true ); + equal( button.button( "option", "text" ), true, + "Setting showLabel true with option method sets text option to true" ); + button.button( "option", "text", false ); + equal( button.button( "option", "showLabel" ), false, + "Setting text false with option method sets showLabel option to false" ); + button.button( "option", "text", true ); + equal( button.button( "option", "showLabel" ), true, + "Setting text true with option method sets showLabel option to true" ); + button.button( "option", "showLabel", false ); + equal( button.button( "option", "text" ), false, + "Setting showLabel false with option method sets text option to false" ); + button.button( "destroy" ); + button.button( { + text: true, + icon: "ui-icon-gear" + } ); + equal( button.button( "option", "showLabel" ), true, + "Setting the text option to true sets the showLabel option to true on init" ); + button.button( "destroy" ); + button.button( { + showLabel: true, + icon: "ui-icon-gear" + } ); + equal( button.button( "option", "text" ), true, + "Setting the showLabel option to true sets the text option to true on init" ); + button.button( "destroy" ); + button.button( { + showLabel: false, + icon: "ui-icon-gear" + } ); + equal( button.button( "option", "text" ), false, + "Setting the showLabel option to false sets the text option to false on init" ); +} ); + +test( "icon / icons options properly proxied", function() { + expect( 10 ); + + var button = $( "#button" ); + + button.button( { + icon: "foo" + } ); + + equal( button.button( "option", "icons.primary" ), "foo", + "Icon option properly proxied on init" ); + + button.button( { + icon: "bar" + } ); + + equal( button.button( "option", "icons.primary" ), "bar", + "Icon option properly proxied with option method" ); + + button.button( { + icons: { + primary: "foo" + } + } ); + + equal( button.button( "option", "icon" ), "foo", + "Icons primary option properly proxied with option method" ); + equal( button.button( "option", "iconPosition" ), "beginning", + "Icons primary option sets iconPosition option to beginning" ); + + button.button( { + icons: { + secondary: "bar" + } + } ); + + equal( button.button( "option", "icon" ), "bar", + "Icons secondary option properly proxied with option method" ); + equal( button.button( "option", "iconPosition" ), "end", + "Icons secondary option sets iconPosition option to end" ); + + button.button( "destroy" ); + + button.button( { + icons: { + primary: "foo" + } + } ); + + equal( button.button( "option", "icon" ), "foo", + "Icons primary option properly proxied on init" ); + equal( button.button( "option", "iconPosition" ), "beginning", + "Icons primary option sets iconPosition option to beginning on init" ); + + button.button( { + icons: { + secondary: "bar" + } + } ); + + equal( button.button( "option", "icon" ), "bar", + "Icons secondary option properly proxied on init" ); + equal( button.button( "option", "iconPosition" ), "end", + "Icons secondary option sets iconPosition option to end on init" ); +} ); + +} ); -- cgit v1.2.3 From 16abde399daa07e11f3b972ab675d59374cf08be Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Wed, 7 Jan 2015 21:51:38 -0500 Subject: Spinner: Updates for new button widget and classes option --- demos/button/default.html | 9 +- demos/button/icons.html | 10 +- demos/button/splitbutton.html | 70 -------- demos/button/toolbar.html | 115 ------------ demos/checkboxradio/default.html | 9 +- demos/checkboxradio/no-icons.html | 9 +- demos/checkboxradio/product-selector.html | 10 +- demos/checkboxradio/radiogroup.html | 10 +- tests/unit/button/common-deprecated.js | 2 +- tests/unit/button/core.js | 1 + tests/unit/button/deprecated.js | 2 +- tests/unit/checkboxradio/common.js | 2 +- tests/unit/checkboxradio/core.js | 2 +- tests/unit/checkboxradio/events.js | 72 +------- tests/unit/checkboxradio/methods.js | 2 +- tests/unit/checkboxradio/options.js | 2 +- ui/checkboxradio.js | 289 ------------------------------ ui/widgets/button.js | 3 +- ui/widgets/checkboxradio.js | 265 +++++++++++++++++++++++++++ ui/widgets/spinner.js | 12 +- 20 files changed, 293 insertions(+), 603 deletions(-) delete mode 100644 demos/button/splitbutton.html delete mode 100644 demos/button/toolbar.html delete mode 100644 ui/checkboxradio.js create mode 100644 ui/widgets/checkboxradio.js (limited to 'tests/unit/button/deprecated.js') diff --git a/demos/button/default.html b/demos/button/default.html index 5418fd8c9..644dcd225 100644 --- a/demos/button/default.html +++ b/demos/button/default.html @@ -5,18 +5,13 @@ jQuery UI Button - Default functionality - - - - - + diff --git a/demos/button/icons.html b/demos/button/icons.html index a8deca9cd..af4e3000c 100644 --- a/demos/button/icons.html +++ b/demos/button/icons.html @@ -5,13 +5,9 @@ jQuery UI Button - Icons - - - - - + @@ -41,7 +36,6 @@ -

CSS

diff --git a/demos/button/splitbutton.html b/demos/button/splitbutton.html deleted file mode 100644 index 6b7562d68..000000000 --- a/demos/button/splitbutton.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - jQuery UI Button - Split button - - - - - - - - - - - - - -
-
- - -
-
    -
  • Open...
  • -
  • Save
  • -
  • Delete
  • -
-
- -
-

An example of a split button built with two buttons: A plain button with just text, one with only a primary icon -and no text. Both are grouped together in a set.

-
- - diff --git a/demos/button/toolbar.html b/demos/button/toolbar.html deleted file mode 100644 index f2c242f1f..000000000 --- a/demos/button/toolbar.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - jQuery UI Button - Toolbar - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- -
-

- A mediaplayer toolbar. Take a look at the underlying markup: A few button elements, - an input of type checkbox for the Shuffle button, and three inputs of type radio for the Repeat options. -

-
- - diff --git a/demos/checkboxradio/default.html b/demos/checkboxradio/default.html index c8f4c5566..c8c1a800d 100644 --- a/demos/checkboxradio/default.html +++ b/demos/checkboxradio/default.html @@ -4,17 +4,12 @@ jQuery UI Checkboxradio - Default functionality - - - - - + diff --git a/demos/checkboxradio/no-icons.html b/demos/checkboxradio/no-icons.html index 64b511246..c738d8ca8 100644 --- a/demos/checkboxradio/no-icons.html +++ b/demos/checkboxradio/no-icons.html @@ -4,17 +4,12 @@ jQuery UI Checkboxradio - No Icons - - - - - + diff --git a/demos/checkboxradio/product-selector.html b/demos/checkboxradio/product-selector.html index f8da07118..4e6db4507 100644 --- a/demos/checkboxradio/product-selector.html +++ b/demos/checkboxradio/product-selector.html @@ -4,14 +4,9 @@ jQuery UI Checkboxradio - Product Selector - - - - - - +