mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-26 02:57:45 +01:00
71244fc29e
This avoids a JS error when passing the message to `wp.a11y.speak()` when showing the "changeset is locked" overlay to prevent two users from editing the same changeset simultaneously. Props dlh. Fixes #50500. Built from https://develop.svn.wordpress.org/trunk@48210 git-svn-id: http://core.svn.wordpress.org/trunk@47979 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
109 KiB
JavaScript
2 lines
109 KiB
JavaScript
/*! This file is auto-generated */
|
|
!function(e,Z){var a,t,s,n,i,o,r,ee=wp.customize;ee.OverlayNotification=ee.Notification.extend({loading:!1,initialize:function(e,t){var n=this;ee.Notification.prototype.initialize.call(n,e,t),n.containerClasses+=" notification-overlay",n.loading&&(n.containerClasses+=" notification-loading")},render:function(){var e=ee.Notification.prototype.render.call(this);return e.on("keydown",_.bind(this.handleEscape,this)),e},handleEscape:function(e){var t=this;27===e.which&&(e.stopPropagation(),t.dismissible&&t.parent&&t.parent.remove(t.code))}}),ee.Notifications=ee.Values.extend({alt:!1,defaultConstructor:ee.Notification,initialize:function(e){var t=this;ee.Values.prototype.initialize.call(t,e),_.bindAll(t,"constrainFocus"),t._addedIncrement=0,t._addedOrder={},t.bind("add",function(e){t.trigger("change",e)}),t.bind("removed",function(e){t.trigger("change",e)})},count:function(){return _.size(this._value)},add:function(e,t){var n,i,a=this;return i="string"==typeof e?(n=e,t):(n=e.code,e),a.has(n)||(a._addedIncrement+=1,a._addedOrder[n]=a._addedIncrement),ee.Values.prototype.add.call(a,n,i)},remove:function(e){return delete this._addedOrder[e],ee.Values.prototype.remove.call(this,e)},get:function(e){var t,a,o=this;return t=_.values(o._value),_.extend({sort:!1},e).sort&&(a={error:4,warning:3,success:2,info:1},t.sort(function(e,t){var n=0,i=0;return _.isUndefined(a[e.type])||(n=a[e.type]),_.isUndefined(a[t.type])||(i=a[t.type]),n!==i?i-n:o._addedOrder[t.code]-o._addedOrder[e.code]})),t},render:function(){var e,t,n,i,a=this,o=!1,s=[],r={};a.container&&a.container.length&&(e=a.get({sort:!0}),a.container.toggle(0!==e.length),a.container.is(a.previousContainer)&&_.isEqual(e,a.previousNotifications)||((n=a.container.children("ul").first()).length||(n=Z("<ul></ul>"),a.container.append(n)),n.find("> [data-code]").remove(),_.each(a.previousNotifications,function(e){r[e.code]=e}),_.each(e,function(e){var t;!wp.a11y||r[e.code]&&_.isEqual(e.message,r[e.code].message)||wp.a11y.speak(e.message,"assertive"),t=Z(e.render()),e.container=t,n.append(t),e.extended(ee.OverlayNotification)&&s.push(e)}),t=Boolean(s.length),a.previousNotifications&&(o=Boolean(_.find(a.previousNotifications,function(e){return e.extended(ee.OverlayNotification)}))),t!==o&&(Z(document.body).toggleClass("customize-loading",t),a.container.toggleClass("has-overlay-notifications",t),t?(a.previousActiveElement=document.activeElement,Z(document).on("keydown",a.constrainFocus)):Z(document).off("keydown",a.constrainFocus)),t?(a.focusContainer=s[s.length-1].container,a.focusContainer.prop("tabIndex",-1),(i=a.focusContainer.find(":focusable")).length?i.first().focus():a.focusContainer.focus()):a.previousActiveElement&&(Z(a.previousActiveElement).focus(),a.previousActiveElement=null),a.previousNotifications=e,a.previousContainer=a.container,a.trigger("rendered")))},constrainFocus:function(e){var t,n=this;e.stopPropagation(),9===e.which&&(0===(t=n.focusContainer.find(":focusable")).length&&(t=n.focusContainer),Z.contains(n.focusContainer[0],e.target)&&Z.contains(n.focusContainer[0],document.activeElement)?t.last().is(e.target)&&!e.shiftKey?(e.preventDefault(),t.first().focus()):t.first().is(e.target)&&e.shiftKey&&(e.preventDefault(),t.last().focus()):(e.preventDefault(),t.first().focus()))}}),ee.Setting=ee.Value.extend({defaults:{transport:"refresh",dirty:!1},initialize:function(e,t,n){var i,a=this;i=_.extend({previewer:ee.previewer},a.defaults,n||{}),ee.Value.prototype.initialize.call(a,t,i),a.id=e,a._dirty=i.dirty,a.notifications=new ee.Notifications,a.bind(a.preview)},preview:function(){var e,t=this;"postMessage"!==(e=t.transport)||ee.state("previewerAlive").get()||(e="refresh"),"postMessage"===e?t.previewer.send("setting",[t.id,t()]):"refresh"===e&&t.previewer.refresh()},findControls:function(){var n=this,i=[];return ee.control.each(function(t){_.each(t.settings,function(e){e.id===n.id&&i.push(t)})}),i}}),ee._latestRevision=0,ee._lastSavedRevision=0,ee._latestSettingRevisions={},ee.bind("change",function(e){ee._latestRevision+=1,ee._latestSettingRevisions[e.id]=ee._latestRevision}),ee.bind("ready",function(){ee.bind("add",function(e){e._dirty&&(ee._latestRevision+=1,ee._latestSettingRevisions[e.id]=ee._latestRevision)})}),ee.dirtyValues=function(n){var i={};return ee.each(function(e){var t;e._dirty&&(t=ee._latestSettingRevisions[e.id],ee.state("changesetStatus").get()&&n&&n.unsaved&&(_.isUndefined(t)||t<=ee._lastSavedRevision)||(i[e.id]=e.get()))}),i},ee.requestChangesetUpdate=function(n,e){var t,i,a,o,s={};return t=new Z.Deferred,0!==ee.state("processing").get()?(t.reject("already_processing"),t.promise()):(o=_.extend({title:null,date:null,autosave:!1,force:!1},e),n&&_.extend(s,n),_.each(ee.dirtyValues({unsaved:!0}),function(e,t){n&&null===n[t]||(s[t]=_.extend({},s[t]||{},{value:e}))}),ee.trigger("changeset-save",s,o),!o.force&&_.isEmpty(s)&&null===o.title&&null===o.date?(t.resolve({}),t.promise()):o.status?t.reject({code:"illegal_status_in_changeset_update"}).promise():o.date&&o.autosave?t.reject({code:"illegal_autosave_with_date_gmt"}).promise():(ee.state("processing").set(ee.state("processing").get()+1),t.always(function(){ee.state("processing").set(ee.state("processing").get()-1)}),delete(a=ee.previewer.query({excludeCustomizedSaved:!0})).customized,_.extend(a,{nonce:ee.settings.nonce.save,customize_theme:ee.settings.theme.stylesheet,customize_changeset_data:JSON.stringify(s)}),null!==o.title&&(a.customize_changeset_title=o.title),null!==o.date&&(a.customize_changeset_date=o.date),!1!==o.autosave&&(a.customize_changeset_autosave="true"),ee.trigger("save-request-params",a),(i=wp.ajax.post("customize_save",a)).done(function(e){var n={};ee._lastSavedRevision=Math.max(ee._latestRevision,ee._lastSavedRevision),ee.state("changesetStatus").set(e.changeset_status),e.changeset_date&&ee.state("changesetDate").set(e.changeset_date),t.resolve(e),ee.trigger("changeset-saved",e),e.setting_validities&&_.each(e.setting_validities,function(e,t){!0===e&&_.isObject(s[t])&&!_.isUndefined(s[t].value)&&(n[t]=s[t].value)}),ee.previewer.send("changeset-saved",_.extend({},e,{saved_changeset_values:n}))}),i.fail(function(e){t.reject(e),ee.trigger("changeset-error",e)}),i.always(function(e){e.setting_validities&&ee._handleSettingValidities({settingValidities:e.setting_validities})}),t.promise()))},ee.utils.bubbleChildValueChanges=function(n,e){Z.each(e,function(e,t){n[t].bind(function(e,t){n.parent&&e!==t&&n.parent.trigger("change",n)})})},t=function(e){var t,n,i,a;t=this,i=function(){var e;e=(t.extended(ee.Panel)||t.extended(ee.Section))&&t.expanded&&t.expanded()?t.contentContainer:t.container,0===(a=e.find(".control-focus:first")).length&&(a=e.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first()),a.focus()},(e=e||{}).completeCallback?(n=e.completeCallback,e.completeCallback=function(){i(),n()}):e.completeCallback=i,ee.state("paneVisible").set(!0),t.expand?t.expand(e):e.completeCallback()},ee.utils.prioritySort=function(e,t){return e.priority()===t.priority()&&"number"==typeof e.params.instanceNumber&&"number"==typeof t.params.instanceNumber?e.params.instanceNumber-t.params.instanceNumber:e.priority()-t.priority()},ee.utils.isKeydownButNotEnterEvent=function(e){return"keydown"===e.type&&13!==e.which},ee.utils.areElementListsEqual=function(e,t){return e.length===t.length&&-1===_.indexOf(_.map(_.zip(e,t),function(e){return Z(e[0]).is(e[1])}),!1)},ee.utils.highlightButton=function(e,t){var n,i="button-see-me",a=!1;function o(){a=!0}return(n=_.extend({delay:0,focusTarget:e},t)).focusTarget.on("focusin",o),setTimeout(function(){n.focusTarget.off("focusin",o),a||(e.addClass(i),e.one("animationend",function(){e.removeClass(i)}))},n.delay),o},ee.utils.getCurrentTimestamp=function(){var e,t,n;return t=_.now(),e=new Date(ee.settings.initialServerDate.replace(/-/g,"/")),n=t-ee.settings.initialClientTimestamp,n+=ee.settings.initialClientTimestamp-ee.settings.initialServerTimestamp,e.setTime(e.getTime()+n),e.getTime()},ee.utils.getRemainingTime=function(e){var t;return t=(e instanceof Date?e.getTime():"string"==typeof e?new Date(e.replace(/-/g,"/")).getTime():e)-ee.utils.getCurrentTimestamp(),t=Math.ceil(t/1e3)},n=document.createElement("div"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},s=(o=_.find(_.keys(i),function(e){return!_.isUndefined(n.style[e])}))?i[o]:null,a=ee.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:Z.noop},defaultExpandedArguments:{duration:"fast",completeCallback:Z.noop},containerType:"container",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null},initialize:function(e,t){var n=this;n.id=e,a.instanceCounter||(a.instanceCounter=0),a.instanceCounter++,Z.extend(n,{params:_.defaults(t.params||t,n.defaults)}),n.params.instanceNumber||(n.params.instanceNumber=a.instanceCounter),n.notifications=new ee.Notifications,n.templateSelector=n.params.templateId||"customize-"+n.containerType+"-"+n.params.type,n.container=Z(n.params.content),0===n.container.length&&(n.container=Z(n.getContainer())),n.headContainer=n.container,n.contentContainer=n.getContent(),n.container=n.container.add(n.contentContainer),n.deferred={embedded:new Z.Deferred},n.priority=new ee.Value,n.active=new ee.Value,n.activeArgumentsQueue=[],n.expanded=new ee.Value,n.expandedArgumentsQueue=[],n.active.bind(function(e){var t=n.activeArgumentsQueue.shift();t=Z.extend({},n.defaultActiveArguments,t),e=e&&n.isContextuallyActive(),n.onChangeActive(e,t)}),n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift();t=Z.extend({},n.defaultExpandedArguments,t),n.onChangeExpanded(e,t)}),n.deferred.embedded.done(function(){n.setupNotifications(),n.attachEvents()}),ee.utils.bubbleChildValueChanges(n,["priority","active"]),n.priority.set(n.params.priority),n.active.set(n.params.active),n.expanded.set(!1)},getNotificationsContainerElement:function(){return this.contentContainer.find(".customize-control-notifications-container:first")},setupNotifications:function(){var e,t=this;t.notifications.container=t.getNotificationsContainerElement(),e=function(){t.expanded.get()&&t.notifications.render()},t.expanded.bind(e),e(),t.notifications.bind("change",_.debounce(e))},ready:function(){},_children:function(t,e){var n=this,i=[];return ee[e].each(function(e){e[t].get()===n.id&&i.push(e)}),i.sort(ee.utils.prioritySort),i},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(e,t){var n,i=this,a=i.headContainer;t.unchanged?t.completeCallback&&t.completeCallback():(n="resolved"===ee.previewer.deferred.active.state()?t.duration:0,i.extended(ee.Panel)&&(ee.panel.each(function(e){e!==i&&e.expanded()&&(e,n=0)}),e||_.each(i.sections(),function(e){e.collapse({duration:0})})),Z.contains(document,a.get(0))?e?a.slideDown(n,t.completeCallback):i.expanded()?i.collapse({duration:n,completeCallback:function(){a.slideUp(n,t.completeCallback)}}):a.slideUp(n,t.completeCallback):(a.toggle(e),t.completeCallback&&t.completeCallback()))},_toggleActive:function(e,t){return t=t||{},e&&this.active.get()||!e&&!this.active.get()?(t.unchanged=!0,this.onChangeActive(this.active.get(),t),!1):(t.unchanged=!1,this.activeArgumentsQueue.push(t),this.active.set(e),!0)},activate:function(e){return this._toggleActive(!0,e)},deactivate:function(e){return this._toggleActive(!1,e)},onChangeExpanded:function(){throw new Error("Must override with subclass.")},_toggleExpanded:function(e,t){var n,i=this;return n=(t=t||{}).completeCallback,!(e&&!i.active())&&(ee.state("paneVisible").set(!0),t.completeCallback=function(){n&&n.apply(i,arguments),e?i.container.trigger("expanded"):i.container.trigger("collapsed")},e&&i.expanded.get()||!e&&!i.expanded.get()?(t.unchanged=!0,i.onChangeExpanded(i.expanded.get(),t),!1):(t.unchanged=!1,i.expandedArgumentsQueue.push(t),i.expanded.set(e),!0))},expand:function(e){return this._toggleExpanded(!0,e)},collapse:function(e){return this._toggleExpanded(!1,e)},_animateChangeExpanded:function(t){if(s){var n,i,a=this,o=a.contentContainer,e=o.closest(".wp-full-overlay");n=e.add(o),(!a.panel||""===a.panel()||!!ee.panel(a.panel()).contentContainer.hasClass("skip-transition"))&&(n=n.add("#customize-info, .customize-pane-parent")),i=function(e){2===e.eventPhase&&Z(e.target).is(o)&&(o.off(s,i),n.removeClass("busy"),t&&t())},o.on(s,i),n.addClass("busy"),_.defer(function(){var e=o.closest(".wp-full-overlay-sidebar-content"),t=e.scrollTop(),n=o.data("previous-scrollTop")||0,i=a.expanded();i&&0<t?(o.css("top",t+"px"),o.data("previous-scrollTop",t)):!i&&0<t+n&&(o.css("top",n-t+"px"),e.scrollTop(n))})}else t&&t()},focus:t,getContainer:function(){var e,t=this;return(e=0!==Z("#tmpl-"+t.templateSelector).length?wp.template(t.templateSelector):wp.template("customize-"+t.containerType+"-default"))&&t.container?Z.trim(e(_.extend({id:t.id},t.params))):"<li></li>"},getContent:function(){var e=this.container,t=e.find(".accordion-section-content, .control-panel-content").first(),n="sub-"+e.attr("id"),i=n,a=e.attr("aria-owns");return a&&(i=i+" "+a),e.attr("aria-owns",i),t.detach().attr({id:n,class:"customize-pane-child "+t.attr("class")+" "+e.attr("class")})}}),ee.Section=a.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(e,t){var n,i=this;(n=t.params||t).type||_.find(ee.sectionConstructor,function(e,t){return e===i.constructor&&(n.type=t,!0)}),a.prototype.initialize.call(i,e,n),i.id=e,i.panel=new ee.Value,i.panel.bind(function(e){Z(i.headContainer).toggleClass("control-subsection",!!e)}),i.panel.set(i.params.panel||""),ee.utils.bubbleChildValueChanges(i,["panel"]),i.embed(),i.deferred.embedded.done(function(){i.ready()})},embed:function(){var e,n=this;n.containerParent=ee.ensure(n.containerParent),e=function(e){var t;e?ee.panel(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer,n.headContainer.parent().is(t)||t.append(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve()})}):(t=ee.ensure(n.containerPaneParent),n.headContainer.parent().is(t)||t.append(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve())},n.panel.bind(e),e(n.panel.get())},attachEvents:function(){var e,t,n=this;n.container.hasClass("cannot-expand")||(n.container.find(".accordion-section-title, .customize-section-back").on("click keydown",function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()?n.collapse():n.expand())}),n.container.find(".customize-section-title .customize-help-toggle").on("click",function(){(e=n.container.find(".section-meta")).hasClass("cannot-expand")||((t=e.find(".customize-section-description:first")).toggleClass("open"),t.slideToggle(n.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),Z(this).attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}))}))},isContextuallyActive:function(){var e=this.controls(),t=0;return _(e).each(function(e){e.active()&&(t+=1)}),0!==t},controls:function(){return this._children("section","control")},onChangeExpanded:function(e,t){var n,i,a=this,o=a.headContainer.closest(".wp-full-overlay-sidebar-content"),s=a.contentContainer,r=a.headContainer.closest(".wp-full-overlay"),c=s.find(".customize-section-back"),l=a.headContainer.find(".accordion-section-title").first();e&&!s.hasClass("open")?(n=t.unchanged?t.completeCallback:Z.proxy(function(){a._animateChangeExpanded(function(){l.attr("tabindex","-1"),c.attr("tabindex","0"),c.focus(),s.css("top",""),o.scrollTop(0),t.completeCallback&&t.completeCallback()}),s.addClass("open"),r.addClass("section-open"),ee.state("expandedSection").set(a)},this),t.allowMultiple||ee.section.each(function(e){e!==a&&e.collapse({duration:t.duration})}),a.panel()?ee.panel(a.panel()).expand({duration:t.duration,completeCallback:n}):(t.allowMultiple||ee.panel.each(function(e){e.collapse()}),n())):!e&&s.hasClass("open")?(a.panel()&&(i=ee.panel(a.panel())).contentContainer.hasClass("skip-transition")&&i.collapse(),a._animateChangeExpanded(function(){c.attr("tabindex","-1"),l.attr("tabindex","0"),l.focus(),s.css("top",""),t.completeCallback&&t.completeCallback()}),s.removeClass("open"),r.removeClass("section-open"),a===ee.state("expandedSection").get()&&ee.state("expandedSection").set(!1)):t.completeCallback&&t.completeCallback()}}),ee.ThemesSection=ee.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,updateCountDebounced:null,initialize:function(e,t){var n=this;n.headerContainer=Z(),n.$window=Z(window),n.$body=Z(document.body),ee.Section.prototype.initialize.call(n,e,t),n.updateCountDebounced=_.debounce(n.updateCount,500)},embed:function(){var e,n=this;e=function(e){var t;ee.panel(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer,n.headContainer.parent().is(t)||t.find(".customize-themes-full-container-container").before(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve()})})},n.panel.bind(e),e(n.panel.get())},ready:function(){var t=this;t.overlay=t.container.find(".theme-overlay"),t.template=wp.template("customize-themes-details-view"),t.container.on("keydown",function(e){t.overlay.find(".theme-wrap").is(":visible")&&(39===e.keyCode&&t.nextTheme(),37===e.keyCode&&t.previousTheme(),27===e.keyCode&&(t.$body.hasClass("modal-open")?t.closeDetails():t.headerContainer.find(".customize-themes-section-title").focus(),e.stopPropagation()))}),t.renderScreenshots=_.throttle(t.renderScreenshots,100),_.bindAll(t,"renderScreenshots","loadMore","checkTerm","filtersChecked")},isContextuallyActive:function(){return this.active()},attachEvents:function(){var e,a=this;function t(){var e=a.headerContainer.find(".customize-themes-section-title");e.toggleClass("selected",a.expanded()),e.attr("aria-expanded",a.expanded()?"true":"false"),a.expanded()||e.removeClass("details-open")}a.container.find(".customize-section-back").on("click keydown",function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),a.collapse())}),a.headerContainer=Z("#accordion-section-"+a.id),a.headerContainer.on("click",".customize-themes-section-title",function(){a.headerContainer.find(".filter-details").length&&(a.headerContainer.find(".customize-themes-section-title").toggleClass("details-open").attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}),a.headerContainer.find(".filter-details").slideToggle(180)),a.expanded()||a.expand()}),a.container.on("click",".theme-actions .preview-theme",function(){ee.panel("themes").loadThemePreview(Z(this).data("slug"))}),a.container.on("click",".left",function(){a.previousTheme()}),a.container.on("click",".right",function(){a.nextTheme()}),a.container.on("click",".theme-backdrop, .close",function(){a.closeDetails()}),"local"===a.params.filter_type?a.container.on("input",".wp-filter-search-themes",function(e){a.filterSearch(e.currentTarget.value)}):"remote"===a.params.filter_type&&(e=_.debounce(a.checkTerm,500),a.contentContainer.on("input",".wp-filter-search",function(){ee.panel("themes").expanded()&&(e(a),a.expanded()||a.expand())}),a.contentContainer.on("click",".filter-group input",function(){a.filtersChecked(),a.checkTerm(a)})),a.contentContainer.on("click",".feature-filter-toggle",function(e){var t=Z(".customize-themes-full-container"),n=Z(e.currentTarget);if(a.filtersHeight=n.parent().next(".filter-drawer").height(),!(0<t.scrollTop()&&(t.animate({scrollTop:0},400),n.hasClass("open"))))if(n.toggleClass("open").attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}).parent().next(".filter-drawer").slideToggle(180,"linear"),n.hasClass("open")){var i=1018<window.innerWidth?50:76;a.contentContainer.find(".themes").css("margin-top",a.filtersHeight+i)}else a.contentContainer.find(".themes").css("margin-top",0)}),a.contentContainer.on("click",".no-themes-local .search-dotorg-themes",function(){ee.section("wporg_themes").focus()}),a.expanded.bind(t),t(),ee.bind("ready",function(){a.contentContainer=a.container.find(".customize-themes-section"),a.contentContainer.appendTo(Z(".customize-themes-full-container")),a.container.add(a.headerContainer)})},onChangeExpanded:function(e,n){var i=this,t=i.contentContainer.closest(".customize-themes-full-container");function a(){0===i.loaded&&i.loadThemes(),ee.section.each(function(e){var t;e!==i&&"themes"===e.params.type&&(t=e.contentContainer.find(".wp-filter-search").val(),i.contentContainer.find(".wp-filter-search").val(t),""===t&&""!==i.term&&"local"!==i.params.filter_type?(i.term="",i.initializeNewQuery(i.term,i.tags)):"remote"===i.params.filter_type?i.checkTerm(i):"local"===i.params.filter_type&&i.filterSearch(t),e.collapse({duration:n.duration}))}),i.contentContainer.addClass("current-section"),t.scrollTop(),t.on("scroll",_.throttle(i.renderScreenshots,300)),t.on("scroll",_.throttle(i.loadMore,300)),n.completeCallback&&n.completeCallback(),i.updateCount()}n.unchanged?n.completeCallback&&n.completeCallback():e?i.panel()&&ee.panel.has(i.panel())?ee.panel(i.panel()).expand({duration:n.duration,completeCallback:a}):a():(i.contentContainer.removeClass("current-section"),i.headerContainer.find(".filter-details").slideUp(180),t.off("scroll"),n.completeCallback&&n.completeCallback())},getContent:function(){return this.container.find(".control-section-content")},loadThemes:function(){var e,n,t,i=this;i.loading||(n=Math.ceil(i.loaded/100)+1,e={nonce:ee.settings.nonce.switch_themes,wp_customize:"on",theme_action:i.params.action,customized_theme:ee.settings.theme.stylesheet,page:n},"remote"===i.params.filter_type&&(e.search=i.term,e.tags=i.tags),i.headContainer.closest(".wp-full-overlay").addClass("loading"),i.loading=!0,i.container.find(".no-themes").hide(),(t=wp.ajax.post("customize_load_themes",e)).done(function(e){var t=e.themes;if(""!==i.nextTerm||""!==i.nextTags)return i.nextTerm&&(i.term=i.nextTerm),i.nextTags&&(i.tags=i.nextTags),i.nextTerm="",i.nextTags="",i.loading=!1,void i.loadThemes();0!==t.length?(i.loadControls(t,n),1===n&&(_.each(i.controls().slice(0,3),function(e){var t=e.params.theme.screenshot[0];t&&((new Image).src=t)}),"local"!==i.params.filter_type&&wp.a11y.speak(ee.settings.l10n.themeSearchResults.replace("%d",e.info.results))),_.delay(i.renderScreenshots,100),("local"===i.params.filter_type||t.length<100)&&(i.fullyLoaded=!0)):0===i.loaded?(i.container.find(".no-themes").show(),wp.a11y.speak(i.container.find(".no-themes").text())):i.fullyLoaded=!0,"local"===i.params.filter_type?i.updateCount():i.updateCount(e.info.results),i.container.find(".unexpected-error").hide(),i.headContainer.closest(".wp-full-overlay").removeClass("loading"),i.loading=!1}),t.fail(function(e){void 0===e?(i.container.find(".unexpected-error").show(),wp.a11y.speak(i.container.find(".unexpected-error").text())):"undefined"!=typeof console&&console.error&&console.error(e),i.headContainer.closest(".wp-full-overlay").removeClass("loading"),i.loading=!1}))},loadControls:function(e,t){var n=[],i=this;_.each(e,function(e){var t=new ee.controlConstructor.theme(i.params.action+"_theme_"+e.id,{type:"theme",section:i.params.id,theme:e,priority:i.loaded+1});ee.control.add(t),n.push(t),i.loaded=i.loaded+1}),1!==t&&Array.prototype.push.apply(i.screenshotQueue,n)},loadMore:function(){var e,t;this.fullyLoaded||this.loading||(t=(e=this.container.closest(".customize-themes-full-container")).scrollTop()+e.height(),e.prop("scrollHeight")-3e3<t&&this.loadThemes())},filterSearch:function(e){var t,n=0,i=this,a=ee.section.has("wporg_themes")&&"remote"!==i.params.filter_type?".no-themes-local":".no-themes",o=i.controls();i.loading||(t=e.toLowerCase().trim().replace(/-/g," ").split(" "),_.each(o,function(e){e.filter(t)&&(n+=1)}),0===n?(i.container.find(a).show(),wp.a11y.speak(i.container.find(a).text())):i.container.find(a).hide(),i.renderScreenshots(),ee.reflowPaneContents(),i.updateCountDebounced(n))},checkTerm:function(e){var t;"remote"===e.params.filter_type&&(t=e.contentContainer.find(".wp-filter-search").val(),e.term!==t.trim()&&e.initializeNewQuery(t,e.tags))},filtersChecked:function(){var e=this,t=e.container.find(".filter-group").find(":checkbox"),n=[];_.each(t.filter(":checked"),function(e){n.push(Z(e).prop("value"))}),0===n.length?(n="",e.contentContainer.find(".feature-filter-toggle .filter-count-0").show(),e.contentContainer.find(".feature-filter-toggle .filter-count-filters").hide()):(e.contentContainer.find(".feature-filter-toggle .theme-filter-count").text(n.length),e.contentContainer.find(".feature-filter-toggle .filter-count-0").hide(),e.contentContainer.find(".feature-filter-toggle .filter-count-filters").show()),_.isEqual(e.tags,n)||(e.loading?e.nextTags=n:"remote"===e.params.filter_type?e.initializeNewQuery(e.term,n):"local"===e.params.filter_type&&e.filterSearch(n.join(" ")))},initializeNewQuery:function(e,t){var n=this;_.each(n.controls(),function(e){e.container.remove(),ee.control.remove(e.id)}),n.loaded=0,n.fullyLoaded=!1,n.screenshotQueue=null,n.loading?(n.nextTerm=e,n.nextTags=t):(n.term=e,n.tags=t,n.loadThemes()),n.expanded()||n.expand()},renderScreenshots:function(){var l=this;null!==l.screenshotQueue&&0!==l.screenshotQueue.length||(l.screenshotQueue=_.filter(l.controls(),function(e){return!e.screenshotRendered})),l.screenshotQueue.length&&(l.screenshotQueue=_.filter(l.screenshotQueue,function(e){var t=e.container.find(".theme-screenshot"),n=t.find("img");if(!n.length)return!1;if(n.is(":hidden"))return!0;var i=l.$window.scrollTop(),a=i+l.$window.height(),o=n.offset().top,s=t.height(),r=3*s,c=i-r<=o+s&&o<=a+r;return c&&e.container.trigger("render-screenshot"),!c}))},getVisibleCount:function(){return this.contentContainer.find("li.customize-control:visible").length},updateCount:function(e){var t,n;e||0===e||(e=this.getVisibleCount()),n=this.contentContainer.find(".themes-displayed"),t=this.contentContainer.find(".theme-count"),0===e?t.text("0"):(n.fadeOut(180,function(){t.text(e),n.fadeIn(180)}),wp.a11y.speak(ee.settings.l10n.announceThemeCount.replace("%d",e)))},nextTheme:function(){var e=this;e.getNextTheme()&&e.showDetails(e.getNextTheme(),function(){e.overlay.find(".right").focus()})},getNextTheme:function(){var e,t,n,i;return e=ee.control(this.params.action+"_theme_"+this.currentTheme),n=this.controls(),-1!==(i=_.indexOf(n,e))&&(!!(t=n[i+1])&&t.params.theme)},previousTheme:function(){var e=this;e.getPreviousTheme()&&e.showDetails(e.getPreviousTheme(),function(){e.overlay.find(".left").focus()})},getPreviousTheme:function(){var e,t,n,i;return e=ee.control(this.params.action+"_theme_"+this.currentTheme),n=this.controls(),-1!==(i=_.indexOf(n,e))&&(!!(t=n[i-1])&&t.params.theme)},updateLimits:function(){this.getNextTheme()||this.overlay.find(".right").addClass("disabled"),this.getPreviousTheme()||this.overlay.find(".left").addClass("disabled")},loadThemePreview:function(e){return ee.ThemesPanel.prototype.loadThemePreview.call(this,e)},showDetails:function(e,t){var n=this,i=ee.panel("themes");function a(){return!i.canSwitchTheme(e.id)}n.currentTheme=e.id,n.overlay.html(n.template(e)).fadeIn("fast").focus(),n.overlay.find("button.preview, button.preview-theme").toggleClass("disabled",a()),n.overlay.find("button.theme-install").toggleClass("disabled",a()||!1===ee.settings.theme._canInstall||!0===ee.settings.theme._filesystemCredentialsNeeded),n.$body.addClass("modal-open"),n.containFocus(n.overlay),n.updateLimits(),wp.a11y.speak(ee.settings.l10n.announceThemeDetails.replace("%s",e.name)),t&&t()},closeDetails:function(){this.$body.removeClass("modal-open"),this.overlay.fadeOut("fast"),ee.control(this.params.action+"_theme_"+this.currentTheme).container.find(".theme").focus()},containFocus:function(t){var n;t.on("keydown",function(e){if(9===e.keyCode)return(n=Z(":tabbable",t)).last()[0]!==e.target||e.shiftKey?n.first()[0]===e.target&&e.shiftKey?(n.last().focus(),!1):void 0:(n.first().focus(),!1)})}}),ee.OuterSection=ee.Section.extend({initialize:function(){this.containerParent="#customize-outer-theme-controls",this.containerPaneParent=".customize-outer-pane-parent",ee.Section.prototype.initialize.apply(this,arguments)},onChangeExpanded:function(e,t){var n,i,a=this,o=a.headContainer.closest(".wp-full-overlay-sidebar-content"),s=a.contentContainer,r=s.find(".customize-section-back"),c=a.headContainer.find(".accordion-section-title").first();Z(document.body).toggleClass("outer-section-open",e),a.container.toggleClass("open",e),a.container.removeClass("busy"),ee.section.each(function(e){"outer"===e.params.type&&e.id!==a.id&&e.container.removeClass("open")}),e&&!s.hasClass("open")?(n=t.unchanged?t.completeCallback:Z.proxy(function(){a._animateChangeExpanded(function(){c.attr("tabindex","-1"),r.attr("tabindex","0"),r.focus(),s.css("top",""),o.scrollTop(0),t.completeCallback&&t.completeCallback()}),s.addClass("open")},this),a.panel()?ee.panel(a.panel()).expand({duration:t.duration,completeCallback:n}):n()):!e&&s.hasClass("open")?(a.panel()&&(i=ee.panel(a.panel())).contentContainer.hasClass("skip-transition")&&i.collapse(),a._animateChangeExpanded(function(){r.attr("tabindex","-1"),c.attr("tabindex","0"),c.focus(),s.css("top",""),t.completeCallback&&t.completeCallback()}),s.removeClass("open")):t.completeCallback&&t.completeCallback()}}),ee.Panel=a.extend({containerType:"panel",initialize:function(e,t){var n,i=this;(n=t.params||t).type||_.find(ee.panelConstructor,function(e,t){return e===i.constructor&&(n.type=t,!0)}),a.prototype.initialize.call(i,e,n),i.embed(),i.deferred.embedded.done(function(){i.ready()})},embed:function(){var e=this,t=Z("#customize-theme-controls"),n=Z(".customize-pane-parent");e.headContainer.parent().is(n)||n.append(e.headContainer),e.contentContainer.parent().is(e.headContainer)||t.append(e.contentContainer),e.renderContent(),e.deferred.embedded.resolve()},attachEvents:function(){var t,n=this;n.headContainer.find(".accordion-section-title").on("click keydown",function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()||n.expand())}),n.container.find(".customize-panel-back").on("click keydown",function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()&&n.collapse())}),(t=n.container.find(".panel-meta:first")).find("> .accordion-section-title .customize-help-toggle").on("click",function(){if(!t.hasClass("cannot-expand")){var e=t.find(".customize-panel-description:first");t.hasClass("open")?(t.toggleClass("open"),e.slideUp(n.defaultExpandedArguments.duration,function(){e.trigger("toggled")}),Z(this).attr("aria-expanded",!1)):(e.slideDown(n.defaultExpandedArguments.duration,function(){e.trigger("toggled")}),t.toggleClass("open"),Z(this).attr("aria-expanded",!0))}})},sections:function(){return this._children("panel","section")},isContextuallyActive:function(){var e=this.sections(),t=0;return _(e).each(function(e){e.active()&&e.isContextuallyActive()&&(t+=1)}),0!==t},onChangeExpanded:function(e,t){if(t.unchanged)t.completeCallback&&t.completeCallback();else{var n=this,i=n.contentContainer,a=i.closest(".wp-full-overlay"),o=i.closest(".wp-full-overlay-sidebar-content"),s=n.headContainer.find(".accordion-section-title"),r=i.find(".customize-panel-back"),c=n.sections();e&&!i.hasClass("current-panel")?(ee.section.each(function(e){n.id!==e.panel()&&e.collapse({duration:0})}),ee.panel.each(function(e){n!==e&&e.collapse({duration:0})}),n.params.autoExpandSoleSection&&1===c.length&&c[0].active.get()?(i.addClass("current-panel skip-transition"),a.addClass("in-sub-panel"),c[0].expand({completeCallback:t.completeCallback})):(n._animateChangeExpanded(function(){s.attr("tabindex","-1"),r.attr("tabindex","0"),r.focus(),i.css("top",""),o.scrollTop(0),t.completeCallback&&t.completeCallback()}),i.addClass("current-panel"),a.addClass("in-sub-panel")),ee.state("expandedPanel").set(n)):!e&&i.hasClass("current-panel")&&(i.hasClass("skip-transition")?i.removeClass("skip-transition"):n._animateChangeExpanded(function(){s.attr("tabindex","0"),r.attr("tabindex","-1"),s.focus(),i.css("top",""),t.completeCallback&&t.completeCallback()}),a.removeClass("in-sub-panel"),i.removeClass("current-panel"),n===ee.state("expandedPanel").get()&&ee.state("expandedPanel").set(!1))}},renderContent:function(){var e,t=this;(e=0!==Z("#tmpl-"+t.templateSelector+"-content").length?wp.template(t.templateSelector+"-content"):wp.template("customize-panel-default-content"))&&t.headContainer&&t.contentContainer.html(e(_.extend({id:t.id},t.params)))}}),ee.ThemesPanel=ee.Panel.extend({initialize:function(e,t){this.installingThemes=[],ee.Panel.prototype.initialize.call(this,e,t)},canSwitchTheme:function(e){return!(!e||e!==ee.settings.theme.stylesheet)||"publish"===ee.state("selectedChangesetStatus").get()&&(""===ee.state("changesetStatus").get()||"auto-draft"===ee.state("changesetStatus").get())},attachEvents:function(){var t=this;function e(){t.canSwitchTheme()?t.notifications.remove("theme_switch_unavailable"):t.notifications.add(new ee.Notification("theme_switch_unavailable",{message:ee.l10n.themePreviewUnavailable,type:"warning"}))}ee.Panel.prototype.attachEvents.apply(t),ee.settings.theme._canInstall&&ee.settings.theme._filesystemCredentialsNeeded&&t.notifications.add(new ee.Notification("theme_install_unavailable",{message:ee.l10n.themeInstallUnavailable,type:"info",dismissible:!0})),e(),ee.state("selectedChangesetStatus").bind(e),ee.state("changesetStatus").bind(e),t.contentContainer.on("click",".customize-theme",function(){t.collapse()}),t.contentContainer.on("click",".customize-themes-section-title, .customize-themes-mobile-back",function(){Z(".wp-full-overlay").toggleClass("showing-themes")}),t.contentContainer.on("click",".theme-install",function(e){t.installTheme(e)}),t.contentContainer.on("click",".update-theme, #update-theme",function(e){e.preventDefault(),e.stopPropagation(),t.updateTheme(e)}),t.contentContainer.on("click",".delete-theme",function(e){t.deleteTheme(e)}),_.bindAll(t,"installTheme","updateTheme")},onChangeExpanded:function(e,t){var n,i,a=!1;ee.Panel.prototype.onChangeExpanded.apply(this,[e,t]),t.unchanged?t.completeCallback&&t.completeCallback():(n=this.headContainer.closest(".wp-full-overlay"),e?(n.addClass("in-themes-panel").delay(200).find(".customize-themes-full-container").addClass("animate"),_.delay(function(){n.addClass("themes-panel-expanded")},200),600<window.innerWidth&&(i=this.sections(),_.each(i,function(e){e.expanded()&&(a=!0)}),!a&&0<i.length&&i[0].expand())):n.removeClass("in-themes-panel themes-panel-expanded").find(".customize-themes-full-container").removeClass("animate"))},installTheme:function(e){var i,t,n,a=this,o=Z(e.target).data("slug"),s=Z.Deferred();return i=Z(e.target).hasClass("preview"),ee.settings.theme._filesystemCredentialsNeeded?s.reject({errorCode:"theme_install_unavailable"}):a.canSwitchTheme(o)?_.contains(a.installingThemes,o)?s.reject({errorCode:"theme_already_installing"}):(wp.updates.maybeRequestFilesystemCredentials(e),t=function(t){var e,n=!1;if(i)ee.notifications.remove("theme_installing"),a.loadThemePreview(o);else{if(ee.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t.slug&&(n=e.params.theme,e.rerenderAsInstalled(!0))}),!n||ee.control.has("installed_theme_"+n.id))return void s.resolve(t);n.type="installed",e=new ee.controlConstructor.theme("installed_theme_"+n.id,{type:"theme",section:"installed_themes",theme:n,priority:0}),ee.control.add(e),ee.control(e.id).container.trigger("render-screenshot"),ee.section.each(function(e){"themes"===e.params.type&&n.id===e.currentTheme&&e.closeDetails()})}s.resolve(t)},a.installingThemes.push(o),n=wp.updates.installTheme({slug:o}),i&&ee.notifications.add(new ee.OverlayNotification("theme_installing",{message:ee.l10n.themeDownloading,type:"info",loading:!0})),n.done(t),n.fail(function(){ee.notifications.remove("theme_installing")})):s.reject({errorCode:"theme_switch_unavailable"}),s.promise()},loadThemePreview:function(e){var t,n,i,a=Z.Deferred();return this.canSwitchTheme(e)?((n=document.createElement("a")).href=location.href,i=_.extend(ee.utils.parseQueryString(n.search.substr(1)),{theme:e,changeset_uuid:ee.settings.changeset.uuid,return:ee.settings.url.return}),ee.state("saved").get()||(i.customize_autosaved="on"),n.search=Z.param(i),ee.notifications.add(new ee.OverlayNotification("theme_previewing",{message:ee.l10n.themePreviewWait,type:"info",loading:!0})),t=function(){var e;0<ee.state("processing").get()||(ee.state("processing").unbind(t),(e=ee.requestChangesetUpdate({},{autosave:!0})).done(function(){a.resolve(),Z(window).off("beforeunload.customize-confirm"),location.replace(n.href)}),e.fail(function(){ee.notifications.remove("theme_previewing"),a.reject()}))},0===ee.state("processing").get()?t():ee.state("processing").bind(t)):a.reject({errorCode:"theme_switch_unavailable"}),a.promise()},updateTheme:function(e){wp.updates.maybeRequestFilesystemCredentials(e),Z(document).one("wp-theme-update-success",function(e,t){ee.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t.slug&&(e.params.theme.hasUpdate=!1,e.params.theme.version=t.newVersion,setTimeout(function(){e.rerenderAsInstalled(!0)},2e3))})}),wp.updates.updateTheme({slug:Z(e.target).closest(".notice").data("slug")})},deleteTheme:function(e){var t,n;t=Z(e.target).data("slug"),n=ee.section("installed_themes"),e.preventDefault(),ee.settings.theme._filesystemCredentialsNeeded||window.confirm(ee.settings.l10n.confirmDeleteTheme)&&(wp.updates.maybeRequestFilesystemCredentials(e),Z(document).one("wp-theme-delete-success",function(){var e=ee.control("installed_theme_"+t);e.container.remove(),ee.control.remove(e.id),n.loaded=n.loaded-1,n.updateCount(),ee.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t&&e.rerenderAsInstalled(!1)})}),wp.updates.deleteTheme({slug:t}),n.closeDetails(),n.focus())}}),ee.Control=ee.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:Z.noop},defaults:{label:"",description:"",active:!0,priority:10},initialize:function(e,t){var n,i,a=this,o=[];a.params=_.extend({},a.defaults,a.params||{},t.params||t||{}),ee.Control.instanceCounter||(ee.Control.instanceCounter=0),ee.Control.instanceCounter++,a.params.instanceNumber||(a.params.instanceNumber=ee.Control.instanceCounter),a.params.type||_.find(ee.controlConstructor,function(e,t){return e===a.constructor&&(a.params.type=t,!0)}),a.params.content||(a.params.content=Z("<li></li>",{id:"customize-control-"+e.replace(/]/g,"").replace(/\[/g,"-"),class:"customize-control customize-control-"+a.params.type})),a.id=e,a.selector="#customize-control-"+e.replace(/\]/g,"").replace(/\[/g,"-"),a.params.content?a.container=Z(a.params.content):a.container=Z(a.selector),a.params.templateId?a.templateSelector=a.params.templateId:a.templateSelector="customize-control-"+a.params.type+"-content",a.deferred=_.extend(a.deferred||{},{embedded:new Z.Deferred}),a.section=new ee.Value,a.priority=new ee.Value,a.active=new ee.Value,a.activeArgumentsQueue=[],a.notifications=new ee.Notifications({alt:a.altNotice}),a.elements=[],a.active.bind(function(e){var t=a.activeArgumentsQueue.shift();t=Z.extend({},a.defaultActiveArguments,t),a.onChangeActive(e,t)}),a.section.set(a.params.section),a.priority.set(isNaN(a.params.priority)?10:a.params.priority),a.active.set(a.params.active),ee.utils.bubbleChildValueChanges(a,["section","priority","active"]),a.settings={},n={},a.params.setting&&(n.default=a.params.setting),_.extend(n,a.params.settings),_.each(n,function(e,t){var n;_.isObject(e)&&_.isFunction(e.extended)&&e.extended(ee.Value)?a.settings[t]=e:_.isString(e)&&((n=ee(e))?a.settings[t]=n:o.push(e))}),i=function(){_.each(n,function(e,t){!a.settings[t]&&_.isString(e)&&(a.settings[t]=ee(e))}),a.settings[0]&&!a.settings.default&&(a.settings.default=a.settings[0]),a.setting=a.settings.default||null,a.linkElements(),a.embed()},0===o.length?i():ee.apply(ee,o.concat(i)),a.deferred.embedded.done(function(){a.linkElements(),a.setupNotifications(),a.ready()})},linkElements:function(){var i,a,o,s=this;i=s.container.find("[data-customize-setting-link], [data-customize-setting-key-link]"),a={},i.each(function(){var e,t,n=Z(this);if(!n.data("customizeSettingLinked")){if(n.data("customizeSettingLinked",!0),n.is(":radio")){if(e=n.prop("name"),a[e])return;a[e]=!0,n=i.filter('[name="'+e+'"]')}n.data("customizeSettingLink")?t=ee(n.data("customizeSettingLink")):n.data("customizeSettingKeyLink")&&(t=s.settings[n.data("customizeSettingKeyLink")]),t&&(o=new ee.Element(n),s.elements.push(o),o.sync(t),o.set(t()))}})},embed:function(){var e,n=this;e=function(e){var t;e&&ee.section(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),n.container.parent().is(t)||(t.append(n.container),n.renderContent()),n.deferred.embedded.resolve()})})},n.section.bind(e),e(n.section.get())},ready:function(){var t,n=this;"dropdown-pages"===n.params.type&&n.params.allow_addition&&((t=n.container.find(".new-content-item")).hide(),n.container.on("click",".add-new-toggle",function(e){Z(e.currentTarget).slideUp(180),t.slideDown(180),t.find(".create-item-input").focus()}),n.container.on("click",".add-content",function(){n.addNewPage()}),n.container.on("keydown",".create-item-input",function(e){13===e.which&&n.addNewPage()}))},getNotificationsContainerElement:function(){var e,t,n=this;return(t=n.container.find(".customize-control-notifications-container:first")).length||(t=Z('<div class="customize-control-notifications-container"></div>'),n.container.hasClass("customize-control-nav_menu_item")?n.container.find(".menu-item-settings:first").prepend(t):n.container.hasClass("customize-control-widget_form")?n.container.find(".widget-inside:first").prepend(t):(e=n.container.find(".customize-control-title")).length?e.after(t):n.container.prepend(t)),t},setupNotifications:function(){var n,e,i=this;_.each(i.settings,function(n){n.notifications&&(n.notifications.bind("add",function(e){var t=_.extend({},e,{setting:n.id});i.notifications.add(new ee.Notification(n.id+":"+e.code,t))}),n.notifications.bind("remove",function(e){i.notifications.remove(n.id+":"+e.code)}))}),n=function(){var e=i.section();(!e||ee.section.has(e)&&ee.section(e).expanded())&&i.notifications.render()},i.notifications.bind("rendered",function(){var e=i.notifications.get();i.container.toggleClass("has-notifications",0!==e.length),i.container.toggleClass("has-error",0!==_.where(e,{type:"error"}).length)}),e=function(e,t){t&&ee.section.has(t)&&ee.section(t).expanded.unbind(n),e&&ee.section(e,function(e){e.expanded.bind(n),n()})},i.section.bind(e),e(i.section.get()),i.notifications.bind("change",_.debounce(n))},renderNotifications:function(){var e,t,n=this,i=!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."),(e=n.getNotificationsContainerElement())&&e.length&&(t=[],n.notifications.each(function(e){t.push(e),"error"===e.type&&(i=!0)}),0===t.length?e.stop().slideUp("fast"):e.stop().slideDown("fast",null,function(){Z(this).css("height","auto")}),n.notificationsTemplate||(n.notificationsTemplate=wp.template("customize-control-notifications")),n.container.toggleClass("has-notifications",0!==t.length),n.container.toggleClass("has-error",i),e.empty().append(Z.trim(n.notificationsTemplate({notifications:t,altNotice:Boolean(n.altNotice)}))))},expand:function(e){ee.section(this.section()).expand(e)},focus:t,onChangeActive:function(e,t){t.unchanged?t.completeCallback&&t.completeCallback():Z.contains(document,this.container[0])?e?this.container.slideDown(t.duration,t.completeCallback):this.container.slideUp(t.duration,t.completeCallback):(this.container.toggle(e),t.completeCallback&&t.completeCallback())},toggle:function(e){return this.onChangeActive(e,this.defaultActiveArguments)},activate:a.prototype.activate,deactivate:a.prototype.deactivate,_toggleActive:a.prototype._toggleActive,dropdownInit:function(){function e(e){"string"==typeof e&&i.statuses&&i.statuses[e]?n.html(i.statuses[e]).show():n.hide()}var t=this,n=this.container.find(".dropdown-status"),i=this.params,a=!1;this.container.on("click keydown",".dropdown",function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),a||t.container.toggleClass("open"),t.container.hasClass("open")&&t.container.parent().parent().find("li.library-selected").focus(),a=!0,setTimeout(function(){a=!1},400))}),this.setting.bind(e),e(this.setting())},renderContent:function(){var e,t,n,i,a=this;t=["button","checkbox","date","datetime-local","email","month","number","password","radio","range","search","select","tel","time","text","textarea","week","url"],(n=a.templateSelector)==="customize-control-"+a.params.type+"-content"&&_.contains(t,a.params.type)&&!document.getElementById("tmpl-"+n)&&0===a.container.children().length&&(n="customize-control-default-content"),document.getElementById("tmpl-"+n)&&(e=wp.template(n))&&a.container&&a.container.html(e(a.params)),a.notifications.container=a.getNotificationsContainerElement(),(!(i=a.section())||ee.section.has(i)&&ee.section(i).expanded())&&a.notifications.render()},addNewPage:function(){var e,a,o,t,s,r,c=this;"dropdown-pages"===c.params.type&&c.params.allow_addition&&ee.Menus&&(a=c.container.find(".add-new-toggle"),o=c.container.find(".new-content-item"),t=c.container.find(".create-item-input"),s=t.val(),r=c.container.find("select"),s?(t.removeClass("invalid"),t.attr("disabled","disabled"),(e=ee.Menus.insertAutoDraftPost({post_title:s,post_type:"page"})).done(function(e){var t,n,i;t=new ee.Menus.AvailableItemModel({id:"post-"+e.post_id,title:s,type:"post_type",type_label:ee.Menus.data.l10n.page_label,object:"page",object_id:e.post_id,url:e.url}),ee.Menus.availableMenuItemsPanel.collection.add(t),n=Z("#available-menu-items-post_type-page").find(".available-menu-items-list"),i=wp.template("available-menu-item"),n.prepend(i(t.attributes)),r.focus(),c.setting.set(String(e.post_id)),o.slideUp(180),a.slideDown(180)}),e.always(function(){t.val("").removeAttr("disabled")})):t.addClass("invalid"))}}),ee.ColorControl=ee.Control.extend({ready:function(){var t,n=this,e="hue"===this.params.mode,i=!1;e?(t=this.container.find(".color-picker-hue")).val(n.setting()).wpColorPicker({change:function(e,t){i=!0,n.setting(t.color.h()),i=!1}}):(t=this.container.find(".color-picker-hex")).val(n.setting()).wpColorPicker({change:function(){i=!0,n.setting.set(t.wpColorPicker("color")),i=!1},clear:function(){i=!0,n.setting.set(""),i=!1}}),n.setting.bind(function(e){i||(t.val(e),t.wpColorPicker("color",e))}),n.container.on("keydown",function(e){27===e.which&&n.container.find(".wp-picker-container").hasClass("wp-picker-active")&&(t.wpColorPicker("close"),n.container.find(".wp-color-result").focus(),e.stopPropagation())})}}),ee.MediaControl=ee.Control.extend({ready:function(){var n=this;function e(e){var t=Z.Deferred();n.extended(ee.UploadControl)?t.resolve():(e=parseInt(e,10),_.isNaN(e)||e<=0?(delete n.params.attachment,t.resolve()):n.params.attachment&&n.params.attachment.id===e&&t.resolve()),"pending"===t.state()&&wp.media.attachment(e).fetch().done(function(){n.params.attachment=this.attributes,t.resolve(),wp.customize.previewer.send(n.setting.id+"-attachment-data",this.attributes)}),t.done(function(){n.renderContent()})}_.bindAll(n,"restoreDefault","removeFile","openFrame","select","pausePlayer"),n.container.on("click keydown",".upload-button",n.openFrame),n.container.on("click keydown",".upload-button",n.pausePlayer),n.container.on("click keydown",".thumbnail-image img",n.openFrame),n.container.on("click keydown",".default-button",n.restoreDefault),n.container.on("click keydown",".remove-button",n.pausePlayer),n.container.on("click keydown",".remove-button",n.removeFile),n.container.on("click keydown",".remove-button",n.cleanupPlayer),ee.section(n.section()).container.on("expanded",function(){n.player&&n.player.setControlsSize()}).on("collapsed",function(){n.pausePlayer()}),e(n.setting()),n.setting.bind(e)},pausePlayer:function(){this.player&&this.player.pause()},cleanupPlayer:function(){this.player&&wp.media.mixin.removePlayer(this.player)},openFrame:function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.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 e,t=this.frame.state().get("selection").first().toJSON(),n=window._wpmejsSettings||{};this.params.attachment=t,this.setting(t.id),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,n):this.cleanupPlayer()},restoreDefault:function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment=this.params.defaultAttachment,this.setting(this.params.defaultAttachment.url))},removeFile:function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent())}}),ee.UploadControl=ee.MediaControl.extend({select:function(){var e,t=this.frame.state().get("selection").first().toJSON(),n=window._wpmejsSettings||{};this.params.attachment=t,this.setting(t.url),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,n):this.cleanupPlayer()},success:function(){},removerVisibility:function(){}}),ee.ImageControl=ee.UploadControl.extend({thumbnailSrc:function(){}}),ee.BackgroundControl=ee.UploadControl.extend({ready:function(){ee.UploadControl.prototype.ready.apply(this,arguments)},select:function(){ee.UploadControl.prototype.select.apply(this,arguments),wp.ajax.post("custom-background-add",{nonce:_wpCustomizeBackground.nonces.add,wp_customize:"on",customize_theme:ee.settings.theme.stylesheet,attachment_id:this.params.attachment.id})}}),ee.BackgroundPositionControl=ee.Control.extend({ready:function(){var e,i=this;i.container.on("change",'input[name="background-position"]',function(){var e=Z(this).val().split(" ");i.settings.x(e[0]),i.settings.y(e[1])}),e=_.debounce(function(){var e,t,n;e=i.settings.x.get(),t=i.settings.y.get(),n=String(e)+" "+String(t),i.container.find('input[name="background-position"][value="'+n+'"]').click()}),i.settings.x.bind(e),i.settings.y.bind(e),e()}}),ee.CroppedImageControl=ee.MediaControl.extend({openFrame:function(e){ee.utils.isKeydownButNotEnterEvent(e)||(this.initFrame(),this.frame.setState("library").open())},initFrame:function(){var e=_wpMediaViewsL10n;this.frame=wp.media({button:{text:e.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 e=this.frame.state().get("selection").first().toJSON();this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):(this.setImageFromAttachment(e),this.frame.close())},onCropped:function(e){this.setImageFromAttachment(e)},calculateImageSelectOptions:function(e,t){var n,i,a,o=t.get("control"),s=!!parseInt(o.params.flex_width,10),r=!!parseInt(o.params.flex_height,10),c=e.get("width"),l=e.get("height"),d=parseInt(o.params.width,10),u=parseInt(o.params.height,10),p=d/u,h=d,f=u;return t.set("canSkipCrop",!o.mustBeCropped(s,r,d,u,c,l)),p<c/l?d=(u=l)*p:u=(d=c)/p,!(a={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:c,imageHeight:l,minWidth:d<h?d:h,minHeight:u<f?u:f,x1:n=(c-d)/2,y1:i=(l-u)/2,x2:d+n,y2:u+i})==r&&!1==s&&(a.aspectRatio=d+":"+u),!0==r&&(delete a.minHeight,a.maxWidth=c),!0==s&&(delete a.minWidth,a.maxHeight=l),a},mustBeCropped:function(e,t,n,i,a,o){return(!0!==e||!0!==t)&&((!0!==e||i!==o)&&((!0!==t||n!==a)&&((n!==a||i!==o)&&!(a<=n))))},onSkippedCrop:function(){var e=this.frame.state().get("selection").first().toJSON();this.setImageFromAttachment(e)},setImageFromAttachment:function(e){this.params.attachment=e,this.setting(e.id)}}),ee.SiteIconControl=ee.CroppedImageControl.extend({initFrame:function(){var e=_wpMediaViewsL10n;this.frame=wp.media({button:{text:e.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 e=this.frame.state().get("selection").first().toJSON(),t=this;this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):wp.ajax.post("crop-image",{nonce:e.nonces.edit,id:e.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(e){t.setImageFromAttachment(e),t.frame.close()}).fail(function(){t.frame.trigger("content:error:crop")})},setImageFromAttachment:function(t){var n;_.each(["site_icon-32","thumbnail","full"],function(e){n||_.isUndefined(t.sizes[e])||(n=t.sizes[e])}),this.params.attachment=t,this.setting(t.id),n&&Z('link[rel="icon"][sizes="32x32"]').attr("href",n.url)},removeFile:function(e){ee.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent(),Z('link[rel="icon"][sizes="32x32"]').attr("href","/favicon.ico"))}}),ee.HeaderControl=ee.Control.extend({ready:function(){this.btnRemove=Z("#customize-control-header_image .actions .remove"),this.btnNew=Z("#customize-control-header_image .actions .new"),_.bindAll(this,"openMedia","removeImage"),this.btnNew.on("click",this.openMedia),this.btnRemove.on("click",this.removeImage),ee.HeaderTool.currentHeader=this.getInitialHeaderImage(),new ee.HeaderTool.CurrentView({model:ee.HeaderTool.currentHeader,el:"#customize-control-header_image .current .container"}),new ee.HeaderTool.ChoiceListView({collection:ee.HeaderTool.UploadsList=new ee.HeaderTool.ChoiceList,el:"#customize-control-header_image .choices .uploaded .list"}),new ee.HeaderTool.ChoiceListView({collection:ee.HeaderTool.DefaultsList=new ee.HeaderTool.DefaultsList,el:"#customize-control-header_image .choices .default .list"}),ee.HeaderTool.combinedList=ee.HeaderTool.CombinedList=new ee.HeaderTool.CombinedList([ee.HeaderTool.UploadsList,ee.HeaderTool.DefaultsList]),wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize="on",wp.media.controller.Cropper.prototype.defaults.doCropArgs.customize_theme=ee.settings.theme.stylesheet},getInitialHeaderImage:function(){if(!ee.get().header_image||!ee.get().header_image_data||_.contains(["remove-header","random-default-image","random-uploaded-image"],ee.get().header_image))return new ee.HeaderTool.ImageModel;var e=_.find(_wpCustomizeHeader.uploads,function(e){return e.attachment_id===ee.get().header_image_data.attachment_id});return e=e||{url:ee.get().header_image,thumbnail_url:ee.get().header_image,attachment_id:ee.get().header_image_data.attachment_id},new ee.HeaderTool.ImageModel({header:e,choice:e.url.split("/").pop()})},calculateImageSelectOptions:function(e,t){var n,i,a,o,s,r,c=parseInt(_wpCustomizeHeader.data.width,10),l=parseInt(_wpCustomizeHeader.data.height,10),d=!!parseInt(_wpCustomizeHeader.data["flex-width"],10),u=!!parseInt(_wpCustomizeHeader.data["flex-height"],10);return s=e.get("width"),o=e.get("height"),this.headerImage=new ee.HeaderTool.ImageModel,this.headerImage.set({themeWidth:c,themeHeight:l,themeFlexWidth:d,themeFlexHeight:u,imageWidth:s,imageHeight:o}),t.set("canSkipCrop",!this.headerImage.shouldBeCropped()),(n=c/l)<(i=s)/(a=o)?c=(l=a)*n:l=(c=i)/n,!(r={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:s,imageHeight:o,x1:0,y1:0,x2:c,y2:l})==u&&!1==d&&(r.aspectRatio=c+":"+l),!1==u&&(r.maxHeight=l),!1==d&&(r.maxWidth=c),r},openMedia:function(e){var t=_wpMediaViewsL10n;e.preventDefault(),this.frame=wp.media({button:{text:t.selectAndCrop,close:!1},states:[new wp.media.controller.Library({title:t.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(e){var t=e.url,n=e.attachment_id,i=e.width,a=e.height;this.setImageFromURL(t,n,i,a)},onSkippedCrop:function(e){var t=e.get("url"),n=e.get("width"),i=e.get("height");this.setImageFromURL(t,e.id,n,i)},setImageFromURL:function(e,t,n,i){var a,o={};o.url=e,o.thumbnail_url=e,o.timestamp=_.now(),t&&(o.attachment_id=t),n&&(o.width=n),i&&(o.height=i),a=new ee.HeaderTool.ImageModel({header:o,choice:e.split("/").pop()}),ee.HeaderTool.UploadsList.add(a),ee.HeaderTool.currentHeader.set(a.toJSON()),a.save(),a.importImage()},removeImage:function(){ee.HeaderTool.currentHeader.trigger("hide"),ee.HeaderTool.CombinedList.trigger("control:removeImage")}}),ee.ThemeControl=ee.Control.extend({touchDrag:!1,screenshotRendered:!1,ready:function(){var n=this,e=ee.panel("themes");function t(){return!e.canSwitchTheme(n.params.theme.id)}function i(){n.container.find("button.preview, button.preview-theme").toggleClass("disabled",t()),n.container.find("button.theme-install").toggleClass("disabled",t()||!1===ee.settings.theme._canInstall||!0===ee.settings.theme._filesystemCredentialsNeeded)}ee.state("selectedChangesetStatus").bind(i),ee.state("changesetStatus").bind(i),i(),n.container.on("touchmove",".theme",function(){n.touchDrag=!0}),n.container.on("click keydown touchend",".theme",function(e){var t;if(!ee.utils.isKeydownButNotEnterEvent(e))return!0===n.touchDrag?n.touchDrag=!1:void(Z(e.target).is(".theme-actions .button, .update-theme")||(e.preventDefault(),(t=ee.section(n.section())).showDetails(n.params.theme,function(){ee.settings.theme._filesystemCredentialsNeeded&&t.overlay.find(".theme-actions .delete-theme").remove()})))}),n.container.on("render-screenshot",function(){var e=Z(this).find("img"),t=e.data("src");t&&e.attr("src",t),n.screenshotRendered=!0})},filter:function(e){var t=this,n=0,i=t.params.theme.name+" "+t.params.theme.description+" "+t.params.theme.tags+" "+t.params.theme.author+" ";return i=i.toLowerCase().replace("-"," "),_.isArray(e)||(e=[e]),t.params.theme.name.toLowerCase()===e.join(" ")?n=100:(n+=10*(i.split(e.join(" ")).length-1),_.each(e,function(e){n=(n+=2*(i.split(e+" ").length-1))+i.split(e).length-1}),99<n&&(n=99)),0!==n?(t.activate(),t.params.priority=101-n,!0):(t.deactivate(),!(t.params.priority=101))},rerenderAsInstalled:function(e){var t,n=this;e?n.params.theme.type="installed":(t=ee.section(n.params.section),n.params.theme.type=t.params.action),n.renderContent(),n.container.trigger("render-screenshot")}}),ee.CodeEditorControl=ee.Control.extend({initialize:function(e,t){var n=this;n.deferred=_.extend(n.deferred||{},{codemirror:Z.Deferred()}),ee.Control.prototype.initialize.call(n,e,t),n.notifications.bind("add",function(e){var t;e.code===n.setting.id+":csslint_error"&&(e.templateId="customize-code-editor-lint-error-notification",e.render=(t=e.render,function(){var e=t.call(this);return e.find("input[type=checkbox]").on("click",function(){n.setting.notifications.remove("csslint_error")}),e}))})},ready:function(){var i=this;i.section()?ee.section(i.section(),function(n){n.deferred.embedded.done(function(){var t;n.expanded()?i.initEditor():(t=function(e){e&&(i.initEditor(),n.expanded.unbind(t))},n.expanded.bind(t))})}):i.initEditor()},initEditor:function(){var e,t=this,n=!1;wp.codeEditor&&(_.isUndefined(t.params.editor_settings)||!1!==t.params.editor_settings)&&((n=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{}).codemirror=_.extend({},n.codemirror,{indentUnit:2,tabSize:2}),_.isObject(t.params.editor_settings)&&_.each(t.params.editor_settings,function(e,t){_.isObject(e)&&(n[t]=_.extend({},n[t],e))})),e=new ee.Element(t.container.find("textarea")),t.elements.push(e),e.sync(t.setting),e.set(t.setting()),n?t.initSyntaxHighlightingEditor(n):t.initPlainTextareaEditor()},focus:function(e){var t,n=this,i=_.extend({},e);t=i.completeCallback,i.completeCallback=function(){t&&t(),n.editor&&n.editor.codemirror.focus()},ee.Control.prototype.focus.call(n,i)},initSyntaxHighlightingEditor:function(e){var t,n=this,i=n.container.find("textarea"),a=!1;t=_.extend({},e,{onTabNext:_.bind(n.onTabNext,n),onTabPrevious:_.bind(n.onTabPrevious,n),onUpdateErrorNotice:_.bind(n.onUpdateErrorNotice,n)}),n.editor=wp.codeEditor.initialize(i,t),Z(n.editor.codemirror.display.lineDiv).attr({role:"textbox","aria-multiline":"true","aria-label":n.params.label,"aria-describedby":"editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"}),n.container.find("label").on("click",function(){n.editor.codemirror.focus()}),n.editor.codemirror.on("change",function(e){a=!0,i.val(e.getValue()).trigger("change"),a=!1}),n.setting.bind(function(e){a||n.editor.codemirror.setValue(e)}),n.editor.codemirror.on("keydown",function(e,t){27===t.keyCode&&t.stopPropagation()}),n.deferred.codemirror.resolveWith(n,[n.editor.codemirror])},onTabNext:function(){var e,t;t=(e=ee.section(this.section()).controls()).indexOf(this),e.length===t+1?Z("#customize-footer-actions .collapse-sidebar").focus():e[t+1].container.find(":focusable:first").focus()},onTabPrevious:function(){var e,t,n;0===(t=(e=(n=ee.section(this.section())).controls()).indexOf(this))?n.contentContainer.find(".customize-section-title .customize-help-toggle, .customize-section-title .customize-section-description.open .section-description-close").last().focus():e[t-1].contentContainer.find(":focusable:first").focus()},onUpdateErrorNotice:function(e){var t;this.setting.notifications.remove("csslint_error"),0!==e.length&&(t=1===e.length?ee.l10n.customCssError.singular.replace("%d","1"):ee.l10n.customCssError.plural.replace("%d",String(e.length)),this.setting.notifications.add(new ee.Notification("csslint_error",{message:t,type:"error"})))},initPlainTextareaEditor:function(){var a=this.container.find("textarea"),o=a[0];a.on("blur",function(){a.data("next-tab-blurs",!1)}),a.on("keydown",function(e){var t,n,i;27!==e.keyCode?9!==e.keyCode||e.ctrlKey||e.altKey||e.shiftKey||a.data("next-tab-blurs")||(t=o.selectionStart,n=o.selectionEnd,i=o.value,0<=t&&(o.value=i.substring(0,t).concat("\t",i.substring(n)),a.selectionStart=o.selectionEnd=t+1),e.stopPropagation(),e.preventDefault()):a.data("next-tab-blurs")||(a.data("next-tab-blurs",!0),e.stopPropagation())}),this.deferred.codemirror.rejectWith(this)}}),ee.DateTimeControl=ee.Control.extend({ready:function(){var i=this;if(i.inputElements={},i.invalidDate=!1,_.bindAll(i,"populateSetting","updateDaysForMonth","populateDateInputs"),!i.setting)throw new Error("Missing setting");i.container.find(".date-input").each(function(){var e,t,n=Z(this);e=n.data("component"),t=new ee.Element(n),i.inputElements[e]=t,i.elements.push(t),n.on("change",function(){i.invalidDate&&i.notifications.add(new ee.Notification("invalid_date",{message:ee.l10n.invalidDate}))}),n.on("input",_.debounce(function(){i.invalidDate||i.notifications.remove("invalid_date")})),n.on("blur",_.debounce(function(){i.invalidDate||i.populateDateInputs()}))}),i.inputElements.month.bind(i.updateDaysForMonth),i.inputElements.year.bind(i.updateDaysForMonth),i.populateDateInputs(),i.setting.bind(i.populateDateInputs),_.each(i.inputElements,function(e){e.bind(i.populateSetting)})},parseDateTime:function(e){var t,n;return e&&(t=e.match(/^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/)),t?(t.shift(),n={year:t.shift(),month:t.shift(),day:t.shift(),hour:t.shift()||"00",minute:t.shift()||"00",second:t.shift()||"00"},this.params.includeTime&&this.params.twelveHourFormat&&(n.hour=parseInt(n.hour,10),n.meridian=12<=n.hour?"pm":"am",n.hour=n.hour%12?String(n.hour%12):String(12),delete n.second),n):null},validateInputs:function(){var e,o,s=this;return s.invalidDate=!1,e=["year","day"],s.params.includeTime&&e.push("hour","minute"),_.find(e,function(e){var t,n,i,a;return t=s.inputElements[e],o=t.element.get(0),n=parseInt(t.element.attr("max"),10),i=parseInt(t.element.attr("min"),10),a=parseInt(t(),10),s.invalidDate=isNaN(a)||n<a||a<i,s.invalidDate||o.setCustomValidity(""),s.invalidDate}),s.inputElements.meridian&&!s.invalidDate&&(o=s.inputElements.meridian.element.get(0),"am"!==s.inputElements.meridian.get()&&"pm"!==s.inputElements.meridian.get()?s.invalidDate=!0:o.setCustomValidity("")),s.invalidDate?o.setCustomValidity(ee.l10n.invalidValue):o.setCustomValidity(""),(!s.section()||ee.section.has(s.section())&&ee.section(s.section()).expanded())&&_.result(o,"reportValidity"),s.invalidDate},updateDaysForMonth:function(){var e,t,n,i,a=this;n=parseInt(a.inputElements.month(),10),t=parseInt(a.inputElements.year(),10),i=parseInt(a.inputElements.day(),10),n&&t&&(e=new Date(t,n,0).getDate(),a.inputElements.day.element.attr("max",e),e<i&&a.inputElements.day(String(e)))},populateSetting:function(){var e,t=this;return!(t.validateInputs()||!t.params.allowPastDate&&!t.isFutureDate())&&(e=t.convertInputDateToString(),t.setting.set(e),!0)},convertInputDateToString:function(){var e,t,n,i,a=this,o="";return i=function(e,t){var n;return String(e).length<t&&(n=t-String(e).length,e=Math.pow(10,n).toString().substr(1)+String(e)),e},n=function(e){var t=parseInt(a.inputElements[e].get(),10);return _.contains(["month","day","hour","minute"],e)?t=i(t,2):"year"===e&&(t=i(t,4)),t},e=["year","-","month","-","day"],a.params.includeTime&&(t=a.inputElements.meridian?a.convertHourToTwentyFourHourFormat(a.inputElements.hour(),a.inputElements.meridian()):a.inputElements.hour(),e=e.concat([" ",i(t,2),":","minute",":","00"])),_.each(e,function(e){o+=a.inputElements[e]?n(e):e}),o},isFutureDate:function(){return 0<ee.utils.getRemainingTime(this.convertInputDateToString())},convertHourToTwentyFourHourFormat:function(e,t){var n,i;return i=parseInt(e,10),isNaN(i)?"":(n="pm"===t&&i<12?i+12:"am"===t&&12===i?i-12:i,String(n))},populateDateInputs:function(){var i;return!!(i=this.parseDateTime(this.setting.get()))&&(_.each(this.inputElements,function(e,t){var n=i[t];"month"===t||"meridian"===t?(n=n.replace(/^0/,""),e.set(n)):(n=parseInt(n,10),e.element.is(document.activeElement)?n!==parseInt(e(),10)&&e.set(String(n)):e.set(i[t]))}),!0)},toggleFutureDateNotification:function(e){var t,n;return t="not_future_date",e?(n=new ee.Notification(t,{type:"error",message:ee.l10n.futureDateError}),this.notifications.add(n)):this.notifications.remove(t),this}}),ee.PreviewLinkControl=ee.Control.extend({defaults:_.extend({},ee.Control.prototype.defaults,{templateId:"customize-preview-link-control"}),ready:function(){var e,t,n,i,a,o,s=this;_.bindAll(s,"updatePreviewLink"),s.setting||(s.setting=new ee.Value),s.previewElements={},s.container.find(".preview-control-element").each(function(){n=Z(this),t=n.data("component"),e=new ee.Element(n),s.previewElements[t]=e,s.elements.push(e)}),i=s.previewElements.url,a=s.previewElements.input,o=s.previewElements.button,a.link(s.setting),i.link(s.setting),i.bind(function(e){i.element.parent().attr({href:e,target:ee.settings.changeset.uuid})}),ee.bind("ready",s.updatePreviewLink),ee.state("saved").bind(s.updatePreviewLink),ee.state("changesetStatus").bind(s.updatePreviewLink),ee.state("activated").bind(s.updatePreviewLink),ee.previewer.previewUrl.bind(s.updatePreviewLink),o.element.on("click",function(e){e.preventDefault(),s.setting()&&(a.element.select(),document.execCommand("copy"),o(o.element.data("copied-text")))}),i.element.parent().on("click",function(e){Z(this).hasClass("disabled")&&e.preventDefault()}),o.element.on("mouseenter",function(){s.setting()&&o(o.element.data("copy-text"))})},updatePreviewLink:function(){var e;e=!ee.state("saved").get()||""===ee.state("changesetStatus").get()||"auto-draft"===ee.state("changesetStatus").get(),this.toggleSaveNotification(e),this.previewElements.url.element.parent().toggleClass("disabled",e),this.previewElements.button.element.prop("disabled",e),this.setting.set(ee.previewer.getFrontendPreviewUrl())},toggleSaveNotification:function(e){var t,n;t="changes_not_saved",e?(n=new ee.Notification(t,{type:"info",message:ee.l10n.saveBeforeShare}),this.notifications.add(n)):this.notifications.remove(t)}}),ee.defaultConstructor=ee.Setting,ee.control=new ee.Values({defaultConstructor:ee.Control}),ee.section=new ee.Values({defaultConstructor:ee.Section}),ee.panel=new ee.Values({defaultConstructor:ee.Panel}),ee.notifications=new ee.Notifications,ee.PreviewFrame=ee.Messenger.extend({sensitivity:null,initialize:function(e,t){var n=Z.Deferred();n.promise(this),this.container=e.container,Z.extend(e,{channel:ee.PreviewFrame.uuid()}),ee.Messenger.prototype.initialize.call(this,e,t),this.add("previewUrl",e.previewUrl),this.query=Z.extend(e.query||{},{customize_messenger_channel:this.channel()}),this.run(n)},run:function(t){var e,n,i,a=this,o=!1,s=!1,r=null,c="{}"!==a.query.customized;a._ready&&a.unbind("ready",a._ready),a._ready=function(e){s=!0,r=e,a.container.addClass("iframe-ready"),e&&o&&t.resolveWith(a,[e])},a.bind("ready",a._ready),(e=document.createElement("a")).href=a.previewUrl(),n=_.extend(ee.utils.parseQueryString(e.search.substr(1)),{customize_changeset_uuid:a.query.customize_changeset_uuid,customize_theme:a.query.customize_theme,customize_messenger_channel:a.query.customize_messenger_channel}),!ee.settings.changeset.autosaved&&ee.state("saved").get()||(n.customize_autosaved="on"),e.search=Z.param(n),a.iframe=Z("<iframe />",{title:ee.l10n.previewIframeTitle,name:"customize-"+a.channel()}),a.iframe.attr("onmousewheel",""),a.iframe.attr("sandbox","allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts"),c?a.iframe.attr("data-src",e.href):a.iframe.attr("src",e.href),a.iframe.appendTo(a.container),a.targetWindow(a.iframe[0].contentWindow),c&&((i=Z("<form>",{action:e.href,target:a.iframe.attr("name"),method:"post",hidden:"hidden"})).append(Z("<input>",{type:"hidden",name:"_method",value:"GET"})),_.each(a.query,function(e,t){i.append(Z("<input>",{type:"hidden",name:t,value:e}))}),a.container.append(i),i.submit(),i.remove()),a.bind("iframe-loading-error",function(e){a.iframe.remove(),0!==e?-1!==e?t.rejectWith(a,["request failure"]):t.rejectWith(a,["cheatin"]):a.login(t)}),a.iframe.one("load",function(){o=!0,s?t.resolveWith(a,[r]):setTimeout(function(){t.rejectWith(a,["ready timeout"])},a.sensitivity)})},login:function(n){var i,a=this;if(i=function(){n.rejectWith(a,["logged out"])},this.triedLogin)return i();Z.get(ee.settings.url.ajax,{action:"logged-in"}).fail(i).done(function(e){var t;"1"!==e&&i(),(t=Z("<iframe />",{src:a.previewUrl(),title:ee.l10n.previewIframeTitle}).hide()).appendTo(a.container),t.on("load",function(){a.triedLogin=!0,t.remove(),a.run(n)})})},destroy:function(){ee.Messenger.prototype.destroy.call(this),this.iframe&&this.iframe.remove(),delete this.iframe,delete this.targetWindow}}),r=0,ee.PreviewFrame.uuid=function(){return"preview-"+String(r++)},ee.setDocumentTitle=function(e){var t;t=ee.settings.documentTitleTmpl.replace("%s",e),document.title=t,ee.trigger("title",t)},ee.Previewer=ee.Messenger.extend({refreshBuffer:null,initialize:function(e,t){var n,s=this,i=document.createElement("a");Z.extend(s,t||{}),s.deferred={active:Z.Deferred()},s.refresh=_.debounce((n=s.refresh,function(){var e,t;(e=function(){return 0===ee.state("processing").get()})()?n.call(s):(t=function(){e()&&(n.call(s),ee.state("processing").unbind(t))},ee.state("processing").bind(t))}),s.refreshBuffer),s.container=ee.ensure(e.container),s.allowedUrls=e.allowedUrls,e.url=window.location.href,ee.Messenger.prototype.initialize.call(s,e),i.href=s.origin(),s.add("scheme",i.protocol.replace(/:$/,"")),s.add("previewUrl",e.previewUrl).setter(function(e){var n,t,i,a=null,o=[];return(n=document.createElement("a")).href=e,/\/wp-(admin|includes|content)(\/|$)/.test(n.pathname)?null:(1<n.search.length&&(delete(t=ee.utils.parseQueryString(n.search.substr(1))).customize_changeset_uuid,delete t.customize_theme,delete t.customize_messenger_channel,delete t.customize_autosaved,_.isEmpty(t)?n.search="":n.search=Z.param(t)),o.push(n),s.scheme.get()+":"!==n.protocol&&((n=document.createElement("a")).href=o[0].href,n.protocol=s.scheme.get()+":",o.unshift(n)),i=document.createElement("a"),_.find(o,function(t){return!_.isUndefined(_.find(s.allowedUrls,function(e){if(i.href=e,n.protocol===i.protocol&&n.host===i.host&&0===n.pathname.indexOf(i.pathname.replace(/\/$/,"")))return a=t.href,!0}))}),a)}),s.bind("ready",s.ready),s.deferred.active.done(_.bind(s.keepPreviewAlive,s)),s.bind("synced",function(){s.send("active")}),s.previewUrl.bind(s.refresh),s.scroll=0,s.bind("scroll",function(e){s.scroll=e}),s.bind("url",function(e){var t,n=!1;s.scroll=0,t=function(){n=!0},s.previewUrl.bind(t),s.previewUrl.set(e),s.previewUrl.unbind(t),n||s.refresh()}),s.bind("documentTitle",function(e){ee.setDocumentTitle(e)})},ready:function(e){var t,n=this,i={};i.settings=ee.get(),i["settings-modified-while-loading"]=n.settingsModifiedWhileLoading,"resolved"===n.deferred.active.state()&&!n.loading||(i.scroll=n.scroll),i["edit-shortcut-visibility"]=ee.state("editShortcutVisibility").get(),n.send("sync",i),e.currentUrl&&(n.previewUrl.unbind(n.refresh),n.previewUrl.set(e.currentUrl),n.previewUrl.bind(n.refresh)),t={panel:e.activePanels,section:e.activeSections,control:e.activeControls},_(t).each(function(n,i){ee[i].each(function(e,t){_.isUndefined(ee.settings[i+"s"][t])&&_.isUndefined(n[t])||(n[t]?e.activate():e.deactivate())})}),e.settingValidities&&ee._handleSettingValidities({settingValidities:e.settingValidities,focusInvalidControl:!1})},keepPreviewAlive:function(){var e,t,n,i;i=function(){t=setTimeout(n,ee.settings.timeouts.keepAliveCheck)},e=function(){ee.state("previewerAlive").set(!0),clearTimeout(t),i()},n=function(){ee.state("previewerAlive").set(!1)},i(),this.bind("ready",e),this.bind("keep-alive",e)},query:function(){},abort:function(){this.loading&&(this.loading.destroy(),delete this.loading)},refresh:function(){var e,i=this;i.send("loading-initiated"),i.abort(),i.loading=new ee.PreviewFrame({url:i.url(),previewUrl:i.previewUrl(),query:i.query({excludeCustomizedSaved:!0})||{},container:i.container}),i.settingsModifiedWhileLoading={},e=function(e){i.settingsModifiedWhileLoading[e.id]=!0},ee.bind("change",e),i.loading.always(function(){ee.unbind("change",e)}),i.loading.done(function(e){var t,n=this;i.preview=n,i.targetWindow(n.targetWindow()),i.channel(n.channel()),t=function(){n.unbind("synced",t),i._previousPreview&&i._previousPreview.destroy(),i._previousPreview=i.preview,i.deferred.active.resolve(),delete i.loading},n.bind("synced",t),i.trigger("ready",e)}),i.loading.fail(function(e){i.send("loading-failed"),"logged out"===e&&(i.preview&&(i.preview.destroy(),delete i.preview),i.login().done(i.refresh)),"cheatin"===e&&i.cheatin()})},login:function(){var t,n,i,a=this;return this._login||(t=Z.Deferred(),this._login=t.promise(),n=new ee.Messenger({channel:"login",url:ee.settings.url.login}),i=Z("<iframe />",{src:ee.settings.url.login,title:ee.l10n.loginIframeTitle}).appendTo(this.container),n.targetWindow(i[0].contentWindow),n.bind("login",function(){var e=a.refreshNonces();e.always(function(){i.remove(),n.destroy(),delete a._login}),e.done(function(){t.resolve()}),e.fail(function(){a.cheatin(),t.reject()})})),this._login},cheatin:function(){Z(document.body).empty().addClass("cheatin").append("<h1>"+ee.l10n.notAllowedHeading+"</h1><p>"+ee.l10n.notAllowed+"</p>")},refreshNonces:function(){var e,t=Z.Deferred();return t.promise(),(e=wp.ajax.post("customize_refresh_nonces",{wp_customize:"on",customize_theme:ee.settings.theme.stylesheet})).done(function(e){ee.trigger("nonce-refresh",e),t.resolve()}),e.fail(function(){t.reject()}),t}}),ee.settingConstructor={},ee.controlConstructor={color:ee.ColorControl,media:ee.MediaControl,upload:ee.UploadControl,image:ee.ImageControl,cropped_image:ee.CroppedImageControl,site_icon:ee.SiteIconControl,header:ee.HeaderControl,background:ee.BackgroundControl,background_position:ee.BackgroundPositionControl,theme:ee.ThemeControl,date_time:ee.DateTimeControl,code_editor:ee.CodeEditorControl},ee.panelConstructor={themes:ee.ThemesPanel},ee.sectionConstructor={themes:ee.ThemesSection,outer:ee.OuterSection},ee._handleSettingValidities=function(e){var t,s=[],n=!1;_.each(e.settingValidities,function(t,e){var o=ee(e);o&&(_.isObject(t)&&_.each(t,function(e,t){var n,i,a=!1;n=new ee.Notification(t,_.extend({fromServer:!0},e)),(i=o.notifications(n.code))&&(a=n.type!==i.type||n.message!==i.message||!_.isEqual(n.data,i.data)),a&&o.notifications.remove(t),o.notifications.has(n.code)||o.notifications.add(n),s.push(o.id)}),o.notifications.each(function(e){!e.fromServer||"error"!==e.type||!0!==t&&t[e.code]||o.notifications.remove(e.code)}))}),e.focusInvalidControl&&(t=ee.findControlsForSettings(s),_(_.values(t)).find(function(e){return _(e).find(function(e){var t=e.section()&&ee.section.has(e.section())&&ee.section(e.section()).expanded();return t&&e.expanded&&(t=e.expanded()),t&&(e.focus(),n=!0),n})}),n||_.isEmpty(t)||_.values(t)[0][0].focus())},ee.findControlsForSettings=function(e){var n,i={};return _.each(_.unique(e),function(e){var t=ee(e);t&&(n=t.findControls())&&0<n.length&&(i[e]=n)}),i},ee.reflowPaneContents=_.bind(function(){var i,e,t,a=[],o=!1;document.activeElement&&(e=Z(document.activeElement)),ee.panel.each(function(e){if("themes"!==e.id){var t=e.sections(),n=_.pluck(t,"headContainer");a.push(e),i=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),ee.utils.areElementListsEqual(n,i.children("[id]"))||(_(t).each(function(e){i.append(e.headContainer)}),o=!0)}}),ee.section.each(function(e){var t=e.controls(),n=_.pluck(t,"container");e.panel()||a.push(e),i=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),ee.utils.areElementListsEqual(n,i.children("[id]"))||(_(t).each(function(e){i.append(e.container)}),o=!0)}),a.sort(ee.utils.prioritySort),t=_.pluck(a,"headContainer"),i=Z("#customize-theme-controls .customize-pane-parent"),ee.utils.areElementListsEqual(t,i.children())||(_(a).each(function(e){i.append(e.headContainer)}),o=!0),ee.panel.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),ee.section.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),o&&e&&e.focus(),ee.trigger("pane-contents-reflowed")},ee),ee.state=new ee.Values,_.each(["saved","saving","trashing","activated","processing","paneVisible","expandedPanel","expandedSection","changesetDate","selectedChangesetDate","changesetStatus","selectedChangesetStatus","remainingTimeToPublish","previewerAlive","editShortcutVisibility","changesetLocked","previewedDevice"],function(e){ee.state.create(e)}),Z(function(){if(ee.settings=window._wpCustomizeSettings,ee.l10n=window._wpCustomizeControlsL10n,ee.settings&&Z.support.postMessage&&(Z.support.cors||!ee.settings.isCrossDomain)){null===ee.PreviewFrame.prototype.sensitivity&&(ee.PreviewFrame.prototype.sensitivity=ee.settings.timeouts.previewFrameSensitivity),null===ee.Previewer.prototype.refreshBuffer&&(ee.Previewer.prototype.refreshBuffer=ee.settings.timeouts.windowRefresh);var m,t,n,e,i,a,o,s,r,c,l,d,u,p,h,f,g,v,w,b,C,y,x,k,z,S,T,E,D,P,N,I,U,A,F,V,H,L,M=Z(document.body),O=M.children(".wp-full-overlay"),j=Z("#customize-info .panel-title.site-title"),R=Z(".customize-controls-close"),B=Z("#save"),W=Z("#customize-save-button-wrapper"),q=Z("#publish-settings"),Q=Z("#customize-footer-actions");ee.bind("ready",function(){ee.section.add(new ee.OuterSection("publish_settings",{title:ee.l10n.publishSettings,priority:0,active:ee.settings.theme.active}))}),ee.section("publish_settings",function(t){var e,n,i,a,o,s,r,c,l,d,u;function p(){u=u||ee.utils.highlightButton(W,{delay:1e3,focusTarget:B})}function h(){u&&(u(),u=null)}n=new ee.Control("trash_changeset",{type:"button",section:t.id,priority:30,input_attrs:{class:"button-link button-link-delete",value:ee.l10n.discardChanges}}),ee.control.add(n),n.deferred.embedded.done(function(){n.container.find(".button-link").on("click",function(){confirm(ee.l10n.trashConfirm)&&wp.customize.previewer.trash()})}),ee.control.add(new ee.PreviewLinkControl("changeset_preview_link",{section:t.id,priority:100})),a=function(){return!!ee.state("activated").get()&&(!ee.state("trashing").get()&&"trash"!==ee.state("changesetStatus").get()&&(""!==ee.state("changesetStatus").get()||!ee.state("saved").get()))},t.active.validate=a,i=function(){t.active.set(a())},ee.state("activated").bind(i),ee.state("trashing").bind(i),ee.state("saved").bind(i),ee.state("changesetStatus").bind(i),i(),(e=function(){q.toggle(t.active.get()),B.toggleClass("has-next-sibling",t.active.get())})(),t.active.bind(e),ee.state("selectedChangesetStatus").bind(h),t.contentContainer.find(".customize-action").text(ee.l10n.updating),t.contentContainer.find(".customize-section-back").removeAttr("tabindex"),q.prop("disabled",!1),q.on("click",function(e){e.preventDefault(),t.expanded.set(!t.expanded.get())}),t.expanded.bind(function(e){var t;q.attr("aria-expanded",String(e)),q.toggleClass("active",e),e?h():(""!==(t=ee.state("changesetStatus").get())&&"auto-draft"!==t||(t="publish"),ee.state("selectedChangesetStatus").get()!==t?p():"future"===ee.state("selectedChangesetStatus").get()&&ee.state("selectedChangesetDate").get()!==ee.state("changesetDate").get()&&p())}),o=new ee.Control("changeset_status",{priority:10,type:"radio",section:"publish_settings",setting:ee.state("selectedChangesetStatus"),templateId:"customize-selected-changeset-status-control",label:ee.l10n.action,choices:ee.settings.changeset.statusChoices}),ee.control.add(o),(s=new ee.DateTimeControl("changeset_scheduled_date",{priority:20,section:"publish_settings",setting:ee.state("selectedChangesetDate"),minYear:(new Date).getFullYear(),allowPastDate:!1,includeTime:!0,twelveHourFormat:/a/i.test(ee.settings.timeFormat),description:ee.l10n.scheduleDescription})).notifications.alt=!0,ee.control.add(s),c=function(){ee.state("selectedChangesetStatus").set("publish"),ee.previewer.save()},d=function(){var e="future"===ee.state("changesetStatus").get()&&"future"===ee.state("selectedChangesetStatus").get()&&ee.state("changesetDate").get()&&ee.state("selectedChangesetDate").get()===ee.state("changesetDate").get()&&0<=ee.utils.getRemainingTime(ee.state("changesetDate").get());e&&!l?l=setInterval(function(){var e=ee.utils.getRemainingTime(ee.state("changesetDate").get());ee.state("remainingTimeToPublish").set(e),e<=0&&(clearInterval(l),l=0,c())},1e3):!e&&l&&(clearInterval(l),l=0)},ee.state("changesetDate").bind(d),ee.state("selectedChangesetDate").bind(d),ee.state("changesetStatus").bind(d),ee.state("selectedChangesetStatus").bind(d),d(),s.active.validate=function(){return"future"===ee.state("selectedChangesetStatus").get()},(r=function(e){s.active.set("future"===e)})(ee.state("selectedChangesetStatus").get()),ee.state("selectedChangesetStatus").bind(r),ee.state("saving").bind(function(e){e&&"future"===ee.state("selectedChangesetStatus").get()&&s.toggleFutureDateNotification(!s.isFutureDate())})}),Z("#customize-controls").on("keydown",function(e){var t=13===e.which,n=Z(e.target);t&&(n.is("input:not([type=button])")||n.is("select"))&&e.preventDefault()}),Z(".customize-info").find("> .accordion-section-title .customize-help-toggle").on("click",function(){var e=Z(this).closest(".accordion-section"),t=e.find(".customize-panel-description:first");e.hasClass("cannot-expand")||(e.hasClass("open")?(e.toggleClass("open"),t.slideUp(ee.Panel.prototype.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),Z(this).attr("aria-expanded",!1)):(t.slideDown(ee.Panel.prototype.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),e.toggleClass("open"),Z(this).attr("aria-expanded",!0)))}),ee.previewer=new ee.Previewer({container:"#customize-preview",form:"#customize-controls",previewUrl:ee.settings.url.preview,allowedUrls:ee.settings.url.allowed},{nonce:ee.settings.nonce,query:function(e){var t={wp_customize:"on",customize_theme:ee.settings.theme.stylesheet,nonce:this.nonce.preview,customize_changeset_uuid:ee.settings.changeset.uuid};return!ee.settings.changeset.autosaved&&ee.state("saved").get()||(t.customize_autosaved="on"),t.customized=JSON.stringify(ee.dirtyValues({unsaved:e&&e.excludeCustomizedSaved})),t},save:function(o){var e,t,s=this,r=Z.Deferred(),c=ee.state("selectedChangesetStatus").get(),l=ee.state("selectedChangesetDate").get(),n=ee.state("processing"),d={},u=[],p=[],h=[];function f(e){d[e.id]=!0}return o&&o.status&&(c=o.status),ee.state("saving").get()&&(r.reject("already_saving"),r.promise()),ee.state("saving").set(!0),t=function(){var e,t,n={},i=ee._latestRevision,a="client_side_error";if(ee.bind("change",f),ee.notifications.remove(a),ee.each(function(t){t.notifications.each(function(e){"error"!==e.type||e.fromServer||(u.push(t.id),n[t.id]||(n[t.id]={}),n[t.id][e.code]=e)})}),ee.control.each(function(t){t.setting&&(t.setting.id||!t.active.get())||t.notifications.each(function(e){"error"===e.type&&h.push([t])})}),p=_.union(h,_.values(ee.findControlsForSettings(u))),!_.isEmpty(p))return p[0][0].focus(),ee.unbind("change",f),u.length&&ee.notifications.add(new ee.Notification(a,{message:(1===u.length?ee.l10n.saveBlockedError.singular:ee.l10n.saveBlockedError.plural).replace(/%s/g,String(u.length)),type:"error",dismissible:!0,saveFailure:!0})),r.rejectWith(s,[{setting_invalidities:n}]),ee.state("saving").set(!1),r.promise();t=Z.extend(s.query({excludeCustomizedSaved:!1}),{nonce:s.nonce.save,customize_changeset_status:c}),o&&o.date?t.customize_changeset_date=o.date:"future"===c&&l&&(t.customize_changeset_date=l),o&&o.title&&(t.customize_changeset_title=o.title),ee.trigger("save-request-params",t),e=wp.ajax.post("customize_save",t),ee.state("processing").set(ee.state("processing").get()+1),ee.trigger("save",e),e.always(function(){ee.state("processing").set(ee.state("processing").get()-1),ee.state("saving").set(!1),ee.unbind("change",f)}),ee.notifications.each(function(e){e.saveFailure&&ee.notifications.remove(e.code)}),e.fail(function(e){var t,n;n={type:"error",dismissible:!0,fromServer:!0,saveFailure:!0},"0"===e?e="not_logged_in":"-1"===e&&(e="invalid_nonce"),"invalid_nonce"===e?s.cheatin():"not_logged_in"===e?(s.preview.iframe.hide(),s.login().done(function(){s.save(),s.preview.iframe.show()})):e.code?"not_future_date"===e.code&&ee.section.has("publish_settings")&&ee.section("publish_settings").active.get()&&ee.control.has("changeset_scheduled_date")?ee.control("changeset_scheduled_date").toggleFutureDateNotification(!0).focus():"changeset_locked"!==e.code&&(t=new ee.Notification(e.code,_.extend(n,{message:e.message}))):t=new ee.Notification("unknown_error",_.extend(n,{message:ee.l10n.unknownRequestFail})),t&&ee.notifications.add(t),e.setting_validities&&ee._handleSettingValidities({settingValidities:e.setting_validities,focusInvalidControl:!0}),r.rejectWith(s,[e]),ee.trigger("error",e),"changeset_already_published"===e.code&&e.next_changeset_uuid&&(ee.settings.changeset.uuid=e.next_changeset_uuid,ee.state("changesetStatus").set(""),ee.settings.changeset.branching&&m.send("changeset-uuid",ee.settings.changeset.uuid),ee.previewer.send("changeset-uuid",ee.settings.changeset.uuid))}),e.done(function(e){s.send("saved",e),ee.state("changesetStatus").set(e.changeset_status),e.changeset_date&&ee.state("changesetDate").set(e.changeset_date),"publish"===e.changeset_status&&(ee.each(function(e){e._dirty&&(_.isUndefined(ee._latestSettingRevisions[e.id])||ee._latestSettingRevisions[e.id]<=i)&&(e._dirty=!1)}),ee.state("changesetStatus").set(""),ee.settings.changeset.uuid=e.next_changeset_uuid,ee.settings.changeset.branching&&m.send("changeset-uuid",ee.settings.changeset.uuid)),ee._lastSavedRevision=Math.max(i,ee._lastSavedRevision),e.setting_validities&&ee._handleSettingValidities({settingValidities:e.setting_validities,focusInvalidControl:!0}),r.resolveWith(s,[e]),ee.trigger("saved",e),_.isEmpty(d)||ee.state("saved").set(!1)})},0===n()?t():(e=function(){0===n()&&(ee.state.unbind("change",e),t())},ee.state.bind("change",e)),r.promise()},trash:function(){var e,n,i;ee.state("trashing").set(!0),ee.state("processing").set(ee.state("processing").get()+1),e=wp.ajax.post("customize_trash",{customize_changeset_uuid:ee.settings.changeset.uuid,nonce:ee.settings.nonce.trash}),ee.notifications.add(new ee.OverlayNotification("changeset_trashing",{type:"info",message:ee.l10n.revertingChanges,loading:!0})),n=function(){var e,t=document.createElement("a");ee.state("changesetStatus").set("trash"),ee.each(function(e){e._dirty=!1}),ee.state("saved").set(!0),t.href=location.href,delete(e=ee.utils.parseQueryString(t.search.substr(1))).changeset_uuid,e.return=ee.settings.url.return,t.search=Z.param(e),location.replace(t.href)},i=function(e,t){var n=e||"unknown_error";ee.state("processing").set(ee.state("processing").get()-1),ee.state("trashing").set(!1),ee.notifications.remove("changeset_trashing"),ee.notifications.add(new ee.Notification(n,{message:t||ee.l10n.unknownError,dismissible:!0,type:"error"}))},e.done(function(e){n(e.message)}),e.fail(function(e){var t=e.code||"trashing_failed";e.success||"non_existent_changeset"===t||"changeset_already_trashed"===t?n(e.message):i(t,e.message)})},getFrontendPreviewUrl:function(){var e,t;return(t=document.createElement("a")).href=this.previewUrl.get(),e=ee.utils.parseQueryString(t.search.substr(1)),ee.state("changesetStatus").get()&&"publish"!==ee.state("changesetStatus").get()&&(e.customize_changeset_uuid=ee.settings.changeset.uuid),ee.state("activated").get()||(e.customize_theme=ee.settings.theme.stylesheet),t.search=Z.param(e),t.href}}),Z.ajaxPrefilter(function(e){/wp_customize=on/.test(e.data)&&(e.data+="&"+Z.param({customize_preview_nonce:ee.settings.nonce.preview}))}),ee.previewer.bind("nonce",function(e){Z.extend(this.nonce,e)}),ee.bind("nonce-refresh",function(e){Z.extend(ee.settings.nonce,e),Z.extend(ee.previewer.nonce,e),ee.previewer.send("nonce-refresh",e)}),Z.each(ee.settings.settings,function(e,t){var n=ee.settingConstructor[t.type]||ee.Setting;ee.add(new n(e,t.value,{transport:t.transport,previewer:ee.previewer,dirty:!!t.dirty}))}),Z.each(ee.settings.panels,function(e,t){var n,i=ee.panelConstructor[t.type]||ee.Panel;n=_.extend({params:t},t),ee.panel.add(new i(e,n))}),Z.each(ee.settings.sections,function(e,t){var n,i=ee.sectionConstructor[t.type]||ee.Section;n=_.extend({params:t},t),ee.section.add(new i(e,n))}),Z.each(ee.settings.controls,function(e,t){var n,i=ee.controlConstructor[t.type]||ee.Control;n=_.extend({params:t},t),ee.control.add(new i(e,n))}),_.each(["panel","section","control"],function(e){var t=ee.settings.autofocus[e];t&&ee[e](t,function(e){e.deferred.embedded.done(function(){ee.previewer.deferred.active.done(function(){e.focus()})})})}),ee.bind("ready",ee.reflowPaneContents),Z([ee.panel,ee.section,ee.control]).each(function(e,t){var n=_.debounce(ee.reflowPaneContents,ee.settings.timeouts.reflowPaneContents);t.bind("add",n),t.bind("change",n),t.bind("remove",n)}),ee.bind("ready",function(){var e,t,n;ee.notifications.container=Z("#customize-notifications-area"),ee.notifications.bind("change",_.debounce(function(){ee.notifications.render()})),e=Z(".wp-full-overlay-sidebar-content"),ee.notifications.bind("rendered",function(){e.css("top",""),0!==ee.notifications.count()&&(t=ee.notifications.container.outerHeight()+1,n=parseInt(e.css("top"),10),e.css("top",n+t+"px")),ee.notifications.trigger("sidebarTopUpdated")}),ee.notifications.render()}),t=ee.state,i=t.instance("saved"),a=t.instance("saving"),o=t.instance("trashing"),s=t.instance("activated"),r=t.instance("processing"),c=t.instance("paneVisible"),l=t.instance("expandedPanel"),d=t.instance("expandedSection"),u=t.instance("changesetStatus"),p=t.instance("selectedChangesetStatus"),h=t.instance("changesetDate"),f=t.instance("selectedChangesetDate"),g=t.instance("previewerAlive"),v=t.instance("editShortcutVisibility"),w=t.instance("changesetLocked"),t.bind("change",function(){var e;s()?""===u.get()&&i()?(ee.settings.changeset.currentUserCanPublish?B.val(ee.l10n.published):B.val(ee.l10n.saved),R.find(".screen-reader-text").text(ee.l10n.close)):("draft"===p()?i()&&p()===u()?B.val(ee.l10n.draftSaved):B.val(ee.l10n.saveDraft):"future"===p()?i()&&p()===u()?h.get()!==f.get()?B.val(ee.l10n.schedule):B.val(ee.l10n.scheduled):B.val(ee.l10n.schedule):ee.settings.changeset.currentUserCanPublish&&B.val(ee.l10n.publish),R.find(".screen-reader-text").text(ee.l10n.cancel)):(B.val(ee.l10n.activate),R.find(".screen-reader-text").text(ee.l10n.cancel)),e=!a()&&!o()&&!w()&&(!s()||!i()||u()!==p()&&""!==u()||"future"===p()&&h.get()!==f.get()),B.prop("disabled",!e)}),p.validate=function(e){return""===e||"auto-draft"===e?null:e},e=ee.settings.changeset.currentUserCanPublish?"publish":"draft",u(ee.settings.changeset.status),w(Boolean(ee.settings.changeset.lockUser)),h(ee.settings.changeset.publishDate),f(ee.settings.changeset.publishDate),p(""===ee.settings.changeset.status||"auto-draft"===ee.settings.changeset.status?e:ee.settings.changeset.status),p.link(u),i(!0),""===u()&&ee.each(function(e){e._dirty&&i(!1)}),a(!1),s(ee.settings.theme.active),r(0),c(!0),l(!1),d(!1),g(!0),v("visible"),ee.bind("change",function(){t("saved").get()&&t("saved").set(!1)}),ee.settings.changeset.branching&&i.bind(function(e){e||n(!0)}),a.bind(function(e){M.toggleClass("saving",e)}),o.bind(function(e){M.toggleClass("trashing",e)}),ee.bind("saved",function(e){t("saved").set(!0),"publish"===e.changeset_status&&t("activated").set(!0)}),s.bind(function(e){e&&ee.trigger("activated")}),n=function(e){var t,n;if(history.replaceState){if((t=document.createElement("a")).href=location.href,n=ee.utils.parseQueryString(t.search.substr(1)),e){if(n.changeset_uuid===ee.settings.changeset.uuid)return;n.changeset_uuid=ee.settings.changeset.uuid}else{if(!n.changeset_uuid)return;delete n.changeset_uuid}t.search=Z.param(n),history.replaceState({},document.title,t.href)}},ee.settings.changeset.branching&&u.bind(function(e){n(""!==e&&"publish"!==e&&"trash"!==e)}),b=ee.OverlayNotification.extend({templateId:"customize-changeset-locked-notification",lockUser:null,initialize:function(e,t){var n,i;n=e||"changeset_locked",(i=_.extend({message:"",type:"warning",containerClasses:"",lockUser:{}},t)).containerClasses+=" notification-changeset-locked",ee.OverlayNotification.prototype.initialize.call(this,n,i)},render:function(){var n,e,i,a,t=this;return e=_.extend({allowOverride:!1,returnUrl:ee.settings.url.return,previewUrl:ee.previewer.previewUrl.get(),frontendPreviewUrl:ee.previewer.getFrontendPreviewUrl()},this),n=ee.OverlayNotification.prototype.render.call(e),ee.requestChangesetUpdate({},{autosave:!0}).fail(function(e){e.autosaved||n.find(".notice-error").prop("hidden",!1).text(e.message||ee.l10n.unknownRequestFail)}),(i=n.find(".customize-notice-take-over-button")).on("click",function(e){e.preventDefault(),a||(i.addClass("disabled"),(a=wp.ajax.post("customize_override_changeset_lock",{wp_customize:"on",customize_theme:ee.settings.theme.stylesheet,customize_changeset_uuid:ee.settings.changeset.uuid,nonce:ee.settings.nonce.override_lock})).done(function(){ee.notifications.remove(t.code),ee.state("changesetLocked").set(!1)}),a.fail(function(e){var t=e.message||ee.l10n.unknownRequestFail;n.find(".notice-error").prop("hidden",!1).text(t),a.always(function(){i.removeClass("disabled")})}),a.always(function(){a=null}))}),n}}),ee.settings.changeset.lockUser&&K({allowOverride:!0}),Z(document).on("heartbeat-send.update_lock_notice",function(e,t){t.check_changeset_lock=!0,t.changeset_uuid=ee.settings.changeset.uuid}),Z(document).on("heartbeat-tick.update_lock_notice",function(e,t){var n,i="changeset_locked";t.customize_changeset_lock_user&&((n=ee.notifications(i))&&n.lockUser.id!==ee.settings.changeset.lockUser.id&&ee.notifications.remove(i),K({lockUser:t.customize_changeset_lock_user}))}),ee.bind("error",function(e){"changeset_locked"===e.code&&e.lock_user&&K({lockUser:e.lock_user})}),E=!(T=[]),ee.settings.changeset.autosaved&&(ee.state("saved").set(!1),T.push("customize_autosaved")),ee.settings.changeset.branching||ee.settings.changeset.status&&"auto-draft"!==ee.settings.changeset.status||T.push("changeset_uuid"),0<T.length&&(C=T,x=document.createElement("a"),k=0,x.href=location.href,y=ee.utils.parseQueryString(x.search.substr(1)),_.each(C,function(e){void 0!==y[e]&&(k+=1,delete y[e])}),0!==k&&(x.search=Z.param(y),history.replaceState({},document.title,x.href))),(ee.settings.changeset.latestAutoDraftUuid||ee.settings.changeset.hasAutosaveRevision)&&(S="autosave_available",ee.notifications.add(new ee.Notification(S,{message:ee.l10n.autosaveNotice,type:"warning",dismissible:!0,render:function(){var e,t=ee.Notification.prototype.render.call(this);return(e=t.find("a")).prop("href",$()),e.on("click",function(e){e.preventDefault(),location.replace($())}),t.find(".notice-dismiss").on("click",J),t}})),z=function(){J(),ee.notifications.remove(S),ee.unbind("change",z),ee.state("changesetStatus").unbind(z)},ee.bind("change",z),ee.state("changesetStatus").bind(z)),ee.previewer.previewUrl()?ee.previewer.refresh():ee.previewer.previewUrl(ee.settings.url.home),B.click(function(e){ee.previewer.save(),e.preventDefault()}).keydown(function(e){9!==e.which&&(13===e.which&&ee.previewer.save(),e.preventDefault())}),R.keydown(function(e){9!==e.which&&(13===e.which&&this.click(),e.preventDefault())}),Z(".collapse-sidebar").on("click",function(){ee.state("paneVisible").set(!ee.state("paneVisible").get())}),ee.state("paneVisible").bind(function(e){O.toggleClass("preview-only",!e),O.toggleClass("expanded",e),O.toggleClass("collapsed",!e),e?Z(".collapse-sidebar").attr({"aria-expanded":"true","aria-label":ee.l10n.collapseSidebar}):Z(".collapse-sidebar").attr({"aria-expanded":"false","aria-label":ee.l10n.expandSidebar})}),M.on("keydown",function(e){var t,n=[],i=[],a=[];if(27===e.which&&(Z(e.target).is("body")||Z.contains(Z("#customize-controls")[0],e.target))&&(ee.control.each(function(e){e.expanded&&e.expanded()&&_.isFunction(e.collapse)&&n.push(e)}),ee.section.each(function(e){e.expanded()&&i.push(e)}),ee.panel.each(function(e){e.expanded()&&a.push(e)}),0<n.length&&0===i.length&&(n.length=0),t=n[0]||i[0]||a[0])){if("themes"===t.params.type)return void(M.hasClass("modal-open")?t.closeDetails():ee.panel.has("themes")&&ee.panel("themes").collapse());t.collapse(),e.preventDefault()}}),Z(".customize-controls-preview-toggle").on("click",function(){ee.state("paneVisible").set(!ee.state("paneVisible").get())}),V=Z(".wp-full-overlay-sidebar-content"),D=function(e){var t,n=e,i=ee.state("expandedSection").get(),a=ee.state("expandedPanel").get();if(A&&A.element&&(N(A.element),A.element.find(".description").off("toggled",P)),!n)if(!i&&a&&a.contentContainer)n=a;else{if(a||!i||!i.contentContainer)return void(A=!1);n=i}(t=n.contentContainer.find(".customize-section-title, .panel-meta").first()).length?((A={instance:n,element:t,parent:t.closest(".customize-pane-child"),height:t.outerHeight()}).element.find(".description").on("toggled",P),i&&I(A.element,A.parent)):A=!1},ee.state("expandedSection").bind(D),ee.state("expandedPanel").bind(D),V.on("scroll",_.throttle(function(){if(A){var e,t=V.scrollTop();e=F?t===F?0:F<t?1:-1:1,F=t,0!==e&&U(A,t,e)}},8)),ee.notifications.bind("sidebarTopUpdated",function(){A&&A.element.hasClass("is-sticky")&&A.element.css("top",V.css("top"))}),N=function(e){e.hasClass("is-sticky")&&e.removeClass("is-sticky").addClass("maybe-sticky is-in-view").css("top",V.scrollTop()+"px")},I=function(e,t){e.hasClass("is-in-view")&&(e.removeClass("maybe-sticky is-in-view").css({width:"",top:""}),t.css("padding-top",""))},P=function(){A.height=A.element.outerHeight()},U=function(e,t,n){var i=e.element,a=e.parent,o=e.height,s=parseInt(i.css("top"),10),r=i.hasClass("maybe-sticky"),c=i.hasClass("is-sticky"),l=i.hasClass("is-in-view");if(-1!==n)return c&&(s=t,i.removeClass("is-sticky").css({top:s+"px",width:""})),void(l&&s+o<t&&(i.removeClass("is-in-view"),a.css("padding-top","")));if(!r&&o<=t)r=!0,i.addClass("maybe-sticky");else if(0===t)return i.removeClass("maybe-sticky is-in-view is-sticky").css({top:"",width:""}),void a.css("padding-top","");l&&!c?t<=s&&i.addClass("is-sticky").css({top:V.css("top"),width:a.outerWidth()+"px"}):r&&!l&&(i.addClass("is-in-view").css("top",t-o+"px"),a.css("padding-top",o+"px"))},ee.previewedDevice=ee.state("previewedDevice"),ee.bind("ready",function(){_.find(ee.settings.previewableDevices,function(e,t){if(!0===e.default)return ee.previewedDevice.set(t),!0})}),Q.find(".devices button").on("click",function(e){ee.previewedDevice.set(Z(e.currentTarget).data("device"))}),ee.previewedDevice.bind(function(e){var t=Z(".wp-full-overlay"),n="";Q.find(".devices button").removeClass("active").attr("aria-pressed",!1),Q.find(".devices .preview-"+e).addClass("active").attr("aria-pressed",!0),Z.each(ee.settings.previewableDevices,function(e){n+=" preview-"+e}),t.removeClass(n).addClass("preview-"+e)}),j.length&&ee("blogname",function(e){function t(){j.text(Z.trim(e())||ee.l10n.untitledBlogName)}e.bind(t),t()}),m=new ee.Messenger({url:ee.settings.url.parent,channel:"loader"}),H=!1,m.bind("back",function(){H=!0}),ee.bind("change",G),ee.state("selectedChangesetStatus").bind(G),ee.state("selectedChangesetDate").bind(G),m.bind("confirm-close",function(){X().done(function(){m.send("confirmed-close",!0)}).fail(function(){m.send("confirmed-close",!1)})}),R.on("click.customize-controls-close",function(e){e.preventDefault(),H?m.send("close"):X().done(function(){Z(window).off("beforeunload.customize-confirm"),window.location.href=R.prop("href")})}),Z.each(["saved","change"],function(e,t){ee.bind(t,function(){m.send(t)})}),ee.bind("title",function(e){m.send("title",e)}),ee.settings.changeset.branching&&m.send("changeset-uuid",ee.settings.changeset.uuid),m.send("ready"),Z.each({background_image:{controls:["background_preset","background_position","background_size","background_repeat","background_attachment"],callback:function(e){return!!e}},show_on_front:{controls:["page_on_front","page_for_posts"],callback:function(e){return"page"===e}},header_textcolor:{controls:["header_textcolor"],callback:function(e){return"blank"!==e}}},function(e,i){ee(e,function(n){Z.each(i.controls,function(e,t){ee.control(t,function(t){function e(e){t.container.toggle(i.callback(e))}e(n.get()),n.bind(e)})})})}),ee.control("background_preset",function(e){var a,t,o,n,i,s;a={default:[!1,!1,!1,!1],fill:[!0,!1,!1,!1],fit:[!0,!1,!0,!1],repeat:[!0,!1,!1,!0],custom:[!0,!0,!0,!0]},t=[_wpCustomizeBackground.defaults["default-position-x"],_wpCustomizeBackground.defaults["default-position-y"],_wpCustomizeBackground.defaults["default-size"],_wpCustomizeBackground.defaults["default-repeat"],_wpCustomizeBackground.defaults["default-attachment"]],o={default:t,fill:["left","top","cover","no-repeat","fixed"],fit:["left","top","contain","no-repeat","fixed"],repeat:["left","top","auto","repeat","scroll"]},n=function(i){_.each(["background_position","background_size","background_repeat","background_attachment"],function(e,t){var n=ee.control(e);n&&n.container.toggle(a[i][t])})},i=function(i){_.each(["background_position_x","background_position_y","background_size","background_repeat","background_attachment"],function(e,t){var n=ee(e);n&&n.set(o[i][t])})},s=e.setting.get(),n(s),e.setting.bind("change",function(e){n(e),"custom"!==e&&i(e)})}),ee.control("background_repeat",function(t){t.elements[0].unsync(ee("background_repeat")),t.element=new ee.Element(t.container.find("input")),t.element.set("no-repeat"!==t.setting()),t.element.bind(function(e){t.setting.set(e?"repeat":"no-repeat")}),t.setting.bind(function(e){t.element.set("no-repeat"!==e)})}),ee.control("background_attachment",function(t){t.elements[0].unsync(ee("background_attachment")),t.element=new ee.Element(t.container.find("input")),t.element.set("fixed"!==t.setting()),t.element.bind(function(e){t.setting.set(e?"scroll":"fixed")}),t.setting.bind(function(e){t.element.set("fixed"!==e)})}),ee.control("display_header_text",function(t){var n="";t.elements[0].unsync(ee("header_textcolor")),t.element=new ee.Element(t.container.find("input")),t.element.set("blank"!==t.setting()),t.element.bind(function(e){e||(n=ee("header_textcolor").get()),t.setting.set(e?n:"blank")}),t.setting.bind(function(e){t.element.set("blank"!==e)})}),ee("show_on_front","page_on_front","page_for_posts",function(i,a,o){function e(){var e,t,n="show_on_front_page_collision";e=parseInt(a(),10),t=parseInt(o(),10),"page"===i()&&(this===a&&0<e&&ee.previewer.previewUrl.set(ee.settings.url.home),this===o&&0<t&&ee.previewer.previewUrl.set(ee.settings.url.home+"?page_id="+t)),"page"===i()&&e&&t&&e===t?i.notifications.add(new ee.Notification(n,{type:"error",message:ee.l10n.pageOnFrontError})):i.notifications.remove(n)}i.bind(e),a.bind(e),o.bind(e),e.call(i,i()),ee.control("show_on_front",function(e){e.deferred.embedded.done(function(){e.container.append(e.getNotificationsContainerElement())})})}),L=Z.Deferred(),ee.section("custom_css",function(t){t.deferred.embedded.done(function(){t.expanded()?L.resolve(t):t.expanded.bind(function(e){e&&L.resolve(t)})})}),L.done(function(e){var t=ee.control("custom_css");t.container.find(".customize-control-title:first").addClass("screen-reader-text"),e.container.find(".section-description-buttons .section-description-close").on("click",function(){e.container.find(".section-meta .customize-section-description:first").removeClass("open").slideUp(),e.container.find(".customize-help-toggle").attr("aria-expanded","false").focus()}),t&&!t.setting.get()&&(e.container.find(".section-meta .customize-section-description:first").addClass("open").show().trigger("toggled"),e.container.find(".customize-help-toggle").attr("aria-expanded","true"))}),ee.control("header_video",function(n){n.deferred.embedded.done(function(){function e(){var e=ee.section(n.section()),t="video_header_not_available";e&&(n.active.get()?e.notifications.remove(t):e.notifications.add(new ee.Notification(t,{type:"info",message:ee.l10n.videoHeaderNotice})))}e(),n.active.bind(e)})}),ee.previewer.bind("selective-refresh-setting-validities",function(e){ee._handleSettingValidities({settingValidities:e,focusInvalidControl:!1})}),ee.previewer.bind("focus-control-for-setting",function(n){var i=[];ee.control.each(function(e){var t=_.pluck(e.settings,"id");-1!==_.indexOf(t,n)&&i.push(e)}),i.length&&(i.sort(function(e,t){return e.priority()-t.priority()}),i[0].focus())}),ee.previewer.bind("refresh",function(){ee.previewer.refresh()}),ee.state("paneVisible").bind(function(e){var t;t=window.matchMedia?window.matchMedia("screen and ( max-width: 640px )").matches:Z(window).width()<=640,ee.state("editShortcutVisibility").set(e||t?"visible":"hidden")}),window.matchMedia&&window.matchMedia("screen and ( max-width: 640px )").addListener(function(){var e=ee.state("paneVisible");e.callbacks.fireWith(e,[e.get(),e.get()])}),ee.previewer.bind("edit-shortcut-visibility",function(e){ee.state("editShortcutVisibility").set(e)}),ee.state("editShortcutVisibility").bind(function(e){ee.previewer.send("edit-shortcut-visibility",e)}),ee.bind("change",function e(){var t,n,i,a=!1;function o(e){e||ee.settings.changeset.autosaved||(ee.settings.changeset.autosaved=!0,ee.previewer.send("autosaving"))}ee.unbind("change",e),ee.state("saved").bind(o),o(ee.state("saved").get()),n=function(){a||(a=!0,ee.requestChangesetUpdate({},{autosave:!0}).always(function(){a=!1})),i()},(i=function(){clearTimeout(t),t=setTimeout(function(){n()},ee.settings.timeouts.changesetAutoSave)})(),Z(document).on("visibilitychange.wp-customize-changeset-update",function(){document.hidden&&n()}),Z(window).on("beforeunload.wp-customize-changeset-update",function(){n()})}),Z(document).one("tinymce-editor-setup",function(){window.tinymce.ui.FloatPanel&&(!window.tinymce.ui.FloatPanel.zIndex||window.tinymce.ui.FloatPanel.zIndex<500001)&&(window.tinymce.ui.FloatPanel.zIndex=500001)}),M.addClass("ready"),ee.trigger("ready")}function K(e){e&&e.lockUser&&(ee.settings.changeset.lockUser=e.lockUser),ee.state("changesetLocked").set(!0),ee.notifications.add(new b("changeset_locked",{lockUser:ee.settings.changeset.lockUser,allowOverride:Boolean(e&&e.allowOverride)}))}function $(){var e,t;return(e=document.createElement("a")).href=location.href,t=ee.utils.parseQueryString(e.search.substr(1)),ee.settings.changeset.latestAutoDraftUuid?t.changeset_uuid=ee.settings.changeset.latestAutoDraftUuid:t.customize_autosaved="on",t.return=ee.settings.url.return,e.search=Z.param(t),e.href}function J(){E||(wp.ajax.post("customize_dismiss_autosave_or_lock",{wp_customize:"on",customize_theme:ee.settings.theme.stylesheet,customize_changeset_uuid:ee.settings.changeset.uuid,nonce:ee.settings.nonce.dismiss_autosave_or_lock,dismiss_autosave:!0}),E=!0)}function Y(){var e;return ee.state("activated").get()?(""!==(e=ee.state("changesetStatus").get())&&"auto-draft"!==e||(e="publish"),ee.state("selectedChangesetStatus").get()===e&&(("future"!==ee.state("selectedChangesetStatus").get()||ee.state("selectedChangesetDate").get()===ee.state("changesetDate").get())&&(ee.state("saved").get()&&"auto-draft"!==ee.state("changesetStatus").get()))):0===ee._latestRevision}function G(){ee.unbind("change",G),ee.state("selectedChangesetStatus").unbind(G),ee.state("selectedChangesetDate").unbind(G),Z(window).on("beforeunload.customize-confirm",function(){if(!Y()&&!ee.state("changesetLocked").get())return setTimeout(function(){O.removeClass("customize-loading")},1),ee.l10n.saveAlert})}function X(){var e=Z.Deferred(),t=!1,n=!1;return Y()?n=!0:confirm(ee.l10n.saveAlert)?(n=!0,ee.each(function(e){e._dirty=!1}),Z(document).off("visibilitychange.wp-customize-changeset-update"),Z(window).off("beforeunload.wp-customize-changeset-update"),R.css("cursor","progress"),""!==ee.state("changesetStatus").get()&&(t=!0)):e.reject(),(n||t)&&wp.ajax.send("customize_dismiss_autosave_or_lock",{timeout:500,data:{wp_customize:"on",customize_theme:ee.settings.theme.stylesheet,customize_changeset_uuid:ee.settings.changeset.uuid,nonce:ee.settings.nonce.dismiss_autosave_or_lock,dismiss_autosave:t,dismiss_lock:n}}).always(function(){e.resolve()}),e.promise()}})}(wp,jQuery); |