]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Updates for new button widget and classes option
authorAlexander Schmitz <arschmitz@gmail.com>
Thu, 8 Jan 2015 02:51:38 +0000 (21:51 -0500)
committerAlexander Schmitz <arschmitz@gmail.com>
Thu, 8 Oct 2015 18:02:35 +0000 (14:02 -0400)
20 files changed:
demos/button/default.html
demos/button/icons.html
demos/button/splitbutton.html [deleted file]
demos/button/toolbar.html [deleted file]
demos/checkboxradio/default.html
demos/checkboxradio/no-icons.html
demos/checkboxradio/product-selector.html
demos/checkboxradio/radiogroup.html
tests/unit/button/common-deprecated.js
tests/unit/button/core.js
tests/unit/button/deprecated.js
tests/unit/checkboxradio/common.js
tests/unit/checkboxradio/core.js
tests/unit/checkboxradio/events.js
tests/unit/checkboxradio/methods.js
tests/unit/checkboxradio/options.js
ui/checkboxradio.js [deleted file]
ui/widgets/button.js
ui/widgets/checkboxradio.js [new file with mode: 0644]
ui/widgets/spinner.js

index 5418fd8c975a36f4453704675722032b397c4e1d..644dcd2254162592a0fdff5d42dd3be644c1dde3 100644 (file)
@@ -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>
index a8deca9cd6ff5fdd29e2f2977a310f90e41a9285..af4e3000cda6660279371a04f54fd14125f8fd6a 100644 (file)
@@ -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 (file)
index 6b7562d..0000000
+++ /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 (file)
index f2c242f..0000000
+++ /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>
index c8f4c55668f7e6fb4c989645215a8945b07afc62..c8c1a800da21e81d9f85e75101cee34ca5739fc7 100644 (file)
@@ -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>
index 64b511246848e2db0ffaa7cc42c7f39f73e65828..c738d8ca88278118732d463c822767a4c6c589b8 100644 (file)
@@ -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>
index f8da071187d7b6116831dcad339c36077063b2bc..4e6db4507b339ad71061d4b41a3e32f1a0cdc977 100644 (file)
@@ -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 {
index b307db82d7ffeada07036197ed9cd4da781b39ae..bfca290b0d116c83bc24f0d70aee01b56b96597d 100644 (file)
@@ -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>
index 1441d3a8aeac82ee97f159b692ffab980d40d780..0f03bdba271d8afc3c0d04eef4969be7b639a499 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "lib/common",
-       "ui/button"
+       "ui/widgets/button"
 ], function( common ) {
 
 common.testWidget( "button", {
index a7c164a33301bce08b4005d02785b8c340289bf9..de26b03127f9d330037048dcfc415092648f54d8 100644 (file)
@@ -1,5 +1,6 @@
 define( [
        "jquery",
+       "ui/safe-active-element",
        "ui/widgets/button"
 ], function( $ ) {
 
index bb023ab4f471432fef41ba607ad5b256d47c0b96..fac02e2a636d7c2117938005ad48ca67bf161189 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/button"
+       "ui/widgets/button"
 ], function( $ ) {
 
 module( "Button (deprecated): core" );
index 6a739435f91b0f858298cbd49b2c95a841e80843..0dd663d07a816107d690bbed0884dc211573140c 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "lib/common",
-       "ui/checkboxradio"
+       "ui/widgets/checkboxradio"
 ], function( common ) {
 
 common.testWidget( "checkboxradio", {
index e70ca58c138a6fae63f4c183b3b27b288b878e53..70ed4bb69b57509a731963004d8f6200014722cd 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/checkboxradio"
+       "ui/widgets/checkboxradio"
 ], function( $ ) {
 
 module( "Checkboxradio: core" );
index e5909a386836e414a137d644bdd30a8c7a2598f0..ad7f1e75f4ae94a832f9888d154ff201d8e20f36 100644 (file)
@@ -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 ) {
index f189c9eeae228745a9e9282dfe18c7c73e756073..c0ce9fde6735b49570abcd2c90521f771f4115d8 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/checkboxradio"
+       "ui/widgets/checkboxradio"
 ], function( $ ) {
 
 module( "Checkboxradio: methods" );
index 11bd072ca4110aebc27b7077f317a11e68cdf163..1998ff54e6d0d3aa26e71b8a74c6892393869aff 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/checkboxradio"
+       "ui/widgets/checkboxradio"
 ], function( $ ) {
 
 module( "Checkboxradio: options" );
diff --git a/ui/checkboxradio.js b/ui/checkboxradio.js
deleted file mode 100644 (file)
index 84f69af..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-/*!
- * jQuery UI Checkboxradio @VERSION
- * http://jqueryui.com
- *
- * Copyright 2014 jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- *
- * http://api.jqueryui.com/checkboxradio/
- */
-( function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define( [
-                       "jquery",
-                       "./core",
-                       "./widget"
-               ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery );
-       }
-}( 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", {
-       version: "@VERSION",
-       options: {
-               disabled: null,
-               label: null,
-               icon: true,
-               classes: {
-                       "ui-checkboxradio-label": "ui-corner-all",
-                       "ui-checkboxradio-icon": "ui-corner-all"
-               }
-       },
-
-       _getCreateOptions: function() {
-               var disabled, labels,
-                       that = this,
-                       options = this._super() || {};
-
-               // We read the type here, because it makes more sense to throw a element type error first,
-               // rather then the error for lack of a label. Often if its the wrong type, it
-               // won't have a label (e.g. calling on a div, btn, etc)
-               this._readType();
-
-               labels = this.element.labels();
-
-               // Todo: For now we will use the last label we need to check about the best
-               // way to handle multiple labels with some accessability experts
-               this.label = $( labels[ labels.length - 1 ] );
-               if ( !this.label.length ) {
-                       $.error( "No label found for checkboxradio widget" );
-               }
-
-               this.originalLabel = "";
-
-               // We need to get the label text but this may also need to make sure it does not contain the
-               // input itself.
-               this.label.contents().not( this.element ).each( function() {
-
-                       // The label contents could be text html or a mix we concat each element to get a string
-                       // representation of the label without the input as part of it.
-                       that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
-               } );
-
-               // Set the label option if we found label text
-               if ( this.originalLabel ) {
-                       options.label = this.originalLabel;
-               }
-
-               disabled = this.element[ 0 ].disabled;
-               if ( disabled != null ) {
-                       options.disabled = disabled;
-               }
-               return options;
-       },
-
-       _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;
-
-               // 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.formParent.data( "uiCheckboxradioCount", formCount + 1 );
-
-               if ( this.options.disabled == null ) {
-                       this.options.disabled = this.element[ 0 ].disabled || false;
-               }
-
-               this._setOption( "disabled", this.options.disabled );
-               this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
-               this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
-
-               if ( this.type === "radio" ) {
-                       this._addClass( this.label, "ui-checkboxradio-radio-label" );
-               }
-
-               if ( this.options.label && this.options.label !== this.originalLabel ) {
-                       this._updateLabel();
-               } else if ( this.originalLabel ) {
-                       this.options.label = this.originalLabel;
-               }
-
-               this._enhance();
-
-               if ( checked ) {
-                       this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
-                       this._addClass( this.icon, null, "ui-state-hover" );
-               }
-
-               this._on( {
-                       "change": "_toggleClasses",
-                       "focus": function() {
-                               this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
-                       },
-                       "blur": function() {
-                               this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
-                       }
-               } );
-       },
-
-       _readType: function() {
-               var nodeName = this.element[ 0 ].nodeName.toLowerCase();
-               this.type = this.element[ 0 ].type;
-               if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
-                       $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
-                               " and element.type=" + this.type );
-               }
-       },
-
-       // Support jQuery Mobile enhanced option
-       _enhance: function() {
-               this._updateIcon( this.element[ 0 ].checked );
-       },
-
-       widget: function() {
-               return this.label;
-       },
-
-       _getRadioGroup: function() {
-               var name = this.element[ 0 ].name,
-                       that = this,
-                       radios = $( [] );
-
-               if ( name ) {
-                       name = $.ui.escapeSelector( name );
-                       radios = this.formParent.find( "[name='" + $.ui.escapeSelector( name ) + "']" ).filter( function() {
-                               var form = $( this ).form();
-                               return ( form.length ? form : $( "body" ) )[ 0 ] === that.formParent[ 0 ];
-                       } );
-               }
-               return radios.not( this.element );
-       },
-
-       _toggleClasses: function() {
-               var checked = this.element[ 0 ].checked;
-               this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
-
-               if ( this.options.icon && this.type === "checkbox" ) {
-
-                       // We add ui-state-highlight to change the icon color
-                       this._toggleClass( this.icon, null, "ui-icon-check ui-state-highlight", checked )
-                               ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
-               }
-               if ( this.type === "radio" ) {
-                       this._getRadioGroup()
-                               .each( function() {
-                                       var instance = $( this ).checkboxradio( "instance" );
-
-                                       if ( instance ) {
-                                               instance._removeClass( instance.label,
-                                                       "ui-checkboxradio-checked", "ui-state-active" );
-                                       }
-                               } );
-               }
-       },
-
-       _destroy: function() {
-               var formCount = this.formParent.data( "uiCheckboxradioCount" ) - 1;
-
-               this.formParent.data( "uiCheckboxradioCount", formCount );
-
-               if ( formCount === 0 ) {
-                       this.formParent.off( "reset." + this.widgetFullName, formResetHandler );
-               }
-
-               if ( this.icon ) {
-                       this.icon.remove();
-                       this.iconSpace.remove();
-               }
-       },
-
-       _setOption: function( key, value ) {
-
-               // We don't alow the value to be set to nothing
-               if ( key === "label" && !value ) {
-                       return;
-               }
-
-               this._super( key, value );
-
-               if ( key === "disabled" ) {
-                       this._toggleClass( this.label, null, "ui-state-disabled", value );
-                       this.element[ 0 ].disabled = value;
-
-                       // Don't refresh if disabled
-                       return;
-               }
-               this.refresh();
-       },
-
-       _updateIcon: function( checked ) {
-               var toAdd = "ui-icon ui-icon-background ";
-
-               if ( this.options.icon ) {
-                       if ( !this.icon ) {
-                               this.icon = $( "<span>" );
-                               this.iconSpace = $( "<span> </span>" );
-                               this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
-                       }
-
-                       if ( this.type === "checkbox" ) {
-                               toAdd += checked ? "ui-icon-check" : "ui-icon-blank";
-                               this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
-                       } else {
-                               toAdd += "ui-icon-blank";
-                       }
-                       this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
-                       if ( !checked ) {
-                               this._removeClass( this.icon, null, "ui-icon-check" );
-                       }
-                       this.icon.prependTo( this.label ).after( this.iconSpace );
-               } else if ( this.icon !== undefined ) {
-                       this.icon.remove();
-                       this.iconSpace.remove();
-                       delete this.icon;
-               }
-       },
-
-       _updateLabel: function() {
-
-               // Remove the contents of the label ( minus the icon, icon space, and input )
-               this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove();
-               this.label.append( this.options.label );
-       },
-
-       refresh: function() {
-               var checked = this.element[ 0 ].checked,
-                       isDisabled = this.element[ 0 ].disabled;
-
-               this._updateIcon( checked );
-               this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
-               if ( this.options.label !== null ) {
-                       this._updateLabel();
-               }
-
-               if ( isDisabled !== this.options.disabled ) {
-                       this._setOptions( { "disabled": isDisabled } );
-               }
-       }
-
-} );
-
-return $.ui.checkboxradio;
-
-} ) );
index 34a2afa407ddb0b38c0bbb9bd2ca83693910afc5..2e6cc1f3c635e872ddd4171ff21238a1b0622e5d 100644 (file)
@@ -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/widgets/checkboxradio.js b/ui/widgets/checkboxradio.js
new file mode 100644 (file)
index 0000000..781274b
--- /dev/null
@@ -0,0 +1,265 @@
+/*!
+ * jQuery UI Checkboxradio @VERSION
+ * http://jqueryui.com
+ *
+ * Copyright 2014 jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ *
+ * http://api.jqueryui.com/checkboxradio/
+ */
+( function( factory ) {
+       if ( typeof define === "function" && define.amd ) {
+
+               // AMD. Register as an anonymous module.
+               define( [
+                       "jquery",
+                       "../escape-selector",
+                       "../form-reset-mixin",
+                       "../labels",
+                       "../widget"
+               ], factory );
+       } else {
+
+               // Browser globals
+               factory( jQuery );
+       }
+}( function( $ ) {
+
+$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
+       version: "@VERSION",
+       options: {
+               disabled: null,
+               label: null,
+               icon: true,
+               classes: {
+                       "ui-checkboxradio-label": "ui-corner-all",
+                       "ui-checkboxradio-icon": "ui-corner-all"
+               }
+       },
+
+       _getCreateOptions: function() {
+               var disabled, labels,
+                       that = this,
+                       options = this._super() || {};
+
+               // We read the type here, because it makes more sense to throw a element type error first,
+               // rather then the error for lack of a label. Often if its the wrong type, it
+               // won't have a label (e.g. calling on a div, btn, etc)
+               this._readType();
+
+               labels = this.element.labels();
+
+               // Todo: For now we will use the last label we need to check about the best
+               // way to handle multiple labels with some accessability experts
+               this.label = $( labels[ labels.length - 1 ] );
+               if ( !this.label.length ) {
+                       $.error( "No label found for checkboxradio widget" );
+               }
+
+               this.originalLabel = "";
+
+               // We need to get the label text but this may also need to make sure it does not contain the
+               // input itself.
+               this.label.contents().not( this.element ).each( function() {
+
+                       // The label contents could be text html or a mix we concat each element to get a string
+                       // representation of the label without the input as part of it.
+                       that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
+               } );
+
+               // Set the label option if we found label text
+               if ( this.originalLabel ) {
+                       options.label = this.originalLabel;
+               }
+
+               disabled = this.element[ 0 ].disabled;
+               if ( disabled != null ) {
+                       options.disabled = disabled;
+               }
+               return options;
+       },
+
+       _create: function() {
+               var checked = this.element[ 0 ].checked;
+
+               this._bindFormResetHandler();
+
+               // 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;
+               }
+
+               this._setOption( "disabled", this.options.disabled );
+               this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
+               this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
+
+               if ( this.type === "radio" ) {
+                       this._addClass( this.label, "ui-checkboxradio-radio-label" );
+               }
+
+               if ( this.options.label && this.options.label !== this.originalLabel ) {
+                       this._updateLabel();
+               } else if ( this.originalLabel ) {
+                       this.options.label = this.originalLabel;
+               }
+
+               this._enhance();
+
+               if ( checked ) {
+                       this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
+                       this._addClass( this.icon, null, "ui-state-hover" );
+               }
+
+               this._on( {
+                       "change": "_toggleClasses",
+                       "focus": function() {
+                               this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
+                       },
+                       "blur": function() {
+                               this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
+                       }
+               } );
+       },
+
+       _readType: function() {
+               var nodeName = this.element[ 0 ].nodeName.toLowerCase();
+               this.type = this.element[ 0 ].type;
+               if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
+                       $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
+                               " and element.type=" + this.type );
+               }
+       },
+
+       // Support jQuery Mobile enhanced option
+       _enhance: function() {
+               this._updateIcon( this.element[ 0 ].checked );
+       },
+
+       widget: function() {
+               return this.label;
+       },
+
+       _getRadioGroup: function() {
+               var name = this.element[ 0 ].name,
+                       that = this,
+                       radios = $( [] );
+
+               if ( name ) {
+                       name = $.ui.escapeSelector( name );
+                       radios = this.formParent.find( "[name='" + $.ui.escapeSelector( name ) + "']" ).filter( function() {
+                               var form = $( this ).form();
+                               return ( form.length ? form : $( "body" ) )[ 0 ] === that.formParent[ 0 ];
+                       } );
+               }
+               return radios.not( this.element );
+       },
+
+       _toggleClasses: function() {
+               var checked = this.element[ 0 ].checked;
+               this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
+
+               if ( this.options.icon && this.type === "checkbox" ) {
+
+                       // We add ui-state-highlight to change the icon color
+                       this._toggleClass( this.icon, null, "ui-icon-check ui-state-highlight", checked )
+                               ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
+               }
+               if ( this.type === "radio" ) {
+                       this._getRadioGroup()
+                               .each( function() {
+                                       var instance = $( this ).checkboxradio( "instance" );
+
+                                       if ( instance ) {
+                                               instance._removeClass( instance.label,
+                                                       "ui-checkboxradio-checked", "ui-state-active" );
+                                       }
+                               } );
+               }
+       },
+
+       _destroy: function() {
+               this._unbindFormResetHandler();
+
+               if ( this.icon ) {
+                       this.icon.remove();
+                       this.iconSpace.remove();
+               }
+       },
+
+       _setOption: function( key, value ) {
+
+               // We don't alow the value to be set to nothing
+               if ( key === "label" && !value ) {
+                       return;
+               }
+
+               this._super( key, value );
+
+               if ( key === "disabled" ) {
+                       this._toggleClass( this.label, null, "ui-state-disabled", value );
+                       this.element[ 0 ].disabled = value;
+
+                       // Don't refresh if disabled
+                       return;
+               }
+               this.refresh();
+       },
+
+       _updateIcon: function( checked ) {
+               var toAdd = "ui-icon ui-icon-background ";
+
+               if ( this.options.icon ) {
+                       if ( !this.icon ) {
+                               this.icon = $( "<span>" );
+                               this.iconSpace = $( "<span> </span>" );
+                               this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
+                       }
+
+                       if ( this.type === "checkbox" ) {
+                               toAdd += checked ? "ui-icon-check" : "ui-icon-blank";
+                               this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
+                       } else {
+                               toAdd += "ui-icon-blank";
+                       }
+                       this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
+                       if ( !checked ) {
+                               this._removeClass( this.icon, null, "ui-icon-check" );
+                       }
+                       this.icon.prependTo( this.label ).after( this.iconSpace );
+               } else if ( this.icon !== undefined ) {
+                       this.icon.remove();
+                       this.iconSpace.remove();
+                       delete this.icon;
+               }
+       },
+
+       _updateLabel: function() {
+
+               // Remove the contents of the label ( minus the icon, icon space, and input )
+               this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove();
+               this.label.append( this.options.label );
+       },
+
+       refresh: function() {
+               var checked = this.element[ 0 ].checked,
+                       isDisabled = this.element[ 0 ].disabled;
+
+               this._updateIcon( checked );
+               this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
+               if ( this.options.label !== null ) {
+                       this._updateLabel();
+               }
+
+               if ( isDisabled !== this.options.disabled ) {
+                       this._setOptions( { "disabled": isDisabled } );
+               }
+       }
+
+} ] );
+
+return $.ui.checkboxradio;
+
+} ) );
index f79b2baedf27edfda25761f0f546c4b6ddfd7ed0..3a0b6deef3dbe0b826dfbdf4fd1d4b91c6041a1c 100644 (file)
@@ -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