WordPress/wp-admin/js/customize-controls.min.js
desrosj 968d57a6b3 Build/Test Tools: Support NodeJS 14.x in the 4.5 branch.
This updates the 4.5 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy.

Because older branches use (really) old versions of NodeJS, the local Docker environment cannot be backported since the needed dependencies will not run on these older versions (see #48301). This also blocks the ability to move automated testing over to GitHub Actions (see #50401).

This also replaces the `npm-shrinkwrap.json` with a `package-lock.json` file. Lock files were not supported in earlier versions of NPM, but can now be used.

In addition to backporting the package updates that happened after branching 4.5, dependencies that were removed in future releases have also been updated to their latest versions.

Props desrosj, dd32, netweb, jorbin.
Merges [37185,37212,37612,38111,38688,39110,39113-39119,39478,42460-42461,42463,42887,43320,43323,43977,44219,44233,44728,45321,45765,46404,46408-46409,47404,47867-47869,47872-47873,48705,49636,49933,49937,49939,50017,50126,50176,50185,50192] to the 4.5 branch.
See #52341.
Built from https://develop.svn.wordpress.org/branches/4.5@50208


git-svn-id: http://core.svn.wordpress.org/branches/4.5@49880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 04:20:44 +00:00

1 line
44 KiB
JavaScript

!function(m){var i,e,t,f=wp.customize;f.Setting=f.Value.extend({initialize:function(e,t,n){f.Value.prototype.initialize.call(this,t,n),this.id=e,this.transport=this.transport||"refresh",this._dirty=n.dirty||!1,this.bind(this.preview)},preview:function(){switch(this.transport){case"refresh":return this.previewer.refresh();case"postMessage":return this.previewer.send("setting",[this.id,this()])}}}),f.utils={},f.utils.bubbleChildValueChanges=function(n,e){m.each(e,function(e,t){n[t].bind(function(e,t){n.parent&&e!==t&&n.parent.trigger("change",n)})})},e=function(e){var t,n,i=this,o=function(){var e=i.extended(f.Panel)&&i.expanded&&i.expanded()?i.container.find("ul.control-panel-content"):i.extended(f.Section)&&i.expanded&&i.expanded()?i.container.find("ul.accordion-section-content"):i.container;(n=0===(n=e.find(".control-focus:first")).length?e.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first():n).focus()};(e=e||{}).completeCallback?(t=e.completeCallback,e.completeCallback=function(){o(),t()}):e.completeCallback=o,i.expand?i.expand(e):e.completeCallback()},f.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()},f.utils.isKeydownButNotEnterEvent=function(e){return"keydown"===e.type&&13!==e.which},f.utils.areElementListsEqual=function(e,t){return e.length===t.length&&-1===_.indexOf(_.map(_.zip(e,t),function(e){return m(e[0]).is(e[1])}),!1)},i=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:m.noop},defaultExpandedArguments:{duration:"fast",completeCallback:m.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,(t=t||{}).params=_.defaults(t.params||{},n.defaults),m.extend(n,t),n.templateSelector="customize-"+n.containerType+"-"+n.params.type,n.container=m(n.params.content),0===n.container.length&&(n.container=m(n.getContainer())),n.deferred={embedded:new m.Deferred},n.priority=new f.Value,n.active=new f.Value,n.activeArgumentsQueue=[],n.expanded=new f.Value,n.expandedArgumentsQueue=[],n.active.bind(function(e){var t=n.activeArgumentsQueue.shift(),t=m.extend({},n.defaultActiveArguments,t);e=e&&n.isContextuallyActive(),n.onChangeActive(e,t)}),n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift(),t=m.extend({},n.defaultExpandedArguments,t);n.onChangeExpanded(e,t)}),n.deferred.embedded.done(function(){n.attachEvents()}),f.utils.bubbleChildValueChanges(n,["priority","active"]),n.priority.set(n.params.priority),n.active.set(n.params.active),n.expanded.set(!1)},ready:function(){},_children:function(t,e){var n=this,i=[];return f[e].each(function(e){e[t].get()===n.id&&i.push(e)}),i.sort(f.utils.prioritySort),i},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(e,t){var n,i,o=this;t.unchanged?t.completeCallback&&t.completeCallback():(n="resolved"===f.previewer.deferred.active.state()?t.duration:0,o.extended(f.Panel)&&(f.panel.each(function(e){e!==o&&e.expanded()&&(i=e,n=0)}),e||_.each(o.sections(),function(e){e.collapse({duration:0})})),m.contains(document,o.container[0])?e?o.container.stop(!0,!0).slideDown(n,t.completeCallback):o.expanded()?o.collapse({duration:n,completeCallback:function(){o.container.stop(!0,!0).slideUp(n,t.completeCallback)}}):o.container.stop(!0,!0).slideUp(n,t.completeCallback):(o.container.toggle(e),t.completeCallback&&t.completeCallback()),i&&i._recalculateTopMargin())},_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())&&(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)},focus:e,getContainer:function(){var e=this,t=0!==m("#tmpl-"+e.templateSelector).length?wp.template(e.templateSelector):wp.template("customize-"+e.containerType+"-default");return t&&e.container?m.trim(t(e.params)):"<li></li>"}}),f.Section=i.extend({containerType:"section",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null,panel:null,customizeAction:""},initialize:function(e,t){var n=this;i.prototype.initialize.call(n,e,t),n.id=e,n.panel=new f.Value,n.panel.bind(function(e){m(n.container).toggleClass("control-subsection",!!e)}),n.panel.set(n.params.panel||""),f.utils.bubbleChildValueChanges(n,["panel"]),n.embed(),n.deferred.embedded.done(function(){n.ready()})},embed:function(){var n=this,e=function(e){var t;e?f.panel(e,function(e){e.deferred.embedded.done(function(){t=e.container.find("ul:first"),n.container.parent().is(t)||t.append(n.container),n.deferred.embedded.resolve()})}):(t=m("#customize-theme-controls").children("ul"),n.container.parent().is(t)||t.append(n.container),n.deferred.embedded.resolve())};n.panel.bind(e),e(n.panel.get()),n.deferred.embedded.done(function(){f.bind("pane-contents-reflowed",_.debounce(function(){n._recalculateTopMargin()},100))})},attachEvents:function(){var t=this;t.container.find(".accordion-section-title, .customize-section-back").on("click keydown",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),t.expanded()?t.collapse():t.expand())})},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,o,a,r=this,s=r.container.closest(".wp-full-overlay-sidebar-content"),c=r.container.find(".accordion-section-content"),l=r.container.closest(".wp-full-overlay"),d=r.container.find(".customize-section-back"),u=r.container.find(".accordion-section-title").first(),p=m("#customize-header-actions").height();e&&!r.container.hasClass("open")?(i=t.unchanged?t.completeCallback:(s.scrollTop(0),n=function(){var e=window.matchMedia||window.msMatchMedia,t=90;e&&e("(max-width: 640px)").matches&&(t=45),c.css("height",window.innerHeight-t)},function(){r.container.addClass("open"),l.addClass("section-open"),o=c.offset().top,a=s.scrollTop(),c.css("margin-top",p-o-a),n(),u.attr("tabindex","-1"),d.attr("tabindex","0"),d.focus(),t.completeCallback&&t.completeCallback(),m(window).on("resize.customizer-section",_.debounce(n,100)),setTimeout(_.bind(r._recalculateTopMargin,r),0)}),t.allowMultiple||f.section.each(function(e){e!==r&&e.collapse({duration:t.duration})}),r.panel()?f.panel(r.panel()).expand({duration:t.duration,completeCallback:i}):(f.panel.each(function(e){e.collapse()}),i())):!e&&r.container.hasClass("open")?(r.container.removeClass("open"),l.removeClass("section-open"),c.css("margin-top",""),s.scrollTop(0),d.attr("tabindex","-1"),u.attr("tabindex","0"),u.focus(),t.completeCallback&&t.completeCallback(),m(window).off("resize.customizer-section")):t.completeCallback&&t.completeCallback()},_recalculateTopMargin:function(){var e,t=this.container.find(".accordion-section-content");0!==t.length&&(e=m("#customize-header-actions").height(),0<(e=t.offset().top-e)&&t.css("margin-top",parseInt(t.css("margin-top"),10)-e))}}),f.ThemesSection=f.Section.extend({currentTheme:"",overlay:"",template:"",screenshotQueue:null,$window:m(window),initialize:function(){return this.$customizeSidebar=m(".wp-full-overlay-sidebar-content:first"),f.Section.prototype.initialize.apply(this,arguments)},ready:function(){var t=this;t.overlay=t.container.find(".theme-overlay"),t.template=wp.template("customize-themes-details-view"),m("body").on("keyup",function(e){t.overlay.find(".theme-wrap").is(":visible")&&(39===e.keyCode&&t.nextTheme(),37===e.keyCode&&t.previousTheme(),27===e.keyCode&&t.closeDetails())}),_.bindAll(this,"renderScreenshots")},isContextuallyActive:function(){return this.active()},attachEvents:function(){var n=this;n.container.find(".change-theme, .customize-theme").on("click keydown",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()?n.collapse():n.expand())}),n.container.on("click keydown",".left",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.previousTheme())}),n.container.on("click keydown",".right",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.nextTheme())}),n.container.on("click keydown",".theme-backdrop, .close",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.closeDetails())});var i=_.throttle(_.bind(n.renderScreenshots,this),100);n.container.on("input","#themes-filter",function(e){var t=e.currentTarget.value.toLowerCase().trim().replace("-"," "),e=n.controls();_.each(e,function(e){e.filter(t)}),i(),e=n.container.find("li.customize-control:visible").length,n.container.find(".theme-count").text(e)}),f.bind("ready",function(){_.each(n.controls().slice(0,3),function(e){e=e.params.theme.screenshot[0];e&&((new Image).src=e)})})},onChangeExpanded:function(e,t){var n,i,o,a,r,s,c,l,d,u;t.unchanged?t.completeCallback&&t.completeCallback():(a=(o=this).container.closest(".accordion-section"),r=a.closest(".wp-full-overlay"),c=(s=a.closest(".wp-full-overlay-sidebar-content")).find(".open"),l=a.find(".customize-theme"),d=a.find(".change-theme"),u=a.find(".control-panel-content"),e?(f.section.each(function(e){e!==o&&e.collapse({duration:t.duration})}),f.panel.each(function(e){e.collapse({duration:0})}),u.show(0,function(){n=u.offset().top,i=s.scrollTop(),u.css("margin-top",m("#customize-header-actions").height()-n-i),a.addClass("current-panel"),r.addClass("in-themes-panel"),s.scrollTop(0),_.delay(o.renderScreenshots,10),o.$customizeSidebar.on("scroll.customize-themes-section",_.throttle(o.renderScreenshots,300)),t.completeCallback&&t.completeCallback()}),l.focus()):(c.removeClass("open"),a.removeClass("current-panel"),r.removeClass("in-themes-panel"),o.$customizeSidebar.off("scroll.customize-themes-section"),u.delay(180).hide(0,function(){u.css("margin-top","inherit"),t.completeCallback&&t.completeCallback()}),l.attr("tabindex","0"),d.focus(),s.scrollTop(0)))},_recalculateTopMargin:function(){f.Panel.prototype._recalculateTopMargin.call(this)},renderScreenshots:function(){var r=this;null===r.screenshotQueue&&(r.screenshotQueue=r.controls()),r.screenshotQueue.length&&(r.screenshotQueue=_.filter(r.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=r.$window.scrollTop(),o=i+r.$window.height(),a=n.offset().top,n=t.height(),t=3*n,t=i-t<=a+n&&a<=o+t;return t&&e.container.trigger("render-screenshot"),!t}))},nextTheme:function(){var e=this;e.getNextTheme()&&e.showDetails(e.getNextTheme(),function(){e.overlay.find(".right").focus()})},getNextTheme:function(){var e=f.control("theme_"+this.currentTheme),t=e.container.next("li.customize-control-theme");return!!t.length&&(t=t[0].id.replace("customize-control-",""),(e=f.control(t)).params.theme)},previousTheme:function(){var e=this;e.getPreviousTheme()&&e.showDetails(e.getPreviousTheme(),function(){e.overlay.find(".left").focus()})},getPreviousTheme:function(){var e=f.control("theme_"+this.currentTheme),t=e.container.prev("li.customize-control-theme");return!!t.length&&(t=t[0].id.replace("customize-control-",""),(e=f.control(t)).params.theme)},updateLimits:function(){this.getNextTheme()||this.overlay.find(".right").addClass("disabled"),this.getPreviousTheme()||this.overlay.find(".left").addClass("disabled")},showDetails:function(e,t){var n=this;t=t||function(){},n.currentTheme=e.id,n.overlay.html(n.template(e)).fadeIn("fast").focus(),m("body").addClass("modal-open"),n.containFocus(n.overlay),n.updateLimits(),t()},closeDetails:function(){m("body").removeClass("modal-open"),this.overlay.fadeOut("fast"),f.control("theme_"+this.currentTheme).focus()},containFocus:function(t){var n;t.on("keydown",function(e){if(9===e.keyCode)return(n=m(":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)})}}),f.Panel=i.extend({containerType:"panel",initialize:function(e,t){var n=this;i.prototype.initialize.call(n,e,t),n.embed(),n.deferred.embedded.done(function(){n.ready()})},embed:function(){var e=this,t=m("#customize-theme-controls > ul");e.container.parent().is(t)||(t.append(e.container),e.renderContent()),f.bind("pane-contents-reflowed",_.debounce(function(){e._recalculateTopMargin()},100)),e.deferred.embedded.resolve()},attachEvents:function(){var t,n=this;n.container.find(".accordion-section-title").on("click keydown",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()||n.expand())}),n.container.find(".customize-panel-back").on("click keydown",function(e){f.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 keydown",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),(t=n.container.find(".panel-meta")).hasClass("cannot-expand")||(e=t.find(".customize-panel-description:first"),t.hasClass("open")?(t.toggleClass("open"),e.slideUp(n.defaultExpandedArguments.duration),m(this).attr("aria-expanded",!1)):(e.slideDown(n.defaultExpandedArguments.duration),t.toggleClass("open"),m(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){var n,i,o,a,r,s,c,l,d,u,p,h;t.unchanged?t.completeCallback&&t.completeCallback():(a=(o=this).container.closest(".accordion-section"),r=a.closest(".wp-full-overlay"),c=(s=a.closest(".wp-full-overlay-sidebar-content")).find(".open"),l=r.find("#customize-theme-controls > ul > .accordion-section > .accordion-section-title"),d=a.find(".customize-panel-back"),u=a.find(".accordion-section-title").first(),p=a.find(".control-panel-content"),h=m("#customize-header-actions").height(),e?(f.section.each(function(e){o.id!==e.panel()&&e.collapse({duration:0})}),f.panel.each(function(e){o!==e&&e.collapse({duration:0})}),p.show(0,function(){p.parent().show(),n=p.offset().top,i=s.scrollTop(),p.css("margin-top",h-n-i),a.addClass("current-panel"),r.addClass("in-sub-panel"),s.scrollTop(0),t.completeCallback&&t.completeCallback()}),l.attr("tabindex","-1"),d.attr("tabindex","0"),d.focus(),o._recalculateTopMargin()):(c.removeClass("open"),a.removeClass("current-panel"),r.removeClass("in-sub-panel"),p.delay(180).hide(0,function(){p.css("margin-top","inherit"),t.completeCallback&&t.completeCallback()}),l.attr("tabindex","0"),d.attr("tabindex","-1"),u.focus(),s.scrollTop(0)))},_recalculateTopMargin:function(){var e=m("#customize-header-actions").height(),t=this.container.closest(".accordion-section").find(".control-panel-content");t.css("margin-top",parseInt(t.css("margin-top"),10)-(t.offset().top-e))},renderContent:function(){var e=this,t=0!==m("#tmpl-"+e.templateSelector+"-content").length?wp.template(e.templateSelector+"-content"):wp.template("customize-panel-default-content");t&&e.container&&e.container.find(".accordion-sub-container").html(t(e.params))}}),f.Control=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:m.noop},initialize:function(e,t){var i,o,a=this;a.params={},m.extend(a,t||{}),a.id=e,a.selector="#customize-control-"+e.replace(/\]/g,"").replace(/\[/g,"-"),a.templateSelector="customize-control-"+a.params.type+"-content",a.container=a.params.content?m(a.params.content):m(a.selector),a.deferred={embedded:new m.Deferred},a.section=new f.Value,a.priority=new f.Value,a.active=new f.Value,a.activeArgumentsQueue=[],a.elements=[],i=a.container.find("[data-customize-setting-link]"),o={},i.each(function(){var e,n=m(this);if(n.is(":radio")){if(e=n.prop("name"),o[e])return;o[e]=!0,n=i.filter('[name="'+e+'"]')}f(n.data("customizeSettingLink"),function(e){var t=new f.Element(n);a.elements.push(t),t.sync(e),t.set(e())})}),a.active.bind(function(e){var t=a.activeArgumentsQueue.shift(),t=m.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),f.utils.bubbleChildValueChanges(a,["section","priority","active"]),0===(e=m.map(a.params.settings,function(e){return e})).length?(a.setting=null,a.settings={},a.embed()):f.apply(f,e.concat(function(){for(var e in a.settings={},a.params.settings)a.settings[e]=f(a.params.settings[e]);a.setting=a.settings["default"]||null,a.embed()})),a.deferred.embedded.done(function(){a.ready()})},embed:function(){var n=this,e=function(e){var t;e&&f.section(e,function(e){e.deferred.embedded.done(function(){t=e.container.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(){},expand:function(e){f.section(this.section()).expand(e)},focus:e,onChangeActive:function(e,t){t.unchanged?t.completeCallback&&t.completeCallback():m.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:i.prototype.activate,deactivate:i.prototype.deactivate,_toggleActive:i.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,o=!1;this.container.on("click keydown",".dropdown",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),o||t.container.toggleClass("open"),t.container.hasClass("open")&&t.container.parent().parent().find("li.library-selected").focus(),o=!0,setTimeout(function(){o=!1},400))}),this.setting.bind(e),e(this.setting())},renderContent:function(){var e,t=this;0!==m("#tmpl-"+t.templateSelector).length&&(e=wp.template(t.templateSelector))&&t.container&&t.container.html(e(t.params))}}),f.ColorControl=f.Control.extend({ready:function(){var e=this,t=this.container.find(".color-picker-hex");t.val(e.setting()).wpColorPicker({change:function(){e.setting.set(t.wpColorPicker("color"))},clear:function(){e.setting.set("")}}),this.setting.bind(function(e){t.val(e),t.wpColorPicker("color",e)})}}),f.MediaControl=f.Control.extend({ready:function(){var t=this;_.bindAll(t,"restoreDefault","removeFile","openFrame","select","pausePlayer"),t.container.on("click keydown",".upload-button",t.openFrame),t.container.on("click keydown",".upload-button",t.pausePlayer),t.container.on("click keydown",".thumbnail-image img",t.openFrame),t.container.on("click keydown",".default-button",t.restoreDefault),t.container.on("click keydown",".remove-button",t.pausePlayer),t.container.on("click keydown",".remove-button",t.removeFile),t.container.on("click keydown",".remove-button",t.cleanupPlayer),f.section(t.section()).container.on("expanded",function(){t.player&&t.player.setControlsSize()}).on("collapsed",function(){t.pausePlayer()}),t.setting.bind(function(e){wp.media.attachment(e).fetch().done(function(){wp.customize.previewer.send(t.setting.id+"-attachment-data",this.attributes)}),t.renderContent()})},pausePlayer:function(){this.player&&this.player.pause()},cleanupPlayer:function(){this.player&&wp.media.mixin.removePlayer(this.player)},openFrame:function(e){f.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=this.frame.state().get("selection").first().toJSON(),t=window._wpmejsSettings||{};this.params.attachment=e,this.setting(e.id),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,t):this.cleanupPlayer()},restoreDefault:function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment=this.params.defaultAttachment,this.setting(this.params.defaultAttachment.url))},removeFile:function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent())}}),f.UploadControl=f.MediaControl.extend({select:function(){var e=this.frame.state().get("selection").first().toJSON(),t=window._wpmejsSettings||{};this.params.attachment=e,this.setting(e.url),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,t):this.cleanupPlayer()},success:function(){},removerVisibility:function(){}}),f.ImageControl=f.UploadControl.extend({thumbnailSrc:function(){}}),f.BackgroundControl=f.UploadControl.extend({ready:function(){f.UploadControl.prototype.ready.apply(this,arguments)},select:function(){f.UploadControl.prototype.select.apply(this,arguments),wp.ajax.post("custom-background-add",{nonce:_wpCustomizeBackground.nonces.add,wp_customize:"on",theme:f.settings.theme.stylesheet,attachment_id:this.params.attachment.id})}}),f.CroppedImageControl=f.MediaControl.extend({openFrame:function(e){f.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=t.get("control"),i=!!parseInt(n.params.flex_width,10),o=!!parseInt(n.params.flex_height,10),a=e.get("width"),r=e.get("height"),s=parseInt(n.params.width,10),c=parseInt(n.params.height,10),l=s/c,d=s,e=c;return t.set("canSkipCrop",!n.mustBeCropped(i,o,s,c,a,r)),l<a/r?s=(c=r)*l:c=(s=a)/l,!(e={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:a,imageHeight:r,minWidth:s<d?s:d,minHeight:c<e?c:e,x1:d=(a-s)/2,y1:e=(r-c)/2,x2:s+d,y2:c+e})==o&&!1==i&&(e.aspectRatio=s+":"+c),!0==o&&(delete e.minHeight,e.maxWidth=a),!0==i&&(delete e.minWidth,e.maxHeight=r),e},mustBeCropped:function(e,t,n,i,o,a){return(!0!==e||!0!==t)&&((!0!==e||i!==a)&&((!0!==t||n!==o)&&((n!==o||i!==a)&&!(o<=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)}}),f.SiteIconControl=f.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.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),m('link[sizes="32x32"]').attr("href",n.url)},removeFile:function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent(),m('link[rel="icon"]').attr("href",""))}}),f.HeaderControl=f.Control.extend({ready:function(){this.btnRemove=m("#customize-control-header_image .actions .remove"),this.btnNew=m("#customize-control-header_image .actions .new"),_.bindAll(this,"openMedia","removeImage"),this.btnNew.on("click",this.openMedia),this.btnRemove.on("click",this.removeImage),f.HeaderTool.currentHeader=this.getInitialHeaderImage(),new f.HeaderTool.CurrentView({model:f.HeaderTool.currentHeader,el:"#customize-control-header_image .current .container"}),new f.HeaderTool.ChoiceListView({collection:f.HeaderTool.UploadsList=new f.HeaderTool.ChoiceList,el:"#customize-control-header_image .choices .uploaded .list"}),new f.HeaderTool.ChoiceListView({collection:f.HeaderTool.DefaultsList=new f.HeaderTool.DefaultsList,el:"#customize-control-header_image .choices .default .list"}),f.HeaderTool.combinedList=f.HeaderTool.CombinedList=new f.HeaderTool.CombinedList([f.HeaderTool.UploadsList,f.HeaderTool.DefaultsList]),wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize="on",wp.media.controller.Cropper.prototype.defaults.doCropArgs.theme=f.settings.theme.stylesheet},getInitialHeaderImage:function(){if(!f.get().header_image||!f.get().header_image_data||_.contains(["remove-header","random-default-image","random-uploaded-image"],f.get().header_image))return new f.HeaderTool.ImageModel;var e=(e=_.find(_wpCustomizeHeader.uploads,function(e){return e.attachment_id===f.get().header_image_data.attachment_id}))||{url:f.get().header_image,thumbnail_url:f.get().header_image,attachment_id:f.get().header_image_data.attachment_id};return new f.HeaderTool.ImageModel({header:e,choice:e.url.split("/").pop()})},calculateImageSelectOptions:function(e,t){var n=parseInt(_wpCustomizeHeader.data.width,10),i=parseInt(_wpCustomizeHeader.data.height,10),o=!!parseInt(_wpCustomizeHeader.data["flex-width"],10),a=!!parseInt(_wpCustomizeHeader.data["flex-height"],10),r=e.get("width"),e=e.get("height");return this.headerImage=new f.HeaderTool.ImageModel,this.headerImage.set({themeWidth:n,themeHeight:i,themeFlexWidth:o,themeFlexHeight:a,imageWidth:r,imageHeight:e}),t.set("canSkipCrop",!this.headerImage.shouldBeCropped()),(t=n/i)<r/e?n=(i=e)*t:i=(n=r)/t,!(e={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:r,imageHeight:e,x1:0,y1:0,x2:n,y2:i})==a&&!1==o&&(e.aspectRatio=n+":"+i),!1==a&&(e.maxHeight=i),!1==o&&(e.maxWidth=n),e},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,e=e.height;this.setImageFromURL(t,n,i,e)},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 o={};o.url=e,o.thumbnail_url=e,o.timestamp=_.now(),t&&(o.attachment_id=t),n&&(o.width=n),i&&(o.height=i),e=new f.HeaderTool.ImageModel({header:o,choice:e.split("/").pop()}),f.HeaderTool.UploadsList.add(e),f.HeaderTool.currentHeader.set(e.toJSON()),e.save(),e.importImage()},removeImage:function(){f.HeaderTool.currentHeader.trigger("hide"),f.HeaderTool.CombinedList.trigger("control:removeImage")}}),f.ThemeControl=f.Control.extend({touchDrag:!1,isRendered:!1,renderContent:function(){var t=this,n=arguments;f.section(t.section(),function(e){e.expanded()?(f.Control.prototype.renderContent.apply(t,n),t.isRendered=!0):e.expanded.bind(function(e){e&&!t.isRendered&&(f.Control.prototype.renderContent.apply(t,n),t.isRendered=!0)})})},ready:function(){var t=this;t.container.on("touchmove",".theme",function(){t.touchDrag=!0}),t.container.on("click keydown touchend",".theme",function(e){if(!f.utils.isKeydownButNotEnterEvent(e)){if(!0===t.touchDrag)return t.touchDrag=!1;m(e.target).is(".theme-actions .button")||(e=m(this).data("previewUrl"),m(".wp-full-overlay").addClass("customize-loading"),window.parent.location=e)}}),t.container.on("click keydown",".theme-actions .theme-details",function(e){f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),f.section(t.section()).showDetails(t.params.theme))}),t.container.on("render-screenshot",function(){var e=m(this).find("img"),t=e.data("src");t&&e.attr("src",t)})},filter:function(e){var t=this;-1!==(t.params.theme.name+" "+t.params.theme.description+" "+t.params.theme.tags+" "+t.params.theme.author).toLowerCase().replace("-"," ").search(e)?t.activate():t.deactivate()}}),f.defaultConstructor=f.Setting,f.control=new f.Values({defaultConstructor:f.Control}),f.section=new f.Values({defaultConstructor:f.Section}),f.panel=new f.Values({defaultConstructor:f.Panel}),f.PreviewFrame=f.Messenger.extend({sensitivity:2e3,initialize:function(e,t){var n=m.Deferred();n.promise(this),this.container=e.container,this.signature=e.signature,m.extend(e,{channel:f.PreviewFrame.uuid()}),f.Messenger.prototype.initialize.call(this,e,t),this.add("previewUrl",e.previewUrl),this.query=m.extend(e.query||{},{customize_messenger_channel:this.channel()}),this.run(n)},run:function(i){var o=this,a=!1,r=!1;this._ready&&this.unbind("ready",this._ready),this._ready=function(){r=!0,a&&i.resolveWith(o)},this.bind("ready",this._ready),this.bind("ready",function(e){this.container.addClass("iframe-ready"),e&&(e={panel:e.activePanels,section:e.activeSections,control:e.activeControls},_(e).each(function(n,e){f[e].each(function(e,t){!(!n||!n[t])?e.activate():e.deactivate()})}))}),this.request=m.ajax(this.previewUrl(),{type:"POST",data:this.query,xhrFields:{withCredentials:!0}}),this.request.fail(function(){i.rejectWith(o,["request failure"])}),this.request.done(function(e){var t=o.request.getResponseHeader("Location"),n=o.signature;t&&t!==o.previewUrl()?i.rejectWith(o,["redirect",t]):"0"!==e?"-1"!==e?-1===(t=e.lastIndexOf(n))||t<e.lastIndexOf("</html>")?i.rejectWith(o,["unsigned"]):(e=e.slice(0,t)+e.slice(t+n.length),o.iframe=m("<iframe />",{title:f.l10n.previewIframeTitle}).appendTo(o.container),o.iframe.one("load",function(){a=!0,r?i.resolveWith(o):setTimeout(function(){i.rejectWith(o,["ready timeout"])},o.sensitivity)}),o.targetWindow(o.iframe[0].contentWindow),o.targetWindow().document.open(),o.targetWindow().document.write(e),o.targetWindow().document.close()):i.rejectWith(o,["cheatin"]):o.login(i)})},login:function(n){var i=this,o=function(){n.rejectWith(i,["logged out"])};if(this.triedLogin)return o();m.get(f.settings.url.ajax,{action:"logged-in"}).fail(o).done(function(e){var t;"1"!==e&&o(),(t=m("<iframe />",{src:i.previewUrl(),title:f.l10n.previewIframeTitle}).hide()).appendTo(i.container),t.on("load",function(){i.triedLogin=!0,t.remove(),i.run(n)})})},destroy:function(){f.Messenger.prototype.destroy.call(this),this.request.abort(),this.iframe&&this.iframe.remove(),delete this.request,delete this.iframe,delete this.targetWindow}}),t=0,f.PreviewFrame.uuid=function(){return"preview-"+t++},f.setDocumentTitle=function(e){e=f.settings.documentTitleTmpl.replace("%s",e);document.title=e,f.trigger("title",e)},f.Previewer=f.Messenger.extend({refreshBuffer:250,initialize:function(e,t){var n,i,o,a=this,r=/^https?/;function s(){i=null,o.call(n)}m.extend(this,t||{}),this.deferred={active:m.Deferred()},this.refresh=(o=(n=this).refresh,function(){if("number"!=typeof i){if(!n.loading)return s();n.abort()}clearTimeout(i),i=setTimeout(s,n.refreshBuffer)}),this.container=f.ensure(e.container),this.allowedUrls=e.allowedUrls,this.signature=e.signature,e.url=window.location.href,f.Messenger.prototype.initialize.call(this,e),this.add("scheme",this.origin()).link(this.origin).setter(function(e){e=e.match(r);return e?e[0]:""}),this.add("previewUrl",e.previewUrl).setter(function(e){var o;return/\/wp-admin(\/|$)/.test(e.replace(/[#?].*$/,""))?null:(m.each([e.replace(r,a.scheme()),e],function(e,i){if(m.each(a.allowedUrls,function(e,t){var n;if(t=t.replace(/\/+$/,""),n=i.replace(t,""),0===i.indexOf(t)&&/^([/#?]|$)/.test(n))return o=i,!1}),o)return!1}),o||null)}),this.previewUrl.bind(this.refresh),this.scroll=0,this.bind("scroll",function(e){this.scroll=e}),this.bind("url",this.previewUrl),this.bind("documentTitle",function(e){f.setDocumentTitle(e)})},query:function(){},abort:function(){this.loading&&(this.loading.destroy(),delete this.loading)},refresh:function(){var n=this;this.send("loading-initiated"),this.abort(),this.loading=new f.PreviewFrame({url:this.url(),previewUrl:this.previewUrl(),query:this.query()||{},container:this.container,signature:this.signature}),this.loading.done(function(){this.bind("synced",function(){n.preview&&n.preview.destroy(),n.preview=this,delete n.loading,n.targetWindow(this.targetWindow()),n.channel(this.channel()),n.deferred.active.resolve(),n.send("active")}),this.send("sync",{scroll:n.scroll,settings:f.get()})}),this.loading.fail(function(e,t){n.send("loading-failed"),"redirect"===e&&t&&n.previewUrl(t),"logged out"===e&&(n.preview&&(n.preview.destroy(),delete n.preview),n.login().done(n.refresh)),"cheatin"===e&&n.cheatin()})},login:function(){var t,n,i,o=this;return this._login||(t=m.Deferred(),this._login=t.promise(),n=new f.Messenger({channel:"login",url:f.settings.url.login}),i=m("<iframe />",{src:f.settings.url.login,title:f.l10n.loginIframeTitle}).appendTo(this.container),n.targetWindow(i[0].contentWindow),n.bind("login",function(){var e=o.refreshNonces();e.always(function(){i.remove(),n.destroy(),delete o._login}),e.done(function(){t.resolve()}),e.fail(function(){o.cheatin(),t.reject()})}),this._login)},cheatin:function(){m(document.body).empty().addClass("cheatin").append("<h1>"+f.l10n.cheatin+"</h1><p>"+f.l10n.notAllowed+"</p>")},refreshNonces:function(){var e,t=m.Deferred();return t.promise(),(e=wp.ajax.post("customize_refresh_nonces",{wp_customize:"on",theme:f.settings.theme.stylesheet})).done(function(e){f.trigger("nonce-refresh",e),t.resolve()}),e.fail(function(){t.reject()}),t}}),f.controlConstructor={color:f.ColorControl,media:f.MediaControl,upload:f.UploadControl,image:f.ImageControl,cropped_image:f.CroppedImageControl,site_icon:f.SiteIconControl,header:f.HeaderControl,background:f.BackgroundControl,theme:f.ThemeControl},f.panelConstructor={},f.sectionConstructor={themes:f.ThemesSection},m(function(){var n,e,o,t,i,a,r,s,c,l,d,u;f.settings=window._wpCustomizeSettings,f.l10n=window._wpCustomizeControlsL10n,f.settings&&(!m.support.postMessage||!m.support.cors&&f.settings.isCrossDomain||(o=m(document.body),t=o.children(".wp-full-overlay"),i=m("#customize-info .panel-title.site-title"),a=m(".customize-controls-close"),r=m("#save"),s=m("#customize-footer-actions"),m("#customize-controls").on("keydown",function(e){var t=13===e.which,n=m(e.target);t&&(n.is("input:not([type=button])")||n.is("select"))&&e.preventDefault()}),m(".customize-info").find("> .accordion-section-title .customize-help-toggle").on("click keydown",function(e){var t;f.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),e=(t=m(this).closest(".accordion-section")).find(".customize-panel-description:first"),t.hasClass("cannot-expand")||(t.hasClass("open")?(t.toggleClass("open"),e.slideUp(f.Panel.prototype.defaultExpandedArguments.duration),m(this).attr("aria-expanded",!1)):(e.slideDown(f.Panel.prototype.defaultExpandedArguments.duration),t.toggleClass("open"),m(this).attr("aria-expanded",!0))))}),f.previewer=new f.Previewer({container:"#customize-preview",form:"#customize-controls",previewUrl:f.settings.url.preview,allowedUrls:f.settings.url.allowed,signature:"WP_CUSTOMIZER_SIGNATURE"},{nonce:f.settings.nonce,query:function(){var n={};return f.each(function(e,t){e._dirty&&(n[t]=e())}),{wp_customize:"on",theme:f.settings.theme.stylesheet,customized:JSON.stringify(n),nonce:this.nonce.preview}},save:function(){var e,t,n=this,i=f.state("processing");o.addClass("saving"),t=function(){var e=m.extend(n.query(),{nonce:n.nonce.save}),e=wp.ajax.post("customize_save",e);f.trigger("save",e),e.always(function(){o.removeClass("saving")}),e.fail(function(e){"0"===e?e="not_logged_in":"-1"===e&&(e="invalid_nonce"),"invalid_nonce"===e?n.cheatin():"not_logged_in"===e&&(n.preview.iframe.hide(),n.login().done(function(){n.save(),n.preview.iframe.show()})),f.trigger("error",e)}),e.done(function(e){f.each(function(e){e._dirty=!1}),f.previewer.send("saved",e),f.trigger("saved",e)})},0===i()?t():(e=function(){0===i()&&(f.state.unbind("change",e),t())},f.state.bind("change",e))}}),m.ajaxPrefilter(function(e){/wp_customize=on/.test(e.data)&&(e.data+="&"+m.param({customize_preview_nonce:f.settings.nonce.preview}))}),f.previewer.bind("nonce",function(e){m.extend(this.nonce,e)}),f.bind("nonce-refresh",function(e){m.extend(f.settings.nonce,e),m.extend(f.previewer.nonce,e),f.previewer.send("nonce-refresh",e)}),m.each(f.settings.settings,function(e,t){f.create(e,e,t.value,{transport:t.transport,previewer:f.previewer,dirty:!!t.dirty})}),m.each(f.settings.panels,function(e,t){t=new(f.panelConstructor[t.type]||f.Panel)(e,{params:t});f.panel.add(e,t)}),m.each(f.settings.sections,function(e,t){t=new(f.sectionConstructor[t.type]||f.Section)(e,{params:t});f.section.add(e,t)}),m.each(f.settings.controls,function(e,t){t=new(f.controlConstructor[t.type]||f.Control)(e,{params:t,previewer:f.previewer});f.control.add(e,t)}),_.each(["panel","section","control"],function(e){var t=f.settings.autofocus[e];t&&f[e](t,function(e){e.deferred.embedded.done(function(){f.previewer.deferred.active.done(function(){e.focus()})})})}),f.reflowPaneContents=_.bind(function(){var i,e,t,o=[],a=!1;document.activeElement&&(e=m(document.activeElement)),f.panel.each(function(e){var t=e.sections(),n=_.pluck(t,"container");o.push(e),i=e.container.find("ul:first"),f.utils.areElementListsEqual(n,i.children("[id]"))||(_(t).each(function(e){i.append(e.container)}),a=!0)}),f.section.each(function(e){var t=e.controls(),n=_.pluck(t,"container");e.panel()||o.push(e),i=e.container.find("ul:first"),f.utils.areElementListsEqual(n,i.children("[id]"))||(_(t).each(function(e){i.append(e.container)}),a=!0)}),o.sort(f.utils.prioritySort),t=_.pluck(o,"container"),i=m("#customize-theme-controls").children("ul"),f.utils.areElementListsEqual(t,i.children())||(_(o).each(function(e){i.append(e.container)}),a=!0),f.panel.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),f.section.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),a&&e&&e.focus(),f.trigger("pane-contents-reflowed")},f),f.bind("ready",f.reflowPaneContents),f.reflowPaneContents=_.debounce(f.reflowPaneContents,100),m([f.panel,f.section,f.control]).each(function(e,t){t.bind("add",f.reflowPaneContents),t.bind("change",f.reflowPaneContents),t.bind("remove",f.reflowPaneContents)}),f.previewer.previewUrl()?f.previewer.refresh():f.previewer.previewUrl(f.settings.url.home),c=new f.Values,l=c.create("saved"),d=c.create("activated"),u=c.create("processing"),c.bind("change",function(){d()?l()?(r.val(f.l10n.saved).prop("disabled",!0),a.find(".screen-reader-text").text(f.l10n.close)):(r.val(f.l10n.save).prop("disabled",!1),a.find(".screen-reader-text").text(f.l10n.cancel)):(r.val(f.l10n.activate).prop("disabled",!1),a.find(".screen-reader-text").text(f.l10n.cancel))}),l(!0),d(f.settings.theme.active),u(0),f.bind("change",function(){c("saved").set(!1)}),f.bind("saved",function(){c("saved").set(!0),c("activated").set(!0)}),d.bind(function(e){e&&f.trigger("activated")}),f.state=c,r.click(function(e){f.previewer.save(),e.preventDefault()}).keydown(function(e){9!==e.which&&(13===e.which&&f.previewer.save(),e.preventDefault())}),a.keydown(function(e){9!==e.which&&(13===e.which&&this.click(),e.preventDefault())}),m(".collapse-sidebar").on("click",function(){"true"===m(this).attr("aria-expanded")?m(this).attr({"aria-expanded":"false","aria-label":f.l10n.expandSidebar}):m(this).attr({"aria-expanded":"true","aria-label":f.l10n.collapseSidebar}),t.toggleClass("collapsed").toggleClass("expanded")}),m(".customize-controls-preview-toggle").on("click keydown",function(e){f.utils.isKeydownButNotEnterEvent(e)||(t.toggleClass("preview-only"),e.preventDefault())}),f.previewedDevice=new f.Value,f.bind("ready",function(){_.find(f.settings.previewableDevices,function(e,t){if(!0===e["default"])return f.previewedDevice.set(t),!0})}),s.find(".devices button").on("click",function(e){f.previewedDevice.set(m(e.currentTarget).data("device"))}),f.previewedDevice.bind(function(e){var t=m(".wp-full-overlay"),n="";s.find(".devices button").removeClass("active").attr("aria-pressed",!1),s.find(".devices .preview-"+e).addClass("active").attr("aria-pressed",!0),m.each(f.settings.previewableDevices,function(e){n+=" preview-"+e}),t.removeClass(n).addClass("preview-"+e)}),i.length&&f("blogname",function(e){function t(){i.text(m.trim(e())||f.l10n.untitledBlogName)}e.bind(t),t()}),(n=new f.Messenger({url:f.settings.url.parent,channel:"loader"})).bind("back",function(){a.on("click.customize-controls-close",function(e){e.preventDefault(),n.send("close")})}),m(window).on("beforeunload",function(){if(!f.state("saved")())return setTimeout(function(){t.removeClass("customize-loading")},1),f.l10n.saveAlert}),m.each(["saved","change"],function(e,t){f.bind(t,function(){n.send(t)})}),f.bind("activated",function(){n.targetWindow()?n.send("activated",f.settings.url.activated):f.settings.url.activated&&(window.location=f.settings.url.activated)}),f.bind("title",function(e){n.send("title",e)}),n.send("ready"),m.each({background_image:{controls:["background_repeat","background_position_x","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){f(e,function(n){m.each(i.controls,function(e,t){f.control(t,function(t){function e(e){t.container.toggle(i.callback(e))}e(n.get()),n.bind(e)})})})}),f.control("display_header_text",function(t){var n="";t.elements[0].unsync(f("header_textcolor")),t.element=new f.Element(t.container.find("input")),t.element.set("blank"!==t.setting()),t.element.bind(function(e){e||(n=f("header_textcolor").get()),t.setting.set(e?n:"blank")}),t.setting.bind(function(e){t.element.set("blank"!==e)})}),f("show_on_front","page_on_front",function(e,t){function n(){"page"===e()&&0<parseInt(t(),10)&&f.previewer.previewUrl.set(f.settings.url.home)}e.bind(n),t.bind(n)}),f("page_for_posts",function(e){e.bind(function(e){0<(e=parseInt(e,10))&&f.previewer.previewUrl.set(f.settings.url.home+"?page_id="+e)})}),f.previewer.bind("focus-control-for-setting",function(n){var i;f.control.each(function(e){var t=_.pluck(e.settings,"id");-1!==_.indexOf(t,n)&&(i=e)}),i&&i.focus()}),f.previewer.bind("refresh",function(){f.previewer.refresh()}),f.trigger("ready"),(e=a).focus(),setTimeout(function(){e.focus()},200)))})}((wp,jQuery));