"+h.l10n.cheatin+"
")}}),h.controlConstructor={color:h.ColorControl,upload:h.UploadControl,image:h.ImageControl,header:h.HeaderControl},h.panelConstructor={},h.sectionConstructor={},b(function(){if(h.settings=window._wpCustomizeSettings,h.l10n=window._wpCustomizeControlsL10n,h.settings){if(!b.support.postMessage||!b.support.cors&&h.settings.isCrossDomain)return window.location=h.settings.url.fallback;var a,c,d=b(document.body),e=d.children(".wp-full-overlay"),i=b("#customize-info .theme-name.site-title"),j=b(".customize-controls-close"),k=b("#save");b("#customize-controls").on("keydown",function(a){var c=13===a.which,d=b(a.target);c&&(d.is("input:not([type=button])")||d.is("select"))&&a.preventDefault()}),b("#customize-info").find("> .accordion-section-title").on("click keydown",function(a){if(!f(a)){a.preventDefault();var c=b(this).parent(),d=c.find(".accordion-section-content:first");c.hasClass("cannot-expand")||(c.hasClass("open")?(c.toggleClass("open"),d.slideUp(h.Panel.prototype.defaultExpandedArguments.duration)):(d.slideDown(h.Panel.prototype.defaultExpandedArguments.duration),c.toggleClass("open")))}}),h.previewer=new h.Previewer({container:"#customize-preview",form:"#customize-controls",previewUrl:h.settings.url.preview,allowedUrls:h.settings.url.allowed,signature:"WP_CUSTOMIZER_SIGNATURE"},{nonce:h.settings.nonce,query:function(){var a={};return h.each(function(b,c){b._dirty&&(a[c]=b())}),{wp_customize:"on",theme:h.settings.theme.stylesheet,customized:JSON.stringify(a),nonce:this.nonce.preview}},save:function(){var a,c,e=this,f=b.extend(this.query(),{action:"customize_save",nonce:this.nonce.save}),g=h.state("processing");d.addClass("saving"),c=function(){var a=b.post(h.settings.url.ajax,f);h.trigger("save",a),a.always(function(){d.removeClass("saving")}),a.done(function(a){return"0"===a?(e.preview.iframe.hide(),void e.login().done(function(){e.save(),e.preview.iframe.show()})):"-1"===a?void e.cheatin():(h.each(function(a){a._dirty=!1}),void h.trigger("saved"))})},0===g()?c():(a=function(){0===g()&&(h.state.unbind("change",a),c())},h.state.bind("change",a))}}),h.previewer.bind("nonce",function(a){b.extend(this.nonce,a)}),b.each(h.settings.settings,function(a,b){h.create(a,a,b.value,{transport:b.transport,previewer:h.previewer})}),b.each(h.settings.panels,function(a,b){var c,d=h.panelConstructor[b.type]||h.Panel;c=new d(a,{params:b}),h.panel.add(a,c)}),b.each(h.settings.sections,function(a,b){var c,d=h.sectionConstructor[b.type]||h.Section;c=new d(a,{params:b}),h.section.add(a,c)}),b.each(h.settings.controls,function(a,b){var c,d=h.controlConstructor[b.type]||h.Control;c=new d(a,{params:b,previewer:h.previewer}),h.control.add(a,c)}),_.each(["panel","section","control"],function(a){var b,c=h.settings.autofocus[a];c&&h[a](c)&&(b=h[a](c),b.deferred.ready.done(function(){h.previewer.deferred.active.done(function(){b.focus()})}))}),h.reflowPaneContents=_.bind(function(){var a,c,d,e=[],f=!1;document.activeElement&&(c=b(document.activeElement)),h.panel.each(function(b){var c=b.sections(),d=_.pluck(c,"container");e.push(b),a=b.container.find("ul:first"),g(d,a.children("[id]"))||(_(c).each(function(b){a.append(b.container)}),f=!0)}),h.section.each(function(b){var c=b.controls(),d=_.pluck(c,"container");b.panel()||e.push(b),a=b.container.find("ul:first"),g(d,a.children("[id]"))||(_(c).each(function(b){a.append(b.container)}),f=!0)}),e.sort(function(a,b){return a.priority()-b.priority()}),d=_.pluck(e,"container"),a=b("#customize-theme-controls").children("ul"),g(d,a.children())||(_(e).each(function(b){a.append(b.container)}),f=!0),h.panel.each(function(a){var b=a.active();a.active.callbacks.fireWith(a.active,[b,b])}),h.section.each(function(a){var b=a.active();a.active.callbacks.fireWith(a.active,[b,b])}),f&&c&&c.focus()},h),h.bind("ready",h.reflowPaneContents),h.reflowPaneContents=_.debounce(h.reflowPaneContents,100),b([h.panel,h.section,h.control]).each(function(a,b){b.bind("add",h.reflowPaneContents),b.bind("change",h.reflowPaneContents),b.bind("remove",h.reflowPaneContents)}),h.previewer.previewUrl()?h.previewer.refresh():h.previewer.previewUrl(h.settings.url.home),function(){var a=new h.Values,b=a.create("saved"),c=a.create("activated"),d=a.create("processing");a.bind("change",function(){c()?b()?(k.val(h.l10n.saved).prop("disabled",!0),j.find(".screen-reader-text").text(h.l10n.close)):(k.val(h.l10n.save).prop("disabled",!1),j.find(".screen-reader-text").text(h.l10n.cancel)):(k.val(h.l10n.activate).prop("disabled",!1),j.find(".screen-reader-text").text(h.l10n.cancel))}),b(!0),c(h.settings.theme.active),d(0),h.bind("change",function(){a("saved").set(!1)}),h.bind("saved",function(){a("saved").set(!0),a("activated").set(!0)}),c.bind(function(a){a&&h.trigger("activated")}),h.state=a}(),k.click(function(a){h.previewer.save(),a.preventDefault()}).keydown(function(a){9!==a.which&&(13===a.which&&h.previewer.save(),a.preventDefault())}),b("#customize-header-actions").on("click keydown",".control-panel-back",function(a){f(a)||(a.preventDefault(),h.panel.each(function(a){a.collapse()}))}),j.keydown(function(a){9!==a.which&&(13===a.which&&this.click(),a.preventDefault())}),b(".upload-dropzone a.upload").keydown(function(a){13===a.which&&this.click()}),b(".collapse-sidebar").on("click keydown",function(a){f(a)||(e.toggleClass("collapsed").toggleClass("expanded"),a.preventDefault())}),i.length&&b("#customize-control-blogname input").on("input",function(){i.text(this.value)}),a=new h.Messenger({url:h.settings.url.parent,channel:"loader"}),a.bind("back",function(){j.on("click.customize-controls-close",function(b){b.preventDefault(),a.send("close")})}),b(window).on("beforeunload",function(){return h.state("saved")()?void 0:h.l10n.saveAlert}),b.each(["saved","change"],function(b,c){h.bind(c,function(){a.send(c)})}),h.bind("activated",function(){a.targetWindow()?a.send("activated",h.settings.url.activated):h.settings.url.activated&&(window.location=h.settings.url.activated)}),a.send("ready"),b.each({background_image:{controls:["background_repeat","background_position_x","background_attachment"],callback:function(a){return!!a}},show_on_front:{controls:["page_on_front","page_for_posts"],callback:function(a){return"page"===a}},header_textcolor:{controls:["header_textcolor"],callback:function(a){return"blank"!==a}}},function(a,c){h(a,function(a){b.each(c.controls,function(b,d){h.control(d,function(b){var d=function(a){b.container.toggle(c.callback(a))};d(a.get()),a.bind(d)})})})}),h.control("display_header_text",function(a){var b="";a.elements[0].unsync(h("header_textcolor")),a.element=new h.Element(a.container.find("input")),a.element.set("blank"!==a.setting()),a.element.bind(function(c){c||(b=h("header_textcolor").get()),a.setting.set(c?b:"blank")}),a.setting.bind(function(b){a.element.set("blank"!==b)})}),h.trigger("ready"),c=j,c.focus(),setTimeout(function(){c.focus()},200)}})}(wp,jQuery); \ No newline at end of file +!function(a,b){var c,d,e,f,g,h,i=wp.customize;i.Setting=i.Value.extend({initialize:function(a,b,c){i.Value.prototype.initialize.call(this,b,c),this.id=a,this.transport=this.transport||"refresh",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()])}}}),c=function(a,c){b.each(c,function(b,c){a[c].bind(function(b,c){a.parent&&b!==c&&a.parent.trigger("change",a)})})},e=function(a){var b,c,d;b=this,a=a||{},d=function(){b.container.find(":focusable:first").focus(),b.container[0].scrollIntoView(!0)},a.completeCallback?(c=a.completeCallback,a.completeCallback=function(){d(),c()}):a.completeCallback=d,b.expand?b.expand(a):a.completeCallback()},h=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=function(a){return"keydown"===a.type&&13!==a.which},g=function(a,c){var d=a.length===c.length&&-1===_.map(_.zip(a,c),function(a){return b(a[0]).is(a[1])}).indexOf(!1);return d},d=i.Class.extend({defaultActiveArguments:{duration:"fast"},defaultExpandedArguments:{duration:"fast"},initialize:function(a,d){var e=this;e.id=a,e.params={},b.extend(e,d||{}),e.container=b(e.params.content),e.deferred={ready:new b.Deferred},e.priority=new i.Value,e.active=new i.Value,e.activeArgumentsQueue=[],e.expanded=new i.Value,e.expandedArgumentsQueue=[],e.active.bind(function(a){var c=e.activeArgumentsQueue.shift();c=b.extend({},e.defaultActiveArguments,c),a=a&&e.isContextuallyActive(),e.onChangeActive(a,c)}),e.expanded.bind(function(a){var c=e.expandedArgumentsQueue.shift();c=b.extend({},e.defaultExpandedArguments,c),e.onChangeExpanded(a,c)}),e.attachEvents(),c(e,["priority","active"]),e.priority.set(isNaN(e.params.priority)?100:e.params.priority),e.active.set(e.params.active),e.expanded.set(!1)},ready:function(){},_children:function(a,b){var c=this,d=[];return i[b].each(function(b){b[a].get()===c.id&&d.push(b)}),d.sort(h),d},isContextuallyActive:function(){throw new Error("Must override with subclass.")},onChangeActive:function(a,b){var c="resolved"===i.previewer.deferred.active.state()?b.duration:0;a?this.container.stop(!0,!0).slideDown(c,b.completeCallback):this.container.stop(!0,!0).slideUp(c,b.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=this;return b=b||{},a&&this.expanded.get()||!a&&!this.expanded.get()?(b.unchanged=!0,c.onChangeExpanded(c.expanded.get(),b),!1):(b.unchanged=!1,this.expandedArgumentsQueue.push(b),this.expanded.set(a),!0)},expand:function(a){return this._toggleExpanded(!0,a)},collapse:function(a){return this._toggleExpanded(!1,a)},focus:e}),i.Section=d.extend({initialize:function(a,e){var f=this;d.prototype.initialize.call(f,a,e),f.id=a,f.panel=new i.Value,f.panel.bind(function(a){b(f.container).toggleClass("control-subsection",!!a)}),f.panel.set(f.params.panel||""),c(f,["panel"]),f.embed(),f.deferred.ready.done(function(){f.ready()})},embed:function(){var a,c=this;a=function(a){var d;a?i.panel(a,function(a){a.deferred.ready.done(function(){d=a.container.find("ul:first"),c.container.parent().is(d)||d.append(c.container),c.deferred.ready.resolve()})}):(d=b("#customize-theme-controls").children("ul"),c.container.parent().is(d)||d.append(c.container),c.deferred.ready.resolve())},c.panel.bind(a),a(c.panel.get())},attachEvents:function(){var a=this;a.container.find(".accordion-section-title").on("click keydown",function(b){f(b)||(b.preventDefault(),a.expanded()?a.collapse():a.expand())})},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,b){var c,d=this,e=d.container.find(".accordion-section-content");a?(c=b.unchanged?b.completeCallback:function(){e.stop().slideDown(b.duration,b.completeCallback),d.container.addClass("open")},b.allowMultiple||i.section.each(function(a){a!==d&&a.collapse({duration:b.duration})}),d.panel()?i.panel(d.panel()).expand({duration:b.duration,completeCallback:c}):c()):(d.container.removeClass("open"),e.slideUp(b.duration,b.completeCallback))}}),i.Panel=d.extend({initialize:function(a,b){var c=this;d.prototype.initialize.call(c,a,b),c.embed(),c.deferred.ready.done(function(){c.ready()})},embed:function(){var a=this,c=b("#customize-theme-controls > ul");a.container.parent().is(c)||c.append(a.container),a.deferred.ready.resolve()},attachEvents:function(){var a,b=this;b.container.find(".accordion-section-title").on("click keydown",function(a){f(a)||(a.preventDefault(),b.expanded()||b.expand())}),a=b.container.find(".panel-meta:first"),a.find("> .accordion-section-title").on("click keydown",function(c){if(!f(c)&&(c.preventDefault(),!a.hasClass("cannot-expand"))){var d=a.find(".accordion-section-content:first");a.hasClass("open")?(a.toggleClass("open"),d.slideUp(b.defaultExpandedArguments.duration)):(d.slideDown(b.defaultExpandedArguments.duration),a.toggleClass("open"))}})},sections:function(){return this._children("panel","section")},isContextuallyActive:function(){var a=this,b=a.sections(),c=0;return _(b).each(function(a){a.active()&&a.isContextuallyActive()&&(c+=1)}),0!==c},onChangeExpanded:function(a,b){if(b.unchanged)return void(b.completeCallback&&b.completeCallback());var c,d,e=this,f=e.container.closest(".accordion-section"),g=f.closest(".wp-full-overlay"),h=f.closest(".accordion-container"),j=h.find(".open"),k=g.find("#customize-theme-controls > ul > .accordion-section > .accordion-section-title").add("#customize-info > .accordion-section-title"),l=g.find(".control-panel-back"),m=f.find(".accordion-section-title").first(),n=f.find(".control-panel-content");a?(i.section.each(function(a){a.panel()||a.collapse({duration:0})}),i.panel.each(function(a){e!==a&&a.collapse({duration:0})}),n.show(0,function(){c=n.offset().top,d=h.scrollTop(),n.css("margin-top",45-c-d),f.addClass("current-panel"),g.addClass("in-sub-panel"),h.scrollTop(0),b.completeCallback&&b.completeCallback()}),k.attr("tabindex","-1"),l.attr("tabindex","0"),l.focus()):(j.removeClass("open"),f.removeClass("current-panel"),g.removeClass("in-sub-panel"),n.delay(180).hide(0,function(){n.css("margin-top","inherit"),b.completeCallback&&b.completeCallback()}),k.attr("tabindex","0"),l.attr("tabindex","-1"),m.focus(),h.scrollTop(0))}}),i.Control=i.Class.extend({defaultActiveArguments:{duration:"fast"},initialize:function(a,d){var e,f,g,h=this;h.params={},b.extend(h,d||{}),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={ready:new b.Deferred},h.section=new i.Value,h.priority=new i.Value,h.active=new i.Value,h.activeArgumentsQueue=[],h.elements=[],e=h.container.find("[data-customize-setting-link]"),f={},e.each(function(){var a,c=b(this);if(c.is(":radio")){if(a=c.prop("name"),f[a])return;f[a]=!0,c=e.filter('[name="'+a+'"]')}i(c.data("customizeSettingLink"),function(a){var b=new i.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),c(h,["section","priority","active"]),g=b.map(h.params.settings,function(a){return a}),i.apply(i,g.concat(function(){var a;h.settings={};for(a in h.params.settings)h.settings[a]=i(h.params.settings[a]);h.setting=h.settings["default"]||null,h.embed()})),h.deferred.ready.done(function(){h.ready()})},embed:function(){var a,b=this;a=function(a){var c;a&&i.section(a,function(a){a.deferred.ready.done(function(){c=a.container.find("ul:first"),b.container.parent().is(c)||(c.append(b.container),b.renderContent()),b.deferred.ready.resolve()})})},b.section.bind(a),a(b.section.get())},ready:function(){},expand:function(a){i.section(this.section()).expand(a)},focus:e,onChangeActive:function(a,b){a?this.container.slideDown(b.duration,b.completeCallback):this.container.slideUp(b.duration,b.completeCallback)},toggle:function(a){return this.onChangeActive(a,this.defaultActiveArguments)},activate:d.prototype.activate,deactivate:d.prototype.deactivate,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(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.append(a(c.params)))}}),i.ColorControl=i.Control.extend({ready:function(){var a=this,b=this.container.find(".color-picker-hex");b.val(a.setting()).wpColorPicker({change:function(){a.setting.set(b.wpColorPicker("color"))},clear:function(){a.setting.set(!1)}}),this.setting.bind(function(a){b.val(a),b.wpColorPicker("color",a)})}}),i.UploadControl=i.Control.extend({ready:function(){var a=this;this.params.removed=this.params.removed||"",this.success=b.proxy(this.success,this),this.uploader=b.extend({container:this.container,browser:this.container.find(".upload"),dropzone:this.container.find(".upload-dropzone"),success:this.success,plupload:{},params:{}},this.uploader||{}),a.params.extensions&&(a.uploader.plupload.filters=[{title:i.l10n.allowedFiles,extensions:a.params.extensions}]),a.params.context&&(a.uploader.params["post_data[context]"]=this.params.context),i.settings.theme.stylesheet&&(a.uploader.params["post_data[theme]"]=i.settings.theme.stylesheet),this.uploader=new wp.Uploader(this.uploader),this.remover=this.container.find(".remove"),this.remover.on("click keydown",function(b){f(b)||(a.setting.set(a.params.removed),b.preventDefault())}),this.removerVisibility=b.proxy(this.removerVisibility,this),this.setting.bind(this.removerVisibility),this.removerVisibility(this.setting.get())},success:function(a){this.setting.set(a.get("url"))},removerVisibility:function(a){this.remover.toggle(a!=this.params.removed)}}),i.ImageControl=i.UploadControl.extend({ready:function(){var a,c=this;this.uploader={init:function(){var a,b;this.supports.dragdrop||(a=c.container.find(".upload-fallback"),b=a.children().detach(),this.browser.detach().empty().append(b),a.append(this.browser).show())}},i.UploadControl.prototype.ready.call(this),this.thumbnail=this.container.find(".preview-thumbnail img"),this.thumbnailSrc=b.proxy(this.thumbnailSrc,this),this.setting.bind(this.thumbnailSrc),this.library=this.container.find(".library"),this.tabs={},a=this.library.find(".library-content"),this.library.children("ul").children("li").each(function(){var d=b(this),e=d.data("customizeTab"),f=a.filter('[data-customize-tab="'+e+'"]');c.tabs[e]={both:d.add(f),link:d,panel:f}}),this.library.children("ul").on("click keydown","li",function(a){if(!f(a)){var d=b(this).data("customizeTab"),e=c.tabs[d];a.preventDefault(),e.link.hasClass("library-selected")||(c.selected.both.removeClass("library-selected"),c.selected=e,c.selected.both.addClass("library-selected"))}}),this.library.on("click keydown","a",function(a){if(!f(a)){var d=b(this).data("customizeImageValue");d&&(c.setting.set(d),a.preventDefault())}}),this.tabs.uploaded&&(this.tabs.uploaded.target=this.library.find(".uploaded-target"),this.tabs.uploaded.panel.find(".thumbnail").length||this.tabs.uploaded.both.addClass("hidden")),a.each(function(){var a=c.tabs[b(this).data("customizeTab")];return a.link.hasClass("hidden")?void 0:(c.selected=a,a.both.addClass("library-selected"),!1)}),this.dropdownInit()},success:function(a){i.UploadControl.prototype.success.call(this,a),this.tabs.uploaded&&this.tabs.uploaded.target.length&&(this.tabs.uploaded.both.removeClass("hidden"),a.element=b('').data("customizeImageValue",a.get("url")).append('"+i.l10n.cheatin+"
")}}),i.controlConstructor={color:i.ColorControl,upload:i.UploadControl,image:i.ImageControl,header:i.HeaderControl},i.panelConstructor={},i.sectionConstructor={},b(function(){if(i.settings=window._wpCustomizeSettings,i.l10n=window._wpCustomizeControlsL10n,i.settings){if(!b.support.postMessage||!b.support.cors&&i.settings.isCrossDomain)return window.location=i.settings.url.fallback;var a,c,d=b(document.body),e=d.children(".wp-full-overlay"),j=b("#customize-info .theme-name.site-title"),k=b(".customize-controls-close"),l=b("#save");b("#customize-controls").on("keydown",function(a){var c=13===a.which,d=b(a.target);c&&(d.is("input:not([type=button])")||d.is("select"))&&a.preventDefault()}),b("#customize-info").find("> .accordion-section-title").on("click keydown",function(a){if(!f(a)){a.preventDefault();var c=b(this).parent(),d=c.find(".accordion-section-content:first");c.hasClass("cannot-expand")||(c.hasClass("open")?(c.toggleClass("open"),d.slideUp(i.Panel.prototype.defaultExpandedArguments.duration)):(d.slideDown(i.Panel.prototype.defaultExpandedArguments.duration),c.toggleClass("open")))}}),i.previewer=new i.Previewer({container:"#customize-preview",form:"#customize-controls",previewUrl:i.settings.url.preview,allowedUrls:i.settings.url.allowed,signature:"WP_CUSTOMIZER_SIGNATURE"},{nonce:i.settings.nonce,query:function(){var a={};return i.each(function(b,c){b._dirty&&(a[c]=b())}),{wp_customize:"on",theme:i.settings.theme.stylesheet,customized:JSON.stringify(a),nonce:this.nonce.preview}},save:function(){var a,c,e=this,f=b.extend(this.query(),{action:"customize_save",nonce:this.nonce.save}),g=i.state("processing");d.addClass("saving"),c=function(){var a=b.post(i.settings.url.ajax,f);i.trigger("save",a),a.always(function(){d.removeClass("saving")}),a.done(function(a){return"0"===a?(e.preview.iframe.hide(),void e.login().done(function(){e.save(),e.preview.iframe.show()})):"-1"===a?void e.cheatin():(i.each(function(a){a._dirty=!1}),void i.trigger("saved"))})},0===g()?c():(a=function(){0===g()&&(i.state.unbind("change",a),c())},i.state.bind("change",a))}}),i.previewer.bind("nonce",function(a){b.extend(this.nonce,a)}),b.each(i.settings.settings,function(a,b){i.create(a,a,b.value,{transport:b.transport,previewer:i.previewer})}),b.each(i.settings.panels,function(a,b){var c,d=i.panelConstructor[b.type]||i.Panel;c=new d(a,{params:b}),i.panel.add(a,c)}),b.each(i.settings.sections,function(a,b){var c,d=i.sectionConstructor[b.type]||i.Section;c=new d(a,{params:b}),i.section.add(a,c)}),b.each(i.settings.controls,function(a,b){var c,d=i.controlConstructor[b.type]||i.Control;c=new d(a,{params:b,previewer:i.previewer}),i.control.add(a,c)}),_.each(["panel","section","control"],function(a){var b,c=i.settings.autofocus[a];c&&i[a](c)&&(b=i[a](c),b.deferred.ready.done(function(){i.previewer.deferred.active.done(function(){b.focus()})}))}),i.reflowPaneContents=_.bind(function(){var a,c,d,e=[],f=!1;document.activeElement&&(c=b(document.activeElement)),i.panel.each(function(b){var c=b.sections(),d=_.pluck(c,"container");e.push(b),a=b.container.find("ul:first"),g(d,a.children("[id]"))||(_(c).each(function(b){a.append(b.container)}),f=!0)}),i.section.each(function(b){var c=b.controls(),d=_.pluck(c,"container");b.panel()||e.push(b),a=b.container.find("ul:first"),g(d,a.children("[id]"))||(_(c).each(function(b){a.append(b.container)}),f=!0)}),e.sort(h),d=_.pluck(e,"container"),a=b("#customize-theme-controls").children("ul"),g(d,a.children())||(_(e).each(function(b){a.append(b.container)}),f=!0),i.panel.each(function(a){var b=a.active();a.active.callbacks.fireWith(a.active,[b,b])}),i.section.each(function(a){var b=a.active();a.active.callbacks.fireWith(a.active,[b,b])}),f&&c&&c.focus()},i),i.bind("ready",i.reflowPaneContents),i.reflowPaneContents=_.debounce(i.reflowPaneContents,100),b([i.panel,i.section,i.control]).each(function(a,b){b.bind("add",i.reflowPaneContents),b.bind("change",i.reflowPaneContents),b.bind("remove",i.reflowPaneContents)}),i.previewer.previewUrl()?i.previewer.refresh():i.previewer.previewUrl(i.settings.url.home),function(){var a=new i.Values,b=a.create("saved"),c=a.create("activated"),d=a.create("processing");a.bind("change",function(){c()?b()?(l.val(i.l10n.saved).prop("disabled",!0),k.find(".screen-reader-text").text(i.l10n.close)):(l.val(i.l10n.save).prop("disabled",!1),k.find(".screen-reader-text").text(i.l10n.cancel)):(l.val(i.l10n.activate).prop("disabled",!1),k.find(".screen-reader-text").text(i.l10n.cancel))}),b(!0),c(i.settings.theme.active),d(0),i.bind("change",function(){a("saved").set(!1)}),i.bind("saved",function(){a("saved").set(!0),a("activated").set(!0)}),c.bind(function(a){a&&i.trigger("activated")}),i.state=a}(),l.click(function(a){i.previewer.save(),a.preventDefault()}).keydown(function(a){9!==a.which&&(13===a.which&&i.previewer.save(),a.preventDefault())}),b("#customize-header-actions").on("click keydown",".control-panel-back",function(a){f(a)||(a.preventDefault(),i.panel.each(function(a){a.collapse()}))}),k.keydown(function(a){9!==a.which&&(13===a.which&&this.click(),a.preventDefault())}),b(".upload-dropzone a.upload").keydown(function(a){13===a.which&&this.click()}),b(".collapse-sidebar").on("click keydown",function(a){f(a)||(e.toggleClass("collapsed").toggleClass("expanded"),a.preventDefault())}),j.length&&b("#customize-control-blogname input").on("input",function(){j.text(this.value)}),a=new i.Messenger({url:i.settings.url.parent,channel:"loader"}),a.bind("back",function(){k.on("click.customize-controls-close",function(b){b.preventDefault(),a.send("close")})}),b(window).on("beforeunload",function(){return i.state("saved")()?void 0:i.l10n.saveAlert}),b.each(["saved","change"],function(b,c){i.bind(c,function(){a.send(c)})}),i.bind("activated",function(){a.targetWindow()?a.send("activated",i.settings.url.activated):i.settings.url.activated&&(window.location=i.settings.url.activated)}),a.send("ready"),b.each({background_image:{controls:["background_repeat","background_position_x","background_attachment"],callback:function(a){return!!a}},show_on_front:{controls:["page_on_front","page_for_posts"],callback:function(a){return"page"===a}},header_textcolor:{controls:["header_textcolor"],callback:function(a){return"blank"!==a}}},function(a,c){i(a,function(a){b.each(c.controls,function(b,d){i.control(d,function(b){var d=function(a){b.container.toggle(c.callback(a))};d(a.get()),a.bind(d)})})})}),i.control("display_header_text",function(a){var b="";a.elements[0].unsync(i("header_textcolor")),a.element=new i.Element(a.container.find("input")),a.element.set("blank"!==a.setting()),a.element.bind(function(c){c||(b=i("header_textcolor").get()),a.setting.set(c?b:"blank")}),a.setting.bind(function(b){a.element.set("blank"!==b)})}),i.trigger("ready"),c=k,c.focus(),setTimeout(function(){c.focus()},200)}})}(wp,jQuery); \ No newline at end of file diff --git a/wp-includes/class-wp-customize-control.php b/wp-includes/class-wp-customize-control.php index 2130f0c0de..7fe3c0f3c5 100644 --- a/wp-includes/class-wp-customize-control.php +++ b/wp-includes/class-wp-customize-control.php @@ -7,6 +7,27 @@ * @since 3.4.0 */ class WP_Customize_Control { + + /** + * Incremented with each new class instantiation, then stored in $instance_number. + * + * Used when sorting two instances whose priorities are equal. + * + * @since 4.1.0 + * @access protected + * @var int + */ + protected static $instance_count = 0; + + /** + * Order in which this instance was created in relation to other instances. + * + * @since 4.1.0 + * @access public + * @var int + */ + public $instance_number; + /** * @access public * @var WP_Customize_Manager @@ -127,6 +148,8 @@ class WP_Customize_Control { if ( empty( $this->active_callback ) ) { $this->active_callback = array( $this, 'active_callback' ); } + self::$instance_count += 1; + $this->instance_number = self::$instance_count; // Process settings. if ( empty( $this->settings ) ) { @@ -218,13 +241,14 @@ class WP_Customize_Control { $this->json['settings'][ $key ] = $setting->id; } - $this->json['type'] = $this->type; - $this->json['priority'] = $this->priority; - $this->json['active'] = $this->active(); - $this->json['section'] = $this->section; - $this->json['content'] = $this->get_content(); - $this->json['label'] = $this->label; + $this->json['type'] = $this->type; + $this->json['priority'] = $this->priority; + $this->json['active'] = $this->active(); + $this->json['section'] = $this->section; + $this->json['content'] = $this->get_content(); + $this->json['label'] = $this->label; $this->json['description'] = $this->description; + $this->json['instanceNumber'] = $this->instance_number; } /** diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 371ea90fdc..987edc6e85 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -856,28 +856,27 @@ final class WP_Customize_Manager { * @since 4.1.0 */ public function render_control_templates() { - foreach( $this->registered_control_types as $control_type ) { + foreach ( $this->registered_control_types as $control_type ) { $control = new $control_type( $this, 'temp', array() ); $control->print_template(); } } - /** - * Helper function to compare two objects by priority. + /** + * Helper function to compare two objects by priority, ensuring sort stability via instance_number. * * @since 3.4.0 * - * @param object $a Object A. - * @param object $b Object B. + * @param {WP_Customize_Panel|WP_Customize_Section|WP_Customize_Control} $a Object A. + * @param {WP_Customize_Panel|WP_Customize_Section|WP_Customize_Control} $b Object B. * @return int */ protected final function _cmp_priority( $a, $b ) { - $ap = $a->priority; - $bp = $b->priority; - - if ( $ap == $bp ) - return 0; - return ( $ap > $bp ) ? 1 : -1; + if ( $a->priority === $b->priority ) { + return $a->instance_number - $a->instance_number; + } else { + return $a->priority - $b->priority; + } } /** @@ -891,8 +890,8 @@ final class WP_Customize_Manager { */ public function prepare_controls() { - $this->controls = array_reverse( $this->controls ); $controls = array(); + uasort( $this->controls, array( $this, '_cmp_priority' ) ); foreach ( $this->controls as $id => $control ) { if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() ) { @@ -905,8 +904,6 @@ final class WP_Customize_Manager { $this->controls = $controls; // Prepare sections. - // Reversing makes uasort sort by time added when conflicts occur. - $this->sections = array_reverse( $this->sections ); uasort( $this->sections, array( $this, '_cmp_priority' ) ); $sections = array(); @@ -930,8 +927,6 @@ final class WP_Customize_Manager { $this->sections = $sections; // Prepare panels. - // Reversing makes uasort sort by time added when conflicts occur. - $this->panels = array_reverse( $this->panels ); uasort( $this->panels, array( $this, '_cmp_priority' ) ); $panels = array(); diff --git a/wp-includes/class-wp-customize-panel.php b/wp-includes/class-wp-customize-panel.php index 201c4b914f..7a5b36453a 100644 --- a/wp-includes/class-wp-customize-panel.php +++ b/wp-includes/class-wp-customize-panel.php @@ -10,6 +10,26 @@ */ class WP_Customize_Panel { + /** + * Incremented with each new class instantiation, then stored in $instance_number. + * + * Used when sorting two instances whose priorities are equal. + * + * @since 4.1.0 + * @access protected + * @var int + */ + protected static $instance_count = 0; + + /** + * Order in which this instance was created in relation to other instances. + * + * @since 4.1.0 + * @access public + * @var int + */ + public $instance_number; + /** * WP_Customize_Manager instance. * @@ -128,6 +148,8 @@ class WP_Customize_Panel { if ( empty( $this->active_callback ) ) { $this->active_callback = array( $this, 'active_callback' ); } + self::$instance_count += 1; + $this->instance_number = self::$instance_count; $this->sections = array(); // Users cannot customize the $sections array. @@ -185,6 +207,7 @@ class WP_Customize_Panel { $array = wp_array_slice_assoc( (array) $this, array( 'title', 'description', 'priority', 'type' ) ); $array['content'] = $this->get_content(); $array['active'] = $this->active(); + $array['instanceNumber'] = $this->instance_number; return $array; } diff --git a/wp-includes/class-wp-customize-section.php b/wp-includes/class-wp-customize-section.php index 3553285cc4..86c565d56c 100644 --- a/wp-includes/class-wp-customize-section.php +++ b/wp-includes/class-wp-customize-section.php @@ -10,6 +10,26 @@ */ class WP_Customize_Section { + /** + * Incremented with each new class instantiation, then stored in $instance_number. + * + * Used when sorting two instances whose priorities are equal. + * + * @since 4.1.0 + * @access protected + * @var int + */ + protected static $instance_count = 0; + + /** + * Order in which this instance was created in relation to other instances. + * + * @since 4.1.0 + * @access public + * @var int + */ + public $instance_number; + /** * WP_Customize_Manager instance. * @@ -137,6 +157,8 @@ class WP_Customize_Section { if ( empty( $this->active_callback ) ) { $this->active_callback = array( $this, 'active_callback' ); } + self::$instance_count += 1; + $this->instance_number = self::$instance_count; $this->controls = array(); // Users cannot customize the $controls array. @@ -194,6 +216,7 @@ class WP_Customize_Section { $array = wp_array_slice_assoc( (array) $this, array( 'title', 'description', 'priority', 'panel', 'type' ) ); $array['content'] = $this->get_content(); $array['active'] = $this->active(); + $array['instanceNumber'] = $this->instance_number; return $array; } diff --git a/wp-includes/version.php b/wp-includes/version.php index d850eece6d..f96d6edbb8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30213'; +$wp_version = '4.1-alpha-30214'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.