Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: customize-widgets.js
/**
[0] Fix | Delete
* @output wp-admin/js/customize-widgets.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global _wpCustomizeWidgetsSettings */
[4] Fix | Delete
(function( wp, $ ){
[5] Fix | Delete
[6] Fix | Delete
if ( ! wp || ! wp.customize ) { return; }
[7] Fix | Delete
[8] Fix | Delete
// Set up our namespace...
[9] Fix | Delete
var api = wp.customize,
[10] Fix | Delete
l10n;
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* @namespace wp.customize.Widgets
[14] Fix | Delete
*/
[15] Fix | Delete
api.Widgets = api.Widgets || {};
[16] Fix | Delete
api.Widgets.savedWidgetIds = {};
[17] Fix | Delete
[18] Fix | Delete
// Link settings.
[19] Fix | Delete
api.Widgets.data = _wpCustomizeWidgetsSettings || {};
[20] Fix | Delete
l10n = api.Widgets.data.l10n;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* wp.customize.Widgets.WidgetModel
[24] Fix | Delete
*
[25] Fix | Delete
* A single widget model.
[26] Fix | Delete
*
[27] Fix | Delete
* @class wp.customize.Widgets.WidgetModel
[28] Fix | Delete
* @augments Backbone.Model
[29] Fix | Delete
*/
[30] Fix | Delete
api.Widgets.WidgetModel = Backbone.Model.extend(/** @lends wp.customize.Widgets.WidgetModel.prototype */{
[31] Fix | Delete
id: null,
[32] Fix | Delete
temp_id: null,
[33] Fix | Delete
classname: null,
[34] Fix | Delete
control_tpl: null,
[35] Fix | Delete
description: null,
[36] Fix | Delete
is_disabled: null,
[37] Fix | Delete
is_multi: null,
[38] Fix | Delete
multi_number: null,
[39] Fix | Delete
name: null,
[40] Fix | Delete
id_base: null,
[41] Fix | Delete
transport: null,
[42] Fix | Delete
params: [],
[43] Fix | Delete
width: null,
[44] Fix | Delete
height: null,
[45] Fix | Delete
search_matched: true
[46] Fix | Delete
});
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* wp.customize.Widgets.WidgetCollection
[50] Fix | Delete
*
[51] Fix | Delete
* Collection for widget models.
[52] Fix | Delete
*
[53] Fix | Delete
* @class wp.customize.Widgets.WidgetCollection
[54] Fix | Delete
* @augments Backbone.Collection
[55] Fix | Delete
*/
[56] Fix | Delete
api.Widgets.WidgetCollection = Backbone.Collection.extend(/** @lends wp.customize.Widgets.WidgetCollection.prototype */{
[57] Fix | Delete
model: api.Widgets.WidgetModel,
[58] Fix | Delete
[59] Fix | Delete
// Controls searching on the current widget collection
[60] Fix | Delete
// and triggers an update event.
[61] Fix | Delete
doSearch: function( value ) {
[62] Fix | Delete
[63] Fix | Delete
// Don't do anything if we've already done this search.
[64] Fix | Delete
// Useful because the search handler fires multiple times per keystroke.
[65] Fix | Delete
if ( this.terms === value ) {
[66] Fix | Delete
return;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
// Updates terms with the value passed.
[70] Fix | Delete
this.terms = value;
[71] Fix | Delete
[72] Fix | Delete
// If we have terms, run a search...
[73] Fix | Delete
if ( this.terms.length > 0 ) {
[74] Fix | Delete
this.search( this.terms );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
// If search is blank, set all the widgets as they matched the search to reset the views.
[78] Fix | Delete
if ( this.terms === '' ) {
[79] Fix | Delete
this.each( function ( widget ) {
[80] Fix | Delete
widget.set( 'search_matched', true );
[81] Fix | Delete
} );
[82] Fix | Delete
}
[83] Fix | Delete
},
[84] Fix | Delete
[85] Fix | Delete
// Performs a search within the collection.
[86] Fix | Delete
// @uses RegExp
[87] Fix | Delete
search: function( term ) {
[88] Fix | Delete
var match, haystack;
[89] Fix | Delete
[90] Fix | Delete
// Escape the term string for RegExp meta characters.
[91] Fix | Delete
term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
[92] Fix | Delete
[93] Fix | Delete
// Consider spaces as word delimiters and match the whole string
[94] Fix | Delete
// so matching terms can be combined.
[95] Fix | Delete
term = term.replace( / /g, ')(?=.*' );
[96] Fix | Delete
match = new RegExp( '^(?=.*' + term + ').+', 'i' );
[97] Fix | Delete
[98] Fix | Delete
this.each( function ( data ) {
[99] Fix | Delete
haystack = [ data.get( 'name' ), data.get( 'description' ) ].join( ' ' );
[100] Fix | Delete
data.set( 'search_matched', match.test( haystack ) );
[101] Fix | Delete
} );
[102] Fix | Delete
}
[103] Fix | Delete
});
[104] Fix | Delete
api.Widgets.availableWidgets = new api.Widgets.WidgetCollection( api.Widgets.data.availableWidgets );
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* wp.customize.Widgets.SidebarModel
[108] Fix | Delete
*
[109] Fix | Delete
* A single sidebar model.
[110] Fix | Delete
*
[111] Fix | Delete
* @class wp.customize.Widgets.SidebarModel
[112] Fix | Delete
* @augments Backbone.Model
[113] Fix | Delete
*/
[114] Fix | Delete
api.Widgets.SidebarModel = Backbone.Model.extend(/** @lends wp.customize.Widgets.SidebarModel.prototype */{
[115] Fix | Delete
after_title: null,
[116] Fix | Delete
after_widget: null,
[117] Fix | Delete
before_title: null,
[118] Fix | Delete
before_widget: null,
[119] Fix | Delete
'class': null,
[120] Fix | Delete
description: null,
[121] Fix | Delete
id: null,
[122] Fix | Delete
name: null,
[123] Fix | Delete
is_rendered: false
[124] Fix | Delete
});
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* wp.customize.Widgets.SidebarCollection
[128] Fix | Delete
*
[129] Fix | Delete
* Collection for sidebar models.
[130] Fix | Delete
*
[131] Fix | Delete
* @class wp.customize.Widgets.SidebarCollection
[132] Fix | Delete
* @augments Backbone.Collection
[133] Fix | Delete
*/
[134] Fix | Delete
api.Widgets.SidebarCollection = Backbone.Collection.extend(/** @lends wp.customize.Widgets.SidebarCollection.prototype */{
[135] Fix | Delete
model: api.Widgets.SidebarModel
[136] Fix | Delete
});
[137] Fix | Delete
api.Widgets.registeredSidebars = new api.Widgets.SidebarCollection( api.Widgets.data.registeredSidebars );
[138] Fix | Delete
[139] Fix | Delete
api.Widgets.AvailableWidgetsPanelView = wp.Backbone.View.extend(/** @lends wp.customize.Widgets.AvailableWidgetsPanelView.prototype */{
[140] Fix | Delete
[141] Fix | Delete
el: '#available-widgets',
[142] Fix | Delete
[143] Fix | Delete
events: {
[144] Fix | Delete
'input #widgets-search': 'search',
[145] Fix | Delete
'focus .widget-tpl' : 'focus',
[146] Fix | Delete
'click .widget-tpl' : '_submit',
[147] Fix | Delete
'keypress .widget-tpl' : '_submit',
[148] Fix | Delete
'keydown' : 'keyboardAccessible'
[149] Fix | Delete
},
[150] Fix | Delete
[151] Fix | Delete
// Cache current selected widget.
[152] Fix | Delete
selected: null,
[153] Fix | Delete
[154] Fix | Delete
// Cache sidebar control which has opened panel.
[155] Fix | Delete
currentSidebarControl: null,
[156] Fix | Delete
$search: null,
[157] Fix | Delete
$clearResults: null,
[158] Fix | Delete
searchMatchesCount: null,
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* View class for the available widgets panel.
[162] Fix | Delete
*
[163] Fix | Delete
* @constructs wp.customize.Widgets.AvailableWidgetsPanelView
[164] Fix | Delete
* @augments wp.Backbone.View
[165] Fix | Delete
*/
[166] Fix | Delete
initialize: function() {
[167] Fix | Delete
var self = this;
[168] Fix | Delete
[169] Fix | Delete
this.$search = $( '#widgets-search' );
[170] Fix | Delete
[171] Fix | Delete
this.$clearResults = this.$el.find( '.clear-results' );
[172] Fix | Delete
[173] Fix | Delete
_.bindAll( this, 'close' );
[174] Fix | Delete
[175] Fix | Delete
this.listenTo( this.collection, 'change', this.updateList );
[176] Fix | Delete
[177] Fix | Delete
this.updateList();
[178] Fix | Delete
[179] Fix | Delete
// Set the initial search count to the number of available widgets.
[180] Fix | Delete
this.searchMatchesCount = this.collection.length;
[181] Fix | Delete
[182] Fix | Delete
/*
[183] Fix | Delete
* If the available widgets panel is open and the customize controls
[184] Fix | Delete
* are interacted with (i.e. available widgets panel is blurred) then
[185] Fix | Delete
* close the available widgets panel. Also close on back button click.
[186] Fix | Delete
*/
[187] Fix | Delete
$( '#customize-controls, #available-widgets .customize-section-title' ).on( 'click keydown', function( e ) {
[188] Fix | Delete
var isAddNewBtn = $( e.target ).is( '.add-new-widget, .add-new-widget *' );
[189] Fix | Delete
if ( $( 'body' ).hasClass( 'adding-widget' ) && ! isAddNewBtn ) {
[190] Fix | Delete
self.close();
[191] Fix | Delete
}
[192] Fix | Delete
} );
[193] Fix | Delete
[194] Fix | Delete
// Clear the search results and trigger an `input` event to fire a new search.
[195] Fix | Delete
this.$clearResults.on( 'click', function() {
[196] Fix | Delete
self.$search.val( '' ).focus().trigger( 'input' );
[197] Fix | Delete
} );
[198] Fix | Delete
[199] Fix | Delete
// Close the panel if the URL in the preview changes.
[200] Fix | Delete
api.previewer.bind( 'url', this.close );
[201] Fix | Delete
},
[202] Fix | Delete
[203] Fix | Delete
/**
[204] Fix | Delete
* Performs a search and handles selected widget.
[205] Fix | Delete
*/
[206] Fix | Delete
search: _.debounce( function( event ) {
[207] Fix | Delete
var firstVisible;
[208] Fix | Delete
[209] Fix | Delete
this.collection.doSearch( event.target.value );
[210] Fix | Delete
// Update the search matches count.
[211] Fix | Delete
this.updateSearchMatchesCount();
[212] Fix | Delete
// Announce how many search results.
[213] Fix | Delete
this.announceSearchMatches();
[214] Fix | Delete
[215] Fix | Delete
// Remove a widget from being selected if it is no longer visible.
[216] Fix | Delete
if ( this.selected && ! this.selected.is( ':visible' ) ) {
[217] Fix | Delete
this.selected.removeClass( 'selected' );
[218] Fix | Delete
this.selected = null;
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
// If a widget was selected but the filter value has been cleared out, clear selection.
[222] Fix | Delete
if ( this.selected && ! event.target.value ) {
[223] Fix | Delete
this.selected.removeClass( 'selected' );
[224] Fix | Delete
this.selected = null;
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
// If a filter has been entered and a widget hasn't been selected, select the first one shown.
[228] Fix | Delete
if ( ! this.selected && event.target.value ) {
[229] Fix | Delete
firstVisible = this.$el.find( '> .widget-tpl:visible:first' );
[230] Fix | Delete
if ( firstVisible.length ) {
[231] Fix | Delete
this.select( firstVisible );
[232] Fix | Delete
}
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
// Toggle the clear search results button.
[236] Fix | Delete
if ( '' !== event.target.value ) {
[237] Fix | Delete
this.$clearResults.addClass( 'is-visible' );
[238] Fix | Delete
} else if ( '' === event.target.value ) {
[239] Fix | Delete
this.$clearResults.removeClass( 'is-visible' );
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
// Set a CSS class on the search container when there are no search results.
[243] Fix | Delete
if ( ! this.searchMatchesCount ) {
[244] Fix | Delete
this.$el.addClass( 'no-widgets-found' );
[245] Fix | Delete
} else {
[246] Fix | Delete
this.$el.removeClass( 'no-widgets-found' );
[247] Fix | Delete
}
[248] Fix | Delete
}, 500 ),
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Updates the count of the available widgets that have the `search_matched` attribute.
[252] Fix | Delete
*/
[253] Fix | Delete
updateSearchMatchesCount: function() {
[254] Fix | Delete
this.searchMatchesCount = this.collection.where({ search_matched: true }).length;
[255] Fix | Delete
},
[256] Fix | Delete
[257] Fix | Delete
/**
[258] Fix | Delete
* Sends a message to the aria-live region to announce how many search results.
[259] Fix | Delete
*/
[260] Fix | Delete
announceSearchMatches: function() {
[261] Fix | Delete
var message = l10n.widgetsFound.replace( '%d', this.searchMatchesCount ) ;
[262] Fix | Delete
[263] Fix | Delete
if ( ! this.searchMatchesCount ) {
[264] Fix | Delete
message = l10n.noWidgetsFound;
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
wp.a11y.speak( message );
[268] Fix | Delete
},
[269] Fix | Delete
[270] Fix | Delete
/**
[271] Fix | Delete
* Changes visibility of available widgets.
[272] Fix | Delete
*/
[273] Fix | Delete
updateList: function() {
[274] Fix | Delete
this.collection.each( function( widget ) {
[275] Fix | Delete
var widgetTpl = $( '#widget-tpl-' + widget.id );
[276] Fix | Delete
widgetTpl.toggle( widget.get( 'search_matched' ) && ! widget.get( 'is_disabled' ) );
[277] Fix | Delete
if ( widget.get( 'is_disabled' ) && widgetTpl.is( this.selected ) ) {
[278] Fix | Delete
this.selected = null;
[279] Fix | Delete
}
[280] Fix | Delete
} );
[281] Fix | Delete
},
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Highlights a widget.
[285] Fix | Delete
*/
[286] Fix | Delete
select: function( widgetTpl ) {
[287] Fix | Delete
this.selected = $( widgetTpl );
[288] Fix | Delete
this.selected.siblings( '.widget-tpl' ).removeClass( 'selected' );
[289] Fix | Delete
this.selected.addClass( 'selected' );
[290] Fix | Delete
},
[291] Fix | Delete
[292] Fix | Delete
/**
[293] Fix | Delete
* Highlights a widget on focus.
[294] Fix | Delete
*/
[295] Fix | Delete
focus: function( event ) {
[296] Fix | Delete
this.select( $( event.currentTarget ) );
[297] Fix | Delete
},
[298] Fix | Delete
[299] Fix | Delete
/**
[300] Fix | Delete
* Handles submit for keypress and click on widget.
[301] Fix | Delete
*/
[302] Fix | Delete
_submit: function( event ) {
[303] Fix | Delete
// Only proceed with keypress if it is Enter or Spacebar.
[304] Fix | Delete
if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) {
[305] Fix | Delete
return;
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
this.submit( $( event.currentTarget ) );
[309] Fix | Delete
},
[310] Fix | Delete
[311] Fix | Delete
/**
[312] Fix | Delete
* Adds a selected widget to the sidebar.
[313] Fix | Delete
*/
[314] Fix | Delete
submit: function( widgetTpl ) {
[315] Fix | Delete
var widgetId, widget, widgetFormControl;
[316] Fix | Delete
[317] Fix | Delete
if ( ! widgetTpl ) {
[318] Fix | Delete
widgetTpl = this.selected;
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
if ( ! widgetTpl || ! this.currentSidebarControl ) {
[322] Fix | Delete
return;
[323] Fix | Delete
}
[324] Fix | Delete
[325] Fix | Delete
this.select( widgetTpl );
[326] Fix | Delete
[327] Fix | Delete
widgetId = $( this.selected ).data( 'widget-id' );
[328] Fix | Delete
widget = this.collection.findWhere( { id: widgetId } );
[329] Fix | Delete
if ( ! widget ) {
[330] Fix | Delete
return;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
widgetFormControl = this.currentSidebarControl.addWidget( widget.get( 'id_base' ) );
[334] Fix | Delete
if ( widgetFormControl ) {
[335] Fix | Delete
widgetFormControl.focus();
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
this.close();
[339] Fix | Delete
},
[340] Fix | Delete
[341] Fix | Delete
/**
[342] Fix | Delete
* Opens the panel.
[343] Fix | Delete
*/
[344] Fix | Delete
open: function( sidebarControl ) {
[345] Fix | Delete
this.currentSidebarControl = sidebarControl;
[346] Fix | Delete
[347] Fix | Delete
// Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens.
[348] Fix | Delete
_( this.currentSidebarControl.getWidgetFormControls() ).each( function( control ) {
[349] Fix | Delete
if ( control.params.is_wide ) {
[350] Fix | Delete
control.collapseForm();
[351] Fix | Delete
}
[352] Fix | Delete
} );
[353] Fix | Delete
[354] Fix | Delete
if ( api.section.has( 'publish_settings' ) ) {
[355] Fix | Delete
api.section( 'publish_settings' ).collapse();
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
$( 'body' ).addClass( 'adding-widget' );
[359] Fix | Delete
[360] Fix | Delete
this.$el.find( '.selected' ).removeClass( 'selected' );
[361] Fix | Delete
[362] Fix | Delete
// Reset search.
[363] Fix | Delete
this.collection.doSearch( '' );
[364] Fix | Delete
[365] Fix | Delete
if ( ! api.settings.browser.mobile ) {
[366] Fix | Delete
this.$search.focus();
[367] Fix | Delete
}
[368] Fix | Delete
},
[369] Fix | Delete
[370] Fix | Delete
/**
[371] Fix | Delete
* Closes the panel.
[372] Fix | Delete
*/
[373] Fix | Delete
close: function( options ) {
[374] Fix | Delete
options = options || {};
[375] Fix | Delete
[376] Fix | Delete
if ( options.returnFocus && this.currentSidebarControl ) {
[377] Fix | Delete
this.currentSidebarControl.container.find( '.add-new-widget' ).focus();
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
this.currentSidebarControl = null;
[381] Fix | Delete
this.selected = null;
[382] Fix | Delete
[383] Fix | Delete
$( 'body' ).removeClass( 'adding-widget' );
[384] Fix | Delete
[385] Fix | Delete
this.$search.val( '' ).trigger( 'input' );
[386] Fix | Delete
},
[387] Fix | Delete
[388] Fix | Delete
/**
[389] Fix | Delete
* Adds keyboard accessiblity to the panel.
[390] Fix | Delete
*/
[391] Fix | Delete
keyboardAccessible: function( event ) {
[392] Fix | Delete
var isEnter = ( event.which === 13 ),
[393] Fix | Delete
isEsc = ( event.which === 27 ),
[394] Fix | Delete
isDown = ( event.which === 40 ),
[395] Fix | Delete
isUp = ( event.which === 38 ),
[396] Fix | Delete
isTab = ( event.which === 9 ),
[397] Fix | Delete
isShift = ( event.shiftKey ),
[398] Fix | Delete
selected = null,
[399] Fix | Delete
firstVisible = this.$el.find( '> .widget-tpl:visible:first' ),
[400] Fix | Delete
lastVisible = this.$el.find( '> .widget-tpl:visible:last' ),
[401] Fix | Delete
isSearchFocused = $( event.target ).is( this.$search ),
[402] Fix | Delete
isLastWidgetFocused = $( event.target ).is( '.widget-tpl:visible:last' );
[403] Fix | Delete
[404] Fix | Delete
if ( isDown || isUp ) {
[405] Fix | Delete
if ( isDown ) {
[406] Fix | Delete
if ( isSearchFocused ) {
[407] Fix | Delete
selected = firstVisible;
[408] Fix | Delete
} else if ( this.selected && this.selected.nextAll( '.widget-tpl:visible' ).length !== 0 ) {
[409] Fix | Delete
selected = this.selected.nextAll( '.widget-tpl:visible:first' );
[410] Fix | Delete
}
[411] Fix | Delete
} else if ( isUp ) {
[412] Fix | Delete
if ( isSearchFocused ) {
[413] Fix | Delete
selected = lastVisible;
[414] Fix | Delete
} else if ( this.selected && this.selected.prevAll( '.widget-tpl:visible' ).length !== 0 ) {
[415] Fix | Delete
selected = this.selected.prevAll( '.widget-tpl:visible:first' );
[416] Fix | Delete
}
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
this.select( selected );
[420] Fix | Delete
[421] Fix | Delete
if ( selected ) {
[422] Fix | Delete
selected.focus();
[423] Fix | Delete
} else {
[424] Fix | Delete
this.$search.focus();
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
return;
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
// If enter pressed but nothing entered, don't do anything.
[431] Fix | Delete
if ( isEnter && ! this.$search.val() ) {
[432] Fix | Delete
return;
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
if ( isEnter ) {
[436] Fix | Delete
this.submit();
[437] Fix | Delete
} else if ( isEsc ) {
[438] Fix | Delete
this.close( { returnFocus: true } );
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
if ( this.currentSidebarControl && isTab && ( isShift && isSearchFocused || ! isShift && isLastWidgetFocused ) ) {
[442] Fix | Delete
this.currentSidebarControl.container.find( '.add-new-widget' ).focus();
[443] Fix | Delete
event.preventDefault();
[444] Fix | Delete
}
[445] Fix | Delete
}
[446] Fix | Delete
});
[447] Fix | Delete
[448] Fix | Delete
/**
[449] Fix | Delete
* Handlers for the widget-synced event, organized by widget ID base.
[450] Fix | Delete
* Other widgets may provide their own update handlers by adding
[451] Fix | Delete
* listeners for the widget-synced event.
[452] Fix | Delete
*
[453] Fix | Delete
* @alias wp.customize.Widgets.formSyncHandlers
[454] Fix | Delete
*/
[455] Fix | Delete
api.Widgets.formSyncHandlers = {
[456] Fix | Delete
[457] Fix | Delete
/**
[458] Fix | Delete
* @param {jQuery.Event} e
[459] Fix | Delete
* @param {jQuery} widget
[460] Fix | Delete
* @param {string} newForm
[461] Fix | Delete
*/
[462] Fix | Delete
rss: function( e, widget, newForm ) {
[463] Fix | Delete
var oldWidgetError = widget.find( '.widget-error:first' ),
[464] Fix | Delete
newWidgetError = $( '<div>' + newForm + '</div>' ).find( '.widget-error:first' );
[465] Fix | Delete
[466] Fix | Delete
if ( oldWidgetError.length && newWidgetError.length ) {
[467] Fix | Delete
oldWidgetError.replaceWith( newWidgetError );
[468] Fix | Delete
} else if ( oldWidgetError.length ) {
[469] Fix | Delete
oldWidgetError.remove();
[470] Fix | Delete
} else if ( newWidgetError.length ) {
[471] Fix | Delete
widget.find( '.widget-content:first' ).prepend( newWidgetError );
[472] Fix | Delete
}
[473] Fix | Delete
}
[474] Fix | Delete
};
[475] Fix | Delete
[476] Fix | Delete
api.Widgets.WidgetControl = api.Control.extend(/** @lends wp.customize.Widgets.WidgetControl.prototype */{
[477] Fix | Delete
defaultExpandedArguments: {
[478] Fix | Delete
duration: 'fast',
[479] Fix | Delete
completeCallback: $.noop
[480] Fix | Delete
},
[481] Fix | Delete
[482] Fix | Delete
/**
[483] Fix | Delete
* wp.customize.Widgets.WidgetControl
[484] Fix | Delete
*
[485] Fix | Delete
* Customizer control for widgets.
[486] Fix | Delete
* Note that 'widget_form' must match the WP_Widget_Form_Customize_Control::$type
[487] Fix | Delete
*
[488] Fix | Delete
* @since 4.1.0
[489] Fix | Delete
*
[490] Fix | Delete
* @constructs wp.customize.Widgets.WidgetControl
[491] Fix | Delete
* @augments wp.customize.Control
[492] Fix | Delete
*/
[493] Fix | Delete
initialize: function( id, options ) {
[494] Fix | Delete
var control = this;
[495] Fix | Delete
[496] Fix | Delete
control.widgetControlEmbedded = false;
[497] Fix | Delete
control.widgetContentEmbedded = false;
[498] Fix | Delete
control.expanded = new api.Value( false );
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function