diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-01-07 21:51:38 -0500 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-10-08 14:02:35 -0400 |
commit | 16abde399daa07e11f3b972ab675d59374cf08be (patch) | |
tree | df9f2ef654f5357ad1e7e1eac3ad6f79194b33f1 | |
parent | 9f7f0a427966741a460e91336947698879f8ad77 (diff) | |
download | jquery-ui-16abde399daa07e11f3b972ab675d59374cf08be.tar.gz jquery-ui-16abde399daa07e11f3b972ab675d59374cf08be.zip |
Spinner: Updates for new button widget and classes option
-rw-r--r-- | demos/button/default.html | 9 | ||||
-rw-r--r-- | demos/button/icons.html | 10 | ||||
-rw-r--r-- | demos/button/splitbutton.html | 70 | ||||
-rw-r--r-- | demos/button/toolbar.html | 115 | ||||
-rw-r--r-- | demos/checkboxradio/default.html | 9 | ||||
-rw-r--r-- | demos/checkboxradio/no-icons.html | 9 | ||||
-rw-r--r-- | demos/checkboxradio/product-selector.html | 10 | ||||
-rw-r--r-- | demos/checkboxradio/radiogroup.html | 10 | ||||
-rw-r--r-- | tests/unit/button/common-deprecated.js | 2 | ||||
-rw-r--r-- | tests/unit/button/core.js | 1 | ||||
-rw-r--r-- | tests/unit/button/deprecated.js | 2 | ||||
-rw-r--r-- | tests/unit/checkboxradio/common.js | 2 | ||||
-rw-r--r-- | tests/unit/checkboxradio/core.js | 2 | ||||
-rw-r--r-- | tests/unit/checkboxradio/events.js | 72 | ||||
-rw-r--r-- | tests/unit/checkboxradio/methods.js | 2 | ||||
-rw-r--r-- | tests/unit/checkboxradio/options.js | 2 | ||||
-rw-r--r-- | ui/widgets/button.js | 3 | ||||
-rw-r--r-- | ui/widgets/checkboxradio.js (renamed from ui/checkboxradio.js) | 46 | ||||
-rw-r--r-- | ui/widgets/spinner.js | 12 |
19 files changed, 39 insertions, 349 deletions
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 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery UI Button - Default functionality</title> <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/button.js"></script> <link rel="stylesheet" href="../demos.css"> - <script> - $( function() { + <script src="../../external/requirejs/require.js"></script> + <script src="../bootstrap.js"> $( ".widget input[type=submit], .widget a, .widget button" ).button(); $( "button, input, a" ).click( function( event ) { event.preventDefault(); } ); - } ); </script> </head> <body> 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 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery UI Button - Icons</title> <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/button.js"></script> <link rel="stylesheet" href="../demos.css"> - <script> - $( function() { + <script src="../../external/requirejs/require.js"></script> + <script src="../bootstrap.js"> $( ".widget button" ).first() .button() .next().button( { @@ -29,7 +25,6 @@ icon: "ui-icon-gear", iconPosition: "bottom" } ); - } ); </script> </head> <body> @@ -41,7 +36,6 @@ <button>Button with icon on the right</button> <button>Button with icon on the top</button> <button>Button with icon on the bottom</button> - <button>Button with icon on the top</button> </div> <div class="css"> <h1>CSS</h1> 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 @@ -<!doctype html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>jQuery UI Button - Split button</title> - <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/button.js"></script> - <script src="../../ui/position.js"></script> - <script src="../../ui/menu.js"></script> - <link rel="stylesheet" href="../demos.css"> - <style> - .ui-menu { position: absolute; width: 100px; } - </style> - <script> - $(function() { - $( "#rerun" ) - .button() - .on( "click", function() { - alert( "Running the last action" ); - }) - .next() - .button({ - text: false, - icons: { - primary: "ui-icon-triangle-1-s" - } - }) - .on( "click", function() { - var menu = $( this ).parent().next().show().position({ - my: "left top", - at: "left bottom", - of: this - }); - $( document ).one( "click", function() { - menu.hide(); - }); - return false; - }) - .parent() - .buttonset() - .next() - .hide() - .menu(); - }); - </script> -</head> -<body> - -<div> - <div> - <button id="rerun">Run last action</button> - <button id="select">Select an action</button> - </div> - <ul> - <li><div>Open...</div></li> - <li><div>Save</div></li> - <li><div>Delete</div></li> - </ul> -</div> - -<div class="demo-description"> -<p>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.</p> -</div> -</body> -</html> 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 @@ -<!doctype html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>jQuery UI Button - Toolbar</title> - <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/button.js"></script> - <link rel="stylesheet" href="../demos.css"> - <style> - #toolbar { - padding: 4px; - display: inline-block; - } - </style> - <script> - $(function() { - $( "#beginning" ).button({ - text: false, - icons: { - primary: "ui-icon-seek-start" - } - }); - $( "#rewind" ).button({ - text: false, - icons: { - primary: "ui-icon-seek-prev" - } - }); - $( "#play" ).button({ - text: false, - icons: { - primary: "ui-icon-play" - } - }) - .on( "click", function() { - var options; - if ( $( this ).text() === "play" ) { - options = { - label: "pause", - icons: { - primary: "ui-icon-pause" - } - }; - } else { - options = { - label: "play", - icons: { - primary: "ui-icon-play" - } - }; - } - $( this ).button( "option", options ); - }); - $( "#stop" ).button({ - text: false, - icons: { - primary: "ui-icon-stop" - } - }) - .on( "click", function() { - $( "#play" ).button( "option", { - label: "play", - icons: { - primary: "ui-icon-play" - } - }); - }); - $( "#forward" ).button({ - text: false, - icons: { - primary: "ui-icon-seek-next" - } - }); - $( "#end" ).button({ - text: false, - icons: { - primary: "ui-icon-seek-end" - } - }); - $( "#shuffle" ).button(); - $( "#repeat" ).buttonset(); - }); - </script> -</head> -<body> - -<div id="toolbar" class="ui-widget-header ui-corner-all"> - <button id="beginning">go to beginning</button> - <button id="rewind">rewind</button> - <button id="play">play</button> - <button id="stop">stop</button> - <button id="forward">fast forward</button> - <button id="end">go to end</button> - - <input type="checkbox" id="shuffle" /><label for="shuffle">Shuffle</label> - - <span id="repeat"> - <input type="radio" id="repeat0" name="repeat" checked="checked" /><label for="repeat0">No Repeat</label> - <input type="radio" id="repeat1" name="repeat" /><label for="repeat1">Once</label> - <input type="radio" id="repeatall" name="repeat" /><label for="repeatall">All</label> - </span> -</div> - -<div class="demo-description"> -<p> - 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. -</p> -</div> -</body> -</html> 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 @@ <meta charset="utf-8"> <title>jQuery UI Checkboxradio - Default functionality</title> <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/checkboxradio.js"></script> <link rel="stylesheet" href="../demos.css"> - <script> - $(function() { + <script src="../../external/requirejs/require.js"></script> + <script src="../bootstrap.js"> $( "input" ).checkboxradio({ label: "foo" }); - }); </script> </head> <body> 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 @@ <meta charset="utf-8"> <title>jQuery UI Checkboxradio - No Icons</title> <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/checkboxradio.js"></script> <link rel="stylesheet" href="../demos.css"> - <script> - $(function() { + <script src="../../external/requirejs/require.js"></script> + <script src="../bootstrap.js"> $( "input" ).checkboxradio({ icon: false }); - }); </script> </head> <body> 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 @@ <meta charset="utf-8"> <title>jQuery UI Checkboxradio - Product Selector</title> <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/checkboxradio.js"></script> - <script src="../../ui/controlgroup.js"></script> <link rel="stylesheet" href="../demos.css"> - <script> - $(function() { + <script src="../../external/requirejs/require.js"></script> + <script src="../bootstrap.js"> $( "input" ).checkboxradio(); $( "[name='shape']").on( "change", function(){ $( ".shape" ).removeClass( "circle pill square rectangle" ) @@ -34,7 +29,6 @@ $( ".toggles" ).controlgroup({ direction: "vertical" }); - }); </script> <style> .shape { diff --git a/demos/checkboxradio/radiogroup.html b/demos/checkboxradio/radiogroup.html index b307db82d..bfca290b0 100644 --- a/demos/checkboxradio/radiogroup.html +++ b/demos/checkboxradio/radiogroup.html @@ -4,17 +4,11 @@ <meta charset="utf-8"> <title>jQuery UI Checkboxradio - Radio Group</title> <link rel="stylesheet" href="../../themes/base/all.css"> - <script src="../../external/jquery/jquery.js"></script> - <script src="../../ui/core.js"></script> - <script src="../../ui/widget.js"></script> - <script src="../../ui/checkboxradio.js"></script> - <script src="../../ui/controlgroup.js"></script> <link rel="stylesheet" href="../demos.css"> - <script> - $(function() { + <script src="../../external/requirejs/require.js"></script> + <script src="../bootstrap.js"> $( "input" ).checkboxradio(); $( "fieldset" ).controlgroup(); - }); </script> </head> <body> diff --git a/tests/unit/button/common-deprecated.js b/tests/unit/button/common-deprecated.js index 1441d3a8a..0f03bdba2 100644 --- a/tests/unit/button/common-deprecated.js +++ b/tests/unit/button/common-deprecated.js @@ -1,6 +1,6 @@ define( [ "lib/common", - "ui/button" + "ui/widgets/button" ], function( common ) { common.testWidget( "button", { diff --git a/tests/unit/button/core.js b/tests/unit/button/core.js index a7c164a33..de26b0312 100644 --- a/tests/unit/button/core.js +++ b/tests/unit/button/core.js @@ -1,5 +1,6 @@ define( [ "jquery", + "ui/safe-active-element", "ui/widgets/button" ], function( $ ) { diff --git a/tests/unit/button/deprecated.js b/tests/unit/button/deprecated.js index bb023ab4f..fac02e2a6 100644 --- a/tests/unit/button/deprecated.js +++ b/tests/unit/button/deprecated.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/button" + "ui/widgets/button" ], function( $ ) { module( "Button (deprecated): core" ); diff --git a/tests/unit/checkboxradio/common.js b/tests/unit/checkboxradio/common.js index 6a739435f..0dd663d07 100644 --- a/tests/unit/checkboxradio/common.js +++ b/tests/unit/checkboxradio/common.js @@ -1,6 +1,6 @@ define( [ "lib/common", - "ui/checkboxradio" + "ui/widgets/checkboxradio" ], function( common ) { common.testWidget( "checkboxradio", { diff --git a/tests/unit/checkboxradio/core.js b/tests/unit/checkboxradio/core.js index e70ca58c1..70ed4bb69 100644 --- a/tests/unit/checkboxradio/core.js +++ b/tests/unit/checkboxradio/core.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/checkboxradio" + "ui/widgets/checkboxradio" ], function( $ ) { module( "Checkboxradio: core" ); diff --git a/tests/unit/checkboxradio/events.js b/tests/unit/checkboxradio/events.js index e5909a386..ad7f1e75f 100644 --- a/tests/unit/checkboxradio/events.js +++ b/tests/unit/checkboxradio/events.js @@ -1,80 +1,10 @@ define( [ "jquery", - "ui/checkboxradio" + "ui/widgets/checkboxradio" ], function( $ ) { module( "Checkboxradio: events" ); -asyncTest( "form reset / click", function( assert ) { - expect( 35 ); - - var radios = [ - $( "#radio11" ).checkboxradio(), - $( "#radio12" ).checkboxradio(), - $( "#radio13" ).checkboxradio() - ], - widgets = [ - radios[ 0 ].checkboxradio( "widget" ), - radios[ 1 ].checkboxradio( "widget" ), - radios[ 2 ].checkboxradio( "widget" ) - ], - form1 = $( "#form1" ), - form2 = $( "#form2" ); - - // Checkes that only the specified radio is checked in the group - function assertChecked( checked ) { - $.each( widgets, function( index ) { - var method = index === checked ? "hasClasses" : "lacksClasses"; - - assert[ method ]( widgets[ index ], "ui-checkboxradio-checked ui-state-active" ); - } ); - } - - // Checks the form count on each form - function assertFormCount( count ) { - equal( form1.data( "uiCheckboxradioCount" ), count, "Form1 has a count of " + count ); - equal( form2.data( "uiCheckboxradioCount" ), 3, "Form2 has a count of 3" ); - } - - // Run the tests - function testForms( current, start ) { - assertChecked( 2 ); - - if ( !start && current !== 0 ) { - radios[ current - 1 ].checkboxradio( "destroy" ); - } - - assertFormCount( 3 - current ); - - radios[ current ].prop( "checked", true ); - radios[ current ].trigger( "change" ); - assertChecked( current ); - - form1.trigger( "reset" ); - } - - // Recoursivly run the tests in a setTimeout with call back for the resets - function iterate( i ) { - setTimeout( function() { - if ( i < 3 ) { - testForms( i ); - iterate( i + 1 ); - return; - } - radios[ 2 ].checkboxradio( "destroy" ); - assertChecked( false ); - start(); - } ); - } - - $( "#form2 input" ).checkboxradio(); - - // Check the starting state then kick everything off - testForms( 0, true ); - iterate( 0 ); - -} ); - asyncTest( "Resetting a checkbox's form should refresh the visual state of the checkbox", function( assert ) { diff --git a/tests/unit/checkboxradio/methods.js b/tests/unit/checkboxradio/methods.js index f189c9eea..c0ce9fde6 100644 --- a/tests/unit/checkboxradio/methods.js +++ b/tests/unit/checkboxradio/methods.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/checkboxradio" + "ui/widgets/checkboxradio" ], function( $ ) { module( "Checkboxradio: methods" ); diff --git a/tests/unit/checkboxradio/options.js b/tests/unit/checkboxradio/options.js index 11bd072ca..1998ff54e 100644 --- a/tests/unit/checkboxradio/options.js +++ b/tests/unit/checkboxradio/options.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/checkboxradio" + "ui/widgets/checkboxradio" ], function( $ ) { module( "Checkboxradio: options" ); diff --git a/ui/widgets/button.js b/ui/widgets/button.js index 34a2afa40..2e6cc1f3c 100644 --- a/ui/widgets/button.js +++ b/ui/widgets/button.js @@ -12,8 +12,7 @@ //>>description: Enhances a form with themeable buttons. //>>docs: http://api.jqueryui.com/button/ //>>demos: http://jqueryui.com/button/ -//>>css.structure: ../themes/base/core.css -//>>css.structure: ../themes/base/button.css +//>>css.structure: ../themes/base/core.css, ../themes/base/button.css //>>css.theme: ../themes/base/theme.css ( function( factory ) { diff --git a/ui/checkboxradio.js b/ui/widgets/checkboxradio.js index 84f69afaa..781274b9b 100644 --- a/ui/checkboxradio.js +++ b/ui/widgets/checkboxradio.js @@ -14,8 +14,10 @@ // AMD. Register as an anonymous module. define( [ "jquery", - "./core", - "./widget" + "../escape-selector", + "../form-reset-mixin", + "../labels", + "../widget" ], factory ); } else { @@ -24,19 +26,7 @@ } }( function( $ ) { -// Remove and replace with reset handler extension -var formResetHandler = function() { - var form = $( this ); - - // Wait for the form reset to actually happen before refreshing - setTimeout( function() { - - // We dont filter for css only versions since css only is not supported - form.find( ".ui-checkboxradio" ).checkboxradio( "refresh" ); - } ); - }; - -$.widget( "ui.checkboxradio", { +$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { version: "@VERSION", options: { disabled: null, @@ -91,20 +81,12 @@ $.widget( "ui.checkboxradio", { }, _create: function() { - var formCount, - checked = this.element[ 0 ].checked, - form = this.element.form(); - this.formParent = !!form.length ? form : $( "body" ); - - formCount = this.formParent.data( "uiCheckboxradioCount" ) || 0; + var checked = this.element[ 0 ].checked; - // We don't use _on and _off here because we want all the checkboxes in the same form to use - // single handler which handles all the checkboxradio widgets in the form - if ( formCount === 0 ) { - this.formParent.on( "reset." + this.widgetFullName, formResetHandler ); - } + this._bindFormResetHandler(); - this.formParent.data( "uiCheckboxradioCount", formCount + 1 ); + // this.form is set by the form-reset-mixin + this.formParent = this.form.length ? this.form : $( "body" ); if ( this.options.disabled == null ) { this.options.disabled = this.element[ 0 ].disabled || false; @@ -199,13 +181,7 @@ $.widget( "ui.checkboxradio", { }, _destroy: function() { - var formCount = this.formParent.data( "uiCheckboxradioCount" ) - 1; - - this.formParent.data( "uiCheckboxradioCount", formCount ); - - if ( formCount === 0 ) { - this.formParent.off( "reset." + this.widgetFullName, formResetHandler ); - } + this._unbindFormResetHandler(); if ( this.icon ) { this.icon.remove(); @@ -282,7 +258,7 @@ $.widget( "ui.checkboxradio", { } } -} ); +} ] ); return $.ui.checkboxradio; diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index f79b2baed..3a0b6deef 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -250,17 +250,19 @@ $.widget( "ui.spinner", { // Button bindings this.buttons = this.uiSpinner.children( "a" ) .attr( "tabIndex", -1 ) - .button(); + .button( { + classes: { + "ui-button": "" + } + } ); // TODO: Right now button does not support classes this is already updated in button PR this._removeClass( this.buttons, "ui-corner-all" ); this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" ); this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" ); - this._addClass( this.buttons.first().find( ".ui-button-text span" ), null, - "ui-icon " + this.options.icons.up ); - this._addClass( this.buttons.last().find( ".ui-button-text span" ), null, - "ui-icon " + this.options.icons.down ); + this.buttons.first().button( "option", "icon", this.options.icons.up ); + this.buttons.last().button( "option", "icon", this.options.icons.down ); // IE 6 doesn't understand height: 50% for the buttons // unless the wrapper has an explicit height |