vendor/assets/javascripts/jquery-ui/widgets/button.js in activeadmin-3.2.1 vs vendor/assets/javascripts/jquery-ui/widgets/button.js in activeadmin-3.2.2

- old
+ new

@@ -2,28 +2,30 @@ //= require jquery-ui/widgets/checkboxradio //= require jquery-ui/keycode //= require jquery-ui/widget /*! - * jQuery UI Button 1.12.1 - * http://jqueryui.com + * jQuery UI Button 1.13.3 + * https://jqueryui.com * - * Copyright jQuery Foundation and other contributors + * Copyright OpenJS Foundation and other contributors * Released under the MIT license. - * http://jquery.org/license + * https://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/ +//>>docs: https://api.jqueryui.com/button/ +//>>demos: https://jqueryui.com/button/ //>>css.structure: ../../themes/base/core.css //>>css.structure: ../../themes/base/button.css //>>css.theme: ../../themes/base/theme.css ( function( factory ) { + "use strict"; + if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. define( [ "jquery", @@ -39,14 +41,15 @@ } else { // Browser globals factory( jQuery ); } -}( function( $ ) { +} )( function( $ ) { +"use strict"; $.widget( "ui.button", { - version: "1.12.1", + version: "1.13.3", defaultElement: "<button>", options: { classes: { "ui-button": "ui-corner-all" }, @@ -266,11 +269,11 @@ if ( key === "disabled" ) { this._toggleClass( null, "ui-state-disabled", value ); this.element[ 0 ].disabled = value; if ( value ) { - this.element.blur(); + this.element.trigger( "blur" ); } } }, refresh: function() { @@ -345,26 +348,86 @@ this._superApply( arguments ); } } ); $.fn.button = ( function( orig ) { - return function() { - if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) || - ( this.length && this[ 0 ].tagName === "INPUT" && ( - this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio" - ) ) ) { - return orig.apply( this, arguments ); - } - if ( !$.ui.checkboxradio ) { - $.error( "Checkboxradio widget missing" ); - } - if ( arguments.length === 0 ) { - return this.checkboxradio( { - "icon": false + return function( options ) { + var isMethodCall = typeof options === "string"; + var args = Array.prototype.slice.call( arguments, 1 ); + var returnValue = this; + + if ( isMethodCall ) { + + // If this is an empty collection, we need to have the instance method + // return undefined instead of the jQuery instance + if ( !this.length && options === "instance" ) { + returnValue = undefined; + } else { + this.each( function() { + var methodValue; + var type = $( this ).attr( "type" ); + var name = type !== "checkbox" && type !== "radio" ? + "button" : + "checkboxradio"; + var instance = $.data( this, "ui-" + name ); + + if ( options === "instance" ) { + returnValue = instance; + return false; + } + + if ( !instance ) { + return $.error( "cannot call methods on button" + + " prior to initialization; " + + "attempted to call method '" + options + "'" ); + } + + if ( typeof instance[ options ] !== "function" || + options.charAt( 0 ) === "_" ) { + return $.error( "no such method '" + options + "' for button" + + " widget instance" ); + } + + methodValue = instance[ options ].apply( instance, args ); + + if ( methodValue !== instance && methodValue !== undefined ) { + returnValue = methodValue && methodValue.jquery ? + returnValue.pushStack( methodValue.get() ) : + methodValue; + return false; + } + } ); + } + } else { + + // Allow multiple hashes to be passed on init + if ( args.length ) { + options = $.widget.extend.apply( null, [ options ].concat( args ) ); + } + + this.each( function() { + var type = $( this ).attr( "type" ); + var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio"; + var instance = $.data( this, "ui-" + name ); + + if ( instance ) { + instance.option( options || {} ); + if ( instance._init ) { + instance._init(); + } + } else { + if ( name === "button" ) { + orig.call( $( this ), options ); + return; + } + + $( this ).checkboxradio( $.extend( { icon: false }, options ) ); + } } ); } - return this.checkboxradio.apply( this, arguments ); + + return returnValue; }; } )( $.fn.button ); $.fn.buttonset = function() { if ( !$.ui.controlgroup ) { @@ -386,6 +449,6 @@ }; } return $.ui.button; -} ) ); +} );