Edit File by line
/home/barbar84/public_h.../wp-inclu.../js/jquery/ui
File: controlgroup.js
/*!
[0] Fix | Delete
* jQuery UI Controlgroup 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: Controlgroup
[9] Fix | Delete
//>>group: Widgets
[10] Fix | Delete
//>>description: Visually groups form control widgets
[11] Fix | Delete
//>>docs: http://api.jqueryui.com/controlgroup/
[12] Fix | Delete
//>>demos: http://jqueryui.com/controlgroup/
[13] Fix | Delete
//>>css.structure: ../../themes/base/core.css
[14] Fix | Delete
//>>css.structure: ../../themes/base/controlgroup.css
[15] Fix | Delete
//>>css.theme: ../../themes/base/theme.css
[16] Fix | Delete
[17] Fix | Delete
( function( factory ) {
[18] Fix | Delete
if ( typeof define === "function" && define.amd ) {
[19] Fix | Delete
[20] Fix | Delete
// AMD. Register as an anonymous module.
[21] Fix | Delete
define( [
[22] Fix | Delete
"jquery",
[23] Fix | Delete
"./core"
[24] Fix | Delete
], factory );
[25] Fix | Delete
} else {
[26] Fix | Delete
[27] Fix | Delete
// Browser globals
[28] Fix | Delete
factory( jQuery );
[29] Fix | Delete
}
[30] Fix | Delete
}( function( $ ) {
[31] Fix | Delete
var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
[32] Fix | Delete
[33] Fix | Delete
return $.widget( "ui.controlgroup", {
[34] Fix | Delete
version: "1.12.1",
[35] Fix | Delete
defaultElement: "<div>",
[36] Fix | Delete
options: {
[37] Fix | Delete
direction: "horizontal",
[38] Fix | Delete
disabled: null,
[39] Fix | Delete
onlyVisible: true,
[40] Fix | Delete
items: {
[41] Fix | Delete
"button": "input[type=button], input[type=submit], input[type=reset], button, a",
[42] Fix | Delete
"controlgroupLabel": ".ui-controlgroup-label",
[43] Fix | Delete
"checkboxradio": "input[type='checkbox'], input[type='radio']",
[44] Fix | Delete
"selectmenu": "select",
[45] Fix | Delete
"spinner": ".ui-spinner-input"
[46] Fix | Delete
}
[47] Fix | Delete
},
[48] Fix | Delete
[49] Fix | Delete
_create: function() {
[50] Fix | Delete
this._enhance();
[51] Fix | Delete
},
[52] Fix | Delete
[53] Fix | Delete
// To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
[54] Fix | Delete
_enhance: function() {
[55] Fix | Delete
this.element.attr( "role", "toolbar" );
[56] Fix | Delete
this.refresh();
[57] Fix | Delete
},
[58] Fix | Delete
[59] Fix | Delete
_destroy: function() {
[60] Fix | Delete
this._callChildMethod( "destroy" );
[61] Fix | Delete
this.childWidgets.removeData( "ui-controlgroup-data" );
[62] Fix | Delete
this.element.removeAttr( "role" );
[63] Fix | Delete
if ( this.options.items.controlgroupLabel ) {
[64] Fix | Delete
this.element
[65] Fix | Delete
.find( this.options.items.controlgroupLabel )
[66] Fix | Delete
.find( ".ui-controlgroup-label-contents" )
[67] Fix | Delete
.contents().unwrap();
[68] Fix | Delete
}
[69] Fix | Delete
},
[70] Fix | Delete
[71] Fix | Delete
_initWidgets: function() {
[72] Fix | Delete
var that = this,
[73] Fix | Delete
childWidgets = [];
[74] Fix | Delete
[75] Fix | Delete
// First we iterate over each of the items options
[76] Fix | Delete
$.each( this.options.items, function( widget, selector ) {
[77] Fix | Delete
var labels;
[78] Fix | Delete
var options = {};
[79] Fix | Delete
[80] Fix | Delete
// Make sure the widget has a selector set
[81] Fix | Delete
if ( !selector ) {
[82] Fix | Delete
return;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if ( widget === "controlgroupLabel" ) {
[86] Fix | Delete
labels = that.element.find( selector );
[87] Fix | Delete
labels.each( function() {
[88] Fix | Delete
var element = $( this );
[89] Fix | Delete
[90] Fix | Delete
if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
[91] Fix | Delete
return;
[92] Fix | Delete
}
[93] Fix | Delete
element.contents()
[94] Fix | Delete
.wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
[95] Fix | Delete
} );
[96] Fix | Delete
that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
[97] Fix | Delete
childWidgets = childWidgets.concat( labels.get() );
[98] Fix | Delete
return;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
// Make sure the widget actually exists
[102] Fix | Delete
if ( !$.fn[ widget ] ) {
[103] Fix | Delete
return;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
// We assume everything is in the middle to start because we can't determine
[107] Fix | Delete
// first / last elements until all enhancments are done.
[108] Fix | Delete
if ( that[ "_" + widget + "Options" ] ) {
[109] Fix | Delete
options = that[ "_" + widget + "Options" ]( "middle" );
[110] Fix | Delete
} else {
[111] Fix | Delete
options = { classes: {} };
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
// Find instances of this widget inside controlgroup and init them
[115] Fix | Delete
that.element
[116] Fix | Delete
.find( selector )
[117] Fix | Delete
.each( function() {
[118] Fix | Delete
var element = $( this );
[119] Fix | Delete
var instance = element[ widget ]( "instance" );
[120] Fix | Delete
[121] Fix | Delete
// We need to clone the default options for this type of widget to avoid
[122] Fix | Delete
// polluting the variable options which has a wider scope than a single widget.
[123] Fix | Delete
var instanceOptions = $.widget.extend( {}, options );
[124] Fix | Delete
[125] Fix | Delete
// If the button is the child of a spinner ignore it
[126] Fix | Delete
// TODO: Find a more generic solution
[127] Fix | Delete
if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
[128] Fix | Delete
return;
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
// Create the widget if it doesn't exist
[132] Fix | Delete
if ( !instance ) {
[133] Fix | Delete
instance = element[ widget ]()[ widget ]( "instance" );
[134] Fix | Delete
}
[135] Fix | Delete
if ( instance ) {
[136] Fix | Delete
instanceOptions.classes =
[137] Fix | Delete
that._resolveClassesValues( instanceOptions.classes, instance );
[138] Fix | Delete
}
[139] Fix | Delete
element[ widget ]( instanceOptions );
[140] Fix | Delete
[141] Fix | Delete
// Store an instance of the controlgroup to be able to reference
[142] Fix | Delete
// from the outermost element for changing options and refresh
[143] Fix | Delete
var widgetElement = element[ widget ]( "widget" );
[144] Fix | Delete
$.data( widgetElement[ 0 ], "ui-controlgroup-data",
[145] Fix | Delete
instance ? instance : element[ widget ]( "instance" ) );
[146] Fix | Delete
[147] Fix | Delete
childWidgets.push( widgetElement[ 0 ] );
[148] Fix | Delete
} );
[149] Fix | Delete
} );
[150] Fix | Delete
[151] Fix | Delete
this.childWidgets = $( $.unique( childWidgets ) );
[152] Fix | Delete
this._addClass( this.childWidgets, "ui-controlgroup-item" );
[153] Fix | Delete
},
[154] Fix | Delete
[155] Fix | Delete
_callChildMethod: function( method ) {
[156] Fix | Delete
this.childWidgets.each( function() {
[157] Fix | Delete
var element = $( this ),
[158] Fix | Delete
data = element.data( "ui-controlgroup-data" );
[159] Fix | Delete
if ( data && data[ method ] ) {
[160] Fix | Delete
data[ method ]();
[161] Fix | Delete
}
[162] Fix | Delete
} );
[163] Fix | Delete
},
[164] Fix | Delete
[165] Fix | Delete
_updateCornerClass: function( element, position ) {
[166] Fix | Delete
var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
[167] Fix | Delete
var add = this._buildSimpleOptions( position, "label" ).classes.label;
[168] Fix | Delete
[169] Fix | Delete
this._removeClass( element, null, remove );
[170] Fix | Delete
this._addClass( element, null, add );
[171] Fix | Delete
},
[172] Fix | Delete
[173] Fix | Delete
_buildSimpleOptions: function( position, key ) {
[174] Fix | Delete
var direction = this.options.direction === "vertical";
[175] Fix | Delete
var result = {
[176] Fix | Delete
classes: {}
[177] Fix | Delete
};
[178] Fix | Delete
result.classes[ key ] = {
[179] Fix | Delete
"middle": "",
[180] Fix | Delete
"first": "ui-corner-" + ( direction ? "top" : "left" ),
[181] Fix | Delete
"last": "ui-corner-" + ( direction ? "bottom" : "right" ),
[182] Fix | Delete
"only": "ui-corner-all"
[183] Fix | Delete
}[ position ];
[184] Fix | Delete
[185] Fix | Delete
return result;
[186] Fix | Delete
},
[187] Fix | Delete
[188] Fix | Delete
_spinnerOptions: function( position ) {
[189] Fix | Delete
var options = this._buildSimpleOptions( position, "ui-spinner" );
[190] Fix | Delete
[191] Fix | Delete
options.classes[ "ui-spinner-up" ] = "";
[192] Fix | Delete
options.classes[ "ui-spinner-down" ] = "";
[193] Fix | Delete
[194] Fix | Delete
return options;
[195] Fix | Delete
},
[196] Fix | Delete
[197] Fix | Delete
_buttonOptions: function( position ) {
[198] Fix | Delete
return this._buildSimpleOptions( position, "ui-button" );
[199] Fix | Delete
},
[200] Fix | Delete
[201] Fix | Delete
_checkboxradioOptions: function( position ) {
[202] Fix | Delete
return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
[203] Fix | Delete
},
[204] Fix | Delete
[205] Fix | Delete
_selectmenuOptions: function( position ) {
[206] Fix | Delete
var direction = this.options.direction === "vertical";
[207] Fix | Delete
return {
[208] Fix | Delete
width: direction ? "auto" : false,
[209] Fix | Delete
classes: {
[210] Fix | Delete
middle: {
[211] Fix | Delete
"ui-selectmenu-button-open": "",
[212] Fix | Delete
"ui-selectmenu-button-closed": ""
[213] Fix | Delete
},
[214] Fix | Delete
first: {
[215] Fix | Delete
"ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
[216] Fix | Delete
"ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
[217] Fix | Delete
},
[218] Fix | Delete
last: {
[219] Fix | Delete
"ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
[220] Fix | Delete
"ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
[221] Fix | Delete
},
[222] Fix | Delete
only: {
[223] Fix | Delete
"ui-selectmenu-button-open": "ui-corner-top",
[224] Fix | Delete
"ui-selectmenu-button-closed": "ui-corner-all"
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
}[ position ]
[228] Fix | Delete
};
[229] Fix | Delete
},
[230] Fix | Delete
[231] Fix | Delete
_resolveClassesValues: function( classes, instance ) {
[232] Fix | Delete
var result = {};
[233] Fix | Delete
$.each( classes, function( key ) {
[234] Fix | Delete
var current = instance.options.classes[ key ] || "";
[235] Fix | Delete
current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
[236] Fix | Delete
result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
[237] Fix | Delete
} );
[238] Fix | Delete
return result;
[239] Fix | Delete
},
[240] Fix | Delete
[241] Fix | Delete
_setOption: function( key, value ) {
[242] Fix | Delete
if ( key === "direction" ) {
[243] Fix | Delete
this._removeClass( "ui-controlgroup-" + this.options.direction );
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
this._super( key, value );
[247] Fix | Delete
if ( key === "disabled" ) {
[248] Fix | Delete
this._callChildMethod( value ? "disable" : "enable" );
[249] Fix | Delete
return;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
this.refresh();
[253] Fix | Delete
},
[254] Fix | Delete
[255] Fix | Delete
refresh: function() {
[256] Fix | Delete
var children,
[257] Fix | Delete
that = this;
[258] Fix | Delete
[259] Fix | Delete
this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
[260] Fix | Delete
[261] Fix | Delete
if ( this.options.direction === "horizontal" ) {
[262] Fix | Delete
this._addClass( null, "ui-helper-clearfix" );
[263] Fix | Delete
}
[264] Fix | Delete
this._initWidgets();
[265] Fix | Delete
[266] Fix | Delete
children = this.childWidgets;
[267] Fix | Delete
[268] Fix | Delete
// We filter here because we need to track all childWidgets not just the visible ones
[269] Fix | Delete
if ( this.options.onlyVisible ) {
[270] Fix | Delete
children = children.filter( ":visible" );
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
if ( children.length ) {
[274] Fix | Delete
[275] Fix | Delete
// We do this last because we need to make sure all enhancment is done
[276] Fix | Delete
// before determining first and last
[277] Fix | Delete
$.each( [ "first", "last" ], function( index, value ) {
[278] Fix | Delete
var instance = children[ value ]().data( "ui-controlgroup-data" );
[279] Fix | Delete
[280] Fix | Delete
if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
[281] Fix | Delete
var options = that[ "_" + instance.widgetName + "Options" ](
[282] Fix | Delete
children.length === 1 ? "only" : value
[283] Fix | Delete
);
[284] Fix | Delete
options.classes = that._resolveClassesValues( options.classes, instance );
[285] Fix | Delete
instance.element[ instance.widgetName ]( options );
[286] Fix | Delete
} else {
[287] Fix | Delete
that._updateCornerClass( children[ value ](), value );
[288] Fix | Delete
}
[289] Fix | Delete
} );
[290] Fix | Delete
[291] Fix | Delete
// Finally call the refresh method on each of the child widgets.
[292] Fix | Delete
this._callChildMethod( "refresh" );
[293] Fix | Delete
}
[294] Fix | Delete
}
[295] Fix | Delete
} );
[296] Fix | Delete
} ) );
[297] Fix | Delete
[298] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function