<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>
<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( {
icon: "ui-icon-gear",
iconPosition: "bottom"
} );
- } );
</script>
</head>
<body>
<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>
+++ /dev/null
-<!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>
+++ /dev/null
-<!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>
<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>
<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>
<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" )
$( ".toggles" ).controlgroup({
direction: "vertical"
});
- });
</script>
<style>
.shape {
<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>
define( [
"lib/common",
- "ui/button"
+ "ui/widgets/button"
], function( common ) {
common.testWidget( "button", {
define( [
"jquery",
+ "ui/safe-active-element",
"ui/widgets/button"
], function( $ ) {
define( [
"jquery",
- "ui/button"
+ "ui/widgets/button"
], function( $ ) {
module( "Button (deprecated): core" );
define( [
"lib/common",
- "ui/checkboxradio"
+ "ui/widgets/checkboxradio"
], function( common ) {
common.testWidget( "checkboxradio", {
define( [
"jquery",
- "ui/checkboxradio"
+ "ui/widgets/checkboxradio"
], function( $ ) {
module( "Checkboxradio: core" );
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 ) {
define( [
"jquery",
- "ui/checkboxradio"
+ "ui/widgets/checkboxradio"
], function( $ ) {
module( "Checkboxradio: methods" );
define( [
"jquery",
- "ui/checkboxradio"
+ "ui/widgets/checkboxradio"
], function( $ ) {
module( "Checkboxradio: options" );
+++ /dev/null
-/*!
- * 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;
-
-} ) );
//>>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 ) {
--- /dev/null
+/*!
+ * 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;
+
+} ) );
// 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