Edit File by line
/home/barbar84/public_h.../wp-inclu.../js/jquery/ui
File: checkboxradio.js
/*!
[0] Fix | Delete
* jQuery UI Checkboxradio 1.12.1
[1] Fix | Delete
* http://jqueryui.com
[2] Fix | Delete
*
[3] Fix | Delete
* Copyright jQuery Foundation and other contributors
[4] Fix | Delete
* Released under the MIT license.
[5] Fix | Delete
* http://jquery.org/license
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
//>>label: Checkboxradio
[9] Fix | Delete
//>>group: Widgets
[10] Fix | Delete
//>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
[11] Fix | Delete
//>>docs: http://api.jqueryui.com/checkboxradio/
[12] Fix | Delete
//>>demos: http://jqueryui.com/checkboxradio/
[13] Fix | Delete
//>>css.structure: ../../themes/base/core.css
[14] Fix | Delete
//>>css.structure: ../../themes/base/button.css
[15] Fix | Delete
//>>css.structure: ../../themes/base/checkboxradio.css
[16] Fix | Delete
//>>css.theme: ../../themes/base/theme.css
[17] Fix | Delete
[18] Fix | Delete
( function( factory ) {
[19] Fix | Delete
if ( typeof define === "function" && define.amd ) {
[20] Fix | Delete
[21] Fix | Delete
// AMD. Register as an anonymous module.
[22] Fix | Delete
define( [
[23] Fix | Delete
"jquery",
[24] Fix | Delete
"./core"
[25] Fix | Delete
], factory );
[26] Fix | Delete
} else {
[27] Fix | Delete
[28] Fix | Delete
// Browser globals
[29] Fix | Delete
factory( jQuery );
[30] Fix | Delete
}
[31] Fix | Delete
}( function( $ ) {
[32] Fix | Delete
[33] Fix | Delete
$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
[34] Fix | Delete
version: "1.12.1",
[35] Fix | Delete
options: {
[36] Fix | Delete
disabled: null,
[37] Fix | Delete
label: null,
[38] Fix | Delete
icon: true,
[39] Fix | Delete
classes: {
[40] Fix | Delete
"ui-checkboxradio-label": "ui-corner-all",
[41] Fix | Delete
"ui-checkboxradio-icon": "ui-corner-all"
[42] Fix | Delete
}
[43] Fix | Delete
},
[44] Fix | Delete
[45] Fix | Delete
_getCreateOptions: function() {
[46] Fix | Delete
var disabled, labels;
[47] Fix | Delete
var that = this;
[48] Fix | Delete
var options = this._super() || {};
[49] Fix | Delete
[50] Fix | Delete
// We read the type here, because it makes more sense to throw a element type error first,
[51] Fix | Delete
// rather then the error for lack of a label. Often if its the wrong type, it
[52] Fix | Delete
// won't have a label (e.g. calling on a div, btn, etc)
[53] Fix | Delete
this._readType();
[54] Fix | Delete
[55] Fix | Delete
labels = this.element.labels();
[56] Fix | Delete
[57] Fix | Delete
// If there are multiple labels, use the last one
[58] Fix | Delete
this.label = $( labels[ labels.length - 1 ] );
[59] Fix | Delete
if ( !this.label.length ) {
[60] Fix | Delete
$.error( "No label found for checkboxradio widget" );
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
this.originalLabel = "";
[64] Fix | Delete
[65] Fix | Delete
// We need to get the label text but this may also need to make sure it does not contain the
[66] Fix | Delete
// input itself.
[67] Fix | Delete
this.label.contents().not( this.element[ 0 ] ).each( function() {
[68] Fix | Delete
[69] Fix | Delete
// The label contents could be text, html, or a mix. We concat each element to get a
[70] Fix | Delete
// string representation of the label, without the input as part of it.
[71] Fix | Delete
that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
[72] Fix | Delete
} );
[73] Fix | Delete
[74] Fix | Delete
// Set the label option if we found label text
[75] Fix | Delete
if ( this.originalLabel ) {
[76] Fix | Delete
options.label = this.originalLabel;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
disabled = this.element[ 0 ].disabled;
[80] Fix | Delete
if ( disabled != null ) {
[81] Fix | Delete
options.disabled = disabled;
[82] Fix | Delete
}
[83] Fix | Delete
return options;
[84] Fix | Delete
},
[85] Fix | Delete
[86] Fix | Delete
_create: function() {
[87] Fix | Delete
var checked = this.element[ 0 ].checked;
[88] Fix | Delete
[89] Fix | Delete
this._bindFormResetHandler();
[90] Fix | Delete
[91] Fix | Delete
if ( this.options.disabled == null ) {
[92] Fix | Delete
this.options.disabled = this.element[ 0 ].disabled;
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
this._setOption( "disabled", this.options.disabled );
[96] Fix | Delete
this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
[97] Fix | Delete
this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
[98] Fix | Delete
[99] Fix | Delete
if ( this.type === "radio" ) {
[100] Fix | Delete
this._addClass( this.label, "ui-checkboxradio-radio-label" );
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
if ( this.options.label && this.options.label !== this.originalLabel ) {
[104] Fix | Delete
this._updateLabel();
[105] Fix | Delete
} else if ( this.originalLabel ) {
[106] Fix | Delete
this.options.label = this.originalLabel;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
this._enhance();
[110] Fix | Delete
[111] Fix | Delete
if ( checked ) {
[112] Fix | Delete
this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
[113] Fix | Delete
if ( this.icon ) {
[114] Fix | Delete
this._addClass( this.icon, null, "ui-state-hover" );
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
this._on( {
[119] Fix | Delete
change: "_toggleClasses",
[120] Fix | Delete
focus: function() {
[121] Fix | Delete
this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
[122] Fix | Delete
},
[123] Fix | Delete
blur: function() {
[124] Fix | Delete
this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
[125] Fix | Delete
}
[126] Fix | Delete
} );
[127] Fix | Delete
},
[128] Fix | Delete
[129] Fix | Delete
_readType: function() {
[130] Fix | Delete
var nodeName = this.element[ 0 ].nodeName.toLowerCase();
[131] Fix | Delete
this.type = this.element[ 0 ].type;
[132] Fix | Delete
if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
[133] Fix | Delete
$.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
[134] Fix | Delete
" and element.type=" + this.type );
[135] Fix | Delete
}
[136] Fix | Delete
},
[137] Fix | Delete
[138] Fix | Delete
// Support jQuery Mobile enhanced option
[139] Fix | Delete
_enhance: function() {
[140] Fix | Delete
this._updateIcon( this.element[ 0 ].checked );
[141] Fix | Delete
},
[142] Fix | Delete
[143] Fix | Delete
widget: function() {
[144] Fix | Delete
return this.label;
[145] Fix | Delete
},
[146] Fix | Delete
[147] Fix | Delete
_getRadioGroup: function() {
[148] Fix | Delete
var group;
[149] Fix | Delete
var name = this.element[ 0 ].name;
[150] Fix | Delete
var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
[151] Fix | Delete
[152] Fix | Delete
if ( !name ) {
[153] Fix | Delete
return $( [] );
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
if ( this.form.length ) {
[157] Fix | Delete
group = $( this.form[ 0 ].elements ).filter( nameSelector );
[158] Fix | Delete
} else {
[159] Fix | Delete
[160] Fix | Delete
// Not inside a form, check all inputs that also are not inside a form
[161] Fix | Delete
group = $( nameSelector ).filter( function() {
[162] Fix | Delete
return $( this ).form().length === 0;
[163] Fix | Delete
} );
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
return group.not( this.element );
[167] Fix | Delete
},
[168] Fix | Delete
[169] Fix | Delete
_toggleClasses: function() {
[170] Fix | Delete
var checked = this.element[ 0 ].checked;
[171] Fix | Delete
this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
[172] Fix | Delete
[173] Fix | Delete
if ( this.options.icon && this.type === "checkbox" ) {
[174] Fix | Delete
this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
[175] Fix | Delete
._toggleClass( this.icon, null, "ui-icon-blank", !checked );
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
if ( this.type === "radio" ) {
[179] Fix | Delete
this._getRadioGroup()
[180] Fix | Delete
.each( function() {
[181] Fix | Delete
var instance = $( this ).checkboxradio( "instance" );
[182] Fix | Delete
[183] Fix | Delete
if ( instance ) {
[184] Fix | Delete
instance._removeClass( instance.label,
[185] Fix | Delete
"ui-checkboxradio-checked", "ui-state-active" );
[186] Fix | Delete
}
[187] Fix | Delete
} );
[188] Fix | Delete
}
[189] Fix | Delete
},
[190] Fix | Delete
[191] Fix | Delete
_destroy: function() {
[192] Fix | Delete
this._unbindFormResetHandler();
[193] Fix | Delete
[194] Fix | Delete
if ( this.icon ) {
[195] Fix | Delete
this.icon.remove();
[196] Fix | Delete
this.iconSpace.remove();
[197] Fix | Delete
}
[198] Fix | Delete
},
[199] Fix | Delete
[200] Fix | Delete
_setOption: function( key, value ) {
[201] Fix | Delete
[202] Fix | Delete
// We don't allow the value to be set to nothing
[203] Fix | Delete
if ( key === "label" && !value ) {
[204] Fix | Delete
return;
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
this._super( key, value );
[208] Fix | Delete
[209] Fix | Delete
if ( key === "disabled" ) {
[210] Fix | Delete
this._toggleClass( this.label, null, "ui-state-disabled", value );
[211] Fix | Delete
this.element[ 0 ].disabled = value;
[212] Fix | Delete
[213] Fix | Delete
// Don't refresh when setting disabled
[214] Fix | Delete
return;
[215] Fix | Delete
}
[216] Fix | Delete
this.refresh();
[217] Fix | Delete
},
[218] Fix | Delete
[219] Fix | Delete
_updateIcon: function( checked ) {
[220] Fix | Delete
var toAdd = "ui-icon ui-icon-background ";
[221] Fix | Delete
[222] Fix | Delete
if ( this.options.icon ) {
[223] Fix | Delete
if ( !this.icon ) {
[224] Fix | Delete
this.icon = $( "<span>" );
[225] Fix | Delete
this.iconSpace = $( "<span> </span>" );
[226] Fix | Delete
this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
if ( this.type === "checkbox" ) {
[230] Fix | Delete
toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
[231] Fix | Delete
this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
[232] Fix | Delete
} else {
[233] Fix | Delete
toAdd += "ui-icon-blank";
[234] Fix | Delete
}
[235] Fix | Delete
this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
[236] Fix | Delete
if ( !checked ) {
[237] Fix | Delete
this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
[238] Fix | Delete
}
[239] Fix | Delete
this.icon.prependTo( this.label ).after( this.iconSpace );
[240] Fix | Delete
} else if ( this.icon !== undefined ) {
[241] Fix | Delete
this.icon.remove();
[242] Fix | Delete
this.iconSpace.remove();
[243] Fix | Delete
delete this.icon;
[244] Fix | Delete
}
[245] Fix | Delete
},
[246] Fix | Delete
[247] Fix | Delete
_updateLabel: function() {
[248] Fix | Delete
[249] Fix | Delete
// Remove the contents of the label ( minus the icon, icon space, and input )
[250] Fix | Delete
var contents = this.label.contents().not( this.element[ 0 ] );
[251] Fix | Delete
if ( this.icon ) {
[252] Fix | Delete
contents = contents.not( this.icon[ 0 ] );
[253] Fix | Delete
}
[254] Fix | Delete
if ( this.iconSpace ) {
[255] Fix | Delete
contents = contents.not( this.iconSpace[ 0 ] );
[256] Fix | Delete
}
[257] Fix | Delete
contents.remove();
[258] Fix | Delete
[259] Fix | Delete
this.label.append( this.options.label );
[260] Fix | Delete
},
[261] Fix | Delete
[262] Fix | Delete
refresh: function() {
[263] Fix | Delete
var checked = this.element[ 0 ].checked,
[264] Fix | Delete
isDisabled = this.element[ 0 ].disabled;
[265] Fix | Delete
[266] Fix | Delete
this._updateIcon( checked );
[267] Fix | Delete
this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
[268] Fix | Delete
if ( this.options.label !== null ) {
[269] Fix | Delete
this._updateLabel();
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
if ( isDisabled !== this.options.disabled ) {
[273] Fix | Delete
this._setOptions( { "disabled": isDisabled } );
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
} ] );
[278] Fix | Delete
[279] Fix | Delete
return $.ui.checkboxradio;
[280] Fix | Delete
[281] Fix | Delete
} ) );
[282] Fix | Delete
[283] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function