diff --git a/wp-admin/js/customize-controls.js b/wp-admin/js/customize-controls.js
index 83ac3f5669..4cee2d7f5f 100644
--- a/wp-admin/js/customize-controls.js
+++ b/wp-admin/js/customize-controls.js
@@ -131,8 +131,8 @@
* @augments wp.customize.Class
*/
Container = api.Class.extend({
- defaultActiveArguments: { duration: 'fast' },
- defaultExpandedArguments: { duration: 'fast' },
+ defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
+ defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
initialize: function ( id, options ) {
var container = this;
@@ -217,7 +217,11 @@
*/
onChangeActive: function ( active, args ) {
var duration = ( 'resolved' === api.previewer.deferred.active.state() ? args.duration : 0 );
- if ( active ) {
+ if ( ! $.contains( document, this.container ) ) {
+ // jQuery.fn.slideUp is not hiding an element if it is not in the DOM
+ this.container.toggle( active );
+ args.completeCallback();
+ } else if ( active ) {
this.container.stop( true, true ).slideDown( duration, args.completeCallback );
} else {
this.container.stop( true, true ).slideUp( duration, args.completeCallback );
@@ -640,7 +644,7 @@
* @augments wp.customize.Class
*/
api.Control = api.Class.extend({
- defaultActiveArguments: { duration: 'fast' },
+ defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
initialize: function( id, options ) {
var control = this,
@@ -781,7 +785,11 @@
* @param {Object} args merged on top of this.defaultActiveArguments
*/
onChangeActive: function ( active, args ) {
- if ( active ) {
+ if ( ! $.contains( document, this.container ) ) {
+ // jQuery.fn.slideUp is not hiding an element if it is not in the DOM
+ this.container.toggle( active );
+ args.completeCallback();
+ } else if ( active ) {
this.container.slideDown( args.duration, args.completeCallback );
} else {
this.container.slideUp( args.duration, args.completeCallback );
diff --git a/wp-admin/js/customize-controls.min.js b/wp-admin/js/customize-controls.min.js
index 64af5f33c9..b7519f08b9 100644
--- a/wp-admin/js/customize-controls.min.js
+++ b/wp-admin/js/customize-controls.min.js
@@ -1 +1 @@
-!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('').appendTo(this.tabs.uploaded.target))},thumbnailSrc:function(a){/^(https?:)?\/\//.test(a)?this.thumbnail.prop("src",a).show():this.thumbnail.hide()}}),i.HeaderControl=i.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),i.HeaderTool.currentHeader=new i.HeaderTool.ImageModel,new i.HeaderTool.CurrentView({model:i.HeaderTool.currentHeader,el:".current .container"}),new i.HeaderTool.ChoiceListView({collection:i.HeaderTool.UploadsList=new i.HeaderTool.ChoiceList,el:".choices .uploaded .list"}),new i.HeaderTool.ChoiceListView({collection:i.HeaderTool.DefaultsList=new i.HeaderTool.DefaultsList,el:".choices .default .list"}),i.HeaderTool.combinedList=i.HeaderTool.CombinedList=new i.HeaderTool.CombinedList([i.HeaderTool.UploadsList,i.HeaderTool.DefaultsList])},calculateImageSelectOptions:function(a,b){var c,d,e,f,g,h,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 g=a.get("width"),f=a.get("height"),this.headerImage=new i.HeaderTool.ImageModel,this.headerImage.set({themeWidth:j,themeHeight:k,themeFlexWidth:l,themeFlexHeight:m,imageWidth:g,imageHeight:f}),b.set("canSkipCrop",!this.headerImage.shouldBeCropped()),c=j/k,d=g,e=f,d/e>c?(k=e,j=k*c):(j=d,k=j/c),h={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:g,imageHeight:f,x1:0,y1:0,x2:j,y2:k},m===!1&&l===!1&&(h.aspectRatio=j+":"+k),m===!1&&(h.maxHeight=k),l===!1&&(h.maxWidth=j),h},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,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.post_content,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,f={};f.url=a,f.thumbnail_url=a,f.timestamp=_.now(),b&&(f.attachment_id=b),c&&(f.width=c),d&&(f.height=d),e=new i.HeaderTool.ImageModel({header:f,choice:a.split("/").pop()}),i.HeaderTool.UploadsList.add(e),i.HeaderTool.currentHeader.set(e.toJSON()),e.save(),e.importImage()},removeImage:function(){i.HeaderTool.currentHeader.trigger("hide"),i.HeaderTool.CombinedList.trigger("control:removeImage")}}),i.defaultConstructor=i.Setting,i.control=new i.Values({defaultConstructor:i.Control}),i.section=new i.Values({defaultConstructor:i.Section}),i.panel=new i.Values({defaultConstructor:i.Panel}),i.PreviewFrame=i.Messenger.extend({sensitivity:2e3,initialize:function(a,c){var d=b.Deferred();d.promise(this),this.container=a.container,this.signature=a.signature,b.extend(a,{channel:i.PreviewFrame.uuid()}),i.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=this,d=!1,e=!1;this._ready&&this.unbind("ready",this._ready),this._ready=function(){e=!0,d&&a.resolveWith(c)},this.bind("ready",this._ready),this.bind("ready",function(a){if(a){var c={panel:a.activePanels,section:a.activeSections,control:a.activeControls};b.each(c,function(a,c){c&&b.each(c,function(b,c){var d=i[a](b);d&&d.active(c)})})}}),this.request=b.ajax(this.previewUrl(),{type:"POST",data:this.query,xhrFields:{withCredentials:!0}}),this.request.fail(function(){a.rejectWith(c,["request failure"])}),this.request.done(function(f){var g,h=c.request.getResponseHeader("Location"),i=c.signature;return h&&h!==c.previewUrl()?void a.rejectWith(c,["redirect",h]):"0"===f?void c.login(a):"-1"===f?void a.rejectWith(c,["cheatin"]):(g=f.lastIndexOf(i),-1===g||g")?void a.rejectWith(c,["unsigned"]):(f=f.slice(0,g)+f.slice(g+i.length),c.iframe=b("").appendTo(c.container),c.iframe.one("load",function(){d=!0,e?a.resolveWith(c):setTimeout(function(){a.rejectWith(c,["ready timeout"])},c.sensitivity)}),c.targetWindow(c.iframe[0].contentWindow),c.targetWindow().document.open(),c.targetWindow().document.write(f),void c.targetWindow().document.close()))})},login:function(a){var c,d=this;return c=function(){a.rejectWith(d,["logged out"])},this.triedLogin?c():void b.get(i.settings.url.ajax,{action:"logged-in"}).fail(c).done(function(e){var f;"1"!==e&&c(),f=b('').hide(),f.appendTo(d.container),f.load(function(){d.triedLogin=!0,f.remove(),d.run(a)})})},destroy:function(){i.Messenger.prototype.destroy.call(this),this.request.abort(),this.iframe&&this.iframe.remove(),delete this.request,delete this.iframe,delete this.targetWindow}}),function(){var a=0;i.PreviewFrame.uuid=function(){return"preview-"+a++}}(),i.setDocumentTitle=function(a){var b,c;b=i.settings.documentTitleTmpl,c=b.replace("%s",a),document.title=c,window!==window.parent&&(window.parent.document.title=document.title)},i.Previewer=i.Messenger.extend({refreshBuffer:250,initialize:function(a,c){var d=this,e=/^https?/;b.extend(this,c||{}),this.deferred={active:b.Deferred()},this.refresh=function(a){var b,c=a.refresh,d=function(){b=null,c.call(a)};return function(){if("number"!=typeof b){if(!a.loading)return d();a.abort()}clearTimeout(b),b=setTimeout(d,a.refreshBuffer)}}(this),this.container=i.ensure(a.container),this.allowedUrls=a.allowedUrls,this.signature=a.signature,a.url=window.location.href,i.Messenger.prototype.initialize.call(this,a),this.add("scheme",this.origin()).link(this.origin).setter(function(a){var b=a.match(e);return b?b[0]:""}),this.add("previewUrl",a.previewUrl).setter(function(a){var c;return/\/wp-admin(\/|$)/.test(a.replace(/[#?].*$/,""))?null:(b.each([a.replace(e,d.scheme()),a],function(a,e){return b.each(d.allowedUrls,function(a,b){var d;return b=b.replace(/\/+$/,""),d=e.replace(b,""),0===e.indexOf(b)&&/^([/#?]|$)/.test(d)?(c=e,!1):void 0}),c?!1:void 0}),c?c:null)}),this.previewUrl.bind(this.refresh),this.scroll=0,this.bind("scroll",function(a){this.scroll=a}),this.bind("url",this.previewUrl),this.bind("documentTitle",function(a){i.setDocumentTitle(a)})},query:function(){},abort:function(){this.loading&&(this.loading.destroy(),delete this.loading)},refresh:function(){var a=this;this.abort(),this.loading=new i.PreviewFrame({url:this.url(),previewUrl:this.previewUrl(),query:this.query()||{},container:this.container,signature:this.signature}),this.loading.done(function(){this.bind("synced",function(){a.preview&&a.preview.destroy(),a.preview=this,delete a.loading,a.targetWindow(this.targetWindow()),a.channel(this.channel()),a.deferred.active.resolve(),a.send("active")}),this.send("sync",{scroll:a.scroll,settings:i.get()})}),this.loading.fail(function(b,c){"redirect"===b&&c&&a.previewUrl(c),"logged out"===b&&(a.preview&&(a.preview.destroy(),delete a.preview),a.login().done(a.refresh)),"cheatin"===b&&a.cheatin()})},login:function(){var a,c,d,e=this;return this._login?this._login:(a=b.Deferred(),this._login=a.promise(),c=new i.Messenger({channel:"login",url:i.settings.url.login}),d=b('').appendTo(this.container),c.targetWindow(d[0].contentWindow),c.bind("login",function(){d.remove(),c.destroy(),delete e._login,a.resolve()}),this._login)},cheatin:function(){b(document.body).empty().addClass("cheatin").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
+!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",completeCallback:b.noop},defaultExpandedArguments:{duration:"fast",completeCallback:b.noop},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,c){var d="resolved"===i.previewer.deferred.active.state()?c.duration:0;b.contains(document,this.container)?a?this.container.stop(!0,!0).slideDown(d,c.completeCallback):this.container.stop(!0,!0).slideUp(d,c.completeCallback):(this.container.toggle(a),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=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",completeCallback:b.noop},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,c){b.contains(document,this.container)?a?this.container.slideDown(c.duration,c.completeCallback):this.container.slideUp(c.duration,c.completeCallback):(this.container.toggle(a),c.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('').appendTo(this.tabs.uploaded.target))},thumbnailSrc:function(a){/^(https?:)?\/\//.test(a)?this.thumbnail.prop("src",a).show():this.thumbnail.hide()}}),i.HeaderControl=i.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),i.HeaderTool.currentHeader=new i.HeaderTool.ImageModel,new i.HeaderTool.CurrentView({model:i.HeaderTool.currentHeader,el:".current .container"}),new i.HeaderTool.ChoiceListView({collection:i.HeaderTool.UploadsList=new i.HeaderTool.ChoiceList,el:".choices .uploaded .list"}),new i.HeaderTool.ChoiceListView({collection:i.HeaderTool.DefaultsList=new i.HeaderTool.DefaultsList,el:".choices .default .list"}),i.HeaderTool.combinedList=i.HeaderTool.CombinedList=new i.HeaderTool.CombinedList([i.HeaderTool.UploadsList,i.HeaderTool.DefaultsList])},calculateImageSelectOptions:function(a,b){var c,d,e,f,g,h,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 g=a.get("width"),f=a.get("height"),this.headerImage=new i.HeaderTool.ImageModel,this.headerImage.set({themeWidth:j,themeHeight:k,themeFlexWidth:l,themeFlexHeight:m,imageWidth:g,imageHeight:f}),b.set("canSkipCrop",!this.headerImage.shouldBeCropped()),c=j/k,d=g,e=f,d/e>c?(k=e,j=k*c):(j=d,k=j/c),h={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:g,imageHeight:f,x1:0,y1:0,x2:j,y2:k},m===!1&&l===!1&&(h.aspectRatio=j+":"+k),m===!1&&(h.maxHeight=k),l===!1&&(h.maxWidth=j),h},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,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.post_content,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,f={};f.url=a,f.thumbnail_url=a,f.timestamp=_.now(),b&&(f.attachment_id=b),c&&(f.width=c),d&&(f.height=d),e=new i.HeaderTool.ImageModel({header:f,choice:a.split("/").pop()}),i.HeaderTool.UploadsList.add(e),i.HeaderTool.currentHeader.set(e.toJSON()),e.save(),e.importImage()},removeImage:function(){i.HeaderTool.currentHeader.trigger("hide"),i.HeaderTool.CombinedList.trigger("control:removeImage")}}),i.defaultConstructor=i.Setting,i.control=new i.Values({defaultConstructor:i.Control}),i.section=new i.Values({defaultConstructor:i.Section}),i.panel=new i.Values({defaultConstructor:i.Panel}),i.PreviewFrame=i.Messenger.extend({sensitivity:2e3,initialize:function(a,c){var d=b.Deferred();d.promise(this),this.container=a.container,this.signature=a.signature,b.extend(a,{channel:i.PreviewFrame.uuid()}),i.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=this,d=!1,e=!1;this._ready&&this.unbind("ready",this._ready),this._ready=function(){e=!0,d&&a.resolveWith(c)},this.bind("ready",this._ready),this.bind("ready",function(a){if(a){var c={panel:a.activePanels,section:a.activeSections,control:a.activeControls};b.each(c,function(a,c){c&&b.each(c,function(b,c){var d=i[a](b);d&&d.active(c)})})}}),this.request=b.ajax(this.previewUrl(),{type:"POST",data:this.query,xhrFields:{withCredentials:!0}}),this.request.fail(function(){a.rejectWith(c,["request failure"])}),this.request.done(function(f){var g,h=c.request.getResponseHeader("Location"),i=c.signature;return h&&h!==c.previewUrl()?void a.rejectWith(c,["redirect",h]):"0"===f?void c.login(a):"-1"===f?void a.rejectWith(c,["cheatin"]):(g=f.lastIndexOf(i),-1===g||g")?void a.rejectWith(c,["unsigned"]):(f=f.slice(0,g)+f.slice(g+i.length),c.iframe=b("").appendTo(c.container),c.iframe.one("load",function(){d=!0,e?a.resolveWith(c):setTimeout(function(){a.rejectWith(c,["ready timeout"])},c.sensitivity)}),c.targetWindow(c.iframe[0].contentWindow),c.targetWindow().document.open(),c.targetWindow().document.write(f),void c.targetWindow().document.close()))})},login:function(a){var c,d=this;return c=function(){a.rejectWith(d,["logged out"])},this.triedLogin?c():void b.get(i.settings.url.ajax,{action:"logged-in"}).fail(c).done(function(e){var f;"1"!==e&&c(),f=b('').hide(),f.appendTo(d.container),f.load(function(){d.triedLogin=!0,f.remove(),d.run(a)})})},destroy:function(){i.Messenger.prototype.destroy.call(this),this.request.abort(),this.iframe&&this.iframe.remove(),delete this.request,delete this.iframe,delete this.targetWindow}}),function(){var a=0;i.PreviewFrame.uuid=function(){return"preview-"+a++}}(),i.setDocumentTitle=function(a){var b,c;b=i.settings.documentTitleTmpl,c=b.replace("%s",a),document.title=c,window!==window.parent&&(window.parent.document.title=document.title)},i.Previewer=i.Messenger.extend({refreshBuffer:250,initialize:function(a,c){var d=this,e=/^https?/;b.extend(this,c||{}),this.deferred={active:b.Deferred()},this.refresh=function(a){var b,c=a.refresh,d=function(){b=null,c.call(a)};return function(){if("number"!=typeof b){if(!a.loading)return d();a.abort()}clearTimeout(b),b=setTimeout(d,a.refreshBuffer)}}(this),this.container=i.ensure(a.container),this.allowedUrls=a.allowedUrls,this.signature=a.signature,a.url=window.location.href,i.Messenger.prototype.initialize.call(this,a),this.add("scheme",this.origin()).link(this.origin).setter(function(a){var b=a.match(e);return b?b[0]:""}),this.add("previewUrl",a.previewUrl).setter(function(a){var c;return/\/wp-admin(\/|$)/.test(a.replace(/[#?].*$/,""))?null:(b.each([a.replace(e,d.scheme()),a],function(a,e){return b.each(d.allowedUrls,function(a,b){var d;return b=b.replace(/\/+$/,""),d=e.replace(b,""),0===e.indexOf(b)&&/^([/#?]|$)/.test(d)?(c=e,!1):void 0}),c?!1:void 0}),c?c:null)}),this.previewUrl.bind(this.refresh),this.scroll=0,this.bind("scroll",function(a){this.scroll=a}),this.bind("url",this.previewUrl),this.bind("documentTitle",function(a){i.setDocumentTitle(a)})},query:function(){},abort:function(){this.loading&&(this.loading.destroy(),delete this.loading)},refresh:function(){var a=this;this.abort(),this.loading=new i.PreviewFrame({url:this.url(),previewUrl:this.previewUrl(),query:this.query()||{},container:this.container,signature:this.signature}),this.loading.done(function(){this.bind("synced",function(){a.preview&&a.preview.destroy(),a.preview=this,delete a.loading,a.targetWindow(this.targetWindow()),a.channel(this.channel()),a.deferred.active.resolve(),a.send("active")}),this.send("sync",{scroll:a.scroll,settings:i.get()})}),this.loading.fail(function(b,c){"redirect"===b&&c&&a.previewUrl(c),"logged out"===b&&(a.preview&&(a.preview.destroy(),delete a.preview),a.login().done(a.refresh)),"cheatin"===b&&a.cheatin()})},login:function(){var a,c,d,e=this;return this._login?this._login:(a=b.Deferred(),this._login=a.promise(),c=new i.Messenger({channel:"login",url:i.settings.url.login}),d=b('').appendTo(this.container),c.targetWindow(d[0].contentWindow),c.bind("login",function(){d.remove(),c.destroy(),delete e._login,a.resolve()}),this._login)},cheatin:function(){b(document.body).empty().addClass("cheatin").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-admin/js/customize-widgets.js b/wp-admin/js/customize-widgets.js
index 3338f7bc08..eac16a559b 100644
--- a/wp-admin/js/customize-widgets.js
+++ b/wp-admin/js/customize-widgets.js
@@ -405,7 +405,8 @@
*/
api.Widgets.WidgetControl = api.Control.extend({
defaultExpandedArguments: {
- duration: 'fast'
+ duration: 'fast',
+ completeCallback: $.noop
},
initialize: function ( id, options ) {
diff --git a/wp-admin/js/customize-widgets.min.js b/wp-admin/js/customize-widgets.min.js
index 339ac06388..bdd947dd4a 100644
--- a/wp-admin/js/customize-widgets.min.js
+++ b/wp-admin/js/customize-widgets.min.js
@@ -1 +1 @@
-!function(a,b){function c(a){var b,c={number:null,id_base:null};return b=a.match(/^(.+)-(\d+)$/),b?(c.id_base=b[1],c.number=parseInt(b[2],10)):c.id_base=a,c}function d(a){var b,d=c(a);return b="widget_"+d.id_base,d.number&&(b+="["+d.number+"]"),b}if(a&&a.customize){var e,f=a.customize;f.Widgets=f.Widgets||{},f.Widgets.data=_wpCustomizeWidgetsSettings||{},e=f.Widgets.data.l10n,delete f.Widgets.data.l10n,f.Widgets.WidgetModel=Backbone.Model.extend({id:null,temp_id:null,classname:null,control_tpl:null,description:null,is_disabled:null,is_multi:null,multi_number:null,name:null,id_base:null,transport:"refresh",params:[],width:null,height:null,search_matched:!0}),f.Widgets.WidgetCollection=Backbone.Collection.extend({model:f.Widgets.WidgetModel,doSearch:function(a){this.terms!==a&&(this.terms=a,this.terms.length>0&&this.search(this.terms),""===this.terms&&this.each(function(a){a.set("search_matched",!0)}))},search:function(a){var b,c;a=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a=a.replace(/ /g,")(?=.*"),b=new RegExp("^(?=.*"+a+").+","i"),this.each(function(a){c=[a.get("name"),a.get("id"),a.get("description")].join(" "),a.set("search_matched",b.test(c))})}}),f.Widgets.availableWidgets=new f.Widgets.WidgetCollection(f.Widgets.data.availableWidgets),f.Widgets.SidebarModel=Backbone.Model.extend({after_title:null,after_widget:null,before_title:null,before_widget:null,"class":null,description:null,id:null,name:null,is_rendered:!1}),f.Widgets.SidebarCollection=Backbone.Collection.extend({model:f.Widgets.SidebarModel}),f.Widgets.registeredSidebars=new f.Widgets.SidebarCollection(f.Widgets.data.registeredSidebars),f.Widgets.AvailableWidgetsPanelView=a.Backbone.View.extend({el:"#available-widgets",events:{"input #widgets-search":"search","keyup #widgets-search":"search","change #widgets-search":"search","search #widgets-search":"search","focus .widget-tpl":"focus","click .widget-tpl":"_submit","keypress .widget-tpl":"_submit",keydown:"keyboardAccessible"},selected:null,currentSidebarControl:null,$search:null,initialize:function(){var a=this;this.$search=b("#widgets-search"),_.bindAll(this,"close"),this.listenTo(this.collection,"change",this.updateList),this.updateList(),b("#customize-controls").on("click keydown",function(c){var d=b(c.target).is(".add-new-widget, .add-new-widget *");b("body").hasClass("adding-widget")&&!d&&a.close()}),f.previewer.bind("url",this.close)},search:function(a){var b;this.collection.doSearch(a.target.value),this.selected&&!this.selected.is(":visible")&&(this.selected.removeClass("selected"),this.selected=null),this.selected&&!a.target.value&&(this.selected.removeClass("selected"),this.selected=null),!this.selected&&a.target.value&&(b=this.$el.find("> .widget-tpl:visible:first"),b.length&&this.select(b))},updateList:function(){this.collection.each(function(a){var c=b("#widget-tpl-"+a.id);c.toggle(a.get("search_matched")&&!a.get("is_disabled")),a.get("is_disabled")&&c.is(this.selected)&&(this.selected=null)})},select:function(a){this.selected=b(a),this.selected.siblings(".widget-tpl").removeClass("selected"),this.selected.addClass("selected")},focus:function(a){this.select(b(a.currentTarget))},_submit:function(a){("keypress"!==a.type||13===a.which||32===a.which)&&this.submit(b(a.currentTarget))},submit:function(a){var c,d;a||(a=this.selected),a&&this.currentSidebarControl&&(this.select(a),c=b(this.selected).data("widget-id"),d=this.collection.findWhere({id:c}),d&&(this.currentSidebarControl.addWidget(d.get("id_base")),this.close()))},open:function(a){this.currentSidebarControl=a,_(this.currentSidebarControl.getWidgetFormControls()).each(function(a){a.params.is_wide&&a.collapseForm()}),b("body").addClass("adding-widget"),this.$el.find(".selected").removeClass("selected"),this.collection.doSearch(""),this.$search.focus()},close:function(a){a=a||{},a.returnFocus&&this.currentSidebarControl&&this.currentSidebarControl.container.find(".add-new-widget").focus(),this.currentSidebarControl=null,this.selected=null,b("body").removeClass("adding-widget"),this.$search.val("")},keyboardAccessible:function(a){var c=13===a.which,d=27===a.which,e=40===a.which,f=38===a.which,g=9===a.which,h=a.shiftKey,i=null,j=this.$el.find("> .widget-tpl:visible:first"),k=this.$el.find("> .widget-tpl:visible:last"),l=b(a.target).is(this.$search),m=b(a.target).is(".widget-tpl:visible:last");return e||f?(e?l?i=j:this.selected&&0!==this.selected.nextAll(".widget-tpl:visible").length&&(i=this.selected.nextAll(".widget-tpl:visible:first")):f&&(l?i=k:this.selected&&0!==this.selected.prevAll(".widget-tpl:visible").length&&(i=this.selected.prevAll(".widget-tpl:visible:first"))),this.select(i),void(i?i.focus():this.$search.focus())):void((!c||this.$search.val())&&(c?this.submit():d&&this.close({returnFocus:!0}),g&&(h&&l||!h&&m)&&(this.currentSidebarControl.container.find(".add-new-widget").focus(),a.preventDefault())))}}),f.Widgets.formSyncHandlers={rss:function(a,c,d){var e=c.find(".widget-error:first"),f=b(""+d+"
").find(".widget-error:first");e.length&&f.length?e.replaceWith(f):e.length?e.remove():f.length&&c.find(".widget-content:first").prepend(f)}},f.Widgets.WidgetControl=f.Control.extend({defaultExpandedArguments:{duration:"fast"},initialize:function(a,c){var d=this;f.Control.prototype.initialize.call(d,a,c),d.expanded=new f.Value,d.expandedArgumentsQueue=[],d.expanded.bind(function(a){var c=d.expandedArgumentsQueue.shift();c=b.extend({},d.defaultExpandedArguments,c),d.onChangeExpanded(a,c)}),d.expanded.set(!1)},ready:function(){this._setupModel(),this._setupWideWidget(),this._setupControlToggle(),this._setupWidgetTitle(),this._setupReorderUI(),this._setupHighlightEffects(),this._setupUpdateUI(),this._setupRemoveUI()},_setupModel:function(){var a,b=this;f.Widgets.savedWidgetIds=f.Widgets.savedWidgetIds||[],a=function(){f.Widgets.savedWidgetIds[b.params.widget_id]=!0},f.bind("ready",a),f.bind("saved",a),this._updateCount=0,this.isWidgetUpdating=!1,this.liveUpdateMode=!0,this.setting.bind(function(a,c){_(c).isEqual(a)||b.isWidgetUpdating||b.updateWidget({instance:a})})},_setupWideWidget:function(){var a,c,d,e,g,h=this;this.params.is_wide&&(a=this.container.find(".widget-inside"),c=a.find("> .form"),d=b(".wp-full-overlay-sidebar-content:first"),this.container.addClass("wide-widget-control"),this.container.find(".widget-content:first").css({"max-width":this.params.width,"min-height":this.params.height}),g=function(){var d,e=h.container.offset().top,f=b(window).height(),g=c.outerHeight();a.css("max-height",f),d=Math.max(0,Math.min(Math.max(e,0),f-g)),a.css("top",d)},e=b("#customize-theme-controls"),this.container.on("expand",function(){g(),d.on("scroll",g),b(window).on("resize",g),e.on("expanded collapsed",g)}),this.container.on("collapsed",function(){d.off("scroll",g),b(window).off("resize",g),e.off("expanded collapsed",g)}),f.each(function(a){0===a.id.indexOf("sidebars_widgets[")&&a.bind(function(){h.container.hasClass("expanded")&&g()})}))},_setupControlToggle:function(){var a,b=this;this.container.find(".widget-top").on("click",function(a){a.preventDefault();var c=b.getSidebarWidgetsControl();c.isReordering||b.expanded(!b.expanded())}),a=this.container.find(".widget-control-close"),a.on("click",function(a){a.preventDefault(),b.collapse(),b.container.find(".widget-top .widget-action:first").focus()})},_setupWidgetTitle:function(){var a,b=this;a=function(){var a=b.setting().title,c=b.container.find(".in-widget-title");c.text(a?": "+a:"")},this.setting.bind(a),a()},_setupReorderUI:function(){var a,c,d,e,g=this;a=function(a){a.siblings(".selected").removeClass("selected"),a.addClass("selected");var b=a.data("id")===g.params.sidebar_id;g.container.find(".move-widget-btn").prop("disabled",b)},this.container.find(".widget-title-action").after(b(f.Widgets.data.tpl.widgetReorderNav)),c=b(_.template(f.Widgets.data.tpl.moveWidgetArea,{sidebars:_(f.Widgets.registeredSidebars.toArray()).pluck("attributes")})),this.container.find(".widget-top").after(c),e=function(){var d,e=c.find("li");d=e.filter(function(){return b(this).data("id")===g.params.sidebar_id}),e.each(function(){var c,e,g=b(this);c=g.data("id"),e=f.Widgets.registeredSidebars.get(c),g.toggle(e.get("is_rendered")),g.hasClass("selected")&&!e.get("is_rendered")&&a(d)})},e(),f.Widgets.registeredSidebars.on("change:is_rendered",e),d=this.container.find(".widget-reorder-nav"),d.find(".move-widget, .move-widget-down, .move-widget-up").each(function(){b(this).prepend(g.container.find(".widget-title").text()+": ")}).on("click keypress",function(a){if("keypress"!==a.type||13===a.which||32===a.which)if(b(this).focus(),b(this).is(".move-widget"))g.toggleWidgetMoveArea();else{var c=b(this).is(".move-widget-down"),d=b(this).is(".move-widget-up"),e=g.getWidgetSidebarPosition();if(d&&0===e||c&&e===g.getSidebarWidgetsControl().setting().length-1)return;d?g.moveUp():g.moveDown(),b(this).focus()}}),this.container.find(".widget-area-select").on("click keypress","li",function(c){("keypress"!==event.type||13===event.which||32===event.which)&&(c.preventDefault(),a(b(this)))}),this.container.find(".move-widget-btn").click(function(){g.getSidebarWidgetsControl().toggleReordering(!1);var a,b,c,d,e,h=g.params.sidebar_id,i=g.container.find(".widget-area-select li.selected").data("id");a=f("sidebars_widgets["+h+"]"),b=f("sidebars_widgets["+i+"]"),c=Array.prototype.slice.call(a()),d=Array.prototype.slice.call(b()),e=g.getWidgetSidebarPosition(),c.splice(e,1),d.push(g.params.widget_id),a(c),b(d),g.focus()})},_setupHighlightEffects:function(){var a=this;this.container.on("mouseenter click",function(){a.setting.previewer.send("highlight-widget",a.params.widget_id)}),this.setting.bind(function(){a.setting.previewer.send("highlight-widget",a.params.widget_id)})},_setupUpdateUI:function(){var a,c,d,g,h,i=this;a=this.container.find(".widget:first"),c=a.find(".widget-content:first"),d=this.container.find(".widget-control-save"),d.val(e.saveBtnLabel),d.attr("title",e.saveBtnTooltip),d.removeClass("button-primary").addClass("button-secondary"),d.on("click",function(a){a.preventDefault(),i.updateWidget({disable_form:!0})}),g=_.debounce(function(){i.updateWidget()},250),c.on("keydown","input",function(a){13===a.which&&(a.preventDefault(),i.updateWidget({ignoreActiveElement:!0}))}),c.on("change input propertychange",":input",function(a){i.liveUpdateMode&&("change"===a.type?i.updateWidget():this.checkValidity&&this.checkValidity()&&g())}),this.setting.previewer.channel.bind("synced",function(){i.container.removeClass("previewer-loading")}),f.previewer.bind("widget-updated",function(a){a===i.params.widget_id&&i.container.removeClass("previewer-loading")}),h=f.Widgets.formSyncHandlers[this.params.widget_id_base],h&&b(document).on("widget-synced",function(b,c){a.is(c)&&h.apply(document,arguments)})},onChangeActive:function(a,b){this.container.toggleClass("widget-rendered",a),b.completeCallback&&b.completeCallback()},_setupRemoveUI:function(){var a,b,c=this;a=this.container.find("a.widget-control-remove"),a.on("click",function(a){a.preventDefault();var b;b=c.container.next().is(".customize-control-widget_form")?c.container.next().find(".widget-action:first"):c.container.prev().is(".customize-control-widget_form")?c.container.prev().find(".widget-action:first"):c.container.next(".customize-control-sidebar_widgets").find(".add-new-widget:first"),c.container.slideUp(function(){var a,d,e=f.Widgets.getSidebarWidgetControlContainingWidget(c.params.widget_id);e&&(a=e.setting().slice(),d=_.indexOf(a,c.params.widget_id),-1!==d&&(a.splice(d,1),e.setting(a),b.focus()))})}),b=function(){a.text(e.removeBtnLabel),a.attr("title",e.removeBtnTooltip)},this.params.is_new?f.bind("saved",b):b()},_getInputs:function(a){return b(a).find(":input[name]")},_getInputsSignature:function(a){var c=_(a).map(function(a){var c,d=b(a);return c=d.is(":checkbox, :radio")?[d.attr("id"),d.attr("name"),d.prop("value")]:[d.attr("id"),d.attr("name")],c.join(",")});return c.join(";")},_getInputStatePropertyName:function(a){var c=b(a);return c.is(":radio, :checkbox")?"checked":"value"},getSidebarWidgetsControl:function(){var a,b;return a="sidebars_widgets["+this.params.sidebar_id+"]",(b=f.control(a))?b:void 0},updateWidget:function(c){var d,g,h,i,j,k,l,m,n,o,p,q=this;c=b.extend({instance:null,complete:null,ignoreActiveElement:!1},c),d=c.instance,g=c.complete,this._updateCount+=1,j=this._updateCount,h=this.container.find(".widget:first"),i=h.find(".widget-content:first"),i.find(".widget-error").remove(),this.container.addClass("widget-form-loading"),this.container.addClass("previewer-loading"),n=f.state("processing"),n(n()+1),this.liveUpdateMode||this.container.addClass("widget-form-disabled"),k={},k.action="update-widget",k.wp_customize="on",k.nonce=f.Widgets.data.nonce,k.theme=f.settings.theme.stylesheet,l=b.param(k),m=this._getInputs(i),m.each(function(){var a=b(this),c=q._getInputStatePropertyName(this);a.data("state"+j,a.prop(c))}),l+=d?"&"+b.param({sanitized_widget_setting:JSON.stringify(d)}):"&"+m.serialize(),l+="&"+i.find("~ :input").serialize(),o=b.post(a.ajax.settings.url,l),o.done(function(a){var d,k,l,n,o=!1;return"0"===a?(f.previewer.preview.iframe.hide(),void f.previewer.login().done(function(){q.updateWidget(c),f.previewer.preview.iframe.show()})):"-1"===a?void f.previewer.cheatin():void(a.success?(k=b(""+a.data.form+"
"),l=q._getInputs(k),n=q._getInputsSignature(m)===q._getInputsSignature(l),n&&!q.liveUpdateMode&&(q.liveUpdateMode=!0,q.container.removeClass("widget-form-disabled"),q.container.find('input[name="savewidget"]').hide()),n&&q.liveUpdateMode?(m.each(function(a){var d,e,f,g=b(this),h=b(l[a]),i=q._getInputStatePropertyName(this);d=g.data("state"+j),e=h.prop(i),g.data("sanitized",e),f=d!==e&&(c.ignoreActiveElement||!g.is(document.activeElement)),f&&g.prop(i,e)}),b(document).trigger("widget-synced",[h,a.data.form])):q.liveUpdateMode?(q.liveUpdateMode=!1,q.container.find('input[name="savewidget"]').show(),o=!0):(i.html(a.data.form),q.container.removeClass("widget-form-disabled"),b(document).trigger("widget-updated",[h])),p=!o&&!_(q.setting()).isEqual(a.data.instance),p?(q.isWidgetUpdating=!0,q.setting(a.data.instance),q.isWidgetUpdating=!1):q.container.removeClass("previewer-loading"),g&&g.call(q,null,{noChange:!p,ajaxFinished:!0})):(d=e.error,a.data&&a.data.message&&(d=a.data.message),g?g.call(q,d):i.prepend(''+d+"
")))}),o.fail(function(a,b){g&&g.call(q,b)}),o.always(function(){q.container.removeClass("widget-form-loading"),m.each(function(){b(this).removeData("state"+j)}),n(n()-1)})},expandControlSection:function(){f.Control.prototype.expand.call(this)},_toggleExpanded:f.Section.prototype._toggleExpanded,expand:f.Section.prototype.expand,expandForm:function(){this.expand()},collapse:f.Section.prototype.collapse,collapseForm:function(){this.collapse()},toggleForm:function(a){"undefined"==typeof a&&(a=!this.expanded()),this.expanded(a)},onChangeExpanded:function(a,b){var c,d,e,g,h=this;return b.unchanged?void(a&&f.Control.prototype.expand.call(h,{completeCallback:b.completeCallback})):(c=this.container.find("div.widget:first"),d=c.find(".widget-inside:first"),void(a?(h.expandControlSection(),f.control.each(function(a){h.params.type===a.params.type&&h!==a&&a.collapse()}),e=function(){h.container.removeClass("expanding"),h.container.addClass("expanded"),h.container.trigger("expanded")},b.completeCallback&&(g=e,e=function(){g(),b.completeCallback()}),h.params.is_wide?d.fadeIn(b.duration,e):d.slideDown(b.duration,e),h.container.trigger("expand"),h.container.addClass("expanding")):(e=function(){h.container.removeClass("collapsing"),h.container.removeClass("expanded"),h.container.trigger("collapsed")},b.completeCallback&&(g=e,e=function(){g(),b.completeCallback()}),h.container.trigger("collapse"),h.container.addClass("collapsing"),h.params.is_wide?d.fadeOut(b.duration,e):d.slideUp(b.duration,function(){c.css({width:"",margin:""}),e()}))))},getWidgetSidebarPosition:function(){var a,b;return a=this.getSidebarWidgetsControl().setting(),b=_.indexOf(a,this.params.widget_id),-1!==b?b:void 0},moveUp:function(){this._moveWidgetByOne(-1)},moveDown:function(){this._moveWidgetByOne(1)},_moveWidgetByOne:function(a){var b,c,d,e;b=this.getWidgetSidebarPosition(),c=this.getSidebarWidgetsControl().setting,d=Array.prototype.slice.call(c()),e=d[b+a],d[b+a]=this.params.widget_id,d[b]=e,c(d)},toggleWidgetMoveArea:function(a){var c,d=this;c=this.container.find(".move-widget-area"),"undefined"==typeof a&&(a=!c.hasClass("active")),a&&(c.find(".selected").removeClass("selected"),c.find("li").filter(function(){return b(this).data("id")===d.params.sidebar_id}).addClass("selected"),this.container.find(".move-widget-btn").prop("disabled",!0)),c.toggleClass("active",a)},highlightSectionAndControl:function(){var a;a=this.container.is(":hidden")?this.container.closest(".control-section"):this.container,b(".highlighted").removeClass("highlighted"),a.addClass("highlighted"),setTimeout(function(){a.removeClass("highlighted")},500)}}),f.Widgets.SidebarControl=f.Control.extend({ready:function(){this.$controlSection=this.container.closest(".control-section"),this.$sectionContent=this.container.closest(".accordion-section-content"),this._setupModel(),this._setupSortable(),this._setupAddition(),this._applyCardinalOrderClassNames()},_setupModel:function(){var a=this,d=f.Widgets.registeredSidebars.get(this.params.sidebar_id);this.setting.bind(function(d,e){var g,h,i;h=_(e).difference(d),d=_(d).filter(function(a){var b=c(a);return!!f.Widgets.availableWidgets.findWhere({id_base:b.id_base})}),g=_(d).map(function(b){var c=f.Widgets.getWidgetFormControlForWidget(b);return c||(c=a.addWidget(b)),c}),g.sort(function(a,b){var c=_.indexOf(d,a.params.widget_id),e=_.indexOf(d,b.params.widget_id);return c-e}),i=0,_(g).each(function(b){b.priority(i),b.section(a.section()),i+=1}),a.priority(i),a._applyCardinalOrderClassNames(),_(g).each(function(b){b.params.sidebar_id=a.params.sidebar_id}),_(h).each(function(d){setTimeout(function(){var e,g,h,i,j,k=!1;f.each(function(b){if(b.id!==a.setting.id&&0===b.id.indexOf("sidebars_widgets[")&&"sidebars_widgets[wp_inactive_widgets]"!==b.id){var c,e=b();c=_.indexOf(e,d),-1!==c&&(k=!0)}}),k||(e=f.Widgets.getWidgetFormControlForWidget(d),g=e&&b.contains(document,e.container[0])&&!b.contains(a.$sectionContent[0],e.container[0]),e&&!g&&(f.control.remove(e.id),e.container.remove()),f.Widgets.savedWidgetIds[d]&&(h=f.value("sidebars_widgets[wp_inactive_widgets]")().slice(),h.push(d),f.value("sidebars_widgets[wp_inactive_widgets]")(_(h).unique())),i=c(d).id_base,j=f.Widgets.availableWidgets.findWhere({id_base:i}),j&&!j.get("is_multi")&&j.set("is_disabled",!1))})})}),a.active.bind(function(b){d.set("is_rendered",b),f.section(a.section.get()).active(b)}),f.section(a.section.get()).active(a.active())},_setupSortable:function(){var a=this;this.isReordering=!1,this.$sectionContent.sortable({items:"> .customize-control-widget_form",handle:".widget-top",axis:"y",connectWith:".accordion-section-content:has(.customize-control-sidebar_widgets)",update:function(){var c,d=a.$sectionContent.sortable("toArray");c=b.map(d,function(a){return b("#"+a).find(":input[name=widget-id]").val()}),a.setting(c)}}),this.$controlSection.find(".accordion-section-title").droppable({accept:".customize-control-widget_form",over:function(){var b=f.section(a.section.get());b.expand({allowMultiple:!0,completeCallback:function(){f.section.each(function(a){a.container.find(".customize-control-sidebar_widgets").length&&a.container.find(".accordion-section-content:first").sortable("refreshPositions")})}})}}),this.container.find(".reorder-toggle").on("click keydown",function(b){("keydown"!==b.type||13===b.which||32===b.which)&&a.toggleReordering(!a.isReordering)})},_setupAddition:function(){var a=this;this.container.find(".add-new-widget").on("click keydown",function(c){("keydown"!==c.type||13===c.which||32===c.which)&&(a.$sectionContent.hasClass("reordering")||(b("body").hasClass("adding-widget")?f.Widgets.availableWidgetsPanel.close():f.Widgets.availableWidgetsPanel.open(a)))})},_applyCardinalOrderClassNames:function(){var a=[];_.each(this.setting(),function(b){var c=f.Widgets.getWidgetFormControlForWidget(b);c&&a.push(c)}),a.length&&(b(a).each(function(){b(this.container).removeClass("first-widget").removeClass("last-widget").find(".move-widget-down, .move-widget-up").prop("tabIndex",0)}),_.first(a).container.addClass("first-widget").find(".move-widget-up").prop("tabIndex",-1),_.last(a).container.addClass("last-widget").find(".move-widget-down").prop("tabIndex",-1))},toggleReordering:function(a){a=Boolean(a),a!==this.$sectionContent.hasClass("reordering")&&(this.isReordering=a,this.$sectionContent.toggleClass("reordering",a),a?(_(this.getWidgetFormControls()).each(function(a){a.collapse()}),this.$sectionContent.find(".first-widget .move-widget").focus(),this.$sectionContent.find(".add-new-widget").prop("tabIndex",-1)):this.$sectionContent.find(".add-new-widget").prop("tabIndex",0))},getWidgetFormControls:function(){var a;return a=_(this.setting()).map(function(a){var b=d(a),c=f.control(b);if(c)return c})},addWidget:function(a){var d,e,g,h,i,j,k,l,m,n,o=this,p="widget_form",q=c(a),r=q.number,s=q.id_base,t=f.Widgets.availableWidgets.findWhere({id_base:s});return t?r&&!t.get("is_multi")?!1:(t.get("is_multi")&&!r&&(t.set("multi_number",t.get("multi_number")+1),r=t.get("multi_number")),d=b.trim(b("#widget-tpl-"+t.get("id")).html()),t.get("is_multi")?d=d.replace(/<[^<>]+>/g,function(a){return a.replace(/__i__|%i%/g,r)}):t.set("is_disabled",!0),e=b(d),g=b("").addClass("customize-control").addClass("customize-control-"+p).append(e),g.find("> .widget-icon").remove(),t.get("is_multi")&&(g.find('input[name="widget_number"]').val(r),g.find('input[name="multi_number"]').val(r)),a=g.find('[name="widget-id"]').val(),g.hide(),i="widget_"+t.get("id_base"),t.get("is_multi")&&(i+="["+r+"]"),g.attr("id","customize-control-"+i.replace(/\]/g,"").replace(/\[/g,"-")),j=f.has(i),j||(m={transport:"refresh",previewer:this.setting.previewer},n=f.create(i,i,"",m),n.set({})),h=f.controlConstructor[p],k=new h(i,{params:{settings:{"default":i},content:g,sidebar_id:o.params.sidebar_id,widget_id:a,widget_id_base:t.get("id_base"),type:p,is_new:!j,width:t.get("width"),height:t.get("height"),is_wide:t.get("is_wide")},previewer:o.setting.previewer}),f.control.add(i,k),f.each(function(b){if(b.id!==o.setting.id&&0===b.id.indexOf("sidebars_widgets[")){var c=b().slice(),d=_.indexOf(c,a);-1!==d&&(c.splice(d),b(c))}}),l=this.setting().slice(),-1===_.indexOf(l,a)&&(l.push(a),this.setting(l)),g.slideDown(function(){j?(k.expand(),k.updateWidget({instance:k.setting(),complete:function(a){if(a)throw a;k.focus()}})):k.focus()}),b(document).trigger("widget-added",[e]),k):!1}}),b.extend(f.controlConstructor,{widget_form:f.Widgets.WidgetControl,sidebar_widgets:f.Widgets.SidebarControl}),f.bind("ready",function(){f.Widgets.availableWidgetsPanel=new f.Widgets.AvailableWidgetsPanelView({collection:f.Widgets.availableWidgets}),f.previewer.bind("highlight-widget-control",f.Widgets.highlightWidgetFormControl),f.previewer.bind("focus-widget-control",f.Widgets.focusWidgetFormControl)}),f.Widgets.highlightWidgetFormControl=function(a){var b=f.Widgets.getWidgetFormControlForWidget(a);b&&b.highlightSectionAndControl()},f.Widgets.focusWidgetFormControl=function(a){var b=f.Widgets.getWidgetFormControlForWidget(a);b&&b.focus()},f.Widgets.getSidebarWidgetControlContainingWidget=function(a){var b=null;return f.control.each(function(c){"sidebar_widgets"===c.params.type&&-1!==_.indexOf(c.setting(),a)&&(b=c)}),b},f.Widgets.getWidgetFormControlForWidget=function(a){var b=null;return f.control.each(function(c){"widget_form"===c.params.type&&c.params.widget_id===a&&(b=c)}),b}}}(window.wp,jQuery);
\ No newline at end of file
+!function(a,b){function c(a){var b,c={number:null,id_base:null};return b=a.match(/^(.+)-(\d+)$/),b?(c.id_base=b[1],c.number=parseInt(b[2],10)):c.id_base=a,c}function d(a){var b,d=c(a);return b="widget_"+d.id_base,d.number&&(b+="["+d.number+"]"),b}if(a&&a.customize){var e,f=a.customize;f.Widgets=f.Widgets||{},f.Widgets.data=_wpCustomizeWidgetsSettings||{},e=f.Widgets.data.l10n,delete f.Widgets.data.l10n,f.Widgets.WidgetModel=Backbone.Model.extend({id:null,temp_id:null,classname:null,control_tpl:null,description:null,is_disabled:null,is_multi:null,multi_number:null,name:null,id_base:null,transport:"refresh",params:[],width:null,height:null,search_matched:!0}),f.Widgets.WidgetCollection=Backbone.Collection.extend({model:f.Widgets.WidgetModel,doSearch:function(a){this.terms!==a&&(this.terms=a,this.terms.length>0&&this.search(this.terms),""===this.terms&&this.each(function(a){a.set("search_matched",!0)}))},search:function(a){var b,c;a=a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),a=a.replace(/ /g,")(?=.*"),b=new RegExp("^(?=.*"+a+").+","i"),this.each(function(a){c=[a.get("name"),a.get("id"),a.get("description")].join(" "),a.set("search_matched",b.test(c))})}}),f.Widgets.availableWidgets=new f.Widgets.WidgetCollection(f.Widgets.data.availableWidgets),f.Widgets.SidebarModel=Backbone.Model.extend({after_title:null,after_widget:null,before_title:null,before_widget:null,"class":null,description:null,id:null,name:null,is_rendered:!1}),f.Widgets.SidebarCollection=Backbone.Collection.extend({model:f.Widgets.SidebarModel}),f.Widgets.registeredSidebars=new f.Widgets.SidebarCollection(f.Widgets.data.registeredSidebars),f.Widgets.AvailableWidgetsPanelView=a.Backbone.View.extend({el:"#available-widgets",events:{"input #widgets-search":"search","keyup #widgets-search":"search","change #widgets-search":"search","search #widgets-search":"search","focus .widget-tpl":"focus","click .widget-tpl":"_submit","keypress .widget-tpl":"_submit",keydown:"keyboardAccessible"},selected:null,currentSidebarControl:null,$search:null,initialize:function(){var a=this;this.$search=b("#widgets-search"),_.bindAll(this,"close"),this.listenTo(this.collection,"change",this.updateList),this.updateList(),b("#customize-controls").on("click keydown",function(c){var d=b(c.target).is(".add-new-widget, .add-new-widget *");b("body").hasClass("adding-widget")&&!d&&a.close()}),f.previewer.bind("url",this.close)},search:function(a){var b;this.collection.doSearch(a.target.value),this.selected&&!this.selected.is(":visible")&&(this.selected.removeClass("selected"),this.selected=null),this.selected&&!a.target.value&&(this.selected.removeClass("selected"),this.selected=null),!this.selected&&a.target.value&&(b=this.$el.find("> .widget-tpl:visible:first"),b.length&&this.select(b))},updateList:function(){this.collection.each(function(a){var c=b("#widget-tpl-"+a.id);c.toggle(a.get("search_matched")&&!a.get("is_disabled")),a.get("is_disabled")&&c.is(this.selected)&&(this.selected=null)})},select:function(a){this.selected=b(a),this.selected.siblings(".widget-tpl").removeClass("selected"),this.selected.addClass("selected")},focus:function(a){this.select(b(a.currentTarget))},_submit:function(a){("keypress"!==a.type||13===a.which||32===a.which)&&this.submit(b(a.currentTarget))},submit:function(a){var c,d;a||(a=this.selected),a&&this.currentSidebarControl&&(this.select(a),c=b(this.selected).data("widget-id"),d=this.collection.findWhere({id:c}),d&&(this.currentSidebarControl.addWidget(d.get("id_base")),this.close()))},open:function(a){this.currentSidebarControl=a,_(this.currentSidebarControl.getWidgetFormControls()).each(function(a){a.params.is_wide&&a.collapseForm()}),b("body").addClass("adding-widget"),this.$el.find(".selected").removeClass("selected"),this.collection.doSearch(""),this.$search.focus()},close:function(a){a=a||{},a.returnFocus&&this.currentSidebarControl&&this.currentSidebarControl.container.find(".add-new-widget").focus(),this.currentSidebarControl=null,this.selected=null,b("body").removeClass("adding-widget"),this.$search.val("")},keyboardAccessible:function(a){var c=13===a.which,d=27===a.which,e=40===a.which,f=38===a.which,g=9===a.which,h=a.shiftKey,i=null,j=this.$el.find("> .widget-tpl:visible:first"),k=this.$el.find("> .widget-tpl:visible:last"),l=b(a.target).is(this.$search),m=b(a.target).is(".widget-tpl:visible:last");return e||f?(e?l?i=j:this.selected&&0!==this.selected.nextAll(".widget-tpl:visible").length&&(i=this.selected.nextAll(".widget-tpl:visible:first")):f&&(l?i=k:this.selected&&0!==this.selected.prevAll(".widget-tpl:visible").length&&(i=this.selected.prevAll(".widget-tpl:visible:first"))),this.select(i),void(i?i.focus():this.$search.focus())):void((!c||this.$search.val())&&(c?this.submit():d&&this.close({returnFocus:!0}),g&&(h&&l||!h&&m)&&(this.currentSidebarControl.container.find(".add-new-widget").focus(),a.preventDefault())))}}),f.Widgets.formSyncHandlers={rss:function(a,c,d){var e=c.find(".widget-error:first"),f=b(""+d+"
").find(".widget-error:first");e.length&&f.length?e.replaceWith(f):e.length?e.remove():f.length&&c.find(".widget-content:first").prepend(f)}},f.Widgets.WidgetControl=f.Control.extend({defaultExpandedArguments:{duration:"fast",completeCallback:b.noop},initialize:function(a,c){var d=this;f.Control.prototype.initialize.call(d,a,c),d.expanded=new f.Value,d.expandedArgumentsQueue=[],d.expanded.bind(function(a){var c=d.expandedArgumentsQueue.shift();c=b.extend({},d.defaultExpandedArguments,c),d.onChangeExpanded(a,c)}),d.expanded.set(!1)},ready:function(){this._setupModel(),this._setupWideWidget(),this._setupControlToggle(),this._setupWidgetTitle(),this._setupReorderUI(),this._setupHighlightEffects(),this._setupUpdateUI(),this._setupRemoveUI()},_setupModel:function(){var a,b=this;f.Widgets.savedWidgetIds=f.Widgets.savedWidgetIds||[],a=function(){f.Widgets.savedWidgetIds[b.params.widget_id]=!0},f.bind("ready",a),f.bind("saved",a),this._updateCount=0,this.isWidgetUpdating=!1,this.liveUpdateMode=!0,this.setting.bind(function(a,c){_(c).isEqual(a)||b.isWidgetUpdating||b.updateWidget({instance:a})})},_setupWideWidget:function(){var a,c,d,e,g,h=this;this.params.is_wide&&(a=this.container.find(".widget-inside"),c=a.find("> .form"),d=b(".wp-full-overlay-sidebar-content:first"),this.container.addClass("wide-widget-control"),this.container.find(".widget-content:first").css({"max-width":this.params.width,"min-height":this.params.height}),g=function(){var d,e=h.container.offset().top,f=b(window).height(),g=c.outerHeight();a.css("max-height",f),d=Math.max(0,Math.min(Math.max(e,0),f-g)),a.css("top",d)},e=b("#customize-theme-controls"),this.container.on("expand",function(){g(),d.on("scroll",g),b(window).on("resize",g),e.on("expanded collapsed",g)}),this.container.on("collapsed",function(){d.off("scroll",g),b(window).off("resize",g),e.off("expanded collapsed",g)}),f.each(function(a){0===a.id.indexOf("sidebars_widgets[")&&a.bind(function(){h.container.hasClass("expanded")&&g()})}))},_setupControlToggle:function(){var a,b=this;this.container.find(".widget-top").on("click",function(a){a.preventDefault();var c=b.getSidebarWidgetsControl();c.isReordering||b.expanded(!b.expanded())}),a=this.container.find(".widget-control-close"),a.on("click",function(a){a.preventDefault(),b.collapse(),b.container.find(".widget-top .widget-action:first").focus()})},_setupWidgetTitle:function(){var a,b=this;a=function(){var a=b.setting().title,c=b.container.find(".in-widget-title");c.text(a?": "+a:"")},this.setting.bind(a),a()},_setupReorderUI:function(){var a,c,d,e,g=this;a=function(a){a.siblings(".selected").removeClass("selected"),a.addClass("selected");var b=a.data("id")===g.params.sidebar_id;g.container.find(".move-widget-btn").prop("disabled",b)},this.container.find(".widget-title-action").after(b(f.Widgets.data.tpl.widgetReorderNav)),c=b(_.template(f.Widgets.data.tpl.moveWidgetArea,{sidebars:_(f.Widgets.registeredSidebars.toArray()).pluck("attributes")})),this.container.find(".widget-top").after(c),e=function(){var d,e=c.find("li");d=e.filter(function(){return b(this).data("id")===g.params.sidebar_id}),e.each(function(){var c,e,g=b(this);c=g.data("id"),e=f.Widgets.registeredSidebars.get(c),g.toggle(e.get("is_rendered")),g.hasClass("selected")&&!e.get("is_rendered")&&a(d)})},e(),f.Widgets.registeredSidebars.on("change:is_rendered",e),d=this.container.find(".widget-reorder-nav"),d.find(".move-widget, .move-widget-down, .move-widget-up").each(function(){b(this).prepend(g.container.find(".widget-title").text()+": ")}).on("click keypress",function(a){if("keypress"!==a.type||13===a.which||32===a.which)if(b(this).focus(),b(this).is(".move-widget"))g.toggleWidgetMoveArea();else{var c=b(this).is(".move-widget-down"),d=b(this).is(".move-widget-up"),e=g.getWidgetSidebarPosition();if(d&&0===e||c&&e===g.getSidebarWidgetsControl().setting().length-1)return;d?g.moveUp():g.moveDown(),b(this).focus()}}),this.container.find(".widget-area-select").on("click keypress","li",function(c){("keypress"!==event.type||13===event.which||32===event.which)&&(c.preventDefault(),a(b(this)))}),this.container.find(".move-widget-btn").click(function(){g.getSidebarWidgetsControl().toggleReordering(!1);var a,b,c,d,e,h=g.params.sidebar_id,i=g.container.find(".widget-area-select li.selected").data("id");a=f("sidebars_widgets["+h+"]"),b=f("sidebars_widgets["+i+"]"),c=Array.prototype.slice.call(a()),d=Array.prototype.slice.call(b()),e=g.getWidgetSidebarPosition(),c.splice(e,1),d.push(g.params.widget_id),a(c),b(d),g.focus()})},_setupHighlightEffects:function(){var a=this;this.container.on("mouseenter click",function(){a.setting.previewer.send("highlight-widget",a.params.widget_id)}),this.setting.bind(function(){a.setting.previewer.send("highlight-widget",a.params.widget_id)})},_setupUpdateUI:function(){var a,c,d,g,h,i=this;a=this.container.find(".widget:first"),c=a.find(".widget-content:first"),d=this.container.find(".widget-control-save"),d.val(e.saveBtnLabel),d.attr("title",e.saveBtnTooltip),d.removeClass("button-primary").addClass("button-secondary"),d.on("click",function(a){a.preventDefault(),i.updateWidget({disable_form:!0})}),g=_.debounce(function(){i.updateWidget()},250),c.on("keydown","input",function(a){13===a.which&&(a.preventDefault(),i.updateWidget({ignoreActiveElement:!0}))}),c.on("change input propertychange",":input",function(a){i.liveUpdateMode&&("change"===a.type?i.updateWidget():this.checkValidity&&this.checkValidity()&&g())}),this.setting.previewer.channel.bind("synced",function(){i.container.removeClass("previewer-loading")}),f.previewer.bind("widget-updated",function(a){a===i.params.widget_id&&i.container.removeClass("previewer-loading")}),h=f.Widgets.formSyncHandlers[this.params.widget_id_base],h&&b(document).on("widget-synced",function(b,c){a.is(c)&&h.apply(document,arguments)})},onChangeActive:function(a,b){this.container.toggleClass("widget-rendered",a),b.completeCallback&&b.completeCallback()},_setupRemoveUI:function(){var a,b,c=this;a=this.container.find("a.widget-control-remove"),a.on("click",function(a){a.preventDefault();var b;b=c.container.next().is(".customize-control-widget_form")?c.container.next().find(".widget-action:first"):c.container.prev().is(".customize-control-widget_form")?c.container.prev().find(".widget-action:first"):c.container.next(".customize-control-sidebar_widgets").find(".add-new-widget:first"),c.container.slideUp(function(){var a,d,e=f.Widgets.getSidebarWidgetControlContainingWidget(c.params.widget_id);e&&(a=e.setting().slice(),d=_.indexOf(a,c.params.widget_id),-1!==d&&(a.splice(d,1),e.setting(a),b.focus()))})}),b=function(){a.text(e.removeBtnLabel),a.attr("title",e.removeBtnTooltip)},this.params.is_new?f.bind("saved",b):b()},_getInputs:function(a){return b(a).find(":input[name]")},_getInputsSignature:function(a){var c=_(a).map(function(a){var c,d=b(a);return c=d.is(":checkbox, :radio")?[d.attr("id"),d.attr("name"),d.prop("value")]:[d.attr("id"),d.attr("name")],c.join(",")});return c.join(";")},_getInputStatePropertyName:function(a){var c=b(a);return c.is(":radio, :checkbox")?"checked":"value"},getSidebarWidgetsControl:function(){var a,b;return a="sidebars_widgets["+this.params.sidebar_id+"]",(b=f.control(a))?b:void 0},updateWidget:function(c){var d,g,h,i,j,k,l,m,n,o,p,q=this;c=b.extend({instance:null,complete:null,ignoreActiveElement:!1},c),d=c.instance,g=c.complete,this._updateCount+=1,j=this._updateCount,h=this.container.find(".widget:first"),i=h.find(".widget-content:first"),i.find(".widget-error").remove(),this.container.addClass("widget-form-loading"),this.container.addClass("previewer-loading"),n=f.state("processing"),n(n()+1),this.liveUpdateMode||this.container.addClass("widget-form-disabled"),k={},k.action="update-widget",k.wp_customize="on",k.nonce=f.Widgets.data.nonce,k.theme=f.settings.theme.stylesheet,l=b.param(k),m=this._getInputs(i),m.each(function(){var a=b(this),c=q._getInputStatePropertyName(this);a.data("state"+j,a.prop(c))}),l+=d?"&"+b.param({sanitized_widget_setting:JSON.stringify(d)}):"&"+m.serialize(),l+="&"+i.find("~ :input").serialize(),o=b.post(a.ajax.settings.url,l),o.done(function(a){var d,k,l,n,o=!1;return"0"===a?(f.previewer.preview.iframe.hide(),void f.previewer.login().done(function(){q.updateWidget(c),f.previewer.preview.iframe.show()})):"-1"===a?void f.previewer.cheatin():void(a.success?(k=b(""+a.data.form+"
"),l=q._getInputs(k),n=q._getInputsSignature(m)===q._getInputsSignature(l),n&&!q.liveUpdateMode&&(q.liveUpdateMode=!0,q.container.removeClass("widget-form-disabled"),q.container.find('input[name="savewidget"]').hide()),n&&q.liveUpdateMode?(m.each(function(a){var d,e,f,g=b(this),h=b(l[a]),i=q._getInputStatePropertyName(this);d=g.data("state"+j),e=h.prop(i),g.data("sanitized",e),f=d!==e&&(c.ignoreActiveElement||!g.is(document.activeElement)),f&&g.prop(i,e)}),b(document).trigger("widget-synced",[h,a.data.form])):q.liveUpdateMode?(q.liveUpdateMode=!1,q.container.find('input[name="savewidget"]').show(),o=!0):(i.html(a.data.form),q.container.removeClass("widget-form-disabled"),b(document).trigger("widget-updated",[h])),p=!o&&!_(q.setting()).isEqual(a.data.instance),p?(q.isWidgetUpdating=!0,q.setting(a.data.instance),q.isWidgetUpdating=!1):q.container.removeClass("previewer-loading"),g&&g.call(q,null,{noChange:!p,ajaxFinished:!0})):(d=e.error,a.data&&a.data.message&&(d=a.data.message),g?g.call(q,d):i.prepend(''+d+"
")))}),o.fail(function(a,b){g&&g.call(q,b)}),o.always(function(){q.container.removeClass("widget-form-loading"),m.each(function(){b(this).removeData("state"+j)}),n(n()-1)})},expandControlSection:function(){f.Control.prototype.expand.call(this)},_toggleExpanded:f.Section.prototype._toggleExpanded,expand:f.Section.prototype.expand,expandForm:function(){this.expand()},collapse:f.Section.prototype.collapse,collapseForm:function(){this.collapse()},toggleForm:function(a){"undefined"==typeof a&&(a=!this.expanded()),this.expanded(a)},onChangeExpanded:function(a,b){var c,d,e,g,h=this;return b.unchanged?void(a&&f.Control.prototype.expand.call(h,{completeCallback:b.completeCallback})):(c=this.container.find("div.widget:first"),d=c.find(".widget-inside:first"),void(a?(h.expandControlSection(),f.control.each(function(a){h.params.type===a.params.type&&h!==a&&a.collapse()}),e=function(){h.container.removeClass("expanding"),h.container.addClass("expanded"),h.container.trigger("expanded")},b.completeCallback&&(g=e,e=function(){g(),b.completeCallback()}),h.params.is_wide?d.fadeIn(b.duration,e):d.slideDown(b.duration,e),h.container.trigger("expand"),h.container.addClass("expanding")):(e=function(){h.container.removeClass("collapsing"),h.container.removeClass("expanded"),h.container.trigger("collapsed")},b.completeCallback&&(g=e,e=function(){g(),b.completeCallback()}),h.container.trigger("collapse"),h.container.addClass("collapsing"),h.params.is_wide?d.fadeOut(b.duration,e):d.slideUp(b.duration,function(){c.css({width:"",margin:""}),e()}))))},getWidgetSidebarPosition:function(){var a,b;return a=this.getSidebarWidgetsControl().setting(),b=_.indexOf(a,this.params.widget_id),-1!==b?b:void 0},moveUp:function(){this._moveWidgetByOne(-1)},moveDown:function(){this._moveWidgetByOne(1)},_moveWidgetByOne:function(a){var b,c,d,e;b=this.getWidgetSidebarPosition(),c=this.getSidebarWidgetsControl().setting,d=Array.prototype.slice.call(c()),e=d[b+a],d[b+a]=this.params.widget_id,d[b]=e,c(d)},toggleWidgetMoveArea:function(a){var c,d=this;c=this.container.find(".move-widget-area"),"undefined"==typeof a&&(a=!c.hasClass("active")),a&&(c.find(".selected").removeClass("selected"),c.find("li").filter(function(){return b(this).data("id")===d.params.sidebar_id}).addClass("selected"),this.container.find(".move-widget-btn").prop("disabled",!0)),c.toggleClass("active",a)},highlightSectionAndControl:function(){var a;a=this.container.is(":hidden")?this.container.closest(".control-section"):this.container,b(".highlighted").removeClass("highlighted"),a.addClass("highlighted"),setTimeout(function(){a.removeClass("highlighted")},500)}}),f.Widgets.SidebarControl=f.Control.extend({ready:function(){this.$controlSection=this.container.closest(".control-section"),this.$sectionContent=this.container.closest(".accordion-section-content"),this._setupModel(),this._setupSortable(),this._setupAddition(),this._applyCardinalOrderClassNames()},_setupModel:function(){var a=this,d=f.Widgets.registeredSidebars.get(this.params.sidebar_id);this.setting.bind(function(d,e){var g,h,i;h=_(e).difference(d),d=_(d).filter(function(a){var b=c(a);return!!f.Widgets.availableWidgets.findWhere({id_base:b.id_base})}),g=_(d).map(function(b){var c=f.Widgets.getWidgetFormControlForWidget(b);return c||(c=a.addWidget(b)),c}),g.sort(function(a,b){var c=_.indexOf(d,a.params.widget_id),e=_.indexOf(d,b.params.widget_id);return c-e}),i=0,_(g).each(function(b){b.priority(i),b.section(a.section()),i+=1}),a.priority(i),a._applyCardinalOrderClassNames(),_(g).each(function(b){b.params.sidebar_id=a.params.sidebar_id}),_(h).each(function(d){setTimeout(function(){var e,g,h,i,j,k=!1;f.each(function(b){if(b.id!==a.setting.id&&0===b.id.indexOf("sidebars_widgets[")&&"sidebars_widgets[wp_inactive_widgets]"!==b.id){var c,e=b();c=_.indexOf(e,d),-1!==c&&(k=!0)}}),k||(e=f.Widgets.getWidgetFormControlForWidget(d),g=e&&b.contains(document,e.container[0])&&!b.contains(a.$sectionContent[0],e.container[0]),e&&!g&&(f.control.remove(e.id),e.container.remove()),f.Widgets.savedWidgetIds[d]&&(h=f.value("sidebars_widgets[wp_inactive_widgets]")().slice(),h.push(d),f.value("sidebars_widgets[wp_inactive_widgets]")(_(h).unique())),i=c(d).id_base,j=f.Widgets.availableWidgets.findWhere({id_base:i}),j&&!j.get("is_multi")&&j.set("is_disabled",!1))})})}),a.active.bind(function(b){d.set("is_rendered",b),f.section(a.section.get()).active(b)}),f.section(a.section.get()).active(a.active())},_setupSortable:function(){var a=this;this.isReordering=!1,this.$sectionContent.sortable({items:"> .customize-control-widget_form",handle:".widget-top",axis:"y",connectWith:".accordion-section-content:has(.customize-control-sidebar_widgets)",update:function(){var c,d=a.$sectionContent.sortable("toArray");c=b.map(d,function(a){return b("#"+a).find(":input[name=widget-id]").val()}),a.setting(c)}}),this.$controlSection.find(".accordion-section-title").droppable({accept:".customize-control-widget_form",over:function(){var b=f.section(a.section.get());b.expand({allowMultiple:!0,completeCallback:function(){f.section.each(function(a){a.container.find(".customize-control-sidebar_widgets").length&&a.container.find(".accordion-section-content:first").sortable("refreshPositions")})}})}}),this.container.find(".reorder-toggle").on("click keydown",function(b){("keydown"!==b.type||13===b.which||32===b.which)&&a.toggleReordering(!a.isReordering)})},_setupAddition:function(){var a=this;this.container.find(".add-new-widget").on("click keydown",function(c){("keydown"!==c.type||13===c.which||32===c.which)&&(a.$sectionContent.hasClass("reordering")||(b("body").hasClass("adding-widget")?f.Widgets.availableWidgetsPanel.close():f.Widgets.availableWidgetsPanel.open(a)))})},_applyCardinalOrderClassNames:function(){var a=[];_.each(this.setting(),function(b){var c=f.Widgets.getWidgetFormControlForWidget(b);c&&a.push(c)}),a.length&&(b(a).each(function(){b(this.container).removeClass("first-widget").removeClass("last-widget").find(".move-widget-down, .move-widget-up").prop("tabIndex",0)}),_.first(a).container.addClass("first-widget").find(".move-widget-up").prop("tabIndex",-1),_.last(a).container.addClass("last-widget").find(".move-widget-down").prop("tabIndex",-1))},toggleReordering:function(a){a=Boolean(a),a!==this.$sectionContent.hasClass("reordering")&&(this.isReordering=a,this.$sectionContent.toggleClass("reordering",a),a?(_(this.getWidgetFormControls()).each(function(a){a.collapse()}),this.$sectionContent.find(".first-widget .move-widget").focus(),this.$sectionContent.find(".add-new-widget").prop("tabIndex",-1)):this.$sectionContent.find(".add-new-widget").prop("tabIndex",0))},getWidgetFormControls:function(){var a;return a=_(this.setting()).map(function(a){var b=d(a),c=f.control(b);if(c)return c})},addWidget:function(a){var d,e,g,h,i,j,k,l,m,n,o=this,p="widget_form",q=c(a),r=q.number,s=q.id_base,t=f.Widgets.availableWidgets.findWhere({id_base:s});return t?r&&!t.get("is_multi")?!1:(t.get("is_multi")&&!r&&(t.set("multi_number",t.get("multi_number")+1),r=t.get("multi_number")),d=b.trim(b("#widget-tpl-"+t.get("id")).html()),t.get("is_multi")?d=d.replace(/<[^<>]+>/g,function(a){return a.replace(/__i__|%i%/g,r)}):t.set("is_disabled",!0),e=b(d),g=b("").addClass("customize-control").addClass("customize-control-"+p).append(e),g.find("> .widget-icon").remove(),t.get("is_multi")&&(g.find('input[name="widget_number"]').val(r),g.find('input[name="multi_number"]').val(r)),a=g.find('[name="widget-id"]').val(),g.hide(),i="widget_"+t.get("id_base"),t.get("is_multi")&&(i+="["+r+"]"),g.attr("id","customize-control-"+i.replace(/\]/g,"").replace(/\[/g,"-")),j=f.has(i),j||(m={transport:"refresh",previewer:this.setting.previewer},n=f.create(i,i,"",m),n.set({})),h=f.controlConstructor[p],k=new h(i,{params:{settings:{"default":i},content:g,sidebar_id:o.params.sidebar_id,widget_id:a,widget_id_base:t.get("id_base"),type:p,is_new:!j,width:t.get("width"),height:t.get("height"),is_wide:t.get("is_wide")},previewer:o.setting.previewer}),f.control.add(i,k),f.each(function(b){if(b.id!==o.setting.id&&0===b.id.indexOf("sidebars_widgets[")){var c=b().slice(),d=_.indexOf(c,a);-1!==d&&(c.splice(d),b(c))}}),l=this.setting().slice(),-1===_.indexOf(l,a)&&(l.push(a),this.setting(l)),g.slideDown(function(){j?(k.expand(),k.updateWidget({instance:k.setting(),complete:function(a){if(a)throw a;k.focus()}})):k.focus()}),b(document).trigger("widget-added",[e]),k):!1}}),b.extend(f.controlConstructor,{widget_form:f.Widgets.WidgetControl,sidebar_widgets:f.Widgets.SidebarControl}),f.bind("ready",function(){f.Widgets.availableWidgetsPanel=new f.Widgets.AvailableWidgetsPanelView({collection:f.Widgets.availableWidgets}),f.previewer.bind("highlight-widget-control",f.Widgets.highlightWidgetFormControl),f.previewer.bind("focus-widget-control",f.Widgets.focusWidgetFormControl)}),f.Widgets.highlightWidgetFormControl=function(a){var b=f.Widgets.getWidgetFormControlForWidget(a);b&&b.highlightSectionAndControl()},f.Widgets.focusWidgetFormControl=function(a){var b=f.Widgets.getWidgetFormControlForWidget(a);b&&b.focus()},f.Widgets.getSidebarWidgetControlContainingWidget=function(a){var b=null;return f.control.each(function(c){"sidebar_widgets"===c.params.type&&-1!==_.indexOf(c.setting(),a)&&(b=c)}),b},f.Widgets.getWidgetFormControlForWidget=function(a){var b=null;return f.control.each(function(c){"widget_form"===c.params.type&&c.params.widget_id===a&&(b=c)}),b}}}(window.wp,jQuery);
\ No newline at end of file
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 98b5e6a675..fdef58a3de 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
-$wp_version = '4.1-alpha-30306';
+$wp_version = '4.1-alpha-30307';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.