diff --git a/wp-admin/js/customize-controls.js b/wp-admin/js/customize-controls.js index f2f6196281..bcfe9a8278 100644 --- a/wp-admin/js/customize-controls.js +++ b/wp-admin/js/customize-controls.js @@ -30,9 +30,9 @@ initialize: function( code, params ) { var notification = this; api.Notification.prototype.initialize.call( notification, code, params ); - notification.classes += ' notification-overlay'; + notification.containerClasses += ' notification-overlay'; if ( notification.loading ) { - notification.classes += ' notification-loading'; + notification.containerClasses += ' notification-loading'; } } }); @@ -105,17 +105,25 @@ * Add notification to the collection. * * @since 4.9.0 - * @param {string} code - Notification code. - * @param {object} params - Notification params. - * @return {api.Notification} Added instance (or existing instance if it was already added). + * + * @param {string|wp.customize.Notification} - Notification object to add. Alternatively code may be supplied, and in that case the second notificationObject argument must be supplied. + * @param {wp.customize.Notification} [notificationObject] - Notification to add when first argument is the code string. + * @returns {wp.customize.Notification} Added notification (or existing instance if it was already added). */ - add: function( code, params ) { - var collection = this; + add: function( notification, notificationObject ) { + var collection = this, code, instance; + if ( 'string' === typeof notification ) { + code = notification; + instance = notificationObject; + } else { + code = notification.code; + instance = notification; + } if ( ! collection.has( code ) ) { collection._addedIncrement += 1; collection._addedOrder[ code ] = collection._addedIncrement; } - return api.Values.prototype.add.call( this, code, params ); + return api.Values.prototype.add.call( collection, code, instance ); }, /** @@ -269,7 +277,7 @@ setting.id = id; setting.transport = setting.transport || 'refresh'; setting._dirty = options.dirty || false; - setting.notifications = new api.Values({ defaultConstructor: api.Notification }); + setting.notifications = new api.Notifications(); // Whenever the setting's value changes, refresh the preview. setting.bind( setting.preview ); @@ -745,27 +753,35 @@ * * @param {string} id - The ID for the container. * @param {object} options - Object containing one property: params. - * @param {object} options.params - Object containing the following properties. - * @param {string} options.params.title - Title shown when panel is collapsed and expanded. - * @param {string=} [options.params.description] - Description shown at the top of the panel. - * @param {number=100} [options.params.priority] - The sort priority for the panel. - * @param {string=default} [options.params.type] - The type of the panel. See wp.customize.panelConstructor. - * @param {string=} [options.params.content] - The markup to be used for the panel container. If empty, a JS template is used. - * @param {boolean=true} [options.params.active] - Whether the panel is active or not. + * @param {string} options.title - Title shown when panel is collapsed and expanded. + * @param {string=} [options.description] - Description shown at the top of the panel. + * @param {number=100} [options.priority] - The sort priority for the panel. + * @param {string} [options.templateId] - Template selector for container. + * @param {string=default} [options.type] - The type of the panel. See wp.customize.panelConstructor. + * @param {string=} [options.content] - The markup to be used for the panel container. If empty, a JS template is used. + * @param {boolean=true} [options.active] - Whether the panel is active or not. + * @param {object} [options.params] - Deprecated wrapper for the above properties. */ initialize: function ( id, options ) { var container = this; container.id = id; - options = options || {}; - options.params = _.defaults( - options.params || {}, - container.defaults - ); + if ( ! Container.instanceCounter ) { + Container.instanceCounter = 0; + } + Container.instanceCounter++; - $.extend( container, options ); + $.extend( container, { + params: _.defaults( + options.params || options, // Passing the params is deprecated. + container.defaults + ) + } ); + if ( ! container.params.instanceNumber ) { + container.params.instanceNumber = Container.instanceCounter; + } container.notifications = new api.Notifications(); - container.templateSelector = 'customize-' + container.containerType + '-' + container.params.type; + container.templateSelector = container.params.templateId || 'customize-' + container.containerType + '-' + container.params.type; container.container = $( container.params.content ); if ( 0 === container.container.length ) { container.container = $( container.getContainer() ); @@ -1206,16 +1222,16 @@ * @since 4.1.0 * * @param {string} id - The ID for the section. - * @param {object} options - Object containing one property: params. - * @param {object} options.params - Object containing the following properties. - * @param {string} options.params.title - Title shown when section is collapsed and expanded. - * @param {string=} [options.params.description] - Description shown at the top of the section. - * @param {number=100} [options.params.priority] - The sort priority for the section. - * @param {string=default} [options.params.type] - The type of the section. See wp.customize.sectionConstructor. - * @param {string=} [options.params.content] - The markup to be used for the section container. If empty, a JS template is used. - * @param {boolean=true} [options.params.active] - Whether the section is active or not. - * @param {string} options.params.panel - The ID for the panel this section is associated with. - * @param {string=} [options.params.customizeAction] - Additional context information shown before the section title when expanded. + * @param {object} options - Options. + * @param {string} options.title - Title shown when section is collapsed and expanded. + * @param {string=} [options.description] - Description shown at the top of the section. + * @param {number=100} [options.priority] - The sort priority for the section. + * @param {string=default} [options.type] - The type of the section. See wp.customize.sectionConstructor. + * @param {string=} [options.content] - The markup to be used for the section container. If empty, a JS template is used. + * @param {boolean=true} [options.active] - Whether the section is active or not. + * @param {string} options.panel - The ID for the panel this section is associated with. + * @param {string=} [options.customizeAction] - Additional context information shown before the section title when expanded. + * @param {object} [options.params] - Deprecated wrapper for the above properties. */ initialize: function ( id, options ) { var section = this; @@ -1838,7 +1854,7 @@ section.container.find( '.no-themes' ).hide(); request = wp.ajax.post( 'customize_load_themes', params ); request.done(function( data ) { - var themes = data.themes, themeControl, newThemeControls; + var themes = data.themes, newThemeControls; // Stop and try again if the term changed while loading. if ( '' !== section.nextTerm || '' !== section.nextTags ) { @@ -1860,20 +1876,14 @@ // Add controls for each theme. _.each( themes, function( theme ) { - var customizeId = section.params.action + '_theme_' + theme.id; - themeControl = new api.controlConstructor.theme( customizeId, { - params: { - type: 'theme', - content: '
  • ', - section: section.params.id, - active: true, - theme: theme, - priority: section.loaded + 1 - }, - previewer: api.previewer + var themeControl = new api.controlConstructor.theme( section.params.action + '_theme_' + theme.id, { + type: 'theme', + section: section.params.id, + theme: theme, + priority: section.loaded + 1 } ); - api.control.add( customizeId, themeControl ); + api.control.add( themeControl ); newThemeControls.push( themeControl ); section.loaded = section.loaded + 1; }); @@ -2482,13 +2492,13 @@ * * @param {string} id - The ID for the panel. * @param {object} options - Object containing one property: params. - * @param {object} options.params - Object containing the following properties. - * @param {string} options.params.title - Title shown when panel is collapsed and expanded. - * @param {string=} [options.params.description] - Description shown at the top of the panel. - * @param {number=100} [options.params.priority] - The sort priority for the panel. - * @param {string=default} [options.params.type] - The type of the panel. See wp.customize.panelConstructor. - * @param {string=} [options.params.content] - The markup to be used for the panel container. If empty, a JS template is used. - * @param {boolean=true} [options.params.active] - Whether the panel is active or not. + * @param {string} options.title - Title shown when panel is collapsed and expanded. + * @param {string=} [options.description] - Description shown at the top of the panel. + * @param {number=100} [options.priority] - The sort priority for the panel. + * @param {string=default} [options.type] - The type of the panel. See wp.customize.panelConstructor. + * @param {string=} [options.content] - The markup to be used for the panel container. If empty, a JS template is used. + * @param {boolean=true} [options.active] - Whether the panel is active or not. + * @param {object} [options.params] - Deprecated wrapper for the above properties. */ initialize: function ( id, options ) { var panel = this; @@ -2856,7 +2866,7 @@ wp.updates.maybeRequestFilesystemCredentials( event ); $( document ).one( 'wp-theme-install-success', function( event, response ) { - var theme = false, customizeId, themeControl; + var theme = false, themeControl; if ( preview ) { api.notifications.remove( 'theme_installing' ); @@ -2877,21 +2887,15 @@ // Add theme control to installed section. theme.type = 'installed'; - customizeId = 'installed_theme_' + theme.id; - themeControl = new api.controlConstructor.theme( customizeId, { - params: { - type: 'theme', - content: $( '
  • ' ).attr( 'id', 'customize-control-theme-installed_' + theme.id ).prop( 'outerHTML' ), - section: 'installed_themes', - active: true, - theme: theme, - priority: 0 // Add all newly-installed themes to the top. - }, - previewer: api.previewer + themeControl = new api.controlConstructor.theme( 'installed_theme_' + theme.id, { + type: 'theme', + section: 'installed_themes', + theme: theme, + priority: 0 // Add all newly-installed themes to the top. } ); - api.control.add( customizeId, themeControl ); - api.control( customizeId ).container.trigger( 'render-screenshot' ); + api.control.add( themeControl ); + api.control( themeControl.id ).container.trigger( 'render-screenshot' ); // Close the details modal if it's open to the installed theme. api.section.each( function( section ) { @@ -2913,7 +2917,7 @@ if ( $( event.target ).hasClass( 'preview' ) ) { preview = true; - api.notifications.add( 'theme_installing', new api.OverlayNotification( 'theme_installing', { + api.notifications.add( new api.OverlayNotification( 'theme_installing', { message: api.l10n.themeDownloading, type: 'info', loading: true @@ -2950,7 +2954,7 @@ urlParser.search = $.param( queryParams ); // Update loading message. Everything else is handled by reloading the page. - api.notifications.add( 'theme_previewing', new api.OverlayNotification( 'theme_previewing', { + api.notifications.add( new api.OverlayNotification( 'theme_previewing', { message: api.l10n.themePreviewWait, type: 'info', loading: true @@ -3076,33 +3080,59 @@ * @class * @augments wp.customize.Class * - * @param {string} id Unique identifier for the control instance. - * @param {object} options Options hash for the control instance. - * @param {object} options.params - * @param {object} options.params.type Type of control (e.g. text, radio, dropdown-pages, etc.) - * @param {string} options.params.content The HTML content for the control. - * @param {string} options.params.priority Order of priority to show the control within the section. - * @param {string} options.params.active - * @param {string} options.params.section The ID of the section the control belongs to. - * @param {string} options.params.settings.default The ID of the setting the control relates to. - * @param {string} options.params.settings.data - * @param {string} options.params.label - * @param {string} options.params.description - * @param {string} options.params.instanceNumber Order in which this instance was created in relation to other instances. + * @param {string} id - Unique identifier for the control instance. + * @param {object} options - Options hash for the control instance. + * @param {object} options.type - Type of control (e.g. text, radio, dropdown-pages, etc.) + * @param {string} [options.content] - The HTML content for the control or at least its container. This should normally be left blank and instead supplying a templateId. + * @param {string} [options.templateId] - Template ID for control's content. + * @param {string} [options.priority=10] - Order of priority to show the control within the section. + * @param {string} [options.active=true] - Whether the control is active. + * @param {string} options.section - The ID of the section the control belongs to. + * @param {string} options.settings.default - The ID of the setting the control relates to. + * @param {string} options.settings.data + * @param {string} options.label - Label. + * @param {string} options.description - Description. + * @param {number} [options.instanceNumber] - Order in which this instance was created in relation to other instances. + * @param {object} [options.params] - Deprecated wrapper for the above properties. */ api.Control = api.Class.extend({ defaultActiveArguments: { duration: 'fast', completeCallback: $.noop }, + defaults: { + active: true, + priority: 10 + }, + initialize: function( id, options ) { var control = this, nodes, radios, settings; - control.params = {}; - $.extend( control, options || {} ); + control.params = _.extend( {}, control.defaults ); + + if ( ! api.Control.instanceCounter ) { + api.Control.instanceCounter = 0; + } + api.Control.instanceCounter++; + if ( ! control.params.instanceNumber ) { + control.params.instanceNumber = api.Control.instanceCounter; + } + + _.extend( control.params, options.params || options ); + if ( ! control.params.content ) { + control.params.content = $( '
  • ', { + id: 'customize-control-' + id.replace( /]/g, '' ).replace( /\[/g, '-' ), + 'class': 'customize-control customize-control-' + control.params.type + } ); + } + control.id = id; - control.selector = '#customize-control-' + id.replace( /\]/g, '' ).replace( /\[/g, '-' ); - control.templateSelector = 'customize-control-' + control.params.type + '-content'; - control.container = control.params.content ? $( control.params.content ) : $( control.selector ); + control.selector = '#customize-control-' + id.replace( /\]/g, '' ).replace( /\[/g, '-' ); // Deprecated, likely dead code from time before #28709. + control.templateSelector = control.params.templateId || 'customize-control-' + control.params.type + '-content'; + if ( control.params.content ) { + control.container = $( control.params.content ); + } else { + control.container = $( control.selector ); // Likely dead, per above. See #28709. + } control.deferred = { embedded: new $.Deferred() @@ -3180,17 +3210,14 @@ // Add setting notifications to the control notification. _.each( control.settings, function( setting ) { setting.notifications.bind( 'add', function( settingNotification ) { - var controlNotification, code, params; - code = setting.id + ':' + settingNotification.code; - params = _.extend( + var params = _.extend( {}, settingNotification, { setting: setting.id } ); - controlNotification = new api.Notification( code, params ); - control.notifications.add( controlNotification.code, controlNotification ); + control.notifications.add( new api.Notification( setting.id + ':' + settingNotification.code, params ) ); } ); setting.notifications.bind( 'remove', function( settingNotification ) { control.notifications.remove( setting.id + ':' + settingNotification.code ); @@ -3472,16 +3499,18 @@ */ _toggleActive: Container.prototype._toggleActive, + // @todo This function appears to be dead code and can be removed. dropdownInit: function() { var control = this, statuses = this.container.find('.dropdown-status'), params = this.params, toggleFreeze = false, update = function( to ) { - if ( typeof to === 'string' && params.statuses && params.statuses[ to ] ) + if ( 'string' === typeof to && params.statuses && params.statuses[ to ] ) { statuses.html( params.statuses[ to ] ).show(); - else + } else { statuses.hide(); + } }; // Support the .dropdown class to open/close complex elements @@ -3492,11 +3521,13 @@ event.preventDefault(); - if (!toggleFreeze) - control.container.toggleClass('open'); + if ( ! toggleFreeze ) { + control.container.toggleClass( 'open' ); + } - if ( control.container.hasClass('open') ) - control.container.parent().parent().find('li.library-selected').focus(); + if ( control.container.hasClass( 'open' ) ) { + control.container.parent().parent().find( 'li.library-selected' ).focus(); + } // Don't want to fire focus and click at same time toggleFreeze = true; @@ -4869,7 +4900,7 @@ } else { message = api.l10n.customCssError.plural.replace( '%d', String( errorAnnotations.length ) ); } - control.setting.notifications.add( 'csslint_error', new api.Notification( 'csslint_error', { + control.setting.notifications.add( new api.Notification( 'csslint_error', { message: message, type: 'error' } ) ); @@ -5256,7 +5287,7 @@ type: 'error', message: api.l10n.futureDateError } ); - control.notifications.add( notificationCode, notification ); + control.notifications.add( notification ); } else { control.notifications.remove( notificationCode ); } @@ -5275,17 +5306,9 @@ */ api.PreviewLinkControl = api.Control.extend({ - /** - * Override the templateSelector before embedding the control into the page. - * - * @since 4.9.0 - * @return {void} - */ - embed: function() { - var control = this; - control.templateSelector = 'customize-preview-link-control'; - return api.Control.prototype.embed.apply( control, arguments ); - }, + defaults: _.extend( {}, api.Control.prototype.defaults, { + templateId: 'customize-preview-link-control' + } ), /** * Initialize behaviors. @@ -5386,7 +5409,7 @@ type: 'info', message: api.l10n.saveBeforeShare } ); - control.notifications.add( notificationCode, notification ); + control.notifications.add( notification ); } else { control.notifications.remove( notificationCode ); } @@ -6014,8 +6037,9 @@ var previewer = this, deferred, messenger, iframe; - if ( this._login ) + if ( this._login ) { return this._login; + } deferred = $.Deferred(); this._login = deferred.promise(); @@ -6141,7 +6165,7 @@ } if ( ! setting.notifications.has( notification.code ) ) { - setting.notifications.add( code, notification ); + setting.notifications.add( notification ); } invalidSettings.push( setting.id ); } ); @@ -6331,46 +6355,27 @@ footerActions = $( '#customize-footer-actions' ); api.section( 'publish_settings', function( section ) { - var updateButtonsState, previewLinkControl, TrashControl, trashControlInstance, trashControlId = 'trash_changeset', previewLinkControlId = 'changeset_preview_link', updateSectionActive, isSectionActive; + var updateButtonsState, trashControl, updateSectionActive, isSectionActive; - TrashControl = api.Control.extend( { - - // This is a temporary hack while waiting for richer JS templating and dynamic instantiation. - embed: function() { - var control = this; - control.templateSelector = 'customize-trash-changeset-control'; - return api.Control.prototype.embed.apply( control, arguments ); - } + trashControl = new api.Control( 'trash_changeset', { + type: 'button', + section: section.id, + priority: 30, + templateId: 'customize-trash-changeset-control' } ); - - trashControlInstance = new TrashControl( trashControlId, { - params: { - type: 'button', - section: section.id, - active: true, - priority: 30, - content: '
  • ' - } - } ); - api.control.add( trashControlId, trashControlInstance ); - trashControlInstance.deferred.embedded.done( function() { - trashControlInstance.container.find( 'button' ).on( 'click', function() { + api.control.add( trashControl ); + trashControl.deferred.embedded.done( function() { + trashControl.container.find( 'button' ).on( 'click', function() { if ( confirm( api.l10n.trashConfirm ) ) { wp.customize.previewer.trash(); } } ); } ); - previewLinkControl = new api.PreviewLinkControl( previewLinkControlId, { - params: { - section: section.id, - active: true, - priority: 100, - content: '
  • ' - } - } ); - - api.control.add( previewLinkControlId, previewLinkControl ); + api.control.add( new api.PreviewLinkControl( 'changeset_preview_link', { + section: section.id, + priority: 100 + } ) ); /** * Return whether the pubish settings section should be active. @@ -6588,7 +6593,7 @@ api.unbind( 'change', captureSettingModifiedDuringSave ); if ( invalidSettings.length ) { - api.notifications.add( errorCode, new api.Notification( errorCode, { + api.notifications.add( new api.Notification( errorCode, { message: ( 1 === invalidSettings.length ? api.l10n.saveBlockedError.singular : api.l10n.saveBlockedError.plural ).replace( /%s/g, String( invalidSettings.length ) ), type: 'error', dismissible: true, @@ -6690,7 +6695,7 @@ } if ( notification ) { - api.notifications.add( notification.code, notification ); + api.notifications.add( notification ); } if ( response.setting_validities ) { @@ -6795,7 +6800,7 @@ customize_changeset_uuid: api.settings.changeset.uuid, nonce: api.settings.nonce.trash } ); - api.notifications.add( 'changeset_trashing', new api.OverlayNotification( 'changeset_trashing', { + api.notifications.add( new api.OverlayNotification( 'changeset_trashing', { type: 'info', message: api.l10n.revertingChanges, loading: true @@ -6823,7 +6828,7 @@ api.state( 'processing' ).set( api.state( 'processing' ).get() - 1 ); api.state( 'trashing' ).set( false ); api.notifications.remove( 'changeset_trashing' ); - api.notifications.add( notificationCode, new api.Notification( notificationCode, { + api.notifications.add( new api.Notification( notificationCode, { message: message || api.l10n.unknownError, dismissible: true, type: 'error' @@ -6891,49 +6896,30 @@ // Create Settings $.each( api.settings.settings, function( id, data ) { - var constructor = api.settingConstructor[ data.type ] || api.Setting, - setting; - - setting = new constructor( id, data.value, { + var Constructor = api.settingConstructor[ data.type ] || api.Setting; + api.add( new Constructor( id, data.value, { transport: data.transport, previewer: api.previewer, dirty: !! data.dirty - } ); - api.add( id, setting ); + } ) ); }); // Create Panels $.each( api.settings.panels, function ( id, data ) { - var constructor = api.panelConstructor[ data.type ] || api.Panel, - panel; - - panel = new constructor( id, { - params: data - } ); - api.panel.add( id, panel ); + var Constructor = api.panelConstructor[ data.type ] || api.Panel; + api.panel.add( new Constructor( id, data ) ); }); // Create Sections $.each( api.settings.sections, function ( id, data ) { - var constructor = api.sectionConstructor[ data.type ] || api.Section, - section; - - section = new constructor( id, { - params: data - } ); - api.section.add( id, section ); + var Constructor = api.sectionConstructor[ data.type ] || api.Section; + api.section.add( new Constructor( id, data ) ); }); // Create Controls $.each( api.settings.controls, function( id, data ) { - var constructor = api.controlConstructor[ data.type ] || api.Control, - control; - - control = new constructor( id, { - params: data, - previewer: api.previewer - } ); - api.control.add( id, control ); + var Constructor = api.controlConstructor[ data.type ] || api.Control; + api.control.add( new Constructor( id, data ) ); }); // Focus the autofocused element @@ -7240,7 +7226,7 @@ var code = 'autosave_available', onStateChange; // Since there is an autosave revision and the user hasn't loaded with autosaved, add notification to prompt to load autosaved version. - api.notifications.add( code, new api.Notification( code, { + api.notifications.add( new api.Notification( code, { message: api.l10n.autosaveNotice, type: 'warning', dismissible: true, @@ -7893,8 +7879,9 @@ control.element.set( 'blank' !== control.setting() ); control.element.bind( function( to ) { - if ( ! to ) + if ( ! to ) { last = api( 'header_textcolor' ).get(); + } control.setting.set( to ? last : 'blank' ); }); @@ -7926,7 +7913,7 @@ // Toggle notification when the homepage and posts page are both set and the same. if ( 'page' === showOnFront() && pageOnFrontId && pageForPostsId && pageOnFrontId === pageForPostsId ) { - showOnFront.notifications.add( errorCode, new api.Notification( errorCode, { + showOnFront.notifications.add( new api.Notification( errorCode, { type: 'error', message: api.l10n.pageOnFrontError } ) ); @@ -8077,7 +8064,7 @@ if ( headerVideoControl.active.get() ) { section.notifications.remove( noticeCode ); } else { - section.notifications.add( noticeCode, new api.Notification( noticeCode, { + section.notifications.add( new api.Notification( noticeCode, { type: 'info', message: api.l10n.videoHeaderNotice } ) ); diff --git a/wp-admin/js/customize-controls.min.js b/wp-admin/js/customize-controls.min.js index 0495135d4e..2d2ddc8110 100644 --- a/wp-admin/js/customize-controls.min.js +++ b/wp-admin/js/customize-controls.min.js @@ -1,4 +1,4 @@ -!function(a,b){var c,d,e,f=wp.customize;f.OverlayNotification=f.Notification.extend({loading:!1,initialize:function(a,b){var c=this;f.Notification.prototype.initialize.call(c,a,b),c.classes+=" notification-overlay",c.loading&&(c.classes+=" notification-loading")}}),f.Notifications=f.Values.extend({alt:!1,defaultConstructor:f.Notification,initialize:function(a){var b=this;f.Values.prototype.initialize.call(b,a),b._addedIncrement=0,b._addedOrder={},b.bind("add",function(a){b.trigger("change",a)}),b.bind("removed",function(a){b.trigger("change",a)})},count:function(){return _.size(this._value)},add:function(a,b){var c=this;return c.has(a)||(c._addedIncrement+=1,c._addedOrder[a]=c._addedIncrement),f.Values.prototype.add.call(this,a,b)},remove:function(a){var b=this;return delete b._addedOrder[a],f.Values.prototype.remove.call(this,a)},get:function(a){var b,c,d,e=this;return b=_.values(e._value),d=_.extend({sort:!1},a),d.sort&&(c={error:4,warning:3,success:2,info:1},b.sort(function(a,b){var d=0,f=0;return _.isUndefined(c[a.type])||(d=c[a.type]),_.isUndefined(c[b.type])||(f=c[b.type]),d!==f?f-d:e._addedOrder[b.code]-e._addedOrder[a.code]})),b},render:function(){var a,c,d,e=this,g=!1,h={};e.container&&e.container.length&&(a=e.get({sort:!0}),e.container.toggle(0!==a.length),e.container.is(e.previousContainer)&&_.isEqual(a,e.previousNotifications)||(d=e.container.children("ul").first(),d.length||(d=b(""),e.container.append(d)),d.find("> [data-code]").remove(),_.each(e.previousNotifications,function(a){h[a.code]=a}),_.each(a,function(a){var c;!wp.a11y||h[a.code]&&_.isEqual(a.message,h[a.code].message)||wp.a11y.speak(a.message,"assertive"),c=b(a.render()),d.append(c)}),c=Boolean(_.find(a,function(a){return a.extended(f.OverlayNotification)})),e.previousNotifications&&(g=Boolean(_.find(e.previousNotifications,function(a){return a.extended(f.OverlayNotification)}))),c!==g&&(b(document.body).toggleClass("customize-loading",c),e.container.toggleClass("has-overlay-notifications",c)),e.previousNotifications=a,e.previousContainer=e.container,e.trigger("rendered")))}}),f.Setting=f.Value.extend({initialize:function(a,b,c){var d=this;f.Value.prototype.initialize.call(d,b,c),d.id=a,d.transport=d.transport||"refresh",d._dirty=c.dirty||!1,d.notifications=new f.Values({defaultConstructor:f.Notification}),d.bind(d.preview)},preview:function(){var a,b=this;a=b.transport,"postMessage"!==a||f.state("previewerAlive").get()||(a="refresh"),"postMessage"===a?b.previewer.send("setting",[b.id,b()]):"refresh"===a&&b.previewer.refresh()},findControls:function(){var a=this,b=[];return f.control.each(function(c){_.each(c.settings,function(d){d.id===a.id&&b.push(c)})}),b}}),f._latestRevision=0,f._lastSavedRevision=0,f._latestSettingRevisions={},f.bind("change",function(a){f._latestRevision+=1,f._latestSettingRevisions[a.id]=f._latestRevision}),f.bind("ready",function(){f.bind("add",function(a){a._dirty&&(f._latestRevision+=1,f._latestSettingRevisions[a.id]=f._latestRevision)})}),f.dirtyValues=function(a){var b={};return f.each(function(c){var d;c._dirty&&(d=f._latestSettingRevisions[c.id],f.state("changesetStatus").get()&&a&&a.unsaved&&(_.isUndefined(d)||d<=f._lastSavedRevision)||(b[c.id]=c.get()))}),b},f.requestChangesetUpdate=function(a,c){var d,e,g,h,i={};return d=new b.Deferred,0!==f.state("processing").get()?(d.reject("already_processing"),d.promise()):(h=_.extend({title:null,date:null,autosave:!1,force:!1},c),a&&_.extend(i,a),_.each(f.dirtyValues({unsaved:!0}),function(b,c){a&&null===a[c]||(i[c]=_.extend({},i[c]||{},{value:b}))}),f.trigger("changeset-save",i,h),!h.force&&_.isEmpty(i)&&null===h.title&&null===h.date?(d.resolve({}),d.promise()):h.status?d.reject({code:"illegal_status_in_changeset_update"}).promise():h.date&&h.autosave?d.reject({code:"illegal_autosave_with_date_gmt"}).promise():(f.state("processing").set(f.state("processing").get()+1),d.always(function(){f.state("processing").set(f.state("processing").get()-1)}),g=f.previewer.query({excludeCustomizedSaved:!0}),delete g.customized,_.extend(g,{nonce:f.settings.nonce.save,customize_theme:f.settings.theme.stylesheet,customize_changeset_data:JSON.stringify(i)}),null!==h.title&&(g.customize_changeset_title=h.title),null!==h.date&&(g.customize_changeset_date=h.date),!1!==h.autosave&&(g.customize_changeset_autosave="true"),e=wp.ajax.post("customize_save",g),e.done(function(a){var b={};f._lastSavedRevision=Math.max(f._latestRevision,f._lastSavedRevision),f.state("changesetStatus").set(a.changeset_status),a.changeset_date&&f.state("changesetDate").set(a.changeset_date),d.resolve(a),f.trigger("changeset-saved",a),a.setting_validities&&_.each(a.setting_validities,function(a,c){!0===a&&_.isObject(i[c])&&!_.isUndefined(i[c].value)&&(b[c]=i[c].value)}),f.previewer.send("changeset-saved",_.extend({},a,{saved_changeset_values:b}))}),e.fail(function(a){d.reject(a),f.trigger("changeset-error",a)}),e.always(function(a){a.setting_validities&&f._handleSettingValidities({settingValidities:a.setting_validities})}),d.promise()))},f.utils.bubbleChildValueChanges=function(a,c){b.each(c,function(b,c){a[c].bind(function(b,c){a.parent&&b!==c&&a.parent.trigger("change",a)})})},d=function(a){var b,c,d,e;b=this,a=a||{},d=function(){var a;a=(b.extended(f.Panel)||b.extended(f.Section))&&b.expanded&&b.expanded()?b.contentContainer:b.container,e=a.find(".control-focus:first"),0===e.length&&(e=a.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first()),e.focus()},a.completeCallback?(c=a.completeCallback,a.completeCallback=function(){d(),c()}):a.completeCallback=d,f.state("paneVisible").set(!0),b.expand?b.expand(a):a.completeCallback()},f.utils.prioritySort=function(a,b){return a.priority()===b.priority()&&"number"==typeof a.params.instanceNumber&&"number"==typeof b.params.instanceNumber?a.params.instanceNumber-b.params.instanceNumber:a.priority()-b.priority()},f.utils.isKeydownButNotEnterEvent=function(a){return"keydown"===a.type&&13!==a.which},f.utils.areElementListsEqual=function(a,c){var d=a.length===c.length&&-1===_.indexOf(_.map(_.zip(a,c),function(a){return b(a[0]).is(a[1])}),!1);return d},f.utils.getCurrentTimestamp=function(){var a,b,c;return b=_.now(),a=new Date(f.settings.initialServerDate.replace(/-/g,"/")),c=b-f.settings.initialClientTimestamp,c+=f.settings.initialClientTimestamp-f.settings.initialServerTimestamp,a.setTime(a.getTime()+c),a.getTime()},f.utils.getRemainingTime=function(a){var b,c,d=1e3;return c=a instanceof Date?a.getTime():"string"==typeof a?new Date(a.replace(/-/g,"/")).getTime():a,b=c-f.utils.getCurrentTimestamp(),b=Math.ceil(b/d)},e=function(){var a,b,c;return a=document.createElement("div"),b={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},c=_.find(_.keys(b),function(b){return!_.isUndefined(a.style[b])}),c?b[c]:null}(),c=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:b.noop},defaultExpandedArguments:{duration:"fast",completeCallback:b.noop},containerType:"container",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null},initialize:function(a,c){var d=this;d.id=a,c=c||{},c.params=_.defaults(c.params||{},d.defaults),b.extend(d,c),d.notifications=new f.Notifications,d.templateSelector="customize-"+d.containerType+"-"+d.params.type,d.container=b(d.params.content),0===d.container.length&&(d.container=b(d.getContainer())),d.headContainer=d.container,d.contentContainer=d.getContent(),d.container=d.container.add(d.contentContainer),d.deferred={embedded:new b.Deferred},d.priority=new f.Value,d.active=new f.Value,d.activeArgumentsQueue=[],d.expanded=new f.Value,d.expandedArgumentsQueue=[],d.active.bind(function(a){var c=d.activeArgumentsQueue.shift();c=b.extend({},d.defaultActiveArguments,c),a=a&&d.isContextuallyActive(),d.onChangeActive(a,c)}),d.expanded.bind(function(a){var c=d.expandedArgumentsQueue.shift();c=b.extend({},d.defaultExpandedArguments,c),d.onChangeExpanded(a,c)}),d.deferred.embedded.done(function(){d.setupNotifications(),d.attachEvents()}),f.utils.bubbleChildValueChanges(d,["priority","active"]),d.priority.set(d.params.priority),d.active.set(d.params.active),d.expanded.set(!1)},getNotificationsContainerElement:function(){var a=this;return a.contentContainer.find(".customize-control-notifications-container:first")},setupNotifications:function(){var a,b=this;b.notifications.container=b.getNotificationsContainerElement(),a=function(){b.expanded.get()&&b.notifications.render()},b.expanded.bind(a),a(),b.notifications.bind("change",_.debounce(a))},ready:function(){},_children:function(a,b){var c=this,d=[];return f[b].each(function(b){b[a].get()===c.id&&d.push(b)}),d.sort(f.utils.prioritySort),d},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(a,c){var d,e,g=this,h=g.headContainer;return c.unchanged?void(c.completeCallback&&c.completeCallback()):(d="resolved"===f.previewer.deferred.active.state()?c.duration:0,g.extended(f.Panel)&&(f.panel.each(function(a){a!==g&&a.expanded()&&(e=a,d=0)}),a||_.each(g.sections(),function(a){a.collapse({duration:0})})),void(b.contains(document,h.get(0))?a?h.slideDown(d,c.completeCallback):g.expanded()?g.collapse({duration:d,completeCallback:function(){h.slideUp(d,c.completeCallback)}}):h.slideUp(d,c.completeCallback):(h.toggle(a),c.completeCallback&&c.completeCallback())))},_toggleActive:function(a,b){var c=this;return b=b||{},a&&this.active.get()||!a&&!this.active.get()?(b.unchanged=!0,c.onChangeActive(c.active.get(),b),!1):(b.unchanged=!1,this.activeArgumentsQueue.push(b),this.active.set(a),!0)},activate:function(a){return this._toggleActive(!0,a)},deactivate:function(a){return this._toggleActive(!1,a)},onChangeExpanded:function(){throw new Error("Must override with subclass.")},_toggleExpanded:function(a,b){var c,d=this;return b=b||{},c=b.completeCallback,!(a&&!d.active())&&(f.state("paneVisible").set(!0),b.completeCallback=function(){c&&c.apply(d,arguments),a?d.container.trigger("expanded"):d.container.trigger("collapsed")},a&&d.expanded.get()||!a&&!d.expanded.get()?(b.unchanged=!0,d.onChangeExpanded(d.expanded.get(),b),!1):(b.unchanged=!1,d.expandedArgumentsQueue.push(b),d.expanded.set(a),!0))},expand:function(a){return this._toggleExpanded(!0,a)},collapse:function(a){return this._toggleExpanded(!1,a)},_animateChangeExpanded:function(a){if(!e)return void(a&&a());var c,d,g,h=this,i=h.contentContainer,j=i.closest(".wp-full-overlay");c=j.add(i),g=!h.panel||""===h.panel()||!!f.panel(h.panel()).contentContainer.hasClass("skip-transition"),g&&(c=c.add("#customize-info, .customize-pane-parent")),d=function(f){2===f.eventPhase&&b(f.target).is(i)&&(i.off(e,d),c.removeClass("busy"),a&&a())},i.on(e,d),c.addClass("busy"),_.defer(function(){var a=i.closest(".wp-full-overlay-sidebar-content"),b=a.scrollTop(),c=i.data("previous-scrollTop")||0,d=h.expanded();d&&0"},getContent:function(){var a=this,b=a.container,c=b.find(".accordion-section-content, .control-panel-content").first(),d="sub-"+b.attr("id"),e=d,f=b.attr("aria-owns");return f&&(e=e+" "+f),b.attr("aria-owns",e),c.detach().attr({id:d,"class":"customize-pane-child "+c.attr("class")+" "+b.attr("class")})}}),f.Section=c.extend({containerType:"section",containerParent:"#customize-theme-controls",containerPaneParent:".customize-pane-parent",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null,panel:null,customizeAction:""},initialize:function(a,d){var e=this;c.prototype.initialize.call(e,a,d),e.id=a,e.panel=new f.Value,e.panel.bind(function(a){b(e.headContainer).toggleClass("control-subsection",!!a)}),e.panel.set(e.params.panel||""),f.utils.bubbleChildValueChanges(e,["panel"]),e.embed(),e.deferred.embedded.done(function(){e.ready()})},embed:function(){var a,b=this;b.containerParent=f.ensure(b.containerParent),a=function(a){var c;a?f.panel(a,function(a){a.deferred.embedded.done(function(){c=a.contentContainer,b.headContainer.parent().is(c)||c.append(b.headContainer),b.contentContainer.parent().is(b.headContainer)||b.containerParent.append(b.contentContainer),b.deferred.embedded.resolve()})}):(c=f.ensure(b.containerPaneParent),b.headContainer.parent().is(c)||c.append(b.headContainer),b.contentContainer.parent().is(b.headContainer)||b.containerParent.append(b.contentContainer),b.deferred.embedded.resolve())},b.panel.bind(a),a(b.panel.get())},attachEvents:function(){var a,c,d=this;d.container.hasClass("cannot-expand")||(d.container.find(".accordion-section-title, .customize-section-back").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),d.expanded()?d.collapse():d.expand())}),d.container.find(".customize-section-title .customize-help-toggle").on("click",function(){a=d.container.find(".section-meta"),a.hasClass("cannot-expand")||(c=a.find(".customize-section-description:first"),c.toggleClass("open"),c.slideToggle(d.defaultExpandedArguments.duration,function(){c.trigger("toggled")}),b(this).attr("aria-expanded",function(a,b){return"true"===b?"false":"true"}))}))},isContextuallyActive:function(){var a=this,b=a.controls(),c=0;return _(b).each(function(a){a.active()&&(c+=1)}),0!==c},controls:function(){return this._children("section","control")},onChangeExpanded:function(a,c){var d,e,g=this,h=g.headContainer.closest(".wp-full-overlay-sidebar-content"),i=g.contentContainer,j=g.headContainer.closest(".wp-full-overlay"),k=i.find(".customize-section-back"),l=g.headContainer.find(".accordion-section-title").first();a&&!i.hasClass("open")?(d=c.unchanged?c.completeCallback:b.proxy(function(){g._animateChangeExpanded(function(){l.attr("tabindex","-1"),k.attr("tabindex","0"),k.focus(),i.css("top",""),h.scrollTop(0),c.completeCallback&&c.completeCallback()}),i.addClass("open"),j.addClass("section-open"),f.state("expandedSection").set(g)},this),c.allowMultiple||f.section.each(function(a){a!==g&&a.collapse({duration:c.duration})}),g.panel()?f.panel(g.panel()).expand({duration:c.duration,completeCallback:d}):(c.allowMultiple||f.panel.each(function(a){a.collapse()}),d())):!a&&i.hasClass("open")?(g.panel()&&(e=f.panel(g.panel()),e.contentContainer.hasClass("skip-transition")&&e.collapse()),g._animateChangeExpanded(function(){k.attr("tabindex","-1"),l.attr("tabindex","0"),l.focus(),i.css("top",""),c.completeCallback&&c.completeCallback()}),i.removeClass("open"),j.removeClass("section-open"),g===f.state("expandedSection").get()&&f.state("expandedSection").set(!1)):c.completeCallback&&c.completeCallback()}}),f.ThemesSection=f.Section.extend({currentTheme:"",overlay:"",template:"",screenshotQueue:null,$window:null,$body:null,loaded:0,loading:!1,fullyLoaded:!1,term:"",tags:"",nextTerm:"",nextTags:"",filtersHeight:0,headerContainer:null,initialize:function(a,c){var d=this;d.headerContainer=b(),d.$window=b(window),d.$body=b(document.body),f.Section.prototype.initialize.call(d,a,c)},embed:function(){var a,b=this;a=function(a){var c;f.panel(a,function(a){a.deferred.embedded.done(function(){c=a.contentContainer,b.headContainer.parent().is(c)||c.find(".customize-themes-full-container-container").before(b.headContainer),b.contentContainer.parent().is(b.headContainer)||b.containerParent.append(b.contentContainer),b.deferred.embedded.resolve()})})},b.panel.bind(a),a(b.panel.get())},ready:function(){var a=this;a.overlay=a.container.find(".theme-overlay"),a.template=wp.template("customize-themes-details-view"),a.container.on("keydown",function(b){a.overlay.find(".theme-wrap").is(":visible")&&(39===b.keyCode&&a.nextTheme(),37===b.keyCode&&a.previousTheme(),27===b.keyCode&&(a.$body.hasClass("modal-open")?a.closeDetails():a.headerContainer.find(".customize-themes-section-title").focus(),b.stopPropagation()))}),a.renderScreenshots=_.throttle(a.renderScreenshots,100),_.bindAll(a,"renderScreenshots","loadMore","checkTerm","filtersChecked")},isContextuallyActive:function(){return this.active()},attachEvents:function(){var a,c=this;c.container.find(".customize-section-back").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),c.collapse())}),c.headerContainer=b("#accordion-section-"+c.id),c.headerContainer.on("click",".customize-themes-section-title",function(){c.headerContainer.find(".filter-details").length&&(c.headerContainer.find(".customize-themes-section-title").toggleClass("details-open").attr("aria-expanded",function(a,b){return"true"===b?"false":"true"}),c.headerContainer.find(".filter-details").slideToggle(180)),c.expanded()||c.expand()}),c.container.on("click",".theme-actions .preview-theme",function(){f.panel("themes").loadThemePreview(b(this).data("slug"))}),c.container.on("click",".left",function(){c.previousTheme()}),c.container.on("click",".right",function(){c.nextTheme()}),c.container.on("click",".theme-backdrop, .close",function(){c.closeDetails()}),c.container.on("input",".wp-filter-search-themes",function(a){c.filterSearch(a.currentTarget)}),"wporg"===c.params.action&&(a=_.debounce(c.checkTerm,500),c.contentContainer.on("input",".wp-filter-search",function(){a(c),c.expanded()||c.expand(),c.checkTerm(c)}),c.contentContainer.on("click",".filter-group input",function(){c.filtersChecked(),c.checkTerm(c)}),c.contentContainer.on("click",".feature-filter-toggle",function(a){b(a.currentTarget).toggleClass("open").attr("aria-expanded",function(a,b){return"true"===b?"false":"true"}).next(".filter-drawer").slideToggle(180,"linear",function(){0===c.filtersHeight&&(c.filtersHeight=b(this).height(),c.contentContainer.find(".themes").css("margin-top",c.filtersHeight+76))}),b(a.currentTarget).hasClass("open")?c.contentContainer.find(".themes").css("margin-top",c.filtersHeight+76):c.contentContainer.find(".themes").css("margin-top",0)})),c.contentContainer.on("click",".no-themes-local .search-dotorg-themes",function(){f.section("wporg_themes").focus()}),f.bind("ready",function(){c.contentContainer=c.container.find(".customize-themes-section"),c.contentContainer.appendTo(b(".customize-themes-full-container")),c.container.add(c.headerContainer)})},onChangeExpanded:function(a,b){var c=this,d=c.contentContainer.closest(".customize-themes-full-container");return b.unchanged?void(b.completeCallback&&b.completeCallback()):void(a?(0===c.loaded&&c.loadControls(),f.section.each(function(a){var d;a!==c&&("themes"===a.params.type&&(d=a.contentContainer.find(".wp-filter-search").val(),c.contentContainer.find(".wp-filter-search").val(d),""===d&&""!==c.term&&"installed"!==c.params.action?(c.term="",c.initializeNewQuery(c.term,c.tags)):c.checkTerm(c),c.filterSearch(c.contentContainer.find(".wp-filter-search").get(0))),a.collapse({duration:b.duration}))}),c.contentContainer.addClass("current-section"),d.scrollTop(),c.headerContainer.find(".customize-themes-section-title").addClass("selected").attr("aria-expanded","true"),d.on("scroll",_.throttle(c.renderScreenshots,300)),d.on("scroll",_.throttle(c.loadMore,300)),b.completeCallback&&b.completeCallback(),c.updateCount()):(c.contentContainer.removeClass("current-section"),c.headerContainer.find(".customize-themes-section-title").removeClass("selected details-open").attr("aria-expanded","false"),c.headerContainer.find(".filter-details").slideUp(180),d.off("scroll"),b.completeCallback&&b.completeCallback()))},getContent:function(){return this.container.find(".control-section-content")},loadControls:function(){var a,b,c,d=this;d.loading||(b=Math.ceil(d.loaded/100)+1,a={nonce:f.settings.nonce.switch_themes,wp_customize:"on",theme_action:d.params.action,customized_theme:f.settings.theme.stylesheet,page:b},"wporg"===d.params.action&&(a.search=d.term,a.tags=d.tags),d.headContainer.closest(".wp-full-overlay").addClass("loading"),d.loading=!0,d.container.find(".no-themes").hide(),c=wp.ajax.post("customize_load_themes",a),c.done(function(a){var c,e,g=a.themes;return""!==d.nextTerm||""!==d.nextTags?(d.nextTerm&&(d.term=d.nextTerm),d.nextTags&&(d.tags=d.nextTags),d.nextTerm="",d.nextTags="",d.loading=!1,void d.loadControls()):(0!==g.length?(e=[],_.each(g,function(a){var b=d.params.action+"_theme_"+a.id;c=new f.controlConstructor.theme(b,{params:{type:"theme",content:'
  • ',section:d.params.id,active:!0,theme:a,priority:d.loaded+1},previewer:f.previewer}),f.control.add(b,c),e.push(c),d.loaded=d.loaded+1}),1===b?(_.each(d.controls().slice(0,3),function(a){var b,c=a.params.theme.screenshot[0];c&&(b=new Image,b.src=c)}),"installed"!==d.params.action&&wp.a11y.speak(f.settings.l10n.themeSearchResults.replace("%d",a.info.results))):Array.prototype.push.apply(d.screenshotQueue,e),_.delay(d.renderScreenshots,100),("installed"===d.params.action||100>g.length)&&(d.fullyLoaded=!0)):0===d.loaded?(d.container.find(".no-themes").show(),wp.a11y.speak(d.container.find(".no-themes").text())):d.fullyLoaded=!0,"installed"===d.params.action?d.updateCount():d.updateCount(a.info.results),d.container.find(".unexpected-error").hide(),d.headContainer.closest(".wp-full-overlay").removeClass("loading"),void(d.loading=!1))}),c.fail(function(a){"undefined"==typeof a?(d.container.find(".unexpected-error").show(),wp.a11y.speak(d.container.find(".unexpected-error").text())):"undefined"!=typeof console&&console.error&&console.error(a),d.headContainer.closest(".wp-full-overlay").removeClass("loading"),d.loading=!1}))},loadMore:function(){var a,b,c,d=this;d.fullyLoaded||d.loading||(a=d.container.closest(".customize-themes-full-container"),b=a.scrollTop()+a.height(),c=a.prop("scrollHeight")-3e3,b>c&&d.loadControls())},filterSearch:function(a){var b=0,c=!1,d=this,e=void 0!==f.section("wporg_themes")&&"wporg"!==d.params.action?".no-themes-local":".no-themes",g=a.value.toLowerCase().trim().replace("-"," "),h=d.controls();d.loading||(_.each(h,function(a){c=a.filter(g),c&&(b+=1)}),0===b?(d.container.find(e).show(),wp.a11y.speak(d.container.find(e).text())):d.container.find(e).hide(),d.renderScreenshots(),d.updateCount(b))},checkTerm:function(a){var b;"wporg"===a.params.action&&(b=a.contentContainer.find(".wp-filter-search").val(),a.term!==b&&a.initializeNewQuery(b,a.tags))},filtersChecked:function(){var a=this,c=a.container.find(".filter-group").find(":checkbox"),d=[];_.each(c.filter(":checked"),function(a){d.push(b(a).prop("value"))}),0===d.length?(d="",a.contentContainer.find(".feature-filter-toggle .filter-count-0").show(),a.contentContainer.find(".feature-filter-toggle .filter-count-filters").hide()):(a.contentContainer.find(".feature-filter-toggle .theme-filter-count").text(d.length),a.contentContainer.find(".feature-filter-toggle .filter-count-0").hide(),a.contentContainer.find(".feature-filter-toggle .filter-count-filters").show()),_.isEqual(a.tags,d)||(a.loading?a.nextTags=d:a.initializeNewQuery(a.term,d))},initializeNewQuery:function(a,b){var c=this;_.each(c.controls(),function(a){a.container.remove(),f.control.remove(a.id)}),c.loaded=0,c.fullyLoaded=!1,c.screenshotQueue=null,c.loading?(c.nextTerm=a,c.nextTags=b):(c.term=a,c.tags=b,c.loadControls()),c.expanded()||c.expand()},renderScreenshots:function(){var a=this;null!==a.screenshotQueue&&0!==a.screenshotQueue.length||(a.screenshotQueue=_.filter(a.controls(),function(a){return!a.screenshotRendered})),a.screenshotQueue.length&&(a.screenshotQueue=_.filter(a.screenshotQueue,function(b){var c=b.container.find(".theme-screenshot"),d=c.find("img");if(!d.length)return!1;if(d.is(":hidden"))return!0;var e=a.$window.scrollTop(),f=e+a.$window.height(),g=d.offset().top,h=c.height(),i=g+h,j=3*h,k=i>=e-j&&g<=f+j;return k&&b.container.trigger("render-screenshot"),!k}))},getVisibleCount:function(){return this.contentContainer.find("li.customize-control:visible").length},updateCount:function(a){var b,c,d=this;a||0===a||(a=d.getVisibleCount()),c=d.contentContainer.find(".themes-displayed"),b=d.contentContainer.find(".theme-count"),0===a?b.text("0"):(c.fadeOut(180,function(){b.text(a),c.fadeIn(180)}),wp.a11y.speak(f.settings.l10n.announceThemeCount.replace("%d",a)))},nextTheme:function(){var a=this;a.getNextTheme()&&a.showDetails(a.getNextTheme(),function(){a.overlay.find(".right").focus()})},getNextTheme:function(){var a,b,c=this;return a=f.control(c.params.action+"_theme_"+this.currentTheme),b=a.container.next("li.customize-control-theme"),!!b.length&&(b=b[0].id.replace("customize-control-theme-"+c.params.action,c.params.action+"_theme"),a=f.control(b),a.params.theme)},previousTheme:function(){var a=this;a.getPreviousTheme()&&a.showDetails(a.getPreviousTheme(),function(){a.overlay.find(".left").focus()})},getPreviousTheme:function(){var a,b,c=this;return a=f.control(c.params.action+"_theme_"+this.currentTheme),b=a.container.prev("li.customize-control-theme"),!!b.length&&(b=b[0].id.replace("customize-control-theme-"+c.params.action,c.params.action+"_theme"),a=f.control(b),a.params.theme)},updateLimits:function(){this.getNextTheme()||this.overlay.find(".right").addClass("disabled"),this.getPreviousTheme()||this.overlay.find(".left").addClass("disabled")},loadThemePreview:function(a){return f.ThemesPanel.prototype.loadThemePreview.call(this,a)},showDetails:function(a,b){var c=this;c.currentTheme=a.id,c.overlay.html(c.template(a)).fadeIn("fast").focus(),c.$body.addClass("modal-open"),c.containFocus(c.overlay),c.updateLimits(),wp.a11y.speak(f.settings.l10n.announceThemeDetails.replace("%s",a.name)),b&&b()},closeDetails:function(){var a=this;a.$body.removeClass("modal-open"),a.overlay.fadeOut("fast"),f.control(a.params.action+"_theme_"+a.currentTheme).container.find(".theme").focus()},containFocus:function(a){var c;a.on("keydown",function(d){if(9===d.keyCode)return c=b(":tabbable",a),c.last()[0]!==d.target||d.shiftKey?c.first()[0]===d.target&&d.shiftKey?(c.last().focus(),!1):void 0:(c.first().focus(),!1)})}}),f.OuterSection=f.Section.extend({initialize:function(){var a=this;a.containerParent="#customize-outer-theme-controls",a.containerPaneParent=".customize-outer-pane-parent",f.Section.prototype.initialize.apply(a,arguments)},onChangeExpanded:function(a,c){var d,e,g=this,h=g.headContainer.closest(".wp-full-overlay-sidebar-content"),i=g.contentContainer,j=i.find(".customize-section-back"),k=g.headContainer.find(".accordion-section-title").first(),l=b(document.body);l.toggleClass("outer-section-open",a),g.container.toggleClass("open",a),g.container.removeClass("busy"),f.section.each(function(a){"outer"===a.params.type&&a.id!==g.id&&a.container.removeClass("open")}),a&&!i.hasClass("open")?(d=c.unchanged?c.completeCallback:b.proxy(function(){g._animateChangeExpanded(function(){k.attr("tabindex","-1"),j.attr("tabindex","0"),j.focus(),i.css("top",""),h.scrollTop(0),c.completeCallback&&c.completeCallback()}),i.addClass("open")},this),g.panel()?f.panel(g.panel()).expand({duration:c.duration,completeCallback:d}):d()):!a&&i.hasClass("open")?(g.panel()&&(e=f.panel(g.panel()),e.contentContainer.hasClass("skip-transition")&&e.collapse()),g._animateChangeExpanded(function(){j.attr("tabindex","-1"),k.attr("tabindex","0"),k.focus(),i.css("top",""),c.completeCallback&&c.completeCallback()}),i.removeClass("open")):c.completeCallback&&c.completeCallback()}}),f.Panel=c.extend({containerType:"panel",initialize:function(a,b){var d=this;c.prototype.initialize.call(d,a,b),d.embed(),d.deferred.embedded.done(function(){d.ready()})},embed:function(){var a=this,c=b("#customize-theme-controls"),d=b(".customize-pane-parent");a.headContainer.parent().is(d)||d.append(a.headContainer),a.contentContainer.parent().is(a.headContainer)||c.append(a.contentContainer),a.renderContent(),a.deferred.embedded.resolve()},attachEvents:function(){var a,c=this;c.headContainer.find(".accordion-section-title").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),c.expanded()||c.expand())}),c.container.find(".customize-panel-back").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),c.expanded()&&c.collapse())}),a=c.container.find(".panel-meta:first"),a.find("> .accordion-section-title .customize-help-toggle").on("click",function(){if(!a.hasClass("cannot-expand")){var d=a.find(".customize-panel-description:first");a.hasClass("open")?(a.toggleClass("open"),d.slideUp(c.defaultExpandedArguments.duration,function(){d.trigger("toggled")}),b(this).attr("aria-expanded",!1)):(d.slideDown(c.defaultExpandedArguments.duration,function(){d.trigger("toggled")}),a.toggleClass("open"),b(this).attr("aria-expanded",!0))}})},sections:function(){return this._children("panel","section")},isContextuallyActive:function(){var a=this,b=a.sections(),c=0;return _(b).each(function(a){a.active()&&a.isContextuallyActive()&&(c+=1)}),0!==c},onChangeExpanded:function(a,b){if(b.unchanged)return void(b.completeCallback&&b.completeCallback());var c,d=this,e=d.contentContainer,g=e.closest(".wp-full-overlay"),h=e.closest(".wp-full-overlay-sidebar-content"),i=d.headContainer.find(".accordion-section-title"),j=e.find(".customize-panel-back"),k=d.sections();a&&!e.hasClass("current-panel")?(f.section.each(function(a){d.id!==a.panel()&&a.collapse({duration:0})}),f.panel.each(function(a){d!==a&&a.collapse({duration:0})}),d.params.autoExpandSoleSection&&1===k.length&&k[0].active.get()?(e.addClass("current-panel skip-transition"),g.addClass("in-sub-panel"),k[0].expand({completeCallback:b.completeCallback})):(d._animateChangeExpanded(function(){i.attr("tabindex","-1"),j.attr("tabindex","0"),j.focus(),e.css("top",""),h.scrollTop(0),b.completeCallback&&b.completeCallback()}),e.addClass("current-panel"),g.addClass("in-sub-panel")),f.state("expandedPanel").set(d)):!a&&e.hasClass("current-panel")&&(c=e.hasClass("skip-transition"),c?e.removeClass("skip-transition"):d._animateChangeExpanded(function(){i.attr("tabindex","0"),j.attr("tabindex","-1"),i.focus(),e.css("top",""),b.completeCallback&&b.completeCallback()}),g.removeClass("in-sub-panel"),e.removeClass("current-panel"),d===f.state("expandedPanel").get()&&f.state("expandedPanel").set(!1))},renderContent:function(){var a,c=this;a=0!==b("#tmpl-"+c.templateSelector+"-content").length?wp.template(c.templateSelector+"-content"):wp.template("customize-panel-default-content"),a&&c.headContainer&&c.contentContainer.html(a(c.params))}}),f.ThemesPanel=f.Panel.extend({initialize:function(a,b){var c=this;c.installingThemes=[],f.Panel.prototype.initialize.call(c,a,b)},attachEvents:function(){var a=this;f.Panel.prototype.attachEvents.apply(a),a.contentContainer.on("click",".customize-theme",function(){a.collapse()}),a.contentContainer.on("click",".customize-themes-section-title, .customize-themes-mobile-back",function(){b(".wp-full-overlay").toggleClass("showing-themes")}),a.contentContainer.on("click",".theme-install",function(b){a.installTheme(b)}),a.contentContainer.on("click",".update-theme, #update-theme",function(b){b.preventDefault(),b.stopPropagation(),a.updateTheme(b)}),a.contentContainer.on("click",".delete-theme",function(b){a.deleteTheme(b)}),_.bindAll(a,"installTheme","updateTheme")},onChangeExpanded:function(a,b){var c,d=this;return f.Panel.prototype.onChangeExpanded.apply(this,[a,b]),b.unchanged?void(b.completeCallback&&b.completeCallback()):(c=d.headContainer.closest(".wp-full-overlay"),void(a?(c.addClass("in-themes-panel").delay(200).find(".customize-themes-full-container").addClass("animate"),600').attr("id","customize-control-theme-installed_"+j.id).prop("outerHTML"),section:"installed_themes",active:!0,theme:j,priority:0},previewer:f.previewer}),f.control.add(h,i),f.control(h).container.trigger("render-screenshot"),f.section.each(function(a){"themes"===a.params.type&&j.id===a.currentTheme&&a.closeDetails()})}}),c.installingThemes.push(b(a.target).data("slug")),wp.updates.installTheme({slug:e}),b(a.target).hasClass("preview")&&(d=!0,f.notifications.add("theme_installing",new f.OverlayNotification("theme_installing",{message:f.l10n.themeDownloading,type:"info",loading:!0}))))},loadThemePreview:function(a){var c,d,e,g=b.Deferred();return d=document.createElement("a"),d.href=location.href,e=_.extend(f.utils.parseQueryString(d.search.substr(1)),{theme:a,changeset_uuid:f.settings.changeset.uuid}),f.state("saved").get()||(e.customize_autosaved="on"),d.search=b.param(e),f.notifications.add("theme_previewing",new f.OverlayNotification("theme_previewing",{message:f.l10n.themePreviewWait,type:"info",loading:!0})),c=function(){var a;f.state("processing").get()>0||(f.state("processing").unbind(c),a=f.requestChangesetUpdate({},{autosave:!0}),a.done(function(){g.resolve(),b(window).off("beforeunload.customize-confirm"),window.location.href=d.href}),a.fail(function(){f.notifications.remove("theme_previewing"),g.reject()}))},0===f.state("processing").get()?c():f.state("processing").bind(c),g.promise()},updateTheme:function(a){wp.updates.maybeRequestFilesystemCredentials(a),b(document).one("wp-theme-update-success",function(a,b){f.control.each(function(a){"theme"===a.params.type&&a.params.theme.id===b.slug&&(a.params.theme.hasUpdate=!1,a.rerenderAsInstalled(!0))})}),wp.updates.updateTheme({slug:b(a.target).closest(".notice").data("slug")})},deleteTheme:function(a){var c,d;c=b(a.target).data("slug"),d=f.section("installed_themes"),a.preventDefault(),window.confirm(f.settings.l10n.confirmDeleteTheme)&&(wp.updates.maybeRequestFilesystemCredentials(a),b(document).one("wp-theme-delete-success",function(){var a=f.control("installed_theme_"+c);a.container.remove(),f.control.remove(a.id),d.loaded=d.loaded-1,d.updateCount(),f.control.each(function(a){"theme"===a.params.type&&a.params.theme.id===c&&a.rerenderAsInstalled(!1)})}),wp.updates.deleteTheme({slug:c}),d.closeDetails(),d.focus())}}),f.Control=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:b.noop},initialize:function(a,c){var d,e,g,h=this;h.params={},b.extend(h,c||{}),h.id=a,h.selector="#customize-control-"+a.replace(/\]/g,"").replace(/\[/g,"-"),h.templateSelector="customize-control-"+h.params.type+"-content",h.container=b(h.params.content?h.params.content:h.selector),h.deferred={embedded:new b.Deferred},h.section=new f.Value,h.priority=new f.Value,h.active=new f.Value,h.activeArgumentsQueue=[],h.notifications=new f.Notifications({alt:h.altNotice}),h.elements=[],d=h.container.find("[data-customize-setting-link]"),e={},d.each(function(){var a,c=b(this);if(c.is(":radio")){if(a=c.prop("name"),e[a])return;e[a]=!0,c=d.filter('[name="'+a+'"]')}f(c.data("customizeSettingLink"),function(a){var b=new f.Element(c);h.elements.push(b),b.sync(a),b.set(a())})}),h.active.bind(function(a){var c=h.activeArgumentsQueue.shift();c=b.extend({},h.defaultActiveArguments,c),h.onChangeActive(a,c)}),h.section.set(h.params.section),h.priority.set(isNaN(h.params.priority)?10:h.params.priority),h.active.set(h.params.active),f.utils.bubbleChildValueChanges(h,["section","priority","active"]),g=b.map(h.params.settings,function(a){return a}),0===g.length?(h.setting=null,h.settings={},h.embed()):f.apply(f,g.concat(function(){var a;h.settings={};for(a in h.params.settings)h.settings[a]=f(h.params.settings[a]);h.setting=h.settings["default"]||null,_.each(h.settings,function(a){a.notifications.bind("add",function(b){var c,d,e;d=a.id+":"+b.code,e=_.extend({},b,{setting:a.id}),c=new f.Notification(d,e),h.notifications.add(c.code,c)}),a.notifications.bind("remove",function(b){h.notifications.remove(a.id+":"+b.code)})}),h.embed()})),h.deferred.embedded.done(function(){h.setupNotifications(),h.ready()})},embed:function(){var a,b=this;a=function(a){var c;a&&f.section(a,function(a){a.deferred.embedded.done(function(){c=a.contentContainer.is("ul")?a.contentContainer:a.contentContainer.find("ul:first"),b.container.parent().is(c)||(c.append(b.container),b.renderContent()),b.deferred.embedded.resolve()})})},b.section.bind(a),a(b.section.get())},ready:function(){var a,c=this;"dropdown-pages"===c.params.type&&c.params.allow_addition&&(a=c.container.find(".new-content-item"),a.hide(),c.container.on("click",".add-new-toggle",function(c){b(c.currentTarget).slideUp(180),a.slideDown(180),a.find(".create-item-input").focus()}),c.container.on("click",".add-content",function(){c.addNewPage()}),c.container.on("keyup",".create-item-input",function(a){13===a.which&&c.addNewPage()}))},getNotificationsContainerElement:function(){var a,c,d=this;return c=d.container.find(".customize-control-notifications-container:first"),c.length?c:(c=b('
    '),d.container.hasClass("customize-control-nav_menu_item")?d.container.find(".menu-item-settings:first").prepend(c):d.container.hasClass("customize-control-widget_form")?d.container.find(".widget-inside:first").prepend(c):(a=d.container.find(".customize-control-title"),a.length?a.after(c):d.container.prepend(c)),c)},setupNotifications:function(){var a,b,c=this;c.notifications.container=c.getNotificationsContainerElement(),a=function(){var a=c.section();(!a||f.section.has(a)&&f.section(a).expanded())&&c.notifications.render()},c.notifications.bind("rendered",function(){var a=c.notifications.get();c.container.toggleClass("has-notifications",0!==a.length),c.container.toggleClass("has-error",0!==_.where(a,{type:"error"}).length)}),b=function(b,c){c&&f.section.has(c)&&f.section(c).expanded.unbind(a),b&&f.section(b,function(b){b.expanded.bind(a),a()})},c.section.bind(b),b(c.section.get()),c.notifications.bind("change",_.debounce(a))},renderNotifications:function(){var a,c,d=this,e=!1;"undefined"!=typeof console&&console.warn&&console.warn("[DEPRECATED] wp.customize.Control.prototype.renderNotifications() is deprecated in favor of instantating a wp.customize.Notifications and calling its render() method."),a=d.getNotificationsContainerElement(),a&&a.length&&(c=[],d.notifications.each(function(a){c.push(a),"error"===a.type&&(e=!0)}),0===c.length?a.stop().slideUp("fast"):a.stop().slideDown("fast",null,function(){b(this).css("height","auto")}),d.notificationsTemplate||(d.notificationsTemplate=wp.template("customize-control-notifications")),d.container.toggleClass("has-notifications",0!==c.length),d.container.toggleClass("has-error",e),a.empty().append(b.trim(d.notificationsTemplate({notifications:c,altNotice:Boolean(d.altNotice)}))))},expand:function(a){f.section(this.section()).expand(a)},focus:d,onChangeActive:function(a,c){return c.unchanged?void(c.completeCallback&&c.completeCallback()):void(b.contains(document,this.container[0])?a?this.container.slideDown(c.duration,c.completeCallback):this.container.slideUp(c.duration,c.completeCallback):(this.container.toggle(a),c.completeCallback&&c.completeCallback()))},toggle:function(a){return this.onChangeActive(a,this.defaultActiveArguments)},activate:c.prototype.activate,deactivate:c.prototype.deactivate,_toggleActive:c.prototype._toggleActive,dropdownInit:function(){var a=this,b=this.container.find(".dropdown-status"),c=this.params,d=!1,e=function(a){"string"==typeof a&&c.statuses&&c.statuses[a]?b.html(c.statuses[a]).show():b.hide()};this.container.on("click keydown",".dropdown",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),d||a.container.toggleClass("open"),a.container.hasClass("open")&&a.container.parent().parent().find("li.library-selected").focus(),d=!0,setTimeout(function(){d=!1},400))}),this.setting.bind(e),e(this.setting())},renderContent:function(){var a,c=this;0!==b("#tmpl-"+c.templateSelector).length&&(a=wp.template(c.templateSelector),a&&c.container&&c.container.html(a(c.params)))},addNewPage:function(){var a,c,d,e,g,h,i=this;if("dropdown-pages"===i.params.type&&i.params.allow_addition&&f.Menus){if(c=i.container.find(".add-new-toggle"),d=i.container.find(".new-content-item"),e=i.container.find(".create-item-input"),g=e.val(),h=i.container.find("select"),!g)return void e.addClass("invalid");e.removeClass("invalid"),e.attr("disabled","disabled"),a=f.Menus.insertAutoDraftPost({post_title:g,post_type:"page"}),a.done(function(a){var e,j,k;e=new f.Menus.AvailableItemModel({id:"post-"+a.post_id,title:g,type:"post_type",type_label:f.Menus.data.l10n.page_label,object:"page",object_id:a.post_id,url:a.url}),f.Menus.availableMenuItemsPanel.collection.add(e),j=b("#available-menu-items-post_type-page").find(".available-menu-items-list"),k=wp.template("available-menu-item"),j.prepend(k(e.attributes)),h.focus(),i.setting.set(String(a.post_id)),d.slideUp(180),c.slideDown(180)}),a.always(function(){e.val("").removeAttr("disabled")})}}}),f.ColorControl=f.Control.extend({ready:function(){var a,b=this,c="hue"===this.params.mode,d=!1;c?(a=this.container.find(".color-picker-hue"),a.val(b.setting()).wpColorPicker({change:function(a,c){d=!0,b.setting(c.color.h()),d=!1}})):(a=this.container.find(".color-picker-hex"),a.val(b.setting()).wpColorPicker({change:function(){d=!0,b.setting.set(a.wpColorPicker("color")),d=!1},clear:function(){d=!0,b.setting.set(""),d=!1}})),b.setting.bind(function(b){d||(a.val(b),a.wpColorPicker("color",b))}),b.container.on("keydown",function(c){var d;27===c.which&&(d=b.container.find(".wp-picker-container"),d.hasClass("wp-picker-active")&&(a.wpColorPicker("close"),b.container.find(".wp-color-result").focus(),c.stopPropagation()))})}}),f.MediaControl=f.Control.extend({ready:function(){function a(a){var d=b.Deferred();c.extended(f.UploadControl)?d.resolve():(a=parseInt(a,10),_.isNaN(a)||a<=0?(delete c.params.attachment,d.resolve()):c.params.attachment&&c.params.attachment.id===a&&d.resolve()),"pending"===d.state()&&wp.media.attachment(a).fetch().done(function(){c.params.attachment=this.attributes,d.resolve(),wp.customize.previewer.send(c.setting.id+"-attachment-data",this.attributes)}),d.done(function(){c.renderContent()})}var c=this;_.bindAll(c,"restoreDefault","removeFile","openFrame","select","pausePlayer"),c.container.on("click keydown",".upload-button",c.openFrame),c.container.on("click keydown",".upload-button",c.pausePlayer),c.container.on("click keydown",".thumbnail-image img",c.openFrame),c.container.on("click keydown",".default-button",c.restoreDefault),c.container.on("click keydown",".remove-button",c.pausePlayer),c.container.on("click keydown",".remove-button",c.removeFile),c.container.on("click keydown",".remove-button",c.cleanupPlayer),f.section(c.section()).container.on("expanded",function(){c.player&&c.player.setControlsSize()}).on("collapsed",function(){c.pausePlayer()}),a(c.setting()),c.setting.bind(a)},pausePlayer:function(){this.player&&this.player.pause()},cleanupPlayer:function(){this.player&&wp.media.mixin.removePlayer(this.player)},openFrame:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.frame||this.initFrame(),this.frame.open())},initFrame:function(){this.frame=wp.media({button:{text:this.params.button_labels.frame_button},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:this.params.mime_type}),multiple:!1,date:!1})]}),this.frame.on("select",this.select)},select:function(){var a,b=this.frame.state().get("selection").first().toJSON(),c=window._wpmejsSettings||{};this.params.attachment=b,this.setting(b.id),a=this.container.find("audio, video").get(0),a?this.player=new MediaElementPlayer(a,c):this.cleanupPlayer()},restoreDefault:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.params.attachment=this.params.defaultAttachment,this.setting(this.params.defaultAttachment.url))},removeFile:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent())}}),f.UploadControl=f.MediaControl.extend({select:function(){var a,b=this.frame.state().get("selection").first().toJSON(),c=window._wpmejsSettings||{};this.params.attachment=b,this.setting(b.url),a=this.container.find("audio, video").get(0),a?this.player=new MediaElementPlayer(a,c):this.cleanupPlayer()},success:function(){},removerVisibility:function(){}}),f.ImageControl=f.UploadControl.extend({thumbnailSrc:function(){}}),f.BackgroundControl=f.UploadControl.extend({ready:function(){f.UploadControl.prototype.ready.apply(this,arguments)},select:function(){f.UploadControl.prototype.select.apply(this,arguments),wp.ajax.post("custom-background-add",{nonce:_wpCustomizeBackground.nonces.add,wp_customize:"on",customize_theme:f.settings.theme.stylesheet,attachment_id:this.params.attachment.id})}}),f.BackgroundPositionControl=f.Control.extend({ready:function(){var a,c=this;c.container.on("change",'input[name="background-position"]',function(){var a=b(this).val().split(" ");c.settings.x(a[0]),c.settings.y(a[1])}),a=_.debounce(function(){var a,b,d,e;a=c.settings.x.get(),b=c.settings.y.get(),e=String(a)+" "+String(b),d=c.container.find('input[name="background-position"][value="'+e+'"]'),d.click()}),c.settings.x.bind(a),c.settings.y.bind(a),a()}}),f.CroppedImageControl=f.MediaControl.extend({openFrame:function(a){f.utils.isKeydownButNotEnterEvent(a)||(this.initFrame(),this.frame.setState("library").open())},initFrame:function(){var a=_wpMediaViewsL10n;this.frame=wp.media({button:{text:a.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.CustomizeImageCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var a=this.frame.state().get("selection").first().toJSON();this.params.width!==a.width||this.params.height!==a.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):(this.setImageFromAttachment(a),this.frame.close())},onCropped:function(a){this.setImageFromAttachment(a)},calculateImageSelectOptions:function(a,b){var c,d,e,f=b.get("control"),g=!!parseInt(f.params.flex_width,10),h=!!parseInt(f.params.flex_height,10),i=a.get("width"),j=a.get("height"),k=parseInt(f.params.width,10),l=parseInt(f.params.height,10),m=k/l,n=k,o=l;return b.set("canSkipCrop",!f.mustBeCropped(g,h,k,l,i,j)),i/j>m?(l=j,k=l*m):(k=i,l=k/m),c=(i-k)/2,d=(j-l)/2,e={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:i,imageHeight:j,minWidth:n>k?k:n,minHeight:o>l?l:o,x1:c,y1:d,x2:k+c,y2:l+d},h===!1&&g===!1&&(e.aspectRatio=k+":"+l),!0===h&&(delete e.minHeight,e.maxWidth=i),!0===g&&(delete e.minWidth,e.maxHeight=j),e},mustBeCropped:function(a,b,c,d,e,f){return(!0!==a||!0!==b)&&((!0!==a||d!==f)&&((!0!==b||c!==e)&&((c!==e||d!==f)&&!(e<=c))))},onSkippedCrop:function(){var a=this.frame.state().get("selection").first().toJSON();this.setImageFromAttachment(a)},setImageFromAttachment:function(a){this.params.attachment=a,this.setting(a.id)}}),f.SiteIconControl=f.CroppedImageControl.extend({initFrame:function(){var a=_wpMediaViewsL10n;this.frame=wp.media({button:{text:a.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.SiteIconCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var a=this.frame.state().get("selection").first().toJSON(),b=this;this.params.width!==a.width||this.params.height!==a.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):wp.ajax.post("crop-image",{nonce:a.nonces.edit,id:a.id,context:"site-icon",cropDetails:{x1:0,y1:0,width:this.params.width,height:this.params.height,dst_width:this.params.width,dst_height:this.params.height}}).done(function(a){b.setImageFromAttachment(a),b.frame.close()}).fail(function(){b.frame.trigger("content:error:crop")})},setImageFromAttachment:function(a){var c,d,e=["site_icon-32","thumbnail","full"];_.each(e,function(b){d||_.isUndefined(a.sizes[b])||(d=a.sizes[b])}),this.params.attachment=a,this.setting(a.id),d&&(c=b('link[rel="icon"][sizes="32x32"]'),c.attr("href",d.url))},removeFile:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent(),b('link[rel="icon"][sizes="32x32"]').attr("href","/favicon.ico"))}}),f.HeaderControl=f.Control.extend({ready:function(){this.btnRemove=b("#customize-control-header_image .actions .remove"),this.btnNew=b("#customize-control-header_image .actions .new"),_.bindAll(this,"openMedia","removeImage"),this.btnNew.on("click",this.openMedia),this.btnRemove.on("click",this.removeImage),f.HeaderTool.currentHeader=this.getInitialHeaderImage(),new f.HeaderTool.CurrentView({model:f.HeaderTool.currentHeader,el:"#customize-control-header_image .current .container"}),new f.HeaderTool.ChoiceListView({collection:f.HeaderTool.UploadsList=new f.HeaderTool.ChoiceList,el:"#customize-control-header_image .choices .uploaded .list"}),new f.HeaderTool.ChoiceListView({collection:f.HeaderTool.DefaultsList=new f.HeaderTool.DefaultsList,el:"#customize-control-header_image .choices .default .list"}),f.HeaderTool.combinedList=f.HeaderTool.CombinedList=new f.HeaderTool.CombinedList([f.HeaderTool.UploadsList,f.HeaderTool.DefaultsList]),wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize="on",wp.media.controller.Cropper.prototype.defaults.doCropArgs.customize_theme=f.settings.theme.stylesheet},getInitialHeaderImage:function(){if(!f.get().header_image||!f.get().header_image_data||_.contains(["remove-header","random-default-image","random-uploaded-image"],f.get().header_image))return new f.HeaderTool.ImageModel;var a=_.find(_wpCustomizeHeader.uploads,function(a){return a.attachment_id===f.get().header_image_data.attachment_id});return a||(a={url:f.get().header_image,thumbnail_url:f.get().header_image,attachment_id:f.get().header_image_data.attachment_id}),new f.HeaderTool.ImageModel({header:a,choice:a.url.split("/").pop()})},calculateImageSelectOptions:function(a,b){var c,d,e,g,h,i,j=parseInt(_wpCustomizeHeader.data.width,10),k=parseInt(_wpCustomizeHeader.data.height,10),l=!!parseInt(_wpCustomizeHeader.data["flex-width"],10),m=!!parseInt(_wpCustomizeHeader.data["flex-height"],10);return h=a.get("width"),g=a.get("height"),this.headerImage=new f.HeaderTool.ImageModel,this.headerImage.set({themeWidth:j,themeHeight:k,themeFlexWidth:l,themeFlexHeight:m,imageWidth:h,imageHeight:g}),b.set("canSkipCrop",!this.headerImage.shouldBeCropped()),c=j/k,d=h,e=g,d/e>c?(k=e,j=k*c):(j=d,k=j/c),i={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:h,imageHeight:g,x1:0,y1:0,x2:j,y2:k},m===!1&&l===!1&&(i.aspectRatio=j+":"+k),m===!1&&(i.maxHeight=k),l===!1&&(i.maxWidth=j),i},openMedia:function(a){var b=_wpMediaViewsL10n;a.preventDefault(),this.frame=wp.media({button:{text:b.selectAndCrop,close:!1},states:[new wp.media.controller.Library({title:b.chooseImage,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:_wpCustomizeHeader.data.width,suggestedHeight:_wpCustomizeHeader.data.height}),new wp.media.controller.Cropper({imgSelectOptions:this.calculateImageSelectOptions})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this),this.frame.open()},onSelect:function(){this.frame.setState("cropper")},onCropped:function(a){var b=a.url,c=a.attachment_id,d=a.width,e=a.height;this.setImageFromURL(b,c,d,e)},onSkippedCrop:function(a){var b=a.get("url"),c=a.get("width"),d=a.get("height");this.setImageFromURL(b,a.id,c,d)},setImageFromURL:function(a,b,c,d){var e,g={};g.url=a,g.thumbnail_url=a,g.timestamp=_.now(),b&&(g.attachment_id=b),c&&(g.width=c),d&&(g.height=d),e=new f.HeaderTool.ImageModel({header:g,choice:a.split("/").pop()}),f.HeaderTool.UploadsList.add(e),f.HeaderTool.currentHeader.set(e.toJSON()),e.save(),e.importImage()},removeImage:function(){f.HeaderTool.currentHeader.trigger("hide"),f.HeaderTool.CombinedList.trigger("control:removeImage")}}),f.ThemeControl=f.Control.extend({touchDrag:!1,screenshotRendered:!1,ready:function(){var a=this;a.container.on("touchmove",".theme",function(){a.touchDrag=!0}),a.container.on("click keydown touchend",".theme",function(c){if(!f.utils.isKeydownButNotEnterEvent(c))return a.touchDrag===!0?a.touchDrag=!1:void(b(c.target).is(".theme-actions .button, .update-theme")||(c.preventDefault(),f.section(a.section()).showDetails(a.params.theme)))}),a.container.on("render-screenshot",function(){var c=b(this).find("img"),d=c.data("src");d&&c.attr("src",d),a.screenshotRendered=!0})},filter:function(a){var b=this,c=b.params.theme.name+" "+b.params.theme.description+" "+b.params.theme.tags+" "+b.params.theme.author;return c=c.toLowerCase().replace("-"," "),-1!==c.search(a)?(b.activate(),!0):(b.deactivate(),!1)},rerenderAsInstalled:function(a){var b,c=this;a?c.params.theme.type="installed":(b=f.section(c.params.section),c.params.theme.type=b.params.action),c.renderContent(),c.container.trigger("render-screenshot")}}),f.CodeEditorControl=f.Control.extend({ready:function(){var a=this;return a.section()?void f.section(a.section(),function(b){b.deferred.embedded.done(function(){var c;b.expanded()?a.initEditor():(c=function(d){d&&(a.initEditor(),b.expanded.unbind(c))},b.expanded.bind(c))})}):void a.initEditor()},initEditor:function(){var a,b=this;a=new f.Element(b.container.find("textarea")),b.elements.push(a),a.sync(b.setting),a.set(b.setting()),b.params.editor_settings?b.initSyntaxHighlightingEditor(b.params.editor_settings):b.initPlainTextareaEditor()},focus:function(a){var b,c=this,d=_.extend({},a);b=d.completeCallback,d.completeCallback=function(){b&&b(),c.editor&&c.editor.codemirror.focus()},f.Control.prototype.focus.call(c,d)},initSyntaxHighlightingEditor:function(a){var c,d=this,e=d.container.find("textarea"),f=!1;c=_.extend({},a,{onTabNext:_.bind(d.onTabNext,d),onTabPrevious:_.bind(d.onTabPrevious,d),onUpdateErrorNotice:_.bind(d.onUpdateErrorNotice,d)}),d.editor=wp.codeEditor.initialize(e,c),b(d.editor.codemirror.display.lineDiv).attr({role:"textbox","aria-multiline":"true","aria-label":d.params.label,"aria-describedby":"editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"}),d.container.find("label").on("click",function(){d.editor.codemirror.focus()}),d.editor.codemirror.on("change",function(a){f=!0,e.val(a.getValue()).trigger("change"),f=!1}),d.setting.bind(function(a){f||d.editor.codemirror.setValue(a)}),d.editor.codemirror.on("keydown",function(a,b){var c=27;c===b.keyCode&&b.stopPropagation()})},onTabNext:function(){var a,c,d,e=this;d=f.section(e.section()),a=d.controls(),c=a.indexOf(e),a.length===c+1?b("#customize-footer-actions .collapse-sidebar").focus():a[c+1].container.find(":focusable:first").focus()},onTabPrevious:function(){var a,b,c,d=this;c=f.section(d.section()),a=c.controls(),b=a.indexOf(d),0===b?c.contentContainer.find(".customize-section-title .customize-help-toggle, .customize-section-title .customize-section-description.open .section-description-close").last().focus():a[b-1].contentContainer.find(":focusable:first").focus()},onUpdateErrorNotice:function(a){var b,c=this;c.setting.notifications.remove("csslint_error"),0!==a.length&&(b=1===a.length?f.l10n.customCssError.singular.replace("%d","1"):f.l10n.customCssError.plural.replace("%d",String(a.length)),c.setting.notifications.add("csslint_error",new f.Notification("csslint_error",{message:b,type:"error"})))},initPlainTextareaEditor:function(){var a=this,b=a.container.find("textarea"),c=b[0];b.on("blur",function(){b.data("next-tab-blurs",!1)}),b.on("keydown",function(a){var d,e,f,g=9,h=27;return h===a.keyCode?void(b.data("next-tab-blurs")||(b.data("next-tab-blurs",!0),a.stopPropagation())):void(g!==a.keyCode||a.ctrlKey||a.altKey||a.shiftKey||b.data("next-tab-blurs")||(d=c.selectionStart,e=c.selectionEnd,f=c.value,d>=0&&(c.value=f.substring(0,d).concat("\t",f.substring(e)),b.selectionStart=c.selectionEnd=d+1),a.stopPropagation(),a.preventDefault()))})}}),f.DateTimeControl=f.Control.extend({ready:function(){var a=this;a.inputElements={},a.invalidDate=!1,_.bindAll(a,"populateSetting","updateDaysForMonth","updateMinutesForHour","populateDateInputs"),a.setting||(a.setting=new f.Value),!a.setting.get()&&a.params.defaultValue&&a.setting.set(a.params.defaultValue),a.container.find(".date-input").each(function(){var c,d,e=b(this);c=e.data("component"),d=new f.Element(e),"meridian"===c?d.validate=function(a){return"am"!==a&&"pm"!==a?null:a}:d.validate=function(a){var b=parseInt(a,10);return isNaN(b)?null:b},d.bind(a.populateSetting),a.inputElements[c]=d,a.elements.push(d)}),a.inputElements.month.bind(a.updateDaysForMonth),a.inputElements.year.bind(a.updateDaysForMonth),a.params.includeTime&&a.inputElements.hour.bind(a.updateMinutesForHour),a.populateDateInputs(),a.setting.bind(a.populateDateInputs)},parseDateTime:function(a){var b,c,d=this,e=12;return a&&(b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/)),b?(b.shift(),c={year:b.shift(),month:b.shift(),day:b.shift(),hour:b.shift()||"00",minute:b.shift()||"00",second:b.shift()||"00"},d.params.includeTime&&d.params.twelveHourFormat&&(c.hour=parseInt(c.hour,10),c.meridian=c.hour>=e?"pm":"am",c.hour=c.hour%e?String(c.hour%e):String(e),delete c.second),c):null},validateInputs:function(){var a,b,c=this;return c.invalidDate=!1,b=["year","day"],c.params.includeTime&&b.push("hour","minute"),_.each(b,function(b){var d,e,g,h,i;c.invalidDate||(d=c.inputElements[b],e=d.element.get(0),g=parseInt(d.element.attr("max"),10),h=parseInt(d.element.attr("min"),10),i=d(),c.invalidDate=i>g||ia&&e.inputElements.day(a))},updateMinutesForHour:function(){var a,b=this,c=24;b.inputElements.meridian||(a=b.inputElements.minute.element,c===b.inputElements.hour()?(b.inputElements.minute(0),a.data("default-max",a.attr("max")),a.attr("max","0")):a.data("default-max")&&a.attr("max",a.data("default-max")))},populateSetting:function(){var a,b=this;return!(b.validateInputs()||!b.params.allowPastDate&&!b.isFutureDate())&&(a=b.convertInputDateToString(),b.setting.set(a),!0)},convertInputDateToString:function(){var a,b,c,d,e=this,f="";return d=function(a,b){var c;return String(a).length",{title:f.l10n.previewIframeTitle,name:"customize-"+g.channel()}),g.iframe.attr("onmousewheel",""), -k?g.iframe.attr("data-src",c.href):g.iframe.attr("src",c.href),g.iframe.appendTo(g.container),g.targetWindow(g.iframe[0].contentWindow),k&&(e=b("
    ",{action:c.href,target:g.iframe.attr("name"),method:"post",hidden:"hidden"}),e.append(b("",{type:"hidden",name:"_method",value:"GET"})),_.each(g.query,function(a,c){e.append(b("",{type:"hidden",name:c,value:a}))}),g.container.append(e),e.submit(),e.remove()),g.bind("iframe-loading-error",function(b){return g.iframe.remove(),0===b?void g.login(a):-1===b?void a.rejectWith(g,["cheatin"]):void a.rejectWith(g,["request failure"])}),g.iframe.one("load",function(){h=!0,i?a.resolveWith(g,[j]):setTimeout(function(){a.rejectWith(g,["ready timeout"])},g.sensitivity)})},login:function(a){var c,d=this;return c=function(){a.rejectWith(d,["logged out"])},this.triedLogin?c():void b.get(f.settings.url.ajax,{action:"logged-in"}).fail(c).done(function(e){var g;"1"!==e&&c(),g=b("