wp/wp-includes/js/jquery/ui/button.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 /*!
     1 /*!
     2  * jQuery UI Button 1.12.1
     2  * jQuery UI Button 1.13.1
     3  * http://jqueryui.com
     3  * http://jqueryui.com
     4  *
     4  *
     5  * Copyright jQuery Foundation and other contributors
     5  * Copyright jQuery Foundation and other contributors
     6  * Released under the MIT license.
     6  * Released under the MIT license.
     7  * http://jquery.org/license
     7  * http://jquery.org/license
    15 //>>css.structure: ../../themes/base/core.css
    15 //>>css.structure: ../../themes/base/core.css
    16 //>>css.structure: ../../themes/base/button.css
    16 //>>css.structure: ../../themes/base/button.css
    17 //>>css.theme: ../../themes/base/theme.css
    17 //>>css.theme: ../../themes/base/theme.css
    18 
    18 
    19 ( function( factory ) {
    19 ( function( factory ) {
       
    20 	"use strict";
       
    21 
    20 	if ( typeof define === "function" && define.amd ) {
    22 	if ( typeof define === "function" && define.amd ) {
    21 
    23 
    22 		// AMD. Register as an anonymous module.
    24 		// AMD. Register as an anonymous module.
    23 		define( [
    25 		define( [
    24 			"jquery",
    26 			"jquery",
    33 	} else {
    35 	} else {
    34 
    36 
    35 		// Browser globals
    37 		// Browser globals
    36 		factory( jQuery );
    38 		factory( jQuery );
    37 	}
    39 	}
    38 }( function( $ ) {
    40 } )( function( $ ) {
       
    41 "use strict";
    39 
    42 
    40 $.widget( "ui.button", {
    43 $.widget( "ui.button", {
    41 	version: "1.12.1",
    44 	version: "1.13.1",
    42 	defaultElement: "<button>",
    45 	defaultElement: "<button>",
    43 	options: {
    46 	options: {
    44 		classes: {
    47 		classes: {
    45 			"ui-button": "ui-corner-all"
    48 			"ui-button": "ui-corner-all"
    46 		},
    49 		},
   235 			this._updateIcon( key, value );
   238 			this._updateIcon( key, value );
   236 		}
   239 		}
   237 
   240 
   238 		// Make sure we can't end up with a button that has neither text nor icon
   241 		// Make sure we can't end up with a button that has neither text nor icon
   239 		if ( key === "showLabel" ) {
   242 		if ( key === "showLabel" ) {
   240 				this._toggleClass( "ui-button-icon-only", null, !value );
   243 			this._toggleClass( "ui-button-icon-only", null, !value );
   241 				this._updateTooltip();
   244 			this._updateTooltip();
   242 		}
   245 		}
   243 
   246 
   244 		if ( key === "label" ) {
   247 		if ( key === "label" ) {
   245 			if ( this.isInput ) {
   248 			if ( this.isInput ) {
   246 				this.element.val( value );
   249 				this.element.val( value );
   260 
   263 
   261 		if ( key === "disabled" ) {
   264 		if ( key === "disabled" ) {
   262 			this._toggleClass( null, "ui-state-disabled", value );
   265 			this._toggleClass( null, "ui-state-disabled", value );
   263 			this.element[ 0 ].disabled = value;
   266 			this.element[ 0 ].disabled = value;
   264 			if ( value ) {
   267 			if ( value ) {
   265 				this.element.blur();
   268 				this.element.trigger( "blur" );
   266 			}
   269 			}
   267 		}
   270 		}
   268 	},
   271 	},
   269 
   272 
   270 	refresh: function() {
   273 	refresh: function() {
   301 			}
   304 			}
   302 			if ( !this.options.showLabel && this.options.text ) {
   305 			if ( !this.options.showLabel && this.options.text ) {
   303 				this.options.text = this.options.showLabel;
   306 				this.options.text = this.options.showLabel;
   304 			}
   307 			}
   305 			if ( !this.options.icon && ( this.options.icons.primary ||
   308 			if ( !this.options.icon && ( this.options.icons.primary ||
   306 					this.options.icons.secondary ) ) {
   309 				this.options.icons.secondary ) ) {
   307 				if ( this.options.icons.primary ) {
   310 				if ( this.options.icons.primary ) {
   308 					this.options.icon = this.options.icons.primary;
   311 					this.options.icon = this.options.icons.primary;
   309 				} else {
   312 				} else {
   310 					this.options.icon = this.options.icons.secondary;
   313 					this.options.icon = this.options.icons.secondary;
   311 					this.options.iconPosition = "end";
   314 					this.options.iconPosition = "end";
   339 			this._superApply( arguments );
   342 			this._superApply( arguments );
   340 		}
   343 		}
   341 	} );
   344 	} );
   342 
   345 
   343 	$.fn.button = ( function( orig ) {
   346 	$.fn.button = ( function( orig ) {
   344 		return function() {
   347 		return function( options ) {
   345 			if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
   348 			var isMethodCall = typeof options === "string";
   346 					( this.length && this[ 0 ].tagName === "INPUT" && (
   349 			var args = Array.prototype.slice.call( arguments, 1 );
   347 						this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
   350 			var returnValue = this;
   348 					) ) ) {
   351 
   349 				return orig.apply( this, arguments );
   352 			if ( isMethodCall ) {
   350 			}
   353 
   351 			if ( !$.ui.checkboxradio ) {
   354 				// If this is an empty collection, we need to have the instance method
   352 				$.error( "Checkboxradio widget missing" );
   355 				// return undefined instead of the jQuery instance
   353 			}
   356 				if ( !this.length && options === "instance" ) {
   354 			if ( arguments.length === 0 ) {
   357 					returnValue = undefined;
   355 				return this.checkboxradio( {
   358 				} else {
   356 					"icon": false
   359 					this.each( function() {
       
   360 						var methodValue;
       
   361 						var type = $( this ).attr( "type" );
       
   362 						var name = type !== "checkbox" && type !== "radio" ?
       
   363 							"button" :
       
   364 							"checkboxradio";
       
   365 						var instance = $.data( this, "ui-" + name );
       
   366 
       
   367 						if ( options === "instance" ) {
       
   368 							returnValue = instance;
       
   369 							return false;
       
   370 						}
       
   371 
       
   372 						if ( !instance ) {
       
   373 							return $.error( "cannot call methods on button" +
       
   374 								" prior to initialization; " +
       
   375 								"attempted to call method '" + options + "'" );
       
   376 						}
       
   377 
       
   378 						if ( typeof instance[ options ] !== "function" ||
       
   379 							options.charAt( 0 ) === "_" ) {
       
   380 							return $.error( "no such method '" + options + "' for button" +
       
   381 								" widget instance" );
       
   382 						}
       
   383 
       
   384 						methodValue = instance[ options ].apply( instance, args );
       
   385 
       
   386 						if ( methodValue !== instance && methodValue !== undefined ) {
       
   387 							returnValue = methodValue && methodValue.jquery ?
       
   388 								returnValue.pushStack( methodValue.get() ) :
       
   389 								methodValue;
       
   390 							return false;
       
   391 						}
       
   392 					} );
       
   393 				}
       
   394 			} else {
       
   395 
       
   396 				// Allow multiple hashes to be passed on init
       
   397 				if ( args.length ) {
       
   398 					options = $.widget.extend.apply( null, [ options ].concat( args ) );
       
   399 				}
       
   400 
       
   401 				this.each( function() {
       
   402 					var type = $( this ).attr( "type" );
       
   403 					var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
       
   404 					var instance = $.data( this, "ui-" + name );
       
   405 
       
   406 					if ( instance ) {
       
   407 						instance.option( options || {} );
       
   408 						if ( instance._init ) {
       
   409 							instance._init();
       
   410 						}
       
   411 					} else {
       
   412 						if ( name === "button" ) {
       
   413 							orig.call( $( this ), options );
       
   414 							return;
       
   415 						}
       
   416 
       
   417 						$( this ).checkboxradio( $.extend( { icon: false }, options ) );
       
   418 					}
   357 				} );
   419 				} );
   358 			}
   420 			}
   359 			return this.checkboxradio.apply( this, arguments );
   421 
       
   422 			return returnValue;
   360 		};
   423 		};
   361 	} )( $.fn.button );
   424 	} )( $.fn.button );
   362 
   425 
   363 	$.fn.buttonset = function() {
   426 	$.fn.buttonset = function() {
   364 		if ( !$.ui.controlgroup ) {
   427 		if ( !$.ui.controlgroup ) {
   380 	};
   443 	};
   381 }
   444 }
   382 
   445 
   383 return $.ui.button;
   446 return $.ui.button;
   384 
   447 
   385 } ) );
   448 } );