Edit File by line
/home/zeestwma/richards.../wp-inclu.../js/jquery/ui
File: button.js
/*!
[0] Fix | Delete
* jQuery UI Button 1.13.3
[1] Fix | Delete
* https://jqueryui.com
[2] Fix | Delete
*
[3] Fix | Delete
* Copyright OpenJS Foundation and other contributors
[4] Fix | Delete
* Released under the MIT license.
[5] Fix | Delete
* https://jquery.org/license
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
//>>label: Button
[9] Fix | Delete
//>>group: Widgets
[10] Fix | Delete
//>>description: Enhances a form with themeable buttons.
[11] Fix | Delete
//>>docs: https://api.jqueryui.com/button/
[12] Fix | Delete
//>>demos: https://jqueryui.com/button/
[13] Fix | Delete
//>>css.structure: ../../themes/base/core.css
[14] Fix | Delete
//>>css.structure: ../../themes/base/button.css
[15] Fix | Delete
//>>css.theme: ../../themes/base/theme.css
[16] Fix | Delete
[17] Fix | Delete
( function( factory ) {
[18] Fix | Delete
"use strict";
[19] Fix | Delete
[20] Fix | Delete
if ( typeof define === "function" && define.amd ) {
[21] Fix | Delete
[22] Fix | Delete
// AMD. Register as an anonymous module.
[23] Fix | Delete
define( [
[24] Fix | Delete
"jquery",
[25] Fix | Delete
[26] Fix | Delete
// These are only for backcompat
[27] Fix | Delete
// TODO: Remove after 1.12
[28] Fix | Delete
"./controlgroup",
[29] Fix | Delete
"./checkboxradio",
[30] Fix | Delete
[31] Fix | Delete
"../keycode",
[32] Fix | Delete
"../widget"
[33] Fix | Delete
], factory );
[34] Fix | Delete
} else {
[35] Fix | Delete
[36] Fix | Delete
// Browser globals
[37] Fix | Delete
factory( jQuery );
[38] Fix | Delete
}
[39] Fix | Delete
} )( function( $ ) {
[40] Fix | Delete
"use strict";
[41] Fix | Delete
[42] Fix | Delete
$.widget( "ui.button", {
[43] Fix | Delete
version: "1.13.3",
[44] Fix | Delete
defaultElement: "<button>",
[45] Fix | Delete
options: {
[46] Fix | Delete
classes: {
[47] Fix | Delete
"ui-button": "ui-corner-all"
[48] Fix | Delete
},
[49] Fix | Delete
disabled: null,
[50] Fix | Delete
icon: null,
[51] Fix | Delete
iconPosition: "beginning",
[52] Fix | Delete
label: null,
[53] Fix | Delete
showLabel: true
[54] Fix | Delete
},
[55] Fix | Delete
[56] Fix | Delete
_getCreateOptions: function() {
[57] Fix | Delete
var disabled,
[58] Fix | Delete
[59] Fix | Delete
// This is to support cases like in jQuery Mobile where the base widget does have
[60] Fix | Delete
// an implementation of _getCreateOptions
[61] Fix | Delete
options = this._super() || {};
[62] Fix | Delete
[63] Fix | Delete
this.isInput = this.element.is( "input" );
[64] Fix | Delete
[65] Fix | Delete
disabled = this.element[ 0 ].disabled;
[66] Fix | Delete
if ( disabled != null ) {
[67] Fix | Delete
options.disabled = disabled;
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
this.originalLabel = this.isInput ? this.element.val() : this.element.html();
[71] Fix | Delete
if ( this.originalLabel ) {
[72] Fix | Delete
options.label = this.originalLabel;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
return options;
[76] Fix | Delete
},
[77] Fix | Delete
[78] Fix | Delete
_create: function() {
[79] Fix | Delete
if ( !this.option.showLabel & !this.options.icon ) {
[80] Fix | Delete
this.options.showLabel = true;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
// We have to check the option again here even though we did in _getCreateOptions,
[84] Fix | Delete
// because null may have been passed on init which would override what was set in
[85] Fix | Delete
// _getCreateOptions
[86] Fix | Delete
if ( this.options.disabled == null ) {
[87] Fix | Delete
this.options.disabled = this.element[ 0 ].disabled || false;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
this.hasTitle = !!this.element.attr( "title" );
[91] Fix | Delete
[92] Fix | Delete
// Check to see if the label needs to be set or if its already correct
[93] Fix | Delete
if ( this.options.label && this.options.label !== this.originalLabel ) {
[94] Fix | Delete
if ( this.isInput ) {
[95] Fix | Delete
this.element.val( this.options.label );
[96] Fix | Delete
} else {
[97] Fix | Delete
this.element.html( this.options.label );
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
this._addClass( "ui-button", "ui-widget" );
[101] Fix | Delete
this._setOption( "disabled", this.options.disabled );
[102] Fix | Delete
this._enhance();
[103] Fix | Delete
[104] Fix | Delete
if ( this.element.is( "a" ) ) {
[105] Fix | Delete
this._on( {
[106] Fix | Delete
"keyup": function( event ) {
[107] Fix | Delete
if ( event.keyCode === $.ui.keyCode.SPACE ) {
[108] Fix | Delete
event.preventDefault();
[109] Fix | Delete
[110] Fix | Delete
// Support: PhantomJS <= 1.9, IE 8 Only
[111] Fix | Delete
// If a native click is available use it so we actually cause navigation
[112] Fix | Delete
// otherwise just trigger a click event
[113] Fix | Delete
if ( this.element[ 0 ].click ) {
[114] Fix | Delete
this.element[ 0 ].click();
[115] Fix | Delete
} else {
[116] Fix | Delete
this.element.trigger( "click" );
[117] Fix | Delete
}
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
} );
[121] Fix | Delete
}
[122] Fix | Delete
},
[123] Fix | Delete
[124] Fix | Delete
_enhance: function() {
[125] Fix | Delete
if ( !this.element.is( "button" ) ) {
[126] Fix | Delete
this.element.attr( "role", "button" );
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
if ( this.options.icon ) {
[130] Fix | Delete
this._updateIcon( "icon", this.options.icon );
[131] Fix | Delete
this._updateTooltip();
[132] Fix | Delete
}
[133] Fix | Delete
},
[134] Fix | Delete
[135] Fix | Delete
_updateTooltip: function() {
[136] Fix | Delete
this.title = this.element.attr( "title" );
[137] Fix | Delete
[138] Fix | Delete
if ( !this.options.showLabel && !this.title ) {
[139] Fix | Delete
this.element.attr( "title", this.options.label );
[140] Fix | Delete
}
[141] Fix | Delete
},
[142] Fix | Delete
[143] Fix | Delete
_updateIcon: function( option, value ) {
[144] Fix | Delete
var icon = option !== "iconPosition",
[145] Fix | Delete
position = icon ? this.options.iconPosition : value,
[146] Fix | Delete
displayBlock = position === "top" || position === "bottom";
[147] Fix | Delete
[148] Fix | Delete
// Create icon
[149] Fix | Delete
if ( !this.icon ) {
[150] Fix | Delete
this.icon = $( "<span>" );
[151] Fix | Delete
[152] Fix | Delete
this._addClass( this.icon, "ui-button-icon", "ui-icon" );
[153] Fix | Delete
[154] Fix | Delete
if ( !this.options.showLabel ) {
[155] Fix | Delete
this._addClass( "ui-button-icon-only" );
[156] Fix | Delete
}
[157] Fix | Delete
} else if ( icon ) {
[158] Fix | Delete
[159] Fix | Delete
// If we are updating the icon remove the old icon class
[160] Fix | Delete
this._removeClass( this.icon, null, this.options.icon );
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
// If we are updating the icon add the new icon class
[164] Fix | Delete
if ( icon ) {
[165] Fix | Delete
this._addClass( this.icon, null, value );
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
this._attachIcon( position );
[169] Fix | Delete
[170] Fix | Delete
// If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
[171] Fix | Delete
// the iconSpace if there is one.
[172] Fix | Delete
if ( displayBlock ) {
[173] Fix | Delete
this._addClass( this.icon, null, "ui-widget-icon-block" );
[174] Fix | Delete
if ( this.iconSpace ) {
[175] Fix | Delete
this.iconSpace.remove();
[176] Fix | Delete
}
[177] Fix | Delete
} else {
[178] Fix | Delete
[179] Fix | Delete
// Position is beginning or end so remove the ui-widget-icon-block class and add the
[180] Fix | Delete
// space if it does not exist
[181] Fix | Delete
if ( !this.iconSpace ) {
[182] Fix | Delete
this.iconSpace = $( "<span> </span>" );
[183] Fix | Delete
this._addClass( this.iconSpace, "ui-button-icon-space" );
[184] Fix | Delete
}
[185] Fix | Delete
this._removeClass( this.icon, null, "ui-wiget-icon-block" );
[186] Fix | Delete
this._attachIconSpace( position );
[187] Fix | Delete
}
[188] Fix | Delete
},
[189] Fix | Delete
[190] Fix | Delete
_destroy: function() {
[191] Fix | Delete
this.element.removeAttr( "role" );
[192] Fix | Delete
[193] Fix | Delete
if ( this.icon ) {
[194] Fix | Delete
this.icon.remove();
[195] Fix | Delete
}
[196] Fix | Delete
if ( this.iconSpace ) {
[197] Fix | Delete
this.iconSpace.remove();
[198] Fix | Delete
}
[199] Fix | Delete
if ( !this.hasTitle ) {
[200] Fix | Delete
this.element.removeAttr( "title" );
[201] Fix | Delete
}
[202] Fix | Delete
},
[203] Fix | Delete
[204] Fix | Delete
_attachIconSpace: function( iconPosition ) {
[205] Fix | Delete
this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
[206] Fix | Delete
},
[207] Fix | Delete
[208] Fix | Delete
_attachIcon: function( iconPosition ) {
[209] Fix | Delete
this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
[210] Fix | Delete
},
[211] Fix | Delete
[212] Fix | Delete
_setOptions: function( options ) {
[213] Fix | Delete
var newShowLabel = options.showLabel === undefined ?
[214] Fix | Delete
this.options.showLabel :
[215] Fix | Delete
options.showLabel,
[216] Fix | Delete
newIcon = options.icon === undefined ? this.options.icon : options.icon;
[217] Fix | Delete
[218] Fix | Delete
if ( !newShowLabel && !newIcon ) {
[219] Fix | Delete
options.showLabel = true;
[220] Fix | Delete
}
[221] Fix | Delete
this._super( options );
[222] Fix | Delete
},
[223] Fix | Delete
[224] Fix | Delete
_setOption: function( key, value ) {
[225] Fix | Delete
if ( key === "icon" ) {
[226] Fix | Delete
if ( value ) {
[227] Fix | Delete
this._updateIcon( key, value );
[228] Fix | Delete
} else if ( this.icon ) {
[229] Fix | Delete
this.icon.remove();
[230] Fix | Delete
if ( this.iconSpace ) {
[231] Fix | Delete
this.iconSpace.remove();
[232] Fix | Delete
}
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
if ( key === "iconPosition" ) {
[237] Fix | Delete
this._updateIcon( key, value );
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
// Make sure we can't end up with a button that has neither text nor icon
[241] Fix | Delete
if ( key === "showLabel" ) {
[242] Fix | Delete
this._toggleClass( "ui-button-icon-only", null, !value );
[243] Fix | Delete
this._updateTooltip();
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
if ( key === "label" ) {
[247] Fix | Delete
if ( this.isInput ) {
[248] Fix | Delete
this.element.val( value );
[249] Fix | Delete
} else {
[250] Fix | Delete
[251] Fix | Delete
// If there is an icon, append it, else nothing then append the value
[252] Fix | Delete
// this avoids removal of the icon when setting label text
[253] Fix | Delete
this.element.html( value );
[254] Fix | Delete
if ( this.icon ) {
[255] Fix | Delete
this._attachIcon( this.options.iconPosition );
[256] Fix | Delete
this._attachIconSpace( this.options.iconPosition );
[257] Fix | Delete
}
[258] Fix | Delete
}
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
this._super( key, value );
[262] Fix | Delete
[263] Fix | Delete
if ( key === "disabled" ) {
[264] Fix | Delete
this._toggleClass( null, "ui-state-disabled", value );
[265] Fix | Delete
this.element[ 0 ].disabled = value;
[266] Fix | Delete
if ( value ) {
[267] Fix | Delete
this.element.trigger( "blur" );
[268] Fix | Delete
}
[269] Fix | Delete
}
[270] Fix | Delete
},
[271] Fix | Delete
[272] Fix | Delete
refresh: function() {
[273] Fix | Delete
[274] Fix | Delete
// Make sure to only check disabled if its an element that supports this otherwise
[275] Fix | Delete
// check for the disabled class to determine state
[276] Fix | Delete
var isDisabled = this.element.is( "input, button" ) ?
[277] Fix | Delete
this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
[278] Fix | Delete
[279] Fix | Delete
if ( isDisabled !== this.options.disabled ) {
[280] Fix | Delete
this._setOptions( { disabled: isDisabled } );
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
this._updateTooltip();
[284] Fix | Delete
}
[285] Fix | Delete
} );
[286] Fix | Delete
[287] Fix | Delete
// DEPRECATED
[288] Fix | Delete
if ( $.uiBackCompat !== false ) {
[289] Fix | Delete
[290] Fix | Delete
// Text and Icons options
[291] Fix | Delete
$.widget( "ui.button", $.ui.button, {
[292] Fix | Delete
options: {
[293] Fix | Delete
text: true,
[294] Fix | Delete
icons: {
[295] Fix | Delete
primary: null,
[296] Fix | Delete
secondary: null
[297] Fix | Delete
}
[298] Fix | Delete
},
[299] Fix | Delete
[300] Fix | Delete
_create: function() {
[301] Fix | Delete
if ( this.options.showLabel && !this.options.text ) {
[302] Fix | Delete
this.options.showLabel = this.options.text;
[303] Fix | Delete
}
[304] Fix | Delete
if ( !this.options.showLabel && this.options.text ) {
[305] Fix | Delete
this.options.text = this.options.showLabel;
[306] Fix | Delete
}
[307] Fix | Delete
if ( !this.options.icon && ( this.options.icons.primary ||
[308] Fix | Delete
this.options.icons.secondary ) ) {
[309] Fix | Delete
if ( this.options.icons.primary ) {
[310] Fix | Delete
this.options.icon = this.options.icons.primary;
[311] Fix | Delete
} else {
[312] Fix | Delete
this.options.icon = this.options.icons.secondary;
[313] Fix | Delete
this.options.iconPosition = "end";
[314] Fix | Delete
}
[315] Fix | Delete
} else if ( this.options.icon ) {
[316] Fix | Delete
this.options.icons.primary = this.options.icon;
[317] Fix | Delete
}
[318] Fix | Delete
this._super();
[319] Fix | Delete
},
[320] Fix | Delete
[321] Fix | Delete
_setOption: function( key, value ) {
[322] Fix | Delete
if ( key === "text" ) {
[323] Fix | Delete
this._super( "showLabel", value );
[324] Fix | Delete
return;
[325] Fix | Delete
}
[326] Fix | Delete
if ( key === "showLabel" ) {
[327] Fix | Delete
this.options.text = value;
[328] Fix | Delete
}
[329] Fix | Delete
if ( key === "icon" ) {
[330] Fix | Delete
this.options.icons.primary = value;
[331] Fix | Delete
}
[332] Fix | Delete
if ( key === "icons" ) {
[333] Fix | Delete
if ( value.primary ) {
[334] Fix | Delete
this._super( "icon", value.primary );
[335] Fix | Delete
this._super( "iconPosition", "beginning" );
[336] Fix | Delete
} else if ( value.secondary ) {
[337] Fix | Delete
this._super( "icon", value.secondary );
[338] Fix | Delete
this._super( "iconPosition", "end" );
[339] Fix | Delete
}
[340] Fix | Delete
}
[341] Fix | Delete
this._superApply( arguments );
[342] Fix | Delete
}
[343] Fix | Delete
} );
[344] Fix | Delete
[345] Fix | Delete
$.fn.button = ( function( orig ) {
[346] Fix | Delete
return function( options ) {
[347] Fix | Delete
var isMethodCall = typeof options === "string";
[348] Fix | Delete
var args = Array.prototype.slice.call( arguments, 1 );
[349] Fix | Delete
var returnValue = this;
[350] Fix | Delete
[351] Fix | Delete
if ( isMethodCall ) {
[352] Fix | Delete
[353] Fix | Delete
// If this is an empty collection, we need to have the instance method
[354] Fix | Delete
// return undefined instead of the jQuery instance
[355] Fix | Delete
if ( !this.length && options === "instance" ) {
[356] Fix | Delete
returnValue = undefined;
[357] Fix | Delete
} else {
[358] Fix | Delete
this.each( function() {
[359] Fix | Delete
var methodValue;
[360] Fix | Delete
var type = $( this ).attr( "type" );
[361] Fix | Delete
var name = type !== "checkbox" && type !== "radio" ?
[362] Fix | Delete
"button" :
[363] Fix | Delete
"checkboxradio";
[364] Fix | Delete
var instance = $.data( this, "ui-" + name );
[365] Fix | Delete
[366] Fix | Delete
if ( options === "instance" ) {
[367] Fix | Delete
returnValue = instance;
[368] Fix | Delete
return false;
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
if ( !instance ) {
[372] Fix | Delete
return $.error( "cannot call methods on button" +
[373] Fix | Delete
" prior to initialization; " +
[374] Fix | Delete
"attempted to call method '" + options + "'" );
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
if ( typeof instance[ options ] !== "function" ||
[378] Fix | Delete
options.charAt( 0 ) === "_" ) {
[379] Fix | Delete
return $.error( "no such method '" + options + "' for button" +
[380] Fix | Delete
" widget instance" );
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
methodValue = instance[ options ].apply( instance, args );
[384] Fix | Delete
[385] Fix | Delete
if ( methodValue !== instance && methodValue !== undefined ) {
[386] Fix | Delete
returnValue = methodValue && methodValue.jquery ?
[387] Fix | Delete
returnValue.pushStack( methodValue.get() ) :
[388] Fix | Delete
methodValue;
[389] Fix | Delete
return false;
[390] Fix | Delete
}
[391] Fix | Delete
} );
[392] Fix | Delete
}
[393] Fix | Delete
} else {
[394] Fix | Delete
[395] Fix | Delete
// Allow multiple hashes to be passed on init
[396] Fix | Delete
if ( args.length ) {
[397] Fix | Delete
options = $.widget.extend.apply( null, [ options ].concat( args ) );
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
this.each( function() {
[401] Fix | Delete
var type = $( this ).attr( "type" );
[402] Fix | Delete
var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
[403] Fix | Delete
var instance = $.data( this, "ui-" + name );
[404] Fix | Delete
[405] Fix | Delete
if ( instance ) {
[406] Fix | Delete
instance.option( options || {} );
[407] Fix | Delete
if ( instance._init ) {
[408] Fix | Delete
instance._init();
[409] Fix | Delete
}
[410] Fix | Delete
} else {
[411] Fix | Delete
if ( name === "button" ) {
[412] Fix | Delete
orig.call( $( this ), options );
[413] Fix | Delete
return;
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
$( this ).checkboxradio( $.extend( { icon: false }, options ) );
[417] Fix | Delete
}
[418] Fix | Delete
} );
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
return returnValue;
[422] Fix | Delete
};
[423] Fix | Delete
} )( $.fn.button );
[424] Fix | Delete
[425] Fix | Delete
$.fn.buttonset = function() {
[426] Fix | Delete
if ( !$.ui.controlgroup ) {
[427] Fix | Delete
$.error( "Controlgroup widget missing" );
[428] Fix | Delete
}
[429] Fix | Delete
if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
[430] Fix | Delete
return this.controlgroup.apply( this,
[431] Fix | Delete
[ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
[432] Fix | Delete
}
[433] Fix | Delete
if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
[434] Fix | Delete
return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
[435] Fix | Delete
}
[436] Fix | Delete
if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
[437] Fix | Delete
arguments[ 0 ].items = {
[438] Fix | Delete
button: arguments[ 0 ].items
[439] Fix | Delete
};
[440] Fix | Delete
}
[441] Fix | Delete
return this.controlgroup.apply( this, arguments );
[442] Fix | Delete
};
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
return $.ui.button;
[446] Fix | Delete
[447] Fix | Delete
} );
[448] Fix | Delete
[449] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function