]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Move button into widgets folder
authorAlexander Schmitz <arschmitz@gmail.com>
Wed, 15 Jul 2015 01:57:20 +0000 (21:57 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Sat, 8 Aug 2015 04:29:37 +0000 (00:29 -0400)
Ref #13885

demos/bootstrap.js
tests/unit/button/common.js
tests/unit/button/core.js
tests/unit/button/events.js
tests/unit/button/methods.js
tests/unit/button/options.js
ui/button.js [deleted file]
ui/dialog.js
ui/spinner.js
ui/widgets/button.js [new file with mode: 0644]

index 71d2e4ef38af7069e3b504e0bedb2539c925e813..a2ce072eacf18244f7741ac7199bde8a8fad4806 100644 (file)
@@ -26,7 +26,8 @@ var effectsAll = [
 ];
 var widgets = [
        "accordion",
-       "autocomplete"
+       "autocomplete",
+       "button"
 ];
 
 function getPath( module ) {
index d376f4f05aa421f6903f74370699c82d4e8e16d7..0372cddbf1f663fa34c131318220c73ef3f56899 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "lib/common",
-       "ui/button"
+       "ui/widgets/button"
 ], function( common ) {
 
 common.testWidget( "button", {
index 8539464baea577938a69cb9fbf9b6c8265010ef6..f3ae2e583611be6c240a651def328c51f8c06c01 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/button"
+       "ui/widgets/button"
 ], function( $ ) {
 
 module("button: core");
index 63550e2f82991e3e0a7a6c1f5e28e94a95f75c28..d778b4a2bf343492c88040d8e08862fc2e020b04 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/button"
+       "ui/widgets/button"
 ], function( $ ) {
 
 module("button: events");
index be36096b22e3853dbfc6663ed0644c5ff073dead..29e91702219db981b9b7905f867066bbb152c003 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/button"
+       "ui/widgets/button"
 ], function( $ ) {
 
 module("button: methods");
index 23020fc100c2d62c9f33e4bef121071af45b4062..ad4169e147994580431027605bbaca2b3da56c44 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/button"
+       "ui/widgets/button"
 ], function( $ ) {
 
 module( "button: options" );
diff --git a/ui/button.js b/ui/button.js
deleted file mode 100644 (file)
index bc39181..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-/*!
- * jQuery UI Button @VERSION
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Button
-//>>group: Widgets
-//>>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.theme: ../themes/base/theme.css
-
-(function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define([
-                       "jquery",
-                       "./data",
-                       "./keycode",
-                       "./labels",
-                       "./version",
-                       "./widget"
-               ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery );
-       }
-}(function( $ ) {
-
-var lastActive,
-       baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
-       typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
-       formResetHandler = function() {
-               var form = $( this );
-               setTimeout(function() {
-                       form.find( ":ui-button" ).button( "refresh" );
-               }, 1 );
-       },
-       radioGroup = function( radio ) {
-               var name = radio.name,
-                       form = radio.form,
-                       radios = $( [] );
-               if ( name ) {
-                       name = name.replace( /'/g, "\\'" );
-                       if ( form ) {
-                               radios = $( form ).find( "[name='" + name + "'][type=radio]" );
-                       } else {
-                               radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
-                                       .filter(function() {
-                                               return !this.form;
-                                       });
-                       }
-               }
-               return radios;
-       };
-
-$.widget( "ui.button", {
-       version: "@VERSION",
-       defaultElement: "<button>",
-       options: {
-               disabled: null,
-               text: true,
-               label: null,
-               icons: {
-                       primary: null,
-                       secondary: null
-               }
-       },
-       _create: function() {
-               this.element.closest( "form" )
-                       .off( "reset" + this.eventNamespace )
-                       .on( "reset" + this.eventNamespace, formResetHandler );
-
-               if ( typeof this.options.disabled !== "boolean" ) {
-                       this.options.disabled = !!this.element.prop( "disabled" );
-               } else {
-                       this.element.prop( "disabled", this.options.disabled );
-               }
-
-               this._determineButtonType();
-               this.hasTitle = !!this.buttonElement.attr( "title" );
-
-               var that = this,
-                       options = this.options,
-                       toggleButton = this.type === "checkbox" || this.type === "radio",
-                       activeClass = !toggleButton ? "ui-state-active" : "";
-
-               if ( options.label === null ) {
-                       options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
-               }
-
-               this._hoverable( this.buttonElement );
-
-               this.buttonElement
-                       .addClass( baseClasses )
-                       .attr( "role", "button" )
-                       .on( "mouseenter" + this.eventNamespace, function() {
-                               if ( options.disabled ) {
-                                       return;
-                               }
-                               if ( this === lastActive ) {
-                                       $( this ).addClass( "ui-state-active" );
-                               }
-                       })
-                       .on( "mouseleave" + this.eventNamespace, function() {
-                               if ( options.disabled ) {
-                                       return;
-                               }
-                               $( this ).removeClass( activeClass );
-                       })
-                       .on( "click" + this.eventNamespace, function( event ) {
-                               if ( options.disabled ) {
-                                       event.preventDefault();
-                                       event.stopImmediatePropagation();
-                               }
-                       });
-
-               // Can't use _focusable() because the element that receives focus
-               // and the element that gets the ui-state-focus class are different
-               this._on({
-                       focus: function() {
-                               this.buttonElement.addClass( "ui-state-focus" );
-                       },
-                       blur: function() {
-                               this.buttonElement.removeClass( "ui-state-focus" );
-                       }
-               });
-
-               if ( toggleButton ) {
-                       this.element.on( "change" + this.eventNamespace, function() {
-                               that.refresh();
-                       });
-               }
-
-               if ( this.type === "checkbox" ) {
-                       this.buttonElement.on( "click" + this.eventNamespace, function() {
-                               if ( options.disabled ) {
-                                       return false;
-                               }
-                       });
-               } else if ( this.type === "radio" ) {
-                       this.buttonElement.on( "click" + this.eventNamespace, function() {
-                               if ( options.disabled ) {
-                                       return false;
-                               }
-                               $( this ).addClass( "ui-state-active" );
-                               that.buttonElement.attr( "aria-pressed", "true" );
-
-                               var radio = that.element[ 0 ];
-                               radioGroup( radio )
-                                       .not( radio )
-                                       .map(function() {
-                                               return $( this ).button( "widget" )[ 0 ];
-                                       })
-                                       .removeClass( "ui-state-active" )
-                                       .attr( "aria-pressed", "false" );
-                       });
-               } else {
-                       this.buttonElement
-                               .on( "mousedown" + this.eventNamespace, function() {
-                                       if ( options.disabled ) {
-                                               return false;
-                                       }
-                                       $( this ).addClass( "ui-state-active" );
-                                       lastActive = this;
-                                       that.document.one( "mouseup", function() {
-                                               lastActive = null;
-                                       });
-                               })
-                               .on( "mouseup" + this.eventNamespace, function() {
-                                       if ( options.disabled ) {
-                                               return false;
-                                       }
-                                       $( this ).removeClass( "ui-state-active" );
-                               })
-                               .on( "keydown" + this.eventNamespace, function(event) {
-                                       if ( options.disabled ) {
-                                               return false;
-                                       }
-                                       if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
-                                               $( this ).addClass( "ui-state-active" );
-                                       }
-                               })
-                               // see #8559, we bind to blur here in case the button element loses
-                               // focus between keydown and keyup, it would be left in an "active" state
-                               .on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
-                                       $( this ).removeClass( "ui-state-active" );
-                               });
-
-                       if ( this.buttonElement.is("a") ) {
-                               this.buttonElement.on( "keyup", function(event) {
-                                       if ( event.keyCode === $.ui.keyCode.SPACE ) {
-                                               // TODO pass through original event correctly (just as 2nd argument doesn't work)
-                                               $( this ).trigger( "click" );
-                                       }
-                               });
-                       }
-               }
-
-               this._setOption( "disabled", options.disabled );
-               this._resetButton();
-       },
-
-       _determineButtonType: function() {
-               var ancestor, labelSelector, checked;
-
-               if ( this.element.is("[type=checkbox]") ) {
-                       this.type = "checkbox";
-               } else if ( this.element.is("[type=radio]") ) {
-                       this.type = "radio";
-               } else if ( this.element.is("input") ) {
-                       this.type = "input";
-               } else {
-                       this.type = "button";
-               }
-
-               if ( this.type === "checkbox" || this.type === "radio" ) {
-                       // we don't search against the document in case the element
-                       // is disconnected from the DOM
-                       ancestor = this.element.parents().last();
-                       labelSelector = "label[for='" + this.element.attr("id") + "']";
-                       this.buttonElement = ancestor.find( labelSelector );
-                       if ( !this.buttonElement.length ) {
-                               ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
-                               this.buttonElement = ancestor.filter( labelSelector );
-                               if ( !this.buttonElement.length ) {
-                                       this.buttonElement = ancestor.find( labelSelector );
-                               }
-                       }
-                       this.element.addClass( "ui-helper-hidden-accessible" );
-
-                       checked = this.element.is( ":checked" );
-                       if ( checked ) {
-                               this.buttonElement.addClass( "ui-state-active" );
-                       }
-                       this.buttonElement.prop( "aria-pressed", checked );
-               } else {
-                       this.buttonElement = this.element;
-               }
-       },
-
-       widget: function() {
-               return this.buttonElement;
-       },
-
-       _destroy: function() {
-               this.element
-                       .removeClass( "ui-helper-hidden-accessible" );
-               this.buttonElement
-                       .removeClass( baseClasses + " ui-state-active " + typeClasses )
-                       .removeAttr( "role aria-pressed" )
-                       .html( this.buttonElement.find(".ui-button-text").html() );
-
-               if ( !this.hasTitle ) {
-                       this.buttonElement.removeAttr( "title" );
-               }
-       },
-
-       _setOption: function( key, value ) {
-               this._super( key, value );
-               if ( key === "disabled" ) {
-                       this.widget().toggleClass( "ui-state-disabled", !!value );
-                       this.element.prop( "disabled", !!value );
-                       if ( value ) {
-                               if ( this.type === "checkbox" || this.type === "radio" ) {
-                                       this.buttonElement.removeClass( "ui-state-focus" );
-                               } else {
-                                       this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
-                               }
-                       }
-                       return;
-               }
-               this._resetButton();
-       },
-
-       refresh: function() {
-               //See #8237 & #8828
-               var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
-
-               if ( isDisabled !== this.options.disabled ) {
-                       this._setOption( "disabled", isDisabled );
-               }
-               if ( this.type === "radio" ) {
-                       radioGroup( this.element[0] ).each(function() {
-                               if ( $( this ).is( ":checked" ) ) {
-                                       $( this ).button( "widget" )
-                                               .addClass( "ui-state-active" )
-                                               .attr( "aria-pressed", "true" );
-                               } else {
-                                       $( this ).button( "widget" )
-                                               .removeClass( "ui-state-active" )
-                                               .attr( "aria-pressed", "false" );
-                               }
-                       });
-               } else if ( this.type === "checkbox" ) {
-                       if ( this.element.is( ":checked" ) ) {
-                               this.buttonElement
-                                       .addClass( "ui-state-active" )
-                                       .attr( "aria-pressed", "true" );
-                       } else {
-                               this.buttonElement
-                                       .removeClass( "ui-state-active" )
-                                       .attr( "aria-pressed", "false" );
-                       }
-               }
-       },
-
-       _resetButton: function() {
-               if ( this.type === "input" ) {
-                       if ( this.options.label ) {
-                               this.element.val( this.options.label );
-                       }
-                       return;
-               }
-               var buttonElement = this.buttonElement.removeClass( typeClasses ),
-                       buttonText = $( "<span></span>", this.document[0] )
-                               .addClass( "ui-button-text" )
-                               .html( this.options.label )
-                               .appendTo( buttonElement.empty() )
-                               .text(),
-                       icons = this.options.icons,
-                       multipleIcons = icons.primary && icons.secondary,
-                       buttonClasses = [];
-
-               if ( icons.primary || icons.secondary ) {
-                       if ( this.options.text ) {
-                               buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
-                       }
-
-                       if ( icons.primary ) {
-                               buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
-                       }
-
-                       if ( icons.secondary ) {
-                               buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
-                       }
-
-                       if ( !this.options.text ) {
-                               buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
-
-                               if ( !this.hasTitle ) {
-                                       buttonElement.attr( "title", $.trim( buttonText ) );
-                               }
-                       }
-               } else {
-                       buttonClasses.push( "ui-button-text-only" );
-               }
-               buttonElement.addClass( buttonClasses.join( " " ) );
-       }
-});
-
-$.widget( "ui.buttonset", {
-       version: "@VERSION",
-       options: {
-               items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
-       },
-
-       _create: function() {
-               this.element.addClass( "ui-buttonset" );
-       },
-
-       _init: function() {
-               this.refresh();
-       },
-
-       _setOption: function( key, value ) {
-               if ( key === "disabled" ) {
-                       this.buttons.button( "option", key, value );
-               }
-
-               this._super( key, value );
-       },
-
-       refresh: function() {
-               var rtl = this.element.css( "direction" ) === "rtl",
-                       allButtons = this.element.find( this.options.items ),
-                       existingButtons = allButtons.filter( ":ui-button" );
-
-               // Initialize new buttons
-               allButtons.not( ":ui-button" ).button();
-
-               // Refresh existing buttons
-               existingButtons.button( "refresh" );
-
-               this.buttons = allButtons
-                       .map(function() {
-                               return $( this ).button( "widget" )[ 0 ];
-                       })
-                               .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
-                               .filter( ":first" )
-                                       .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
-                               .end()
-                               .filter( ":last" )
-                                       .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
-                               .end()
-                       .end();
-       },
-
-       _destroy: function() {
-               this.element.removeClass( "ui-buttonset" );
-               this.buttons
-                       .map(function() {
-                               return $( this ).button( "widget" )[ 0 ];
-                       })
-                               .removeClass( "ui-corner-left ui-corner-right" )
-                       .end()
-                       .button( "destroy" );
-       }
-});
-
-return $.ui.button;
-
-}));
index 2b1e71dbb92b64c7eb5d8848e5faa58ede58f68c..dc66329739ca66be4f652b0f062e143ae60669d9 100644 (file)
@@ -26,7 +26,7 @@
                        "./version",
                        "./keycode",
                        "./widget",
-                       "./button",
+                       "./widgets/button",
                        "./draggable",
                        "./focusable",
                        "./mouse",
index 241dcaa511b0099912ecb2412e9ab983efc7fa80..b8e6f88a05f7319a7e7514897d9f1ee3023bea32 100644 (file)
@@ -26,7 +26,7 @@
                        "./keycode",
                        "./safe-active-element",
                        "./widget",
-                       "./button"
+                       "./widgets/button"
                ], factory );
        } else {
 
diff --git a/ui/widgets/button.js b/ui/widgets/button.js
new file mode 100644 (file)
index 0000000..f5509b5
--- /dev/null
@@ -0,0 +1,421 @@
+/*!
+ * jQuery UI Button @VERSION
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Button
+//>>group: Widgets
+//>>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.theme: ../themes/base/theme.css
+
+(function( factory ) {
+       if ( typeof define === "function" && define.amd ) {
+
+               // AMD. Register as an anonymous module.
+               define([
+                       "jquery",
+                       "../data",
+                       "../keycode",
+                       "../labels",
+                       "../version",
+                       "../widget"
+               ], factory );
+       } else {
+
+               // Browser globals
+               factory( jQuery );
+       }
+}(function( $ ) {
+
+var lastActive,
+       baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
+       typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
+       formResetHandler = function() {
+               var form = $( this );
+               setTimeout(function() {
+                       form.find( ":ui-button" ).button( "refresh" );
+               }, 1 );
+       },
+       radioGroup = function( radio ) {
+               var name = radio.name,
+                       form = radio.form,
+                       radios = $( [] );
+               if ( name ) {
+                       name = name.replace( /'/g, "\\'" );
+                       if ( form ) {
+                               radios = $( form ).find( "[name='" + name + "'][type=radio]" );
+                       } else {
+                               radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
+                                       .filter(function() {
+                                               return !this.form;
+                                       });
+                       }
+               }
+               return radios;
+       };
+
+$.widget( "ui.button", {
+       version: "@VERSION",
+       defaultElement: "<button>",
+       options: {
+               disabled: null,
+               text: true,
+               label: null,
+               icons: {
+                       primary: null,
+                       secondary: null
+               }
+       },
+       _create: function() {
+               this.element.closest( "form" )
+                       .off( "reset" + this.eventNamespace )
+                       .on( "reset" + this.eventNamespace, formResetHandler );
+
+               if ( typeof this.options.disabled !== "boolean" ) {
+                       this.options.disabled = !!this.element.prop( "disabled" );
+               } else {
+                       this.element.prop( "disabled", this.options.disabled );
+               }
+
+               this._determineButtonType();
+               this.hasTitle = !!this.buttonElement.attr( "title" );
+
+               var that = this,
+                       options = this.options,
+                       toggleButton = this.type === "checkbox" || this.type === "radio",
+                       activeClass = !toggleButton ? "ui-state-active" : "";
+
+               if ( options.label === null ) {
+                       options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
+               }
+
+               this._hoverable( this.buttonElement );
+
+               this.buttonElement
+                       .addClass( baseClasses )
+                       .attr( "role", "button" )
+                       .on( "mouseenter" + this.eventNamespace, function() {
+                               if ( options.disabled ) {
+                                       return;
+                               }
+                               if ( this === lastActive ) {
+                                       $( this ).addClass( "ui-state-active" );
+                               }
+                       })
+                       .on( "mouseleave" + this.eventNamespace, function() {
+                               if ( options.disabled ) {
+                                       return;
+                               }
+                               $( this ).removeClass( activeClass );
+                       })
+                       .on( "click" + this.eventNamespace, function( event ) {
+                               if ( options.disabled ) {
+                                       event.preventDefault();
+                                       event.stopImmediatePropagation();
+                               }
+                       });
+
+               // Can't use _focusable() because the element that receives focus
+               // and the element that gets the ui-state-focus class are different
+               this._on({
+                       focus: function() {
+                               this.buttonElement.addClass( "ui-state-focus" );
+                       },
+                       blur: function() {
+                               this.buttonElement.removeClass( "ui-state-focus" );
+                       }
+               });
+
+               if ( toggleButton ) {
+                       this.element.on( "change" + this.eventNamespace, function() {
+                               that.refresh();
+                       });
+               }
+
+               if ( this.type === "checkbox" ) {
+                       this.buttonElement.on( "click" + this.eventNamespace, function() {
+                               if ( options.disabled ) {
+                                       return false;
+                               }
+                       });
+               } else if ( this.type === "radio" ) {
+                       this.buttonElement.on( "click" + this.eventNamespace, function() {
+                               if ( options.disabled ) {
+                                       return false;
+                               }
+                               $( this ).addClass( "ui-state-active" );
+                               that.buttonElement.attr( "aria-pressed", "true" );
+
+                               var radio = that.element[ 0 ];
+                               radioGroup( radio )
+                                       .not( radio )
+                                       .map(function() {
+                                               return $( this ).button( "widget" )[ 0 ];
+                                       })
+                                       .removeClass( "ui-state-active" )
+                                       .attr( "aria-pressed", "false" );
+                       });
+               } else {
+                       this.buttonElement
+                               .on( "mousedown" + this.eventNamespace, function() {
+                                       if ( options.disabled ) {
+                                               return false;
+                                       }
+                                       $( this ).addClass( "ui-state-active" );
+                                       lastActive = this;
+                                       that.document.one( "mouseup", function() {
+                                               lastActive = null;
+                                       });
+                               })
+                               .on( "mouseup" + this.eventNamespace, function() {
+                                       if ( options.disabled ) {
+                                               return false;
+                                       }
+                                       $( this ).removeClass( "ui-state-active" );
+                               })
+                               .on( "keydown" + this.eventNamespace, function(event) {
+                                       if ( options.disabled ) {
+                                               return false;
+                                       }
+                                       if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
+                                               $( this ).addClass( "ui-state-active" );
+                                       }
+                               })
+                               // see #8559, we bind to blur here in case the button element loses
+                               // focus between keydown and keyup, it would be left in an "active" state
+                               .on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
+                                       $( this ).removeClass( "ui-state-active" );
+                               });
+
+                       if ( this.buttonElement.is("a") ) {
+                               this.buttonElement.on( "keyup", function(event) {
+                                       if ( event.keyCode === $.ui.keyCode.SPACE ) {
+                                               // TODO pass through original event correctly (just as 2nd argument doesn't work)
+                                               $( this ).trigger( "click" );
+                                       }
+                               });
+                       }
+               }
+
+               this._setOption( "disabled", options.disabled );
+               this._resetButton();
+       },
+
+       _determineButtonType: function() {
+               var ancestor, labelSelector, checked;
+
+               if ( this.element.is("[type=checkbox]") ) {
+                       this.type = "checkbox";
+               } else if ( this.element.is("[type=radio]") ) {
+                       this.type = "radio";
+               } else if ( this.element.is("input") ) {
+                       this.type = "input";
+               } else {
+                       this.type = "button";
+               }
+
+               if ( this.type === "checkbox" || this.type === "radio" ) {
+                       // we don't search against the document in case the element
+                       // is disconnected from the DOM
+                       ancestor = this.element.parents().last();
+                       labelSelector = "label[for='" + this.element.attr("id") + "']";
+                       this.buttonElement = ancestor.find( labelSelector );
+                       if ( !this.buttonElement.length ) {
+                               ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
+                               this.buttonElement = ancestor.filter( labelSelector );
+                               if ( !this.buttonElement.length ) {
+                                       this.buttonElement = ancestor.find( labelSelector );
+                               }
+                       }
+                       this.element.addClass( "ui-helper-hidden-accessible" );
+
+                       checked = this.element.is( ":checked" );
+                       if ( checked ) {
+                               this.buttonElement.addClass( "ui-state-active" );
+                       }
+                       this.buttonElement.prop( "aria-pressed", checked );
+               } else {
+                       this.buttonElement = this.element;
+               }
+       },
+
+       widget: function() {
+               return this.buttonElement;
+       },
+
+       _destroy: function() {
+               this.element
+                       .removeClass( "ui-helper-hidden-accessible" );
+               this.buttonElement
+                       .removeClass( baseClasses + " ui-state-active " + typeClasses )
+                       .removeAttr( "role aria-pressed" )
+                       .html( this.buttonElement.find(".ui-button-text").html() );
+
+               if ( !this.hasTitle ) {
+                       this.buttonElement.removeAttr( "title" );
+               }
+       },
+
+       _setOption: function( key, value ) {
+               this._super( key, value );
+               if ( key === "disabled" ) {
+                       this.widget().toggleClass( "ui-state-disabled", !!value );
+                       this.element.prop( "disabled", !!value );
+                       if ( value ) {
+                               if ( this.type === "checkbox" || this.type === "radio" ) {
+                                       this.buttonElement.removeClass( "ui-state-focus" );
+                               } else {
+                                       this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
+                               }
+                       }
+                       return;
+               }
+               this._resetButton();
+       },
+
+       refresh: function() {
+               //See #8237 & #8828
+               var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
+
+               if ( isDisabled !== this.options.disabled ) {
+                       this._setOption( "disabled", isDisabled );
+               }
+               if ( this.type === "radio" ) {
+                       radioGroup( this.element[0] ).each(function() {
+                               if ( $( this ).is( ":checked" ) ) {
+                                       $( this ).button( "widget" )
+                                               .addClass( "ui-state-active" )
+                                               .attr( "aria-pressed", "true" );
+                               } else {
+                                       $( this ).button( "widget" )
+                                               .removeClass( "ui-state-active" )
+                                               .attr( "aria-pressed", "false" );
+                               }
+                       });
+               } else if ( this.type === "checkbox" ) {
+                       if ( this.element.is( ":checked" ) ) {
+                               this.buttonElement
+                                       .addClass( "ui-state-active" )
+                                       .attr( "aria-pressed", "true" );
+                       } else {
+                               this.buttonElement
+                                       .removeClass( "ui-state-active" )
+                                       .attr( "aria-pressed", "false" );
+                       }
+               }
+       },
+
+       _resetButton: function() {
+               if ( this.type === "input" ) {
+                       if ( this.options.label ) {
+                               this.element.val( this.options.label );
+                       }
+                       return;
+               }
+               var buttonElement = this.buttonElement.removeClass( typeClasses ),
+                       buttonText = $( "<span></span>", this.document[0] )
+                               .addClass( "ui-button-text" )
+                               .html( this.options.label )
+                               .appendTo( buttonElement.empty() )
+                               .text(),
+                       icons = this.options.icons,
+                       multipleIcons = icons.primary && icons.secondary,
+                       buttonClasses = [];
+
+               if ( icons.primary || icons.secondary ) {
+                       if ( this.options.text ) {
+                               buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
+                       }
+
+                       if ( icons.primary ) {
+                               buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
+                       }
+
+                       if ( icons.secondary ) {
+                               buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
+                       }
+
+                       if ( !this.options.text ) {
+                               buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
+
+                               if ( !this.hasTitle ) {
+                                       buttonElement.attr( "title", $.trim( buttonText ) );
+                               }
+                       }
+               } else {
+                       buttonClasses.push( "ui-button-text-only" );
+               }
+               buttonElement.addClass( buttonClasses.join( " " ) );
+       }
+});
+
+$.widget( "ui.buttonset", {
+       version: "@VERSION",
+       options: {
+               items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
+       },
+
+       _create: function() {
+               this.element.addClass( "ui-buttonset" );
+       },
+
+       _init: function() {
+               this.refresh();
+       },
+
+       _setOption: function( key, value ) {
+               if ( key === "disabled" ) {
+                       this.buttons.button( "option", key, value );
+               }
+
+               this._super( key, value );
+       },
+
+       refresh: function() {
+               var rtl = this.element.css( "direction" ) === "rtl",
+                       allButtons = this.element.find( this.options.items ),
+                       existingButtons = allButtons.filter( ":ui-button" );
+
+               // Initialize new buttons
+               allButtons.not( ":ui-button" ).button();
+
+               // Refresh existing buttons
+               existingButtons.button( "refresh" );
+
+               this.buttons = allButtons
+                       .map(function() {
+                               return $( this ).button( "widget" )[ 0 ];
+                       })
+                               .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
+                               .filter( ":first" )
+                                       .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
+                               .end()
+                               .filter( ":last" )
+                                       .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
+                               .end()
+                       .end();
+       },
+
+       _destroy: function() {
+               this.element.removeClass( "ui-buttonset" );
+               this.buttons
+                       .map(function() {
+                               return $( this ).button( "widget" )[ 0 ];
+                       })
+                               .removeClass( "ui-corner-left ui-corner-right" )
+                       .end()
+                       .button( "destroy" );
+       }
+});
+
+return $.ui.button;
+
+}));