From de0835dead5ff5af1dbb190d8c493b33bbed290b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 15 Nov 2016 03:47:30 +0000 Subject: [PATCH] Customize: Only show video header controls if previewing front page; show explanatory notice when controls are hidden. Also include todo for the `header_video` control's `button_labels`. See #38796. Props westonruter, joemcgill, celloexpressions. Fixes #38778. Built from https://develop.svn.wordpress.org/trunk@39237 git-svn-id: http://core.svn.wordpress.org/trunk@39177 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/customize-controls.js | 20 ++++++++++++++++++++ wp-admin/js/customize-controls.min.js | 2 +- wp-includes/class-wp-customize-manager.php | 12 ++++++++++-- wp-includes/version.php | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/wp-admin/js/customize-controls.js b/wp-admin/js/customize-controls.js index 17159a0964..ab834680ec 100644 --- a/wp-admin/js/customize-controls.js +++ b/wp-admin/js/customize-controls.js @@ -5284,6 +5284,26 @@ } ); } ); + // Toggle visibility of Header Video notice when active state change. + api.control( 'header_video', function( headerVideoControl ) { + headerVideoControl.deferred.embedded.done( function() { + var toggleNotice = function() { + var section = api.section( headerVideoControl.section() ), notice; + if ( ! section ) { + return; + } + notice = section.container.find( '.header-video-not-currently-previewable:first' ); + if ( headerVideoControl.active.get() ) { + notice.stop().slideUp( 'fast' ); + } else { + notice.stop().slideDown( 'fast' ); + } + }; + toggleNotice(); + headerVideoControl.active.bind( toggleNotice ); + } ); + } ); + // Update the setting validities. api.previewer.bind( 'selective-refresh-setting-validities', function handleSelectiveRefreshedSettingValidities( settingValidities ) { api._handleSettingValidities( { diff --git a/wp-admin/js/customize-controls.min.js b/wp-admin/js/customize-controls.min.js index 5eccbd389e..6c4ae5fb64 100644 --- a/wp-admin/js/customize-controls.min.js +++ b/wp-admin/js/customize-controls.min.js @@ -1,2 +1,2 @@ !function(a,b){var c,d,e,f=wp.customize;f.Setting=f.Value.extend({initialize:function(a,b,c){var d=this;f.Value.prototype.initialize.call(d,b,c),d.id=a,d.transport=d.transport||"refresh",d._dirty=c.dirty||!1,d.notifications=new f.Values({defaultConstructor:f.Notification}),d.bind(d.preview)},preview:function(){var a,b=this;return a=b.transport,"postMessage"!==a||f.state("previewerAlive").get()||(a="refresh"),"postMessage"===a?b.previewer.send("setting",[b.id,b()]):"refresh"===a?b.previewer.refresh():void 0},findControls:function(){var a=this,b=[];return f.control.each(function(c){_.each(c.settings,function(d){d.id===a.id&&b.push(c)})}),b}}),f._latestRevision=0,f._lastSavedRevision=0,f._latestSettingRevisions={},f.bind("change",function(a){f._latestRevision+=1,f._latestSettingRevisions[a.id]=f._latestRevision}),f.bind("ready",function(){f.bind("add",function(a){a._dirty&&(f._latestRevision+=1,f._latestSettingRevisions[a.id]=f._latestRevision)})}),f.dirtyValues=function(a){var b={};return f.each(function(c){var d;c._dirty&&(d=f._latestSettingRevisions[c.id],f.state("changesetStatus").get()&&a&&a.unsaved&&(_.isUndefined(d)||d<=f._lastSavedRevision)||(b[c.id]=c.get()))}),b},f.requestChangesetUpdate=function(a){var c,d,e,g={};return c=new b.Deferred,a&&_.extend(g,a),_.each(f.dirtyValues({unsaved:!0}),function(b,c){a&&null===a[c]||(g[c]=_.extend({},g[c]||{},{value:b}))}),_.isEmpty(g)?(c.resolve({}),c.promise()):(f.state("processing").set(f.state("processing").get()+1),c.always(function(){f.state("processing").set(f.state("processing").get()-1)}),f.trigger("changeset-save",g),e=f.previewer.query({excludeCustomizedSaved:!0}),delete e.customized,_.extend(e,{nonce:f.settings.nonce.save,customize_theme:f.settings.theme.stylesheet,customize_changeset_data:JSON.stringify(g)}),d=wp.ajax.post("customize_save",e),d.done(function(a){var b={};f._lastSavedRevision=Math.max(f._latestRevision,f._lastSavedRevision),f.state("changesetStatus").set(a.changeset_status),c.resolve(a),f.trigger("changeset-saved",a),a.setting_validities&&_.each(a.setting_validities,function(a,c){!0===a&&_.isObject(g[c])&&!_.isUndefined(g[c].value)&&(b[c]=g[c].value)}),f.previewer.send("changeset-saved",_.extend({},a,{saved_changeset_values:b}))}),d.fail(function(a){c.reject(a),f.trigger("changeset-error",a)}),d.always(function(a){a.setting_validities&&f._handleSettingValidities({settingValidities:a.setting_validities})}),c.promise())},f.utils.bubbleChildValueChanges=function(a,c){b.each(c,function(b,c){a[c].bind(function(b,c){a.parent&&b!==c&&a.parent.trigger("change",a)})})},d=function(a){var b,c,d,e;b=this,a=a||{},d=function(){var a;a=(b.extended(f.Panel)||b.extended(f.Section))&&b.expanded&&b.expanded()?b.contentContainer:b.container,e=a.find(".control-focus:first"),0===e.length&&(e=a.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first()),e.focus()},a.completeCallback?(c=a.completeCallback,a.completeCallback=function(){d(),c()}):a.completeCallback=d,f.state("paneVisible").set(!0),b.expand?b.expand(a):a.completeCallback()},f.utils.prioritySort=function(a,b){return a.priority()===b.priority()&&"number"==typeof a.params.instanceNumber&&"number"==typeof b.params.instanceNumber?a.params.instanceNumber-b.params.instanceNumber:a.priority()-b.priority()},f.utils.isKeydownButNotEnterEvent=function(a){return"keydown"===a.type&&13!==a.which},f.utils.areElementListsEqual=function(a,c){var d=a.length===c.length&&-1===_.indexOf(_.map(_.zip(a,c),function(a){return b(a[0]).is(a[1])}),!1);return d},e=function(){var a,b,c;return a=document.createElement("div"),b={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},c=_.find(_.keys(b),function(b){return!_.isUndefined(a.style[b])}),c?b[c]:null}(),c=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:b.noop},defaultExpandedArguments:{duration:"fast",completeCallback:b.noop},containerType:"container",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null},initialize:function(a,c){var d=this;d.id=a,c=c||{},c.params=_.defaults(c.params||{},d.defaults),b.extend(d,c),d.templateSelector="customize-"+d.containerType+"-"+d.params.type,d.container=b(d.params.content),0===d.container.length&&(d.container=b(d.getContainer())),d.headContainer=d.container,d.contentContainer=d.getContent(),d.container=d.container.add(d.contentContainer),d.deferred={embedded:new b.Deferred},d.priority=new f.Value,d.active=new f.Value,d.activeArgumentsQueue=[],d.expanded=new f.Value,d.expandedArgumentsQueue=[],d.active.bind(function(a){var c=d.activeArgumentsQueue.shift();c=b.extend({},d.defaultActiveArguments,c),a=a&&d.isContextuallyActive(),d.onChangeActive(a,c)}),d.expanded.bind(function(a){var c=d.expandedArgumentsQueue.shift();c=b.extend({},d.defaultExpandedArguments,c),d.onChangeExpanded(a,c)}),d.deferred.embedded.done(function(){d.attachEvents()}),f.utils.bubbleChildValueChanges(d,["priority","active"]),d.priority.set(d.params.priority),d.active.set(d.params.active),d.expanded.set(!1)},ready:function(){},_children:function(a,b){var c=this,d=[];return f[b].each(function(b){b[a].get()===c.id&&d.push(b)}),d.sort(f.utils.prioritySort),d},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(a,c){var d,e,g=this,h=g.headContainer;return c.unchanged?void(c.completeCallback&&c.completeCallback()):(d="resolved"===f.previewer.deferred.active.state()?c.duration:0,g.extended(f.Panel)&&(f.panel.each(function(a){a!==g&&a.expanded()&&(e=a,d=0)}),a||_.each(g.sections(),function(a){a.collapse({duration:0})})),void(b.contains(document,h)?a?h.stop(!0,!0).slideDown(d,c.completeCallback):g.expanded()?g.collapse({duration:d,completeCallback:function(){h.stop(!0,!0).slideUp(d,c.completeCallback)}}):h.stop(!0,!0).slideUp(d,c.completeCallback):(h.toggle(a),c.completeCallback&&c.completeCallback())))},_toggleActive:function(a,b){var c=this;return b=b||{},a&&this.active.get()||!a&&!this.active.get()?(b.unchanged=!0,c.onChangeActive(c.active.get(),b),!1):(b.unchanged=!1,this.activeArgumentsQueue.push(b),this.active.set(a),!0)},activate:function(a){return this._toggleActive(!0,a)},deactivate:function(a){return this._toggleActive(!1,a)},onChangeExpanded:function(){throw new Error("Must override with subclass.")},_toggleExpanded:function(a,b){var c,d=this;return b=b||{},c=b.completeCallback,!(a&&!d.active())&&(f.state("paneVisible").set(!0),b.completeCallback=function(){c&&c.apply(d,arguments),a?d.container.trigger("expanded"):d.container.trigger("collapsed")},a&&d.expanded.get()||!a&&!d.expanded.get()?(b.unchanged=!0,d.onChangeExpanded(d.expanded.get(),b),!1):(b.unchanged=!1,d.expandedArgumentsQueue.push(b),d.expanded.set(a),!0))},expand:function(a){return this._toggleExpanded(!0,a)},collapse:function(a){return this._toggleExpanded(!1,a)},_animateChangeExpanded:function(a){if(!e)return void(a&&a());var c,d,f=this,g=f.contentContainer,h=g.closest(".wp-full-overlay");c=h.add(g),(_.isUndefined(f.panel)||""===f.panel())&&(c=c.add("#customize-info, .customize-pane-parent")),d=function(f){2===f.eventPhase&&b(f.target).is(g)&&(g.off(e,d),c.removeClass("busy"),a&&a())},g.on(e,d),c.addClass("busy"),_.defer(function(){var a=g.closest(".wp-full-overlay-sidebar-content"),b=a.scrollTop(),c=g.data("previous-scrollTop")||0,d=f.expanded();d&&0"},getContent:function(){var a=this,b=a.container,c=b.find(".accordion-section-content, .control-panel-content").first(),d="sub-"+b.attr("id"),e=d,f=b.attr("aria-owns");return f&&(e=e+" "+f),b.attr("aria-owns",e),c.detach().attr({id:d,"class":"customize-pane-child "+c.attr("class")+" "+b.attr("class")})}}),f.Section=c.extend({containerType:"section",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null,panel:null,customizeAction:""},initialize:function(a,d){var e=this;c.prototype.initialize.call(e,a,d),e.id=a,e.panel=new f.Value,e.panel.bind(function(a){b(e.headContainer).toggleClass("control-subsection",!!a)}),e.panel.set(e.params.panel||""),f.utils.bubbleChildValueChanges(e,["panel"]),e.embed(),e.deferred.embedded.done(function(){e.ready()})},embed:function(){var a,c=this,d=b("#customize-theme-controls");a=function(a){var e;a?f.panel(a,function(a){a.deferred.embedded.done(function(){e=a.contentContainer,c.headContainer.parent().is(e)||e.append(c.headContainer),c.contentContainer.parent().is(c.headContainer)||d.append(c.contentContainer),c.deferred.embedded.resolve()})}):(e=b(".customize-pane-parent"),c.headContainer.parent().is(e)||e.append(c.headContainer),c.contentContainer.parent().is(c.headContainer)||d.append(c.contentContainer),c.deferred.embedded.resolve())},c.panel.bind(a),a(c.panel.get())},attachEvents:function(){var a,b,c=this;c.container.hasClass("cannot-expand")||(c.container.find(".accordion-section-title, .customize-section-back").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),c.expanded()?c.collapse():c.expand())}),c.container.find(".customize-section-title .customize-help-toggle").on("click",function(){a=c.container.find(".section-meta"),a.hasClass("cannot-expand")||(b=a.find(".customize-section-description:first"),b.toggleClass("open"),b.slideToggle(),b.attr("aria-expanded",function(a,b){return"true"===b?"false":"true"}))}))},isContextuallyActive:function(){var a=this,b=a.controls(),c=0;return _(b).each(function(a){a.active()&&(c+=1)}),0!==c},controls:function(){return this._children("section","control")},onChangeExpanded:function(a,c){var d,e=this,g=e.headContainer.closest(".wp-full-overlay-sidebar-content"),h=e.contentContainer,i=e.headContainer.closest(".wp-full-overlay"),j=h.find(".customize-section-back"),k=e.headContainer.find(".accordion-section-title").first();a&&!h.hasClass("open")?(d=c.unchanged?c.completeCallback:b.proxy(function(){e._animateChangeExpanded(function(){k.attr("tabindex","-1"),j.attr("tabindex","0"),j.focus(),h.css("top",""),g.scrollTop(0),c.completeCallback&&c.completeCallback()}),h.addClass("open"),i.addClass("section-open"),f.state("expandedSection").set(e)},this),c.allowMultiple||f.section.each(function(a){a!==e&&a.collapse({duration:c.duration})}),e.panel()?f.panel(e.panel()).expand({duration:c.duration,completeCallback:d}):(f.panel.each(function(a){a.collapse()}),d())):!a&&h.hasClass("open")?(e._animateChangeExpanded(function(){j.attr("tabindex","-1"),k.attr("tabindex","0"),k.focus(),h.css("top",""),c.completeCallback&&c.completeCallback()}),h.removeClass("open"),i.removeClass("section-open"),e===f.state("expandedSection").get()&&f.state("expandedSection").set(!1)):c.completeCallback&&c.completeCallback()}}),f.ThemesSection=f.Section.extend({currentTheme:"",overlay:"",template:"",screenshotQueue:null,$window:b(window),initialize:function(){return this.$customizeSidebar=b(".wp-full-overlay-sidebar-content:first"),f.Section.prototype.initialize.apply(this,arguments)},ready:function(){var a=this;a.overlay=a.container.find(".theme-overlay"),a.template=wp.template("customize-themes-details-view"),a.container.on("keydown",function(b){a.overlay.find(".theme-wrap").is(":visible")&&(39===b.keyCode&&a.nextTheme(),37===b.keyCode&&a.previousTheme(),27===b.keyCode&&(a.closeDetails(),b.stopPropagation()))}),_.bindAll(this,"renderScreenshots")},isContextuallyActive:function(){return this.active()},attachEvents:function(){var a=this;a.container.find(".change-theme, .customize-theme").on("click keydown",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),a.expanded()?a.collapse():a.expand())}),a.container.on("click keydown",".left",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),a.previousTheme())}),a.container.on("click keydown",".right",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),a.nextTheme())}),a.container.on("click keydown",".theme-backdrop, .close",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),a.closeDetails())});var b=_.throttle(_.bind(a.renderScreenshots,this),100);a.container.on("input","#themes-filter",function(c){var d,e=c.currentTarget.value.toLowerCase().trim().replace("-"," "),f=a.controls();_.each(f,function(a){a.filter(e)}),b(),d=a.container.find("li.customize-control:visible").length,a.container.find(".theme-count").text(d)}),f.bind("ready",function(){_.each(a.controls().slice(0,3),function(a){var b,c=a.params.theme.screenshot[0];c&&(b=new Image,b.src=c)})})},onChangeExpanded:function(a,b){if(b.unchanged)return void(b.completeCallback&&b.completeCallback());var c=this,d=c.contentContainer,e=d.closest(".wp-full-overlay"),g=d.closest(".wp-full-overlay-sidebar-content"),h=d.find(".customize-theme"),i=c.headContainer.find(".change-theme");a&&!d.hasClass("current-panel")?(f.section.each(function(a){a!==c&&a.collapse({duration:b.duration})}),f.panel.each(function(a){a.collapse({duration:0})}),c._animateChangeExpanded(function(){i.attr("tabindex","-1"),h.attr("tabindex","0"),h.focus(),d.css("top",""),g.scrollTop(0),b.completeCallback&&b.completeCallback()}),e.addClass("in-themes-panel"),d.addClass("current-panel"),_.delay(c.renderScreenshots,10),c.$customizeSidebar.on("scroll.customize-themes-section",_.throttle(c.renderScreenshots,300))):!a&&d.hasClass("current-panel")&&(c._animateChangeExpanded(function(){i.attr("tabindex","0"),h.attr("tabindex","-1"),i.focus(),d.css("top",""),b.completeCallback&&b.completeCallback()}),e.removeClass("in-themes-panel"),d.removeClass("current-panel"),c.$customizeSidebar.off("scroll.customize-themes-section"))},renderScreenshots:function(){var a=this;null===a.screenshotQueue&&(a.screenshotQueue=a.controls()),a.screenshotQueue.length&&(a.screenshotQueue=_.filter(a.screenshotQueue,function(b){var c=b.container.find(".theme-screenshot"),d=c.find("img");if(!d.length)return!1;if(d.is(":hidden"))return!0;var e=a.$window.scrollTop(),f=e+a.$window.height(),g=d.offset().top,h=c.height(),i=g+h,j=3*h,k=i>=e-j&&g<=f+j;return k&&b.container.trigger("render-screenshot"),!k}))},nextTheme:function(){var a=this;a.getNextTheme()&&a.showDetails(a.getNextTheme(),function(){a.overlay.find(".right").focus()})},getNextTheme:function(){var a,b;return a=f.control("theme_"+this.currentTheme),b=a.container.next("li.customize-control-theme"),!!b.length&&(b=b[0].id.replace("customize-control-",""),a=f.control(b),a.params.theme)},previousTheme:function(){var a=this;a.getPreviousTheme()&&a.showDetails(a.getPreviousTheme(),function(){a.overlay.find(".left").focus()})},getPreviousTheme:function(){var a,b;return a=f.control("theme_"+this.currentTheme),b=a.container.prev("li.customize-control-theme"),!!b.length&&(b=b[0].id.replace("customize-control-",""),a=f.control(b),a.params.theme)},updateLimits:function(){this.getNextTheme()||this.overlay.find(".right").addClass("disabled"),this.getPreviousTheme()||this.overlay.find(".left").addClass("disabled")},loadThemePreview:function(a){var c,d,e,g=b.Deferred();return e=document.createElement("a"),e.href=location.href,e.search=b.param(_.extend(f.utils.parseQueryString(e.search.substr(1)),{theme:a,changeset_uuid:f.settings.changeset.uuid})),d=b(".wp-full-overlay"),d.addClass("customize-loading"),c=function(){var a;f.state("processing").get()>0||(f.state("processing").unbind(c),a=f.requestChangesetUpdate(),a.done(function(){b(window).off("beforeunload.customize-confirm"),window.location.href=e.href}),a.fail(function(){d.removeClass("customize-loading")}))},0===f.state("processing").get()?c():f.state("processing").bind(c),g.promise()},showDetails:function(a,c){var d,e=this;c=c||function(){},e.currentTheme=a.id,e.overlay.html(e.template(a)).fadeIn("fast").focus(),b("body").addClass("modal-open"),e.containFocus(e.overlay),e.updateLimits(),d=e.overlay.find(".inactive-theme > a"),d.on("click",function(b){b.preventDefault(),d.hasClass("disabled")||(d.addClass("disabled"),e.loadThemePreview(a.id).fail(function(){d.removeClass("disabled")}))}),c()},closeDetails:function(){b("body").removeClass("modal-open"),this.overlay.fadeOut("fast"),f.control("theme_"+this.currentTheme).focus()},containFocus:function(a){var c;a.on("keydown",function(d){if(9===d.keyCode)return c=b(":tabbable",a),c.last()[0]!==d.target||d.shiftKey?c.first()[0]===d.target&&d.shiftKey?(c.last().focus(),!1):void 0:(c.first().focus(),!1)})}}),f.Panel=c.extend({containerType:"panel",initialize:function(a,b){var d=this;c.prototype.initialize.call(d,a,b),d.embed(),d.deferred.embedded.done(function(){d.ready()})},embed:function(){var a=this,c=b("#customize-theme-controls"),d=b(".customize-pane-parent");a.headContainer.parent().is(d)||d.append(a.headContainer),a.contentContainer.parent().is(a.headContainer)||(c.append(a.contentContainer),a.renderContent()),a.deferred.embedded.resolve()},attachEvents:function(){var a,c=this;c.headContainer.find(".accordion-section-title").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),c.expanded()||c.expand())}),c.container.find(".customize-panel-back").on("click keydown",function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),c.expanded()&&c.collapse())}),a=c.container.find(".panel-meta:first"),a.find("> .accordion-section-title .customize-help-toggle").on("click keydown",function(d){if(!f.utils.isKeydownButNotEnterEvent(d)&&(d.preventDefault(),!a.hasClass("cannot-expand"))){var e=a.find(".customize-panel-description:first");a.hasClass("open")?(a.toggleClass("open"),e.slideUp(c.defaultExpandedArguments.duration),b(this).attr("aria-expanded",!1)):(e.slideDown(c.defaultExpandedArguments.duration),a.toggleClass("open"),b(this).attr("aria-expanded",!0))}})},sections:function(){return this._children("panel","section")},isContextuallyActive:function(){var a=this,b=a.sections(),c=0;return _(b).each(function(a){a.active()&&a.isContextuallyActive()&&(c+=1)}),0!==c},onChangeExpanded:function(a,b){if(b.unchanged)return void(b.completeCallback&&b.completeCallback());var c=this,d=c.contentContainer,e=d.closest(".wp-full-overlay"),g=d.closest(".wp-full-overlay-sidebar-content"),h=c.headContainer.find(".accordion-section-title"),i=d.find(".customize-panel-back");a&&!d.hasClass("current-panel")?(f.section.each(function(a){c.id!==a.panel()&&a.collapse({duration:0})}),f.panel.each(function(a){c!==a&&a.collapse({duration:0})}),c._animateChangeExpanded(function(){h.attr("tabindex","-1"),i.attr("tabindex","0"),i.focus(),d.css("top",""),g.scrollTop(0),b.completeCallback&&b.completeCallback()}),e.addClass("in-sub-panel"),d.addClass("current-panel"),f.state("expandedPanel").set(c)):!a&&d.hasClass("current-panel")&&(c._animateChangeExpanded(function(){h.attr("tabindex","0"),i.attr("tabindex","-1"),h.focus(),d.css("top",""),b.completeCallback&&b.completeCallback()}),e.removeClass("in-sub-panel"),d.removeClass("current-panel"),c===f.state("expandedPanel").get()&&f.state("expandedPanel").set(!1))},renderContent:function(){var a,c=this;a=0!==b("#tmpl-"+c.templateSelector+"-content").length?wp.template(c.templateSelector+"-content"):wp.template("customize-panel-default-content"),a&&c.headContainer&&c.contentContainer.html(a(c.params))}}),f.Control=f.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:b.noop},initialize:function(a,c){var d,e,g,h=this;h.params={},b.extend(h,c||{}),h.id=a,h.selector="#customize-control-"+a.replace(/\]/g,"").replace(/\[/g,"-"),h.templateSelector="customize-control-"+h.params.type+"-content",h.container=b(h.params.content?h.params.content:h.selector),h.deferred={embedded:new b.Deferred},h.section=new f.Value,h.priority=new f.Value,h.active=new f.Value,h.activeArgumentsQueue=[],h.notifications=new f.Values({defaultConstructor:f.Notification}),h.elements=[],d=h.container.find("[data-customize-setting-link]"),e={},d.each(function(){var a,c=b(this);if(c.is(":radio")){if(a=c.prop("name"),e[a])return;e[a]=!0,c=d.filter('[name="'+a+'"]')}f(c.data("customizeSettingLink"),function(a){var b=new f.Element(c);h.elements.push(b),b.sync(a),b.set(a())})}),h.active.bind(function(a){var c=h.activeArgumentsQueue.shift();c=b.extend({},h.defaultActiveArguments,c),h.onChangeActive(a,c)}),h.section.set(h.params.section),h.priority.set(isNaN(h.params.priority)?10:h.params.priority),h.active.set(h.params.active),f.utils.bubbleChildValueChanges(h,["section","priority","active"]),g=b.map(h.params.settings,function(a){return a}),0===g.length?(h.setting=null,h.settings={},h.embed()):f.apply(f,g.concat(function(){var a;h.settings={};for(a in h.params.settings)h.settings[a]=f(h.params.settings[a]);h.setting=h.settings["default"]||null,_.each(h.settings,function(a){a.notifications.bind("add",function(b){var c,d,e;d=a.id+":"+b.code,e=_.extend({},b,{setting:a.id}),c=new f.Notification(d,e),h.notifications.add(c.code,c)}),a.notifications.bind("remove",function(b){h.notifications.remove(a.id+":"+b.code)})}),h.embed()})),h.deferred.embedded.done(function(){var a=_.debounce(function(){h.renderNotifications()});h.notifications.bind("add",function(b){wp.a11y.speak(b.message,"assertive"),a()}),h.notifications.bind("remove",a),h.renderNotifications(),h.ready()})},embed:function(){var a,b=this;a=function(a){var c;a&&f.section(a,function(a){a.deferred.embedded.done(function(){c=a.contentContainer.is("ul")?a.contentContainer:a.contentContainer.find("ul:first"),b.container.parent().is(c)||(c.append(b.container),b.renderContent()),b.deferred.embedded.resolve()})})},b.section.bind(a),a(b.section.get())},ready:function(){var a,c=this;"dropdown-pages"===c.params.type&&c.params.allow_addition&&(a=c.container.find(".new-content-item"),a.hide(),c.container.on("click",".add-new-toggle",function(c){b(c.currentTarget).slideUp(180),a.slideDown(180),a.find(".create-item-input").focus()}),c.container.on("click",".add-content",function(){c.addNewPage()}),c.container.on("keyup",".create-item-input",function(a){13===a.which&&c.addNewPage()}))},getNotificationsContainerElement:function(){var a,c,d=this;return c=d.container.find(".customize-control-notifications-container:first"),c.length?c:(c=b('
'),d.container.hasClass("customize-control-nav_menu_item")?d.container.find(".menu-item-settings:first").prepend(c):d.container.hasClass("customize-control-widget_form")?d.container.find(".widget-inside:first").prepend(c):(a=d.container.find(".customize-control-title"),a.length?a.after(c):d.container.prepend(c)),c)},renderNotifications:function(){var a,c,d=this,e=!1;a=d.getNotificationsContainerElement(),a&&a.length&&(c=[],d.notifications.each(function(a){c.push(a),"error"===a.type&&(e=!0)}),0===c.length?a.stop().slideUp("fast"):a.stop().slideDown("fast",null,function(){b(this).css("height","auto")}),d.notificationsTemplate||(d.notificationsTemplate=wp.template("customize-control-notifications")),d.container.toggleClass("has-notifications",0!==c.length),d.container.toggleClass("has-error",e),a.empty().append(b.trim(d.notificationsTemplate({notifications:c,altNotice:Boolean(d.altNotice)}))))},expand:function(a){f.section(this.section()).expand(a)},focus:d,onChangeActive:function(a,c){return c.unchanged?void(c.completeCallback&&c.completeCallback()):void(b.contains(document,this.container[0])?a?this.container.slideDown(c.duration,c.completeCallback):this.container.slideUp(c.duration,c.completeCallback):(this.container.toggle(a),c.completeCallback&&c.completeCallback()))},toggle:function(a){return this.onChangeActive(a,this.defaultActiveArguments)},activate:c.prototype.activate,deactivate:c.prototype.deactivate,_toggleActive:c.prototype._toggleActive,dropdownInit:function(){var a=this,b=this.container.find(".dropdown-status"),c=this.params,d=!1,e=function(a){"string"==typeof a&&c.statuses&&c.statuses[a]?b.html(c.statuses[a]).show():b.hide()};this.container.on("click keydown",".dropdown",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),d||a.container.toggleClass("open"),a.container.hasClass("open")&&a.container.parent().parent().find("li.library-selected").focus(),d=!0,setTimeout(function(){d=!1},400))}),this.setting.bind(e),e(this.setting())},renderContent:function(){var a,c=this;0!==b("#tmpl-"+c.templateSelector).length&&(a=wp.template(c.templateSelector),a&&c.container&&c.container.html(a(c.params)))},addNewPage:function(){var a,c,d,e,g,h,i=this;if("dropdown-pages"===i.params.type&&i.params.allow_addition&&f.Menus){if(c=i.container.find(".add-new-toggle"),d=i.container.find(".new-content-item"),e=i.container.find(".create-item-input"),g=e.val(),h=i.container.find("select"),!g)return void e.addClass("invalid");e.removeClass("invalid"),e.attr("disabled","disabled"),a=f.Menus.insertAutoDraftPost({post_title:g,post_type:"page"}),a.done(function(a){var e,j,k;e=new f.Menus.AvailableItemModel({id:"post-"+a.post_id,title:g,type:"page",type_label:f.Menus.data.l10n.page_label,object:"post_type",object_id:a.post_id,url:a.url}),f.Menus.availableMenuItemsPanel.collection.add(e),j=b("#available-menu-items-post_type-page").find(".available-menu-items-list"),k=wp.template("available-menu-item"),j.prepend(k(e.attributes)),h.focus(),i.setting.set(String(a.post_id)),d.slideUp(180),c.slideDown(180)}).always(function(){e.val("").removeAttr("disabled")})}}}),f.ColorControl=f.Control.extend({ready:function(){var a,b=this,c="hue"===this.params.mode,d=!1;c?(a=this.container.find(".color-picker-hue"),a.val(b.setting()).wpColorPicker({change:function(a,c){d=!0,b.setting(c.color.h()),d=!1}})):(a=this.container.find(".color-picker-hex"),a.val(b.setting()).wpColorPicker({change:function(){d=!0,b.setting.set(a.wpColorPicker("color")),d=!1},clear:function(){d=!0,b.setting.set(""),d=!1}})),b.setting.bind(function(b){d||(a.val(b),a.wpColorPicker("color",b))}),b.container.on("keydown",function(c){var d;27===c.which&&(d=b.container.find(".wp-picker-container"),d.hasClass("wp-picker-active")&&(a.wpColorPicker("close"),b.container.find(".wp-color-result").focus(),c.stopPropagation()))})}}),f.MediaControl=f.Control.extend({ready:function(){function a(a){var d=b.Deferred();c.extended(f.UploadControl)?d.resolve():(a=parseInt(a,10),_.isNaN(a)||a<=0?(delete c.params.attachment,d.resolve()):c.params.attachment&&c.params.attachment.id===a&&d.resolve()),"pending"===d.state()&&wp.media.attachment(a).fetch().done(function(){c.params.attachment=this.attributes,d.resolve(),wp.customize.previewer.send(c.setting.id+"-attachment-data",this.attributes)}),d.done(function(){c.renderContent()})}var c=this;_.bindAll(c,"restoreDefault","removeFile","openFrame","select","pausePlayer"),c.container.on("click keydown",".upload-button",c.openFrame),c.container.on("click keydown",".upload-button",c.pausePlayer),c.container.on("click keydown",".thumbnail-image img",c.openFrame),c.container.on("click keydown",".default-button",c.restoreDefault),c.container.on("click keydown",".remove-button",c.pausePlayer),c.container.on("click keydown",".remove-button",c.removeFile),c.container.on("click keydown",".remove-button",c.cleanupPlayer),f.section(c.section()).container.on("expanded",function(){c.player&&c.player.setControlsSize()}).on("collapsed",function(){c.pausePlayer()}),a(c.setting()),c.setting.bind(a)},pausePlayer:function(){this.player&&this.player.pause()},cleanupPlayer:function(){this.player&&wp.media.mixin.removePlayer(this.player)},openFrame:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.frame||this.initFrame(),this.frame.open())},initFrame:function(){this.frame=wp.media({button:{text:this.params.button_labels.frame_button},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:this.params.mime_type}),multiple:!1,date:!1})]}),this.frame.on("select",this.select)},select:function(){var a,b=this.frame.state().get("selection").first().toJSON(),c=window._wpmejsSettings||{};this.params.attachment=b,this.setting(b.id),a=this.container.find("audio, video").get(0),a?this.player=new MediaElementPlayer(a,c):this.cleanupPlayer()},restoreDefault:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.params.attachment=this.params.defaultAttachment,this.setting(this.params.defaultAttachment.url))},removeFile:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent())}}),f.UploadControl=f.MediaControl.extend({select:function(){var a,b=this.frame.state().get("selection").first().toJSON(),c=window._wpmejsSettings||{};this.params.attachment=b,this.setting(b.url),a=this.container.find("audio, video").get(0),a?this.player=new MediaElementPlayer(a,c):this.cleanupPlayer()},success:function(){},removerVisibility:function(){}}),f.ImageControl=f.UploadControl.extend({thumbnailSrc:function(){}}),f.BackgroundControl=f.UploadControl.extend({ready:function(){f.UploadControl.prototype.ready.apply(this,arguments)},select:function(){f.UploadControl.prototype.select.apply(this,arguments),wp.ajax.post("custom-background-add",{nonce:_wpCustomizeBackground.nonces.add,wp_customize:"on",customize_theme:f.settings.theme.stylesheet,attachment_id:this.params.attachment.id})}}),f.BackgroundPositionControl=f.Control.extend({ready:function(){var a,c=this;c.container.on("change",'input[name="background-position"]',function(){var a=b(this).val().split(" ");c.settings.x(a[0]),c.settings.y(a[1])}),a=_.debounce(function(){var a,b,d,e;a=c.settings.x.get(),b=c.settings.y.get(),e=String(a)+" "+String(b),d=c.container.find('input[name="background-position"][value="'+e+'"]'),d.click()}),c.settings.x.bind(a),c.settings.y.bind(a),a()}}),f.CroppedImageControl=f.MediaControl.extend({openFrame:function(a){f.utils.isKeydownButNotEnterEvent(a)||(this.initFrame(),this.frame.setState("library").open())},initFrame:function(){var a=_wpMediaViewsL10n;this.frame=wp.media({button:{text:a.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.CustomizeImageCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var a=this.frame.state().get("selection").first().toJSON();this.params.width!==a.width||this.params.height!==a.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):(this.setImageFromAttachment(a),this.frame.close())},onCropped:function(a){this.setImageFromAttachment(a)},calculateImageSelectOptions:function(a,b){var c,d,e,f=b.get("control"),g=!!parseInt(f.params.flex_width,10),h=!!parseInt(f.params.flex_height,10),i=a.get("width"),j=a.get("height"),k=parseInt(f.params.width,10),l=parseInt(f.params.height,10),m=k/l,n=k,o=l;return b.set("canSkipCrop",!f.mustBeCropped(g,h,k,l,i,j)),i/j>m?(l=j,k=l*m):(k=i,l=k/m),c=(i-k)/2,d=(j-l)/2,e={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:i,imageHeight:j,minWidth:n>k?k:n,minHeight:o>l?l:o,x1:c,y1:d,x2:k+c,y2:l+d},h===!1&&g===!1&&(e.aspectRatio=k+":"+l),!0===h&&(delete e.minHeight,e.maxWidth=i),!0===g&&(delete e.minWidth,e.maxHeight=j),e},mustBeCropped:function(a,b,c,d,e,f){return(!0!==a||!0!==b)&&((!0!==a||d!==f)&&((!0!==b||c!==e)&&((c!==e||d!==f)&&!(e<=c))))},onSkippedCrop:function(){var a=this.frame.state().get("selection").first().toJSON();this.setImageFromAttachment(a)},setImageFromAttachment:function(a){this.params.attachment=a,this.setting(a.id)}}),f.SiteIconControl=f.CroppedImageControl.extend({ -initFrame:function(){var a=_wpMediaViewsL10n;this.frame=wp.media({button:{text:a.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.SiteIconCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var a=this.frame.state().get("selection").first().toJSON(),b=this;this.params.width!==a.width||this.params.height!==a.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):wp.ajax.post("crop-image",{nonce:a.nonces.edit,id:a.id,context:"site-icon",cropDetails:{x1:0,y1:0,width:this.params.width,height:this.params.height,dst_width:this.params.width,dst_height:this.params.height}}).done(function(a){b.setImageFromAttachment(a),b.frame.close()}).fail(function(){b.frame.trigger("content:error:crop")})},setImageFromAttachment:function(a){var c,d,e=["site_icon-32","thumbnail","full"];_.each(e,function(b){d||_.isUndefined(a.sizes[b])||(d=a.sizes[b])}),this.params.attachment=a,this.setting(a.id),d&&(c=b('link[rel="icon"][sizes="32x32"]'),c.attr("href",d.url))},removeFile:function(a){f.utils.isKeydownButNotEnterEvent(a)||(a.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent(),b('link[rel="icon"][sizes="32x32"]').attr("href","/favicon.ico"))}}),f.HeaderControl=f.Control.extend({ready:function(){this.btnRemove=b("#customize-control-header_image .actions .remove"),this.btnNew=b("#customize-control-header_image .actions .new"),_.bindAll(this,"openMedia","removeImage"),this.btnNew.on("click",this.openMedia),this.btnRemove.on("click",this.removeImage),f.HeaderTool.currentHeader=this.getInitialHeaderImage(),new f.HeaderTool.CurrentView({model:f.HeaderTool.currentHeader,el:"#customize-control-header_image .current .container"}),new f.HeaderTool.ChoiceListView({collection:f.HeaderTool.UploadsList=new f.HeaderTool.ChoiceList,el:"#customize-control-header_image .choices .uploaded .list"}),new f.HeaderTool.ChoiceListView({collection:f.HeaderTool.DefaultsList=new f.HeaderTool.DefaultsList,el:"#customize-control-header_image .choices .default .list"}),f.HeaderTool.combinedList=f.HeaderTool.CombinedList=new f.HeaderTool.CombinedList([f.HeaderTool.UploadsList,f.HeaderTool.DefaultsList]),wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize="on",wp.media.controller.Cropper.prototype.defaults.doCropArgs.customize_theme=f.settings.theme.stylesheet},getInitialHeaderImage:function(){if(!f.get().header_image||!f.get().header_image_data||_.contains(["remove-header","random-default-image","random-uploaded-image"],f.get().header_image))return new f.HeaderTool.ImageModel;var a=_.find(_wpCustomizeHeader.uploads,function(a){return a.attachment_id===f.get().header_image_data.attachment_id});return a||(a={url:f.get().header_image,thumbnail_url:f.get().header_image,attachment_id:f.get().header_image_data.attachment_id}),new f.HeaderTool.ImageModel({header:a,choice:a.url.split("/").pop()})},calculateImageSelectOptions:function(a,b){var c,d,e,g,h,i,j=parseInt(_wpCustomizeHeader.data.width,10),k=parseInt(_wpCustomizeHeader.data.height,10),l=!!parseInt(_wpCustomizeHeader.data["flex-width"],10),m=!!parseInt(_wpCustomizeHeader.data["flex-height"],10);return h=a.get("width"),g=a.get("height"),this.headerImage=new f.HeaderTool.ImageModel,this.headerImage.set({themeWidth:j,themeHeight:k,themeFlexWidth:l,themeFlexHeight:m,imageWidth:h,imageHeight:g}),b.set("canSkipCrop",!this.headerImage.shouldBeCropped()),c=j/k,d=h,e=g,d/e>c?(k=e,j=k*c):(j=d,k=j/c),i={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:h,imageHeight:g,x1:0,y1:0,x2:j,y2:k},m===!1&&l===!1&&(i.aspectRatio=j+":"+k),m===!1&&(i.maxHeight=k),l===!1&&(i.maxWidth=j),i},openMedia:function(a){var b=_wpMediaViewsL10n;a.preventDefault(),this.frame=wp.media({button:{text:b.selectAndCrop,close:!1},states:[new wp.media.controller.Library({title:b.chooseImage,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:_wpCustomizeHeader.data.width,suggestedHeight:_wpCustomizeHeader.data.height}),new wp.media.controller.Cropper({imgSelectOptions:this.calculateImageSelectOptions})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this),this.frame.open()},onSelect:function(){this.frame.setState("cropper")},onCropped:function(a){var b=a.url,c=a.attachment_id,d=a.width,e=a.height;this.setImageFromURL(b,c,d,e)},onSkippedCrop:function(a){var b=a.get("url"),c=a.get("width"),d=a.get("height");this.setImageFromURL(b,a.id,c,d)},setImageFromURL:function(a,b,c,d){var e,g={};g.url=a,g.thumbnail_url=a,g.timestamp=_.now(),b&&(g.attachment_id=b),c&&(g.width=c),d&&(g.height=d),e=new f.HeaderTool.ImageModel({header:g,choice:a.split("/").pop()}),f.HeaderTool.UploadsList.add(e),f.HeaderTool.currentHeader.set(e.toJSON()),e.save(),e.importImage()},removeImage:function(){f.HeaderTool.currentHeader.trigger("hide"),f.HeaderTool.CombinedList.trigger("control:removeImage")}}),f.ThemeControl=f.Control.extend({touchDrag:!1,isRendered:!1,renderContent:function(){var a=this,b=arguments;f.section(a.section(),function(c){c.expanded()?(f.Control.prototype.renderContent.apply(a,b),a.isRendered=!0):c.expanded.bind(function(c){c&&!a.isRendered&&(f.Control.prototype.renderContent.apply(a,b),a.isRendered=!0)})})},ready:function(){var a=this;a.container.on("touchmove",".theme",function(){a.touchDrag=!0}),a.container.on("click keydown touchend",".theme",function(c){if(!f.utils.isKeydownButNotEnterEvent(c))return a.touchDrag===!0?a.touchDrag=!1:void(b(c.target).is(".theme-actions .button")||f.section(a.section()).loadThemePreview(a.params.theme.id))}),a.container.on("click keydown",".theme-actions .theme-details",function(b){f.utils.isKeydownButNotEnterEvent(b)||(b.preventDefault(),f.section(a.section()).showDetails(a.params.theme))}),a.container.on("render-screenshot",function(){var a=b(this).find("img"),c=a.data("src");c&&a.attr("src",c)})},filter:function(a){var b=this,c=b.params.theme.name+" "+b.params.theme.description+" "+b.params.theme.tags+" "+b.params.theme.author;c=c.toLowerCase().replace("-"," "),-1!==c.search(a)?b.activate():b.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:null,initialize:function(a,c){var d=b.Deferred();d.promise(this),this.container=a.container,b.extend(a,{channel:f.PreviewFrame.uuid()}),f.Messenger.prototype.initialize.call(this,a,c),this.add("previewUrl",a.previewUrl),this.query=b.extend(a.query||{},{customize_messenger_channel:this.channel()}),this.run(d)},run:function(a){var c,d,e,g=this,h=!1,i=!1,j=null,k="{}"!==g.query.customized;g._ready&&g.unbind("ready",g._ready),g._ready=function(b){i=!0,j=b,g.container.addClass("iframe-ready"),b&&h&&a.resolveWith(g,[b])},g.bind("ready",g._ready),c=document.createElement("a"),c.href=g.previewUrl(),d=_.extend(f.utils.parseQueryString(c.search.substr(1)),{customize_changeset_uuid:g.query.customize_changeset_uuid,customize_theme:g.query.customize_theme,customize_messenger_channel:g.query.customize_messenger_channel}),c.search=b.param(d),g.iframe=b("