diff options
Diffstat (limited to 'wp-admin/js')
26 files changed, 216 insertions, 84 deletions
diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index af6cedc..b2d8b56 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -903,27 +903,6 @@ $( function() { }); /** - * Handles the `aria-haspopup` attribute on the current menu item when it has a submenu. - * - * @since 4.4.0 - * - * @return {void} - */ - function currentMenuItemHasPopup() { - var $current = $( 'a.wp-has-current-submenu' ); - - if ( 'folded' === menuState ) { - // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu. - $current.attr( 'aria-haspopup', 'true' ); - } else { - // When expanded or in responsive view, reset aria-haspopup. - $current.attr( 'aria-haspopup', 'false' ); - } - } - - $document.on( 'wp-menu-state-set wp-collapse-menu wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup ); - - /** * Ensures an admin submenu is within the visual viewport. * * @since 4.1.0 @@ -1169,7 +1148,7 @@ $( function() { lastClicked = this; // Toggle the "Select all" checkboxes depending if the other ones are all checked or not. - var unchecked = $(this).closest('tbody').find('tr.iedit').find(':checkbox').filter(':visible:enabled').not(':checked'); + var unchecked = $(this).closest('tbody').find('tr').find(':checkbox').filter(':visible:enabled').not(':checked'); /** * Determines if all checkboxes are checked. @@ -1695,8 +1674,10 @@ $( function() { // Modify functionality based on custom activate/deactivate event. $document.on( 'wp-responsive-activate.wp-responsive', function() { self.activate(); + self.toggleAriaHasPopup( 'add' ); }).on( 'wp-responsive-deactivate.wp-responsive', function() { self.deactivate(); + self.toggleAriaHasPopup( 'remove' ); }); $( '#wp-admin-bar-menu-toggle a' ).attr( 'aria-expanded', 'false' ); @@ -1748,7 +1729,7 @@ $( function() { setTimeout( function() { var focusIsInToggle = $.contains( toggleButton, focusedElement ); var focusIsInSidebar = $.contains( sidebar, focusedElement ); - + if ( ! focusIsInToggle && ! focusIsInSidebar ) { $( toggleButton ).trigger( 'click.wp-responsive' ); } @@ -1762,8 +1743,9 @@ $( function() { if ( ! $adminmenu.data('wp-responsive') ) { return; } - + let state = ( 'false' === $( this ).attr( 'aria-expanded' ) ) ? 'true' : 'false'; $( this ).parent( 'li' ).toggleClass( 'selected' ); + $( this ).attr( 'aria-expanded', state ); $( this ).trigger( 'focus' ); event.preventDefault(); }); @@ -1838,6 +1820,34 @@ $( function() { }, /** + * Toggles the aria-haspopup attribute for the responsive admin menu. + * + * The aria-haspopup attribute is only necessary for the responsive menu. + * See ticket https://core.trac.wordpress.org/ticket/43095 + * + * @since 6.6.0 + * + * @param {string} action Whether to add or remove the aria-haspopup attribute. + * + * @return {void} + */ + toggleAriaHasPopup: function( action ) { + var elements = $adminmenu.find( '[data-ariahaspopup]' ); + + if ( action === 'add' ) { + elements.each( function() { + $( this ).attr( 'aria-haspopup', 'menu' ).attr( 'aria-expanded', 'false' ); + } ); + + return; + } + + elements.each( function() { + $( this ).removeAttr( 'aria-haspopup' ).removeAttr( 'aria-expanded' ); + } ); + }, + + /** * Sets the responsiveness and enables the overlay based on the viewport width. * * @since 3.8.0 @@ -2034,7 +2044,6 @@ $( function() { window.wpResponsive.init(); setPinMenu(); setMenuState(); - currentMenuItemHasPopup(); makeNoticesDismissible(); aria_button_if_js(); diff --git a/wp-admin/js/common.min.js b/wp-admin/js/common.min.js index c994b69..e20ff95 100644 --- a/wp-admin/js/common.min.js +++ b/wp-admin/js/common.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(W,$){var Q=W(document),V=W($),q=W(document.body),H=wp.i18n.__,i=wp.i18n.sprintf;function r(e,t,n){n=void 0!==n?i(H("%1$s is deprecated since version %2$s! Use %3$s instead."),e,t,n):i(H("%1$s is deprecated since version %2$s with no alternative available."),e,t);$.console.warn(n)}function e(i,o,a){var s={};return Object.keys(o).forEach(function(e){var t=o[e],n=i+"."+e;"object"==typeof t?Object.defineProperty(s,e,{get:function(){return r(n,a,t.alternative),t.func()}}):Object.defineProperty(s,e,{get:function(){return r(n,a,"wp.i18n"),t}})}),s}$.wp.deprecateL10nObject=e,$.commonL10n=$.commonL10n||{warnDelete:"",dismiss:"",collapseMenu:"",expandMenu:""},$.commonL10n=e("commonL10n",$.commonL10n,"5.5.0"),$.wpPointerL10n=$.wpPointerL10n||{dismiss:""},$.wpPointerL10n=e("wpPointerL10n",$.wpPointerL10n,"5.5.0"),$.userProfileL10n=$.userProfileL10n||{warn:"",warnWeak:"",show:"",hide:"",cancel:"",ariaShow:"",ariaHide:""},$.userProfileL10n=e("userProfileL10n",$.userProfileL10n,"5.5.0"),$.privacyToolsL10n=$.privacyToolsL10n||{noDataFound:"",foundAndRemoved:"",noneRemoved:"",someNotRemoved:"",removalError:"",emailSent:"",noExportFile:"",exportError:""},$.privacyToolsL10n=e("privacyToolsL10n",$.privacyToolsL10n,"5.5.0"),$.authcheckL10n={beforeunload:""},$.authcheckL10n=$.authcheckL10n||e("authcheckL10n",$.authcheckL10n,"5.5.0"),$.tagsl10n={noPerm:"",broken:""},$.tagsl10n=$.tagsl10n||e("tagsl10n",$.tagsl10n,"5.5.0"),$.adminCommentsL10n=$.adminCommentsL10n||{hotkeys_highlight_first:{alternative:"window.adminCommentsSettings.hotkeys_highlight_first",func:function(){return $.adminCommentsSettings.hotkeys_highlight_first}},hotkeys_highlight_last:{alternative:"window.adminCommentsSettings.hotkeys_highlight_last",func:function(){return $.adminCommentsSettings.hotkeys_highlight_last}},replyApprove:"",reply:"",warnQuickEdit:"",warnCommentChanges:"",docTitleComments:"",docTitleCommentsCount:""},$.adminCommentsL10n=e("adminCommentsL10n",$.adminCommentsL10n,"5.5.0"),$.tagsSuggestL10n=$.tagsSuggestL10n||{tagDelimiter:"",removeTerm:"",termSelected:"",termAdded:"",termRemoved:""},$.tagsSuggestL10n=e("tagsSuggestL10n",$.tagsSuggestL10n,"5.5.0"),$.wpColorPickerL10n=$.wpColorPickerL10n||{clear:"",clearAriaLabel:"",defaultString:"",defaultAriaLabel:"",pick:"",defaultLabel:""},$.wpColorPickerL10n=e("wpColorPickerL10n",$.wpColorPickerL10n,"5.5.0"),$.attachMediaBoxL10n=$.attachMediaBoxL10n||{error:""},$.attachMediaBoxL10n=e("attachMediaBoxL10n",$.attachMediaBoxL10n,"5.5.0"),$.postL10n=$.postL10n||{ok:"",cancel:"",publishOn:"",publishOnFuture:"",publishOnPast:"",dateFormat:"",showcomm:"",endcomm:"",publish:"",schedule:"",update:"",savePending:"",saveDraft:"",private:"",public:"",publicSticky:"",password:"",privatelyPublished:"",published:"",saveAlert:"",savingText:"",permalinkSaved:""},$.postL10n=e("postL10n",$.postL10n,"5.5.0"),$.inlineEditL10n=$.inlineEditL10n||{error:"",ntdeltitle:"",notitle:"",comma:"",saved:""},$.inlineEditL10n=e("inlineEditL10n",$.inlineEditL10n,"5.5.0"),$.plugininstallL10n=$.plugininstallL10n||{plugin_information:"",plugin_modal_label:"",ays:""},$.plugininstallL10n=e("plugininstallL10n",$.plugininstallL10n,"5.5.0"),$.navMenuL10n=$.navMenuL10n||{noResultsFound:"",warnDeleteMenu:"",saveAlert:"",untitled:""},$.navMenuL10n=e("navMenuL10n",$.navMenuL10n,"5.5.0"),$.commentL10n=$.commentL10n||{submittedOn:"",dateFormat:""},$.commentL10n=e("commentL10n",$.commentL10n,"5.5.0"),$.setPostThumbnailL10n=$.setPostThumbnailL10n||{setThumbnail:"",saving:"",error:"",done:""},$.setPostThumbnailL10n=e("setPostThumbnailL10n",$.setPostThumbnailL10n,"5.5.0"),$.uiAutocompleteL10n=$.uiAutocompleteL10n||{noResults:"",oneResult:"",manyResults:"",itemSelected:""},$.uiAutocompleteL10n=e("uiAutocompleteL10n",$.uiAutocompleteL10n,"6.5.0"),$.adminMenu={init:function(){},fold:function(){},restoreMenuState:function(){},toggle:function(){},favorites:function(){}},$.columns={init:function(){var n=this;W(".hide-column-tog","#adv-settings").on("click",function(){var e=W(this),t=e.val();e.prop("checked")?n.checked(t):n.unchecked(t),columns.saveManageColumnsState()})},saveManageColumnsState:function(){var e=this.hidden();W.post(ajaxurl,{action:"hidden-columns",hidden:e,screenoptionnonce:W("#screenoptionnonce").val(),page:pagenow})},checked:function(e){W(".column-"+e).removeClass("hidden"),this.colSpanChange(1)},unchecked:function(e){W(".column-"+e).addClass("hidden"),this.colSpanChange(-1)},hidden:function(){return W(".manage-column[id]").filter(".hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return W(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(e,e.length-5)}).get().join(",")}},colSpanChange:function(e){var t=W("table").find(".colspanchange");t.length&&(e=parseInt(t.attr("colspan"),10)+e,t.attr("colspan",e.toString()))}},W(function(){columns.init()}),$.validateForm=function(e){return!W(e).find(".form-required").filter(function(){return""===W(":input:visible",this).val()}).addClass("form-invalid").find(":input:visible").on("change",function(){W(this).closest(".form-invalid").removeClass("form-invalid")}).length},$.showNotice={warn:function(){return!!confirm(H("You are about to permanently delete these items from your site.\nThis action cannot be undone.\n'Cancel' to stop, 'OK' to delete."))},note:function(e){alert(e)}},$.screenMeta={element:null,toggles:null,page:null,init:function(){this.element=W("#screen-meta"),this.toggles=W("#screen-meta-links").find(".show-settings"),this.page=W("#wpcontent"),this.toggles.on("click",this.toggleEvent)},toggleEvent:function(){var e=W("#"+W(this).attr("aria-controls"));e.length&&(e.is(":visible")?screenMeta.close(e,W(this)):screenMeta.open(e,W(this)))},open:function(e,t){W("#screen-meta-links").find(".screen-meta-toggle").not(t.parent()).css("visibility","hidden"),e.parent().show(),e.slideDown("fast",function(){e.removeClass("hidden").trigger("focus"),t.addClass("screen-meta-active").attr("aria-expanded",!0)}),Q.trigger("screen:options:open")},close:function(e,t){e.slideUp("fast",function(){t.removeClass("screen-meta-active").attr("aria-expanded",!1),W(".screen-meta-toggle").css("visibility",""),e.parent().hide(),e.addClass("hidden")}),Q.trigger("screen:options:close")}},W(".contextual-help-tabs").on("click","a",function(e){var t=W(this);if(e.preventDefault(),t.is(".active a"))return!1;W(".contextual-help-tabs .active").removeClass("active"),t.parent("li").addClass("active"),e=W(t.attr("href")),W(".help-tab-content").not(e).removeClass("active").hide(),e.addClass("active").show()});var t,a=!1,s=W("#permalink_structure"),n=W(".permalink-structure input:radio"),l=W("#custom_selection"),o=W(".form-table.permalink-structure .available-structure-tags button");function c(e){-1!==s.val().indexOf(e.text().trim())?(e.attr("data-label",e.attr("aria-label")),e.attr("aria-label",e.attr("data-used")),e.attr("aria-pressed",!0),e.addClass("active")):e.attr("data-label")&&(e.attr("aria-label",e.attr("data-label")),e.attr("aria-pressed",!1),e.removeClass("active"))}function d(){Q.trigger("wp-window-resized")}n.on("change",function(){"custom"!==this.value&&(s.val(this.value),o.each(function(){c(W(this))}))}),s.on("click input",function(){l.prop("checked",!0)}),s.on("focus",function(e){a=!0,W(this).off(e)}),o.each(function(){c(W(this))}),s.on("change",function(){o.each(function(){c(W(this))})}),o.on("click",function(){var e=s.val(),t=s[0].selectionStart,n=s[0].selectionEnd,i=W(this).text().trim(),o=W(this).hasClass("active")?W(this).attr("data-removed"):W(this).attr("data-added");-1!==e.indexOf(i)?(e=e.replace(i+"/",""),s.val("/"===e?"":e),W("#custom_selection_updated").text(o),c(W(this))):(a||0!==t||0!==n||(t=n=e.length),l.prop("checked",!0),"/"!==e.substr(0,t).substr(-1)&&(i="/"+i),"/"!==e.substr(n,1)&&(i+="/"),s.val(e.substr(0,t)+i+e.substr(n)),W("#custom_selection_updated").text(o),c(W(this)),a&&s[0].setSelectionRange&&(n=(e.substr(0,t)+i).length,s[0].setSelectionRange(n,n),s.trigger("focus")))}),W(function(){var n,i,o,a,e,t,s,r,l,c,d=!1,u=W("input.current-page"),R=u.val(),p=/iPhone|iPad|iPod/.test(navigator.userAgent),z=-1!==navigator.userAgent.indexOf("Android"),m=W("#adminmenuwrap"),h=W("#wpwrap"),f=W("#adminmenu"),g=W("#wp-responsive-overlay"),v=W("#wp-toolbar"),b=v.find('a[aria-haspopup="true"]'),w=W(".meta-box-sortables"),k=!1,C=W("#wpadminbar"),y=0,L=!1,x=!1,S=0,A=!1,P={window:V.height(),wpwrap:h.height(),adminbar:C.height(),menu:m.height()},T=W(".wp-header-end");function M(){var e=W("a.wp-has-current-submenu");"folded"===s?e.attr("aria-haspopup","true"):e.attr("aria-haspopup","false")}function _(e){var t=e.find(".wp-submenu"),e=e.offset().top,n=V.scrollTop(),i=e-n-30,e=e+t.height()+1,o=60+e-h.height(),n=V.height()+n-50;1<(o=i<(o=n<e-o?e-n:o)?i:o)&&W("#wp-admin-bar-menu-toggle").is(":hidden")?t.css("margin-top","-"+o+"px"):t.css("margin-top","")}function D(){W(".notice.is-dismissible").each(function(){var t=W(this),e=W('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>');t.find(".notice-dismiss").length||(e.find(".screen-reader-text").text(H("Dismiss this notice.")),e.on("click.wp-dismiss-notice",function(e){e.preventDefault(),t.fadeTo(100,0,function(){t.slideUp(100,function(){t.remove()})})}),t.append(e))})}function E(e,t,n,i){n.on("change",function(){e.val(W(this).val())}),e.on("change",function(){n.val(W(this).val())}),i.on("click",function(e){e.preventDefault(),e.stopPropagation(),t.trigger("click")})}function N(){r.prop("disabled",""===l.map(function(){return W(this).val()}).get().join(""))}function F(e){var t=V.scrollTop(),e=!e||"scroll"!==e.type;if(!p&&!f.data("wp-responsive"))if(P.menu+P.adminbar<P.window||P.menu+P.adminbar+20>P.wpwrap)j();else{if(A=!0,P.menu+P.adminbar>P.window){if(t<0)return void(L||(x=!(L=!0),m.css({position:"fixed",top:"",bottom:""})));if(t+P.window>Q.height()-1)return void(x||(L=!(x=!0),m.css({position:"fixed",top:"",bottom:0})));y<t?L?(L=!1,(S=m.offset().top-P.adminbar-(t-y))+P.menu+P.adminbar<t+P.window&&(S=t+P.window-P.menu-P.adminbar),m.css({position:"absolute",top:S,bottom:""})):!x&&m.offset().top+P.menu<t+P.window&&(x=!0,m.css({position:"fixed",top:"",bottom:0})):t<y?x?(x=!1,(S=m.offset().top-P.adminbar+(y-t))+P.menu>t+P.window&&(S=t),m.css({position:"absolute",top:S,bottom:""})):!L&&m.offset().top>=t+P.adminbar&&(L=!0,m.css({position:"fixed",top:"",bottom:""})):e&&(L=x=!1,0<(S=t+P.window-P.menu-P.adminbar-1)?m.css({position:"absolute",top:S,bottom:""}):j())}y=t}}function U(){P={window:V.height(),wpwrap:h.height(),adminbar:C.height(),menu:m.height()}}function j(){!p&&A&&(L=x=A=!1,m.css({position:"",top:"",bottom:""}))}function O(){U(),f.data("wp-responsive")?(q.removeClass("sticky-menu"),j()):P.menu+P.adminbar>P.window?(F(),q.removeClass("sticky-menu")):(q.addClass("sticky-menu"),j())}function K(){W(".aria-button-if-js").attr("role","button")}function I(){var e=!1;return e=$.innerWidth?Math.max($.innerWidth,document.documentElement.clientWidth):e}function B(){var e=I()||961;s=e<=782?"responsive":q.hasClass("folded")||q.hasClass("auto-fold")&&e<=960&&782<e?"folded":"open",Q.trigger("wp-menu-state-set",{state:s})}f.on("click.wp-submenu-head",".wp-submenu-head",function(e){W(e.target).parent().siblings("a").get(0).click()}),W("#collapse-button").on("click.collapse-menu",function(){var e=I()||961;W("#adminmenu div.wp-submenu").css("margin-top",""),s=e<=960?q.hasClass("auto-fold")?(q.removeClass("auto-fold").removeClass("folded"),setUserSetting("unfold",1),setUserSetting("mfold","o"),"open"):(q.addClass("auto-fold"),setUserSetting("unfold",0),"folded"):q.hasClass("folded")?(q.removeClass("folded"),setUserSetting("mfold","o"),"open"):(q.addClass("folded"),setUserSetting("mfold","f"),"folded"),Q.trigger("wp-collapse-menu",{state:s})}),Q.on("wp-menu-state-set wp-collapse-menu wp-responsive-activate wp-responsive-deactivate",M),("ontouchstart"in $||/IEMobile\/[1-9]/.test(navigator.userAgent))&&(q.on((c=p?"touchstart":"click")+".wp-mobile-hover",function(e){f.data("wp-responsive")||W(e.target).closest("#adminmenu").length||f.find("li.opensub").removeClass("opensub")}),f.find("a.wp-has-submenu").on(c+".wp-mobile-hover",function(e){var t=W(this).parent();f.data("wp-responsive")||t.hasClass("opensub")||t.hasClass("wp-menu-open")&&!(t.width()<40)||(e.preventDefault(),_(t),f.find("li.opensub").removeClass("opensub"),t.addClass("opensub"))})),p||z||(f.find("li.wp-has-submenu").hoverIntent({over:function(){var e=W(this),t=e.find(".wp-submenu"),t=parseInt(t.css("top"),10);isNaN(t)||-5<t||f.data("wp-responsive")||(_(e),f.find("li.opensub").removeClass("opensub"),e.addClass("opensub"))},out:function(){f.data("wp-responsive")||W(this).removeClass("opensub").find(".wp-submenu").css("margin-top","")},timeout:200,sensitivity:7,interval:90}),f.on("focus.adminmenu",".wp-submenu a",function(e){f.data("wp-responsive")||W(e.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(e){f.data("wp-responsive")||W(e.target).closest("li.menu-top").removeClass("opensub")}).find("li.wp-has-submenu.wp-not-current-submenu").on("focusin.adminmenu",function(){_(W(this))})),T.length||(T=W(".wrap h1, .wrap h2").first()),W("div.updated, div.error, div.notice").not(".inline, .below-h2").insertAfter(T),Q.on("wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error",D),screenMeta.init(),q.on("click","tbody > tr > .check-column :checkbox",function(e){if("undefined"!=e.shiftKey){if(e.shiftKey){if(!d)return!0;n=W(d).closest("form").find(":checkbox").filter(":visible:enabled"),i=n.index(d),o=n.index(this),a=W(this).prop("checked"),0<i&&0<o&&i!=o&&(i<o?n.slice(i,o):n.slice(o,i)).prop("checked",function(){return!!W(this).closest("tr").is(":visible")&&a})}var t=W(d=this).closest("tbody").find("tr.iedit").find(":checkbox").filter(":visible:enabled").not(":checked");W(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return 0===t.length})}return!0}),q.on("click.wp-toggle-checkboxes","thead .check-column :checkbox, tfoot .check-column :checkbox",function(e){var t=W(this),n=t.closest("table"),i=t.prop("checked"),o=e.shiftKey||t.data("wp-toggle");n.children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return!W(this).is(":hidden,:disabled")&&(o?!W(this).prop("checked"):!!i)}),n.children("thead, tfoot").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return!o&&!!i})}),E(W("#bulk-action-selector-top"),W("#doaction"),W("#bulk-action-selector-bottom"),W("#doaction2")),E(W("#new_role"),W("#changeit"),W("#new_role2"),W("#changeit2")),W("#wpbody-content").on({focusin:function(){clearTimeout(e),t=W(this).find(".row-actions"),W(".row-actions").not(this).removeClass("visible"),t.addClass("visible")},focusout:function(){e=setTimeout(function(){t.removeClass("visible")},30)}},".table-view-list .has-row-actions"),W("tbody").on("click",".toggle-row",function(){W(this).closest("tr").toggleClass("is-expanded")}),W("#default-password-nag-no").on("click",function(){return setUserSetting("default_password_nag","hide"),W("div.default-password-nag").hide(),!1}),W("#newcontent").on("keydown.wpevent_InsertTab",function(e){var t,n,i,o,a=e.target;27==e.keyCode?(e.preventDefault(),W(a).data("tab-out",!0)):9!=e.keyCode||e.ctrlKey||e.altKey||e.shiftKey||(W(a).data("tab-out")?W(a).data("tab-out",!1):(t=a.selectionStart,n=a.selectionEnd,i=a.value,document.selection?(a.focus(),document.selection.createRange().text="\t"):0<=t&&(o=this.scrollTop,a.value=i.substring(0,t).concat("\t",i.substring(n)),a.selectionStart=a.selectionEnd=t+1,this.scrollTop=o),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()))}),u.length&&u.closest("form").on("submit",function(){-1==W('select[name="action"]').val()&&u.val()==R&&u.val("1")}),W('.search-box input[type="search"], .search-box input[type="submit"]').on("mousedown",function(){W('select[name^="action"]').val("-1")}),W("#contextual-help-link, #show-settings-link").on("focus.scroll-into-view",function(e){e.target.scrollIntoViewIfNeeded&&e.target.scrollIntoViewIfNeeded(!1)}),(c=W("form.wp-upload-form")).length&&(r=c.find('input[type="submit"]'),l=c.find('input[type="file"]'),N(),l.on("change",N)),p||(V.on("scroll.pin-menu",F),Q.on("tinymce-editor-init.pin-menu",function(e,t){t.on("wp-autoresize",U)})),$.wpResponsive={init:function(){var e=this;this.maybeDisableSortables=this.maybeDisableSortables.bind(this),Q.on("wp-responsive-activate.wp-responsive",function(){e.activate()}).on("wp-responsive-deactivate.wp-responsive",function(){e.deactivate()}),W("#wp-admin-bar-menu-toggle a").attr("aria-expanded","false"),W("#wp-admin-bar-menu-toggle").on("click.wp-responsive",function(e){e.preventDefault(),C.find(".hover").removeClass("hover"),h.toggleClass("wp-responsive-open"),h.hasClass("wp-responsive-open")?(W(this).find("a").attr("aria-expanded","true"),W("#adminmenu a:first").trigger("focus")):W(this).find("a").attr("aria-expanded","false")}),W(document).on("click",function(e){var t;h.hasClass("wp-responsive-open")&&document.hasFocus()&&(t=W.contains(W("#wp-admin-bar-menu-toggle")[0],e.target),e=W.contains(W("#adminmenuwrap")[0],e.target),t||e||W("#wp-admin-bar-menu-toggle").trigger("click.wp-responsive"))}),W(document).on("keyup",function(e){var n,i,o=W("#wp-admin-bar-menu-toggle")[0];h.hasClass("wp-responsive-open")&&(27===e.keyCode?(W(o).trigger("click.wp-responsive"),W(o).find("a").trigger("focus")):9===e.keyCode&&(n=W("#adminmenuwrap")[0],i=e.relatedTarget||document.activeElement,setTimeout(function(){var e=W.contains(o,i),t=W.contains(n,i);e||t||W(o).trigger("click.wp-responsive")},10)))}),f.on("click.wp-responsive","li.wp-has-submenu > a",function(e){f.data("wp-responsive")&&(W(this).parent("li").toggleClass("selected"),W(this).trigger("focus"),e.preventDefault())}),e.trigger(),Q.on("wp-window-resized.wp-responsive",this.trigger.bind(this)),V.on("load.wp-responsive",this.maybeDisableSortables),Q.on("postbox-toggled",this.maybeDisableSortables),W("#screen-options-wrap input").on("click",this.maybeDisableSortables)},maybeDisableSortables:function(){(-1<navigator.userAgent.indexOf("AppleWebKit/")?V.width():$.innerWidth)<=782||w.find(".ui-sortable-handle:visible").length<=1&&jQuery(".columns-prefs-1 input").prop("checked")?this.disableSortables():this.enableSortables()},activate:function(){O(),q.hasClass("auto-fold")||q.addClass("auto-fold"),f.data("wp-responsive",1),this.disableSortables()},deactivate:function(){O(),f.removeData("wp-responsive"),this.maybeDisableSortables()},trigger:function(){var e=I();e&&(e<=782?k||(Q.trigger("wp-responsive-activate"),k=!0):k&&(Q.trigger("wp-responsive-deactivate"),k=!1),e<=480?this.enableOverlay():this.disableOverlay(),this.maybeDisableSortables())},enableOverlay:function(){0===g.length&&(g=W('<div id="wp-responsive-overlay"></div>').insertAfter("#wpcontent").hide().on("click.wp-responsive",function(){v.find(".menupop.hover").removeClass("hover"),W(this).hide()})),b.on("click.wp-responsive",function(){g.show()})},disableOverlay:function(){b.off("click.wp-responsive"),g.hide()},disableSortables:function(){if(w.length)try{w.sortable("disable"),w.find(".ui-sortable-handle").addClass("is-non-sortable")}catch(e){}},enableSortables:function(){if(w.length)try{w.sortable("enable"),w.find(".ui-sortable-handle").removeClass("is-non-sortable")}catch(e){}}},W(document).on("ajaxComplete",function(){K()}),Q.on("wp-window-resized.set-menu-state",B),Q.on("wp-menu-state-set wp-collapse-menu",function(e,t){var n,i=W("#collapse-button"),t="folded"===t.state?(n="false",H("Expand Main menu")):(n="true",H("Collapse Main menu"));i.attr({"aria-expanded":n,"aria-label":t})}),$.wpResponsive.init(),O(),B(),M(),D(),K(),Q.on("wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu",O),W(".wp-initial-focus").trigger("focus"),q.on("click",".js-update-details-toggle",function(){var e=W(this).closest(".js-update-details"),t=W("#"+e.data("update-details"));t.hasClass("update-details-moved")||t.insertAfter(e).addClass("update-details-moved"),t.toggle(),W(this).attr("aria-expanded",t.is(":visible"))})}),W(function(e){var t,n;q.hasClass("update-php")&&(t=e("a.update-from-upload-overwrite"),n=e(".update-from-upload-expired"),t.length)&&n.length&&$.setTimeout(function(){t.hide(),n.removeClass("hidden"),$.wp&&$.wp.a11y&&$.wp.a11y.speak(n.text())},714e4)}),V.on("resize.wp-fire-once",function(){$.clearTimeout(t),t=$.setTimeout(d,200)}),"-ms-user-select"in document.documentElement.style&&navigator.userAgent.match(/IEMobile\/10\.0/)&&((n=document.createElement("style")).appendChild(document.createTextNode("@-ms-viewport{width:auto!important}")),document.getElementsByTagName("head")[0].appendChild(n))}(jQuery,window),function(){var e,i={},o={};i.pauseAll=!1,!window.matchMedia||(e=window.matchMedia("(prefers-reduced-motion: reduce)"))&&!e.matches||(i.pauseAll=!0),i.freezeAnimatedPluginIcons=function(l){function e(){var e=l.width,t=l.height,n=document.createElement("canvas");if(n.width=e,n.height=t,n.className=l.className,l.closest("#update-plugins-table"))for(var i=window.getComputedStyle(l),o=0,a=i.length;o<a;o++){var s=i[o],r=i.getPropertyValue(s);n.style[s]=r}n.getContext("2d").drawImage(l,0,0,e,t),n.setAttribute("aria-hidden","true"),n.setAttribute("role","presentation"),l.parentNode.insertBefore(n,l),l.style.opacity=.01,l.style.width="0px",l.style.height="0px"}l.complete?e():l.addEventListener("load",e,!0)},o.freezeAll=function(){for(var e=document.querySelectorAll(".plugin-icon, #update-plugins-table img"),t=0;t<e.length;t++)/\.gif(?:\?|$)/i.test(e[t].src)&&i.freezeAnimatedPluginIcons(e[t])},!0===i.pauseAll&&o.freezeAll(),e=jQuery,"plugin-install"===window.pagenow&&e(document).ajaxComplete(function(e,t,n){n.data&&"string"==typeof n.data&&n.data.includes("action=search-install-plugins")&&(window.matchMedia?window.matchMedia("(prefers-reduced-motion: reduce)").matches&&o.freezeAll():!0===i.pauseAll&&o.freezeAll())})}();
\ No newline at end of file +!function(B,W){var $=B(document),H=B(W),Q=B(document.body),V=wp.i18n.__,i=wp.i18n.sprintf;function r(e,t,n){n=void 0!==n?i(V("%1$s is deprecated since version %2$s! Use %3$s instead."),e,t,n):i(V("%1$s is deprecated since version %2$s with no alternative available."),e,t);W.console.warn(n)}function e(i,o,a){var s={};return Object.keys(o).forEach(function(e){var t=o[e],n=i+"."+e;"object"==typeof t?Object.defineProperty(s,e,{get:function(){return r(n,a,t.alternative),t.func()}}):Object.defineProperty(s,e,{get:function(){return r(n,a,"wp.i18n"),t}})}),s}W.wp.deprecateL10nObject=e,W.commonL10n=W.commonL10n||{warnDelete:"",dismiss:"",collapseMenu:"",expandMenu:""},W.commonL10n=e("commonL10n",W.commonL10n,"5.5.0"),W.wpPointerL10n=W.wpPointerL10n||{dismiss:""},W.wpPointerL10n=e("wpPointerL10n",W.wpPointerL10n,"5.5.0"),W.userProfileL10n=W.userProfileL10n||{warn:"",warnWeak:"",show:"",hide:"",cancel:"",ariaShow:"",ariaHide:""},W.userProfileL10n=e("userProfileL10n",W.userProfileL10n,"5.5.0"),W.privacyToolsL10n=W.privacyToolsL10n||{noDataFound:"",foundAndRemoved:"",noneRemoved:"",someNotRemoved:"",removalError:"",emailSent:"",noExportFile:"",exportError:""},W.privacyToolsL10n=e("privacyToolsL10n",W.privacyToolsL10n,"5.5.0"),W.authcheckL10n={beforeunload:""},W.authcheckL10n=W.authcheckL10n||e("authcheckL10n",W.authcheckL10n,"5.5.0"),W.tagsl10n={noPerm:"",broken:""},W.tagsl10n=W.tagsl10n||e("tagsl10n",W.tagsl10n,"5.5.0"),W.adminCommentsL10n=W.adminCommentsL10n||{hotkeys_highlight_first:{alternative:"window.adminCommentsSettings.hotkeys_highlight_first",func:function(){return W.adminCommentsSettings.hotkeys_highlight_first}},hotkeys_highlight_last:{alternative:"window.adminCommentsSettings.hotkeys_highlight_last",func:function(){return W.adminCommentsSettings.hotkeys_highlight_last}},replyApprove:"",reply:"",warnQuickEdit:"",warnCommentChanges:"",docTitleComments:"",docTitleCommentsCount:""},W.adminCommentsL10n=e("adminCommentsL10n",W.adminCommentsL10n,"5.5.0"),W.tagsSuggestL10n=W.tagsSuggestL10n||{tagDelimiter:"",removeTerm:"",termSelected:"",termAdded:"",termRemoved:""},W.tagsSuggestL10n=e("tagsSuggestL10n",W.tagsSuggestL10n,"5.5.0"),W.wpColorPickerL10n=W.wpColorPickerL10n||{clear:"",clearAriaLabel:"",defaultString:"",defaultAriaLabel:"",pick:"",defaultLabel:""},W.wpColorPickerL10n=e("wpColorPickerL10n",W.wpColorPickerL10n,"5.5.0"),W.attachMediaBoxL10n=W.attachMediaBoxL10n||{error:""},W.attachMediaBoxL10n=e("attachMediaBoxL10n",W.attachMediaBoxL10n,"5.5.0"),W.postL10n=W.postL10n||{ok:"",cancel:"",publishOn:"",publishOnFuture:"",publishOnPast:"",dateFormat:"",showcomm:"",endcomm:"",publish:"",schedule:"",update:"",savePending:"",saveDraft:"",private:"",public:"",publicSticky:"",password:"",privatelyPublished:"",published:"",saveAlert:"",savingText:"",permalinkSaved:""},W.postL10n=e("postL10n",W.postL10n,"5.5.0"),W.inlineEditL10n=W.inlineEditL10n||{error:"",ntdeltitle:"",notitle:"",comma:"",saved:""},W.inlineEditL10n=e("inlineEditL10n",W.inlineEditL10n,"5.5.0"),W.plugininstallL10n=W.plugininstallL10n||{plugin_information:"",plugin_modal_label:"",ays:""},W.plugininstallL10n=e("plugininstallL10n",W.plugininstallL10n,"5.5.0"),W.navMenuL10n=W.navMenuL10n||{noResultsFound:"",warnDeleteMenu:"",saveAlert:"",untitled:""},W.navMenuL10n=e("navMenuL10n",W.navMenuL10n,"5.5.0"),W.commentL10n=W.commentL10n||{submittedOn:"",dateFormat:""},W.commentL10n=e("commentL10n",W.commentL10n,"5.5.0"),W.setPostThumbnailL10n=W.setPostThumbnailL10n||{setThumbnail:"",saving:"",error:"",done:""},W.setPostThumbnailL10n=e("setPostThumbnailL10n",W.setPostThumbnailL10n,"5.5.0"),W.uiAutocompleteL10n=W.uiAutocompleteL10n||{noResults:"",oneResult:"",manyResults:"",itemSelected:""},W.uiAutocompleteL10n=e("uiAutocompleteL10n",W.uiAutocompleteL10n,"6.5.0"),W.adminMenu={init:function(){},fold:function(){},restoreMenuState:function(){},toggle:function(){},favorites:function(){}},W.columns={init:function(){var n=this;B(".hide-column-tog","#adv-settings").on("click",function(){var e=B(this),t=e.val();e.prop("checked")?n.checked(t):n.unchecked(t),columns.saveManageColumnsState()})},saveManageColumnsState:function(){var e=this.hidden();B.post(ajaxurl,{action:"hidden-columns",hidden:e,screenoptionnonce:B("#screenoptionnonce").val(),page:pagenow})},checked:function(e){B(".column-"+e).removeClass("hidden"),this.colSpanChange(1)},unchecked:function(e){B(".column-"+e).addClass("hidden"),this.colSpanChange(-1)},hidden:function(){return B(".manage-column[id]").filter(".hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return B(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(e,e.length-5)}).get().join(",")}},colSpanChange:function(e){var t=B("table").find(".colspanchange");t.length&&(e=parseInt(t.attr("colspan"),10)+e,t.attr("colspan",e.toString()))}},B(function(){columns.init()}),W.validateForm=function(e){return!B(e).find(".form-required").filter(function(){return""===B(":input:visible",this).val()}).addClass("form-invalid").find(":input:visible").on("change",function(){B(this).closest(".form-invalid").removeClass("form-invalid")}).length},W.showNotice={warn:function(){return!!confirm(V("You are about to permanently delete these items from your site.\nThis action cannot be undone.\n'Cancel' to stop, 'OK' to delete."))},note:function(e){alert(e)}},W.screenMeta={element:null,toggles:null,page:null,init:function(){this.element=B("#screen-meta"),this.toggles=B("#screen-meta-links").find(".show-settings"),this.page=B("#wpcontent"),this.toggles.on("click",this.toggleEvent)},toggleEvent:function(){var e=B("#"+B(this).attr("aria-controls"));e.length&&(e.is(":visible")?screenMeta.close(e,B(this)):screenMeta.open(e,B(this)))},open:function(e,t){B("#screen-meta-links").find(".screen-meta-toggle").not(t.parent()).css("visibility","hidden"),e.parent().show(),e.slideDown("fast",function(){e.removeClass("hidden").trigger("focus"),t.addClass("screen-meta-active").attr("aria-expanded",!0)}),$.trigger("screen:options:open")},close:function(e,t){e.slideUp("fast",function(){t.removeClass("screen-meta-active").attr("aria-expanded",!1),B(".screen-meta-toggle").css("visibility",""),e.parent().hide(),e.addClass("hidden")}),$.trigger("screen:options:close")}},B(".contextual-help-tabs").on("click","a",function(e){var t=B(this);if(e.preventDefault(),t.is(".active a"))return!1;B(".contextual-help-tabs .active").removeClass("active"),t.parent("li").addClass("active"),e=B(t.attr("href")),B(".help-tab-content").not(e).removeClass("active").hide(),e.addClass("active").show()});var t,a=!1,s=B("#permalink_structure"),n=B(".permalink-structure input:radio"),l=B("#custom_selection"),o=B(".form-table.permalink-structure .available-structure-tags button");function c(e){-1!==s.val().indexOf(e.text().trim())?(e.attr("data-label",e.attr("aria-label")),e.attr("aria-label",e.attr("data-used")),e.attr("aria-pressed",!0),e.addClass("active")):e.attr("data-label")&&(e.attr("aria-label",e.attr("data-label")),e.attr("aria-pressed",!1),e.removeClass("active"))}function d(){$.trigger("wp-window-resized")}n.on("change",function(){"custom"!==this.value&&(s.val(this.value),o.each(function(){c(B(this))}))}),s.on("click input",function(){l.prop("checked",!0)}),s.on("focus",function(e){a=!0,B(this).off(e)}),o.each(function(){c(B(this))}),s.on("change",function(){o.each(function(){c(B(this))})}),o.on("click",function(){var e=s.val(),t=s[0].selectionStart,n=s[0].selectionEnd,i=B(this).text().trim(),o=B(this).hasClass("active")?B(this).attr("data-removed"):B(this).attr("data-added");-1!==e.indexOf(i)?(e=e.replace(i+"/",""),s.val("/"===e?"":e),B("#custom_selection_updated").text(o),c(B(this))):(a||0!==t||0!==n||(t=n=e.length),l.prop("checked",!0),"/"!==e.substr(0,t).substr(-1)&&(i="/"+i),"/"!==e.substr(n,1)&&(i+="/"),s.val(e.substr(0,t)+i+e.substr(n)),B("#custom_selection_updated").text(o),c(B(this)),a&&s[0].setSelectionRange&&(n=(e.substr(0,t)+i).length,s[0].setSelectionRange(n,n),s.trigger("focus")))}),B(function(){var n,i,o,a,e,t,s,r,l,c,d=!1,u=B("input.current-page"),R=u.val(),p=/iPhone|iPad|iPod/.test(navigator.userAgent),z=-1!==navigator.userAgent.indexOf("Android"),m=B("#adminmenuwrap"),h=B("#wpwrap"),f=B("#adminmenu"),g=B("#wp-responsive-overlay"),v=B("#wp-toolbar"),b=v.find('a[aria-haspopup="true"]'),w=B(".meta-box-sortables"),k=!1,C=B("#wpadminbar"),y=0,L=!1,x=!1,S=0,A=!1,P={window:H.height(),wpwrap:h.height(),adminbar:C.height(),menu:m.height()},T=B(".wp-header-end");function M(e){var t=e.find(".wp-submenu"),e=e.offset().top,n=H.scrollTop(),i=e-n-30,e=e+t.height()+1,o=60+e-h.height(),n=H.height()+n-50;1<(o=i<(o=n<e-o?e-n:o)?i:o)&&B("#wp-admin-bar-menu-toggle").is(":hidden")?t.css("margin-top","-"+o+"px"):t.css("margin-top","")}function _(){B(".notice.is-dismissible").each(function(){var t=B(this),e=B('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>');t.find(".notice-dismiss").length||(e.find(".screen-reader-text").text(V("Dismiss this notice.")),e.on("click.wp-dismiss-notice",function(e){e.preventDefault(),t.fadeTo(100,0,function(){t.slideUp(100,function(){t.remove()})})}),t.append(e))})}function D(e,t,n,i){n.on("change",function(){e.val(B(this).val())}),e.on("change",function(){n.val(B(this).val())}),i.on("click",function(e){e.preventDefault(),e.stopPropagation(),t.trigger("click")})}function E(){r.prop("disabled",""===l.map(function(){return B(this).val()}).get().join(""))}function N(e){var t=H.scrollTop(),e=!e||"scroll"!==e.type;if(!p&&!f.data("wp-responsive"))if(P.menu+P.adminbar<P.window||P.menu+P.adminbar+20>P.wpwrap)j();else{if(A=!0,P.menu+P.adminbar>P.window){if(t<0)return void(L||(x=!(L=!0),m.css({position:"fixed",top:"",bottom:""})));if(t+P.window>$.height()-1)return void(x||(L=!(x=!0),m.css({position:"fixed",top:"",bottom:0})));y<t?L?(L=!1,(S=m.offset().top-P.adminbar-(t-y))+P.menu+P.adminbar<t+P.window&&(S=t+P.window-P.menu-P.adminbar),m.css({position:"absolute",top:S,bottom:""})):!x&&m.offset().top+P.menu<t+P.window&&(x=!0,m.css({position:"fixed",top:"",bottom:0})):t<y?x?(x=!1,(S=m.offset().top-P.adminbar+(y-t))+P.menu>t+P.window&&(S=t),m.css({position:"absolute",top:S,bottom:""})):!L&&m.offset().top>=t+P.adminbar&&(L=!0,m.css({position:"fixed",top:"",bottom:""})):e&&(L=x=!1,0<(S=t+P.window-P.menu-P.adminbar-1)?m.css({position:"absolute",top:S,bottom:""}):j())}y=t}}function F(){P={window:H.height(),wpwrap:h.height(),adminbar:C.height(),menu:m.height()}}function j(){!p&&A&&(L=x=A=!1,m.css({position:"",top:"",bottom:""}))}function O(){F(),f.data("wp-responsive")?(Q.removeClass("sticky-menu"),j()):P.menu+P.adminbar>P.window?(N(),Q.removeClass("sticky-menu")):(Q.addClass("sticky-menu"),j())}function U(){B(".aria-button-if-js").attr("role","button")}function I(){var e=!1;return e=W.innerWidth?Math.max(W.innerWidth,document.documentElement.clientWidth):e}function K(){var e=I()||961;s=e<=782?"responsive":Q.hasClass("folded")||Q.hasClass("auto-fold")&&e<=960&&782<e?"folded":"open",$.trigger("wp-menu-state-set",{state:s})}f.on("click.wp-submenu-head",".wp-submenu-head",function(e){B(e.target).parent().siblings("a").get(0).click()}),B("#collapse-button").on("click.collapse-menu",function(){var e=I()||961;B("#adminmenu div.wp-submenu").css("margin-top",""),s=e<=960?Q.hasClass("auto-fold")?(Q.removeClass("auto-fold").removeClass("folded"),setUserSetting("unfold",1),setUserSetting("mfold","o"),"open"):(Q.addClass("auto-fold"),setUserSetting("unfold",0),"folded"):Q.hasClass("folded")?(Q.removeClass("folded"),setUserSetting("mfold","o"),"open"):(Q.addClass("folded"),setUserSetting("mfold","f"),"folded"),$.trigger("wp-collapse-menu",{state:s})}),("ontouchstart"in W||/IEMobile\/[1-9]/.test(navigator.userAgent))&&(Q.on((c=p?"touchstart":"click")+".wp-mobile-hover",function(e){f.data("wp-responsive")||B(e.target).closest("#adminmenu").length||f.find("li.opensub").removeClass("opensub")}),f.find("a.wp-has-submenu").on(c+".wp-mobile-hover",function(e){var t=B(this).parent();f.data("wp-responsive")||t.hasClass("opensub")||t.hasClass("wp-menu-open")&&!(t.width()<40)||(e.preventDefault(),M(t),f.find("li.opensub").removeClass("opensub"),t.addClass("opensub"))})),p||z||(f.find("li.wp-has-submenu").hoverIntent({over:function(){var e=B(this),t=e.find(".wp-submenu"),t=parseInt(t.css("top"),10);isNaN(t)||-5<t||f.data("wp-responsive")||(M(e),f.find("li.opensub").removeClass("opensub"),e.addClass("opensub"))},out:function(){f.data("wp-responsive")||B(this).removeClass("opensub").find(".wp-submenu").css("margin-top","")},timeout:200,sensitivity:7,interval:90}),f.on("focus.adminmenu",".wp-submenu a",function(e){f.data("wp-responsive")||B(e.target).closest("li.menu-top").addClass("opensub")}).on("blur.adminmenu",".wp-submenu a",function(e){f.data("wp-responsive")||B(e.target).closest("li.menu-top").removeClass("opensub")}).find("li.wp-has-submenu.wp-not-current-submenu").on("focusin.adminmenu",function(){M(B(this))})),T.length||(T=B(".wrap h1, .wrap h2").first()),B("div.updated, div.error, div.notice").not(".inline, .below-h2").insertAfter(T),$.on("wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error",_),screenMeta.init(),Q.on("click","tbody > tr > .check-column :checkbox",function(e){if("undefined"!=e.shiftKey){if(e.shiftKey){if(!d)return!0;n=B(d).closest("form").find(":checkbox").filter(":visible:enabled"),i=n.index(d),o=n.index(this),a=B(this).prop("checked"),0<i&&0<o&&i!=o&&(i<o?n.slice(i,o):n.slice(o,i)).prop("checked",function(){return!!B(this).closest("tr").is(":visible")&&a})}var t=B(d=this).closest("tbody").find("tr").find(":checkbox").filter(":visible:enabled").not(":checked");B(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return 0===t.length})}return!0}),Q.on("click.wp-toggle-checkboxes","thead .check-column :checkbox, tfoot .check-column :checkbox",function(e){var t=B(this),n=t.closest("table"),i=t.prop("checked"),o=e.shiftKey||t.data("wp-toggle");n.children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return!B(this).is(":hidden,:disabled")&&(o?!B(this).prop("checked"):!!i)}),n.children("thead, tfoot").filter(":visible").children().children(".check-column").find(":checkbox").prop("checked",function(){return!o&&!!i})}),D(B("#bulk-action-selector-top"),B("#doaction"),B("#bulk-action-selector-bottom"),B("#doaction2")),D(B("#new_role"),B("#changeit"),B("#new_role2"),B("#changeit2")),B("#wpbody-content").on({focusin:function(){clearTimeout(e),t=B(this).find(".row-actions"),B(".row-actions").not(this).removeClass("visible"),t.addClass("visible")},focusout:function(){e=setTimeout(function(){t.removeClass("visible")},30)}},".table-view-list .has-row-actions"),B("tbody").on("click",".toggle-row",function(){B(this).closest("tr").toggleClass("is-expanded")}),B("#default-password-nag-no").on("click",function(){return setUserSetting("default_password_nag","hide"),B("div.default-password-nag").hide(),!1}),B("#newcontent").on("keydown.wpevent_InsertTab",function(e){var t,n,i,o,a=e.target;27==e.keyCode?(e.preventDefault(),B(a).data("tab-out",!0)):9!=e.keyCode||e.ctrlKey||e.altKey||e.shiftKey||(B(a).data("tab-out")?B(a).data("tab-out",!1):(t=a.selectionStart,n=a.selectionEnd,i=a.value,document.selection?(a.focus(),document.selection.createRange().text="\t"):0<=t&&(o=this.scrollTop,a.value=i.substring(0,t).concat("\t",i.substring(n)),a.selectionStart=a.selectionEnd=t+1,this.scrollTop=o),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()))}),u.length&&u.closest("form").on("submit",function(){-1==B('select[name="action"]').val()&&u.val()==R&&u.val("1")}),B('.search-box input[type="search"], .search-box input[type="submit"]').on("mousedown",function(){B('select[name^="action"]').val("-1")}),B("#contextual-help-link, #show-settings-link").on("focus.scroll-into-view",function(e){e.target.scrollIntoViewIfNeeded&&e.target.scrollIntoViewIfNeeded(!1)}),(c=B("form.wp-upload-form")).length&&(r=c.find('input[type="submit"]'),l=c.find('input[type="file"]'),E(),l.on("change",E)),p||(H.on("scroll.pin-menu",N),$.on("tinymce-editor-init.pin-menu",function(e,t){t.on("wp-autoresize",F)})),W.wpResponsive={init:function(){var e=this;this.maybeDisableSortables=this.maybeDisableSortables.bind(this),$.on("wp-responsive-activate.wp-responsive",function(){e.activate(),e.toggleAriaHasPopup("add")}).on("wp-responsive-deactivate.wp-responsive",function(){e.deactivate(),e.toggleAriaHasPopup("remove")}),B("#wp-admin-bar-menu-toggle a").attr("aria-expanded","false"),B("#wp-admin-bar-menu-toggle").on("click.wp-responsive",function(e){e.preventDefault(),C.find(".hover").removeClass("hover"),h.toggleClass("wp-responsive-open"),h.hasClass("wp-responsive-open")?(B(this).find("a").attr("aria-expanded","true"),B("#adminmenu a:first").trigger("focus")):B(this).find("a").attr("aria-expanded","false")}),B(document).on("click",function(e){var t;h.hasClass("wp-responsive-open")&&document.hasFocus()&&(t=B.contains(B("#wp-admin-bar-menu-toggle")[0],e.target),e=B.contains(B("#adminmenuwrap")[0],e.target),t||e||B("#wp-admin-bar-menu-toggle").trigger("click.wp-responsive"))}),B(document).on("keyup",function(e){var n,i,o=B("#wp-admin-bar-menu-toggle")[0];h.hasClass("wp-responsive-open")&&(27===e.keyCode?(B(o).trigger("click.wp-responsive"),B(o).find("a").trigger("focus")):9===e.keyCode&&(n=B("#adminmenuwrap")[0],i=e.relatedTarget||document.activeElement,setTimeout(function(){var e=B.contains(o,i),t=B.contains(n,i);e||t||B(o).trigger("click.wp-responsive")},10)))}),f.on("click.wp-responsive","li.wp-has-submenu > a",function(e){var t;f.data("wp-responsive")&&(t="false"===B(this).attr("aria-expanded")?"true":"false",B(this).parent("li").toggleClass("selected"),B(this).attr("aria-expanded",t),B(this).trigger("focus"),e.preventDefault())}),e.trigger(),$.on("wp-window-resized.wp-responsive",this.trigger.bind(this)),H.on("load.wp-responsive",this.maybeDisableSortables),$.on("postbox-toggled",this.maybeDisableSortables),B("#screen-options-wrap input").on("click",this.maybeDisableSortables)},maybeDisableSortables:function(){(-1<navigator.userAgent.indexOf("AppleWebKit/")?H.width():W.innerWidth)<=782||w.find(".ui-sortable-handle:visible").length<=1&&jQuery(".columns-prefs-1 input").prop("checked")?this.disableSortables():this.enableSortables()},activate:function(){O(),Q.hasClass("auto-fold")||Q.addClass("auto-fold"),f.data("wp-responsive",1),this.disableSortables()},deactivate:function(){O(),f.removeData("wp-responsive"),this.maybeDisableSortables()},toggleAriaHasPopup:function(e){var t=f.find("[data-ariahaspopup]");"add"===e?t.each(function(){B(this).attr("aria-haspopup","menu").attr("aria-expanded","false")}):t.each(function(){B(this).removeAttr("aria-haspopup").removeAttr("aria-expanded")})},trigger:function(){var e=I();e&&(e<=782?k||($.trigger("wp-responsive-activate"),k=!0):k&&($.trigger("wp-responsive-deactivate"),k=!1),e<=480?this.enableOverlay():this.disableOverlay(),this.maybeDisableSortables())},enableOverlay:function(){0===g.length&&(g=B('<div id="wp-responsive-overlay"></div>').insertAfter("#wpcontent").hide().on("click.wp-responsive",function(){v.find(".menupop.hover").removeClass("hover"),B(this).hide()})),b.on("click.wp-responsive",function(){g.show()})},disableOverlay:function(){b.off("click.wp-responsive"),g.hide()},disableSortables:function(){if(w.length)try{w.sortable("disable"),w.find(".ui-sortable-handle").addClass("is-non-sortable")}catch(e){}},enableSortables:function(){if(w.length)try{w.sortable("enable"),w.find(".ui-sortable-handle").removeClass("is-non-sortable")}catch(e){}}},B(document).on("ajaxComplete",function(){U()}),$.on("wp-window-resized.set-menu-state",K),$.on("wp-menu-state-set wp-collapse-menu",function(e,t){var n,i=B("#collapse-button"),t="folded"===t.state?(n="false",V("Expand Main menu")):(n="true",V("Collapse Main menu"));i.attr({"aria-expanded":n,"aria-label":t})}),W.wpResponsive.init(),O(),K(),_(),U(),$.on("wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu",O),B(".wp-initial-focus").trigger("focus"),Q.on("click",".js-update-details-toggle",function(){var e=B(this).closest(".js-update-details"),t=B("#"+e.data("update-details"));t.hasClass("update-details-moved")||t.insertAfter(e).addClass("update-details-moved"),t.toggle(),B(this).attr("aria-expanded",t.is(":visible"))})}),B(function(e){var t,n;Q.hasClass("update-php")&&(t=e("a.update-from-upload-overwrite"),n=e(".update-from-upload-expired"),t.length)&&n.length&&W.setTimeout(function(){t.hide(),n.removeClass("hidden"),W.wp&&W.wp.a11y&&W.wp.a11y.speak(n.text())},714e4)}),H.on("resize.wp-fire-once",function(){W.clearTimeout(t),t=W.setTimeout(d,200)}),"-ms-user-select"in document.documentElement.style&&navigator.userAgent.match(/IEMobile\/10\.0/)&&((n=document.createElement("style")).appendChild(document.createTextNode("@-ms-viewport{width:auto!important}")),document.getElementsByTagName("head")[0].appendChild(n))}(jQuery,window),function(){var e,i={},o={};i.pauseAll=!1,!window.matchMedia||(e=window.matchMedia("(prefers-reduced-motion: reduce)"))&&!e.matches||(i.pauseAll=!0),i.freezeAnimatedPluginIcons=function(l){function e(){var e=l.width,t=l.height,n=document.createElement("canvas");if(n.width=e,n.height=t,n.className=l.className,l.closest("#update-plugins-table"))for(var i=window.getComputedStyle(l),o=0,a=i.length;o<a;o++){var s=i[o],r=i.getPropertyValue(s);n.style[s]=r}n.getContext("2d").drawImage(l,0,0,e,t),n.setAttribute("aria-hidden","true"),n.setAttribute("role","presentation"),l.parentNode.insertBefore(n,l),l.style.opacity=.01,l.style.width="0px",l.style.height="0px"}l.complete?e():l.addEventListener("load",e,!0)},o.freezeAll=function(){for(var e=document.querySelectorAll(".plugin-icon, #update-plugins-table img"),t=0;t<e.length;t++)/\.gif(?:\?|$)/i.test(e[t].src)&&i.freezeAnimatedPluginIcons(e[t])},!0===i.pauseAll&&o.freezeAll(),e=jQuery,"plugin-install"===window.pagenow&&e(document).ajaxComplete(function(e,t,n){n.data&&"string"==typeof n.data&&n.data.includes("action=search-install-plugins")&&(window.matchMedia?window.matchMedia("(prefers-reduced-motion: reduce)").matches&&o.freezeAll():!0===i.pauseAll&&o.freezeAll())})}();
\ No newline at end of file diff --git a/wp-admin/js/customize-controls.js b/wp-admin/js/customize-controls.js index 650ac8a..5ed89af 100644 --- a/wp-admin/js/customize-controls.js +++ b/wp-admin/js/customize-controls.js @@ -1799,7 +1799,7 @@ section.closeDetails(); } else { - // Escape from the inifinite scroll list. + // Escape from the infinite scroll list. section.headerContainer.find( '.customize-themes-section-title' ).focus(); } event.stopPropagation(); // Prevent section from being collapsed. @@ -1917,7 +1917,7 @@ section.contentContainer.on( 'click', '.feature-filter-toggle', function( e ) { var $themeContainer = $( '.customize-themes-full-container' ), $filterToggle = $( e.currentTarget ); - section.filtersHeight = $filterToggle.parent().next( '.filter-drawer' ).height(); + section.filtersHeight = $filterToggle.parents( '.themes-filter-bar' ).next( '.filter-drawer' ).height(); if ( 0 < $themeContainer.scrollTop() ) { $themeContainer.animate( { scrollTop: 0 }, 400 ); @@ -1932,7 +1932,7 @@ .attr( 'aria-expanded', function( i, attr ) { return 'true' === attr ? 'false' : 'true'; }) - .parent().next( '.filter-drawer' ).slideToggle( 180, 'linear' ); + .parents( '.themes-filter-bar' ).next( '.filter-drawer' ).slideToggle( 180, 'linear' ); if ( $filterToggle.hasClass( 'open' ) ) { var marginOffset = 1018 < window.innerWidth ? 50 : 76; @@ -3739,7 +3739,7 @@ ready: function() { var control = this, newItem; if ( 'dropdown-pages' === control.params.type && control.params.allow_addition ) { - newItem = control.container.find( '.new-content-item' ); + newItem = control.container.find( '.new-content-item-wrapper' ); newItem.hide(); // Hide in JS to preserve flex display when showing. control.container.on( 'click', '.add-new-toggle', function( e ) { $( e.currentTarget ).slideUp( 180 ); @@ -4085,7 +4085,7 @@ } toggle = control.container.find( '.add-new-toggle' ); - container = control.container.find( '.new-content-item' ); + container = control.container.find( '.new-content-item-wrapper' ); input = control.container.find( '.create-item-input' ); title = input.val(); select = control.container.find( 'select' ); @@ -7199,7 +7199,7 @@ } ) ); /** - * Return whether the pubish settings section should be active. + * Return whether the publish settings section should be active. * * @return {boolean} Is section active. */ diff --git a/wp-admin/js/customize-controls.min.js b/wp-admin/js/customize-controls.min.js index 3485f50..5ffb1fa 100644 --- a/wp-admin/js/customize-controls.min.js +++ b/wp-admin/js/customize-controls.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(J){var a,s,t,e,n,i,Y=wp.customize,o=window.matchMedia("(prefers-reduced-motion: reduce)"),r=o.matches;o.addEventListener("change",function(e){r=e.matches}),Y.OverlayNotification=Y.Notification.extend({loading:!1,initialize:function(e,t){var n=this;Y.Notification.prototype.initialize.call(n,e,t),n.containerClasses+=" notification-overlay",n.loading&&(n.containerClasses+=" notification-loading")},render:function(){var e=Y.Notification.prototype.render.call(this);return e.on("keydown",_.bind(this.handleEscape,this)),e},handleEscape:function(e){var t=this;27===e.which&&(e.stopPropagation(),t.dismissible)&&t.parent&&t.parent.remove(t.code)}}),Y.Notifications=Y.Values.extend({alt:!1,defaultConstructor:Y.Notification,initialize:function(e){var t=this;Y.Values.prototype.initialize.call(t,e),_.bindAll(t,"constrainFocus"),t._addedIncrement=0,t._addedOrder={},t.bind("add",function(e){t.trigger("change",e)}),t.bind("removed",function(e){t.trigger("change",e)})},count:function(){return _.size(this._value)},add:function(e,t){var n,i=this,t="string"==typeof e?(n=e,t):(n=e.code,e);return i.has(n)||(i._addedIncrement+=1,i._addedOrder[n]=i._addedIncrement),Y.Values.prototype.add.call(i,n,t)},remove:function(e){return delete this._addedOrder[e],Y.Values.prototype.remove.call(this,e)},get:function(e){var a,o=this,t=_.values(o._value);return _.extend({sort:!1},e).sort&&(a={error:4,warning:3,success:2,info:1},t.sort(function(e,t){var n=0,i=0;return(n=_.isUndefined(a[e.type])?n:a[e.type])!==(i=_.isUndefined(a[t.type])?i:a[t.type])?i-n:o._addedOrder[t.code]-o._addedOrder[e.code]})),t},render:function(){var e,t,n,i=this,a=!1,o=[],s={};i.container&&i.container.length&&(e=i.get({sort:!0}),i.container.toggle(0!==e.length),i.container.is(i.previousContainer)&&_.isEqual(e,i.previousNotifications)||((n=i.container.children("ul").first()).length||(n=J("<ul></ul>"),i.container.append(n)),n.find("> [data-code]").remove(),_.each(i.previousNotifications,function(e){s[e.code]=e}),_.each(e,function(e){var t;!wp.a11y||s[e.code]&&_.isEqual(e.message,s[e.code].message)||wp.a11y.speak(e.message,"assertive"),t=J(e.render()),e.container=t,n.append(t),e.extended(Y.OverlayNotification)&&o.push(e)}),(t=Boolean(o.length))!==(a=i.previousNotifications?Boolean(_.find(i.previousNotifications,function(e){return e.extended(Y.OverlayNotification)})):a)&&(J(document.body).toggleClass("customize-loading",t),i.container.toggleClass("has-overlay-notifications",t),t?(i.previousActiveElement=document.activeElement,J(document).on("keydown",i.constrainFocus)):J(document).off("keydown",i.constrainFocus)),t?(i.focusContainer=o[o.length-1].container,i.focusContainer.prop("tabIndex",-1),((a=i.focusContainer.find(":focusable")).length?a.first():i.focusContainer).focus()):i.previousActiveElement&&(J(i.previousActiveElement).trigger("focus"),i.previousActiveElement=null),i.previousNotifications=e,i.previousContainer=i.container,i.trigger("rendered")))},constrainFocus:function(e){var t,n=this;e.stopPropagation(),9===e.which&&(0===(t=n.focusContainer.find(":focusable")).length&&(t=n.focusContainer),!J.contains(n.focusContainer[0],e.target)||!J.contains(n.focusContainer[0],document.activeElement)||t.last().is(e.target)&&!e.shiftKey?(e.preventDefault(),t.first().focus()):t.first().is(e.target)&&e.shiftKey&&(e.preventDefault(),t.last().focus()))}}),Y.Setting=Y.Value.extend({defaults:{transport:"refresh",dirty:!1},initialize:function(e,t,n){var i=this,n=_.extend({previewer:Y.previewer},i.defaults,n||{});Y.Value.prototype.initialize.call(i,t,n),i.id=e,i._dirty=n.dirty,i.notifications=new Y.Notifications,i.bind(i.preview)},preview:function(){var e=this,t=e.transport;"postMessage"===(t="postMessage"!==t||Y.state("previewerAlive").get()?t:"refresh")?e.previewer.send("setting",[e.id,e()]):"refresh"===t&&e.previewer.refresh()},findControls:function(){var n=this,i=[];return Y.control.each(function(t){_.each(t.settings,function(e){e.id===n.id&&i.push(t)})}),i}}),Y._latestRevision=0,Y._lastSavedRevision=0,Y._latestSettingRevisions={},Y.bind("change",function(e){Y._latestRevision+=1,Y._latestSettingRevisions[e.id]=Y._latestRevision}),Y.bind("ready",function(){Y.bind("add",function(e){e._dirty&&(Y._latestRevision+=1,Y._latestSettingRevisions[e.id]=Y._latestRevision)})}),Y.dirtyValues=function(n){var i={};return Y.each(function(e){var t;e._dirty&&(t=Y._latestSettingRevisions[e.id],Y.state("changesetStatus").get()&&n&&n.unsaved&&(_.isUndefined(t)||t<=Y._lastSavedRevision)||(i[e.id]=e.get()))}),i},Y.requestChangesetUpdate=function(n,e){var t,i={},a=new J.Deferred;if(0!==Y.state("processing").get())a.reject("already_processing");else if(e=_.extend({title:null,date:null,autosave:!1,force:!1},e),n&&_.extend(i,n),_.each(Y.dirtyValues({unsaved:!0}),function(e,t){n&&null===n[t]||(i[t]=_.extend({},i[t]||{},{value:e}))}),Y.trigger("changeset-save",i,e),!e.force&&_.isEmpty(i)&&null===e.title&&null===e.date)a.resolve({});else{if(e.status)return a.reject({code:"illegal_status_in_changeset_update"}).promise();if(e.date&&e.autosave)return a.reject({code:"illegal_autosave_with_date_gmt"}).promise();Y.state("processing").set(Y.state("processing").get()+1),a.always(function(){Y.state("processing").set(Y.state("processing").get()-1)}),delete(t=Y.previewer.query({excludeCustomizedSaved:!0})).customized,_.extend(t,{nonce:Y.settings.nonce.save,customize_theme:Y.settings.theme.stylesheet,customize_changeset_data:JSON.stringify(i)}),null!==e.title&&(t.customize_changeset_title=e.title),null!==e.date&&(t.customize_changeset_date=e.date),!1!==e.autosave&&(t.customize_changeset_autosave="true"),Y.trigger("save-request-params",t),(e=wp.ajax.post("customize_save",t)).done(function(e){var n={};Y._lastSavedRevision=Math.max(Y._latestRevision,Y._lastSavedRevision),Y.state("changesetStatus").set(e.changeset_status),e.changeset_date&&Y.state("changesetDate").set(e.changeset_date),a.resolve(e),Y.trigger("changeset-saved",e),e.setting_validities&&_.each(e.setting_validities,function(e,t){!0===e&&_.isObject(i[t])&&!_.isUndefined(i[t].value)&&(n[t]=i[t].value)}),Y.previewer.send("changeset-saved",_.extend({},e,{saved_changeset_values:n}))}),e.fail(function(e){a.reject(e),Y.trigger("changeset-error",e)}),e.always(function(e){e.setting_validities&&Y._handleSettingValidities({settingValidities:e.setting_validities})})}return a.promise()},Y.utils.bubbleChildValueChanges=function(n,e){J.each(e,function(e,t){n[t].bind(function(e,t){n.parent&&e!==t&&n.parent.trigger("change",n)})})},o=function(e){var t,n,i=this,a=function(){var e;i.extended(Y.Panel)&&1<(n=i.sections()).length&&n.forEach(function(e){e.expanded()&&e.collapse()}),e=(i.extended(Y.Panel)||i.extended(Y.Section))&&i.expanded&&i.expanded()?i.contentContainer:i.container,(n=0===(n=e.find(".control-focus:first")).length?e.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first():n).focus()};(e=e||{}).completeCallback?(t=e.completeCallback,e.completeCallback=function(){a(),t()}):e.completeCallback=a,Y.state("paneVisible").set(!0),i.expand?i.expand(e):e.completeCallback()},Y.utils.prioritySort=function(e,t){return e.priority()===t.priority()&&"number"==typeof e.params.instanceNumber&&"number"==typeof t.params.instanceNumber?e.params.instanceNumber-t.params.instanceNumber:e.priority()-t.priority()},Y.utils.isKeydownButNotEnterEvent=function(e){return"keydown"===e.type&&13!==e.which},Y.utils.areElementListsEqual=function(e,t){return e.length===t.length&&-1===_.indexOf(_.map(_.zip(e,t),function(e){return J(e[0]).is(e[1])}),!1)},Y.utils.highlightButton=function(e,t){var n,i="button-see-me",a=!1;function o(){a=!0}return(n=_.extend({delay:0,focusTarget:e},t)).focusTarget.on("focusin",o),setTimeout(function(){n.focusTarget.off("focusin",o),a||(e.addClass(i),e.one("animationend",function(){e.removeClass(i)}))},n.delay),o},Y.utils.getCurrentTimestamp=function(){var e=_.now(),t=new Date(Y.settings.initialServerDate.replace(/-/g,"/")),e=e-Y.settings.initialClientTimestamp;return e+=Y.settings.initialClientTimestamp-Y.settings.initialServerTimestamp,t.setTime(t.getTime()+e),t.getTime()},Y.utils.getRemainingTime=function(e){e=e instanceof Date?e.getTime():"string"==typeof e?new Date(e.replace(/-/g,"/")).getTime():e,e-=Y.utils.getCurrentTimestamp();return Math.ceil(e/1e3)},t=document.createElement("div"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},n=_.find(_.keys(e),function(e){return!_.isUndefined(t.style[e])}),s=n?e[n]:null,a=Y.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:J.noop},defaultExpandedArguments:{duration:"fast",completeCallback:J.noop},containerType:"container",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null},initialize:function(e,t){var n=this;n.id=e,a.instanceCounter||(a.instanceCounter=0),a.instanceCounter++,J.extend(n,{params:_.defaults(t.params||t,n.defaults)}),n.params.instanceNumber||(n.params.instanceNumber=a.instanceCounter),n.notifications=new Y.Notifications,n.templateSelector=n.params.templateId||"customize-"+n.containerType+"-"+n.params.type,n.container=J(n.params.content),0===n.container.length&&(n.container=J(n.getContainer())),n.headContainer=n.container,n.contentContainer=n.getContent(),n.container=n.container.add(n.contentContainer),n.deferred={embedded:new J.Deferred},n.priority=new Y.Value,n.active=new Y.Value,n.activeArgumentsQueue=[],n.expanded=new Y.Value,n.expandedArgumentsQueue=[],n.active.bind(function(e){var t=n.activeArgumentsQueue.shift(),t=J.extend({},n.defaultActiveArguments,t);e=e&&n.isContextuallyActive(),n.onChangeActive(e,t)}),n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift(),t=J.extend({},n.defaultExpandedArguments,t);n.onChangeExpanded(e,t)}),n.deferred.embedded.done(function(){n.setupNotifications(),n.attachEvents()}),Y.utils.bubbleChildValueChanges(n,["priority","active"]),n.priority.set(n.params.priority),n.active.set(n.params.active),n.expanded.set(!1)},getNotificationsContainerElement:function(){return this.contentContainer.find(".customize-control-notifications-container:first")},setupNotifications:function(){var e,t=this;t.notifications.container=t.getNotificationsContainerElement(),t.expanded.bind(e=function(){t.expanded.get()&&t.notifications.render()}),e(),t.notifications.bind("change",_.debounce(e))},ready:function(){},_children:function(t,e){var n=this,i=[];return Y[e].each(function(e){e[t].get()===n.id&&i.push(e)}),i.sort(Y.utils.prioritySort),i},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(e,t){var n,i=this,a=i.headContainer;t.unchanged?t.completeCallback&&t.completeCallback():(n="resolved"===Y.previewer.deferred.active.state()?t.duration:0,i.extended(Y.Panel)&&(Y.panel.each(function(e){e!==i&&e.expanded()&&(n=0)}),e||_.each(i.sections(),function(e){e.collapse({duration:0})})),J.contains(document,a.get(0))?e?a.slideDown(n,t.completeCallback):i.expanded()?i.collapse({duration:n,completeCallback:function(){a.slideUp(n,t.completeCallback)}}):a.slideUp(n,t.completeCallback):(a.toggle(e),t.completeCallback&&t.completeCallback()))},_toggleActive:function(e,t){return t=t||{},e&&this.active.get()||!e&&!this.active.get()?(t.unchanged=!0,this.onChangeActive(this.active.get(),t),!1):(t.unchanged=!1,this.activeArgumentsQueue.push(t),this.active.set(e),!0)},activate:function(e){return this._toggleActive(!0,e)},deactivate:function(e){return this._toggleActive(!1,e)},onChangeExpanded:function(){throw new Error("Must override with subclass.")},_toggleExpanded:function(e,t){var n,i=this;return n=(t=t||{}).completeCallback,!(e&&!i.active()||(Y.state("paneVisible").set(!0),t.completeCallback=function(){n&&n.apply(i,arguments),e?i.container.trigger("expanded"):i.container.trigger("collapsed")},e&&i.expanded.get()||!e&&!i.expanded.get()?(t.unchanged=!0,i.onChangeExpanded(i.expanded.get(),t),1):(t.unchanged=!1,i.expandedArgumentsQueue.push(t),i.expanded.set(e),0)))},expand:function(e){return this._toggleExpanded(!0,e)},collapse:function(e){return this._toggleExpanded(!1,e)},_animateChangeExpanded:function(t){var a,o,n,i;!s||r?_.defer(function(){t&&t()}):(o=(a=this).contentContainer,i=o.closest(".wp-full-overlay").add(o),a.panel&&""!==a.panel()&&!Y.panel(a.panel()).contentContainer.hasClass("skip-transition")||(i=i.add("#customize-info, .customize-pane-parent")),n=function(e){2===e.eventPhase&&J(e.target).is(o)&&(o.off(s,n),i.removeClass("busy"),t)&&t()},o.on(s,n),i.addClass("busy"),_.defer(function(){var e=o.closest(".wp-full-overlay-sidebar-content"),t=e.scrollTop(),n=o.data("previous-scrollTop")||0,i=a.expanded();i&&0<t?(o.css("top",t+"px"),o.data("previous-scrollTop",t)):!i&&0<t+n&&(o.css("top",n-t+"px"),e.scrollTop(n))}))},focus:o,getContainer:function(){var e=this,t=0!==J("#tmpl-"+e.templateSelector).length?wp.template(e.templateSelector):wp.template("customize-"+e.containerType+"-default");return t&&e.container?t(_.extend({id:e.id},e.params)).toString().trim():"<li></li>"},getContent:function(){var e=this.container,t=e.find(".accordion-section-content, .control-panel-content").first(),n="sub-"+e.attr("id"),i=n,a=e.attr("aria-owns");return e.attr("aria-owns",i=a?i+" "+a:i),t.detach().attr({id:n,class:"customize-pane-child "+t.attr("class")+" "+e.attr("class")})}}),Y.Section=a.extend({containerType:"section",containerParent:"#customize-theme-controls",containerPaneParent:".customize-pane-parent",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null,panel:null,customizeAction:""},initialize:function(e,t){var n=this,i=t.params||t;i.type||_.find(Y.sectionConstructor,function(e,t){return e===n.constructor&&(i.type=t,!0)}),a.prototype.initialize.call(n,e,i),n.id=e,n.panel=new Y.Value,n.panel.bind(function(e){J(n.headContainer).toggleClass("control-subsection",!!e)}),n.panel.set(n.params.panel||""),Y.utils.bubbleChildValueChanges(n,["panel"]),n.embed(),n.deferred.embedded.done(function(){n.ready()})},embed:function(){var e,n=this;n.containerParent=Y.ensure(n.containerParent),n.panel.bind(e=function(e){var t;e?Y.panel(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer,n.headContainer.parent().is(t)||t.append(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve()})}):(t=Y.ensure(n.containerPaneParent),n.headContainer.parent().is(t)||t.append(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve())}),e(n.panel.get())},attachEvents:function(){var e,t,n=this;n.container.hasClass("cannot-expand")||(n.container.find(".accordion-section-title, .customize-section-back").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()?n.collapse():n.expand())}),n.container.find(".customize-section-title .customize-help-toggle").on("click",function(){(e=n.container.find(".section-meta")).hasClass("cannot-expand")||((t=e.find(".customize-section-description:first")).toggleClass("open"),t.slideToggle(n.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),J(this).attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}))}))},isContextuallyActive:function(){var e=this.controls(),t=0;return _(e).each(function(e){e.active()&&(t+=1)}),0!==t},controls:function(){return this._children("section","control")},onChangeExpanded:function(e,t){var n,i=this,a=i.headContainer.closest(".wp-full-overlay-sidebar-content"),o=i.contentContainer,s=i.headContainer.closest(".wp-full-overlay"),r=o.find(".customize-section-back"),c=i.headContainer.find(".accordion-section-title").first();e&&!o.hasClass("open")?(n=t.unchanged?t.completeCallback:function(){i._animateChangeExpanded(function(){c.attr("tabindex","-1"),r.attr("tabindex","0"),r.trigger("focus"),o.css("top",""),a.scrollTop(0),t.completeCallback&&t.completeCallback()}),o.addClass("open"),s.addClass("section-open"),Y.state("expandedSection").set(i)}.bind(this),t.allowMultiple||Y.section.each(function(e){e!==i&&e.collapse({duration:t.duration})}),i.panel()?Y.panel(i.panel()).expand({duration:t.duration,completeCallback:n}):(t.allowMultiple||Y.panel.each(function(e){e.collapse()}),n())):!e&&o.hasClass("open")?(i.panel()&&(n=Y.panel(i.panel())).contentContainer.hasClass("skip-transition")&&n.collapse(),i._animateChangeExpanded(function(){r.attr("tabindex","-1"),c.attr("tabindex","0"),c.trigger("focus"),o.css("top",""),t.completeCallback&&t.completeCallback()}),o.removeClass("open"),s.removeClass("section-open"),i===Y.state("expandedSection").get()&&Y.state("expandedSection").set(!1)):t.completeCallback&&t.completeCallback()}}),Y.ThemesSection=Y.Section.extend({currentTheme:"",overlay:"",template:"",screenshotQueue:null,$window:null,$body:null,loaded:0,loading:!1,fullyLoaded:!1,term:"",tags:"",nextTerm:"",nextTags:"",filtersHeight:0,headerContainer:null,updateCountDebounced:null,initialize:function(e,t){var n=this;n.headerContainer=J(),n.$window=J(window),n.$body=J(document.body),Y.Section.prototype.initialize.call(n,e,t),n.updateCountDebounced=_.debounce(n.updateCount,500)},embed:function(){var n=this,e=function(e){var t;Y.panel(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer,n.headContainer.parent().is(t)||t.find(".customize-themes-full-container-container").before(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve()})})};n.panel.bind(e),e(n.panel.get())},ready:function(){var t=this;t.overlay=t.container.find(".theme-overlay"),t.template=wp.template("customize-themes-details-view"),t.container.on("keydown",function(e){t.overlay.find(".theme-wrap").is(":visible")&&(39===e.keyCode&&t.nextTheme(),37===e.keyCode&&t.previousTheme(),27===e.keyCode)&&(t.$body.hasClass("modal-open")?t.closeDetails():t.headerContainer.find(".customize-themes-section-title").focus(),e.stopPropagation())}),t.renderScreenshots=_.throttle(t.renderScreenshots,100),_.bindAll(t,"renderScreenshots","loadMore","checkTerm","filtersChecked")},isContextuallyActive:function(){return this.active()},attachEvents:function(){var e,n=this;function t(){var e=n.headerContainer.find(".customize-themes-section-title");e.toggleClass("selected",n.expanded()),e.attr("aria-expanded",n.expanded()?"true":"false"),n.expanded()||e.removeClass("details-open")}n.container.find(".customize-section-back").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.collapse())}),n.headerContainer=J("#accordion-section-"+n.id),n.headerContainer.on("click",".customize-themes-section-title",function(){n.headerContainer.find(".filter-details").length&&(n.headerContainer.find(".customize-themes-section-title").toggleClass("details-open").attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}),n.headerContainer.find(".filter-details").slideToggle(180)),n.expanded()||n.expand()}),n.container.on("click",".theme-actions .preview-theme",function(){Y.panel("themes").loadThemePreview(J(this).data("slug"))}),n.container.on("click",".left",function(){n.previousTheme()}),n.container.on("click",".right",function(){n.nextTheme()}),n.container.on("click",".theme-backdrop, .close",function(){n.closeDetails()}),"local"===n.params.filter_type?n.container.on("input",".wp-filter-search-themes",function(e){n.filterSearch(e.currentTarget.value)}):"remote"===n.params.filter_type&&(e=_.debounce(n.checkTerm,500),n.contentContainer.on("input",".wp-filter-search",function(){Y.panel("themes").expanded()&&(e(n),n.expanded()||n.expand())}),n.contentContainer.on("click",".filter-group input",function(){n.filtersChecked(),n.checkTerm(n)})),n.contentContainer.on("click",".feature-filter-toggle",function(e){var t=J(".customize-themes-full-container"),e=J(e.currentTarget);n.filtersHeight=e.parent().next(".filter-drawer").height(),0<t.scrollTop()&&(t.animate({scrollTop:0},400),e.hasClass("open"))||(e.toggleClass("open").attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}).parent().next(".filter-drawer").slideToggle(180,"linear"),e.hasClass("open")?(t=1018<window.innerWidth?50:76,n.contentContainer.find(".themes").css("margin-top",n.filtersHeight+t)):n.contentContainer.find(".themes").css("margin-top",0))}),n.contentContainer.on("click",".no-themes-local .search-dotorg-themes",function(){Y.section("wporg_themes").focus()}),n.expanded.bind(t),t(),Y.bind("ready",function(){n.contentContainer=n.container.find(".customize-themes-section"),n.contentContainer.appendTo(J(".customize-themes-full-container")),n.container.add(n.headerContainer)})},onChangeExpanded:function(e,n){var i=this,t=i.contentContainer.closest(".customize-themes-full-container");function a(){0===i.loaded&&i.loadThemes(),Y.section.each(function(e){var t;e!==i&&"themes"===e.params.type&&(t=e.contentContainer.find(".wp-filter-search").val(),i.contentContainer.find(".wp-filter-search").val(t),""===t&&""!==i.term&&"local"!==i.params.filter_type?(i.term="",i.initializeNewQuery(i.term,i.tags)):"remote"===i.params.filter_type?i.checkTerm(i):"local"===i.params.filter_type&&i.filterSearch(t),e.collapse({duration:n.duration}))}),i.contentContainer.addClass("current-section"),t.scrollTop(),t.on("scroll",_.throttle(i.renderScreenshots,300)),t.on("scroll",_.throttle(i.loadMore,300)),n.completeCallback&&n.completeCallback(),i.updateCount()}n.unchanged?n.completeCallback&&n.completeCallback():e?i.panel()&&Y.panel.has(i.panel())?Y.panel(i.panel()).expand({duration:n.duration,completeCallback:a}):a():(i.contentContainer.removeClass("current-section"),i.headerContainer.find(".filter-details").slideUp(180),t.off("scroll"),n.completeCallback&&n.completeCallback())},getContent:function(){return this.container.find(".control-section-content")},loadThemes:function(){var n,e,i=this;i.loading||(n=Math.ceil(i.loaded/100)+1,e={nonce:Y.settings.nonce.switch_themes,wp_customize:"on",theme_action:i.params.action,customized_theme:Y.settings.theme.stylesheet,page:n},"remote"===i.params.filter_type&&(e.search=i.term,e.tags=i.tags),i.headContainer.closest(".wp-full-overlay").addClass("loading"),i.loading=!0,i.container.find(".no-themes").hide(),(e=wp.ajax.post("customize_load_themes",e)).done(function(e){var t=e.themes;""!==i.nextTerm||""!==i.nextTags?(i.nextTerm&&(i.term=i.nextTerm),i.nextTags&&(i.tags=i.nextTags),i.nextTerm="",i.nextTags="",i.loading=!1,i.loadThemes()):(0!==t.length?(i.loadControls(t,n),1===n&&(_.each(i.controls().slice(0,3),function(e){e=e.params.theme.screenshot[0];e&&((new Image).src=e)}),"local"!==i.params.filter_type)&&wp.a11y.speak(Y.settings.l10n.themeSearchResults.replace("%d",e.info.results)),_.delay(i.renderScreenshots,100),("local"===i.params.filter_type||t.length<100)&&(i.fullyLoaded=!0)):0===i.loaded?(i.container.find(".no-themes").show(),wp.a11y.speak(i.container.find(".no-themes").text())):i.fullyLoaded=!0,"local"===i.params.filter_type?i.updateCount():i.updateCount(e.info.results),i.container.find(".unexpected-error").hide(),i.headContainer.closest(".wp-full-overlay").removeClass("loading"),i.loading=!1)}),e.fail(function(e){void 0===e?(i.container.find(".unexpected-error").show(),wp.a11y.speak(i.container.find(".unexpected-error").text())):"undefined"!=typeof console&&console.error&&console.error(e),i.headContainer.closest(".wp-full-overlay").removeClass("loading"),i.loading=!1}))},loadControls:function(e,t){var n=[],i=this;_.each(e,function(e){e=new Y.controlConstructor.theme(i.params.action+"_theme_"+e.id,{type:"theme",section:i.params.id,theme:e,priority:i.loaded+1});Y.control.add(e),n.push(e),i.loaded=i.loaded+1}),1!==t&&Array.prototype.push.apply(i.screenshotQueue,n)},loadMore:function(){var e,t;this.fullyLoaded||this.loading||(t=(e=this.container.closest(".customize-themes-full-container")).scrollTop()+e.height(),e.prop("scrollHeight")-3e3<t&&this.loadThemes())},filterSearch:function(e){var t,n=0,i=this,a=Y.section.has("wporg_themes")&&"remote"!==i.params.filter_type?".no-themes-local":".no-themes",o=i.controls();i.loading||(t=e.toLowerCase().trim().replace(/-/g," ").split(" "),_.each(o,function(e){e.filter(t)&&(n+=1)}),0===n?(i.container.find(a).show(),wp.a11y.speak(i.container.find(a).text())):i.container.find(a).hide(),i.renderScreenshots(),Y.reflowPaneContents(),i.updateCountDebounced(n))},checkTerm:function(e){var t;"remote"===e.params.filter_type&&(t=e.contentContainer.find(".wp-filter-search").val(),e.term!==t.trim())&&e.initializeNewQuery(t,e.tags)},filtersChecked:function(){var e=this,t=e.container.find(".filter-group").find(":checkbox"),n=[];_.each(t.filter(":checked"),function(e){n.push(J(e).prop("value"))}),0===n.length?(n="",e.contentContainer.find(".feature-filter-toggle .filter-count-0").show(),e.contentContainer.find(".feature-filter-toggle .filter-count-filters").hide()):(e.contentContainer.find(".feature-filter-toggle .theme-filter-count").text(n.length),e.contentContainer.find(".feature-filter-toggle .filter-count-0").hide(),e.contentContainer.find(".feature-filter-toggle .filter-count-filters").show()),_.isEqual(e.tags,n)||(e.loading?e.nextTags=n:"remote"===e.params.filter_type?e.initializeNewQuery(e.term,n):"local"===e.params.filter_type&&e.filterSearch(n.join(" ")))},initializeNewQuery:function(e,t){var n=this;_.each(n.controls(),function(e){e.container.remove(),Y.control.remove(e.id)}),n.loaded=0,n.fullyLoaded=!1,n.screenshotQueue=null,n.loading?(n.nextTerm=e,n.nextTags=t):(n.term=e,n.tags=t,n.loadThemes()),n.expanded()||n.expand()},renderScreenshots:function(){var o=this;null!==o.screenshotQueue&&0!==o.screenshotQueue.length||(o.screenshotQueue=_.filter(o.controls(),function(e){return!e.screenshotRendered})),o.screenshotQueue.length&&(o.screenshotQueue=_.filter(o.screenshotQueue,function(e){var t,n,i=e.container.find(".theme-screenshot"),a=i.find("img");return!(!a.length||!a.is(":hidden")&&(t=(n=o.$window.scrollTop())+o.$window.height(),a=a.offset().top,(n=n-(i=3*(n=i.height()))<=a+n&&a<=t+i)&&e.container.trigger("render-screenshot"),n))}))},getVisibleCount:function(){return this.contentContainer.find("li.customize-control:visible").length},updateCount:function(e){var t,n;e||0===e||(e=this.getVisibleCount()),n=this.contentContainer.find(".themes-displayed"),t=this.contentContainer.find(".theme-count"),0===e?t.text("0"):(n.fadeOut(180,function(){t.text(e),n.fadeIn(180)}),wp.a11y.speak(Y.settings.l10n.announceThemeCount.replace("%d",e)))},nextTheme:function(){var e=this;e.getNextTheme()&&e.showDetails(e.getNextTheme(),function(){e.overlay.find(".right").focus()})},getNextTheme:function(){var e=Y.control(this.params.action+"_theme_"+this.currentTheme),t=this.controls(),e=_.indexOf(t,e);return-1!==e&&!!(t=t[e+1])&&t.params.theme},previousTheme:function(){var e=this;e.getPreviousTheme()&&e.showDetails(e.getPreviousTheme(),function(){e.overlay.find(".left").focus()})},getPreviousTheme:function(){var e=Y.control(this.params.action+"_theme_"+this.currentTheme),t=this.controls(),e=_.indexOf(t,e);return-1!==e&&!!(t=t[e-1])&&t.params.theme},updateLimits:function(){this.getNextTheme()||this.overlay.find(".right").addClass("disabled"),this.getPreviousTheme()||this.overlay.find(".left").addClass("disabled")},loadThemePreview:function(e){return Y.ThemesPanel.prototype.loadThemePreview.call(this,e)},showDetails:function(e,t){var n=this,i=Y.panel("themes");function a(){return!i.canSwitchTheme(e.id)}n.currentTheme=e.id,n.overlay.html(n.template(e)).fadeIn("fast").focus(),n.overlay.find("button.preview, button.preview-theme").toggleClass("disabled",a()),n.overlay.find("button.theme-install").toggleClass("disabled",a()||!1===Y.settings.theme._canInstall||!0===Y.settings.theme._filesystemCredentialsNeeded),n.$body.addClass("modal-open"),n.containFocus(n.overlay),n.updateLimits(),wp.a11y.speak(Y.settings.l10n.announceThemeDetails.replace("%s",e.name)),t&&t()},closeDetails:function(){this.$body.removeClass("modal-open"),this.overlay.fadeOut("fast"),Y.control(this.params.action+"_theme_"+this.currentTheme).container.find(".theme").focus()},containFocus:function(t){var n;t.on("keydown",function(e){if(9===e.keyCode)return(n=J(":tabbable",t)).last()[0]!==e.target||e.shiftKey?n.first()[0]===e.target&&e.shiftKey?(n.last().focus(),!1):void 0:(n.first().focus(),!1)})}}),Y.OuterSection=Y.Section.extend({initialize:function(){this.containerParent="#customize-outer-theme-controls",this.containerPaneParent=".customize-outer-pane-parent",Y.Section.prototype.initialize.apply(this,arguments)},onChangeExpanded:function(e,t){var n,i=this,a=i.headContainer.closest(".wp-full-overlay-sidebar-content"),o=i.contentContainer,s=o.find(".customize-section-back"),r=i.headContainer.find(".accordion-section-title").first();J(document.body).toggleClass("outer-section-open",e),i.container.toggleClass("open",e),i.container.removeClass("busy"),Y.section.each(function(e){"outer"===e.params.type&&e.id!==i.id&&e.container.removeClass("open")}),e&&!o.hasClass("open")?(n=t.unchanged?t.completeCallback:function(){i._animateChangeExpanded(function(){r.attr("tabindex","-1"),s.attr("tabindex","0"),s.trigger("focus"),o.css("top",""),a.scrollTop(0),t.completeCallback&&t.completeCallback()}),o.addClass("open")}.bind(this),i.panel()?Y.panel(i.panel()).expand({duration:t.duration,completeCallback:n}):n()):!e&&o.hasClass("open")?(i.panel()&&(n=Y.panel(i.panel())).contentContainer.hasClass("skip-transition")&&n.collapse(),i._animateChangeExpanded(function(){s.attr("tabindex","-1"),r.attr("tabindex","0"),r.trigger("focus"),o.css("top",""),t.completeCallback&&t.completeCallback()}),o.removeClass("open")):t.completeCallback&&t.completeCallback()}}),Y.Panel=a.extend({containerType:"panel",initialize:function(e,t){var n=this,i=t.params||t;i.type||_.find(Y.panelConstructor,function(e,t){return e===n.constructor&&(i.type=t,!0)}),a.prototype.initialize.call(n,e,i),n.embed(),n.deferred.embedded.done(function(){n.ready()})},embed:function(){var e=this,t=J("#customize-theme-controls"),n=J(".customize-pane-parent");e.headContainer.parent().is(n)||n.append(e.headContainer),e.contentContainer.parent().is(e.headContainer)||t.append(e.contentContainer),e.renderContent(),e.deferred.embedded.resolve()},attachEvents:function(){var t,n=this;n.headContainer.find(".accordion-section-title").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded())||n.expand()}),n.container.find(".customize-panel-back").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()&&n.collapse())}),(t=n.container.find(".panel-meta:first")).find("> .accordion-section-title .customize-help-toggle").on("click",function(){var e;t.hasClass("cannot-expand")||(e=t.find(".customize-panel-description:first"),t.hasClass("open")?(t.toggleClass("open"),e.slideUp(n.defaultExpandedArguments.duration,function(){e.trigger("toggled")}),J(this).attr("aria-expanded",!1)):(e.slideDown(n.defaultExpandedArguments.duration,function(){e.trigger("toggled")}),t.toggleClass("open"),J(this).attr("aria-expanded",!0)))})},sections:function(){return this._children("panel","section")},isContextuallyActive:function(){var e=this.sections(),t=0;return _(e).each(function(e){e.active()&&e.isContextuallyActive()&&(t+=1)}),0!==t},onChangeExpanded:function(e,t){var n,i,a,o,s,r,c;t.unchanged?t.completeCallback&&t.completeCallback():(a=(i=(n=this).contentContainer).closest(".wp-full-overlay"),o=i.closest(".wp-full-overlay-sidebar-content"),s=n.headContainer.find(".accordion-section-title"),r=i.find(".customize-panel-back"),c=n.sections(),e&&!i.hasClass("current-panel")?(Y.section.each(function(e){n.id!==e.panel()&&e.collapse({duration:0})}),Y.panel.each(function(e){n!==e&&e.collapse({duration:0})}),n.params.autoExpandSoleSection&&1===c.length&&c[0].active.get()?(i.addClass("current-panel skip-transition"),a.addClass("in-sub-panel"),c[0].expand({completeCallback:t.completeCallback})):(n._animateChangeExpanded(function(){s.attr("tabindex","-1"),r.attr("tabindex","0"),r.trigger("focus"),i.css("top",""),o.scrollTop(0),t.completeCallback&&t.completeCallback()}),i.addClass("current-panel"),a.addClass("in-sub-panel")),Y.state("expandedPanel").set(n)):!e&&i.hasClass("current-panel")&&(i.hasClass("skip-transition")?i.removeClass("skip-transition"):n._animateChangeExpanded(function(){s.attr("tabindex","0"),r.attr("tabindex","-1"),s.focus(),i.css("top",""),t.completeCallback&&t.completeCallback()}),a.removeClass("in-sub-panel"),i.removeClass("current-panel"),n===Y.state("expandedPanel").get())&&Y.state("expandedPanel").set(!1))},renderContent:function(){var e=this,t=0!==J("#tmpl-"+e.templateSelector+"-content").length?wp.template(e.templateSelector+"-content"):wp.template("customize-panel-default-content");t&&e.headContainer&&e.contentContainer.html(t(_.extend({id:e.id},e.params)))}}),Y.ThemesPanel=Y.Panel.extend({initialize:function(e,t){this.installingThemes=[],Y.Panel.prototype.initialize.call(this,e,t)},canSwitchTheme:function(e){return!(!e||e!==Y.settings.theme.stylesheet)||"publish"===Y.state("selectedChangesetStatus").get()&&(""===Y.state("changesetStatus").get()||"auto-draft"===Y.state("changesetStatus").get())},attachEvents:function(){var t=this;function e(){t.canSwitchTheme()?t.notifications.remove("theme_switch_unavailable"):t.notifications.add(new Y.Notification("theme_switch_unavailable",{message:Y.l10n.themePreviewUnavailable,type:"warning"}))}Y.Panel.prototype.attachEvents.apply(t),Y.settings.theme._canInstall&&Y.settings.theme._filesystemCredentialsNeeded&&t.notifications.add(new Y.Notification("theme_install_unavailable",{message:Y.l10n.themeInstallUnavailable,type:"info",dismissible:!0})),e(),Y.state("selectedChangesetStatus").bind(e),Y.state("changesetStatus").bind(e),t.contentContainer.on("click",".customize-theme",function(){t.collapse()}),t.contentContainer.on("click",".customize-themes-section-title, .customize-themes-mobile-back",function(){J(".wp-full-overlay").toggleClass("showing-themes")}),t.contentContainer.on("click",".theme-install",function(e){t.installTheme(e)}),t.contentContainer.on("click",".update-theme, #update-theme",function(e){e.preventDefault(),e.stopPropagation(),t.updateTheme(e)}),t.contentContainer.on("click",".delete-theme",function(e){t.deleteTheme(e)}),_.bindAll(t,"installTheme","updateTheme")},onChangeExpanded:function(e,t){var n,i=!1;Y.Panel.prototype.onChangeExpanded.apply(this,[e,t]),t.unchanged?t.completeCallback&&t.completeCallback():(n=this.headContainer.closest(".wp-full-overlay"),e?(n.addClass("in-themes-panel").delay(200).find(".customize-themes-full-container").addClass("animate"),_.delay(function(){n.addClass("themes-panel-expanded")},200),600<window.innerWidth&&(t=this.sections(),_.each(t,function(e){e.expanded()&&(i=!0)}),!i)&&0<t.length&&t[0].expand()):n.removeClass("in-themes-panel themes-panel-expanded").find(".customize-themes-full-container").removeClass("animate"))},installTheme:function(e){var t,i=this,a=J(e.target).data("slug"),o=J.Deferred(),s=J(e.target).hasClass("preview");return Y.settings.theme._filesystemCredentialsNeeded?o.reject({errorCode:"theme_install_unavailable"}):i.canSwitchTheme(a)?_.contains(i.installingThemes,a)?o.reject({errorCode:"theme_already_installing"}):(wp.updates.maybeRequestFilesystemCredentials(e),e=function(t){var e,n=!1;if(s)Y.notifications.remove("theme_installing"),i.loadThemePreview(a);else{if(Y.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t.slug&&(n=e.params.theme,e.rerenderAsInstalled(!0))}),!n||Y.control.has("installed_theme_"+n.id))return void o.resolve(t);n.type="installed",e=new Y.controlConstructor.theme("installed_theme_"+n.id,{type:"theme",section:"installed_themes",theme:n,priority:0}),Y.control.add(e),Y.control(e.id).container.trigger("render-screenshot"),Y.section.each(function(e){"themes"===e.params.type&&n.id===e.currentTheme&&e.closeDetails()})}o.resolve(t)},i.installingThemes.push(a),t=wp.updates.installTheme({slug:a}),s&&Y.notifications.add(new Y.OverlayNotification("theme_installing",{message:Y.l10n.themeDownloading,type:"info",loading:!0})),t.done(e),t.fail(function(){Y.notifications.remove("theme_installing")})):o.reject({errorCode:"theme_switch_unavailable"}),o.promise()},loadThemePreview:function(e){var t,n,i=J.Deferred();return this.canSwitchTheme(e)?((n=document.createElement("a")).href=location.href,e=_.extend(Y.utils.parseQueryString(n.search.substr(1)),{theme:e,changeset_uuid:Y.settings.changeset.uuid,return:Y.settings.url.return}),Y.state("saved").get()||(e.customize_autosaved="on"),n.search=J.param(e),Y.notifications.add(new Y.OverlayNotification("theme_previewing",{message:Y.l10n.themePreviewWait,type:"info",loading:!0})),t=function(){var e;0<Y.state("processing").get()||(Y.state("processing").unbind(t),(e=Y.requestChangesetUpdate({},{autosave:!0})).done(function(){i.resolve(),J(window).off("beforeunload.customize-confirm"),location.replace(n.href)}),e.fail(function(){Y.notifications.remove("theme_previewing"),i.reject()}))},0===Y.state("processing").get()?t():Y.state("processing").bind(t)):i.reject({errorCode:"theme_switch_unavailable"}),i.promise()},updateTheme:function(e){wp.updates.maybeRequestFilesystemCredentials(e),J(document).one("wp-theme-update-success",function(e,t){Y.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t.slug&&(e.params.theme.hasUpdate=!1,e.params.theme.version=t.newVersion,setTimeout(function(){e.rerenderAsInstalled(!0)},2e3))})}),wp.updates.updateTheme({slug:J(e.target).closest(".notice").data("slug")})},deleteTheme:function(e){var t=J(e.target).data("slug"),n=Y.section("installed_themes");e.preventDefault(),Y.settings.theme._filesystemCredentialsNeeded||window.confirm(Y.settings.l10n.confirmDeleteTheme)&&(wp.updates.maybeRequestFilesystemCredentials(e),J(document).one("wp-theme-delete-success",function(){var e=Y.control("installed_theme_"+t);e.container.remove(),Y.control.remove(e.id),n.loaded=n.loaded-1,n.updateCount(),Y.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t&&e.rerenderAsInstalled(!1)})}),wp.updates.deleteTheme({slug:t}),n.closeDetails(),n.focus())}}),Y.Control=Y.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:J.noop},defaults:{label:"",description:"",active:!0,priority:10},initialize:function(e,t){var n,i=this,a=[];i.params=_.extend({},i.defaults,i.params||{},t.params||t||{}),Y.Control.instanceCounter||(Y.Control.instanceCounter=0),Y.Control.instanceCounter++,i.params.instanceNumber||(i.params.instanceNumber=Y.Control.instanceCounter),i.params.type||_.find(Y.controlConstructor,function(e,t){return e===i.constructor&&(i.params.type=t,!0)}),i.params.content||(i.params.content=J("<li></li>",{id:"customize-control-"+e.replace(/]/g,"").replace(/\[/g,"-"),class:"customize-control customize-control-"+i.params.type})),i.id=e,i.selector="#customize-control-"+e.replace(/\]/g,"").replace(/\[/g,"-"),i.params.content?i.container=J(i.params.content):i.container=J(i.selector),i.params.templateId?i.templateSelector=i.params.templateId:i.templateSelector="customize-control-"+i.params.type+"-content",i.deferred=_.extend(i.deferred||{},{embedded:new J.Deferred}),i.section=new Y.Value,i.priority=new Y.Value,i.active=new Y.Value,i.activeArgumentsQueue=[],i.notifications=new Y.Notifications({alt:i.altNotice}),i.elements=[],i.active.bind(function(e){var t=i.activeArgumentsQueue.shift(),t=J.extend({},i.defaultActiveArguments,t);i.onChangeActive(e,t)}),i.section.set(i.params.section),i.priority.set(isNaN(i.params.priority)?10:i.params.priority),i.active.set(i.params.active),Y.utils.bubbleChildValueChanges(i,["section","priority","active"]),i.settings={},n={},i.params.setting&&(n.default=i.params.setting),_.extend(n,i.params.settings),_.each(n,function(e,t){var n;_.isObject(e)&&_.isFunction(e.extended)&&e.extended(Y.Value)?i.settings[t]=e:_.isString(e)&&((n=Y(e))?i.settings[t]=n:a.push(e))}),t=function(){_.each(n,function(e,t){!i.settings[t]&&_.isString(e)&&(i.settings[t]=Y(e))}),i.settings[0]&&!i.settings.default&&(i.settings.default=i.settings[0]),i.setting=i.settings.default||null,i.linkElements(),i.embed()},0===a.length?t():Y.apply(Y,a.concat(t)),i.deferred.embedded.done(function(){i.linkElements(),i.setupNotifications(),i.ready()})},linkElements:function(){var i,a=this,o=a.container.find("[data-customize-setting-link], [data-customize-setting-key-link]"),s={};o.each(function(){var e,t,n=J(this);if(!n.data("customizeSettingLinked")){if(n.data("customizeSettingLinked",!0),n.is(":radio")){if(e=n.prop("name"),s[e])return;s[e]=!0,n=o.filter('[name="'+e+'"]')}n.data("customizeSettingLink")?t=Y(n.data("customizeSettingLink")):n.data("customizeSettingKeyLink")&&(t=a.settings[n.data("customizeSettingKeyLink")]),t&&(i=new Y.Element(n),a.elements.push(i),i.sync(t),i.set(t()))}})},embed:function(){var n=this,e=function(e){var t;e&&Y.section(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),n.container.parent().is(t)||t.append(n.container),n.renderContent(),n.deferred.embedded.resolve()})})};n.section.bind(e),e(n.section.get())},ready:function(){var t,n=this;"dropdown-pages"===n.params.type&&n.params.allow_addition&&((t=n.container.find(".new-content-item")).hide(),n.container.on("click",".add-new-toggle",function(e){J(e.currentTarget).slideUp(180),t.slideDown(180),t.find(".create-item-input").focus()}),n.container.on("click",".add-content",function(){n.addNewPage()}),n.container.on("keydown",".create-item-input",function(e){13===e.which&&n.addNewPage()}))},getNotificationsContainerElement:function(){var e,t=this,n=t.container.find(".customize-control-notifications-container:first");return n.length||(n=J('<div class="customize-control-notifications-container"></div>'),t.container.hasClass("customize-control-nav_menu_item")?t.container.find(".menu-item-settings:first").prepend(n):t.container.hasClass("customize-control-widget_form")?t.container.find(".widget-inside:first").prepend(n):(e=t.container.find(".customize-control-title")).length?e.after(n):t.container.prepend(n)),n},setupNotifications:function(){var n,e,i=this;_.each(i.settings,function(n){n.notifications&&(n.notifications.bind("add",function(e){var t=_.extend({},e,{setting:n.id});i.notifications.add(new Y.Notification(n.id+":"+e.code,t))}),n.notifications.bind("remove",function(e){i.notifications.remove(n.id+":"+e.code)}))}),n=function(){var e=i.section();(!e||Y.section.has(e)&&Y.section(e).expanded())&&i.notifications.render()},i.notifications.bind("rendered",function(){var e=i.notifications.get();i.container.toggleClass("has-notifications",0!==e.length),i.container.toggleClass("has-error",0!==_.where(e,{type:"error"}).length)}),i.section.bind(e=function(e,t){t&&Y.section.has(t)&&Y.section(t).expanded.unbind(n),e&&Y.section(e,function(e){e.expanded.bind(n),n()})}),e(i.section.get()),i.notifications.bind("change",_.debounce(n))},renderNotifications:function(){var e,t,n=this,i=!1;"undefined"!=typeof console&&console.warn&&console.warn("[DEPRECATED] wp.customize.Control.prototype.renderNotifications() is deprecated in favor of instantiating a wp.customize.Notifications and calling its render() method."),(e=n.getNotificationsContainerElement())&&e.length&&(t=[],n.notifications.each(function(e){t.push(e),"error"===e.type&&(i=!0)}),0===t.length?e.stop().slideUp("fast"):e.stop().slideDown("fast",null,function(){J(this).css("height","auto")}),n.notificationsTemplate||(n.notificationsTemplate=wp.template("customize-control-notifications")),n.container.toggleClass("has-notifications",0!==t.length),n.container.toggleClass("has-error",i),e.empty().append(n.notificationsTemplate({notifications:t,altNotice:Boolean(n.altNotice)}).trim()))},expand:function(e){Y.section(this.section()).expand(e)},focus:o,onChangeActive:function(e,t){t.unchanged?t.completeCallback&&t.completeCallback():J.contains(document,this.container[0])?e?this.container.slideDown(t.duration,t.completeCallback):this.container.slideUp(t.duration,t.completeCallback):(this.container.toggle(e),t.completeCallback&&t.completeCallback())},toggle:function(e){return this.onChangeActive(e,this.defaultActiveArguments)},activate:a.prototype.activate,deactivate:a.prototype.deactivate,_toggleActive:a.prototype._toggleActive,dropdownInit:function(){function e(e){"string"==typeof e&&i.statuses&&i.statuses[e]?n.html(i.statuses[e]).show():n.hide()}var t=this,n=this.container.find(".dropdown-status"),i=this.params,a=!1;this.container.on("click keydown",".dropdown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),a||t.container.toggleClass("open"),t.container.hasClass("open")&&t.container.parent().parent().find("li.library-selected").focus(),a=!0,setTimeout(function(){a=!1},400))}),this.setting.bind(e),e(this.setting())},renderContent:function(){var e=this,t=e.templateSelector;t==="customize-control-"+e.params.type+"-content"&&_.contains(["button","checkbox","date","datetime-local","email","month","number","password","radio","range","search","select","tel","time","text","textarea","week","url"],e.params.type)&&!document.getElementById("tmpl-"+t)&&0===e.container.children().length&&(t="customize-control-default-content"),document.getElementById("tmpl-"+t)&&(t=wp.template(t))&&e.container&&e.container.html(t(e.params)),e.notifications.container=e.getNotificationsContainerElement(),(!(t=e.section())||Y.section.has(t)&&Y.section(t).expanded())&&e.notifications.render()},addNewPage:function(){var e,a,o,t,s,r,c=this;"dropdown-pages"===c.params.type&&c.params.allow_addition&&Y.Menus&&(a=c.container.find(".add-new-toggle"),o=c.container.find(".new-content-item"),t=c.container.find(".create-item-input"),s=t.val(),r=c.container.find("select"),s?(t.removeClass("invalid"),t.attr("disabled","disabled"),(e=Y.Menus.insertAutoDraftPost({post_title:s,post_type:"page"})).done(function(e){var t,n,i=new Y.Menus.AvailableItemModel({id:"post-"+e.post_id,title:s,type:"post_type",type_label:Y.Menus.data.l10n.page_label,object:"page",object_id:e.post_id,url:e.url});Y.Menus.availableMenuItemsPanel.collection.add(i),t=J("#available-menu-items-post_type-page").find(".available-menu-items-list"),n=wp.template("available-menu-item"),t.prepend(n(i.attributes)),r.focus(),c.setting.set(String(e.post_id)),o.slideUp(180),a.slideDown(180)}),e.always(function(){t.val("").removeAttr("disabled")})):t.addClass("invalid"))}}),Y.ColorControl=Y.Control.extend({ready:function(){var t,n=this,e="hue"===this.params.mode,i=!1;e?(t=this.container.find(".color-picker-hue")).val(n.setting()).wpColorPicker({change:function(e,t){i=!0,n.setting(t.color.h()),i=!1}}):(t=this.container.find(".color-picker-hex")).val(n.setting()).wpColorPicker({change:function(){i=!0,n.setting.set(t.wpColorPicker("color")),i=!1},clear:function(){i=!0,n.setting.set(""),i=!1}}),n.setting.bind(function(e){i||(t.val(e),t.wpColorPicker("color",e))}),n.container.on("keydown",function(e){27===e.which&&n.container.find(".wp-picker-container").hasClass("wp-picker-active")&&(t.wpColorPicker("close"),n.container.find(".wp-color-result").focus(),e.stopPropagation())})}}),Y.MediaControl=Y.Control.extend({ready:function(){var n=this;function e(e){var t=J.Deferred();n.extended(Y.UploadControl)?t.resolve():(e=parseInt(e,10),_.isNaN(e)||e<=0?(delete n.params.attachment,t.resolve()):n.params.attachment&&n.params.attachment.id===e&&t.resolve()),"pending"===t.state()&&wp.media.attachment(e).fetch().done(function(){n.params.attachment=this.attributes,t.resolve(),wp.customize.previewer.send(n.setting.id+"-attachment-data",this.attributes)}),t.done(function(){n.renderContent()})}_.bindAll(n,"restoreDefault","removeFile","openFrame","select","pausePlayer"),n.container.on("click keydown",".upload-button",n.openFrame),n.container.on("click keydown",".upload-button",n.pausePlayer),n.container.on("click keydown",".thumbnail-image img",n.openFrame),n.container.on("click keydown",".default-button",n.restoreDefault),n.container.on("click keydown",".remove-button",n.pausePlayer),n.container.on("click keydown",".remove-button",n.removeFile),n.container.on("click keydown",".remove-button",n.cleanupPlayer),Y.section(n.section()).container.on("expanded",function(){n.player&&n.player.setControlsSize()}).on("collapsed",function(){n.pausePlayer()}),e(n.setting()),n.setting.bind(e)},pausePlayer:function(){this.player&&this.player.pause()},cleanupPlayer:function(){this.player&&wp.media.mixin.removePlayer(this.player)},openFrame:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.frame||this.initFrame(),this.frame.open())},initFrame:function(){this.frame=wp.media({button:{text:this.params.button_labels.frame_button},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:this.params.mime_type}),multiple:!1,date:!1})]}),this.frame.on("select",this.select)},select:function(){var e=this.frame.state().get("selection").first().toJSON(),t=window._wpmejsSettings||{};this.params.attachment=e,this.setting(e.id),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,t):this.cleanupPlayer()},restoreDefault:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment=this.params.defaultAttachment,this.setting(this.params.defaultAttachment.url))},removeFile:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent())}}),Y.UploadControl=Y.MediaControl.extend({select:function(){var e=this.frame.state().get("selection").first().toJSON(),t=window._wpmejsSettings||{};this.params.attachment=e,this.setting(e.url),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,t):this.cleanupPlayer()},success:function(){},removerVisibility:function(){}}),Y.ImageControl=Y.UploadControl.extend({thumbnailSrc:function(){}}),Y.BackgroundControl=Y.UploadControl.extend({ready:function(){Y.UploadControl.prototype.ready.apply(this,arguments)},select:function(){Y.UploadControl.prototype.select.apply(this,arguments),wp.ajax.post("custom-background-add",{nonce:_wpCustomizeBackground.nonces.add,wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,attachment_id:this.params.attachment.id})}}),Y.BackgroundPositionControl=Y.Control.extend({ready:function(){var e,n=this;n.container.on("change",'input[name="background-position"]',function(){var e=J(this).val().split(" ");n.settings.x(e[0]),n.settings.y(e[1])}),e=_.debounce(function(){var e=n.settings.x.get(),t=n.settings.y.get(),e=String(e)+" "+String(t);n.container.find('input[name="background-position"][value="'+e+'"]').trigger("click")}),n.settings.x.bind(e),n.settings.y.bind(e),e()}}),Y.CroppedImageControl=Y.MediaControl.extend({openFrame:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(this.initFrame(),this.frame.setState("library").open())},initFrame:function(){var e=_wpMediaViewsL10n;this.frame=wp.media({button:{text:e.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.CustomizeImageCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var e=this.frame.state().get("selection").first().toJSON();this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):(this.setImageFromAttachment(e),this.frame.close())},onCropped:function(e){this.setImageFromAttachment(e)},calculateImageSelectOptions:function(e,t){var n=t.get("control"),i=!!parseInt(n.params.flex_width,10),a=!!parseInt(n.params.flex_height,10),o=e.get("width"),e=e.get("height"),s=parseInt(n.params.width,10),r=parseInt(n.params.height,10),c=s/r,l=s,d=r;return t.set("canSkipCrop",!n.mustBeCropped(i,a,s,r,o,e)),c<o/e?s=(r=e)*c:r=(s=o)/c,!(c={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:o,imageHeight:e,minWidth:s<l?s:l,minHeight:r<d?r:d,x1:t=(o-s)/2,y1:n=(e-r)/2,x2:s+t,y2:r+n})==a&&!1==i&&(c.aspectRatio=s+":"+r),!0==a&&(delete c.minHeight,c.maxWidth=o),!0==i&&(delete c.minWidth,c.maxHeight=e),c},mustBeCropped:function(e,t,n,i,a,o){return(!0!==e||!0!==t)&&!(!0===e&&i===o||!0===t&&n===a||n===a&&i===o||a<=n)},onSkippedCrop:function(){var e=this.frame.state().get("selection").first().toJSON();this.setImageFromAttachment(e)},setImageFromAttachment:function(e){this.params.attachment=e,this.setting(e.id)}}),Y.SiteIconControl=Y.CroppedImageControl.extend({initFrame:function(){var e=_wpMediaViewsL10n;this.frame=wp.media({button:{text:e.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.SiteIconCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var e=this.frame.state().get("selection").first().toJSON(),t=this;this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):wp.ajax.post("crop-image",{nonce:e.nonces.edit,id:e.id,context:"site-icon",cropDetails:{x1:0,y1:0,width:this.params.width,height:this.params.height,dst_width:this.params.width,dst_height:this.params.height}}).done(function(e){t.setImageFromAttachment(e),t.frame.close()}).fail(function(){t.frame.trigger("content:error:crop")})},setImageFromAttachment:function(t){var n;_.each(["site_icon-32","thumbnail","full"],function(e){n||_.isUndefined(t.sizes[e])||(n=t.sizes[e])}),this.params.attachment=t,this.setting(t.id),n&&J('link[rel="icon"][sizes="32x32"]').attr("href",n.url)},removeFile:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent(),J('link[rel="icon"][sizes="32x32"]').attr("href","/favicon.ico"))}}),Y.HeaderControl=Y.Control.extend({ready:function(){this.btnRemove=J("#customize-control-header_image .actions .remove"),this.btnNew=J("#customize-control-header_image .actions .new"),_.bindAll(this,"openMedia","removeImage"),this.btnNew.on("click",this.openMedia),this.btnRemove.on("click",this.removeImage),Y.HeaderTool.currentHeader=this.getInitialHeaderImage(),new Y.HeaderTool.CurrentView({model:Y.HeaderTool.currentHeader,el:"#customize-control-header_image .current .container"}),new Y.HeaderTool.ChoiceListView({collection:Y.HeaderTool.UploadsList=new Y.HeaderTool.ChoiceList,el:"#customize-control-header_image .choices .uploaded .list"}),new Y.HeaderTool.ChoiceListView({collection:Y.HeaderTool.DefaultsList=new Y.HeaderTool.DefaultsList,el:"#customize-control-header_image .choices .default .list"}),Y.HeaderTool.combinedList=Y.HeaderTool.CombinedList=new Y.HeaderTool.CombinedList([Y.HeaderTool.UploadsList,Y.HeaderTool.DefaultsList]),wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize="on",wp.media.controller.Cropper.prototype.defaults.doCropArgs.customize_theme=Y.settings.theme.stylesheet},getInitialHeaderImage:function(){var e;return Y.get().header_image&&Y.get().header_image_data&&!_.contains(["remove-header","random-default-image","random-uploaded-image"],Y.get().header_image)?(e=(e=_.find(_wpCustomizeHeader.uploads,function(e){return e.attachment_id===Y.get().header_image_data.attachment_id}))||{url:Y.get().header_image,thumbnail_url:Y.get().header_image,attachment_id:Y.get().header_image_data.attachment_id},new Y.HeaderTool.ImageModel({header:e,choice:e.url.split("/").pop()})):new Y.HeaderTool.ImageModel},calculateImageSelectOptions:function(e,t){var n=parseInt(_wpCustomizeHeader.data.width,10),i=parseInt(_wpCustomizeHeader.data.height,10),a=!!parseInt(_wpCustomizeHeader.data["flex-width"],10),o=!!parseInt(_wpCustomizeHeader.data["flex-height"],10),s=e.get("width"),e=e.get("height");return this.headerImage=new Y.HeaderTool.ImageModel,this.headerImage.set({themeWidth:n,themeHeight:i,themeFlexWidth:a,themeFlexHeight:o,imageWidth:s,imageHeight:e}),t.set("canSkipCrop",!this.headerImage.shouldBeCropped()),(t=n/i)<s/e?n=(i=e)*t:i=(n=s)/t,!(t={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:s,imageHeight:e,x1:0,y1:0,x2:n,y2:i})==o&&!1==a&&(t.aspectRatio=n+":"+i),!1==o&&(t.maxHeight=i),!1==a&&(t.maxWidth=n),t},openMedia:function(e){var t=_wpMediaViewsL10n;e.preventDefault(),this.frame=wp.media({button:{text:t.selectAndCrop,close:!1},states:[new wp.media.controller.Library({title:t.chooseImage,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:_wpCustomizeHeader.data.width,suggestedHeight:_wpCustomizeHeader.data.height}),new wp.media.controller.Cropper({imgSelectOptions:this.calculateImageSelectOptions})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this),this.frame.open()},onSelect:function(){this.frame.setState("cropper")},onCropped:function(e){var t=e.url,n=e.attachment_id,i=e.width,e=e.height;this.setImageFromURL(t,n,i,e)},onSkippedCrop:function(e){var t=e.get("url"),n=e.get("width"),i=e.get("height");this.setImageFromURL(t,e.id,n,i)},setImageFromURL:function(e,t,n,i){var a={};a.url=e,a.thumbnail_url=e,a.timestamp=_.now(),t&&(a.attachment_id=t),n&&(a.width=n),i&&(a.height=i),t=new Y.HeaderTool.ImageModel({header:a,choice:e.split("/").pop()}),Y.HeaderTool.UploadsList.add(t),Y.HeaderTool.currentHeader.set(t.toJSON()),t.save(),t.importImage()},removeImage:function(){Y.HeaderTool.currentHeader.trigger("hide"),Y.HeaderTool.CombinedList.trigger("control:removeImage")}}),Y.ThemeControl=Y.Control.extend({touchDrag:!1,screenshotRendered:!1,ready:function(){var n=this,e=Y.panel("themes");function t(){return!e.canSwitchTheme(n.params.theme.id)}function i(){n.container.find("button.preview, button.preview-theme").toggleClass("disabled",t()),n.container.find("button.theme-install").toggleClass("disabled",t()||!1===Y.settings.theme._canInstall||!0===Y.settings.theme._filesystemCredentialsNeeded)}Y.state("selectedChangesetStatus").bind(i),Y.state("changesetStatus").bind(i),i(),n.container.on("touchmove",".theme",function(){n.touchDrag=!0}),n.container.on("click keydown touchend",".theme",function(e){var t;if(!Y.utils.isKeydownButNotEnterEvent(e))return!0===n.touchDrag?n.touchDrag=!1:void(J(e.target).is(".theme-actions .button, .update-theme")||(e.preventDefault(),(t=Y.section(n.section())).showDetails(n.params.theme,function(){Y.settings.theme._filesystemCredentialsNeeded&&t.overlay.find(".theme-actions .delete-theme").remove()})))}),n.container.on("render-screenshot",function(){var e=J(this).find("img"),t=e.data("src");t&&e.attr("src",t),n.screenshotRendered=!0})},filter:function(e){var t=this,n=0,i=(i=t.params.theme.name+" "+t.params.theme.description+" "+t.params.theme.tags+" "+t.params.theme.author+" ").toLowerCase().replace("-"," ");return _.isArray(e)||(e=[e]),t.params.theme.name.toLowerCase()===e.join(" ")?n=100:(n+=10*(i.split(e.join(" ")).length-1),_.each(e,function(e){n=(n+=2*(i.split(e+" ").length-1))+i.split(e).length-1}),99<n&&(n=99)),0!==n?(t.activate(),t.params.priority=101-n,!0):(t.deactivate(),!(t.params.priority=101))},rerenderAsInstalled:function(e){var t=this;e?t.params.theme.type="installed":(e=Y.section(t.params.section),t.params.theme.type=e.params.action),t.renderContent(),t.container.trigger("render-screenshot")}}),Y.CodeEditorControl=Y.Control.extend({initialize:function(e,t){var n=this;n.deferred=_.extend(n.deferred||{},{codemirror:J.Deferred()}),Y.Control.prototype.initialize.call(n,e,t),n.notifications.bind("add",function(e){var t;e.code===n.setting.id+":csslint_error"&&(e.templateId="customize-code-editor-lint-error-notification",e.render=(t=e.render,function(){var e=t.call(this);return e.find("input[type=checkbox]").on("click",function(){n.setting.notifications.remove("csslint_error")}),e}))})},ready:function(){var i=this;i.section()?Y.section(i.section(),function(n){n.deferred.embedded.done(function(){var t;n.expanded()?i.initEditor():n.expanded.bind(t=function(e){e&&(i.initEditor(),n.expanded.unbind(t))})})}):i.initEditor()},initEditor:function(){var e,t=this,n=!1;wp.codeEditor&&(_.isUndefined(t.params.editor_settings)||!1!==t.params.editor_settings)&&((n=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{}).codemirror=_.extend({},n.codemirror,{indentUnit:2,tabSize:2}),_.isObject(t.params.editor_settings))&&_.each(t.params.editor_settings,function(e,t){_.isObject(e)&&(n[t]=_.extend({},n[t],e))}),e=new Y.Element(t.container.find("textarea")),t.elements.push(e),e.sync(t.setting),e.set(t.setting()),n?t.initSyntaxHighlightingEditor(n):t.initPlainTextareaEditor()},focus:function(e){var t=this,e=_.extend({},e),n=e.completeCallback;e.completeCallback=function(){n&&n(),t.editor&&t.editor.codemirror.focus()},Y.Control.prototype.focus.call(t,e)},initSyntaxHighlightingEditor:function(e){var t=this,n=t.container.find("textarea"),i=!1,e=_.extend({},e,{onTabNext:_.bind(t.onTabNext,t),onTabPrevious:_.bind(t.onTabPrevious,t),onUpdateErrorNotice:_.bind(t.onUpdateErrorNotice,t)});t.editor=wp.codeEditor.initialize(n,e),J(t.editor.codemirror.display.lineDiv).attr({role:"textbox","aria-multiline":"true","aria-label":t.params.label,"aria-describedby":"editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"}),t.container.find("label").on("click",function(){t.editor.codemirror.focus()}),t.editor.codemirror.on("change",function(e){i=!0,n.val(e.getValue()).trigger("change"),i=!1}),t.setting.bind(function(e){i||t.editor.codemirror.setValue(e)}),t.editor.codemirror.on("keydown",function(e,t){27===t.keyCode&&t.stopPropagation()}),t.deferred.codemirror.resolveWith(t,[t.editor.codemirror])},onTabNext:function(){var e=Y.section(this.section()).controls(),t=e.indexOf(this);e.length===t+1?J("#customize-footer-actions .collapse-sidebar").trigger("focus"):e[t+1].container.find(":focusable:first").focus()},onTabPrevious:function(){var e=Y.section(this.section()),t=e.controls(),n=t.indexOf(this);(0===n?e.contentContainer.find(".customize-section-title .customize-help-toggle, .customize-section-title .customize-section-description.open .section-description-close").last():t[n-1].contentContainer.find(":focusable:first")).focus()},onUpdateErrorNotice:function(e){this.setting.notifications.remove("csslint_error"),0!==e.length&&(e=1===e.length?Y.l10n.customCssError.singular.replace("%d","1"):Y.l10n.customCssError.plural.replace("%d",String(e.length)),this.setting.notifications.add(new Y.Notification("csslint_error",{message:e,type:"error"})))},initPlainTextareaEditor:function(){var a=this.container.find("textarea"),o=a[0];a.on("blur",function(){a.data("next-tab-blurs",!1)}),a.on("keydown",function(e){var t,n,i;27===e.keyCode?a.data("next-tab-blurs")||(a.data("next-tab-blurs",!0),e.stopPropagation()):9!==e.keyCode||e.ctrlKey||e.altKey||e.shiftKey||a.data("next-tab-blurs")||(t=o.selectionStart,n=o.selectionEnd,i=o.value,0<=t&&(o.value=i.substring(0,t).concat("\t",i.substring(n)),a.selectionStart=o.selectionEnd=t+1),e.stopPropagation(),e.preventDefault())}),this.deferred.codemirror.rejectWith(this)}}),Y.DateTimeControl=Y.Control.extend({ready:function(){var i=this;if(i.inputElements={},i.invalidDate=!1,_.bindAll(i,"populateSetting","updateDaysForMonth","populateDateInputs"),!i.setting)throw new Error("Missing setting");i.container.find(".date-input").each(function(){var e=J(this),t=e.data("component"),n=new Y.Element(e);i.inputElements[t]=n,i.elements.push(n),e.on("change",function(){i.invalidDate&&i.notifications.add(new Y.Notification("invalid_date",{message:Y.l10n.invalidDate}))}),e.on("input",_.debounce(function(){i.invalidDate||i.notifications.remove("invalid_date")})),e.on("blur",_.debounce(function(){i.invalidDate||i.populateDateInputs()}))}),i.inputElements.month.bind(i.updateDaysForMonth),i.inputElements.year.bind(i.updateDaysForMonth),i.populateDateInputs(),i.setting.bind(i.populateDateInputs),_.each(i.inputElements,function(e){e.bind(i.populateSetting)})},parseDateTime:function(e){var t;return(t=e?e.match(/^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/):t)?(t.shift(),e={year:t.shift(),month:t.shift(),day:t.shift(),hour:t.shift()||"00",minute:t.shift()||"00",second:t.shift()||"00"},this.params.includeTime&&this.params.twelveHourFormat&&(e.hour=parseInt(e.hour,10),e.meridian=12<=e.hour?"pm":"am",e.hour=e.hour%12?String(e.hour%12):String(12),delete e.second),e):null},validateInputs:function(){var e,i,a=this;return a.invalidDate=!1,e=["year","day"],a.params.includeTime&&e.push("hour","minute"),_.find(e,function(e){var t,n,e=a.inputElements[e];return i=e.element.get(0),t=parseInt(e.element.attr("max"),10),n=parseInt(e.element.attr("min"),10),e=parseInt(e(),10),a.invalidDate=isNaN(e)||t<e||e<n,a.invalidDate||i.setCustomValidity(""),a.invalidDate}),a.inputElements.meridian&&!a.invalidDate&&(i=a.inputElements.meridian.element.get(0),"am"!==a.inputElements.meridian.get()&&"pm"!==a.inputElements.meridian.get()?a.invalidDate=!0:i.setCustomValidity("")),a.invalidDate?i.setCustomValidity(Y.l10n.invalidValue):i.setCustomValidity(""),(!a.section()||Y.section.has(a.section())&&Y.section(a.section()).expanded())&&_.result(i,"reportValidity"),a.invalidDate},updateDaysForMonth:function(){var e=this,t=parseInt(e.inputElements.month(),10),n=parseInt(e.inputElements.year(),10),i=parseInt(e.inputElements.day(),10);t&&n&&(n=new Date(n,t,0).getDate(),e.inputElements.day.element.attr("max",n),n<i)&&e.inputElements.day(String(n))},populateSetting:function(){var e,t=this;return!(t.validateInputs()||!t.params.allowPastDate&&!t.isFutureDate()||(e=t.convertInputDateToString(),t.setting.set(e),0))},convertInputDateToString:function(){var e,n=this,t="",i=function(e,t){return String(e).length<t&&(t=t-String(e).length,e=Math.pow(10,t).toString().substr(1)+String(e)),e},a=function(e){var t=parseInt(n.inputElements[e].get(),10);return _.contains(["month","day","hour","minute"],e)?t=i(t,2):"year"===e&&(t=i(t,4)),t},o=["year","-","month","-","day"];return n.params.includeTime&&(e=n.inputElements.meridian?n.convertHourToTwentyFourHourFormat(n.inputElements.hour(),n.inputElements.meridian()):n.inputElements.hour(),o=o.concat([" ",i(e,2),":","minute",":","00"])),_.each(o,function(e){t+=n.inputElements[e]?a(e):e}),t},isFutureDate:function(){return 0<Y.utils.getRemainingTime(this.convertInputDateToString())},convertHourToTwentyFourHourFormat:function(e,t){e=parseInt(e,10);return isNaN(e)?"":(t="pm"===t&&e<12?e+12:"am"===t&&12===e?e-12:e,String(t))},populateDateInputs:function(){var i=this.parseDateTime(this.setting.get());return!!i&&(_.each(this.inputElements,function(e,t){var n=i[t];"month"===t||"meridian"===t?(n=n.replace(/^0/,""),e.set(n)):(n=parseInt(n,10),e.element.is(document.activeElement)?n!==parseInt(e(),10)&&e.set(String(n)):e.set(i[t]))}),!0)},toggleFutureDateNotification:function(e){var t="not_future_date";return e?(e=new Y.Notification(t,{type:"error",message:Y.l10n.futureDateError}),this.notifications.add(e)):this.notifications.remove(t),this}}),Y.PreviewLinkControl=Y.Control.extend({defaults:_.extend({},Y.Control.prototype.defaults,{templateId:"customize-preview-link-control"}),ready:function(){var e,t,n,i,a,o=this;_.bindAll(o,"updatePreviewLink"),o.setting||(o.setting=new Y.Value),o.previewElements={},o.container.find(".preview-control-element").each(function(){t=J(this),e=t.data("component"),t=new Y.Element(t),o.previewElements[e]=t,o.elements.push(t)}),n=o.previewElements.url,i=o.previewElements.input,a=o.previewElements.button,i.link(o.setting),n.link(o.setting),n.bind(function(e){n.element.parent().attr({href:e,target:Y.settings.changeset.uuid})}),Y.bind("ready",o.updatePreviewLink),Y.state("saved").bind(o.updatePreviewLink),Y.state("changesetStatus").bind(o.updatePreviewLink),Y.state("activated").bind(o.updatePreviewLink),Y.previewer.previewUrl.bind(o.updatePreviewLink),a.element.on("click",function(e){e.preventDefault(),o.setting()&&(i.element.select(),document.execCommand("copy"),a(a.element.data("copied-text")))}),n.element.parent().on("click",function(e){J(this).hasClass("disabled")&&e.preventDefault()}),a.element.on("mouseenter",function(){o.setting()&&a(a.element.data("copy-text"))})},updatePreviewLink:function(){var e=!Y.state("saved").get()||""===Y.state("changesetStatus").get()||"auto-draft"===Y.state("changesetStatus").get();this.toggleSaveNotification(e),this.previewElements.url.element.parent().toggleClass("disabled",e),this.previewElements.button.element.prop("disabled",e),this.setting.set(Y.previewer.getFrontendPreviewUrl())},toggleSaveNotification:function(e){var t="changes_not_saved";e?(e=new Y.Notification(t,{type:"info",message:Y.l10n.saveBeforeShare}),this.notifications.add(e)):this.notifications.remove(t)}}),Y.defaultConstructor=Y.Setting,Y.control=new Y.Values({defaultConstructor:Y.Control}),Y.section=new Y.Values({defaultConstructor:Y.Section}),Y.panel=new Y.Values({defaultConstructor:Y.Panel}),Y.notifications=new Y.Notifications,Y.PreviewFrame=Y.Messenger.extend({sensitivity:null,initialize:function(e,t){var n=J.Deferred();n.promise(this),this.container=e.container,J.extend(e,{channel:Y.PreviewFrame.uuid()}),Y.Messenger.prototype.initialize.call(this,e,t),this.add("previewUrl",e.previewUrl),this.query=J.extend(e.query||{},{customize_messenger_channel:this.channel()}),this.run(n)},run:function(t){var e,n,i,a=this,o=!1,s=!1,r=null,c="{}"!==a.query.customized;a._ready&&a.unbind("ready",a._ready),a._ready=function(e){s=!0,r=e,a.container.addClass("iframe-ready"),e&&o&&t.resolveWith(a,[e])},a.bind("ready",a._ready),(e=document.createElement("a")).href=a.previewUrl(),n=_.extend(Y.utils.parseQueryString(e.search.substr(1)),{customize_changeset_uuid:a.query.customize_changeset_uuid,customize_theme:a.query.customize_theme,customize_messenger_channel:a.query.customize_messenger_channel}),!Y.settings.changeset.autosaved&&Y.state("saved").get()||(n.customize_autosaved="on"),e.search=J.param(n),a.iframe=J("<iframe />",{title:Y.l10n.previewIframeTitle,name:"customize-"+a.channel()}),a.iframe.attr("onmousewheel",""),a.iframe.attr("sandbox","allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts"),c?a.iframe.attr("data-src",e.href):a.iframe.attr("src",e.href),a.iframe.appendTo(a.container),a.targetWindow(a.iframe[0].contentWindow),c&&((i=J("<form>",{action:e.href,target:a.iframe.attr("name"),method:"post",hidden:"hidden"})).append(J("<input>",{type:"hidden",name:"_method",value:"GET"})),_.each(a.query,function(e,t){i.append(J("<input>",{type:"hidden",name:t,value:e}))}),a.container.append(i),i.trigger("submit"),i.remove()),a.bind("iframe-loading-error",function(e){a.iframe.remove(),0===e?a.login(t):-1===e?t.rejectWith(a,["cheatin"]):t.rejectWith(a,["request failure"])}),a.iframe.one("load",function(){o=!0,s?t.resolveWith(a,[r]):setTimeout(function(){t.rejectWith(a,["ready timeout"])},a.sensitivity)})},login:function(n){var i=this,a=function(){n.rejectWith(i,["logged out"])};if(this.triedLogin)return a();J.get(Y.settings.url.ajax,{action:"logged-in"}).fail(a).done(function(e){var t;"1"!==e&&a(),(t=J("<iframe />",{src:i.previewUrl(),title:Y.l10n.previewIframeTitle}).hide()).appendTo(i.container),t.on("load",function(){i.triedLogin=!0,t.remove(),i.run(n)})})},destroy:function(){Y.Messenger.prototype.destroy.call(this),this.iframe&&this.iframe.remove(),delete this.iframe,delete this.targetWindow}}),i=0,Y.PreviewFrame.uuid=function(){return"preview-"+String(i++)},Y.setDocumentTitle=function(e){e=Y.settings.documentTitleTmpl.replace("%s",e);document.title=e,Y.trigger("title",e)},Y.Previewer=Y.Messenger.extend({refreshBuffer:null,initialize:function(e,t){var n,o=this,i=document.createElement("a");J.extend(o,t||{}),o.deferred={active:J.Deferred()},o.refresh=_.debounce((n=o.refresh,function(){var e,t=function(){return 0===Y.state("processing").get()};t()?n.call(o):(e=function(){t()&&(n.call(o),Y.state("processing").unbind(e))},Y.state("processing").bind(e))}),o.refreshBuffer),o.container=Y.ensure(e.container),o.allowedUrls=e.allowedUrls,e.url=window.location.href,Y.Messenger.prototype.initialize.call(o,e),i.href=o.origin(),o.add("scheme",i.protocol.replace(/:$/,"")),o.add("previewUrl",e.previewUrl).setter(function(e){var n,i=null,t=[],a=document.createElement("a");return a.href=e,/\/wp-(admin|includes|content)(\/|$)/.test(a.pathname)?null:(1<a.search.length&&(delete(e=Y.utils.parseQueryString(a.search.substr(1))).customize_changeset_uuid,delete e.customize_theme,delete e.customize_messenger_channel,delete e.customize_autosaved,_.isEmpty(e)?a.search="":a.search=J.param(e)),t.push(a),o.scheme.get()+":"!==a.protocol&&((a=document.createElement("a")).href=t[0].href,a.protocol=o.scheme.get()+":",t.unshift(a)),n=document.createElement("a"),_.find(t,function(t){return!_.isUndefined(_.find(o.allowedUrls,function(e){if(n.href=e,a.protocol===n.protocol&&a.host===n.host&&0===a.pathname.indexOf(n.pathname.replace(/\/$/,"")))return i=t.href,!0}))}),i)}),o.bind("ready",o.ready),o.deferred.active.done(_.bind(o.keepPreviewAlive,o)),o.bind("synced",function(){o.send("active")}),o.previewUrl.bind(o.refresh),o.scroll=0,o.bind("scroll",function(e){o.scroll=e}),o.bind("url",function(e){var t,n=!1;o.scroll=0,o.previewUrl.bind(t=function(){n=!0}),o.previewUrl.set(e),o.previewUrl.unbind(t),n||o.refresh()}),o.bind("documentTitle",function(e){Y.setDocumentTitle(e)})},ready:function(e){var t=this,n={};n.settings=Y.get(),n["settings-modified-while-loading"]=t.settingsModifiedWhileLoading,"resolved"===t.deferred.active.state()&&!t.loading||(n.scroll=t.scroll),n["edit-shortcut-visibility"]=Y.state("editShortcutVisibility").get(),t.send("sync",n),e.currentUrl&&(t.previewUrl.unbind(t.refresh),t.previewUrl.set(e.currentUrl),t.previewUrl.bind(t.refresh)),n={panel:e.activePanels,section:e.activeSections,control:e.activeControls},_(n).each(function(n,i){Y[i].each(function(e,t){_.isUndefined(Y.settings[i+"s"][t])&&_.isUndefined(n[t])||(n[t]?e.activate():e.deactivate())})}),e.settingValidities&&Y._handleSettingValidities({settingValidities:e.settingValidities,focusInvalidControl:!1})},keepPreviewAlive:function(){var e,t=function(){e=setTimeout(i,Y.settings.timeouts.keepAliveCheck)},n=function(){Y.state("previewerAlive").set(!0),clearTimeout(e),t()},i=function(){Y.state("previewerAlive").set(!1)};t(),this.bind("ready",n),this.bind("keep-alive",n)},query:function(){},abort:function(){this.loading&&(this.loading.destroy(),delete this.loading)},refresh:function(){var e,i=this;i.send("loading-initiated"),i.abort(),i.loading=new Y.PreviewFrame({url:i.url(),previewUrl:i.previewUrl(),query:i.query({excludeCustomizedSaved:!0})||{},container:i.container}),i.settingsModifiedWhileLoading={},Y.bind("change",e=function(e){i.settingsModifiedWhileLoading[e.id]=!0}),i.loading.always(function(){Y.unbind("change",e)}),i.loading.done(function(e){var t,n=this;i.preview=n,i.targetWindow(n.targetWindow()),i.channel(n.channel()),t=function(){n.unbind("synced",t),i._previousPreview&&i._previousPreview.destroy(),i._previousPreview=i.preview,i.deferred.active.resolve(),delete i.loading},n.bind("synced",t),i.trigger("ready",e)}),i.loading.fail(function(e){i.send("loading-failed"),"logged out"===e&&(i.preview&&(i.preview.destroy(),delete i.preview),i.login().done(i.refresh)),"cheatin"===e&&i.cheatin()})},login:function(){var t,n,i,a=this;return this._login||(t=J.Deferred(),this._login=t.promise(),n=new Y.Messenger({channel:"login",url:Y.settings.url.login}),i=J("<iframe />",{src:Y.settings.url.login,title:Y.l10n.loginIframeTitle}).appendTo(this.container),n.targetWindow(i[0].contentWindow),n.bind("login",function(){var e=a.refreshNonces();e.always(function(){i.remove(),n.destroy(),delete a._login}),e.done(function(){t.resolve()}),e.fail(function(){a.cheatin(),t.reject()})})),this._login},cheatin:function(){J(document.body).empty().addClass("cheatin").append("<h1>"+Y.l10n.notAllowedHeading+"</h1><p>"+Y.l10n.notAllowed+"</p>")},refreshNonces:function(){var e,t=J.Deferred();return t.promise(),(e=wp.ajax.post("customize_refresh_nonces",{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet})).done(function(e){Y.trigger("nonce-refresh",e),t.resolve()}),e.fail(function(){t.reject()}),t}}),Y.settingConstructor={},Y.controlConstructor={color:Y.ColorControl,media:Y.MediaControl,upload:Y.UploadControl,image:Y.ImageControl,cropped_image:Y.CroppedImageControl,site_icon:Y.SiteIconControl,header:Y.HeaderControl,background:Y.BackgroundControl,background_position:Y.BackgroundPositionControl,theme:Y.ThemeControl,date_time:Y.DateTimeControl,code_editor:Y.CodeEditorControl},Y.panelConstructor={themes:Y.ThemesPanel},Y.sectionConstructor={themes:Y.ThemesSection,outer:Y.OuterSection},Y._handleSettingValidities=function(e){var o=[],n=!1;_.each(e.settingValidities,function(t,e){var a=Y(e);a&&(_.isObject(t)&&_.each(t,function(e,t){var n=!1,e=new Y.Notification(t,_.extend({fromServer:!0},e)),i=a.notifications(e.code);(n=i?e.type!==i.type||e.message!==i.message||!_.isEqual(e.data,i.data):n)&&a.notifications.remove(t),a.notifications.has(e.code)||a.notifications.add(e),o.push(a.id)}),a.notifications.each(function(e){!e.fromServer||"error"!==e.type||!0!==t&&t[e.code]||a.notifications.remove(e.code)}))}),e.focusInvalidControl&&(e=Y.findControlsForSettings(o),_(_.values(e)).find(function(e){return _(e).find(function(e){var t=e.section()&&Y.section.has(e.section())&&Y.section(e.section()).expanded();return(t=t&&e.expanded?e.expanded():t)&&(e.focus(),n=!0),n})}),n||_.isEmpty(e)||_.values(e)[0][0].focus())},Y.findControlsForSettings=function(e){var n,i={};return _.each(_.unique(e),function(e){var t=Y(e);t&&(n=t.findControls())&&0<n.length&&(i[e]=n)}),i},Y.reflowPaneContents=_.bind(function(){var i,e,t,a=[],o=!1;document.activeElement&&(e=J(document.activeElement)),Y.panel.each(function(e){var t,n;"themes"===e.id||(t=e.sections(),n=_.pluck(t,"headContainer"),a.push(e),i=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),Y.utils.areElementListsEqual(n,i.children("[id]")))||(_(t).each(function(e){i.append(e.headContainer)}),o=!0)}),Y.section.each(function(e){var t=e.controls(),n=_.pluck(t,"container");e.panel()||a.push(e),i=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),Y.utils.areElementListsEqual(n,i.children("[id]"))||(_(t).each(function(e){i.append(e.container)}),o=!0)}),a.sort(Y.utils.prioritySort),t=_.pluck(a,"headContainer"),i=J("#customize-theme-controls .customize-pane-parent"),Y.utils.areElementListsEqual(t,i.children())||(_(a).each(function(e){i.append(e.headContainer)}),o=!0),Y.panel.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),Y.section.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),o&&e&&e.trigger("focus"),Y.trigger("pane-contents-reflowed")},Y),Y.state=new Y.Values,_.each(["saved","saving","trashing","activated","processing","paneVisible","expandedPanel","expandedSection","changesetDate","selectedChangesetDate","changesetStatus","selectedChangesetStatus","remainingTimeToPublish","previewerAlive","editShortcutVisibility","changesetLocked","previewedDevice"],function(e){Y.state.create(e)}),J(function(){var h,o,t,n,i,d,u,p,a,s,r,c,l,f,m,H,L,g,v,w,b,M,O,C,j,y,e,x,k,z,S,T,E,R,B,W,D,N,P,I,U,A;function F(e){e&&e.lockUser&&(Y.settings.changeset.lockUser=e.lockUser),Y.state("changesetLocked").set(!0),Y.notifications.add(new j("changeset_locked",{lockUser:Y.settings.changeset.lockUser,allowOverride:Boolean(e&&e.allowOverride)}))}function q(){var e,t=document.createElement("a");return t.href=location.href,e=Y.utils.parseQueryString(t.search.substr(1)),Y.settings.changeset.latestAutoDraftUuid?e.changeset_uuid=Y.settings.changeset.latestAutoDraftUuid:e.customize_autosaved="on",e.return=Y.settings.url.return,t.search=J.param(e),t.href}function Q(){T||(wp.ajax.post("customize_dismiss_autosave_or_lock",{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.dismiss_autosave_or_lock,dismiss_autosave:!0}),T=!0)}function K(){var e;return Y.state("activated").get()?(""!==(e=Y.state("changesetStatus").get())&&"auto-draft"!==e||(e="publish"),Y.state("selectedChangesetStatus").get()===e&&("future"!==Y.state("selectedChangesetStatus").get()||Y.state("selectedChangesetDate").get()===Y.state("changesetDate").get())&&Y.state("saved").get()&&"auto-draft"!==Y.state("changesetStatus").get()):0===Y._latestRevision}function V(){Y.unbind("change",V),Y.state("selectedChangesetStatus").unbind(V),Y.state("selectedChangesetDate").unbind(V),J(window).on("beforeunload.customize-confirm",function(){if(!K()&&!Y.state("changesetLocked").get())return setTimeout(function(){t.removeClass("customize-loading")},1),Y.l10n.saveAlert})}function $(){var e=J.Deferred(),t=!1,n=!1;return K()?n=!0:confirm(Y.l10n.saveAlert)?(n=!0,Y.each(function(e){e._dirty=!1}),J(document).off("visibilitychange.wp-customize-changeset-update"),J(window).off("beforeunload.wp-customize-changeset-update"),i.css("cursor","progress"),""!==Y.state("changesetStatus").get()&&(t=!0)):e.reject(),(n||t)&&wp.ajax.send("customize_dismiss_autosave_or_lock",{timeout:500,data:{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.dismiss_autosave_or_lock,dismiss_autosave:t,dismiss_lock:n}}).always(function(){e.resolve()}),e.promise()}Y.settings=window._wpCustomizeSettings,Y.l10n=window._wpCustomizeControlsL10n,Y.settings&&J.support.postMessage&&(J.support.cors||!Y.settings.isCrossDomain)&&(null===Y.PreviewFrame.prototype.sensitivity&&(Y.PreviewFrame.prototype.sensitivity=Y.settings.timeouts.previewFrameSensitivity),null===Y.Previewer.prototype.refreshBuffer&&(Y.Previewer.prototype.refreshBuffer=Y.settings.timeouts.windowRefresh),o=J(document.body),t=o.children(".wp-full-overlay"),n=J("#customize-info .panel-title.site-title"),i=J(".customize-controls-close"),d=J("#save"),u=J("#customize-save-button-wrapper"),p=J("#publish-settings"),a=J("#customize-footer-actions"),Y.bind("ready",function(){Y.section.add(new Y.OuterSection("publish_settings",{title:Y.l10n.publishSettings,priority:0,active:Y.settings.theme.active}))}),Y.section("publish_settings",function(t){var e,n,i,a,o,s,r;function c(){r=r||Y.utils.highlightButton(u,{delay:1e3,focusTarget:d})}function l(){r&&(r(),r=null)}e=new Y.Control("trash_changeset",{type:"button",section:t.id,priority:30,input_attrs:{class:"button-link button-link-delete",value:Y.l10n.discardChanges}}),Y.control.add(e),e.deferred.embedded.done(function(){e.container.find(".button-link").on("click",function(){confirm(Y.l10n.trashConfirm)&&wp.customize.previewer.trash()})}),Y.control.add(new Y.PreviewLinkControl("changeset_preview_link",{section:t.id,priority:100})),t.active.validate=n=function(){return!!Y.state("activated").get()&&!(Y.state("trashing").get()||"trash"===Y.state("changesetStatus").get()||""===Y.state("changesetStatus").get()&&Y.state("saved").get())},s=function(){t.active.set(n())},Y.state("activated").bind(s),Y.state("trashing").bind(s),Y.state("saved").bind(s),Y.state("changesetStatus").bind(s),s(),(s=function(){p.toggle(t.active.get()),d.toggleClass("has-next-sibling",t.active.get())})(),t.active.bind(s),Y.state("selectedChangesetStatus").bind(l),t.contentContainer.find(".customize-action").text(Y.l10n.updating),t.contentContainer.find(".customize-section-back").removeAttr("tabindex"),p.prop("disabled",!1),p.on("click",function(e){e.preventDefault(),t.expanded.set(!t.expanded.get())}),t.expanded.bind(function(e){p.attr("aria-expanded",String(e)),p.toggleClass("active",e),e?l():(""!==(e=Y.state("changesetStatus").get())&&"auto-draft"!==e||(e="publish"),(Y.state("selectedChangesetStatus").get()!==e||"future"===Y.state("selectedChangesetStatus").get()&&Y.state("selectedChangesetDate").get()!==Y.state("changesetDate").get())&&c())}),s=new Y.Control("changeset_status",{priority:10,type:"radio",section:"publish_settings",setting:Y.state("selectedChangesetStatus"),templateId:"customize-selected-changeset-status-control",label:Y.l10n.action,choices:Y.settings.changeset.statusChoices}),Y.control.add(s),(i=new Y.DateTimeControl("changeset_scheduled_date",{priority:20,section:"publish_settings",setting:Y.state("selectedChangesetDate"),minYear:(new Date).getFullYear(),allowPastDate:!1,includeTime:!0,twelveHourFormat:/a/i.test(Y.settings.timeFormat),description:Y.l10n.scheduleDescription})).notifications.alt=!0,Y.control.add(i),a=function(){Y.state("selectedChangesetStatus").set("publish"),Y.previewer.save()},s=function(){var e="future"===Y.state("changesetStatus").get()&&"future"===Y.state("selectedChangesetStatus").get()&&Y.state("changesetDate").get()&&Y.state("selectedChangesetDate").get()===Y.state("changesetDate").get()&&0<=Y.utils.getRemainingTime(Y.state("changesetDate").get());e&&!o?o=setInterval(function(){var e=Y.utils.getRemainingTime(Y.state("changesetDate").get());Y.state("remainingTimeToPublish").set(e),e<=0&&(clearInterval(o),o=0,a())},1e3):!e&&o&&(clearInterval(o),o=0)},Y.state("changesetDate").bind(s),Y.state("selectedChangesetDate").bind(s),Y.state("changesetStatus").bind(s),Y.state("selectedChangesetStatus").bind(s),s(),i.active.validate=function(){return"future"===Y.state("selectedChangesetStatus").get()},(s=function(e){i.active.set("future"===e)})(Y.state("selectedChangesetStatus").get()),Y.state("selectedChangesetStatus").bind(s),Y.state("saving").bind(function(e){e&&"future"===Y.state("selectedChangesetStatus").get()&&i.toggleFutureDateNotification(!i.isFutureDate())})}),J("#customize-controls").on("keydown",function(e){var t=13===e.which,n=J(e.target);t&&(n.is("input:not([type=button])")||n.is("select"))&&e.preventDefault()}),J(".customize-info").find("> .accordion-section-title .customize-help-toggle").on("click",function(){var e=J(this).closest(".accordion-section"),t=e.find(".customize-panel-description:first");e.hasClass("cannot-expand")||(e.hasClass("open")?(e.toggleClass("open"),t.slideUp(Y.Panel.prototype.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),J(this).attr("aria-expanded",!1)):(t.slideDown(Y.Panel.prototype.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),e.toggleClass("open"),J(this).attr("aria-expanded",!0)))}),Y.previewer=new Y.Previewer({container:"#customize-preview",form:"#customize-controls",previewUrl:Y.settings.url.preview,allowedUrls:Y.settings.url.allowed},{nonce:Y.settings.nonce,query:function(e){var t={wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,nonce:this.nonce.preview,customize_changeset_uuid:Y.settings.changeset.uuid};return!Y.settings.changeset.autosaved&&Y.state("saved").get()||(t.customize_autosaved="on"),t.customized=JSON.stringify(Y.dirtyValues({unsaved:e&&e.excludeCustomizedSaved})),t},save:function(i){var e,t,a=this,o=J.Deferred(),s=Y.state("selectedChangesetStatus").get(),r=Y.state("selectedChangesetDate").get(),n=Y.state("processing"),c={},l=[],d=[],u=[];function p(e){c[e.id]=!0}return i&&i.status&&(s=i.status),Y.state("saving").get()&&(o.reject("already_saving"),o.promise()),Y.state("saving").set(!0),t=function(){var n={},t=Y._latestRevision,e="client_side_error";if(Y.bind("change",p),Y.notifications.remove(e),Y.each(function(t){t.notifications.each(function(e){"error"!==e.type||e.fromServer||(l.push(t.id),n[t.id]||(n[t.id]={}),n[t.id][e.code]=e)})}),Y.control.each(function(t){t.setting&&(t.setting.id||!t.active.get())||t.notifications.each(function(e){"error"===e.type&&u.push([t])})}),d=_.union(u,_.values(Y.findControlsForSettings(l))),!_.isEmpty(d))return d[0][0].focus(),Y.unbind("change",p),l.length&&Y.notifications.add(new Y.Notification(e,{message:(1===l.length?Y.l10n.saveBlockedError.singular:Y.l10n.saveBlockedError.plural).replace(/%s/g,String(l.length)),type:"error",dismissible:!0,saveFailure:!0})),o.rejectWith(a,[{setting_invalidities:n}]),Y.state("saving").set(!1),o.promise();e=J.extend(a.query({excludeCustomizedSaved:!1}),{nonce:a.nonce.save,customize_changeset_status:s}),i&&i.date?e.customize_changeset_date=i.date:"future"===s&&r&&(e.customize_changeset_date=r),i&&i.title&&(e.customize_changeset_title=i.title),Y.trigger("save-request-params",e),e=wp.ajax.post("customize_save",e),Y.state("processing").set(Y.state("processing").get()+1),Y.trigger("save",e),e.always(function(){Y.state("processing").set(Y.state("processing").get()-1),Y.state("saving").set(!1),Y.unbind("change",p)}),Y.notifications.each(function(e){e.saveFailure&&Y.notifications.remove(e.code)}),e.fail(function(e){var t,n={type:"error",dismissible:!0,fromServer:!0,saveFailure:!0};"0"===e?e="not_logged_in":"-1"===e&&(e="invalid_nonce"),"invalid_nonce"===e?a.cheatin():"not_logged_in"===e?(a.preview.iframe.hide(),a.login().done(function(){a.save(),a.preview.iframe.show()})):e.code?"not_future_date"===e.code&&Y.section.has("publish_settings")&&Y.section("publish_settings").active.get()&&Y.control.has("changeset_scheduled_date")?Y.control("changeset_scheduled_date").toggleFutureDateNotification(!0).focus():"changeset_locked"!==e.code&&(t=new Y.Notification(e.code,_.extend(n,{message:e.message}))):t=new Y.Notification("unknown_error",_.extend(n,{message:Y.l10n.unknownRequestFail})),t&&Y.notifications.add(t),e.setting_validities&&Y._handleSettingValidities({settingValidities:e.setting_validities,focusInvalidControl:!0}),o.rejectWith(a,[e]),Y.trigger("error",e),"changeset_already_published"===e.code&&e.next_changeset_uuid&&(Y.settings.changeset.uuid=e.next_changeset_uuid,Y.state("changesetStatus").set(""),Y.settings.changeset.branching&&h.send("changeset-uuid",Y.settings.changeset.uuid),Y.previewer.send("changeset-uuid",Y.settings.changeset.uuid))}),e.done(function(e){a.send("saved",e),Y.state("changesetStatus").set(e.changeset_status),e.changeset_date&&Y.state("changesetDate").set(e.changeset_date),"publish"===e.changeset_status&&(Y.each(function(e){e._dirty&&(_.isUndefined(Y._latestSettingRevisions[e.id])||Y._latestSettingRevisions[e.id]<=t)&&(e._dirty=!1)}),Y.state("changesetStatus").set(""),Y.settings.changeset.uuid=e.next_changeset_uuid,Y.settings.changeset.branching)&&h.send("changeset-uuid",Y.settings.changeset.uuid),Y._lastSavedRevision=Math.max(t,Y._lastSavedRevision),e.setting_validities&&Y._handleSettingValidities({settingValidities:e.setting_validities,focusInvalidControl:!0}),o.resolveWith(a,[e]),Y.trigger("saved",e),_.isEmpty(c)||Y.state("saved").set(!1)})},0===n()?t():(e=function(){0===n()&&(Y.state.unbind("change",e),t())},Y.state.bind("change",e)),o.promise()},trash:function(){var e,n,i;Y.state("trashing").set(!0),Y.state("processing").set(Y.state("processing").get()+1),e=wp.ajax.post("customize_trash",{customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.trash}),Y.notifications.add(new Y.OverlayNotification("changeset_trashing",{type:"info",message:Y.l10n.revertingChanges,loading:!0})),n=function(){var e,t=document.createElement("a");Y.state("changesetStatus").set("trash"),Y.each(function(e){e._dirty=!1}),Y.state("saved").set(!0),t.href=location.href,delete(e=Y.utils.parseQueryString(t.search.substr(1))).changeset_uuid,e.return=Y.settings.url.return,t.search=J.param(e),location.replace(t.href)},i=function(e,t){e=e||"unknown_error";Y.state("processing").set(Y.state("processing").get()-1),Y.state("trashing").set(!1),Y.notifications.remove("changeset_trashing"),Y.notifications.add(new Y.Notification(e,{message:t||Y.l10n.unknownError,dismissible:!0,type:"error"}))},e.done(function(e){n(e.message)}),e.fail(function(e){var t=e.code||"trashing_failed";e.success||"non_existent_changeset"===t||"changeset_already_trashed"===t?n(e.message):i(t,e.message)})},getFrontendPreviewUrl:function(){var e,t=document.createElement("a");return t.href=this.previewUrl.get(),e=Y.utils.parseQueryString(t.search.substr(1)),Y.state("changesetStatus").get()&&"publish"!==Y.state("changesetStatus").get()&&(e.customize_changeset_uuid=Y.settings.changeset.uuid),Y.state("activated").get()||(e.customize_theme=Y.settings.theme.stylesheet),t.search=J.param(e),t.href}}),J.ajaxPrefilter(function(e){/wp_customize=on/.test(e.data)&&(e.data+="&"+J.param({customize_preview_nonce:Y.settings.nonce.preview}))}),Y.previewer.bind("nonce",function(e){J.extend(this.nonce,e)}),Y.bind("nonce-refresh",function(e){J.extend(Y.settings.nonce,e),J.extend(Y.previewer.nonce,e),Y.previewer.send("nonce-refresh",e)}),J.each(Y.settings.settings,function(e,t){var n=Y.settingConstructor[t.type]||Y.Setting;Y.add(new n(e,t.value,{transport:t.transport,previewer:Y.previewer,dirty:!!t.dirty}))}),J.each(Y.settings.panels,function(e,t){var n=Y.panelConstructor[t.type]||Y.Panel,t=_.extend({params:t},t);Y.panel.add(new n(e,t))}),J.each(Y.settings.sections,function(e,t){var n=Y.sectionConstructor[t.type]||Y.Section,t=_.extend({params:t},t);Y.section.add(new n(e,t))}),J.each(Y.settings.controls,function(e,t){var n=Y.controlConstructor[t.type]||Y.Control,t=_.extend({params:t},t);Y.control.add(new n(e,t))}),_.each(["panel","section","control"],function(e){var t=Y.settings.autofocus[e];t&&Y[e](t,function(e){e.deferred.embedded.done(function(){Y.previewer.deferred.active.done(function(){e.focus()})})})}),Y.bind("ready",Y.reflowPaneContents),J([Y.panel,Y.section,Y.control]).each(function(e,t){var n=_.debounce(Y.reflowPaneContents,Y.settings.timeouts.reflowPaneContents);t.bind("add",n),t.bind("change",n),t.bind("remove",n)}),Y.bind("ready",function(){var e,t,n;Y.notifications.container=J("#customize-notifications-area"),Y.notifications.bind("change",_.debounce(function(){Y.notifications.render()})),e=J(".wp-full-overlay-sidebar-content"),Y.notifications.bind("rendered",function(){e.css("top",""),0!==Y.notifications.count()&&(t=Y.notifications.container.outerHeight()+1,n=parseInt(e.css("top"),10),e.css("top",n+t+"px")),Y.notifications.trigger("sidebarTopUpdated")}),Y.notifications.render()}),s=Y.state,c=s.instance("saved"),l=s.instance("saving"),f=s.instance("trashing"),m=s.instance("activated"),e=s.instance("processing"),I=s.instance("paneVisible"),H=s.instance("expandedPanel"),L=s.instance("expandedSection"),g=s.instance("changesetStatus"),v=s.instance("selectedChangesetStatus"),w=s.instance("changesetDate"),b=s.instance("selectedChangesetDate"),M=s.instance("previewerAlive"),O=s.instance("editShortcutVisibility"),C=s.instance("changesetLocked"),s.bind("change",function(){var e;m()?""===g.get()&&c()?(Y.settings.changeset.currentUserCanPublish?d.val(Y.l10n.published):d.val(Y.l10n.saved),i.find(".screen-reader-text").text(Y.l10n.close)):("draft"===v()?c()&&v()===g()?d.val(Y.l10n.draftSaved):d.val(Y.l10n.saveDraft):"future"===v()?!c()||v()!==g()||w.get()!==b.get()?d.val(Y.l10n.schedule):d.val(Y.l10n.scheduled):Y.settings.changeset.currentUserCanPublish&&d.val(Y.l10n.publish),i.find(".screen-reader-text").text(Y.l10n.cancel)):(d.val(Y.l10n.activate),i.find(".screen-reader-text").text(Y.l10n.cancel)),e=!l()&&!f()&&!C()&&(!m()||!c()||g()!==v()&&""!==g()||"future"===v()&&w.get()!==b.get()),d.prop("disabled",!e)}),v.validate=function(e){return""===e||"auto-draft"===e?null:e},S=Y.settings.changeset.currentUserCanPublish?"publish":"draft",g(Y.settings.changeset.status),C(Boolean(Y.settings.changeset.lockUser)),w(Y.settings.changeset.publishDate),b(Y.settings.changeset.publishDate),v(""===Y.settings.changeset.status||"auto-draft"===Y.settings.changeset.status?S:Y.settings.changeset.status),v.link(g),c(!0),""===g()&&Y.each(function(e){e._dirty&&c(!1)}),l(!1),m(Y.settings.theme.active),e(0),I(!0),H(!1),L(!1),M(!0),O("visible"),Y.bind("change",function(){s("saved").get()&&s("saved").set(!1)}),Y.settings.changeset.branching&&c.bind(function(e){e||r(!0)}),l.bind(function(e){o.toggleClass("saving",e)}),f.bind(function(e){o.toggleClass("trashing",e)}),Y.bind("saved",function(e){s("saved").set(!0),"publish"===e.changeset_status&&s("activated").set(!0)}),m.bind(function(e){e&&Y.trigger("activated")}),r=function(e){var t,n;if(history.replaceState){if((t=document.createElement("a")).href=location.href,n=Y.utils.parseQueryString(t.search.substr(1)),e){if(n.changeset_uuid===Y.settings.changeset.uuid)return;n.changeset_uuid=Y.settings.changeset.uuid}else{if(!n.changeset_uuid)return;delete n.changeset_uuid}t.search=J.param(n),history.replaceState({},document.title,t.href)}},Y.settings.changeset.branching&&g.bind(function(e){r(""!==e&&"publish"!==e&&"trash"!==e)}),j=Y.OverlayNotification.extend({templateId:"customize-changeset-locked-notification",lockUser:null,initialize:function(e,t){e=e||"changeset_locked",t=_.extend({message:"",type:"warning",containerClasses:"",lockUser:{}},t);t.containerClasses+=" notification-changeset-locked",Y.OverlayNotification.prototype.initialize.call(this,e,t)},render:function(){var t,n,i=this,e=_.extend({allowOverride:!1,returnUrl:Y.settings.url.return,previewUrl:Y.previewer.previewUrl.get(),frontendPreviewUrl:Y.previewer.getFrontendPreviewUrl()},this),a=Y.OverlayNotification.prototype.render.call(e);return Y.requestChangesetUpdate({},{autosave:!0}).fail(function(e){e.autosaved||a.find(".notice-error").prop("hidden",!1).text(e.message||Y.l10n.unknownRequestFail)}),(t=a.find(".customize-notice-take-over-button")).on("click",function(e){e.preventDefault(),n||(t.addClass("disabled"),(n=wp.ajax.post("customize_override_changeset_lock",{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.override_lock})).done(function(){Y.notifications.remove(i.code),Y.state("changesetLocked").set(!1)}),n.fail(function(e){e=e.message||Y.l10n.unknownRequestFail;a.find(".notice-error").prop("hidden",!1).text(e),n.always(function(){t.removeClass("disabled")})}),n.always(function(){n=null}))}),a}}),Y.settings.changeset.lockUser&&F({allowOverride:!0}),J(document).on("heartbeat-send.update_lock_notice",function(e,t){t.check_changeset_lock=!0,t.changeset_uuid=Y.settings.changeset.uuid}),J(document).on("heartbeat-tick.update_lock_notice",function(e,t){var n,i="changeset_locked";t.customize_changeset_lock_user&&((n=Y.notifications(i))&&n.lockUser.id!==Y.settings.changeset.lockUser.id&&Y.notifications.remove(i),F({lockUser:t.customize_changeset_lock_user}))}),Y.bind("error",function(e){"changeset_locked"===e.code&&e.lock_user&&F({lockUser:e.lock_user})}),T=!(S=[]),Y.settings.changeset.autosaved&&(Y.state("saved").set(!1),S.push("customize_autosaved")),Y.settings.changeset.branching||Y.settings.changeset.status&&"auto-draft"!==Y.settings.changeset.status||S.push("changeset_uuid"),0<S.length&&(S=S,e=document.createElement("a"),x=0,e.href=location.href,y=Y.utils.parseQueryString(e.search.substr(1)),_.each(S,function(e){void 0!==y[e]&&(x+=1,delete y[e])}),0!==x)&&(e.search=J.param(y),history.replaceState({},document.title,e.href)),(Y.settings.changeset.latestAutoDraftUuid||Y.settings.changeset.hasAutosaveRevision)&&(z="autosave_available",Y.notifications.add(new Y.Notification(z,{message:Y.l10n.autosaveNotice,type:"warning",dismissible:!0,render:function(){var e=Y.Notification.prototype.render.call(this),t=e.find("a");return t.prop("href",q()),t.on("click",function(e){e.preventDefault(),location.replace(q())}),e.find(".notice-dismiss").on("click",Q),e}})),Y.bind("change",k=function(){Q(),Y.notifications.remove(z),Y.unbind("change",k),Y.state("changesetStatus").unbind(k)}),Y.state("changesetStatus").bind(k)),parseInt(J("#customize-info").data("block-theme"),10)&&(S=Y.l10n.blockThemeNotification,Y.notifications.add(new Y.Notification("site_editor_block_theme_notice",{message:S,type:"info",dismissible:!1,render:function(){var e=Y.Notification.prototype.render.call(this),t=e.find("button.switch-to-editor");return t.on("click",function(e){e.preventDefault(),location.assign(t.data("action"))}),e}}))),Y.previewer.previewUrl()?Y.previewer.refresh():Y.previewer.previewUrl(Y.settings.url.home),d.on("click",function(e){Y.previewer.save(),e.preventDefault()}).on("keydown",function(e){9!==e.which&&(13===e.which&&Y.previewer.save(),e.preventDefault())}),i.on("keydown",function(e){9!==e.which&&(13===e.which&&this.click(),e.preventDefault())}),J(".collapse-sidebar").on("click",function(){Y.state("paneVisible").set(!Y.state("paneVisible").get())}),Y.state("paneVisible").bind(function(e){t.toggleClass("preview-only",!e),t.toggleClass("expanded",e),t.toggleClass("collapsed",!e),e?J(".collapse-sidebar").attr({"aria-expanded":"true","aria-label":Y.l10n.collapseSidebar}):J(".collapse-sidebar").attr({"aria-expanded":"false","aria-label":Y.l10n.expandSidebar})}),o.on("keydown",function(e){var t,n=[],i=[],a=[];27===e.which&&(J(e.target).is("body")||J.contains(J("#customize-controls")[0],e.target))&&null===e.target.closest(".block-editor-writing-flow")&&null===e.target.closest(".block-editor-block-list__block-popover")&&(Y.control.each(function(e){e.expanded&&e.expanded()&&_.isFunction(e.collapse)&&n.push(e)}),Y.section.each(function(e){e.expanded()&&i.push(e)}),Y.panel.each(function(e){e.expanded()&&a.push(e)}),0<n.length&&0===i.length&&(n.length=0),t=n[0]||i[0]||a[0])&&("themes"===t.params.type?o.hasClass("modal-open")?t.closeDetails():Y.panel.has("themes")&&Y.panel("themes").collapse():(t.collapse(),e.preventDefault()))}),J(".customize-controls-preview-toggle").on("click",function(){Y.state("paneVisible").set(!Y.state("paneVisible").get())}),P=J(".wp-full-overlay-sidebar-content"),I=function(e){var t=Y.state("expandedSection").get(),n=Y.state("expandedPanel").get();if(D&&D.element&&(R(D.element),D.element.find(".description").off("toggled",E)),!e)if(!t&&n&&n.contentContainer)e=n;else{if(n||!t||!t.contentContainer)return void(D=!1);e=t}(n=e.contentContainer.find(".customize-section-title, .panel-meta").first()).length?((D={instance:e,element:n,parent:n.closest(".customize-pane-child"),height:n.outerHeight()}).element.find(".description").on("toggled",E),t&&B(D.element,D.parent)):D=!1},Y.state("expandedSection").bind(I),Y.state("expandedPanel").bind(I),P.on("scroll",_.throttle(function(){var e,t;D&&(e=P.scrollTop(),t=N?e===N?0:N<e?1:-1:1,N=e,0!==t)&&W(D,e,t)},8)),Y.notifications.bind("sidebarTopUpdated",function(){D&&D.element.hasClass("is-sticky")&&D.element.css("top",P.css("top"))}),R=function(e){e.hasClass("is-sticky")&&e.removeClass("is-sticky").addClass("maybe-sticky is-in-view").css("top",P.scrollTop()+"px")},B=function(e,t){e.hasClass("is-in-view")&&(e.removeClass("maybe-sticky is-in-view").css({width:"",top:""}),t.css("padding-top",""))},E=function(){D.height=D.element.outerHeight()},W=function(e,t,n){var i=e.element,a=e.parent,e=e.height,o=parseInt(i.css("top"),10),s=i.hasClass("maybe-sticky"),r=i.hasClass("is-sticky"),c=i.hasClass("is-in-view");if(-1===n){if(!s&&e<=t)s=!0,i.addClass("maybe-sticky");else if(0===t)return i.removeClass("maybe-sticky is-in-view is-sticky").css({top:"",width:""}),void a.css("padding-top","");c&&!r?t<=o&&i.addClass("is-sticky").css({top:P.css("top"),width:a.outerWidth()+"px"}):s&&!c&&(i.addClass("is-in-view").css("top",t-e+"px"),a.css("padding-top",e+"px"))}else r&&(o=t,i.removeClass("is-sticky").css({top:o+"px",width:""})),c&&o+e<t&&(i.removeClass("is-in-view"),a.css("padding-top",""))},Y.previewedDevice=Y.state("previewedDevice"),Y.bind("ready",function(){_.find(Y.settings.previewableDevices,function(e,t){if(!0===e.default)return Y.previewedDevice.set(t),!0})}),a.find(".devices button").on("click",function(e){Y.previewedDevice.set(J(e.currentTarget).data("device"))}),Y.previewedDevice.bind(function(e){var t=J(".wp-full-overlay"),n="";a.find(".devices button").removeClass("active").attr("aria-pressed",!1),a.find(".devices .preview-"+e).addClass("active").attr("aria-pressed",!0),J.each(Y.settings.previewableDevices,function(e){n+=" preview-"+e}),t.removeClass(n).addClass("preview-"+e)}),n.length&&Y("blogname",function(t){function e(){var e=t()||"";n.text(e.toString().trim()||Y.l10n.untitledBlogName)}t.bind(e),e()}),h=new Y.Messenger({url:Y.settings.url.parent,channel:"loader"}),U=!1,h.bind("back",function(){U=!0}),Y.bind("change",V),Y.state("selectedChangesetStatus").bind(V),Y.state("selectedChangesetDate").bind(V),h.bind("confirm-close",function(){$().done(function(){h.send("confirmed-close",!0)}).fail(function(){h.send("confirmed-close",!1)})}),i.on("click.customize-controls-close",function(e){e.preventDefault(),U?h.send("close"):$().done(function(){J(window).off("beforeunload.customize-confirm"),window.location.href=i.prop("href")})}),J.each(["saved","change"],function(e,t){Y.bind(t,function(){h.send(t)})}),Y.bind("title",function(e){h.send("title",e)}),Y.settings.changeset.branching&&h.send("changeset-uuid",Y.settings.changeset.uuid),h.send("ready"),J.each({background_image:{controls:["background_preset","background_position","background_size","background_repeat","background_attachment"],callback:function(e){return!!e}},show_on_front:{controls:["page_on_front","page_for_posts"],callback:function(e){return"page"===e}},header_textcolor:{controls:["header_textcolor"],callback:function(e){return"blank"!==e}}},function(e,i){Y(e,function(n){J.each(i.controls,function(e,t){Y.control(t,function(t){function e(e){t.container.toggle(i.callback(e))}e(n.get()),n.bind(e)})})})}),Y.control("background_preset",function(e){var i={default:[!1,!1,!1,!1],fill:[!0,!1,!1,!1],fit:[!0,!1,!0,!1],repeat:[!0,!1,!1,!0],custom:[!0,!0,!0,!0]},a={default:[_wpCustomizeBackground.defaults["default-position-x"],_wpCustomizeBackground.defaults["default-position-y"],_wpCustomizeBackground.defaults["default-size"],_wpCustomizeBackground.defaults["default-repeat"],_wpCustomizeBackground.defaults["default-attachment"]],fill:["left","top","cover","no-repeat","fixed"],fit:["left","top","contain","no-repeat","fixed"],repeat:["left","top","auto","repeat","scroll"]},t=function(n){_.each(["background_position","background_size","background_repeat","background_attachment"],function(e,t){e=Y.control(e);e&&e.container.toggle(i[n][t])})},n=function(n){_.each(["background_position_x","background_position_y","background_size","background_repeat","background_attachment"],function(e,t){e=Y(e);e&&e.set(a[n][t])})},o=e.setting.get();t(o),e.setting.bind("change",function(e){t(e),"custom"!==e&&n(e)})}),Y.control("background_repeat",function(t){t.elements[0].unsync(Y("background_repeat")),t.element=new Y.Element(t.container.find("input")),t.element.set("no-repeat"!==t.setting()),t.element.bind(function(e){t.setting.set(e?"repeat":"no-repeat")}),t.setting.bind(function(e){t.element.set("no-repeat"!==e)})}),Y.control("background_attachment",function(t){t.elements[0].unsync(Y("background_attachment")),t.element=new Y.Element(t.container.find("input")),t.element.set("fixed"!==t.setting()),t.element.bind(function(e){t.setting.set(e?"scroll":"fixed")}),t.setting.bind(function(e){t.element.set("fixed"!==e)})}),Y.control("display_header_text",function(t){var n="";t.elements[0].unsync(Y("header_textcolor")),t.element=new Y.Element(t.container.find("input")),t.element.set("blank"!==t.setting()),t.element.bind(function(e){e||(n=Y("header_textcolor").get()),t.setting.set(e?n:"blank")}),t.setting.bind(function(e){t.element.set("blank"!==e)})}),Y("show_on_front","page_on_front","page_for_posts",function(i,a,o){function e(){var e="show_on_front_page_collision",t=parseInt(a(),10),n=parseInt(o(),10);"page"===i()&&(this===a&&0<t&&Y.previewer.previewUrl.set(Y.settings.url.home),this===o)&&0<n&&Y.previewer.previewUrl.set(Y.settings.url.home+"?page_id="+n),"page"===i()&&t&&n&&t===n?i.notifications.add(new Y.Notification(e,{type:"error",message:Y.l10n.pageOnFrontError})):i.notifications.remove(e)}i.bind(e),a.bind(e),o.bind(e),e.call(i,i()),Y.control("show_on_front",function(e){e.deferred.embedded.done(function(){e.container.append(e.getNotificationsContainerElement())})})}),A=J.Deferred(),Y.section("custom_css",function(t){t.deferred.embedded.done(function(){t.expanded()?A.resolve(t):t.expanded.bind(function(e){e&&A.resolve(t)})})}),A.done(function(e){var t=Y.control("custom_css");t.container.find(".customize-control-title:first").addClass("screen-reader-text"),e.container.find(".section-description-buttons .section-description-close").on("click",function(){e.container.find(".section-meta .customize-section-description:first").removeClass("open").slideUp(),e.container.find(".customize-help-toggle").attr("aria-expanded","false").focus()}),t&&!t.setting.get()&&(e.container.find(".section-meta .customize-section-description:first").addClass("open").show().trigger("toggled"),e.container.find(".customize-help-toggle").attr("aria-expanded","true"))}),Y.control("header_video",function(n){n.deferred.embedded.done(function(){function e(){var e=Y.section(n.section()),t="video_header_not_available";e&&(n.active.get()?e.notifications.remove(t):e.notifications.add(new Y.Notification(t,{type:"info",message:Y.l10n.videoHeaderNotice})))}e(),n.active.bind(e)})}),Y.previewer.bind("selective-refresh-setting-validities",function(e){Y._handleSettingValidities({settingValidities:e,focusInvalidControl:!1})}),Y.previewer.bind("focus-control-for-setting",function(n){var i=[];Y.control.each(function(e){var t=_.pluck(e.settings,"id");-1!==_.indexOf(t,n)&&i.push(e)}),i.length&&(i.sort(function(e,t){return e.priority()-t.priority()}),i[0].focus())}),Y.previewer.bind("refresh",function(){Y.previewer.refresh()}),Y.state("paneVisible").bind(function(e){var t=window.matchMedia?window.matchMedia("screen and ( max-width: 640px )").matches:J(window).width()<=640;Y.state("editShortcutVisibility").set(e||t?"visible":"hidden")}),window.matchMedia&&window.matchMedia("screen and ( max-width: 640px )").addListener(function(){var e=Y.state("paneVisible");e.callbacks.fireWith(e,[e.get(),e.get()])}),Y.previewer.bind("edit-shortcut-visibility",function(e){Y.state("editShortcutVisibility").set(e)}),Y.state("editShortcutVisibility").bind(function(e){Y.previewer.send("edit-shortcut-visibility",e)}),Y.bind("change",function e(){var t,n,i,a=!1;function o(e){e||Y.settings.changeset.autosaved||(Y.settings.changeset.autosaved=!0,Y.previewer.send("autosaving"))}Y.unbind("change",e),Y.state("saved").bind(o),o(Y.state("saved").get()),n=function(){a||(a=!0,Y.requestChangesetUpdate({},{autosave:!0}).always(function(){a=!1})),i()},(i=function(){clearTimeout(t),t=setTimeout(function(){n()},Y.settings.timeouts.changesetAutoSave)})(),J(document).on("visibilitychange.wp-customize-changeset-update",function(){document.hidden&&n()}),J(window).on("beforeunload.wp-customize-changeset-update",function(){n()})}),J(document).one("tinymce-editor-setup",function(){window.tinymce.ui.FloatPanel&&(!window.tinymce.ui.FloatPanel.zIndex||window.tinymce.ui.FloatPanel.zIndex<500001)&&(window.tinymce.ui.FloatPanel.zIndex=500001)}),o.addClass("ready"),Y.trigger("ready"))})}((wp,jQuery));
\ No newline at end of file +!function(J){var a,s,t,e,n,i,Y=wp.customize,o=window.matchMedia("(prefers-reduced-motion: reduce)"),r=o.matches;o.addEventListener("change",function(e){r=e.matches}),Y.OverlayNotification=Y.Notification.extend({loading:!1,initialize:function(e,t){var n=this;Y.Notification.prototype.initialize.call(n,e,t),n.containerClasses+=" notification-overlay",n.loading&&(n.containerClasses+=" notification-loading")},render:function(){var e=Y.Notification.prototype.render.call(this);return e.on("keydown",_.bind(this.handleEscape,this)),e},handleEscape:function(e){var t=this;27===e.which&&(e.stopPropagation(),t.dismissible)&&t.parent&&t.parent.remove(t.code)}}),Y.Notifications=Y.Values.extend({alt:!1,defaultConstructor:Y.Notification,initialize:function(e){var t=this;Y.Values.prototype.initialize.call(t,e),_.bindAll(t,"constrainFocus"),t._addedIncrement=0,t._addedOrder={},t.bind("add",function(e){t.trigger("change",e)}),t.bind("removed",function(e){t.trigger("change",e)})},count:function(){return _.size(this._value)},add:function(e,t){var n,i=this,t="string"==typeof e?(n=e,t):(n=e.code,e);return i.has(n)||(i._addedIncrement+=1,i._addedOrder[n]=i._addedIncrement),Y.Values.prototype.add.call(i,n,t)},remove:function(e){return delete this._addedOrder[e],Y.Values.prototype.remove.call(this,e)},get:function(e){var a,o=this,t=_.values(o._value);return _.extend({sort:!1},e).sort&&(a={error:4,warning:3,success:2,info:1},t.sort(function(e,t){var n=0,i=0;return(n=_.isUndefined(a[e.type])?n:a[e.type])!==(i=_.isUndefined(a[t.type])?i:a[t.type])?i-n:o._addedOrder[t.code]-o._addedOrder[e.code]})),t},render:function(){var e,t,n,i=this,a=!1,o=[],s={};i.container&&i.container.length&&(e=i.get({sort:!0}),i.container.toggle(0!==e.length),i.container.is(i.previousContainer)&&_.isEqual(e,i.previousNotifications)||((n=i.container.children("ul").first()).length||(n=J("<ul></ul>"),i.container.append(n)),n.find("> [data-code]").remove(),_.each(i.previousNotifications,function(e){s[e.code]=e}),_.each(e,function(e){var t;!wp.a11y||s[e.code]&&_.isEqual(e.message,s[e.code].message)||wp.a11y.speak(e.message,"assertive"),t=J(e.render()),e.container=t,n.append(t),e.extended(Y.OverlayNotification)&&o.push(e)}),(t=Boolean(o.length))!==(a=i.previousNotifications?Boolean(_.find(i.previousNotifications,function(e){return e.extended(Y.OverlayNotification)})):a)&&(J(document.body).toggleClass("customize-loading",t),i.container.toggleClass("has-overlay-notifications",t),t?(i.previousActiveElement=document.activeElement,J(document).on("keydown",i.constrainFocus)):J(document).off("keydown",i.constrainFocus)),t?(i.focusContainer=o[o.length-1].container,i.focusContainer.prop("tabIndex",-1),((a=i.focusContainer.find(":focusable")).length?a.first():i.focusContainer).focus()):i.previousActiveElement&&(J(i.previousActiveElement).trigger("focus"),i.previousActiveElement=null),i.previousNotifications=e,i.previousContainer=i.container,i.trigger("rendered")))},constrainFocus:function(e){var t,n=this;e.stopPropagation(),9===e.which&&(0===(t=n.focusContainer.find(":focusable")).length&&(t=n.focusContainer),!J.contains(n.focusContainer[0],e.target)||!J.contains(n.focusContainer[0],document.activeElement)||t.last().is(e.target)&&!e.shiftKey?(e.preventDefault(),t.first().focus()):t.first().is(e.target)&&e.shiftKey&&(e.preventDefault(),t.last().focus()))}}),Y.Setting=Y.Value.extend({defaults:{transport:"refresh",dirty:!1},initialize:function(e,t,n){var i=this,n=_.extend({previewer:Y.previewer},i.defaults,n||{});Y.Value.prototype.initialize.call(i,t,n),i.id=e,i._dirty=n.dirty,i.notifications=new Y.Notifications,i.bind(i.preview)},preview:function(){var e=this,t=e.transport;"postMessage"===(t="postMessage"!==t||Y.state("previewerAlive").get()?t:"refresh")?e.previewer.send("setting",[e.id,e()]):"refresh"===t&&e.previewer.refresh()},findControls:function(){var n=this,i=[];return Y.control.each(function(t){_.each(t.settings,function(e){e.id===n.id&&i.push(t)})}),i}}),Y._latestRevision=0,Y._lastSavedRevision=0,Y._latestSettingRevisions={},Y.bind("change",function(e){Y._latestRevision+=1,Y._latestSettingRevisions[e.id]=Y._latestRevision}),Y.bind("ready",function(){Y.bind("add",function(e){e._dirty&&(Y._latestRevision+=1,Y._latestSettingRevisions[e.id]=Y._latestRevision)})}),Y.dirtyValues=function(n){var i={};return Y.each(function(e){var t;e._dirty&&(t=Y._latestSettingRevisions[e.id],Y.state("changesetStatus").get()&&n&&n.unsaved&&(_.isUndefined(t)||t<=Y._lastSavedRevision)||(i[e.id]=e.get()))}),i},Y.requestChangesetUpdate=function(n,e){var t,i={},a=new J.Deferred;if(0!==Y.state("processing").get())a.reject("already_processing");else if(e=_.extend({title:null,date:null,autosave:!1,force:!1},e),n&&_.extend(i,n),_.each(Y.dirtyValues({unsaved:!0}),function(e,t){n&&null===n[t]||(i[t]=_.extend({},i[t]||{},{value:e}))}),Y.trigger("changeset-save",i,e),!e.force&&_.isEmpty(i)&&null===e.title&&null===e.date)a.resolve({});else{if(e.status)return a.reject({code:"illegal_status_in_changeset_update"}).promise();if(e.date&&e.autosave)return a.reject({code:"illegal_autosave_with_date_gmt"}).promise();Y.state("processing").set(Y.state("processing").get()+1),a.always(function(){Y.state("processing").set(Y.state("processing").get()-1)}),delete(t=Y.previewer.query({excludeCustomizedSaved:!0})).customized,_.extend(t,{nonce:Y.settings.nonce.save,customize_theme:Y.settings.theme.stylesheet,customize_changeset_data:JSON.stringify(i)}),null!==e.title&&(t.customize_changeset_title=e.title),null!==e.date&&(t.customize_changeset_date=e.date),!1!==e.autosave&&(t.customize_changeset_autosave="true"),Y.trigger("save-request-params",t),(e=wp.ajax.post("customize_save",t)).done(function(e){var n={};Y._lastSavedRevision=Math.max(Y._latestRevision,Y._lastSavedRevision),Y.state("changesetStatus").set(e.changeset_status),e.changeset_date&&Y.state("changesetDate").set(e.changeset_date),a.resolve(e),Y.trigger("changeset-saved",e),e.setting_validities&&_.each(e.setting_validities,function(e,t){!0===e&&_.isObject(i[t])&&!_.isUndefined(i[t].value)&&(n[t]=i[t].value)}),Y.previewer.send("changeset-saved",_.extend({},e,{saved_changeset_values:n}))}),e.fail(function(e){a.reject(e),Y.trigger("changeset-error",e)}),e.always(function(e){e.setting_validities&&Y._handleSettingValidities({settingValidities:e.setting_validities})})}return a.promise()},Y.utils.bubbleChildValueChanges=function(n,e){J.each(e,function(e,t){n[t].bind(function(e,t){n.parent&&e!==t&&n.parent.trigger("change",n)})})},o=function(e){var t,n,i=this,a=function(){var e;i.extended(Y.Panel)&&1<(n=i.sections()).length&&n.forEach(function(e){e.expanded()&&e.collapse()}),e=(i.extended(Y.Panel)||i.extended(Y.Section))&&i.expanded&&i.expanded()?i.contentContainer:i.container,(n=0===(n=e.find(".control-focus:first")).length?e.find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first():n).focus()};(e=e||{}).completeCallback?(t=e.completeCallback,e.completeCallback=function(){a(),t()}):e.completeCallback=a,Y.state("paneVisible").set(!0),i.expand?i.expand(e):e.completeCallback()},Y.utils.prioritySort=function(e,t){return e.priority()===t.priority()&&"number"==typeof e.params.instanceNumber&&"number"==typeof t.params.instanceNumber?e.params.instanceNumber-t.params.instanceNumber:e.priority()-t.priority()},Y.utils.isKeydownButNotEnterEvent=function(e){return"keydown"===e.type&&13!==e.which},Y.utils.areElementListsEqual=function(e,t){return e.length===t.length&&-1===_.indexOf(_.map(_.zip(e,t),function(e){return J(e[0]).is(e[1])}),!1)},Y.utils.highlightButton=function(e,t){var n,i="button-see-me",a=!1;function o(){a=!0}return(n=_.extend({delay:0,focusTarget:e},t)).focusTarget.on("focusin",o),setTimeout(function(){n.focusTarget.off("focusin",o),a||(e.addClass(i),e.one("animationend",function(){e.removeClass(i)}))},n.delay),o},Y.utils.getCurrentTimestamp=function(){var e=_.now(),t=new Date(Y.settings.initialServerDate.replace(/-/g,"/")),e=e-Y.settings.initialClientTimestamp;return e+=Y.settings.initialClientTimestamp-Y.settings.initialServerTimestamp,t.setTime(t.getTime()+e),t.getTime()},Y.utils.getRemainingTime=function(e){e=e instanceof Date?e.getTime():"string"==typeof e?new Date(e.replace(/-/g,"/")).getTime():e,e-=Y.utils.getCurrentTimestamp();return Math.ceil(e/1e3)},t=document.createElement("div"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"},n=_.find(_.keys(e),function(e){return!_.isUndefined(t.style[e])}),s=n?e[n]:null,a=Y.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:J.noop},defaultExpandedArguments:{duration:"fast",completeCallback:J.noop},containerType:"container",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null},initialize:function(e,t){var n=this;n.id=e,a.instanceCounter||(a.instanceCounter=0),a.instanceCounter++,J.extend(n,{params:_.defaults(t.params||t,n.defaults)}),n.params.instanceNumber||(n.params.instanceNumber=a.instanceCounter),n.notifications=new Y.Notifications,n.templateSelector=n.params.templateId||"customize-"+n.containerType+"-"+n.params.type,n.container=J(n.params.content),0===n.container.length&&(n.container=J(n.getContainer())),n.headContainer=n.container,n.contentContainer=n.getContent(),n.container=n.container.add(n.contentContainer),n.deferred={embedded:new J.Deferred},n.priority=new Y.Value,n.active=new Y.Value,n.activeArgumentsQueue=[],n.expanded=new Y.Value,n.expandedArgumentsQueue=[],n.active.bind(function(e){var t=n.activeArgumentsQueue.shift(),t=J.extend({},n.defaultActiveArguments,t);e=e&&n.isContextuallyActive(),n.onChangeActive(e,t)}),n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift(),t=J.extend({},n.defaultExpandedArguments,t);n.onChangeExpanded(e,t)}),n.deferred.embedded.done(function(){n.setupNotifications(),n.attachEvents()}),Y.utils.bubbleChildValueChanges(n,["priority","active"]),n.priority.set(n.params.priority),n.active.set(n.params.active),n.expanded.set(!1)},getNotificationsContainerElement:function(){return this.contentContainer.find(".customize-control-notifications-container:first")},setupNotifications:function(){var e,t=this;t.notifications.container=t.getNotificationsContainerElement(),t.expanded.bind(e=function(){t.expanded.get()&&t.notifications.render()}),e(),t.notifications.bind("change",_.debounce(e))},ready:function(){},_children:function(t,e){var n=this,i=[];return Y[e].each(function(e){e[t].get()===n.id&&i.push(e)}),i.sort(Y.utils.prioritySort),i},isContextuallyActive:function(){throw new Error("Container.isContextuallyActive() must be overridden in a subclass.")},onChangeActive:function(e,t){var n,i=this,a=i.headContainer;t.unchanged?t.completeCallback&&t.completeCallback():(n="resolved"===Y.previewer.deferred.active.state()?t.duration:0,i.extended(Y.Panel)&&(Y.panel.each(function(e){e!==i&&e.expanded()&&(n=0)}),e||_.each(i.sections(),function(e){e.collapse({duration:0})})),J.contains(document,a.get(0))?e?a.slideDown(n,t.completeCallback):i.expanded()?i.collapse({duration:n,completeCallback:function(){a.slideUp(n,t.completeCallback)}}):a.slideUp(n,t.completeCallback):(a.toggle(e),t.completeCallback&&t.completeCallback()))},_toggleActive:function(e,t){return t=t||{},e&&this.active.get()||!e&&!this.active.get()?(t.unchanged=!0,this.onChangeActive(this.active.get(),t),!1):(t.unchanged=!1,this.activeArgumentsQueue.push(t),this.active.set(e),!0)},activate:function(e){return this._toggleActive(!0,e)},deactivate:function(e){return this._toggleActive(!1,e)},onChangeExpanded:function(){throw new Error("Must override with subclass.")},_toggleExpanded:function(e,t){var n,i=this;return n=(t=t||{}).completeCallback,!(e&&!i.active()||(Y.state("paneVisible").set(!0),t.completeCallback=function(){n&&n.apply(i,arguments),e?i.container.trigger("expanded"):i.container.trigger("collapsed")},e&&i.expanded.get()||!e&&!i.expanded.get()?(t.unchanged=!0,i.onChangeExpanded(i.expanded.get(),t),1):(t.unchanged=!1,i.expandedArgumentsQueue.push(t),i.expanded.set(e),0)))},expand:function(e){return this._toggleExpanded(!0,e)},collapse:function(e){return this._toggleExpanded(!1,e)},_animateChangeExpanded:function(t){var a,o,n,i;!s||r?_.defer(function(){t&&t()}):(o=(a=this).contentContainer,i=o.closest(".wp-full-overlay").add(o),a.panel&&""!==a.panel()&&!Y.panel(a.panel()).contentContainer.hasClass("skip-transition")||(i=i.add("#customize-info, .customize-pane-parent")),n=function(e){2===e.eventPhase&&J(e.target).is(o)&&(o.off(s,n),i.removeClass("busy"),t)&&t()},o.on(s,n),i.addClass("busy"),_.defer(function(){var e=o.closest(".wp-full-overlay-sidebar-content"),t=e.scrollTop(),n=o.data("previous-scrollTop")||0,i=a.expanded();i&&0<t?(o.css("top",t+"px"),o.data("previous-scrollTop",t)):!i&&0<t+n&&(o.css("top",n-t+"px"),e.scrollTop(n))}))},focus:o,getContainer:function(){var e=this,t=0!==J("#tmpl-"+e.templateSelector).length?wp.template(e.templateSelector):wp.template("customize-"+e.containerType+"-default");return t&&e.container?t(_.extend({id:e.id},e.params)).toString().trim():"<li></li>"},getContent:function(){var e=this.container,t=e.find(".accordion-section-content, .control-panel-content").first(),n="sub-"+e.attr("id"),i=n,a=e.attr("aria-owns");return e.attr("aria-owns",i=a?i+" "+a:i),t.detach().attr({id:n,class:"customize-pane-child "+t.attr("class")+" "+e.attr("class")})}}),Y.Section=a.extend({containerType:"section",containerParent:"#customize-theme-controls",containerPaneParent:".customize-pane-parent",defaults:{title:"",description:"",priority:100,type:"default",content:null,active:!0,instanceNumber:null,panel:null,customizeAction:""},initialize:function(e,t){var n=this,i=t.params||t;i.type||_.find(Y.sectionConstructor,function(e,t){return e===n.constructor&&(i.type=t,!0)}),a.prototype.initialize.call(n,e,i),n.id=e,n.panel=new Y.Value,n.panel.bind(function(e){J(n.headContainer).toggleClass("control-subsection",!!e)}),n.panel.set(n.params.panel||""),Y.utils.bubbleChildValueChanges(n,["panel"]),n.embed(),n.deferred.embedded.done(function(){n.ready()})},embed:function(){var e,n=this;n.containerParent=Y.ensure(n.containerParent),n.panel.bind(e=function(e){var t;e?Y.panel(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer,n.headContainer.parent().is(t)||t.append(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve()})}):(t=Y.ensure(n.containerPaneParent),n.headContainer.parent().is(t)||t.append(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve())}),e(n.panel.get())},attachEvents:function(){var e,t,n=this;n.container.hasClass("cannot-expand")||(n.container.find(".accordion-section-title, .customize-section-back").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()?n.collapse():n.expand())}),n.container.find(".customize-section-title .customize-help-toggle").on("click",function(){(e=n.container.find(".section-meta")).hasClass("cannot-expand")||((t=e.find(".customize-section-description:first")).toggleClass("open"),t.slideToggle(n.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),J(this).attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}))}))},isContextuallyActive:function(){var e=this.controls(),t=0;return _(e).each(function(e){e.active()&&(t+=1)}),0!==t},controls:function(){return this._children("section","control")},onChangeExpanded:function(e,t){var n,i=this,a=i.headContainer.closest(".wp-full-overlay-sidebar-content"),o=i.contentContainer,s=i.headContainer.closest(".wp-full-overlay"),r=o.find(".customize-section-back"),c=i.headContainer.find(".accordion-section-title").first();e&&!o.hasClass("open")?(n=t.unchanged?t.completeCallback:function(){i._animateChangeExpanded(function(){c.attr("tabindex","-1"),r.attr("tabindex","0"),r.trigger("focus"),o.css("top",""),a.scrollTop(0),t.completeCallback&&t.completeCallback()}),o.addClass("open"),s.addClass("section-open"),Y.state("expandedSection").set(i)}.bind(this),t.allowMultiple||Y.section.each(function(e){e!==i&&e.collapse({duration:t.duration})}),i.panel()?Y.panel(i.panel()).expand({duration:t.duration,completeCallback:n}):(t.allowMultiple||Y.panel.each(function(e){e.collapse()}),n())):!e&&o.hasClass("open")?(i.panel()&&(n=Y.panel(i.panel())).contentContainer.hasClass("skip-transition")&&n.collapse(),i._animateChangeExpanded(function(){r.attr("tabindex","-1"),c.attr("tabindex","0"),c.trigger("focus"),o.css("top",""),t.completeCallback&&t.completeCallback()}),o.removeClass("open"),s.removeClass("section-open"),i===Y.state("expandedSection").get()&&Y.state("expandedSection").set(!1)):t.completeCallback&&t.completeCallback()}}),Y.ThemesSection=Y.Section.extend({currentTheme:"",overlay:"",template:"",screenshotQueue:null,$window:null,$body:null,loaded:0,loading:!1,fullyLoaded:!1,term:"",tags:"",nextTerm:"",nextTags:"",filtersHeight:0,headerContainer:null,updateCountDebounced:null,initialize:function(e,t){var n=this;n.headerContainer=J(),n.$window=J(window),n.$body=J(document.body),Y.Section.prototype.initialize.call(n,e,t),n.updateCountDebounced=_.debounce(n.updateCount,500)},embed:function(){var n=this,e=function(e){var t;Y.panel(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer,n.headContainer.parent().is(t)||t.find(".customize-themes-full-container-container").before(n.headContainer),n.contentContainer.parent().is(n.headContainer)||n.containerParent.append(n.contentContainer),n.deferred.embedded.resolve()})})};n.panel.bind(e),e(n.panel.get())},ready:function(){var t=this;t.overlay=t.container.find(".theme-overlay"),t.template=wp.template("customize-themes-details-view"),t.container.on("keydown",function(e){t.overlay.find(".theme-wrap").is(":visible")&&(39===e.keyCode&&t.nextTheme(),37===e.keyCode&&t.previousTheme(),27===e.keyCode)&&(t.$body.hasClass("modal-open")?t.closeDetails():t.headerContainer.find(".customize-themes-section-title").focus(),e.stopPropagation())}),t.renderScreenshots=_.throttle(t.renderScreenshots,100),_.bindAll(t,"renderScreenshots","loadMore","checkTerm","filtersChecked")},isContextuallyActive:function(){return this.active()},attachEvents:function(){var e,n=this;function t(){var e=n.headerContainer.find(".customize-themes-section-title");e.toggleClass("selected",n.expanded()),e.attr("aria-expanded",n.expanded()?"true":"false"),n.expanded()||e.removeClass("details-open")}n.container.find(".customize-section-back").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.collapse())}),n.headerContainer=J("#accordion-section-"+n.id),n.headerContainer.on("click",".customize-themes-section-title",function(){n.headerContainer.find(".filter-details").length&&(n.headerContainer.find(".customize-themes-section-title").toggleClass("details-open").attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}),n.headerContainer.find(".filter-details").slideToggle(180)),n.expanded()||n.expand()}),n.container.on("click",".theme-actions .preview-theme",function(){Y.panel("themes").loadThemePreview(J(this).data("slug"))}),n.container.on("click",".left",function(){n.previousTheme()}),n.container.on("click",".right",function(){n.nextTheme()}),n.container.on("click",".theme-backdrop, .close",function(){n.closeDetails()}),"local"===n.params.filter_type?n.container.on("input",".wp-filter-search-themes",function(e){n.filterSearch(e.currentTarget.value)}):"remote"===n.params.filter_type&&(e=_.debounce(n.checkTerm,500),n.contentContainer.on("input",".wp-filter-search",function(){Y.panel("themes").expanded()&&(e(n),n.expanded()||n.expand())}),n.contentContainer.on("click",".filter-group input",function(){n.filtersChecked(),n.checkTerm(n)})),n.contentContainer.on("click",".feature-filter-toggle",function(e){var t=J(".customize-themes-full-container"),e=J(e.currentTarget);n.filtersHeight=e.parents(".themes-filter-bar").next(".filter-drawer").height(),0<t.scrollTop()&&(t.animate({scrollTop:0},400),e.hasClass("open"))||(e.toggleClass("open").attr("aria-expanded",function(e,t){return"true"===t?"false":"true"}).parents(".themes-filter-bar").next(".filter-drawer").slideToggle(180,"linear"),e.hasClass("open")?(t=1018<window.innerWidth?50:76,n.contentContainer.find(".themes").css("margin-top",n.filtersHeight+t)):n.contentContainer.find(".themes").css("margin-top",0))}),n.contentContainer.on("click",".no-themes-local .search-dotorg-themes",function(){Y.section("wporg_themes").focus()}),n.expanded.bind(t),t(),Y.bind("ready",function(){n.contentContainer=n.container.find(".customize-themes-section"),n.contentContainer.appendTo(J(".customize-themes-full-container")),n.container.add(n.headerContainer)})},onChangeExpanded:function(e,n){var i=this,t=i.contentContainer.closest(".customize-themes-full-container");function a(){0===i.loaded&&i.loadThemes(),Y.section.each(function(e){var t;e!==i&&"themes"===e.params.type&&(t=e.contentContainer.find(".wp-filter-search").val(),i.contentContainer.find(".wp-filter-search").val(t),""===t&&""!==i.term&&"local"!==i.params.filter_type?(i.term="",i.initializeNewQuery(i.term,i.tags)):"remote"===i.params.filter_type?i.checkTerm(i):"local"===i.params.filter_type&&i.filterSearch(t),e.collapse({duration:n.duration}))}),i.contentContainer.addClass("current-section"),t.scrollTop(),t.on("scroll",_.throttle(i.renderScreenshots,300)),t.on("scroll",_.throttle(i.loadMore,300)),n.completeCallback&&n.completeCallback(),i.updateCount()}n.unchanged?n.completeCallback&&n.completeCallback():e?i.panel()&&Y.panel.has(i.panel())?Y.panel(i.panel()).expand({duration:n.duration,completeCallback:a}):a():(i.contentContainer.removeClass("current-section"),i.headerContainer.find(".filter-details").slideUp(180),t.off("scroll"),n.completeCallback&&n.completeCallback())},getContent:function(){return this.container.find(".control-section-content")},loadThemes:function(){var n,e,i=this;i.loading||(n=Math.ceil(i.loaded/100)+1,e={nonce:Y.settings.nonce.switch_themes,wp_customize:"on",theme_action:i.params.action,customized_theme:Y.settings.theme.stylesheet,page:n},"remote"===i.params.filter_type&&(e.search=i.term,e.tags=i.tags),i.headContainer.closest(".wp-full-overlay").addClass("loading"),i.loading=!0,i.container.find(".no-themes").hide(),(e=wp.ajax.post("customize_load_themes",e)).done(function(e){var t=e.themes;""!==i.nextTerm||""!==i.nextTags?(i.nextTerm&&(i.term=i.nextTerm),i.nextTags&&(i.tags=i.nextTags),i.nextTerm="",i.nextTags="",i.loading=!1,i.loadThemes()):(0!==t.length?(i.loadControls(t,n),1===n&&(_.each(i.controls().slice(0,3),function(e){e=e.params.theme.screenshot[0];e&&((new Image).src=e)}),"local"!==i.params.filter_type)&&wp.a11y.speak(Y.settings.l10n.themeSearchResults.replace("%d",e.info.results)),_.delay(i.renderScreenshots,100),("local"===i.params.filter_type||t.length<100)&&(i.fullyLoaded=!0)):0===i.loaded?(i.container.find(".no-themes").show(),wp.a11y.speak(i.container.find(".no-themes").text())):i.fullyLoaded=!0,"local"===i.params.filter_type?i.updateCount():i.updateCount(e.info.results),i.container.find(".unexpected-error").hide(),i.headContainer.closest(".wp-full-overlay").removeClass("loading"),i.loading=!1)}),e.fail(function(e){void 0===e?(i.container.find(".unexpected-error").show(),wp.a11y.speak(i.container.find(".unexpected-error").text())):"undefined"!=typeof console&&console.error&&console.error(e),i.headContainer.closest(".wp-full-overlay").removeClass("loading"),i.loading=!1}))},loadControls:function(e,t){var n=[],i=this;_.each(e,function(e){e=new Y.controlConstructor.theme(i.params.action+"_theme_"+e.id,{type:"theme",section:i.params.id,theme:e,priority:i.loaded+1});Y.control.add(e),n.push(e),i.loaded=i.loaded+1}),1!==t&&Array.prototype.push.apply(i.screenshotQueue,n)},loadMore:function(){var e,t;this.fullyLoaded||this.loading||(t=(e=this.container.closest(".customize-themes-full-container")).scrollTop()+e.height(),e.prop("scrollHeight")-3e3<t&&this.loadThemes())},filterSearch:function(e){var t,n=0,i=this,a=Y.section.has("wporg_themes")&&"remote"!==i.params.filter_type?".no-themes-local":".no-themes",o=i.controls();i.loading||(t=e.toLowerCase().trim().replace(/-/g," ").split(" "),_.each(o,function(e){e.filter(t)&&(n+=1)}),0===n?(i.container.find(a).show(),wp.a11y.speak(i.container.find(a).text())):i.container.find(a).hide(),i.renderScreenshots(),Y.reflowPaneContents(),i.updateCountDebounced(n))},checkTerm:function(e){var t;"remote"===e.params.filter_type&&(t=e.contentContainer.find(".wp-filter-search").val(),e.term!==t.trim())&&e.initializeNewQuery(t,e.tags)},filtersChecked:function(){var e=this,t=e.container.find(".filter-group").find(":checkbox"),n=[];_.each(t.filter(":checked"),function(e){n.push(J(e).prop("value"))}),0===n.length?(n="",e.contentContainer.find(".feature-filter-toggle .filter-count-0").show(),e.contentContainer.find(".feature-filter-toggle .filter-count-filters").hide()):(e.contentContainer.find(".feature-filter-toggle .theme-filter-count").text(n.length),e.contentContainer.find(".feature-filter-toggle .filter-count-0").hide(),e.contentContainer.find(".feature-filter-toggle .filter-count-filters").show()),_.isEqual(e.tags,n)||(e.loading?e.nextTags=n:"remote"===e.params.filter_type?e.initializeNewQuery(e.term,n):"local"===e.params.filter_type&&e.filterSearch(n.join(" ")))},initializeNewQuery:function(e,t){var n=this;_.each(n.controls(),function(e){e.container.remove(),Y.control.remove(e.id)}),n.loaded=0,n.fullyLoaded=!1,n.screenshotQueue=null,n.loading?(n.nextTerm=e,n.nextTags=t):(n.term=e,n.tags=t,n.loadThemes()),n.expanded()||n.expand()},renderScreenshots:function(){var o=this;null!==o.screenshotQueue&&0!==o.screenshotQueue.length||(o.screenshotQueue=_.filter(o.controls(),function(e){return!e.screenshotRendered})),o.screenshotQueue.length&&(o.screenshotQueue=_.filter(o.screenshotQueue,function(e){var t,n,i=e.container.find(".theme-screenshot"),a=i.find("img");return!(!a.length||!a.is(":hidden")&&(t=(n=o.$window.scrollTop())+o.$window.height(),a=a.offset().top,(n=n-(i=3*(n=i.height()))<=a+n&&a<=t+i)&&e.container.trigger("render-screenshot"),n))}))},getVisibleCount:function(){return this.contentContainer.find("li.customize-control:visible").length},updateCount:function(e){var t,n;e||0===e||(e=this.getVisibleCount()),n=this.contentContainer.find(".themes-displayed"),t=this.contentContainer.find(".theme-count"),0===e?t.text("0"):(n.fadeOut(180,function(){t.text(e),n.fadeIn(180)}),wp.a11y.speak(Y.settings.l10n.announceThemeCount.replace("%d",e)))},nextTheme:function(){var e=this;e.getNextTheme()&&e.showDetails(e.getNextTheme(),function(){e.overlay.find(".right").focus()})},getNextTheme:function(){var e=Y.control(this.params.action+"_theme_"+this.currentTheme),t=this.controls(),e=_.indexOf(t,e);return-1!==e&&!!(t=t[e+1])&&t.params.theme},previousTheme:function(){var e=this;e.getPreviousTheme()&&e.showDetails(e.getPreviousTheme(),function(){e.overlay.find(".left").focus()})},getPreviousTheme:function(){var e=Y.control(this.params.action+"_theme_"+this.currentTheme),t=this.controls(),e=_.indexOf(t,e);return-1!==e&&!!(t=t[e-1])&&t.params.theme},updateLimits:function(){this.getNextTheme()||this.overlay.find(".right").addClass("disabled"),this.getPreviousTheme()||this.overlay.find(".left").addClass("disabled")},loadThemePreview:function(e){return Y.ThemesPanel.prototype.loadThemePreview.call(this,e)},showDetails:function(e,t){var n=this,i=Y.panel("themes");function a(){return!i.canSwitchTheme(e.id)}n.currentTheme=e.id,n.overlay.html(n.template(e)).fadeIn("fast").focus(),n.overlay.find("button.preview, button.preview-theme").toggleClass("disabled",a()),n.overlay.find("button.theme-install").toggleClass("disabled",a()||!1===Y.settings.theme._canInstall||!0===Y.settings.theme._filesystemCredentialsNeeded),n.$body.addClass("modal-open"),n.containFocus(n.overlay),n.updateLimits(),wp.a11y.speak(Y.settings.l10n.announceThemeDetails.replace("%s",e.name)),t&&t()},closeDetails:function(){this.$body.removeClass("modal-open"),this.overlay.fadeOut("fast"),Y.control(this.params.action+"_theme_"+this.currentTheme).container.find(".theme").focus()},containFocus:function(t){var n;t.on("keydown",function(e){if(9===e.keyCode)return(n=J(":tabbable",t)).last()[0]!==e.target||e.shiftKey?n.first()[0]===e.target&&e.shiftKey?(n.last().focus(),!1):void 0:(n.first().focus(),!1)})}}),Y.OuterSection=Y.Section.extend({initialize:function(){this.containerParent="#customize-outer-theme-controls",this.containerPaneParent=".customize-outer-pane-parent",Y.Section.prototype.initialize.apply(this,arguments)},onChangeExpanded:function(e,t){var n,i=this,a=i.headContainer.closest(".wp-full-overlay-sidebar-content"),o=i.contentContainer,s=o.find(".customize-section-back"),r=i.headContainer.find(".accordion-section-title").first();J(document.body).toggleClass("outer-section-open",e),i.container.toggleClass("open",e),i.container.removeClass("busy"),Y.section.each(function(e){"outer"===e.params.type&&e.id!==i.id&&e.container.removeClass("open")}),e&&!o.hasClass("open")?(n=t.unchanged?t.completeCallback:function(){i._animateChangeExpanded(function(){r.attr("tabindex","-1"),s.attr("tabindex","0"),s.trigger("focus"),o.css("top",""),a.scrollTop(0),t.completeCallback&&t.completeCallback()}),o.addClass("open")}.bind(this),i.panel()?Y.panel(i.panel()).expand({duration:t.duration,completeCallback:n}):n()):!e&&o.hasClass("open")?(i.panel()&&(n=Y.panel(i.panel())).contentContainer.hasClass("skip-transition")&&n.collapse(),i._animateChangeExpanded(function(){s.attr("tabindex","-1"),r.attr("tabindex","0"),r.trigger("focus"),o.css("top",""),t.completeCallback&&t.completeCallback()}),o.removeClass("open")):t.completeCallback&&t.completeCallback()}}),Y.Panel=a.extend({containerType:"panel",initialize:function(e,t){var n=this,i=t.params||t;i.type||_.find(Y.panelConstructor,function(e,t){return e===n.constructor&&(i.type=t,!0)}),a.prototype.initialize.call(n,e,i),n.embed(),n.deferred.embedded.done(function(){n.ready()})},embed:function(){var e=this,t=J("#customize-theme-controls"),n=J(".customize-pane-parent");e.headContainer.parent().is(n)||n.append(e.headContainer),e.contentContainer.parent().is(e.headContainer)||t.append(e.contentContainer),e.renderContent(),e.deferred.embedded.resolve()},attachEvents:function(){var t,n=this;n.headContainer.find(".accordion-section-title").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded())||n.expand()}),n.container.find(".customize-panel-back").on("click keydown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),n.expanded()&&n.collapse())}),(t=n.container.find(".panel-meta:first")).find("> .accordion-section-title .customize-help-toggle").on("click",function(){var e;t.hasClass("cannot-expand")||(e=t.find(".customize-panel-description:first"),t.hasClass("open")?(t.toggleClass("open"),e.slideUp(n.defaultExpandedArguments.duration,function(){e.trigger("toggled")}),J(this).attr("aria-expanded",!1)):(e.slideDown(n.defaultExpandedArguments.duration,function(){e.trigger("toggled")}),t.toggleClass("open"),J(this).attr("aria-expanded",!0)))})},sections:function(){return this._children("panel","section")},isContextuallyActive:function(){var e=this.sections(),t=0;return _(e).each(function(e){e.active()&&e.isContextuallyActive()&&(t+=1)}),0!==t},onChangeExpanded:function(e,t){var n,i,a,o,s,r,c;t.unchanged?t.completeCallback&&t.completeCallback():(a=(i=(n=this).contentContainer).closest(".wp-full-overlay"),o=i.closest(".wp-full-overlay-sidebar-content"),s=n.headContainer.find(".accordion-section-title"),r=i.find(".customize-panel-back"),c=n.sections(),e&&!i.hasClass("current-panel")?(Y.section.each(function(e){n.id!==e.panel()&&e.collapse({duration:0})}),Y.panel.each(function(e){n!==e&&e.collapse({duration:0})}),n.params.autoExpandSoleSection&&1===c.length&&c[0].active.get()?(i.addClass("current-panel skip-transition"),a.addClass("in-sub-panel"),c[0].expand({completeCallback:t.completeCallback})):(n._animateChangeExpanded(function(){s.attr("tabindex","-1"),r.attr("tabindex","0"),r.trigger("focus"),i.css("top",""),o.scrollTop(0),t.completeCallback&&t.completeCallback()}),i.addClass("current-panel"),a.addClass("in-sub-panel")),Y.state("expandedPanel").set(n)):!e&&i.hasClass("current-panel")&&(i.hasClass("skip-transition")?i.removeClass("skip-transition"):n._animateChangeExpanded(function(){s.attr("tabindex","0"),r.attr("tabindex","-1"),s.focus(),i.css("top",""),t.completeCallback&&t.completeCallback()}),a.removeClass("in-sub-panel"),i.removeClass("current-panel"),n===Y.state("expandedPanel").get())&&Y.state("expandedPanel").set(!1))},renderContent:function(){var e=this,t=0!==J("#tmpl-"+e.templateSelector+"-content").length?wp.template(e.templateSelector+"-content"):wp.template("customize-panel-default-content");t&&e.headContainer&&e.contentContainer.html(t(_.extend({id:e.id},e.params)))}}),Y.ThemesPanel=Y.Panel.extend({initialize:function(e,t){this.installingThemes=[],Y.Panel.prototype.initialize.call(this,e,t)},canSwitchTheme:function(e){return!(!e||e!==Y.settings.theme.stylesheet)||"publish"===Y.state("selectedChangesetStatus").get()&&(""===Y.state("changesetStatus").get()||"auto-draft"===Y.state("changesetStatus").get())},attachEvents:function(){var t=this;function e(){t.canSwitchTheme()?t.notifications.remove("theme_switch_unavailable"):t.notifications.add(new Y.Notification("theme_switch_unavailable",{message:Y.l10n.themePreviewUnavailable,type:"warning"}))}Y.Panel.prototype.attachEvents.apply(t),Y.settings.theme._canInstall&&Y.settings.theme._filesystemCredentialsNeeded&&t.notifications.add(new Y.Notification("theme_install_unavailable",{message:Y.l10n.themeInstallUnavailable,type:"info",dismissible:!0})),e(),Y.state("selectedChangesetStatus").bind(e),Y.state("changesetStatus").bind(e),t.contentContainer.on("click",".customize-theme",function(){t.collapse()}),t.contentContainer.on("click",".customize-themes-section-title, .customize-themes-mobile-back",function(){J(".wp-full-overlay").toggleClass("showing-themes")}),t.contentContainer.on("click",".theme-install",function(e){t.installTheme(e)}),t.contentContainer.on("click",".update-theme, #update-theme",function(e){e.preventDefault(),e.stopPropagation(),t.updateTheme(e)}),t.contentContainer.on("click",".delete-theme",function(e){t.deleteTheme(e)}),_.bindAll(t,"installTheme","updateTheme")},onChangeExpanded:function(e,t){var n,i=!1;Y.Panel.prototype.onChangeExpanded.apply(this,[e,t]),t.unchanged?t.completeCallback&&t.completeCallback():(n=this.headContainer.closest(".wp-full-overlay"),e?(n.addClass("in-themes-panel").delay(200).find(".customize-themes-full-container").addClass("animate"),_.delay(function(){n.addClass("themes-panel-expanded")},200),600<window.innerWidth&&(t=this.sections(),_.each(t,function(e){e.expanded()&&(i=!0)}),!i)&&0<t.length&&t[0].expand()):n.removeClass("in-themes-panel themes-panel-expanded").find(".customize-themes-full-container").removeClass("animate"))},installTheme:function(e){var t,i=this,a=J(e.target).data("slug"),o=J.Deferred(),s=J(e.target).hasClass("preview");return Y.settings.theme._filesystemCredentialsNeeded?o.reject({errorCode:"theme_install_unavailable"}):i.canSwitchTheme(a)?_.contains(i.installingThemes,a)?o.reject({errorCode:"theme_already_installing"}):(wp.updates.maybeRequestFilesystemCredentials(e),e=function(t){var e,n=!1;if(s)Y.notifications.remove("theme_installing"),i.loadThemePreview(a);else{if(Y.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t.slug&&(n=e.params.theme,e.rerenderAsInstalled(!0))}),!n||Y.control.has("installed_theme_"+n.id))return void o.resolve(t);n.type="installed",e=new Y.controlConstructor.theme("installed_theme_"+n.id,{type:"theme",section:"installed_themes",theme:n,priority:0}),Y.control.add(e),Y.control(e.id).container.trigger("render-screenshot"),Y.section.each(function(e){"themes"===e.params.type&&n.id===e.currentTheme&&e.closeDetails()})}o.resolve(t)},i.installingThemes.push(a),t=wp.updates.installTheme({slug:a}),s&&Y.notifications.add(new Y.OverlayNotification("theme_installing",{message:Y.l10n.themeDownloading,type:"info",loading:!0})),t.done(e),t.fail(function(){Y.notifications.remove("theme_installing")})):o.reject({errorCode:"theme_switch_unavailable"}),o.promise()},loadThemePreview:function(e){var t,n,i=J.Deferred();return this.canSwitchTheme(e)?((n=document.createElement("a")).href=location.href,e=_.extend(Y.utils.parseQueryString(n.search.substr(1)),{theme:e,changeset_uuid:Y.settings.changeset.uuid,return:Y.settings.url.return}),Y.state("saved").get()||(e.customize_autosaved="on"),n.search=J.param(e),Y.notifications.add(new Y.OverlayNotification("theme_previewing",{message:Y.l10n.themePreviewWait,type:"info",loading:!0})),t=function(){var e;0<Y.state("processing").get()||(Y.state("processing").unbind(t),(e=Y.requestChangesetUpdate({},{autosave:!0})).done(function(){i.resolve(),J(window).off("beforeunload.customize-confirm"),location.replace(n.href)}),e.fail(function(){Y.notifications.remove("theme_previewing"),i.reject()}))},0===Y.state("processing").get()?t():Y.state("processing").bind(t)):i.reject({errorCode:"theme_switch_unavailable"}),i.promise()},updateTheme:function(e){wp.updates.maybeRequestFilesystemCredentials(e),J(document).one("wp-theme-update-success",function(e,t){Y.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t.slug&&(e.params.theme.hasUpdate=!1,e.params.theme.version=t.newVersion,setTimeout(function(){e.rerenderAsInstalled(!0)},2e3))})}),wp.updates.updateTheme({slug:J(e.target).closest(".notice").data("slug")})},deleteTheme:function(e){var t=J(e.target).data("slug"),n=Y.section("installed_themes");e.preventDefault(),Y.settings.theme._filesystemCredentialsNeeded||window.confirm(Y.settings.l10n.confirmDeleteTheme)&&(wp.updates.maybeRequestFilesystemCredentials(e),J(document).one("wp-theme-delete-success",function(){var e=Y.control("installed_theme_"+t);e.container.remove(),Y.control.remove(e.id),n.loaded=n.loaded-1,n.updateCount(),Y.control.each(function(e){"theme"===e.params.type&&e.params.theme.id===t&&e.rerenderAsInstalled(!1)})}),wp.updates.deleteTheme({slug:t}),n.closeDetails(),n.focus())}}),Y.Control=Y.Class.extend({defaultActiveArguments:{duration:"fast",completeCallback:J.noop},defaults:{label:"",description:"",active:!0,priority:10},initialize:function(e,t){var n,i=this,a=[];i.params=_.extend({},i.defaults,i.params||{},t.params||t||{}),Y.Control.instanceCounter||(Y.Control.instanceCounter=0),Y.Control.instanceCounter++,i.params.instanceNumber||(i.params.instanceNumber=Y.Control.instanceCounter),i.params.type||_.find(Y.controlConstructor,function(e,t){return e===i.constructor&&(i.params.type=t,!0)}),i.params.content||(i.params.content=J("<li></li>",{id:"customize-control-"+e.replace(/]/g,"").replace(/\[/g,"-"),class:"customize-control customize-control-"+i.params.type})),i.id=e,i.selector="#customize-control-"+e.replace(/\]/g,"").replace(/\[/g,"-"),i.params.content?i.container=J(i.params.content):i.container=J(i.selector),i.params.templateId?i.templateSelector=i.params.templateId:i.templateSelector="customize-control-"+i.params.type+"-content",i.deferred=_.extend(i.deferred||{},{embedded:new J.Deferred}),i.section=new Y.Value,i.priority=new Y.Value,i.active=new Y.Value,i.activeArgumentsQueue=[],i.notifications=new Y.Notifications({alt:i.altNotice}),i.elements=[],i.active.bind(function(e){var t=i.activeArgumentsQueue.shift(),t=J.extend({},i.defaultActiveArguments,t);i.onChangeActive(e,t)}),i.section.set(i.params.section),i.priority.set(isNaN(i.params.priority)?10:i.params.priority),i.active.set(i.params.active),Y.utils.bubbleChildValueChanges(i,["section","priority","active"]),i.settings={},n={},i.params.setting&&(n.default=i.params.setting),_.extend(n,i.params.settings),_.each(n,function(e,t){var n;_.isObject(e)&&_.isFunction(e.extended)&&e.extended(Y.Value)?i.settings[t]=e:_.isString(e)&&((n=Y(e))?i.settings[t]=n:a.push(e))}),t=function(){_.each(n,function(e,t){!i.settings[t]&&_.isString(e)&&(i.settings[t]=Y(e))}),i.settings[0]&&!i.settings.default&&(i.settings.default=i.settings[0]),i.setting=i.settings.default||null,i.linkElements(),i.embed()},0===a.length?t():Y.apply(Y,a.concat(t)),i.deferred.embedded.done(function(){i.linkElements(),i.setupNotifications(),i.ready()})},linkElements:function(){var i,a=this,o=a.container.find("[data-customize-setting-link], [data-customize-setting-key-link]"),s={};o.each(function(){var e,t,n=J(this);if(!n.data("customizeSettingLinked")){if(n.data("customizeSettingLinked",!0),n.is(":radio")){if(e=n.prop("name"),s[e])return;s[e]=!0,n=o.filter('[name="'+e+'"]')}n.data("customizeSettingLink")?t=Y(n.data("customizeSettingLink")):n.data("customizeSettingKeyLink")&&(t=a.settings[n.data("customizeSettingKeyLink")]),t&&(i=new Y.Element(n),a.elements.push(i),i.sync(t),i.set(t()))}})},embed:function(){var n=this,e=function(e){var t;e&&Y.section(e,function(e){e.deferred.embedded.done(function(){t=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),n.container.parent().is(t)||t.append(n.container),n.renderContent(),n.deferred.embedded.resolve()})})};n.section.bind(e),e(n.section.get())},ready:function(){var t,n=this;"dropdown-pages"===n.params.type&&n.params.allow_addition&&((t=n.container.find(".new-content-item-wrapper")).hide(),n.container.on("click",".add-new-toggle",function(e){J(e.currentTarget).slideUp(180),t.slideDown(180),t.find(".create-item-input").focus()}),n.container.on("click",".add-content",function(){n.addNewPage()}),n.container.on("keydown",".create-item-input",function(e){13===e.which&&n.addNewPage()}))},getNotificationsContainerElement:function(){var e,t=this,n=t.container.find(".customize-control-notifications-container:first");return n.length||(n=J('<div class="customize-control-notifications-container"></div>'),t.container.hasClass("customize-control-nav_menu_item")?t.container.find(".menu-item-settings:first").prepend(n):t.container.hasClass("customize-control-widget_form")?t.container.find(".widget-inside:first").prepend(n):(e=t.container.find(".customize-control-title")).length?e.after(n):t.container.prepend(n)),n},setupNotifications:function(){var n,e,i=this;_.each(i.settings,function(n){n.notifications&&(n.notifications.bind("add",function(e){var t=_.extend({},e,{setting:n.id});i.notifications.add(new Y.Notification(n.id+":"+e.code,t))}),n.notifications.bind("remove",function(e){i.notifications.remove(n.id+":"+e.code)}))}),n=function(){var e=i.section();(!e||Y.section.has(e)&&Y.section(e).expanded())&&i.notifications.render()},i.notifications.bind("rendered",function(){var e=i.notifications.get();i.container.toggleClass("has-notifications",0!==e.length),i.container.toggleClass("has-error",0!==_.where(e,{type:"error"}).length)}),i.section.bind(e=function(e,t){t&&Y.section.has(t)&&Y.section(t).expanded.unbind(n),e&&Y.section(e,function(e){e.expanded.bind(n),n()})}),e(i.section.get()),i.notifications.bind("change",_.debounce(n))},renderNotifications:function(){var e,t,n=this,i=!1;"undefined"!=typeof console&&console.warn&&console.warn("[DEPRECATED] wp.customize.Control.prototype.renderNotifications() is deprecated in favor of instantiating a wp.customize.Notifications and calling its render() method."),(e=n.getNotificationsContainerElement())&&e.length&&(t=[],n.notifications.each(function(e){t.push(e),"error"===e.type&&(i=!0)}),0===t.length?e.stop().slideUp("fast"):e.stop().slideDown("fast",null,function(){J(this).css("height","auto")}),n.notificationsTemplate||(n.notificationsTemplate=wp.template("customize-control-notifications")),n.container.toggleClass("has-notifications",0!==t.length),n.container.toggleClass("has-error",i),e.empty().append(n.notificationsTemplate({notifications:t,altNotice:Boolean(n.altNotice)}).trim()))},expand:function(e){Y.section(this.section()).expand(e)},focus:o,onChangeActive:function(e,t){t.unchanged?t.completeCallback&&t.completeCallback():J.contains(document,this.container[0])?e?this.container.slideDown(t.duration,t.completeCallback):this.container.slideUp(t.duration,t.completeCallback):(this.container.toggle(e),t.completeCallback&&t.completeCallback())},toggle:function(e){return this.onChangeActive(e,this.defaultActiveArguments)},activate:a.prototype.activate,deactivate:a.prototype.deactivate,_toggleActive:a.prototype._toggleActive,dropdownInit:function(){function e(e){"string"==typeof e&&i.statuses&&i.statuses[e]?n.html(i.statuses[e]).show():n.hide()}var t=this,n=this.container.find(".dropdown-status"),i=this.params,a=!1;this.container.on("click keydown",".dropdown",function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),a||t.container.toggleClass("open"),t.container.hasClass("open")&&t.container.parent().parent().find("li.library-selected").focus(),a=!0,setTimeout(function(){a=!1},400))}),this.setting.bind(e),e(this.setting())},renderContent:function(){var e=this,t=e.templateSelector;t==="customize-control-"+e.params.type+"-content"&&_.contains(["button","checkbox","date","datetime-local","email","month","number","password","radio","range","search","select","tel","time","text","textarea","week","url"],e.params.type)&&!document.getElementById("tmpl-"+t)&&0===e.container.children().length&&(t="customize-control-default-content"),document.getElementById("tmpl-"+t)&&(t=wp.template(t))&&e.container&&e.container.html(t(e.params)),e.notifications.container=e.getNotificationsContainerElement(),(!(t=e.section())||Y.section.has(t)&&Y.section(t).expanded())&&e.notifications.render()},addNewPage:function(){var e,a,o,t,s,r,c=this;"dropdown-pages"===c.params.type&&c.params.allow_addition&&Y.Menus&&(a=c.container.find(".add-new-toggle"),o=c.container.find(".new-content-item-wrapper"),t=c.container.find(".create-item-input"),s=t.val(),r=c.container.find("select"),s?(t.removeClass("invalid"),t.attr("disabled","disabled"),(e=Y.Menus.insertAutoDraftPost({post_title:s,post_type:"page"})).done(function(e){var t,n,i=new Y.Menus.AvailableItemModel({id:"post-"+e.post_id,title:s,type:"post_type",type_label:Y.Menus.data.l10n.page_label,object:"page",object_id:e.post_id,url:e.url});Y.Menus.availableMenuItemsPanel.collection.add(i),t=J("#available-menu-items-post_type-page").find(".available-menu-items-list"),n=wp.template("available-menu-item"),t.prepend(n(i.attributes)),r.focus(),c.setting.set(String(e.post_id)),o.slideUp(180),a.slideDown(180)}),e.always(function(){t.val("").removeAttr("disabled")})):t.addClass("invalid"))}}),Y.ColorControl=Y.Control.extend({ready:function(){var t,n=this,e="hue"===this.params.mode,i=!1;e?(t=this.container.find(".color-picker-hue")).val(n.setting()).wpColorPicker({change:function(e,t){i=!0,n.setting(t.color.h()),i=!1}}):(t=this.container.find(".color-picker-hex")).val(n.setting()).wpColorPicker({change:function(){i=!0,n.setting.set(t.wpColorPicker("color")),i=!1},clear:function(){i=!0,n.setting.set(""),i=!1}}),n.setting.bind(function(e){i||(t.val(e),t.wpColorPicker("color",e))}),n.container.on("keydown",function(e){27===e.which&&n.container.find(".wp-picker-container").hasClass("wp-picker-active")&&(t.wpColorPicker("close"),n.container.find(".wp-color-result").focus(),e.stopPropagation())})}}),Y.MediaControl=Y.Control.extend({ready:function(){var n=this;function e(e){var t=J.Deferred();n.extended(Y.UploadControl)?t.resolve():(e=parseInt(e,10),_.isNaN(e)||e<=0?(delete n.params.attachment,t.resolve()):n.params.attachment&&n.params.attachment.id===e&&t.resolve()),"pending"===t.state()&&wp.media.attachment(e).fetch().done(function(){n.params.attachment=this.attributes,t.resolve(),wp.customize.previewer.send(n.setting.id+"-attachment-data",this.attributes)}),t.done(function(){n.renderContent()})}_.bindAll(n,"restoreDefault","removeFile","openFrame","select","pausePlayer"),n.container.on("click keydown",".upload-button",n.openFrame),n.container.on("click keydown",".upload-button",n.pausePlayer),n.container.on("click keydown",".thumbnail-image img",n.openFrame),n.container.on("click keydown",".default-button",n.restoreDefault),n.container.on("click keydown",".remove-button",n.pausePlayer),n.container.on("click keydown",".remove-button",n.removeFile),n.container.on("click keydown",".remove-button",n.cleanupPlayer),Y.section(n.section()).container.on("expanded",function(){n.player&&n.player.setControlsSize()}).on("collapsed",function(){n.pausePlayer()}),e(n.setting()),n.setting.bind(e)},pausePlayer:function(){this.player&&this.player.pause()},cleanupPlayer:function(){this.player&&wp.media.mixin.removePlayer(this.player)},openFrame:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.frame||this.initFrame(),this.frame.open())},initFrame:function(){this.frame=wp.media({button:{text:this.params.button_labels.frame_button},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:this.params.mime_type}),multiple:!1,date:!1})]}),this.frame.on("select",this.select)},select:function(){var e=this.frame.state().get("selection").first().toJSON(),t=window._wpmejsSettings||{};this.params.attachment=e,this.setting(e.id),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,t):this.cleanupPlayer()},restoreDefault:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment=this.params.defaultAttachment,this.setting(this.params.defaultAttachment.url))},removeFile:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent())}}),Y.UploadControl=Y.MediaControl.extend({select:function(){var e=this.frame.state().get("selection").first().toJSON(),t=window._wpmejsSettings||{};this.params.attachment=e,this.setting(e.url),(e=this.container.find("audio, video").get(0))?this.player=new MediaElementPlayer(e,t):this.cleanupPlayer()},success:function(){},removerVisibility:function(){}}),Y.ImageControl=Y.UploadControl.extend({thumbnailSrc:function(){}}),Y.BackgroundControl=Y.UploadControl.extend({ready:function(){Y.UploadControl.prototype.ready.apply(this,arguments)},select:function(){Y.UploadControl.prototype.select.apply(this,arguments),wp.ajax.post("custom-background-add",{nonce:_wpCustomizeBackground.nonces.add,wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,attachment_id:this.params.attachment.id})}}),Y.BackgroundPositionControl=Y.Control.extend({ready:function(){var e,n=this;n.container.on("change",'input[name="background-position"]',function(){var e=J(this).val().split(" ");n.settings.x(e[0]),n.settings.y(e[1])}),e=_.debounce(function(){var e=n.settings.x.get(),t=n.settings.y.get(),e=String(e)+" "+String(t);n.container.find('input[name="background-position"][value="'+e+'"]').trigger("click")}),n.settings.x.bind(e),n.settings.y.bind(e),e()}}),Y.CroppedImageControl=Y.MediaControl.extend({openFrame:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(this.initFrame(),this.frame.setState("library").open())},initFrame:function(){var e=_wpMediaViewsL10n;this.frame=wp.media({button:{text:e.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.CustomizeImageCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var e=this.frame.state().get("selection").first().toJSON();this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):(this.setImageFromAttachment(e),this.frame.close())},onCropped:function(e){this.setImageFromAttachment(e)},calculateImageSelectOptions:function(e,t){var n=t.get("control"),i=!!parseInt(n.params.flex_width,10),a=!!parseInt(n.params.flex_height,10),o=e.get("width"),e=e.get("height"),s=parseInt(n.params.width,10),r=parseInt(n.params.height,10),c=s/r,l=s,d=r;return t.set("canSkipCrop",!n.mustBeCropped(i,a,s,r,o,e)),c<o/e?s=(r=e)*c:r=(s=o)/c,!(c={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:o,imageHeight:e,minWidth:s<l?s:l,minHeight:r<d?r:d,x1:t=(o-s)/2,y1:n=(e-r)/2,x2:s+t,y2:r+n})==a&&!1==i&&(c.aspectRatio=s+":"+r),!0==a&&(delete c.minHeight,c.maxWidth=o),!0==i&&(delete c.minWidth,c.maxHeight=e),c},mustBeCropped:function(e,t,n,i,a,o){return(!0!==e||!0!==t)&&!(!0===e&&i===o||!0===t&&n===a||n===a&&i===o||a<=n)},onSkippedCrop:function(){var e=this.frame.state().get("selection").first().toJSON();this.setImageFromAttachment(e)},setImageFromAttachment:function(e){this.params.attachment=e,this.setting(e.id)}}),Y.SiteIconControl=Y.CroppedImageControl.extend({initFrame:function(){var e=_wpMediaViewsL10n;this.frame=wp.media({button:{text:e.select,close:!1},states:[new wp.media.controller.Library({title:this.params.button_labels.frame_title,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:this.params.width,suggestedHeight:this.params.height}),new wp.media.controller.SiteIconCropper({imgSelectOptions:this.calculateImageSelectOptions,control:this})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this)},onSelect:function(){var e=this.frame.state().get("selection").first().toJSON(),t=this;this.params.width!==e.width||this.params.height!==e.height||this.params.flex_width||this.params.flex_height?this.frame.setState("cropper"):wp.ajax.post("crop-image",{nonce:e.nonces.edit,id:e.id,context:"site-icon",cropDetails:{x1:0,y1:0,width:this.params.width,height:this.params.height,dst_width:this.params.width,dst_height:this.params.height}}).done(function(e){t.setImageFromAttachment(e),t.frame.close()}).fail(function(){t.frame.trigger("content:error:crop")})},setImageFromAttachment:function(t){var n;_.each(["site_icon-32","thumbnail","full"],function(e){n||_.isUndefined(t.sizes[e])||(n=t.sizes[e])}),this.params.attachment=t,this.setting(t.id),n&&J('link[rel="icon"][sizes="32x32"]').attr("href",n.url)},removeFile:function(e){Y.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),this.params.attachment={},this.setting(""),this.renderContent(),J('link[rel="icon"][sizes="32x32"]').attr("href","/favicon.ico"))}}),Y.HeaderControl=Y.Control.extend({ready:function(){this.btnRemove=J("#customize-control-header_image .actions .remove"),this.btnNew=J("#customize-control-header_image .actions .new"),_.bindAll(this,"openMedia","removeImage"),this.btnNew.on("click",this.openMedia),this.btnRemove.on("click",this.removeImage),Y.HeaderTool.currentHeader=this.getInitialHeaderImage(),new Y.HeaderTool.CurrentView({model:Y.HeaderTool.currentHeader,el:"#customize-control-header_image .current .container"}),new Y.HeaderTool.ChoiceListView({collection:Y.HeaderTool.UploadsList=new Y.HeaderTool.ChoiceList,el:"#customize-control-header_image .choices .uploaded .list"}),new Y.HeaderTool.ChoiceListView({collection:Y.HeaderTool.DefaultsList=new Y.HeaderTool.DefaultsList,el:"#customize-control-header_image .choices .default .list"}),Y.HeaderTool.combinedList=Y.HeaderTool.CombinedList=new Y.HeaderTool.CombinedList([Y.HeaderTool.UploadsList,Y.HeaderTool.DefaultsList]),wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize="on",wp.media.controller.Cropper.prototype.defaults.doCropArgs.customize_theme=Y.settings.theme.stylesheet},getInitialHeaderImage:function(){var e;return Y.get().header_image&&Y.get().header_image_data&&!_.contains(["remove-header","random-default-image","random-uploaded-image"],Y.get().header_image)?(e=(e=_.find(_wpCustomizeHeader.uploads,function(e){return e.attachment_id===Y.get().header_image_data.attachment_id}))||{url:Y.get().header_image,thumbnail_url:Y.get().header_image,attachment_id:Y.get().header_image_data.attachment_id},new Y.HeaderTool.ImageModel({header:e,choice:e.url.split("/").pop()})):new Y.HeaderTool.ImageModel},calculateImageSelectOptions:function(e,t){var n=parseInt(_wpCustomizeHeader.data.width,10),i=parseInt(_wpCustomizeHeader.data.height,10),a=!!parseInt(_wpCustomizeHeader.data["flex-width"],10),o=!!parseInt(_wpCustomizeHeader.data["flex-height"],10),s=e.get("width"),e=e.get("height");return this.headerImage=new Y.HeaderTool.ImageModel,this.headerImage.set({themeWidth:n,themeHeight:i,themeFlexWidth:a,themeFlexHeight:o,imageWidth:s,imageHeight:e}),t.set("canSkipCrop",!this.headerImage.shouldBeCropped()),(t=n/i)<s/e?n=(i=e)*t:i=(n=s)/t,!(t={handles:!0,keys:!0,instance:!0,persistent:!0,imageWidth:s,imageHeight:e,x1:0,y1:0,x2:n,y2:i})==o&&!1==a&&(t.aspectRatio=n+":"+i),!1==o&&(t.maxHeight=i),!1==a&&(t.maxWidth=n),t},openMedia:function(e){var t=_wpMediaViewsL10n;e.preventDefault(),this.frame=wp.media({button:{text:t.selectAndCrop,close:!1},states:[new wp.media.controller.Library({title:t.chooseImage,library:wp.media.query({type:"image"}),multiple:!1,date:!1,priority:20,suggestedWidth:_wpCustomizeHeader.data.width,suggestedHeight:_wpCustomizeHeader.data.height}),new wp.media.controller.Cropper({imgSelectOptions:this.calculateImageSelectOptions})]}),this.frame.on("select",this.onSelect,this),this.frame.on("cropped",this.onCropped,this),this.frame.on("skippedcrop",this.onSkippedCrop,this),this.frame.open()},onSelect:function(){this.frame.setState("cropper")},onCropped:function(e){var t=e.url,n=e.attachment_id,i=e.width,e=e.height;this.setImageFromURL(t,n,i,e)},onSkippedCrop:function(e){var t=e.get("url"),n=e.get("width"),i=e.get("height");this.setImageFromURL(t,e.id,n,i)},setImageFromURL:function(e,t,n,i){var a={};a.url=e,a.thumbnail_url=e,a.timestamp=_.now(),t&&(a.attachment_id=t),n&&(a.width=n),i&&(a.height=i),t=new Y.HeaderTool.ImageModel({header:a,choice:e.split("/").pop()}),Y.HeaderTool.UploadsList.add(t),Y.HeaderTool.currentHeader.set(t.toJSON()),t.save(),t.importImage()},removeImage:function(){Y.HeaderTool.currentHeader.trigger("hide"),Y.HeaderTool.CombinedList.trigger("control:removeImage")}}),Y.ThemeControl=Y.Control.extend({touchDrag:!1,screenshotRendered:!1,ready:function(){var n=this,e=Y.panel("themes");function t(){return!e.canSwitchTheme(n.params.theme.id)}function i(){n.container.find("button.preview, button.preview-theme").toggleClass("disabled",t()),n.container.find("button.theme-install").toggleClass("disabled",t()||!1===Y.settings.theme._canInstall||!0===Y.settings.theme._filesystemCredentialsNeeded)}Y.state("selectedChangesetStatus").bind(i),Y.state("changesetStatus").bind(i),i(),n.container.on("touchmove",".theme",function(){n.touchDrag=!0}),n.container.on("click keydown touchend",".theme",function(e){var t;if(!Y.utils.isKeydownButNotEnterEvent(e))return!0===n.touchDrag?n.touchDrag=!1:void(J(e.target).is(".theme-actions .button, .update-theme")||(e.preventDefault(),(t=Y.section(n.section())).showDetails(n.params.theme,function(){Y.settings.theme._filesystemCredentialsNeeded&&t.overlay.find(".theme-actions .delete-theme").remove()})))}),n.container.on("render-screenshot",function(){var e=J(this).find("img"),t=e.data("src");t&&e.attr("src",t),n.screenshotRendered=!0})},filter:function(e){var t=this,n=0,i=(i=t.params.theme.name+" "+t.params.theme.description+" "+t.params.theme.tags+" "+t.params.theme.author+" ").toLowerCase().replace("-"," ");return _.isArray(e)||(e=[e]),t.params.theme.name.toLowerCase()===e.join(" ")?n=100:(n+=10*(i.split(e.join(" ")).length-1),_.each(e,function(e){n=(n+=2*(i.split(e+" ").length-1))+i.split(e).length-1}),99<n&&(n=99)),0!==n?(t.activate(),t.params.priority=101-n,!0):(t.deactivate(),!(t.params.priority=101))},rerenderAsInstalled:function(e){var t=this;e?t.params.theme.type="installed":(e=Y.section(t.params.section),t.params.theme.type=e.params.action),t.renderContent(),t.container.trigger("render-screenshot")}}),Y.CodeEditorControl=Y.Control.extend({initialize:function(e,t){var n=this;n.deferred=_.extend(n.deferred||{},{codemirror:J.Deferred()}),Y.Control.prototype.initialize.call(n,e,t),n.notifications.bind("add",function(e){var t;e.code===n.setting.id+":csslint_error"&&(e.templateId="customize-code-editor-lint-error-notification",e.render=(t=e.render,function(){var e=t.call(this);return e.find("input[type=checkbox]").on("click",function(){n.setting.notifications.remove("csslint_error")}),e}))})},ready:function(){var i=this;i.section()?Y.section(i.section(),function(n){n.deferred.embedded.done(function(){var t;n.expanded()?i.initEditor():n.expanded.bind(t=function(e){e&&(i.initEditor(),n.expanded.unbind(t))})})}):i.initEditor()},initEditor:function(){var e,t=this,n=!1;wp.codeEditor&&(_.isUndefined(t.params.editor_settings)||!1!==t.params.editor_settings)&&((n=wp.codeEditor.defaultSettings?_.clone(wp.codeEditor.defaultSettings):{}).codemirror=_.extend({},n.codemirror,{indentUnit:2,tabSize:2}),_.isObject(t.params.editor_settings))&&_.each(t.params.editor_settings,function(e,t){_.isObject(e)&&(n[t]=_.extend({},n[t],e))}),e=new Y.Element(t.container.find("textarea")),t.elements.push(e),e.sync(t.setting),e.set(t.setting()),n?t.initSyntaxHighlightingEditor(n):t.initPlainTextareaEditor()},focus:function(e){var t=this,e=_.extend({},e),n=e.completeCallback;e.completeCallback=function(){n&&n(),t.editor&&t.editor.codemirror.focus()},Y.Control.prototype.focus.call(t,e)},initSyntaxHighlightingEditor:function(e){var t=this,n=t.container.find("textarea"),i=!1,e=_.extend({},e,{onTabNext:_.bind(t.onTabNext,t),onTabPrevious:_.bind(t.onTabPrevious,t),onUpdateErrorNotice:_.bind(t.onUpdateErrorNotice,t)});t.editor=wp.codeEditor.initialize(n,e),J(t.editor.codemirror.display.lineDiv).attr({role:"textbox","aria-multiline":"true","aria-label":t.params.label,"aria-describedby":"editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"}),t.container.find("label").on("click",function(){t.editor.codemirror.focus()}),t.editor.codemirror.on("change",function(e){i=!0,n.val(e.getValue()).trigger("change"),i=!1}),t.setting.bind(function(e){i||t.editor.codemirror.setValue(e)}),t.editor.codemirror.on("keydown",function(e,t){27===t.keyCode&&t.stopPropagation()}),t.deferred.codemirror.resolveWith(t,[t.editor.codemirror])},onTabNext:function(){var e=Y.section(this.section()).controls(),t=e.indexOf(this);e.length===t+1?J("#customize-footer-actions .collapse-sidebar").trigger("focus"):e[t+1].container.find(":focusable:first").focus()},onTabPrevious:function(){var e=Y.section(this.section()),t=e.controls(),n=t.indexOf(this);(0===n?e.contentContainer.find(".customize-section-title .customize-help-toggle, .customize-section-title .customize-section-description.open .section-description-close").last():t[n-1].contentContainer.find(":focusable:first")).focus()},onUpdateErrorNotice:function(e){this.setting.notifications.remove("csslint_error"),0!==e.length&&(e=1===e.length?Y.l10n.customCssError.singular.replace("%d","1"):Y.l10n.customCssError.plural.replace("%d",String(e.length)),this.setting.notifications.add(new Y.Notification("csslint_error",{message:e,type:"error"})))},initPlainTextareaEditor:function(){var a=this.container.find("textarea"),o=a[0];a.on("blur",function(){a.data("next-tab-blurs",!1)}),a.on("keydown",function(e){var t,n,i;27===e.keyCode?a.data("next-tab-blurs")||(a.data("next-tab-blurs",!0),e.stopPropagation()):9!==e.keyCode||e.ctrlKey||e.altKey||e.shiftKey||a.data("next-tab-blurs")||(t=o.selectionStart,n=o.selectionEnd,i=o.value,0<=t&&(o.value=i.substring(0,t).concat("\t",i.substring(n)),a.selectionStart=o.selectionEnd=t+1),e.stopPropagation(),e.preventDefault())}),this.deferred.codemirror.rejectWith(this)}}),Y.DateTimeControl=Y.Control.extend({ready:function(){var i=this;if(i.inputElements={},i.invalidDate=!1,_.bindAll(i,"populateSetting","updateDaysForMonth","populateDateInputs"),!i.setting)throw new Error("Missing setting");i.container.find(".date-input").each(function(){var e=J(this),t=e.data("component"),n=new Y.Element(e);i.inputElements[t]=n,i.elements.push(n),e.on("change",function(){i.invalidDate&&i.notifications.add(new Y.Notification("invalid_date",{message:Y.l10n.invalidDate}))}),e.on("input",_.debounce(function(){i.invalidDate||i.notifications.remove("invalid_date")})),e.on("blur",_.debounce(function(){i.invalidDate||i.populateDateInputs()}))}),i.inputElements.month.bind(i.updateDaysForMonth),i.inputElements.year.bind(i.updateDaysForMonth),i.populateDateInputs(),i.setting.bind(i.populateDateInputs),_.each(i.inputElements,function(e){e.bind(i.populateSetting)})},parseDateTime:function(e){var t;return(t=e?e.match(/^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/):t)?(t.shift(),e={year:t.shift(),month:t.shift(),day:t.shift(),hour:t.shift()||"00",minute:t.shift()||"00",second:t.shift()||"00"},this.params.includeTime&&this.params.twelveHourFormat&&(e.hour=parseInt(e.hour,10),e.meridian=12<=e.hour?"pm":"am",e.hour=e.hour%12?String(e.hour%12):String(12),delete e.second),e):null},validateInputs:function(){var e,i,a=this;return a.invalidDate=!1,e=["year","day"],a.params.includeTime&&e.push("hour","minute"),_.find(e,function(e){var t,n,e=a.inputElements[e];return i=e.element.get(0),t=parseInt(e.element.attr("max"),10),n=parseInt(e.element.attr("min"),10),e=parseInt(e(),10),a.invalidDate=isNaN(e)||t<e||e<n,a.invalidDate||i.setCustomValidity(""),a.invalidDate}),a.inputElements.meridian&&!a.invalidDate&&(i=a.inputElements.meridian.element.get(0),"am"!==a.inputElements.meridian.get()&&"pm"!==a.inputElements.meridian.get()?a.invalidDate=!0:i.setCustomValidity("")),a.invalidDate?i.setCustomValidity(Y.l10n.invalidValue):i.setCustomValidity(""),(!a.section()||Y.section.has(a.section())&&Y.section(a.section()).expanded())&&_.result(i,"reportValidity"),a.invalidDate},updateDaysForMonth:function(){var e=this,t=parseInt(e.inputElements.month(),10),n=parseInt(e.inputElements.year(),10),i=parseInt(e.inputElements.day(),10);t&&n&&(n=new Date(n,t,0).getDate(),e.inputElements.day.element.attr("max",n),n<i)&&e.inputElements.day(String(n))},populateSetting:function(){var e,t=this;return!(t.validateInputs()||!t.params.allowPastDate&&!t.isFutureDate()||(e=t.convertInputDateToString(),t.setting.set(e),0))},convertInputDateToString:function(){var e,n=this,t="",i=function(e,t){return String(e).length<t&&(t=t-String(e).length,e=Math.pow(10,t).toString().substr(1)+String(e)),e},a=function(e){var t=parseInt(n.inputElements[e].get(),10);return _.contains(["month","day","hour","minute"],e)?t=i(t,2):"year"===e&&(t=i(t,4)),t},o=["year","-","month","-","day"];return n.params.includeTime&&(e=n.inputElements.meridian?n.convertHourToTwentyFourHourFormat(n.inputElements.hour(),n.inputElements.meridian()):n.inputElements.hour(),o=o.concat([" ",i(e,2),":","minute",":","00"])),_.each(o,function(e){t+=n.inputElements[e]?a(e):e}),t},isFutureDate:function(){return 0<Y.utils.getRemainingTime(this.convertInputDateToString())},convertHourToTwentyFourHourFormat:function(e,t){e=parseInt(e,10);return isNaN(e)?"":(t="pm"===t&&e<12?e+12:"am"===t&&12===e?e-12:e,String(t))},populateDateInputs:function(){var i=this.parseDateTime(this.setting.get());return!!i&&(_.each(this.inputElements,function(e,t){var n=i[t];"month"===t||"meridian"===t?(n=n.replace(/^0/,""),e.set(n)):(n=parseInt(n,10),e.element.is(document.activeElement)?n!==parseInt(e(),10)&&e.set(String(n)):e.set(i[t]))}),!0)},toggleFutureDateNotification:function(e){var t="not_future_date";return e?(e=new Y.Notification(t,{type:"error",message:Y.l10n.futureDateError}),this.notifications.add(e)):this.notifications.remove(t),this}}),Y.PreviewLinkControl=Y.Control.extend({defaults:_.extend({},Y.Control.prototype.defaults,{templateId:"customize-preview-link-control"}),ready:function(){var e,t,n,i,a,o=this;_.bindAll(o,"updatePreviewLink"),o.setting||(o.setting=new Y.Value),o.previewElements={},o.container.find(".preview-control-element").each(function(){t=J(this),e=t.data("component"),t=new Y.Element(t),o.previewElements[e]=t,o.elements.push(t)}),n=o.previewElements.url,i=o.previewElements.input,a=o.previewElements.button,i.link(o.setting),n.link(o.setting),n.bind(function(e){n.element.parent().attr({href:e,target:Y.settings.changeset.uuid})}),Y.bind("ready",o.updatePreviewLink),Y.state("saved").bind(o.updatePreviewLink),Y.state("changesetStatus").bind(o.updatePreviewLink),Y.state("activated").bind(o.updatePreviewLink),Y.previewer.previewUrl.bind(o.updatePreviewLink),a.element.on("click",function(e){e.preventDefault(),o.setting()&&(i.element.select(),document.execCommand("copy"),a(a.element.data("copied-text")))}),n.element.parent().on("click",function(e){J(this).hasClass("disabled")&&e.preventDefault()}),a.element.on("mouseenter",function(){o.setting()&&a(a.element.data("copy-text"))})},updatePreviewLink:function(){var e=!Y.state("saved").get()||""===Y.state("changesetStatus").get()||"auto-draft"===Y.state("changesetStatus").get();this.toggleSaveNotification(e),this.previewElements.url.element.parent().toggleClass("disabled",e),this.previewElements.button.element.prop("disabled",e),this.setting.set(Y.previewer.getFrontendPreviewUrl())},toggleSaveNotification:function(e){var t="changes_not_saved";e?(e=new Y.Notification(t,{type:"info",message:Y.l10n.saveBeforeShare}),this.notifications.add(e)):this.notifications.remove(t)}}),Y.defaultConstructor=Y.Setting,Y.control=new Y.Values({defaultConstructor:Y.Control}),Y.section=new Y.Values({defaultConstructor:Y.Section}),Y.panel=new Y.Values({defaultConstructor:Y.Panel}),Y.notifications=new Y.Notifications,Y.PreviewFrame=Y.Messenger.extend({sensitivity:null,initialize:function(e,t){var n=J.Deferred();n.promise(this),this.container=e.container,J.extend(e,{channel:Y.PreviewFrame.uuid()}),Y.Messenger.prototype.initialize.call(this,e,t),this.add("previewUrl",e.previewUrl),this.query=J.extend(e.query||{},{customize_messenger_channel:this.channel()}),this.run(n)},run:function(t){var e,n,i,a=this,o=!1,s=!1,r=null,c="{}"!==a.query.customized;a._ready&&a.unbind("ready",a._ready),a._ready=function(e){s=!0,r=e,a.container.addClass("iframe-ready"),e&&o&&t.resolveWith(a,[e])},a.bind("ready",a._ready),(e=document.createElement("a")).href=a.previewUrl(),n=_.extend(Y.utils.parseQueryString(e.search.substr(1)),{customize_changeset_uuid:a.query.customize_changeset_uuid,customize_theme:a.query.customize_theme,customize_messenger_channel:a.query.customize_messenger_channel}),!Y.settings.changeset.autosaved&&Y.state("saved").get()||(n.customize_autosaved="on"),e.search=J.param(n),a.iframe=J("<iframe />",{title:Y.l10n.previewIframeTitle,name:"customize-"+a.channel()}),a.iframe.attr("onmousewheel",""),a.iframe.attr("sandbox","allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts"),c?a.iframe.attr("data-src",e.href):a.iframe.attr("src",e.href),a.iframe.appendTo(a.container),a.targetWindow(a.iframe[0].contentWindow),c&&((i=J("<form>",{action:e.href,target:a.iframe.attr("name"),method:"post",hidden:"hidden"})).append(J("<input>",{type:"hidden",name:"_method",value:"GET"})),_.each(a.query,function(e,t){i.append(J("<input>",{type:"hidden",name:t,value:e}))}),a.container.append(i),i.trigger("submit"),i.remove()),a.bind("iframe-loading-error",function(e){a.iframe.remove(),0===e?a.login(t):-1===e?t.rejectWith(a,["cheatin"]):t.rejectWith(a,["request failure"])}),a.iframe.one("load",function(){o=!0,s?t.resolveWith(a,[r]):setTimeout(function(){t.rejectWith(a,["ready timeout"])},a.sensitivity)})},login:function(n){var i=this,a=function(){n.rejectWith(i,["logged out"])};if(this.triedLogin)return a();J.get(Y.settings.url.ajax,{action:"logged-in"}).fail(a).done(function(e){var t;"1"!==e&&a(),(t=J("<iframe />",{src:i.previewUrl(),title:Y.l10n.previewIframeTitle}).hide()).appendTo(i.container),t.on("load",function(){i.triedLogin=!0,t.remove(),i.run(n)})})},destroy:function(){Y.Messenger.prototype.destroy.call(this),this.iframe&&this.iframe.remove(),delete this.iframe,delete this.targetWindow}}),i=0,Y.PreviewFrame.uuid=function(){return"preview-"+String(i++)},Y.setDocumentTitle=function(e){e=Y.settings.documentTitleTmpl.replace("%s",e);document.title=e,Y.trigger("title",e)},Y.Previewer=Y.Messenger.extend({refreshBuffer:null,initialize:function(e,t){var n,o=this,i=document.createElement("a");J.extend(o,t||{}),o.deferred={active:J.Deferred()},o.refresh=_.debounce((n=o.refresh,function(){var e,t=function(){return 0===Y.state("processing").get()};t()?n.call(o):(e=function(){t()&&(n.call(o),Y.state("processing").unbind(e))},Y.state("processing").bind(e))}),o.refreshBuffer),o.container=Y.ensure(e.container),o.allowedUrls=e.allowedUrls,e.url=window.location.href,Y.Messenger.prototype.initialize.call(o,e),i.href=o.origin(),o.add("scheme",i.protocol.replace(/:$/,"")),o.add("previewUrl",e.previewUrl).setter(function(e){var n,i=null,t=[],a=document.createElement("a");return a.href=e,/\/wp-(admin|includes|content)(\/|$)/.test(a.pathname)?null:(1<a.search.length&&(delete(e=Y.utils.parseQueryString(a.search.substr(1))).customize_changeset_uuid,delete e.customize_theme,delete e.customize_messenger_channel,delete e.customize_autosaved,_.isEmpty(e)?a.search="":a.search=J.param(e)),t.push(a),o.scheme.get()+":"!==a.protocol&&((a=document.createElement("a")).href=t[0].href,a.protocol=o.scheme.get()+":",t.unshift(a)),n=document.createElement("a"),_.find(t,function(t){return!_.isUndefined(_.find(o.allowedUrls,function(e){if(n.href=e,a.protocol===n.protocol&&a.host===n.host&&0===a.pathname.indexOf(n.pathname.replace(/\/$/,"")))return i=t.href,!0}))}),i)}),o.bind("ready",o.ready),o.deferred.active.done(_.bind(o.keepPreviewAlive,o)),o.bind("synced",function(){o.send("active")}),o.previewUrl.bind(o.refresh),o.scroll=0,o.bind("scroll",function(e){o.scroll=e}),o.bind("url",function(e){var t,n=!1;o.scroll=0,o.previewUrl.bind(t=function(){n=!0}),o.previewUrl.set(e),o.previewUrl.unbind(t),n||o.refresh()}),o.bind("documentTitle",function(e){Y.setDocumentTitle(e)})},ready:function(e){var t=this,n={};n.settings=Y.get(),n["settings-modified-while-loading"]=t.settingsModifiedWhileLoading,"resolved"===t.deferred.active.state()&&!t.loading||(n.scroll=t.scroll),n["edit-shortcut-visibility"]=Y.state("editShortcutVisibility").get(),t.send("sync",n),e.currentUrl&&(t.previewUrl.unbind(t.refresh),t.previewUrl.set(e.currentUrl),t.previewUrl.bind(t.refresh)),n={panel:e.activePanels,section:e.activeSections,control:e.activeControls},_(n).each(function(n,i){Y[i].each(function(e,t){_.isUndefined(Y.settings[i+"s"][t])&&_.isUndefined(n[t])||(n[t]?e.activate():e.deactivate())})}),e.settingValidities&&Y._handleSettingValidities({settingValidities:e.settingValidities,focusInvalidControl:!1})},keepPreviewAlive:function(){var e,t=function(){e=setTimeout(i,Y.settings.timeouts.keepAliveCheck)},n=function(){Y.state("previewerAlive").set(!0),clearTimeout(e),t()},i=function(){Y.state("previewerAlive").set(!1)};t(),this.bind("ready",n),this.bind("keep-alive",n)},query:function(){},abort:function(){this.loading&&(this.loading.destroy(),delete this.loading)},refresh:function(){var e,i=this;i.send("loading-initiated"),i.abort(),i.loading=new Y.PreviewFrame({url:i.url(),previewUrl:i.previewUrl(),query:i.query({excludeCustomizedSaved:!0})||{},container:i.container}),i.settingsModifiedWhileLoading={},Y.bind("change",e=function(e){i.settingsModifiedWhileLoading[e.id]=!0}),i.loading.always(function(){Y.unbind("change",e)}),i.loading.done(function(e){var t,n=this;i.preview=n,i.targetWindow(n.targetWindow()),i.channel(n.channel()),t=function(){n.unbind("synced",t),i._previousPreview&&i._previousPreview.destroy(),i._previousPreview=i.preview,i.deferred.active.resolve(),delete i.loading},n.bind("synced",t),i.trigger("ready",e)}),i.loading.fail(function(e){i.send("loading-failed"),"logged out"===e&&(i.preview&&(i.preview.destroy(),delete i.preview),i.login().done(i.refresh)),"cheatin"===e&&i.cheatin()})},login:function(){var t,n,i,a=this;return this._login||(t=J.Deferred(),this._login=t.promise(),n=new Y.Messenger({channel:"login",url:Y.settings.url.login}),i=J("<iframe />",{src:Y.settings.url.login,title:Y.l10n.loginIframeTitle}).appendTo(this.container),n.targetWindow(i[0].contentWindow),n.bind("login",function(){var e=a.refreshNonces();e.always(function(){i.remove(),n.destroy(),delete a._login}),e.done(function(){t.resolve()}),e.fail(function(){a.cheatin(),t.reject()})})),this._login},cheatin:function(){J(document.body).empty().addClass("cheatin").append("<h1>"+Y.l10n.notAllowedHeading+"</h1><p>"+Y.l10n.notAllowed+"</p>")},refreshNonces:function(){var e,t=J.Deferred();return t.promise(),(e=wp.ajax.post("customize_refresh_nonces",{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet})).done(function(e){Y.trigger("nonce-refresh",e),t.resolve()}),e.fail(function(){t.reject()}),t}}),Y.settingConstructor={},Y.controlConstructor={color:Y.ColorControl,media:Y.MediaControl,upload:Y.UploadControl,image:Y.ImageControl,cropped_image:Y.CroppedImageControl,site_icon:Y.SiteIconControl,header:Y.HeaderControl,background:Y.BackgroundControl,background_position:Y.BackgroundPositionControl,theme:Y.ThemeControl,date_time:Y.DateTimeControl,code_editor:Y.CodeEditorControl},Y.panelConstructor={themes:Y.ThemesPanel},Y.sectionConstructor={themes:Y.ThemesSection,outer:Y.OuterSection},Y._handleSettingValidities=function(e){var o=[],n=!1;_.each(e.settingValidities,function(t,e){var a=Y(e);a&&(_.isObject(t)&&_.each(t,function(e,t){var n=!1,e=new Y.Notification(t,_.extend({fromServer:!0},e)),i=a.notifications(e.code);(n=i?e.type!==i.type||e.message!==i.message||!_.isEqual(e.data,i.data):n)&&a.notifications.remove(t),a.notifications.has(e.code)||a.notifications.add(e),o.push(a.id)}),a.notifications.each(function(e){!e.fromServer||"error"!==e.type||!0!==t&&t[e.code]||a.notifications.remove(e.code)}))}),e.focusInvalidControl&&(e=Y.findControlsForSettings(o),_(_.values(e)).find(function(e){return _(e).find(function(e){var t=e.section()&&Y.section.has(e.section())&&Y.section(e.section()).expanded();return(t=t&&e.expanded?e.expanded():t)&&(e.focus(),n=!0),n})}),n||_.isEmpty(e)||_.values(e)[0][0].focus())},Y.findControlsForSettings=function(e){var n,i={};return _.each(_.unique(e),function(e){var t=Y(e);t&&(n=t.findControls())&&0<n.length&&(i[e]=n)}),i},Y.reflowPaneContents=_.bind(function(){var i,e,t,a=[],o=!1;document.activeElement&&(e=J(document.activeElement)),Y.panel.each(function(e){var t,n;"themes"===e.id||(t=e.sections(),n=_.pluck(t,"headContainer"),a.push(e),i=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),Y.utils.areElementListsEqual(n,i.children("[id]")))||(_(t).each(function(e){i.append(e.headContainer)}),o=!0)}),Y.section.each(function(e){var t=e.controls(),n=_.pluck(t,"container");e.panel()||a.push(e),i=e.contentContainer.is("ul")?e.contentContainer:e.contentContainer.find("ul:first"),Y.utils.areElementListsEqual(n,i.children("[id]"))||(_(t).each(function(e){i.append(e.container)}),o=!0)}),a.sort(Y.utils.prioritySort),t=_.pluck(a,"headContainer"),i=J("#customize-theme-controls .customize-pane-parent"),Y.utils.areElementListsEqual(t,i.children())||(_(a).each(function(e){i.append(e.headContainer)}),o=!0),Y.panel.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),Y.section.each(function(e){var t=e.active();e.active.callbacks.fireWith(e.active,[t,t])}),o&&e&&e.trigger("focus"),Y.trigger("pane-contents-reflowed")},Y),Y.state=new Y.Values,_.each(["saved","saving","trashing","activated","processing","paneVisible","expandedPanel","expandedSection","changesetDate","selectedChangesetDate","changesetStatus","selectedChangesetStatus","remainingTimeToPublish","previewerAlive","editShortcutVisibility","changesetLocked","previewedDevice"],function(e){Y.state.create(e)}),J(function(){var h,o,t,n,i,d,u,p,a,s,r,c,l,f,m,H,L,g,v,w,b,M,O,C,j,y,e,x,k,z,S,T,E,R,B,W,D,N,P,I,U,A;function F(e){e&&e.lockUser&&(Y.settings.changeset.lockUser=e.lockUser),Y.state("changesetLocked").set(!0),Y.notifications.add(new j("changeset_locked",{lockUser:Y.settings.changeset.lockUser,allowOverride:Boolean(e&&e.allowOverride)}))}function q(){var e,t=document.createElement("a");return t.href=location.href,e=Y.utils.parseQueryString(t.search.substr(1)),Y.settings.changeset.latestAutoDraftUuid?e.changeset_uuid=Y.settings.changeset.latestAutoDraftUuid:e.customize_autosaved="on",e.return=Y.settings.url.return,t.search=J.param(e),t.href}function Q(){T||(wp.ajax.post("customize_dismiss_autosave_or_lock",{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.dismiss_autosave_or_lock,dismiss_autosave:!0}),T=!0)}function K(){var e;return Y.state("activated").get()?(""!==(e=Y.state("changesetStatus").get())&&"auto-draft"!==e||(e="publish"),Y.state("selectedChangesetStatus").get()===e&&("future"!==Y.state("selectedChangesetStatus").get()||Y.state("selectedChangesetDate").get()===Y.state("changesetDate").get())&&Y.state("saved").get()&&"auto-draft"!==Y.state("changesetStatus").get()):0===Y._latestRevision}function V(){Y.unbind("change",V),Y.state("selectedChangesetStatus").unbind(V),Y.state("selectedChangesetDate").unbind(V),J(window).on("beforeunload.customize-confirm",function(){if(!K()&&!Y.state("changesetLocked").get())return setTimeout(function(){t.removeClass("customize-loading")},1),Y.l10n.saveAlert})}function $(){var e=J.Deferred(),t=!1,n=!1;return K()?n=!0:confirm(Y.l10n.saveAlert)?(n=!0,Y.each(function(e){e._dirty=!1}),J(document).off("visibilitychange.wp-customize-changeset-update"),J(window).off("beforeunload.wp-customize-changeset-update"),i.css("cursor","progress"),""!==Y.state("changesetStatus").get()&&(t=!0)):e.reject(),(n||t)&&wp.ajax.send("customize_dismiss_autosave_or_lock",{timeout:500,data:{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.dismiss_autosave_or_lock,dismiss_autosave:t,dismiss_lock:n}}).always(function(){e.resolve()}),e.promise()}Y.settings=window._wpCustomizeSettings,Y.l10n=window._wpCustomizeControlsL10n,Y.settings&&J.support.postMessage&&(J.support.cors||!Y.settings.isCrossDomain)&&(null===Y.PreviewFrame.prototype.sensitivity&&(Y.PreviewFrame.prototype.sensitivity=Y.settings.timeouts.previewFrameSensitivity),null===Y.Previewer.prototype.refreshBuffer&&(Y.Previewer.prototype.refreshBuffer=Y.settings.timeouts.windowRefresh),o=J(document.body),t=o.children(".wp-full-overlay"),n=J("#customize-info .panel-title.site-title"),i=J(".customize-controls-close"),d=J("#save"),u=J("#customize-save-button-wrapper"),p=J("#publish-settings"),a=J("#customize-footer-actions"),Y.bind("ready",function(){Y.section.add(new Y.OuterSection("publish_settings",{title:Y.l10n.publishSettings,priority:0,active:Y.settings.theme.active}))}),Y.section("publish_settings",function(t){var e,n,i,a,o,s,r;function c(){r=r||Y.utils.highlightButton(u,{delay:1e3,focusTarget:d})}function l(){r&&(r(),r=null)}e=new Y.Control("trash_changeset",{type:"button",section:t.id,priority:30,input_attrs:{class:"button-link button-link-delete",value:Y.l10n.discardChanges}}),Y.control.add(e),e.deferred.embedded.done(function(){e.container.find(".button-link").on("click",function(){confirm(Y.l10n.trashConfirm)&&wp.customize.previewer.trash()})}),Y.control.add(new Y.PreviewLinkControl("changeset_preview_link",{section:t.id,priority:100})),t.active.validate=n=function(){return!!Y.state("activated").get()&&!(Y.state("trashing").get()||"trash"===Y.state("changesetStatus").get()||""===Y.state("changesetStatus").get()&&Y.state("saved").get())},s=function(){t.active.set(n())},Y.state("activated").bind(s),Y.state("trashing").bind(s),Y.state("saved").bind(s),Y.state("changesetStatus").bind(s),s(),(s=function(){p.toggle(t.active.get()),d.toggleClass("has-next-sibling",t.active.get())})(),t.active.bind(s),Y.state("selectedChangesetStatus").bind(l),t.contentContainer.find(".customize-action").text(Y.l10n.updating),t.contentContainer.find(".customize-section-back").removeAttr("tabindex"),p.prop("disabled",!1),p.on("click",function(e){e.preventDefault(),t.expanded.set(!t.expanded.get())}),t.expanded.bind(function(e){p.attr("aria-expanded",String(e)),p.toggleClass("active",e),e?l():(""!==(e=Y.state("changesetStatus").get())&&"auto-draft"!==e||(e="publish"),(Y.state("selectedChangesetStatus").get()!==e||"future"===Y.state("selectedChangesetStatus").get()&&Y.state("selectedChangesetDate").get()!==Y.state("changesetDate").get())&&c())}),s=new Y.Control("changeset_status",{priority:10,type:"radio",section:"publish_settings",setting:Y.state("selectedChangesetStatus"),templateId:"customize-selected-changeset-status-control",label:Y.l10n.action,choices:Y.settings.changeset.statusChoices}),Y.control.add(s),(i=new Y.DateTimeControl("changeset_scheduled_date",{priority:20,section:"publish_settings",setting:Y.state("selectedChangesetDate"),minYear:(new Date).getFullYear(),allowPastDate:!1,includeTime:!0,twelveHourFormat:/a/i.test(Y.settings.timeFormat),description:Y.l10n.scheduleDescription})).notifications.alt=!0,Y.control.add(i),a=function(){Y.state("selectedChangesetStatus").set("publish"),Y.previewer.save()},s=function(){var e="future"===Y.state("changesetStatus").get()&&"future"===Y.state("selectedChangesetStatus").get()&&Y.state("changesetDate").get()&&Y.state("selectedChangesetDate").get()===Y.state("changesetDate").get()&&0<=Y.utils.getRemainingTime(Y.state("changesetDate").get());e&&!o?o=setInterval(function(){var e=Y.utils.getRemainingTime(Y.state("changesetDate").get());Y.state("remainingTimeToPublish").set(e),e<=0&&(clearInterval(o),o=0,a())},1e3):!e&&o&&(clearInterval(o),o=0)},Y.state("changesetDate").bind(s),Y.state("selectedChangesetDate").bind(s),Y.state("changesetStatus").bind(s),Y.state("selectedChangesetStatus").bind(s),s(),i.active.validate=function(){return"future"===Y.state("selectedChangesetStatus").get()},(s=function(e){i.active.set("future"===e)})(Y.state("selectedChangesetStatus").get()),Y.state("selectedChangesetStatus").bind(s),Y.state("saving").bind(function(e){e&&"future"===Y.state("selectedChangesetStatus").get()&&i.toggleFutureDateNotification(!i.isFutureDate())})}),J("#customize-controls").on("keydown",function(e){var t=13===e.which,n=J(e.target);t&&(n.is("input:not([type=button])")||n.is("select"))&&e.preventDefault()}),J(".customize-info").find("> .accordion-section-title .customize-help-toggle").on("click",function(){var e=J(this).closest(".accordion-section"),t=e.find(".customize-panel-description:first");e.hasClass("cannot-expand")||(e.hasClass("open")?(e.toggleClass("open"),t.slideUp(Y.Panel.prototype.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),J(this).attr("aria-expanded",!1)):(t.slideDown(Y.Panel.prototype.defaultExpandedArguments.duration,function(){t.trigger("toggled")}),e.toggleClass("open"),J(this).attr("aria-expanded",!0)))}),Y.previewer=new Y.Previewer({container:"#customize-preview",form:"#customize-controls",previewUrl:Y.settings.url.preview,allowedUrls:Y.settings.url.allowed},{nonce:Y.settings.nonce,query:function(e){var t={wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,nonce:this.nonce.preview,customize_changeset_uuid:Y.settings.changeset.uuid};return!Y.settings.changeset.autosaved&&Y.state("saved").get()||(t.customize_autosaved="on"),t.customized=JSON.stringify(Y.dirtyValues({unsaved:e&&e.excludeCustomizedSaved})),t},save:function(i){var e,t,a=this,o=J.Deferred(),s=Y.state("selectedChangesetStatus").get(),r=Y.state("selectedChangesetDate").get(),n=Y.state("processing"),c={},l=[],d=[],u=[];function p(e){c[e.id]=!0}return i&&i.status&&(s=i.status),Y.state("saving").get()&&(o.reject("already_saving"),o.promise()),Y.state("saving").set(!0),t=function(){var n={},t=Y._latestRevision,e="client_side_error";if(Y.bind("change",p),Y.notifications.remove(e),Y.each(function(t){t.notifications.each(function(e){"error"!==e.type||e.fromServer||(l.push(t.id),n[t.id]||(n[t.id]={}),n[t.id][e.code]=e)})}),Y.control.each(function(t){t.setting&&(t.setting.id||!t.active.get())||t.notifications.each(function(e){"error"===e.type&&u.push([t])})}),d=_.union(u,_.values(Y.findControlsForSettings(l))),!_.isEmpty(d))return d[0][0].focus(),Y.unbind("change",p),l.length&&Y.notifications.add(new Y.Notification(e,{message:(1===l.length?Y.l10n.saveBlockedError.singular:Y.l10n.saveBlockedError.plural).replace(/%s/g,String(l.length)),type:"error",dismissible:!0,saveFailure:!0})),o.rejectWith(a,[{setting_invalidities:n}]),Y.state("saving").set(!1),o.promise();e=J.extend(a.query({excludeCustomizedSaved:!1}),{nonce:a.nonce.save,customize_changeset_status:s}),i&&i.date?e.customize_changeset_date=i.date:"future"===s&&r&&(e.customize_changeset_date=r),i&&i.title&&(e.customize_changeset_title=i.title),Y.trigger("save-request-params",e),e=wp.ajax.post("customize_save",e),Y.state("processing").set(Y.state("processing").get()+1),Y.trigger("save",e),e.always(function(){Y.state("processing").set(Y.state("processing").get()-1),Y.state("saving").set(!1),Y.unbind("change",p)}),Y.notifications.each(function(e){e.saveFailure&&Y.notifications.remove(e.code)}),e.fail(function(e){var t,n={type:"error",dismissible:!0,fromServer:!0,saveFailure:!0};"0"===e?e="not_logged_in":"-1"===e&&(e="invalid_nonce"),"invalid_nonce"===e?a.cheatin():"not_logged_in"===e?(a.preview.iframe.hide(),a.login().done(function(){a.save(),a.preview.iframe.show()})):e.code?"not_future_date"===e.code&&Y.section.has("publish_settings")&&Y.section("publish_settings").active.get()&&Y.control.has("changeset_scheduled_date")?Y.control("changeset_scheduled_date").toggleFutureDateNotification(!0).focus():"changeset_locked"!==e.code&&(t=new Y.Notification(e.code,_.extend(n,{message:e.message}))):t=new Y.Notification("unknown_error",_.extend(n,{message:Y.l10n.unknownRequestFail})),t&&Y.notifications.add(t),e.setting_validities&&Y._handleSettingValidities({settingValidities:e.setting_validities,focusInvalidControl:!0}),o.rejectWith(a,[e]),Y.trigger("error",e),"changeset_already_published"===e.code&&e.next_changeset_uuid&&(Y.settings.changeset.uuid=e.next_changeset_uuid,Y.state("changesetStatus").set(""),Y.settings.changeset.branching&&h.send("changeset-uuid",Y.settings.changeset.uuid),Y.previewer.send("changeset-uuid",Y.settings.changeset.uuid))}),e.done(function(e){a.send("saved",e),Y.state("changesetStatus").set(e.changeset_status),e.changeset_date&&Y.state("changesetDate").set(e.changeset_date),"publish"===e.changeset_status&&(Y.each(function(e){e._dirty&&(_.isUndefined(Y._latestSettingRevisions[e.id])||Y._latestSettingRevisions[e.id]<=t)&&(e._dirty=!1)}),Y.state("changesetStatus").set(""),Y.settings.changeset.uuid=e.next_changeset_uuid,Y.settings.changeset.branching)&&h.send("changeset-uuid",Y.settings.changeset.uuid),Y._lastSavedRevision=Math.max(t,Y._lastSavedRevision),e.setting_validities&&Y._handleSettingValidities({settingValidities:e.setting_validities,focusInvalidControl:!0}),o.resolveWith(a,[e]),Y.trigger("saved",e),_.isEmpty(c)||Y.state("saved").set(!1)})},0===n()?t():(e=function(){0===n()&&(Y.state.unbind("change",e),t())},Y.state.bind("change",e)),o.promise()},trash:function(){var e,n,i;Y.state("trashing").set(!0),Y.state("processing").set(Y.state("processing").get()+1),e=wp.ajax.post("customize_trash",{customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.trash}),Y.notifications.add(new Y.OverlayNotification("changeset_trashing",{type:"info",message:Y.l10n.revertingChanges,loading:!0})),n=function(){var e,t=document.createElement("a");Y.state("changesetStatus").set("trash"),Y.each(function(e){e._dirty=!1}),Y.state("saved").set(!0),t.href=location.href,delete(e=Y.utils.parseQueryString(t.search.substr(1))).changeset_uuid,e.return=Y.settings.url.return,t.search=J.param(e),location.replace(t.href)},i=function(e,t){e=e||"unknown_error";Y.state("processing").set(Y.state("processing").get()-1),Y.state("trashing").set(!1),Y.notifications.remove("changeset_trashing"),Y.notifications.add(new Y.Notification(e,{message:t||Y.l10n.unknownError,dismissible:!0,type:"error"}))},e.done(function(e){n(e.message)}),e.fail(function(e){var t=e.code||"trashing_failed";e.success||"non_existent_changeset"===t||"changeset_already_trashed"===t?n(e.message):i(t,e.message)})},getFrontendPreviewUrl:function(){var e,t=document.createElement("a");return t.href=this.previewUrl.get(),e=Y.utils.parseQueryString(t.search.substr(1)),Y.state("changesetStatus").get()&&"publish"!==Y.state("changesetStatus").get()&&(e.customize_changeset_uuid=Y.settings.changeset.uuid),Y.state("activated").get()||(e.customize_theme=Y.settings.theme.stylesheet),t.search=J.param(e),t.href}}),J.ajaxPrefilter(function(e){/wp_customize=on/.test(e.data)&&(e.data+="&"+J.param({customize_preview_nonce:Y.settings.nonce.preview}))}),Y.previewer.bind("nonce",function(e){J.extend(this.nonce,e)}),Y.bind("nonce-refresh",function(e){J.extend(Y.settings.nonce,e),J.extend(Y.previewer.nonce,e),Y.previewer.send("nonce-refresh",e)}),J.each(Y.settings.settings,function(e,t){var n=Y.settingConstructor[t.type]||Y.Setting;Y.add(new n(e,t.value,{transport:t.transport,previewer:Y.previewer,dirty:!!t.dirty}))}),J.each(Y.settings.panels,function(e,t){var n=Y.panelConstructor[t.type]||Y.Panel,t=_.extend({params:t},t);Y.panel.add(new n(e,t))}),J.each(Y.settings.sections,function(e,t){var n=Y.sectionConstructor[t.type]||Y.Section,t=_.extend({params:t},t);Y.section.add(new n(e,t))}),J.each(Y.settings.controls,function(e,t){var n=Y.controlConstructor[t.type]||Y.Control,t=_.extend({params:t},t);Y.control.add(new n(e,t))}),_.each(["panel","section","control"],function(e){var t=Y.settings.autofocus[e];t&&Y[e](t,function(e){e.deferred.embedded.done(function(){Y.previewer.deferred.active.done(function(){e.focus()})})})}),Y.bind("ready",Y.reflowPaneContents),J([Y.panel,Y.section,Y.control]).each(function(e,t){var n=_.debounce(Y.reflowPaneContents,Y.settings.timeouts.reflowPaneContents);t.bind("add",n),t.bind("change",n),t.bind("remove",n)}),Y.bind("ready",function(){var e,t,n;Y.notifications.container=J("#customize-notifications-area"),Y.notifications.bind("change",_.debounce(function(){Y.notifications.render()})),e=J(".wp-full-overlay-sidebar-content"),Y.notifications.bind("rendered",function(){e.css("top",""),0!==Y.notifications.count()&&(t=Y.notifications.container.outerHeight()+1,n=parseInt(e.css("top"),10),e.css("top",n+t+"px")),Y.notifications.trigger("sidebarTopUpdated")}),Y.notifications.render()}),s=Y.state,c=s.instance("saved"),l=s.instance("saving"),f=s.instance("trashing"),m=s.instance("activated"),e=s.instance("processing"),I=s.instance("paneVisible"),H=s.instance("expandedPanel"),L=s.instance("expandedSection"),g=s.instance("changesetStatus"),v=s.instance("selectedChangesetStatus"),w=s.instance("changesetDate"),b=s.instance("selectedChangesetDate"),M=s.instance("previewerAlive"),O=s.instance("editShortcutVisibility"),C=s.instance("changesetLocked"),s.bind("change",function(){var e;m()?""===g.get()&&c()?(Y.settings.changeset.currentUserCanPublish?d.val(Y.l10n.published):d.val(Y.l10n.saved),i.find(".screen-reader-text").text(Y.l10n.close)):("draft"===v()?c()&&v()===g()?d.val(Y.l10n.draftSaved):d.val(Y.l10n.saveDraft):"future"===v()?!c()||v()!==g()||w.get()!==b.get()?d.val(Y.l10n.schedule):d.val(Y.l10n.scheduled):Y.settings.changeset.currentUserCanPublish&&d.val(Y.l10n.publish),i.find(".screen-reader-text").text(Y.l10n.cancel)):(d.val(Y.l10n.activate),i.find(".screen-reader-text").text(Y.l10n.cancel)),e=!l()&&!f()&&!C()&&(!m()||!c()||g()!==v()&&""!==g()||"future"===v()&&w.get()!==b.get()),d.prop("disabled",!e)}),v.validate=function(e){return""===e||"auto-draft"===e?null:e},S=Y.settings.changeset.currentUserCanPublish?"publish":"draft",g(Y.settings.changeset.status),C(Boolean(Y.settings.changeset.lockUser)),w(Y.settings.changeset.publishDate),b(Y.settings.changeset.publishDate),v(""===Y.settings.changeset.status||"auto-draft"===Y.settings.changeset.status?S:Y.settings.changeset.status),v.link(g),c(!0),""===g()&&Y.each(function(e){e._dirty&&c(!1)}),l(!1),m(Y.settings.theme.active),e(0),I(!0),H(!1),L(!1),M(!0),O("visible"),Y.bind("change",function(){s("saved").get()&&s("saved").set(!1)}),Y.settings.changeset.branching&&c.bind(function(e){e||r(!0)}),l.bind(function(e){o.toggleClass("saving",e)}),f.bind(function(e){o.toggleClass("trashing",e)}),Y.bind("saved",function(e){s("saved").set(!0),"publish"===e.changeset_status&&s("activated").set(!0)}),m.bind(function(e){e&&Y.trigger("activated")}),r=function(e){var t,n;if(history.replaceState){if((t=document.createElement("a")).href=location.href,n=Y.utils.parseQueryString(t.search.substr(1)),e){if(n.changeset_uuid===Y.settings.changeset.uuid)return;n.changeset_uuid=Y.settings.changeset.uuid}else{if(!n.changeset_uuid)return;delete n.changeset_uuid}t.search=J.param(n),history.replaceState({},document.title,t.href)}},Y.settings.changeset.branching&&g.bind(function(e){r(""!==e&&"publish"!==e&&"trash"!==e)}),j=Y.OverlayNotification.extend({templateId:"customize-changeset-locked-notification",lockUser:null,initialize:function(e,t){e=e||"changeset_locked",t=_.extend({message:"",type:"warning",containerClasses:"",lockUser:{}},t);t.containerClasses+=" notification-changeset-locked",Y.OverlayNotification.prototype.initialize.call(this,e,t)},render:function(){var t,n,i=this,e=_.extend({allowOverride:!1,returnUrl:Y.settings.url.return,previewUrl:Y.previewer.previewUrl.get(),frontendPreviewUrl:Y.previewer.getFrontendPreviewUrl()},this),a=Y.OverlayNotification.prototype.render.call(e);return Y.requestChangesetUpdate({},{autosave:!0}).fail(function(e){e.autosaved||a.find(".notice-error").prop("hidden",!1).text(e.message||Y.l10n.unknownRequestFail)}),(t=a.find(".customize-notice-take-over-button")).on("click",function(e){e.preventDefault(),n||(t.addClass("disabled"),(n=wp.ajax.post("customize_override_changeset_lock",{wp_customize:"on",customize_theme:Y.settings.theme.stylesheet,customize_changeset_uuid:Y.settings.changeset.uuid,nonce:Y.settings.nonce.override_lock})).done(function(){Y.notifications.remove(i.code),Y.state("changesetLocked").set(!1)}),n.fail(function(e){e=e.message||Y.l10n.unknownRequestFail;a.find(".notice-error").prop("hidden",!1).text(e),n.always(function(){t.removeClass("disabled")})}),n.always(function(){n=null}))}),a}}),Y.settings.changeset.lockUser&&F({allowOverride:!0}),J(document).on("heartbeat-send.update_lock_notice",function(e,t){t.check_changeset_lock=!0,t.changeset_uuid=Y.settings.changeset.uuid}),J(document).on("heartbeat-tick.update_lock_notice",function(e,t){var n,i="changeset_locked";t.customize_changeset_lock_user&&((n=Y.notifications(i))&&n.lockUser.id!==Y.settings.changeset.lockUser.id&&Y.notifications.remove(i),F({lockUser:t.customize_changeset_lock_user}))}),Y.bind("error",function(e){"changeset_locked"===e.code&&e.lock_user&&F({lockUser:e.lock_user})}),T=!(S=[]),Y.settings.changeset.autosaved&&(Y.state("saved").set(!1),S.push("customize_autosaved")),Y.settings.changeset.branching||Y.settings.changeset.status&&"auto-draft"!==Y.settings.changeset.status||S.push("changeset_uuid"),0<S.length&&(S=S,e=document.createElement("a"),x=0,e.href=location.href,y=Y.utils.parseQueryString(e.search.substr(1)),_.each(S,function(e){void 0!==y[e]&&(x+=1,delete y[e])}),0!==x)&&(e.search=J.param(y),history.replaceState({},document.title,e.href)),(Y.settings.changeset.latestAutoDraftUuid||Y.settings.changeset.hasAutosaveRevision)&&(z="autosave_available",Y.notifications.add(new Y.Notification(z,{message:Y.l10n.autosaveNotice,type:"warning",dismissible:!0,render:function(){var e=Y.Notification.prototype.render.call(this),t=e.find("a");return t.prop("href",q()),t.on("click",function(e){e.preventDefault(),location.replace(q())}),e.find(".notice-dismiss").on("click",Q),e}})),Y.bind("change",k=function(){Q(),Y.notifications.remove(z),Y.unbind("change",k),Y.state("changesetStatus").unbind(k)}),Y.state("changesetStatus").bind(k)),parseInt(J("#customize-info").data("block-theme"),10)&&(S=Y.l10n.blockThemeNotification,Y.notifications.add(new Y.Notification("site_editor_block_theme_notice",{message:S,type:"info",dismissible:!1,render:function(){var e=Y.Notification.prototype.render.call(this),t=e.find("button.switch-to-editor");return t.on("click",function(e){e.preventDefault(),location.assign(t.data("action"))}),e}}))),Y.previewer.previewUrl()?Y.previewer.refresh():Y.previewer.previewUrl(Y.settings.url.home),d.on("click",function(e){Y.previewer.save(),e.preventDefault()}).on("keydown",function(e){9!==e.which&&(13===e.which&&Y.previewer.save(),e.preventDefault())}),i.on("keydown",function(e){9!==e.which&&(13===e.which&&this.click(),e.preventDefault())}),J(".collapse-sidebar").on("click",function(){Y.state("paneVisible").set(!Y.state("paneVisible").get())}),Y.state("paneVisible").bind(function(e){t.toggleClass("preview-only",!e),t.toggleClass("expanded",e),t.toggleClass("collapsed",!e),e?J(".collapse-sidebar").attr({"aria-expanded":"true","aria-label":Y.l10n.collapseSidebar}):J(".collapse-sidebar").attr({"aria-expanded":"false","aria-label":Y.l10n.expandSidebar})}),o.on("keydown",function(e){var t,n=[],i=[],a=[];27===e.which&&(J(e.target).is("body")||J.contains(J("#customize-controls")[0],e.target))&&null===e.target.closest(".block-editor-writing-flow")&&null===e.target.closest(".block-editor-block-list__block-popover")&&(Y.control.each(function(e){e.expanded&&e.expanded()&&_.isFunction(e.collapse)&&n.push(e)}),Y.section.each(function(e){e.expanded()&&i.push(e)}),Y.panel.each(function(e){e.expanded()&&a.push(e)}),0<n.length&&0===i.length&&(n.length=0),t=n[0]||i[0]||a[0])&&("themes"===t.params.type?o.hasClass("modal-open")?t.closeDetails():Y.panel.has("themes")&&Y.panel("themes").collapse():(t.collapse(),e.preventDefault()))}),J(".customize-controls-preview-toggle").on("click",function(){Y.state("paneVisible").set(!Y.state("paneVisible").get())}),P=J(".wp-full-overlay-sidebar-content"),I=function(e){var t=Y.state("expandedSection").get(),n=Y.state("expandedPanel").get();if(D&&D.element&&(R(D.element),D.element.find(".description").off("toggled",E)),!e)if(!t&&n&&n.contentContainer)e=n;else{if(n||!t||!t.contentContainer)return void(D=!1);e=t}(n=e.contentContainer.find(".customize-section-title, .panel-meta").first()).length?((D={instance:e,element:n,parent:n.closest(".customize-pane-child"),height:n.outerHeight()}).element.find(".description").on("toggled",E),t&&B(D.element,D.parent)):D=!1},Y.state("expandedSection").bind(I),Y.state("expandedPanel").bind(I),P.on("scroll",_.throttle(function(){var e,t;D&&(e=P.scrollTop(),t=N?e===N?0:N<e?1:-1:1,N=e,0!==t)&&W(D,e,t)},8)),Y.notifications.bind("sidebarTopUpdated",function(){D&&D.element.hasClass("is-sticky")&&D.element.css("top",P.css("top"))}),R=function(e){e.hasClass("is-sticky")&&e.removeClass("is-sticky").addClass("maybe-sticky is-in-view").css("top",P.scrollTop()+"px")},B=function(e,t){e.hasClass("is-in-view")&&(e.removeClass("maybe-sticky is-in-view").css({width:"",top:""}),t.css("padding-top",""))},E=function(){D.height=D.element.outerHeight()},W=function(e,t,n){var i=e.element,a=e.parent,e=e.height,o=parseInt(i.css("top"),10),s=i.hasClass("maybe-sticky"),r=i.hasClass("is-sticky"),c=i.hasClass("is-in-view");if(-1===n){if(!s&&e<=t)s=!0,i.addClass("maybe-sticky");else if(0===t)return i.removeClass("maybe-sticky is-in-view is-sticky").css({top:"",width:""}),void a.css("padding-top","");c&&!r?t<=o&&i.addClass("is-sticky").css({top:P.css("top"),width:a.outerWidth()+"px"}):s&&!c&&(i.addClass("is-in-view").css("top",t-e+"px"),a.css("padding-top",e+"px"))}else r&&(o=t,i.removeClass("is-sticky").css({top:o+"px",width:""})),c&&o+e<t&&(i.removeClass("is-in-view"),a.css("padding-top",""))},Y.previewedDevice=Y.state("previewedDevice"),Y.bind("ready",function(){_.find(Y.settings.previewableDevices,function(e,t){if(!0===e.default)return Y.previewedDevice.set(t),!0})}),a.find(".devices button").on("click",function(e){Y.previewedDevice.set(J(e.currentTarget).data("device"))}),Y.previewedDevice.bind(function(e){var t=J(".wp-full-overlay"),n="";a.find(".devices button").removeClass("active").attr("aria-pressed",!1),a.find(".devices .preview-"+e).addClass("active").attr("aria-pressed",!0),J.each(Y.settings.previewableDevices,function(e){n+=" preview-"+e}),t.removeClass(n).addClass("preview-"+e)}),n.length&&Y("blogname",function(t){function e(){var e=t()||"";n.text(e.toString().trim()||Y.l10n.untitledBlogName)}t.bind(e),e()}),h=new Y.Messenger({url:Y.settings.url.parent,channel:"loader"}),U=!1,h.bind("back",function(){U=!0}),Y.bind("change",V),Y.state("selectedChangesetStatus").bind(V),Y.state("selectedChangesetDate").bind(V),h.bind("confirm-close",function(){$().done(function(){h.send("confirmed-close",!0)}).fail(function(){h.send("confirmed-close",!1)})}),i.on("click.customize-controls-close",function(e){e.preventDefault(),U?h.send("close"):$().done(function(){J(window).off("beforeunload.customize-confirm"),window.location.href=i.prop("href")})}),J.each(["saved","change"],function(e,t){Y.bind(t,function(){h.send(t)})}),Y.bind("title",function(e){h.send("title",e)}),Y.settings.changeset.branching&&h.send("changeset-uuid",Y.settings.changeset.uuid),h.send("ready"),J.each({background_image:{controls:["background_preset","background_position","background_size","background_repeat","background_attachment"],callback:function(e){return!!e}},show_on_front:{controls:["page_on_front","page_for_posts"],callback:function(e){return"page"===e}},header_textcolor:{controls:["header_textcolor"],callback:function(e){return"blank"!==e}}},function(e,i){Y(e,function(n){J.each(i.controls,function(e,t){Y.control(t,function(t){function e(e){t.container.toggle(i.callback(e))}e(n.get()),n.bind(e)})})})}),Y.control("background_preset",function(e){var i={default:[!1,!1,!1,!1],fill:[!0,!1,!1,!1],fit:[!0,!1,!0,!1],repeat:[!0,!1,!1,!0],custom:[!0,!0,!0,!0]},a={default:[_wpCustomizeBackground.defaults["default-position-x"],_wpCustomizeBackground.defaults["default-position-y"],_wpCustomizeBackground.defaults["default-size"],_wpCustomizeBackground.defaults["default-repeat"],_wpCustomizeBackground.defaults["default-attachment"]],fill:["left","top","cover","no-repeat","fixed"],fit:["left","top","contain","no-repeat","fixed"],repeat:["left","top","auto","repeat","scroll"]},t=function(n){_.each(["background_position","background_size","background_repeat","background_attachment"],function(e,t){e=Y.control(e);e&&e.container.toggle(i[n][t])})},n=function(n){_.each(["background_position_x","background_position_y","background_size","background_repeat","background_attachment"],function(e,t){e=Y(e);e&&e.set(a[n][t])})},o=e.setting.get();t(o),e.setting.bind("change",function(e){t(e),"custom"!==e&&n(e)})}),Y.control("background_repeat",function(t){t.elements[0].unsync(Y("background_repeat")),t.element=new Y.Element(t.container.find("input")),t.element.set("no-repeat"!==t.setting()),t.element.bind(function(e){t.setting.set(e?"repeat":"no-repeat")}),t.setting.bind(function(e){t.element.set("no-repeat"!==e)})}),Y.control("background_attachment",function(t){t.elements[0].unsync(Y("background_attachment")),t.element=new Y.Element(t.container.find("input")),t.element.set("fixed"!==t.setting()),t.element.bind(function(e){t.setting.set(e?"scroll":"fixed")}),t.setting.bind(function(e){t.element.set("fixed"!==e)})}),Y.control("display_header_text",function(t){var n="";t.elements[0].unsync(Y("header_textcolor")),t.element=new Y.Element(t.container.find("input")),t.element.set("blank"!==t.setting()),t.element.bind(function(e){e||(n=Y("header_textcolor").get()),t.setting.set(e?n:"blank")}),t.setting.bind(function(e){t.element.set("blank"!==e)})}),Y("show_on_front","page_on_front","page_for_posts",function(i,a,o){function e(){var e="show_on_front_page_collision",t=parseInt(a(),10),n=parseInt(o(),10);"page"===i()&&(this===a&&0<t&&Y.previewer.previewUrl.set(Y.settings.url.home),this===o)&&0<n&&Y.previewer.previewUrl.set(Y.settings.url.home+"?page_id="+n),"page"===i()&&t&&n&&t===n?i.notifications.add(new Y.Notification(e,{type:"error",message:Y.l10n.pageOnFrontError})):i.notifications.remove(e)}i.bind(e),a.bind(e),o.bind(e),e.call(i,i()),Y.control("show_on_front",function(e){e.deferred.embedded.done(function(){e.container.append(e.getNotificationsContainerElement())})})}),A=J.Deferred(),Y.section("custom_css",function(t){t.deferred.embedded.done(function(){t.expanded()?A.resolve(t):t.expanded.bind(function(e){e&&A.resolve(t)})})}),A.done(function(e){var t=Y.control("custom_css");t.container.find(".customize-control-title:first").addClass("screen-reader-text"),e.container.find(".section-description-buttons .section-description-close").on("click",function(){e.container.find(".section-meta .customize-section-description:first").removeClass("open").slideUp(),e.container.find(".customize-help-toggle").attr("aria-expanded","false").focus()}),t&&!t.setting.get()&&(e.container.find(".section-meta .customize-section-description:first").addClass("open").show().trigger("toggled"),e.container.find(".customize-help-toggle").attr("aria-expanded","true"))}),Y.control("header_video",function(n){n.deferred.embedded.done(function(){function e(){var e=Y.section(n.section()),t="video_header_not_available";e&&(n.active.get()?e.notifications.remove(t):e.notifications.add(new Y.Notification(t,{type:"info",message:Y.l10n.videoHeaderNotice})))}e(),n.active.bind(e)})}),Y.previewer.bind("selective-refresh-setting-validities",function(e){Y._handleSettingValidities({settingValidities:e,focusInvalidControl:!1})}),Y.previewer.bind("focus-control-for-setting",function(n){var i=[];Y.control.each(function(e){var t=_.pluck(e.settings,"id");-1!==_.indexOf(t,n)&&i.push(e)}),i.length&&(i.sort(function(e,t){return e.priority()-t.priority()}),i[0].focus())}),Y.previewer.bind("refresh",function(){Y.previewer.refresh()}),Y.state("paneVisible").bind(function(e){var t=window.matchMedia?window.matchMedia("screen and ( max-width: 640px )").matches:J(window).width()<=640;Y.state("editShortcutVisibility").set(e||t?"visible":"hidden")}),window.matchMedia&&window.matchMedia("screen and ( max-width: 640px )").addListener(function(){var e=Y.state("paneVisible");e.callbacks.fireWith(e,[e.get(),e.get()])}),Y.previewer.bind("edit-shortcut-visibility",function(e){Y.state("editShortcutVisibility").set(e)}),Y.state("editShortcutVisibility").bind(function(e){Y.previewer.send("edit-shortcut-visibility",e)}),Y.bind("change",function e(){var t,n,i,a=!1;function o(e){e||Y.settings.changeset.autosaved||(Y.settings.changeset.autosaved=!0,Y.previewer.send("autosaving"))}Y.unbind("change",e),Y.state("saved").bind(o),o(Y.state("saved").get()),n=function(){a||(a=!0,Y.requestChangesetUpdate({},{autosave:!0}).always(function(){a=!1})),i()},(i=function(){clearTimeout(t),t=setTimeout(function(){n()},Y.settings.timeouts.changesetAutoSave)})(),J(document).on("visibilitychange.wp-customize-changeset-update",function(){document.hidden&&n()}),J(window).on("beforeunload.wp-customize-changeset-update",function(){n()})}),J(document).one("tinymce-editor-setup",function(){window.tinymce.ui.FloatPanel&&(!window.tinymce.ui.FloatPanel.zIndex||window.tinymce.ui.FloatPanel.zIndex<500001)&&(window.tinymce.ui.FloatPanel.zIndex=500001)}),o.addClass("ready"),Y.trigger("ready"))})}((wp,jQuery));
\ No newline at end of file diff --git a/wp-admin/js/customize-nav-menus.js b/wp-admin/js/customize-nav-menus.js index 9dad3e1..2b5cea3 100644 --- a/wp-admin/js/customize-nav-menus.js +++ b/wp-admin/js/customize-nav-menus.js @@ -2,7 +2,7 @@ * @output wp-admin/js/customize-nav-menus.js */ -/* global _wpCustomizeNavMenusSettings, wpNavMenu, console */ +/* global menus, _wpCustomizeNavMenusSettings, wpNavMenu, console */ ( function( api, wp, $ ) { 'use strict'; @@ -1132,6 +1132,8 @@ $( '#menu-to-edit' ).removeAttr( 'id' ); wpNavMenu.menuList.attr( 'id', 'menu-to-edit' ).addClass( 'menu' ); + api.Menus.MenuItemControl.prototype.initAccessibility(); + _.each( api.section( section.id ).controls(), function( control ) { if ( 'nav_menu_item' === control.params.type ) { control.actuallyEmbed(); @@ -1575,6 +1577,80 @@ }, /** + * Set up the initial state of the screen reader accessibility information for menu items. + * + * @since 6.6.0 + */ + initAccessibility: function() { + var control = this, + menu = $( '#menu-to-edit' ); + + // Refresh the accessibility when the user comes close to the item in any way. + menu.on( 'mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility', '.menu-item', function(){ + control.refreshAdvancedAccessibilityOfItem( $( this ).find( 'button.item-edit' ) ); + } ); + + // We have to update on click as well because we might hover first, change the item, and then click. + menu.on( 'click', 'button.item-edit', function() { + control.refreshAdvancedAccessibilityOfItem( $( this ) ); + } ); + }, + + /** + * refreshAdvancedAccessibilityOfItem( [itemToRefresh] ) + * + * Refreshes advanced accessibility buttons for one menu item. + * Shows or hides buttons based on the location of the menu item. + * + * @param {Object} itemToRefresh The menu item that might need its advanced accessibility buttons refreshed + * + * @since 6.6.0 + */ + refreshAdvancedAccessibilityOfItem: function( itemToRefresh ) { + // Only refresh accessibility when necessary. + if ( true !== $( itemToRefresh ).data( 'needs_accessibility_refresh' ) ) { + return; + } + + var primaryItems, itemPosition, title, + parentItem, parentItemId, parentItemName, subItems, totalSubItems, + $this = $( itemToRefresh ), + menuItem = $this.closest( 'li.menu-item' ).first(), + depth = menuItem.menuItemDepth(), + isPrimaryMenuItem = ( 0 === depth ), + itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), + menuItemType = $this.closest( '.menu-item-handle' ).find( '.item-type' ).text(), + totalMenuItems = $( '#menu-to-edit li' ).length; + + if ( isPrimaryMenuItem ) { + primaryItems = $( '.menu-item-depth-0' ), + itemPosition = primaryItems.index( menuItem ) + 1, + totalMenuItems = primaryItems.length, + // String together help text for primary menu items. + title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$s', menuItemType ).replace( '%3$d', itemPosition ).replace( '%4$d', totalMenuItems ); + } else { + parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(), + parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), + parentItemName = parentItem.find( '.menu-item-title' ).text(), + subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), + totalSubItems = subItems.length, + itemPosition = $( subItems.parents( '.menu-item' ).get().reverse() ).index( menuItem ) + 1; + + // String together help text for sub menu items. + if ( depth < 2 ) { + title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$s', menuItemType ).replace( '%3$d', itemPosition ).replace( '%4$d', totalSubItems ).replace( '%5$s', parentItemName ); + } else { + title = menus.subMenuMoreDepthFocus.replace( '%1$s', itemName ).replace( '%2$s', menuItemType ).replace( '%3$d', itemPosition ).replace( '%4$d', totalSubItems ).replace( '%5$s', parentItemName ).replace( '%6$d', depth ); + } + } + + $this.find( '.screen-reader-text' ).text( title ); + + // Mark this item's accessibility as refreshed. + $this.data( 'needs_accessibility_refresh', false ); + }, + + /** * Override the embed() method to do nothing, * so that the control isn't embedded on load, * unless the containing section is already expanded. @@ -1607,6 +1683,9 @@ } control.renderContent(); control.deferred.embedded.resolve(); // This triggers control.ready(). + + // Mark all menu items as unprocessed. + $( 'button.item-edit' ).data( 'needs_accessibility_refresh', true ); }, /** @@ -1679,22 +1758,15 @@ control.moveDown(); } else if ( isMoveLeft ) { control.moveLeft(); - if ( 1 === control.params.depth ) { - control.container.find( '.is-submenu' ).hide(); - } else { - control.container.find( '.is-submenu' ).show(); - } } else if ( isMoveRight ) { control.moveRight(); control.params.depth += 1; - if ( 0 === control.params.depth ) { - control.container.find( '.is-submenu' ).hide(); - } else { - control.container.find( '.is-submenu' ).show(); - } } - + moveBtn.focus(); // Re-focus after the container was moved. + + // Mark all menu items as unprocessed. + $( 'button.item-edit' ).data( 'needs_accessibility_refresh', true ); } ); }, @@ -2726,6 +2798,9 @@ menuItemControl.setting.set( setting ); }); + + // Mark all menu items as unprocessed. + $( 'button.item-edit' ).data( 'needs_accessibility_refresh', true ); }); }); diff --git a/wp-admin/js/customize-nav-menus.min.js b/wp-admin/js/customize-nav-menus.min.js index 56d54b3..e0c0ca4 100644 --- a/wp-admin/js/customize-nav-menus.min.js +++ b/wp-admin/js/customize-nav-menus.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(c,l,m){"use strict";function u(e){return(e=(e=l.sanitize.stripTagsAndEncodeText(e=e||"")).toString().trim())||c.Menus.data.l10n.unnamed}wpNavMenu.originalInit=wpNavMenu.init,wpNavMenu.options.menuItemDepthPerLevel=20,wpNavMenu.options.sortableItems="> .customize-control-nav_menu_item",wpNavMenu.options.targetTolerance=10,wpNavMenu.init=function(){this.jQueryExtensions()},c.Menus=c.Menus||{},c.Menus.data={itemTypes:[],l10n:{},settingTransport:"refresh",phpIntMax:0,defaultSettingValues:{nav_menu:{},nav_menu_item:{}},locationSlugMappedToName:{}},"undefined"!=typeof _wpCustomizeNavMenusSettings&&m.extend(c.Menus.data,_wpCustomizeNavMenusSettings),c.Menus.generatePlaceholderAutoIncrementId=function(){return-Math.ceil(c.Menus.data.phpIntMax*Math.random())},c.Menus.AvailableItemModel=Backbone.Model.extend(m.extend({id:null},c.Menus.data.defaultSettingValues.nav_menu_item)),c.Menus.AvailableItemCollection=Backbone.Collection.extend({model:c.Menus.AvailableItemModel,sort_key:"order",comparator:function(e){return-e.get(this.sort_key)},sortByField:function(e){this.sort_key=e,this.sort()}}),c.Menus.availableMenuItems=new c.Menus.AvailableItemCollection(c.Menus.data.availableMenuItems),c.Menus.insertAutoDraftPost=function(n){var i=m.Deferred(),e=l.ajax.post("customize-nav-menus-insert-auto-draft",{"customize-menus-nonce":c.settings.nonce["customize-menus"],wp_customize:"on",customize_changeset_uuid:c.settings.changeset.uuid,params:n});return e.done(function(t){t.post_id&&(c("nav_menus_created_posts").set(c("nav_menus_created_posts").get().concat([t.post_id])),"page"===n.post_type&&(c.section.has("static_front_page")&&c.section("static_front_page").activate(),c.control.each(function(e){"dropdown-pages"===e.params.type&&e.container.find('select[name^="_customize-dropdown-pages-"]').append(new Option(n.post_title,t.post_id))})),i.resolve(t))}),e.fail(function(e){var t=e||"";void 0!==e.message&&(t=e.message),console.error(t),i.rejectWith(t)}),i.promise()},c.Menus.AvailableMenuItemsPanelView=l.Backbone.View.extend({el:"#available-menu-items",events:{"input #menu-items-search":"debounceSearch","focus .menu-item-tpl":"focus","click .menu-item-tpl":"_submit","click #custom-menu-item-submit":"_submitLink","keypress #custom-menu-item-name":"_submitLink","click .new-content-item .add-content":"_submitNew","keypress .create-item-input":"_submitNew",keydown:"keyboardAccessible"},selected:null,currentMenuControl:null,debounceSearch:null,$search:null,$clearResults:null,searchTerm:"",rendered:!1,pages:{},sectionContent:"",loading:!1,addingNew:!1,initialize:function(){var n=this;c.panel.has("nav_menus")&&(this.$search=m("#menu-items-search"),this.$clearResults=this.$el.find(".clear-results"),this.sectionContent=this.$el.find(".available-menu-items-list"),this.debounceSearch=_.debounce(n.search,500),_.bindAll(this,"close"),m("#customize-controls, .customize-section-back").on("click keydown",function(e){var t=m(e.target).is(".item-delete, .item-delete *"),e=m(e.target).is(".add-new-menu-item, .add-new-menu-item *");!m("body").hasClass("adding-menu-items")||t||e||n.close()}),this.$clearResults.on("click",function(){n.$search.val("").trigger("focus").trigger("input")}),this.$el.on("input","#custom-menu-item-name.invalid, #custom-menu-item-url.invalid",function(){m(this).removeClass("invalid")}),c.panel("nav_menus").container.on("expanded",function(){n.rendered||(n.initList(),n.rendered=!0)}),this.sectionContent.on("scroll",function(){var e=n.$el.find(".accordion-section.open .available-menu-items-list").prop("scrollHeight"),t=n.$el.find(".accordion-section.open").height();!n.loading&&m(this).scrollTop()>.75*e-t&&(e=m(this).data("type"),t=m(this).data("object"),"search"===e?n.searchTerm&&n.doSearch(n.pages.search):n.loadItems([{type:e,object:t}]))}),c.previewer.bind("url",this.close),n.delegateEvents())},search:function(e){var t=m("#available-menu-items-search"),n=m("#available-menu-items .accordion-section").not(t);e&&this.searchTerm!==e.target.value&&(""===e.target.value||t.hasClass("open")?""===e.target.value&&(t.removeClass("open"),n.show(),this.$clearResults.removeClass("is-visible")):(n.fadeOut(100),t.find(".accordion-section-content").slideDown("fast"),t.addClass("open"),this.$clearResults.addClass("is-visible")),this.searchTerm=e.target.value,this.pages.search=1,this.doSearch(1))},doSearch:function(t){var e,n=this,i=m("#available-menu-items-search"),a=i.find(".accordion-section-content"),o=l.template("available-menu-item");if(n.currentRequest&&n.currentRequest.abort(),!(t<0)){if(1<t)i.addClass("loading-more"),a.attr("aria-busy","true"),l.a11y.speak(c.Menus.data.l10n.itemsLoadingMore);else if(""===n.searchTerm)return a.html(""),void l.a11y.speak("");i.addClass("loading"),n.loading=!0,e=c.previewer.query({excludeCustomizedSaved:!0}),_.extend(e,{"customize-menus-nonce":c.settings.nonce["customize-menus"],wp_customize:"on",search:n.searchTerm,page:t}),n.currentRequest=l.ajax.post("search-available-menu-items-customizer",e),n.currentRequest.done(function(e){1===t&&a.empty(),i.removeClass("loading loading-more"),a.attr("aria-busy","false"),i.addClass("open"),n.loading=!1,e=new c.Menus.AvailableItemCollection(e.items),n.collection.add(e.models),e.each(function(e){a.append(o(e.attributes))}),e.length<20?n.pages.search=-1:n.pages.search=n.pages.search+1,e&&1<t?l.a11y.speak(c.Menus.data.l10n.itemsFoundMore.replace("%d",e.length)):e&&1===t&&l.a11y.speak(c.Menus.data.l10n.itemsFound.replace("%d",e.length))}),n.currentRequest.fail(function(e){e.message&&(a.empty().append(m('<li class="nothing-found"></li>').text(e.message)),l.a11y.speak(e.message)),n.pages.search=-1}),n.currentRequest.always(function(){i.removeClass("loading loading-more"),a.attr("aria-busy","false"),n.loading=!1,n.currentRequest=null})}},initList:function(){var t=this;_.each(c.Menus.data.itemTypes,function(e){t.pages[e.type+":"+e.object]=0}),t.loadItems(c.Menus.data.itemTypes)},loadItems:function(e,t){var i=this,a=[],o={},s=l.template("available-menu-item"),t=_.isString(e)&&_.isString(t)?[{type:e,object:t}]:e;_.each(t,function(e){var t,n=e.type+":"+e.object;-1!==i.pages[n]&&((t=m("#available-menu-items-"+e.type+"-"+e.object)).find(".accordion-section-title").addClass("loading"),o[n]=t,a.push({object:e.object,type:e.type,page:i.pages[n]}))}),0!==a.length&&(i.loading=!0,e=c.previewer.query({excludeCustomizedSaved:!0}),_.extend(e,{"customize-menus-nonce":c.settings.nonce["customize-menus"],wp_customize:"on",item_types:a}),(t=l.ajax.post("load-available-menu-items-customizer",e)).done(function(e){var n;_.each(e.items,function(e,t){0===e.length?(0===i.pages[t]&&o[t].find(".accordion-section-title").addClass("cannot-expand").removeClass("loading").find(".accordion-section-title > button").prop("tabIndex",-1),i.pages[t]=-1):("post_type:page"!==t||o[t].hasClass("open")||o[t].find(".accordion-section-title > button").trigger("click"),e=new c.Menus.AvailableItemCollection(e),i.collection.add(e.models),n=o[t].find(".available-menu-items-list"),e.each(function(e){n.append(s(e.attributes))}),i.pages[t]+=1)})}),t.fail(function(e){"undefined"!=typeof console&&console.error&&console.error(e)}),t.always(function(){_.each(o,function(e){e.find(".accordion-section-title").removeClass("loading")}),i.loading=!1}))},itemSectionHeight:function(){var e=window.innerHeight,t=this.$el.find(".accordion-section:not( #available-menu-items-search ) .accordion-section-content"),n=this.$el.find('.accordion-section:not( #available-menu-items-search ) .available-menu-items-list:not(":only-child")'),e=e-(46*(1+t.length)+14);120<e&&e<290&&(t.css("max-height",e),n.css("max-height",e-60))},select:function(e){this.selected=m(e),this.selected.siblings(".menu-item-tpl").removeClass("selected"),this.selected.addClass("selected")},focus:function(e){this.select(m(e.currentTarget))},_submit:function(e){"keypress"===e.type&&13!==e.which&&32!==e.which||this.submit(m(e.currentTarget))},submit:function(e){var t;(e=e||this.selected)&&this.currentMenuControl&&(this.select(e),t=m(this.selected).data("menu-item-id"),t=this.collection.findWhere({id:t}))&&(this.currentMenuControl.addItemToMenu(t.attributes),m(e).find(".menu-item-handle").addClass("item-added"))},_submitLink:function(e){"keypress"===e.type&&13!==e.which||this.submitLink()},submitLink:function(){var e,t=m("#custom-menu-item-name"),n=m("#custom-menu-item-url"),i=n.val().trim();this.currentMenuControl&&(e=/^((\w+:)?\/\/\w.*|\w+:(?!\/\/$)|\/|\?|#)/,""===t.val()?t.addClass("invalid"):e.test(i)?(e={title:t.val(),url:i,type:"custom",type_label:c.Menus.data.l10n.custom_label,object:"custom"},this.currentMenuControl.addItemToMenu(e),n.val("").attr("placeholder","https://"),t.val("")):n.addClass("invalid"))},_submitNew:function(e){"keypress"===e.type&&13!==e.which||this.addingNew||(e=m(e.target).closest(".accordion-section"),this.submitNew(e))},submitNew:function(n){var i=this,a=n.find(".create-item-input"),e=a.val(),t=n.find(".available-menu-items-list"),o=t.data("type"),s=t.data("object"),r=t.data("type_label");this.currentMenuControl&&"post_type"===o&&(""===a.val().trim()?(a.addClass("invalid"),a.focus()):(a.removeClass("invalid"),n.find(".accordion-section-title").addClass("loading"),i.addingNew=!0,a.attr("disabled","disabled"),c.Menus.insertAutoDraftPost({post_title:e,post_type:s}).done(function(e){var t,e=new c.Menus.AvailableItemModel({id:"post-"+e.post_id,title:a.val(),type:o,type_label:r,object:s,object_id:e.post_id,url:e.url});i.currentMenuControl.addItemToMenu(e.attributes),c.Menus.availableMenuItemsPanel.collection.add(e),t=n.find(".available-menu-items-list"),(e=m(l.template("available-menu-item")(e.attributes))).find(".menu-item-handle:first").addClass("item-added"),t.prepend(e),t.scrollTop(),a.val("").removeAttr("disabled"),i.addingNew=!1,n.find(".accordion-section-title").removeClass("loading")})))},open:function(e){var t,n=this;this.currentMenuControl=e,this.itemSectionHeight(),c.section.has("publish_settings")&&c.section("publish_settings").collapse(),m("body").addClass("adding-menu-items"),t=function(){n.close(),m(this).off("click",t)},m("#customize-preview").on("click",t),_(this.currentMenuControl.getMenuItemControls()).each(function(e){e.collapseForm()}),this.$el.find(".selected").removeClass("selected"),this.$search.trigger("focus")},close:function(e){(e=e||{}).returnFocus&&this.currentMenuControl&&this.currentMenuControl.container.find(".add-new-menu-item").focus(),this.currentMenuControl=null,this.selected=null,m("body").removeClass("adding-menu-items"),m("#available-menu-items .menu-item-handle.item-added").removeClass("item-added"),this.$search.val("").trigger("input")},keyboardAccessible:function(e){var t=13===e.which,n=27===e.which,i=9===e.which&&e.shiftKey,a=m(e.target).is(this.$search);t&&!this.$search.val()||(a&&i?(this.currentMenuControl.container.find(".add-new-menu-item").focus(),e.preventDefault()):n&&this.close({returnFocus:!0}))}}),c.Menus.MenusPanel=c.Panel.extend({attachEvents:function(){c.Panel.prototype.attachEvents.call(this);var t=this.container.find(".panel-meta"),n=t.find(".customize-help-toggle"),i=t.find(".customize-panel-description"),a=m("#screen-options-wrap"),o=t.find(".customize-screen-options-toggle");o.on("click keydown",function(e){if(!c.utils.isKeydownButNotEnterEvent(e))return e.preventDefault(),i.not(":hidden")&&(i.slideUp("fast"),n.attr("aria-expanded","false")),"true"===o.attr("aria-expanded")?(o.attr("aria-expanded","false"),t.removeClass("open"),t.removeClass("active-menu-screen-options"),a.slideUp("fast")):(o.attr("aria-expanded","true"),t.addClass("open"),t.addClass("active-menu-screen-options"),a.slideDown("fast")),!1}),n.on("click keydown",function(e){c.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),"true"===o.attr("aria-expanded")&&(o.attr("aria-expanded","false"),n.attr("aria-expanded","true"),t.addClass("open"),t.removeClass("active-menu-screen-options"),a.slideUp("fast"),i.slideDown("fast")))})},ready:function(){var e=this;e.container.find(".hide-column-tog").on("click",function(){e.saveManageColumnsState()}),c.section("menu_locations",function(e){e.headContainer.prepend(l.template("nav-menu-locations-header")(c.Menus.data))})},saveManageColumnsState:_.debounce(function(){var e=this;e._updateHiddenColumnsRequest&&e._updateHiddenColumnsRequest.abort(),e._updateHiddenColumnsRequest=l.ajax.post("hidden-columns",{hidden:e.hidden(),screenoptionnonce:m("#screenoptionnonce").val(),page:"nav-menus"}),e._updateHiddenColumnsRequest.always(function(){e._updateHiddenColumnsRequest=null})},2e3),checked:function(){},unchecked:function(){},hidden:function(){return m(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(0,e.length-5)}).get().join(",")}}),c.Menus.MenuSection=c.Section.extend({initialize:function(e,t){c.Section.prototype.initialize.call(this,e,t),this.deferred.initSortables=m.Deferred()},ready:function(){var e,t,n=this;if(void 0===n.params.menu_id)throw new Error("params.menu_id was not defined");n.active.validate=function(){return!!c.has(n.id)&&!!c(n.id).get()},n.populateControls(),n.navMenuLocationSettings={},n.assignedLocations=new c.Value([]),c.each(function(e,t){t=t.match(/^nav_menu_locations\[(.+?)]/);t&&(n.navMenuLocationSettings[t[1]]=e).bind(function(){n.refreshAssignedLocations()})}),n.assignedLocations.bind(function(e){n.updateAssignedLocationsInSectionTitle(e)}),n.refreshAssignedLocations(),c.bind("pane-contents-reflowed",function(){n.contentContainer.parent().length&&(n.container.find(".menu-item .menu-item-reorder-nav button").attr({tabindex:"0","aria-hidden":"false"}),n.container.find(".menu-item.move-up-disabled .menus-move-up").attr({tabindex:"-1","aria-hidden":"true"}),n.container.find(".menu-item.move-down-disabled .menus-move-down").attr({tabindex:"-1","aria-hidden":"true"}),n.container.find(".menu-item.move-left-disabled .menus-move-left").attr({tabindex:"-1","aria-hidden":"true"}),n.container.find(".menu-item.move-right-disabled .menus-move-right").attr({tabindex:"-1","aria-hidden":"true"}))}),t=function(){var e="field-"+m(this).val()+"-active";n.contentContainer.toggleClass(e,m(this).prop("checked"))},(e=c.panel("nav_menus").contentContainer.find(".metabox-prefs:first").find(".hide-column-tog")).each(t),e.on("click",t)},populateControls:function(){var e,t=this,n=t.id+"[name]",i=c.control(n);i||(i=new c.controlConstructor.nav_menu_name(n,{type:"nav_menu_name",label:c.Menus.data.l10n.menuNameLabel,section:t.id,priority:0,settings:{default:t.id}}),c.control.add(i),i.active.set(!0)),(n=c.control(t.id))||(n=new c.controlConstructor.nav_menu(t.id,{type:"nav_menu",section:t.id,priority:998,settings:{default:t.id},menu_id:t.params.menu_id}),c.control.add(n),n.active.set(!0)),i=t.id+"[locations]",c.control(i)||(i=new c.controlConstructor.nav_menu_locations(i,{section:t.id,priority:999,settings:{default:t.id},menu_id:t.params.menu_id}),c.control.add(i.id,i),n.active.set(!0)),i=t.id+"[auto_add]",(n=c.control(i))||(n=new c.controlConstructor.nav_menu_auto_add(i,{type:"nav_menu_auto_add",label:"",section:t.id,priority:1e3,settings:{default:t.id}}),c.control.add(n),n.active.set(!0)),i=t.id+"[delete]",(e=c.control(i))||(e=new c.Control(i,{section:t.id,priority:1001,templateId:"nav-menu-delete-button"}),c.control.add(e.id,e),e.active.set(!0),e.deferred.embedded.done(function(){e.container.find("button").on("click",function(){var e=t.params.menu_id;c.Menus.getMenuControl(e).setting.set(!1)})}))},refreshAssignedLocations:function(){var n=this.params.menu_id,i=[];_.each(this.navMenuLocationSettings,function(e,t){e()===n&&i.push(t)}),this.assignedLocations.set(i)},updateAssignedLocationsInSectionTitle:function(e){var n=this.container.find(".accordion-section-title:first");n.find(".menu-in-location").remove(),_.each(e,function(e){var t=m('<span class="menu-in-location"></span>'),e=c.Menus.data.locationSlugMappedToName[e];t.text(c.Menus.data.l10n.menuLocation.replace("%s",e)),n.append(t)}),this.container.toggleClass("assigned-to-menu-location",0!==e.length)},onChangeExpanded:function(e,t){var n,i=this;e&&(wpNavMenu.menuList=i.contentContainer,wpNavMenu.targetList=wpNavMenu.menuList,m("#menu-to-edit").removeAttr("id"),wpNavMenu.menuList.attr("id","menu-to-edit").addClass("menu"),_.each(c.section(i.id).controls(),function(e){"nav_menu_item"===e.params.type&&e.actuallyEmbed()}),t.completeCallback&&(n=t.completeCallback),t.completeCallback=function(){"resolved"!==i.deferred.initSortables.state()&&(wpNavMenu.initSortables(),i.deferred.initSortables.resolve(wpNavMenu.menuList),c.control("nav_menu["+String(i.params.menu_id)+"]").reflowMenuItems()),_.isFunction(n)&&n()}),c.Section.prototype.onChangeExpanded.call(i,e,t)},highlightNewItemButton:function(){c.utils.highlightButton(this.contentContainer.find(".add-new-menu-item"),{delay:2e3})}}),c.Menus.createNavMenu=function(e){var t=c.Menus.generatePlaceholderAutoIncrementId(),n="nav_menu["+String(t)+"]";return c.create(n,n,{},{type:"nav_menu",transport:c.Menus.data.settingTransport,previewer:c.previewer}).set(m.extend({},c.Menus.data.defaultSettingValues.nav_menu,{name:e||""})),c.section.add(new c.Menus.MenuSection(n,{panel:"nav_menus",title:u(e),customizeAction:c.Menus.data.l10n.customizingMenus,priority:10,menu_id:t}))},c.Menus.NewMenuSection=c.Section.extend({attachEvents:function(){var t=this,e=t.container,n=t.contentContainer,i=/^nav_menu\[/;function a(){var t;e.find(".add-new-menu-notice").prop("hidden",(t=0,c.each(function(e){i.test(e.id)&&!1!==e.get()&&(t+=1)}),0<t))}function o(e){i.test(e.id)&&(e.bind(a),a())}t.headContainer.find(".accordion-section-title").replaceWith(l.template("nav-menu-create-menu-section-title")),e.on("click",".customize-add-menu-button",function(){t.expand()}),n.on("keydown",".menu-name-field",function(e){13===e.which&&t.submit()}),n.on("click","#customize-new-menu-submit",function(e){t.submit(),e.stopPropagation(),e.preventDefault()}),c.each(o),c.bind("add",o),c.bind("removed",function(e){i.test(e.id)&&(e.unbind(a),a())}),a(),c.Section.prototype.attachEvents.apply(t,arguments)},ready:function(){this.populateControls()},populateControls:function(){var e=this,t=e.id+"[name]",n=c.control(t);n||(n=new c.controlConstructor.nav_menu_name(t,{label:c.Menus.data.l10n.menuNameLabel,description:c.Menus.data.l10n.newMenuNameDescription,section:e.id,priority:0}),c.control.add(n.id,n),n.active.set(!0)),t=e.id+"[locations]",(n=c.control(t))||(n=new c.controlConstructor.nav_menu_locations(t,{section:e.id,priority:1,menu_id:"",isCreating:!0}),c.control.add(t,n),n.active.set(!0)),t=e.id+"[submit]",(n=c.control(t))||(n=new c.Control(t,{section:e.id,priority:1,templateId:"nav-menu-submit-new-button"}),c.control.add(t,n),n.active.set(!0))},submit:function(){var t,e=this.contentContainer,n=e.find(".menu-name-field").first(),i=n.val();i?(t=c.Menus.createNavMenu(i),n.val(""),n.removeClass("invalid"),e.find(".assigned-menu-location input[type=checkbox]").each(function(){var e=m(this);e.prop("checked")&&(c("nav_menu_locations["+e.data("location-id")+"]").set(t.params.menu_id),e.prop("checked",!1))}),l.a11y.speak(c.Menus.data.l10n.menuAdded),t.focus({completeCallback:function(){t.highlightNewItemButton()}})):(n.addClass("invalid"),n.focus())},selectDefaultLocation:function(e){var t=c.control(this.id+"[locations]"),n={};null!==e&&(n[e]=!0),t.setSelections(n)}}),c.Menus.MenuLocationControl=c.Control.extend({initialize:function(e,t){var n=e.match(/^nav_menu_locations\[(.+?)]/);this.themeLocation=n[1],c.Control.prototype.initialize.call(this,e,t)},ready:function(){var n=this,i=/^nav_menu\[(-?\d+)]/;n.setting.validate=function(e){return""===e?0:parseInt(e,10)},n.container.find(".create-menu").on("click",function(){var e=c.section("add_menu");e.selectDefaultLocation(this.dataset.locationId),e.focus()}),n.container.find(".edit-menu").on("click",function(){var e=n.setting();c.section("nav_menu["+e+"]").focus()}),n.setting.bind("change",function(){var e=0!==n.setting();n.container.find(".create-menu").toggleClass("hidden",e),n.container.find(".edit-menu").toggleClass("hidden",!e)}),c.bind("add",function(e){var t=e.id.match(i);t&&!1!==e()&&(t=t[1],e=new Option(u(e().name),t),n.container.find("select").append(e))}),c.bind("remove",function(e){var e=e.id.match(i);e&&(e=parseInt(e[1],10),n.setting()===e&&n.setting.set(""),n.container.find("option[value="+e+"]").remove())}),c.bind("change",function(e){var t=e.id.match(i);t&&(t=parseInt(t[1],10),!1===e()?(n.setting()===t&&n.setting.set(""),n.container.find("option[value="+t+"]").remove()):n.container.find("option[value="+t+"]").text(u(e().name)))})}}),c.Menus.MenuItemControl=c.Control.extend({initialize:function(e,t){var n=this;n.expanded=new c.Value(!1),n.expandedArgumentsQueue=[],n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift(),t=m.extend({},n.defaultExpandedArguments,t);n.onChangeExpanded(e,t)}),c.Control.prototype.initialize.call(n,e,t),n.active.validate=function(){var e=c.section(n.section()),e=!!e&&e.active();return e}},embed:function(){var e=this.section();e&&((e=c.section(e))&&e.expanded()||c.settings.autofocus.control===this.id)&&this.actuallyEmbed()},actuallyEmbed:function(){"resolved"!==this.deferred.embedded.state()&&(this.renderContent(),this.deferred.embedded.resolve())},ready:function(){if(void 0===this.params.menu_item_id)throw new Error("params.menu_item_id was not defined");this._setupControlToggle(),this._setupReorderUI(),this._setupUpdateUI(),this._setupRemoveUI(),this._setupLinksUI(),this._setupTitleUI()},_setupControlToggle:function(){var i=this;this.container.find(".menu-item-handle").on("click",function(e){e.preventDefault(),e.stopPropagation();var t=i.getMenuControl(),n=m(e.target).is(".item-delete, .item-delete *"),e=m(e.target).is(".add-new-menu-item, .add-new-menu-item *");!m("body").hasClass("adding-menu-items")||n||e||c.Menus.availableMenuItemsPanel.close(),t.isReordering||t.isSorting||i.toggleForm()})},_setupReorderUI:function(){var o=this,e=l.template("menu-item-reorder-nav");o.container.find(".item-controls").after(e),o.container.find(".menu-item-reorder-nav").find(".menus-move-up, .menus-move-down, .menus-move-left, .menus-move-right").on("click",function(){var e=m(this),t=(o.params.depth=o.getDepth(),e.focus(),e.is(".menus-move-up")),n=e.is(".menus-move-down"),i=e.is(".menus-move-left"),a=e.is(".menus-move-right");t?o.moveUp():n?o.moveDown():i?(o.moveLeft(),1===o.params.depth?o.container.find(".is-submenu").hide():o.container.find(".is-submenu").show()):a&&(o.moveRight(),o.params.depth+=1,0===o.params.depth?o.container.find(".is-submenu").hide():o.container.find(".is-submenu").show()),e.focus()})},_setupUpdateUI:function(){var e,s=this,t=s.setting();s.elements={},s.elements.url=new c.Element(s.container.find(".edit-menu-item-url")),s.elements.title=new c.Element(s.container.find(".edit-menu-item-title")),s.elements.attr_title=new c.Element(s.container.find(".edit-menu-item-attr-title")),s.elements.target=new c.Element(s.container.find(".edit-menu-item-target")),s.elements.classes=new c.Element(s.container.find(".edit-menu-item-classes")),s.elements.xfn=new c.Element(s.container.find(".edit-menu-item-xfn")),s.elements.description=new c.Element(s.container.find(".edit-menu-item-description")),_.each(s.elements,function(n,i){n.bind(function(e){n.element.is("input[type=checkbox]")&&(e=e?n.element.val():"");var t=s.setting();t&&t[i]!==e&&((t=_.clone(t))[i]=e,s.setting.set(t))}),t&&("classes"!==i&&"xfn"!==i||!_.isArray(t[i])?n.set(t[i]):n.set(t[i].join(" ")))}),s.setting.bind(function(n,i){var e,t=s.params.menu_item_id,a=[],o=[];!1===n?(e=c.control("nav_menu["+String(i.nav_menu_term_id)+"]"),s.container.remove(),_.each(e.getMenuItemControls(),function(e){i.menu_item_parent===e.setting().menu_item_parent&&e.setting().position>i.position?a.push(e):e.setting().menu_item_parent===t&&o.push(e)}),_.each(a,function(e){var t=_.clone(e.setting());t.position+=o.length,e.setting.set(t)}),_.each(o,function(e,t){var n=_.clone(e.setting());n.position=i.position+t,n.menu_item_parent=i.menu_item_parent,e.setting.set(n)}),e.debouncedReflowMenuItems()):(_.each(n,function(e,t){s.elements[t]&&s.elements[t].set(n[t])}),s.container.find(".menu-item-data-parent-id").val(n.menu_item_parent),n.position===i.position&&n.menu_item_parent===i.menu_item_parent||s.getMenuControl().debouncedReflowMenuItems())}),s.setting.notifications.bind("add",e=function(){s.elements.url.element.toggleClass("invalid",s.setting.notifications.has("invalid_url"))}),s.setting.notifications.bind("removed",e)},_setupRemoveUI:function(){var r=this;r.container.find(".item-delete").on("click",function(){var e,t,n,i=!0,a=0,o=r.params.original_item_id,s=r.getMenuControl().$sectionContent.find(".menu-item");m("body").hasClass("adding-menu-items")||(i=!1),n=r.container.nextAll(".customize-control-nav_menu_item:visible").first(),t=r.container.prevAll(".customize-control-nav_menu_item:visible").first(),e=(n.length?n.find(!1===i?".item-edit":".item-delete"):t.length?t.find(!1===i?".item-edit":".item-delete"):r.container.nextAll(".customize-control-nav_menu").find(".add-new-menu-item")).first(),_.each(s,function(e){m(e).is(":visible")&&(e=e.getAttribute("id").match(/^customize-control-nav_menu_item-(-?\d+)$/,""))&&(e=parseInt(e[1],10),e=c.control("nav_menu_item["+String(e)+"]"))&&o==e.params.original_item_id&&a++}),a<=1&&((n=m("#menu-item-tpl-"+r.params.original_item_id)).removeClass("selected"),n.find(".menu-item-handle").removeClass("item-added")),r.container.slideUp(function(){r.setting.set(!1),l.a11y.speak(c.Menus.data.l10n.itemDeleted),e.focus()}),r.setting.set(!1)})},_setupLinksUI:function(){this.container.find("a.original-link").on("click",function(e){e.preventDefault(),c.previewer.previewUrl(e.target.toString())})},_setupTitleUI:function(){var i;this.container.find(".edit-menu-item-title").on("blur",function(){m(this).val(m(this).val().trim())}),i=this.container.find(".menu-item-title"),this.setting.bind(function(e){var t,n;e&&(e.title=e.title||"",n=(t=e.title.trim())||e.original_title||c.Menus.data.l10n.untitled,e._invalid&&(n=c.Menus.data.l10n.invalidTitleTpl.replace("%s",n)),t||e.original_title?i.text(n).removeClass("no-title"):i.text(n).addClass("no-title"))})},getDepth:function(){var e=this,t=e.setting(),n=0;if(!t)return 0;for(;t&&t.menu_item_parent&&(n+=1,e=c.control("nav_menu_item["+t.menu_item_parent+"]"));)t=e.setting();return n},renderContent:function(){var e,t=this,n=t.setting();t.params.title=n.title||"",t.params.depth=t.getDepth(),t.container.data("item-depth",t.params.depth),e=["menu-item","menu-item-depth-"+String(t.params.depth),"menu-item-"+n.object,"menu-item-edit-inactive"],n._invalid?(e.push("menu-item-invalid"),t.params.title=c.Menus.data.l10n.invalidTitleTpl.replace("%s",t.params.title)):"draft"===n.status&&(e.push("pending"),t.params.title=c.Menus.data.pendingTitleTpl.replace("%s",t.params.title)),t.params.el_classes=e.join(" "),t.params.item_type_label=n.type_label,t.params.item_type=n.type,t.params.url=n.url,t.params.target=n.target,t.params.attr_title=n.attr_title,t.params.classes=_.isArray(n.classes)?n.classes.join(" "):n.classes,t.params.xfn=n.xfn,t.params.description=n.description,t.params.parent=n.menu_item_parent,t.params.original_title=n.original_title||"",t.container.addClass(t.params.el_classes),c.Control.prototype.renderContent.call(t)},getMenuControl:function(){var e=this.setting();return e&&e.nav_menu_term_id?c.control("nav_menu["+e.nav_menu_term_id+"]"):null},expandControlSection:function(){var e=this.container.closest(".accordion-section");e.hasClass("open")||e.find(".accordion-section-title:first").trigger("click")},_toggleExpanded:c.Section.prototype._toggleExpanded,expand:c.Section.prototype.expand,expandForm:function(e){this.expand(e)},collapse:c.Section.prototype.collapse,collapseForm:function(e){this.collapse(e)},toggleForm:function(e,t){(e=void 0===e?!this.expanded():e)?this.expand(t):this.collapse(t)},onChangeExpanded:function(e,t){var n,i=this,a=this.container,o=a.find(".menu-item-settings:first");void 0===e&&(e=!o.is(":visible")),o.is(":visible")===e?t&&t.completeCallback&&t.completeCallback():e?(c.control.each(function(e){i.params.type===e.params.type&&i!==e&&e.collapseForm()}),n=function(){a.removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active"),i.container.trigger("expanded"),t&&t.completeCallback&&t.completeCallback()},a.find(".item-edit").attr("aria-expanded","true"),o.slideDown("fast",n),i.container.trigger("expand")):(n=function(){a.addClass("menu-item-edit-inactive").removeClass("menu-item-edit-active"),i.container.trigger("collapsed"),t&&t.completeCallback&&t.completeCallback()},i.container.trigger("collapse"),a.find(".item-edit").attr("aria-expanded","false"),o.slideUp("fast",n))},focus:function(e){var t=this,n=(e=e||{}).completeCallback,i=function(){t.expandControlSection(),e.completeCallback=function(){t.container.find(".menu-item-settings").find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first().focus(),n&&n()},t.expandForm(e)};c.section.has(t.section())?c.section(t.section()).expand({completeCallback:i}):i()},moveUp:function(){this._changePosition(-1),l.a11y.speak(c.Menus.data.l10n.movedUp)},moveDown:function(){this._changePosition(1),l.a11y.speak(c.Menus.data.l10n.movedDown)},moveLeft:function(){this._changeDepth(-1),l.a11y.speak(c.Menus.data.l10n.movedLeft)},moveRight:function(){this._changeDepth(1),l.a11y.speak(c.Menus.data.l10n.movedRight)},_changePosition:function(e){var t,n=this,i=_.clone(n.setting()),a=[];if(1!==e&&-1!==e)throw new Error("Offset changes by 1 are only supported.");if(n.setting()){if(_(n.getMenuControl().getMenuItemControls()).each(function(e){e.setting().menu_item_parent===i.menu_item_parent&&a.push(e.setting)}),a.sort(function(e,t){return e().position-t().position}),-1===(t=_.indexOf(a,n.setting)))throw new Error("Expected setting to be among siblings.");0===t&&e<0||t===a.length-1&&0<e||((t=a[t+e])&&t.set(m.extend(_.clone(t()),{position:i.position})),i.position+=e,n.setting.set(i))}},_changeDepth:function(e){if(1!==e&&-1!==e)throw new Error("Offset changes by 1 are only supported.");var t,n,i=this,a=_.clone(i.setting()),o=[];if(_(i.getMenuControl().getMenuItemControls()).each(function(e){e.setting().menu_item_parent===a.menu_item_parent&&o.push(e)}),o.sort(function(e,t){return e.setting().position-t.setting().position}),-1===(t=_.indexOf(o,i)))throw new Error("Expected control to be among siblings.");-1===e?a.menu_item_parent&&(n=c.control("nav_menu_item["+a.menu_item_parent+"]"),_(o).chain().slice(t).each(function(e,t){e.setting.set(m.extend({},e.setting(),{menu_item_parent:i.params.menu_item_id,position:t}))}),_(i.getMenuControl().getMenuItemControls()).each(function(e){var t;e.setting().menu_item_parent===n.setting().menu_item_parent&&e.setting().position>n.setting().position&&(t=_.clone(e.setting()),e.setting.set(m.extend(t,{position:t.position+1})))}),a.position=n.setting().position+1,a.menu_item_parent=n.setting().menu_item_parent,i.setting.set(a)):1===e&&0!==t&&(a.menu_item_parent=o[t-1].params.menu_item_id,a.position=0,_(i.getMenuControl().getMenuItemControls()).each(function(e){e.setting().menu_item_parent===a.menu_item_parent&&(a.position=Math.max(a.position,e.setting().position))}),a.position+=1,i.setting.set(a))}}),c.Menus.MenuNameControl=c.Control.extend({ready:function(){var e,n=this;n.setting&&(e=n.setting(),n.nameElement=new c.Element(n.container.find(".menu-name-field")),n.nameElement.bind(function(e){var t=n.setting();t&&t.name!==e&&((t=_.clone(t)).name=e,n.setting.set(t))}),e&&n.nameElement.set(e.name),n.setting.bind(function(e){e&&n.nameElement.set(e.name)}))}}),c.Menus.MenuLocationsControl=c.Control.extend({ready:function(){var d=this;d.container.find(".assigned-menu-location").each(function(){function t(e){var t=c("nav_menu["+String(e)+"]");e&&t&&t()?n.find(".theme-location-set").show().find("span").text(u(t().name)):n.find(".theme-location-set").hide()}var n=m(this),e=n.find("input[type=checkbox]"),i=new c.Element(e),a=c("nav_menu_locations["+e.data("location-id")+"]"),o=""===d.params.menu_id,s=o?_.noop:function(e){i.set(e)},r=o?_.noop:function(e){a.set(e?d.params.menu_id:0)};s(a.get()===d.params.menu_id),e.on("change",function(){r(this.checked)}),a.bind(function(e){s(e===d.params.menu_id),t(e)}),t(a.get())})},setSelections:function(i){this.container.find(".menu-location").each(function(e,t){var n=t.dataset.locationId;t.checked=n in i&&i[n]})}}),c.Menus.MenuAutoAddControl=c.Control.extend({ready:function(){var n=this,e=n.setting();n.active.validate=function(){var e=c.section(n.section()),e=!!e&&e.active();return e},n.autoAddElement=new c.Element(n.container.find("input[type=checkbox].auto_add")),n.autoAddElement.bind(function(e){var t=n.setting();t&&t.name!==e&&((t=_.clone(t)).auto_add=e,n.setting.set(t))}),e&&n.autoAddElement.set(e.auto_add),n.setting.bind(function(e){e&&n.autoAddElement.set(e.auto_add)})}}),c.Menus.MenuControl=c.Control.extend({ready:function(){var t,n,i=this,a=c.section(i.section()),o=i.params.menu_id,e=i.setting();if(void 0===this.params.menu_id)throw new Error("params.menu_id was not defined");i.active.validate=function(){var e=!!a&&a.active();return e},i.$controlSection=a.headContainer,i.$sectionContent=i.container.closest(".accordion-section-content"),this._setupModel(),c.section(i.section(),function(e){e.deferred.initSortables.done(function(e){i._setupSortable(e)})}),this._setupAddition(),this._setupTitle(),e&&(t=u(e.name),c.control.each(function(e){e.extended(c.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&(e.container.find(".nav-menu-widget-form-controls:first").show(),e.container.find(".nav-menu-widget-no-menus-message:first").hide(),0===(n=e.container.find("select")).find("option[value="+String(o)+"]").length)&&n.append(new Option(t,o))}),(e=m("#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )")).find(".nav-menu-widget-form-controls:first").show(),e.find(".nav-menu-widget-no-menus-message:first").hide(),0===(n=e.find(".widget-inside select:first")).find("option[value="+String(o)+"]").length)&&n.append(new Option(t,o)),_.defer(function(){i.updateInvitationVisibility()})},_setupModel:function(){var n=this,i=n.params.menu_id;n.setting.bind(function(e){var t;!1===e?n._handleDeletion():(t=u(e.name),c.control.each(function(e){e.extended(c.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&e.container.find("select").find("option[value="+String(i)+"]").text(t)}))})},_setupSortable:function(e){var a=this;if(!e.is(a.$sectionContent))throw new Error("Unexpected menuList.");e.on("sortstart",function(){a.isSorting=!0}),e.on("sortstop",function(){setTimeout(function(){var e=a.$sectionContent.sortable("toArray"),t=[],n=0,i=10;a.isSorting=!1,a.$sectionContent.scrollLeft(0),_.each(e,function(e){var e=e.match(/^customize-control-nav_menu_item-(-?\d+)$/,"");e&&(e=parseInt(e[1],10),e=c.control("nav_menu_item["+String(e)+"]"))&&t.push(e)}),_.each(t,function(e){var t;!1!==e.setting()&&(t=_.clone(e.setting()),n+=1,i+=1,t.position=n,e.priority(i),t.menu_item_parent=parseInt(e.container.find(".menu-item-data-parent-id").val(),10),t.menu_item_parent||(t.menu_item_parent=0),e.setting.set(t))})})}),a.isReordering=!1,this.container.find(".reorder-toggle").on("click",function(){a.toggleReordering(!a.isReordering)})},_setupAddition:function(){var t=this;this.container.find(".add-new-menu-item").on("click",function(e){t.$sectionContent.hasClass("reordering")||(m("body").hasClass("adding-menu-items")?(m(this).attr("aria-expanded","false"),c.Menus.availableMenuItemsPanel.close(),e.stopPropagation()):(m(this).attr("aria-expanded","true"),c.Menus.availableMenuItemsPanel.open(t)))})},_handleDeletion:function(){var e,n=this.params.menu_id,i=0,t=c.section(this.section()),a=function(){t.container.remove(),c.section.remove(t.id)};t&&t.expanded()?t.collapse({completeCallback:function(){a(),l.a11y.speak(c.Menus.data.l10n.menuDeleted),c.panel("nav_menus").focus()}}):a(),c.each(function(e){/^nav_menu\[/.test(e.id)&&!1!==e()&&(i+=1)}),c.control.each(function(e){var t;e.extended(c.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&((t=e.container.find("select")).val()===String(n)&&t.prop("selectedIndex",0).trigger("change"),e.container.find(".nav-menu-widget-form-controls:first").toggle(0!==i),e.container.find(".nav-menu-widget-no-menus-message:first").toggle(0===i),e.container.find("option[value="+String(n)+"]").remove())}),(e=m("#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )")).find(".nav-menu-widget-form-controls:first").toggle(0!==i),e.find(".nav-menu-widget-no-menus-message:first").toggle(0===i),e.find("option[value="+String(n)+"]").remove()},_setupTitle:function(){var d=this;d.setting.bind(function(e){var t,n,i,a,o,s,r;e&&(t=c.section(d.section()),n=d.params.menu_id,i=t.headContainer.find(".accordion-section-title"),a=t.contentContainer.find(".customize-section-title h3"),o=t.headContainer.find(".menu-in-location"),s=a.find(".customize-action"),r=u(e.name),i.text(r),o.length&&o.appendTo(i),a.text(r),s.length&&s.prependTo(a),c.control.each(function(e){/^nav_menu_locations\[/.test(e.id)&&e.container.find("option[value="+n+"]").text(r)}),t.contentContainer.find(".customize-control-checkbox input").each(function(){m(this).prop("checked")&&m(".current-menu-location-name-"+m(this).data("location-id")).text(r)}))})},toggleReordering:function(e){var t=this.container.find(".add-new-menu-item"),n=this.container.find(".reorder-toggle"),i=this.$sectionContent.find(".item-title");(e=Boolean(e))!==this.$sectionContent.hasClass("reordering")&&(this.isReordering=e,this.$sectionContent.toggleClass("reordering",e),this.$sectionContent.sortable(this.isReordering?"disable":"enable"),this.isReordering?(t.attr({tabindex:"-1","aria-hidden":"true"}),n.attr("aria-label",c.Menus.data.l10n.reorderLabelOff),l.a11y.speak(c.Menus.data.l10n.reorderModeOn),i.attr("aria-hidden","false")):(t.removeAttr("tabindex aria-hidden"),n.attr("aria-label",c.Menus.data.l10n.reorderLabelOn),l.a11y.speak(c.Menus.data.l10n.reorderModeOff),i.attr("aria-hidden","true")),e)&&_(this.getMenuItemControls()).each(function(e){e.collapseForm()})},getMenuItemControls:function(){var t=[],n=this.params.menu_id;return c.control.each(function(e){"nav_menu_item"===e.params.type&&e.setting()&&n===e.setting().nav_menu_term_id&&t.push(e)}),t},reflowMenuItems:function(){var e=this.getMenuItemControls(),a=function(n){var t=[],i=n.currentParent;_.each(n.menuItemControls,function(e){i===e.setting().menu_item_parent&&t.push(e)}),t.sort(function(e,t){return e.setting().position-t.setting().position}),_.each(t,function(t){n.currentAbsolutePosition+=1,t.priority.set(n.currentAbsolutePosition),t.container.hasClass("menu-item-depth-"+String(n.currentDepth))||(_.each(t.container.prop("className").match(/menu-item-depth-\d+/g),function(e){t.container.removeClass(e)}),t.container.addClass("menu-item-depth-"+String(n.currentDepth))),t.container.data("item-depth",n.currentDepth),n.currentDepth+=1,n.currentParent=t.params.menu_item_id,a(n),--n.currentDepth,n.currentParent=i}),t.length&&(_(t).each(function(e){e.container.removeClass("move-up-disabled move-down-disabled move-left-disabled move-right-disabled"),0===n.currentDepth?e.container.addClass("move-left-disabled"):10===n.currentDepth&&e.container.addClass("move-right-disabled")}),t[0].container.addClass("move-up-disabled").addClass("move-right-disabled").toggleClass("move-down-disabled",1===t.length),t[t.length-1].container.addClass("move-down-disabled").toggleClass("move-up-disabled",1===t.length))};a({menuItemControls:e,currentParent:0,currentDepth:0,currentAbsolutePosition:0}),this.updateInvitationVisibility(e),this.container.find(".reorder-toggle").toggle(1<e.length)},debouncedReflowMenuItems:_.debounce(function(){this.reflowMenuItems.apply(this,arguments)},0),addItemToMenu:function(e){var t,n,i,a=0,o=10,s=e.id||"";return _.each(this.getMenuItemControls(),function(e){!1!==e.setting()&&(o=Math.max(o,e.priority()),0===e.setting().menu_item_parent)&&(a=Math.max(a,e.setting().position))}),a+=1,o+=1,delete(e=m.extend({},c.Menus.data.defaultSettingValues.nav_menu_item,e,{nav_menu_term_id:this.params.menu_id,original_title:e.title,position:a})).id,i=c.Menus.generatePlaceholderAutoIncrementId(),t="nav_menu_item["+String(i)+"]",n={type:"nav_menu_item",transport:c.Menus.data.settingTransport,previewer:c.previewer},(n=c.create(t,t,{},n)).set(e),e=new c.controlConstructor.nav_menu_item(t,{type:"nav_menu_item",section:this.id,priority:o,settings:{default:t},menu_item_id:i,original_item_id:s}),c.control.add(e),n.preview(),this.debouncedReflowMenuItems(),l.a11y.speak(c.Menus.data.l10n.itemAdded),e},updateInvitationVisibility:function(e){e=e||this.getMenuItemControls();this.container.find(".new-menu-item-invitation").toggle(0===e.length)}}),m.extend(c.controlConstructor,{nav_menu_location:c.Menus.MenuLocationControl,nav_menu_item:c.Menus.MenuItemControl,nav_menu:c.Menus.MenuControl,nav_menu_name:c.Menus.MenuNameControl,nav_menu_locations:c.Menus.MenuLocationsControl,nav_menu_auto_add:c.Menus.MenuAutoAddControl}),m.extend(c.panelConstructor,{nav_menus:c.Menus.MenusPanel}),m.extend(c.sectionConstructor,{nav_menu:c.Menus.MenuSection,new_menu:c.Menus.NewMenuSection}),c.bind("ready",function(){c.Menus.availableMenuItemsPanel=new c.Menus.AvailableMenuItemsPanelView({collection:c.Menus.availableMenuItems}),c.bind("saved",function(e){(e.nav_menu_updates||e.nav_menu_item_updates)&&c.Menus.applySavedData(e)}),c.state("changesetStatus").bind(function(e){"publish"===e&&(c("nav_menus_created_posts")._value=[])}),c.previewer.bind("focus-nav-menu-item-control",c.Menus.focusMenuItemControl)}),c.Menus.applySavedData=function(e){var u={},r={};_(e.nav_menu_updates).each(function(n){var e,t,i,a,o,s,r,d;if("inserted"===n.status){if(!n.previous_term_id)throw new Error("Expected previous_term_id");if(!n.term_id)throw new Error("Expected term_id");if(e="nav_menu["+String(n.previous_term_id)+"]",!c.has(e))throw new Error("Expected setting to exist: "+e);if(i=c(e),!c.section.has(e))throw new Error("Expected control to exist: "+e);if(o=c.section(e),!(s=i.get()))throw new Error("Did not expect setting to be empty (deleted).");s=m.extend(_.clone(s),n.saved_value),u[n.previous_term_id]=n.term_id,a="nav_menu["+String(n.term_id)+"]",t=c.create(a,a,s,{type:"nav_menu",transport:c.Menus.data.settingTransport,previewer:c.previewer}),(d=o.expanded())&&o.collapse(),a=new c.Menus.MenuSection(a,{panel:"nav_menus",title:s.name,customizeAction:c.Menus.data.l10n.customizingMenus,type:"nav_menu",priority:o.priority.get(),menu_id:n.term_id}),c.section.add(a),c.control.each(function(e){var t;e.extended(c.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&(t=(e=e.container.find("select")).find("option[value="+String(n.previous_term_id)+"]"),e.find("option[value="+String(n.term_id)+"]").prop("selected",t.prop("selected")),t.remove())}),i.callbacks.disable(),i.set(!1),i.preview(),t.preview(),i._dirty=!1,o.container.remove(),c.section.remove(e),r=0,c.each(function(e){/^nav_menu\[/.test(e.id)&&!1!==e()&&(r+=1)}),(s=m("#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )")).find(".nav-menu-widget-form-controls:first").toggle(0!==r),s.find(".nav-menu-widget-no-menus-message:first").toggle(0===r),s.find("option[value="+String(n.previous_term_id)+"]").remove(),l.customize.control.each(function(e){/^nav_menu_locations\[/.test(e.id)&&e.container.find("option[value="+String(n.previous_term_id)+"]").remove()}),c.each(function(e){var t=c.state("saved").get();/^nav_menu_locations\[/.test(e.id)&&e.get()===n.previous_term_id&&(e.set(n.term_id),e._dirty=!1,c.state("saved").set(t),e.preview())}),d&&a.expand()}else if("updated"===n.status){if(t="nav_menu["+String(n.term_id)+"]",!c.has(t))throw new Error("Expected setting to exist: "+t);i=c(t),_.isEqual(n.saved_value,i.get())||(o=c.state("saved").get(),i.set(n.saved_value),i._dirty=!1,c.state("saved").set(o))}}),_(e.nav_menu_item_updates).each(function(e){e.previous_post_id&&(r[e.previous_post_id]=e.post_id)}),_(e.nav_menu_item_updates).each(function(e){var t,n,i,a,o,s;if("inserted"===e.status){if(!e.previous_post_id)throw new Error("Expected previous_post_id");if(!e.post_id)throw new Error("Expected post_id");if(t="nav_menu_item["+String(e.previous_post_id)+"]",!c.has(t))throw new Error("Expected setting to exist: "+t);if(i=c(t),!c.control.has(t))throw new Error("Expected control to exist: "+t);if(o=c.control(t),!(s=i.get()))throw new Error("Did not expect setting to be empty (deleted).");if((s=_.clone(s)).menu_item_parent<0){if(!r[s.menu_item_parent])throw new Error("inserted ID for menu_item_parent not available");s.menu_item_parent=r[s.menu_item_parent]}u[s.nav_menu_term_id]&&(s.nav_menu_term_id=u[s.nav_menu_term_id]),n="nav_menu_item["+String(e.post_id)+"]",a=c.create(n,n,s,{type:"nav_menu_item",transport:c.Menus.data.settingTransport,previewer:c.previewer}),s=new c.controlConstructor.nav_menu_item(n,{type:"nav_menu_item",menu_id:e.post_id,section:"nav_menu["+String(s.nav_menu_term_id)+"]",priority:o.priority.get(),settings:{default:n},menu_item_id:e.post_id}),o.container.remove(),c.control.remove(t),c.control.add(s),i.callbacks.disable(),i.set(!1),i.preview(),a.preview(),i._dirty=!1,s.container.toggleClass("menu-item-edit-inactive",o.container.hasClass("menu-item-edit-inactive"))}}),_.each(e.widget_nav_menu_updates,function(e,t){t=c(t);t&&(t._value=e,t.preview())})},c.Menus.focusMenuItemControl=function(e){e=c.Menus.getMenuItemControl(e);e&&e.focus()},c.Menus.getMenuControl=function(e){return c.control("nav_menu["+e+"]")},c.Menus.getMenuItemControl=function(e){return c.control("nav_menu_item["+e+"]")}}(wp.customize,wp,jQuery);
\ No newline at end of file +!function(u,l,m){"use strict";function c(e){return(e=(e=l.sanitize.stripTagsAndEncodeText(e=e||"")).toString().trim())||u.Menus.data.l10n.unnamed}wpNavMenu.originalInit=wpNavMenu.init,wpNavMenu.options.menuItemDepthPerLevel=20,wpNavMenu.options.sortableItems="> .customize-control-nav_menu_item",wpNavMenu.options.targetTolerance=10,wpNavMenu.init=function(){this.jQueryExtensions()},u.Menus=u.Menus||{},u.Menus.data={itemTypes:[],l10n:{},settingTransport:"refresh",phpIntMax:0,defaultSettingValues:{nav_menu:{},nav_menu_item:{}},locationSlugMappedToName:{}},"undefined"!=typeof _wpCustomizeNavMenusSettings&&m.extend(u.Menus.data,_wpCustomizeNavMenusSettings),u.Menus.generatePlaceholderAutoIncrementId=function(){return-Math.ceil(u.Menus.data.phpIntMax*Math.random())},u.Menus.AvailableItemModel=Backbone.Model.extend(m.extend({id:null},u.Menus.data.defaultSettingValues.nav_menu_item)),u.Menus.AvailableItemCollection=Backbone.Collection.extend({model:u.Menus.AvailableItemModel,sort_key:"order",comparator:function(e){return-e.get(this.sort_key)},sortByField:function(e){this.sort_key=e,this.sort()}}),u.Menus.availableMenuItems=new u.Menus.AvailableItemCollection(u.Menus.data.availableMenuItems),u.Menus.insertAutoDraftPost=function(n){var i=m.Deferred(),e=l.ajax.post("customize-nav-menus-insert-auto-draft",{"customize-menus-nonce":u.settings.nonce["customize-menus"],wp_customize:"on",customize_changeset_uuid:u.settings.changeset.uuid,params:n});return e.done(function(t){t.post_id&&(u("nav_menus_created_posts").set(u("nav_menus_created_posts").get().concat([t.post_id])),"page"===n.post_type&&(u.section.has("static_front_page")&&u.section("static_front_page").activate(),u.control.each(function(e){"dropdown-pages"===e.params.type&&e.container.find('select[name^="_customize-dropdown-pages-"]').append(new Option(n.post_title,t.post_id))})),i.resolve(t))}),e.fail(function(e){var t=e||"";void 0!==e.message&&(t=e.message),console.error(t),i.rejectWith(t)}),i.promise()},u.Menus.AvailableMenuItemsPanelView=l.Backbone.View.extend({el:"#available-menu-items",events:{"input #menu-items-search":"debounceSearch","focus .menu-item-tpl":"focus","click .menu-item-tpl":"_submit","click #custom-menu-item-submit":"_submitLink","keypress #custom-menu-item-name":"_submitLink","click .new-content-item .add-content":"_submitNew","keypress .create-item-input":"_submitNew",keydown:"keyboardAccessible"},selected:null,currentMenuControl:null,debounceSearch:null,$search:null,$clearResults:null,searchTerm:"",rendered:!1,pages:{},sectionContent:"",loading:!1,addingNew:!1,initialize:function(){var n=this;u.panel.has("nav_menus")&&(this.$search=m("#menu-items-search"),this.$clearResults=this.$el.find(".clear-results"),this.sectionContent=this.$el.find(".available-menu-items-list"),this.debounceSearch=_.debounce(n.search,500),_.bindAll(this,"close"),m("#customize-controls, .customize-section-back").on("click keydown",function(e){var t=m(e.target).is(".item-delete, .item-delete *"),e=m(e.target).is(".add-new-menu-item, .add-new-menu-item *");!m("body").hasClass("adding-menu-items")||t||e||n.close()}),this.$clearResults.on("click",function(){n.$search.val("").trigger("focus").trigger("input")}),this.$el.on("input","#custom-menu-item-name.invalid, #custom-menu-item-url.invalid",function(){m(this).removeClass("invalid")}),u.panel("nav_menus").container.on("expanded",function(){n.rendered||(n.initList(),n.rendered=!0)}),this.sectionContent.on("scroll",function(){var e=n.$el.find(".accordion-section.open .available-menu-items-list").prop("scrollHeight"),t=n.$el.find(".accordion-section.open").height();!n.loading&&m(this).scrollTop()>.75*e-t&&(e=m(this).data("type"),t=m(this).data("object"),"search"===e?n.searchTerm&&n.doSearch(n.pages.search):n.loadItems([{type:e,object:t}]))}),u.previewer.bind("url",this.close),n.delegateEvents())},search:function(e){var t=m("#available-menu-items-search"),n=m("#available-menu-items .accordion-section").not(t);e&&this.searchTerm!==e.target.value&&(""===e.target.value||t.hasClass("open")?""===e.target.value&&(t.removeClass("open"),n.show(),this.$clearResults.removeClass("is-visible")):(n.fadeOut(100),t.find(".accordion-section-content").slideDown("fast"),t.addClass("open"),this.$clearResults.addClass("is-visible")),this.searchTerm=e.target.value,this.pages.search=1,this.doSearch(1))},doSearch:function(t){var e,n=this,i=m("#available-menu-items-search"),a=i.find(".accordion-section-content"),o=l.template("available-menu-item");if(n.currentRequest&&n.currentRequest.abort(),!(t<0)){if(1<t)i.addClass("loading-more"),a.attr("aria-busy","true"),l.a11y.speak(u.Menus.data.l10n.itemsLoadingMore);else if(""===n.searchTerm)return a.html(""),void l.a11y.speak("");i.addClass("loading"),n.loading=!0,e=u.previewer.query({excludeCustomizedSaved:!0}),_.extend(e,{"customize-menus-nonce":u.settings.nonce["customize-menus"],wp_customize:"on",search:n.searchTerm,page:t}),n.currentRequest=l.ajax.post("search-available-menu-items-customizer",e),n.currentRequest.done(function(e){1===t&&a.empty(),i.removeClass("loading loading-more"),a.attr("aria-busy","false"),i.addClass("open"),n.loading=!1,e=new u.Menus.AvailableItemCollection(e.items),n.collection.add(e.models),e.each(function(e){a.append(o(e.attributes))}),e.length<20?n.pages.search=-1:n.pages.search=n.pages.search+1,e&&1<t?l.a11y.speak(u.Menus.data.l10n.itemsFoundMore.replace("%d",e.length)):e&&1===t&&l.a11y.speak(u.Menus.data.l10n.itemsFound.replace("%d",e.length))}),n.currentRequest.fail(function(e){e.message&&(a.empty().append(m('<li class="nothing-found"></li>').text(e.message)),l.a11y.speak(e.message)),n.pages.search=-1}),n.currentRequest.always(function(){i.removeClass("loading loading-more"),a.attr("aria-busy","false"),n.loading=!1,n.currentRequest=null})}},initList:function(){var t=this;_.each(u.Menus.data.itemTypes,function(e){t.pages[e.type+":"+e.object]=0}),t.loadItems(u.Menus.data.itemTypes)},loadItems:function(e,t){var i=this,a=[],o={},s=l.template("available-menu-item"),t=_.isString(e)&&_.isString(t)?[{type:e,object:t}]:e;_.each(t,function(e){var t,n=e.type+":"+e.object;-1!==i.pages[n]&&((t=m("#available-menu-items-"+e.type+"-"+e.object)).find(".accordion-section-title").addClass("loading"),o[n]=t,a.push({object:e.object,type:e.type,page:i.pages[n]}))}),0!==a.length&&(i.loading=!0,e=u.previewer.query({excludeCustomizedSaved:!0}),_.extend(e,{"customize-menus-nonce":u.settings.nonce["customize-menus"],wp_customize:"on",item_types:a}),(t=l.ajax.post("load-available-menu-items-customizer",e)).done(function(e){var n;_.each(e.items,function(e,t){0===e.length?(0===i.pages[t]&&o[t].find(".accordion-section-title").addClass("cannot-expand").removeClass("loading").find(".accordion-section-title > button").prop("tabIndex",-1),i.pages[t]=-1):("post_type:page"!==t||o[t].hasClass("open")||o[t].find(".accordion-section-title > button").trigger("click"),e=new u.Menus.AvailableItemCollection(e),i.collection.add(e.models),n=o[t].find(".available-menu-items-list"),e.each(function(e){n.append(s(e.attributes))}),i.pages[t]+=1)})}),t.fail(function(e){"undefined"!=typeof console&&console.error&&console.error(e)}),t.always(function(){_.each(o,function(e){e.find(".accordion-section-title").removeClass("loading")}),i.loading=!1}))},itemSectionHeight:function(){var e=window.innerHeight,t=this.$el.find(".accordion-section:not( #available-menu-items-search ) .accordion-section-content"),n=this.$el.find('.accordion-section:not( #available-menu-items-search ) .available-menu-items-list:not(":only-child")'),e=e-(46*(1+t.length)+14);120<e&&e<290&&(t.css("max-height",e),n.css("max-height",e-60))},select:function(e){this.selected=m(e),this.selected.siblings(".menu-item-tpl").removeClass("selected"),this.selected.addClass("selected")},focus:function(e){this.select(m(e.currentTarget))},_submit:function(e){"keypress"===e.type&&13!==e.which&&32!==e.which||this.submit(m(e.currentTarget))},submit:function(e){var t;(e=e||this.selected)&&this.currentMenuControl&&(this.select(e),t=m(this.selected).data("menu-item-id"),t=this.collection.findWhere({id:t}))&&(this.currentMenuControl.addItemToMenu(t.attributes),m(e).find(".menu-item-handle").addClass("item-added"))},_submitLink:function(e){"keypress"===e.type&&13!==e.which||this.submitLink()},submitLink:function(){var e,t=m("#custom-menu-item-name"),n=m("#custom-menu-item-url"),i=n.val().trim();this.currentMenuControl&&(e=/^((\w+:)?\/\/\w.*|\w+:(?!\/\/$)|\/|\?|#)/,""===t.val()?t.addClass("invalid"):e.test(i)?(e={title:t.val(),url:i,type:"custom",type_label:u.Menus.data.l10n.custom_label,object:"custom"},this.currentMenuControl.addItemToMenu(e),n.val("").attr("placeholder","https://"),t.val("")):n.addClass("invalid"))},_submitNew:function(e){"keypress"===e.type&&13!==e.which||this.addingNew||(e=m(e.target).closest(".accordion-section"),this.submitNew(e))},submitNew:function(n){var i=this,a=n.find(".create-item-input"),e=a.val(),t=n.find(".available-menu-items-list"),o=t.data("type"),s=t.data("object"),r=t.data("type_label");this.currentMenuControl&&"post_type"===o&&(""===a.val().trim()?(a.addClass("invalid"),a.focus()):(a.removeClass("invalid"),n.find(".accordion-section-title").addClass("loading"),i.addingNew=!0,a.attr("disabled","disabled"),u.Menus.insertAutoDraftPost({post_title:e,post_type:s}).done(function(e){var t,e=new u.Menus.AvailableItemModel({id:"post-"+e.post_id,title:a.val(),type:o,type_label:r,object:s,object_id:e.post_id,url:e.url});i.currentMenuControl.addItemToMenu(e.attributes),u.Menus.availableMenuItemsPanel.collection.add(e),t=n.find(".available-menu-items-list"),(e=m(l.template("available-menu-item")(e.attributes))).find(".menu-item-handle:first").addClass("item-added"),t.prepend(e),t.scrollTop(),a.val("").removeAttr("disabled"),i.addingNew=!1,n.find(".accordion-section-title").removeClass("loading")})))},open:function(e){var t,n=this;this.currentMenuControl=e,this.itemSectionHeight(),u.section.has("publish_settings")&&u.section("publish_settings").collapse(),m("body").addClass("adding-menu-items"),t=function(){n.close(),m(this).off("click",t)},m("#customize-preview").on("click",t),_(this.currentMenuControl.getMenuItemControls()).each(function(e){e.collapseForm()}),this.$el.find(".selected").removeClass("selected"),this.$search.trigger("focus")},close:function(e){(e=e||{}).returnFocus&&this.currentMenuControl&&this.currentMenuControl.container.find(".add-new-menu-item").focus(),this.currentMenuControl=null,this.selected=null,m("body").removeClass("adding-menu-items"),m("#available-menu-items .menu-item-handle.item-added").removeClass("item-added"),this.$search.val("").trigger("input")},keyboardAccessible:function(e){var t=13===e.which,n=27===e.which,i=9===e.which&&e.shiftKey,a=m(e.target).is(this.$search);t&&!this.$search.val()||(a&&i?(this.currentMenuControl.container.find(".add-new-menu-item").focus(),e.preventDefault()):n&&this.close({returnFocus:!0}))}}),u.Menus.MenusPanel=u.Panel.extend({attachEvents:function(){u.Panel.prototype.attachEvents.call(this);var t=this.container.find(".panel-meta"),n=t.find(".customize-help-toggle"),i=t.find(".customize-panel-description"),a=m("#screen-options-wrap"),o=t.find(".customize-screen-options-toggle");o.on("click keydown",function(e){if(!u.utils.isKeydownButNotEnterEvent(e))return e.preventDefault(),i.not(":hidden")&&(i.slideUp("fast"),n.attr("aria-expanded","false")),"true"===o.attr("aria-expanded")?(o.attr("aria-expanded","false"),t.removeClass("open"),t.removeClass("active-menu-screen-options"),a.slideUp("fast")):(o.attr("aria-expanded","true"),t.addClass("open"),t.addClass("active-menu-screen-options"),a.slideDown("fast")),!1}),n.on("click keydown",function(e){u.utils.isKeydownButNotEnterEvent(e)||(e.preventDefault(),"true"===o.attr("aria-expanded")&&(o.attr("aria-expanded","false"),n.attr("aria-expanded","true"),t.addClass("open"),t.removeClass("active-menu-screen-options"),a.slideUp("fast"),i.slideDown("fast")))})},ready:function(){var e=this;e.container.find(".hide-column-tog").on("click",function(){e.saveManageColumnsState()}),u.section("menu_locations",function(e){e.headContainer.prepend(l.template("nav-menu-locations-header")(u.Menus.data))})},saveManageColumnsState:_.debounce(function(){var e=this;e._updateHiddenColumnsRequest&&e._updateHiddenColumnsRequest.abort(),e._updateHiddenColumnsRequest=l.ajax.post("hidden-columns",{hidden:e.hidden(),screenoptionnonce:m("#screenoptionnonce").val(),page:"nav-menus"}),e._updateHiddenColumnsRequest.always(function(){e._updateHiddenColumnsRequest=null})},2e3),checked:function(){},unchecked:function(){},hidden:function(){return m(".hide-column-tog").not(":checked").map(function(){var e=this.id;return e.substring(0,e.length-5)}).get().join(",")}}),u.Menus.MenuSection=u.Section.extend({initialize:function(e,t){u.Section.prototype.initialize.call(this,e,t),this.deferred.initSortables=m.Deferred()},ready:function(){var e,t,n=this;if(void 0===n.params.menu_id)throw new Error("params.menu_id was not defined");n.active.validate=function(){return!!u.has(n.id)&&!!u(n.id).get()},n.populateControls(),n.navMenuLocationSettings={},n.assignedLocations=new u.Value([]),u.each(function(e,t){t=t.match(/^nav_menu_locations\[(.+?)]/);t&&(n.navMenuLocationSettings[t[1]]=e).bind(function(){n.refreshAssignedLocations()})}),n.assignedLocations.bind(function(e){n.updateAssignedLocationsInSectionTitle(e)}),n.refreshAssignedLocations(),u.bind("pane-contents-reflowed",function(){n.contentContainer.parent().length&&(n.container.find(".menu-item .menu-item-reorder-nav button").attr({tabindex:"0","aria-hidden":"false"}),n.container.find(".menu-item.move-up-disabled .menus-move-up").attr({tabindex:"-1","aria-hidden":"true"}),n.container.find(".menu-item.move-down-disabled .menus-move-down").attr({tabindex:"-1","aria-hidden":"true"}),n.container.find(".menu-item.move-left-disabled .menus-move-left").attr({tabindex:"-1","aria-hidden":"true"}),n.container.find(".menu-item.move-right-disabled .menus-move-right").attr({tabindex:"-1","aria-hidden":"true"}))}),t=function(){var e="field-"+m(this).val()+"-active";n.contentContainer.toggleClass(e,m(this).prop("checked"))},(e=u.panel("nav_menus").contentContainer.find(".metabox-prefs:first").find(".hide-column-tog")).each(t),e.on("click",t)},populateControls:function(){var e,t=this,n=t.id+"[name]",i=u.control(n);i||(i=new u.controlConstructor.nav_menu_name(n,{type:"nav_menu_name",label:u.Menus.data.l10n.menuNameLabel,section:t.id,priority:0,settings:{default:t.id}}),u.control.add(i),i.active.set(!0)),(n=u.control(t.id))||(n=new u.controlConstructor.nav_menu(t.id,{type:"nav_menu",section:t.id,priority:998,settings:{default:t.id},menu_id:t.params.menu_id}),u.control.add(n),n.active.set(!0)),i=t.id+"[locations]",u.control(i)||(i=new u.controlConstructor.nav_menu_locations(i,{section:t.id,priority:999,settings:{default:t.id},menu_id:t.params.menu_id}),u.control.add(i.id,i),n.active.set(!0)),i=t.id+"[auto_add]",(n=u.control(i))||(n=new u.controlConstructor.nav_menu_auto_add(i,{type:"nav_menu_auto_add",label:"",section:t.id,priority:1e3,settings:{default:t.id}}),u.control.add(n),n.active.set(!0)),i=t.id+"[delete]",(e=u.control(i))||(e=new u.Control(i,{section:t.id,priority:1001,templateId:"nav-menu-delete-button"}),u.control.add(e.id,e),e.active.set(!0),e.deferred.embedded.done(function(){e.container.find("button").on("click",function(){var e=t.params.menu_id;u.Menus.getMenuControl(e).setting.set(!1)})}))},refreshAssignedLocations:function(){var n=this.params.menu_id,i=[];_.each(this.navMenuLocationSettings,function(e,t){e()===n&&i.push(t)}),this.assignedLocations.set(i)},updateAssignedLocationsInSectionTitle:function(e){var n=this.container.find(".accordion-section-title:first");n.find(".menu-in-location").remove(),_.each(e,function(e){var t=m('<span class="menu-in-location"></span>'),e=u.Menus.data.locationSlugMappedToName[e];t.text(u.Menus.data.l10n.menuLocation.replace("%s",e)),n.append(t)}),this.container.toggleClass("assigned-to-menu-location",0!==e.length)},onChangeExpanded:function(e,t){var n,i=this;e&&(wpNavMenu.menuList=i.contentContainer,wpNavMenu.targetList=wpNavMenu.menuList,m("#menu-to-edit").removeAttr("id"),wpNavMenu.menuList.attr("id","menu-to-edit").addClass("menu"),u.Menus.MenuItemControl.prototype.initAccessibility(),_.each(u.section(i.id).controls(),function(e){"nav_menu_item"===e.params.type&&e.actuallyEmbed()}),t.completeCallback&&(n=t.completeCallback),t.completeCallback=function(){"resolved"!==i.deferred.initSortables.state()&&(wpNavMenu.initSortables(),i.deferred.initSortables.resolve(wpNavMenu.menuList),u.control("nav_menu["+String(i.params.menu_id)+"]").reflowMenuItems()),_.isFunction(n)&&n()}),u.Section.prototype.onChangeExpanded.call(i,e,t)},highlightNewItemButton:function(){u.utils.highlightButton(this.contentContainer.find(".add-new-menu-item"),{delay:2e3})}}),u.Menus.createNavMenu=function(e){var t=u.Menus.generatePlaceholderAutoIncrementId(),n="nav_menu["+String(t)+"]";return u.create(n,n,{},{type:"nav_menu",transport:u.Menus.data.settingTransport,previewer:u.previewer}).set(m.extend({},u.Menus.data.defaultSettingValues.nav_menu,{name:e||""})),u.section.add(new u.Menus.MenuSection(n,{panel:"nav_menus",title:c(e),customizeAction:u.Menus.data.l10n.customizingMenus,priority:10,menu_id:t}))},u.Menus.NewMenuSection=u.Section.extend({attachEvents:function(){var t=this,e=t.container,n=t.contentContainer,i=/^nav_menu\[/;function a(){var t;e.find(".add-new-menu-notice").prop("hidden",(t=0,u.each(function(e){i.test(e.id)&&!1!==e.get()&&(t+=1)}),0<t))}function o(e){i.test(e.id)&&(e.bind(a),a())}t.headContainer.find(".accordion-section-title").replaceWith(l.template("nav-menu-create-menu-section-title")),e.on("click",".customize-add-menu-button",function(){t.expand()}),n.on("keydown",".menu-name-field",function(e){13===e.which&&t.submit()}),n.on("click","#customize-new-menu-submit",function(e){t.submit(),e.stopPropagation(),e.preventDefault()}),u.each(o),u.bind("add",o),u.bind("removed",function(e){i.test(e.id)&&(e.unbind(a),a())}),a(),u.Section.prototype.attachEvents.apply(t,arguments)},ready:function(){this.populateControls()},populateControls:function(){var e=this,t=e.id+"[name]",n=u.control(t);n||(n=new u.controlConstructor.nav_menu_name(t,{label:u.Menus.data.l10n.menuNameLabel,description:u.Menus.data.l10n.newMenuNameDescription,section:e.id,priority:0}),u.control.add(n.id,n),n.active.set(!0)),t=e.id+"[locations]",(n=u.control(t))||(n=new u.controlConstructor.nav_menu_locations(t,{section:e.id,priority:1,menu_id:"",isCreating:!0}),u.control.add(t,n),n.active.set(!0)),t=e.id+"[submit]",(n=u.control(t))||(n=new u.Control(t,{section:e.id,priority:1,templateId:"nav-menu-submit-new-button"}),u.control.add(t,n),n.active.set(!0))},submit:function(){var t,e=this.contentContainer,n=e.find(".menu-name-field").first(),i=n.val();i?(t=u.Menus.createNavMenu(i),n.val(""),n.removeClass("invalid"),e.find(".assigned-menu-location input[type=checkbox]").each(function(){var e=m(this);e.prop("checked")&&(u("nav_menu_locations["+e.data("location-id")+"]").set(t.params.menu_id),e.prop("checked",!1))}),l.a11y.speak(u.Menus.data.l10n.menuAdded),t.focus({completeCallback:function(){t.highlightNewItemButton()}})):(n.addClass("invalid"),n.focus())},selectDefaultLocation:function(e){var t=u.control(this.id+"[locations]"),n={};null!==e&&(n[e]=!0),t.setSelections(n)}}),u.Menus.MenuLocationControl=u.Control.extend({initialize:function(e,t){var n=e.match(/^nav_menu_locations\[(.+?)]/);this.themeLocation=n[1],u.Control.prototype.initialize.call(this,e,t)},ready:function(){var n=this,i=/^nav_menu\[(-?\d+)]/;n.setting.validate=function(e){return""===e?0:parseInt(e,10)},n.container.find(".create-menu").on("click",function(){var e=u.section("add_menu");e.selectDefaultLocation(this.dataset.locationId),e.focus()}),n.container.find(".edit-menu").on("click",function(){var e=n.setting();u.section("nav_menu["+e+"]").focus()}),n.setting.bind("change",function(){var e=0!==n.setting();n.container.find(".create-menu").toggleClass("hidden",e),n.container.find(".edit-menu").toggleClass("hidden",!e)}),u.bind("add",function(e){var t=e.id.match(i);t&&!1!==e()&&(t=t[1],e=new Option(c(e().name),t),n.container.find("select").append(e))}),u.bind("remove",function(e){var e=e.id.match(i);e&&(e=parseInt(e[1],10),n.setting()===e&&n.setting.set(""),n.container.find("option[value="+e+"]").remove())}),u.bind("change",function(e){var t=e.id.match(i);t&&(t=parseInt(t[1],10),!1===e()?(n.setting()===t&&n.setting.set(""),n.container.find("option[value="+t+"]").remove()):n.container.find("option[value="+t+"]").text(c(e().name)))})}}),u.Menus.MenuItemControl=u.Control.extend({initialize:function(e,t){var n=this;n.expanded=new u.Value(!1),n.expandedArgumentsQueue=[],n.expanded.bind(function(e){var t=n.expandedArgumentsQueue.shift(),t=m.extend({},n.defaultExpandedArguments,t);n.onChangeExpanded(e,t)}),u.Control.prototype.initialize.call(n,e,t),n.active.validate=function(){var e=u.section(n.section()),e=!!e&&e.active();return e}},initAccessibility:function(){var e=this,t=m("#menu-to-edit");t.on("mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility",".menu-item",function(){e.refreshAdvancedAccessibilityOfItem(m(this).find("button.item-edit"))}),t.on("click","button.item-edit",function(){e.refreshAdvancedAccessibilityOfItem(m(this))})},refreshAdvancedAccessibilityOfItem:function(e){var t,n,i,a,o,s,r,d;!0===m(e).data("needs_accessibility_refresh")&&(o=0===(a=(i=(e=m(e)).closest("li.menu-item").first()).menuItemDepth()),s=e.closest(".menu-item-handle").find(".menu-item-title").text(),r=e.closest(".menu-item-handle").find(".item-type").text(),d=m("#menu-to-edit li").length,d=o?(t=(o=m(".menu-item-depth-0")).index(i)+1,d=o.length,menus.menuFocus.replace("%1$s",s).replace("%2$s",r).replace("%3$d",t).replace("%4$d",d)):(d=(o=i.prevAll(".menu-item-depth-"+parseInt(a-1,10)).first()).find(".menu-item-data-db-id").val(),o=o.find(".menu-item-title").text(),n=(d=m('.menu-item .menu-item-data-parent-id[value="'+d+'"]')).length,t=m(d.parents(".menu-item").get().reverse()).index(i)+1,a<2?menus.subMenuFocus.replace("%1$s",s).replace("%2$s",r).replace("%3$d",t).replace("%4$d",n).replace("%5$s",o):menus.subMenuMoreDepthFocus.replace("%1$s",s).replace("%2$s",r).replace("%3$d",t).replace("%4$d",n).replace("%5$s",o).replace("%6$d",a)),e.find(".screen-reader-text").text(d),e.data("needs_accessibility_refresh",!1))},embed:function(){var e=this.section();e&&((e=u.section(e))&&e.expanded()||u.settings.autofocus.control===this.id)&&this.actuallyEmbed()},actuallyEmbed:function(){"resolved"!==this.deferred.embedded.state()&&(this.renderContent(),this.deferred.embedded.resolve(),m("button.item-edit").data("needs_accessibility_refresh",!0))},ready:function(){if(void 0===this.params.menu_item_id)throw new Error("params.menu_item_id was not defined");this._setupControlToggle(),this._setupReorderUI(),this._setupUpdateUI(),this._setupRemoveUI(),this._setupLinksUI(),this._setupTitleUI()},_setupControlToggle:function(){var i=this;this.container.find(".menu-item-handle").on("click",function(e){e.preventDefault(),e.stopPropagation();var t=i.getMenuControl(),n=m(e.target).is(".item-delete, .item-delete *"),e=m(e.target).is(".add-new-menu-item, .add-new-menu-item *");!m("body").hasClass("adding-menu-items")||n||e||u.Menus.availableMenuItemsPanel.close(),t.isReordering||t.isSorting||i.toggleForm()})},_setupReorderUI:function(){var o=this,e=l.template("menu-item-reorder-nav");o.container.find(".item-controls").after(e),o.container.find(".menu-item-reorder-nav").find(".menus-move-up, .menus-move-down, .menus-move-left, .menus-move-right").on("click",function(){var e=m(this),t=(o.params.depth=o.getDepth(),e.focus(),e.is(".menus-move-up")),n=e.is(".menus-move-down"),i=e.is(".menus-move-left"),a=e.is(".menus-move-right");t?o.moveUp():n?o.moveDown():i?o.moveLeft():a&&(o.moveRight(),o.params.depth+=1),e.focus(),m("button.item-edit").data("needs_accessibility_refresh",!0)})},_setupUpdateUI:function(){var e,s=this,t=s.setting();s.elements={},s.elements.url=new u.Element(s.container.find(".edit-menu-item-url")),s.elements.title=new u.Element(s.container.find(".edit-menu-item-title")),s.elements.attr_title=new u.Element(s.container.find(".edit-menu-item-attr-title")),s.elements.target=new u.Element(s.container.find(".edit-menu-item-target")),s.elements.classes=new u.Element(s.container.find(".edit-menu-item-classes")),s.elements.xfn=new u.Element(s.container.find(".edit-menu-item-xfn")),s.elements.description=new u.Element(s.container.find(".edit-menu-item-description")),_.each(s.elements,function(n,i){n.bind(function(e){n.element.is("input[type=checkbox]")&&(e=e?n.element.val():"");var t=s.setting();t&&t[i]!==e&&((t=_.clone(t))[i]=e,s.setting.set(t))}),t&&("classes"!==i&&"xfn"!==i||!_.isArray(t[i])?n.set(t[i]):n.set(t[i].join(" ")))}),s.setting.bind(function(n,i){var e,t=s.params.menu_item_id,a=[],o=[];!1===n?(e=u.control("nav_menu["+String(i.nav_menu_term_id)+"]"),s.container.remove(),_.each(e.getMenuItemControls(),function(e){i.menu_item_parent===e.setting().menu_item_parent&&e.setting().position>i.position?a.push(e):e.setting().menu_item_parent===t&&o.push(e)}),_.each(a,function(e){var t=_.clone(e.setting());t.position+=o.length,e.setting.set(t)}),_.each(o,function(e,t){var n=_.clone(e.setting());n.position=i.position+t,n.menu_item_parent=i.menu_item_parent,e.setting.set(n)}),e.debouncedReflowMenuItems()):(_.each(n,function(e,t){s.elements[t]&&s.elements[t].set(n[t])}),s.container.find(".menu-item-data-parent-id").val(n.menu_item_parent),n.position===i.position&&n.menu_item_parent===i.menu_item_parent||s.getMenuControl().debouncedReflowMenuItems())}),s.setting.notifications.bind("add",e=function(){s.elements.url.element.toggleClass("invalid",s.setting.notifications.has("invalid_url"))}),s.setting.notifications.bind("removed",e)},_setupRemoveUI:function(){var r=this;r.container.find(".item-delete").on("click",function(){var e,t,n,i=!0,a=0,o=r.params.original_item_id,s=r.getMenuControl().$sectionContent.find(".menu-item");m("body").hasClass("adding-menu-items")||(i=!1),n=r.container.nextAll(".customize-control-nav_menu_item:visible").first(),t=r.container.prevAll(".customize-control-nav_menu_item:visible").first(),e=(n.length?n.find(!1===i?".item-edit":".item-delete"):t.length?t.find(!1===i?".item-edit":".item-delete"):r.container.nextAll(".customize-control-nav_menu").find(".add-new-menu-item")).first(),_.each(s,function(e){m(e).is(":visible")&&(e=e.getAttribute("id").match(/^customize-control-nav_menu_item-(-?\d+)$/,""))&&(e=parseInt(e[1],10),e=u.control("nav_menu_item["+String(e)+"]"))&&o==e.params.original_item_id&&a++}),a<=1&&((n=m("#menu-item-tpl-"+r.params.original_item_id)).removeClass("selected"),n.find(".menu-item-handle").removeClass("item-added")),r.container.slideUp(function(){r.setting.set(!1),l.a11y.speak(u.Menus.data.l10n.itemDeleted),e.focus()}),r.setting.set(!1)})},_setupLinksUI:function(){this.container.find("a.original-link").on("click",function(e){e.preventDefault(),u.previewer.previewUrl(e.target.toString())})},_setupTitleUI:function(){var i;this.container.find(".edit-menu-item-title").on("blur",function(){m(this).val(m(this).val().trim())}),i=this.container.find(".menu-item-title"),this.setting.bind(function(e){var t,n;e&&(e.title=e.title||"",n=(t=e.title.trim())||e.original_title||u.Menus.data.l10n.untitled,e._invalid&&(n=u.Menus.data.l10n.invalidTitleTpl.replace("%s",n)),t||e.original_title?i.text(n).removeClass("no-title"):i.text(n).addClass("no-title"))})},getDepth:function(){var e=this,t=e.setting(),n=0;if(!t)return 0;for(;t&&t.menu_item_parent&&(n+=1,e=u.control("nav_menu_item["+t.menu_item_parent+"]"));)t=e.setting();return n},renderContent:function(){var e,t=this,n=t.setting();t.params.title=n.title||"",t.params.depth=t.getDepth(),t.container.data("item-depth",t.params.depth),e=["menu-item","menu-item-depth-"+String(t.params.depth),"menu-item-"+n.object,"menu-item-edit-inactive"],n._invalid?(e.push("menu-item-invalid"),t.params.title=u.Menus.data.l10n.invalidTitleTpl.replace("%s",t.params.title)):"draft"===n.status&&(e.push("pending"),t.params.title=u.Menus.data.pendingTitleTpl.replace("%s",t.params.title)),t.params.el_classes=e.join(" "),t.params.item_type_label=n.type_label,t.params.item_type=n.type,t.params.url=n.url,t.params.target=n.target,t.params.attr_title=n.attr_title,t.params.classes=_.isArray(n.classes)?n.classes.join(" "):n.classes,t.params.xfn=n.xfn,t.params.description=n.description,t.params.parent=n.menu_item_parent,t.params.original_title=n.original_title||"",t.container.addClass(t.params.el_classes),u.Control.prototype.renderContent.call(t)},getMenuControl:function(){var e=this.setting();return e&&e.nav_menu_term_id?u.control("nav_menu["+e.nav_menu_term_id+"]"):null},expandControlSection:function(){var e=this.container.closest(".accordion-section");e.hasClass("open")||e.find(".accordion-section-title:first").trigger("click")},_toggleExpanded:u.Section.prototype._toggleExpanded,expand:u.Section.prototype.expand,expandForm:function(e){this.expand(e)},collapse:u.Section.prototype.collapse,collapseForm:function(e){this.collapse(e)},toggleForm:function(e,t){(e=void 0===e?!this.expanded():e)?this.expand(t):this.collapse(t)},onChangeExpanded:function(e,t){var n,i=this,a=this.container,o=a.find(".menu-item-settings:first");void 0===e&&(e=!o.is(":visible")),o.is(":visible")===e?t&&t.completeCallback&&t.completeCallback():e?(u.control.each(function(e){i.params.type===e.params.type&&i!==e&&e.collapseForm()}),n=function(){a.removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active"),i.container.trigger("expanded"),t&&t.completeCallback&&t.completeCallback()},a.find(".item-edit").attr("aria-expanded","true"),o.slideDown("fast",n),i.container.trigger("expand")):(n=function(){a.addClass("menu-item-edit-inactive").removeClass("menu-item-edit-active"),i.container.trigger("collapsed"),t&&t.completeCallback&&t.completeCallback()},i.container.trigger("collapse"),a.find(".item-edit").attr("aria-expanded","false"),o.slideUp("fast",n))},focus:function(e){var t=this,n=(e=e||{}).completeCallback,i=function(){t.expandControlSection(),e.completeCallback=function(){t.container.find(".menu-item-settings").find("input, select, textarea, button, object, a[href], [tabindex]").filter(":visible").first().focus(),n&&n()},t.expandForm(e)};u.section.has(t.section())?u.section(t.section()).expand({completeCallback:i}):i()},moveUp:function(){this._changePosition(-1),l.a11y.speak(u.Menus.data.l10n.movedUp)},moveDown:function(){this._changePosition(1),l.a11y.speak(u.Menus.data.l10n.movedDown)},moveLeft:function(){this._changeDepth(-1),l.a11y.speak(u.Menus.data.l10n.movedLeft)},moveRight:function(){this._changeDepth(1),l.a11y.speak(u.Menus.data.l10n.movedRight)},_changePosition:function(e){var t,n=this,i=_.clone(n.setting()),a=[];if(1!==e&&-1!==e)throw new Error("Offset changes by 1 are only supported.");if(n.setting()){if(_(n.getMenuControl().getMenuItemControls()).each(function(e){e.setting().menu_item_parent===i.menu_item_parent&&a.push(e.setting)}),a.sort(function(e,t){return e().position-t().position}),-1===(t=_.indexOf(a,n.setting)))throw new Error("Expected setting to be among siblings.");0===t&&e<0||t===a.length-1&&0<e||((t=a[t+e])&&t.set(m.extend(_.clone(t()),{position:i.position})),i.position+=e,n.setting.set(i))}},_changeDepth:function(e){if(1!==e&&-1!==e)throw new Error("Offset changes by 1 are only supported.");var t,n,i=this,a=_.clone(i.setting()),o=[];if(_(i.getMenuControl().getMenuItemControls()).each(function(e){e.setting().menu_item_parent===a.menu_item_parent&&o.push(e)}),o.sort(function(e,t){return e.setting().position-t.setting().position}),-1===(t=_.indexOf(o,i)))throw new Error("Expected control to be among siblings.");-1===e?a.menu_item_parent&&(n=u.control("nav_menu_item["+a.menu_item_parent+"]"),_(o).chain().slice(t).each(function(e,t){e.setting.set(m.extend({},e.setting(),{menu_item_parent:i.params.menu_item_id,position:t}))}),_(i.getMenuControl().getMenuItemControls()).each(function(e){var t;e.setting().menu_item_parent===n.setting().menu_item_parent&&e.setting().position>n.setting().position&&(t=_.clone(e.setting()),e.setting.set(m.extend(t,{position:t.position+1})))}),a.position=n.setting().position+1,a.menu_item_parent=n.setting().menu_item_parent,i.setting.set(a)):1===e&&0!==t&&(a.menu_item_parent=o[t-1].params.menu_item_id,a.position=0,_(i.getMenuControl().getMenuItemControls()).each(function(e){e.setting().menu_item_parent===a.menu_item_parent&&(a.position=Math.max(a.position,e.setting().position))}),a.position+=1,i.setting.set(a))}}),u.Menus.MenuNameControl=u.Control.extend({ready:function(){var e,n=this;n.setting&&(e=n.setting(),n.nameElement=new u.Element(n.container.find(".menu-name-field")),n.nameElement.bind(function(e){var t=n.setting();t&&t.name!==e&&((t=_.clone(t)).name=e,n.setting.set(t))}),e&&n.nameElement.set(e.name),n.setting.bind(function(e){e&&n.nameElement.set(e.name)}))}}),u.Menus.MenuLocationsControl=u.Control.extend({ready:function(){var d=this;d.container.find(".assigned-menu-location").each(function(){function t(e){var t=u("nav_menu["+String(e)+"]");e&&t&&t()?n.find(".theme-location-set").show().find("span").text(c(t().name)):n.find(".theme-location-set").hide()}var n=m(this),e=n.find("input[type=checkbox]"),i=new u.Element(e),a=u("nav_menu_locations["+e.data("location-id")+"]"),o=""===d.params.menu_id,s=o?_.noop:function(e){i.set(e)},r=o?_.noop:function(e){a.set(e?d.params.menu_id:0)};s(a.get()===d.params.menu_id),e.on("change",function(){r(this.checked)}),a.bind(function(e){s(e===d.params.menu_id),t(e)}),t(a.get())})},setSelections:function(i){this.container.find(".menu-location").each(function(e,t){var n=t.dataset.locationId;t.checked=n in i&&i[n]})}}),u.Menus.MenuAutoAddControl=u.Control.extend({ready:function(){var n=this,e=n.setting();n.active.validate=function(){var e=u.section(n.section()),e=!!e&&e.active();return e},n.autoAddElement=new u.Element(n.container.find("input[type=checkbox].auto_add")),n.autoAddElement.bind(function(e){var t=n.setting();t&&t.name!==e&&((t=_.clone(t)).auto_add=e,n.setting.set(t))}),e&&n.autoAddElement.set(e.auto_add),n.setting.bind(function(e){e&&n.autoAddElement.set(e.auto_add)})}}),u.Menus.MenuControl=u.Control.extend({ready:function(){var t,n,i=this,a=u.section(i.section()),o=i.params.menu_id,e=i.setting();if(void 0===this.params.menu_id)throw new Error("params.menu_id was not defined");i.active.validate=function(){var e=!!a&&a.active();return e},i.$controlSection=a.headContainer,i.$sectionContent=i.container.closest(".accordion-section-content"),this._setupModel(),u.section(i.section(),function(e){e.deferred.initSortables.done(function(e){i._setupSortable(e)})}),this._setupAddition(),this._setupTitle(),e&&(t=c(e.name),u.control.each(function(e){e.extended(u.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&(e.container.find(".nav-menu-widget-form-controls:first").show(),e.container.find(".nav-menu-widget-no-menus-message:first").hide(),0===(n=e.container.find("select")).find("option[value="+String(o)+"]").length)&&n.append(new Option(t,o))}),(e=m("#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )")).find(".nav-menu-widget-form-controls:first").show(),e.find(".nav-menu-widget-no-menus-message:first").hide(),0===(n=e.find(".widget-inside select:first")).find("option[value="+String(o)+"]").length)&&n.append(new Option(t,o)),_.defer(function(){i.updateInvitationVisibility()})},_setupModel:function(){var n=this,i=n.params.menu_id;n.setting.bind(function(e){var t;!1===e?n._handleDeletion():(t=c(e.name),u.control.each(function(e){e.extended(u.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&e.container.find("select").find("option[value="+String(i)+"]").text(t)}))})},_setupSortable:function(e){var a=this;if(!e.is(a.$sectionContent))throw new Error("Unexpected menuList.");e.on("sortstart",function(){a.isSorting=!0}),e.on("sortstop",function(){setTimeout(function(){var e=a.$sectionContent.sortable("toArray"),t=[],n=0,i=10;a.isSorting=!1,a.$sectionContent.scrollLeft(0),_.each(e,function(e){var e=e.match(/^customize-control-nav_menu_item-(-?\d+)$/,"");e&&(e=parseInt(e[1],10),e=u.control("nav_menu_item["+String(e)+"]"))&&t.push(e)}),_.each(t,function(e){var t;!1!==e.setting()&&(t=_.clone(e.setting()),n+=1,i+=1,t.position=n,e.priority(i),t.menu_item_parent=parseInt(e.container.find(".menu-item-data-parent-id").val(),10),t.menu_item_parent||(t.menu_item_parent=0),e.setting.set(t))}),m("button.item-edit").data("needs_accessibility_refresh",!0)})}),a.isReordering=!1,this.container.find(".reorder-toggle").on("click",function(){a.toggleReordering(!a.isReordering)})},_setupAddition:function(){var t=this;this.container.find(".add-new-menu-item").on("click",function(e){t.$sectionContent.hasClass("reordering")||(m("body").hasClass("adding-menu-items")?(m(this).attr("aria-expanded","false"),u.Menus.availableMenuItemsPanel.close(),e.stopPropagation()):(m(this).attr("aria-expanded","true"),u.Menus.availableMenuItemsPanel.open(t)))})},_handleDeletion:function(){var e,n=this.params.menu_id,i=0,t=u.section(this.section()),a=function(){t.container.remove(),u.section.remove(t.id)};t&&t.expanded()?t.collapse({completeCallback:function(){a(),l.a11y.speak(u.Menus.data.l10n.menuDeleted),u.panel("nav_menus").focus()}}):a(),u.each(function(e){/^nav_menu\[/.test(e.id)&&!1!==e()&&(i+=1)}),u.control.each(function(e){var t;e.extended(u.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&((t=e.container.find("select")).val()===String(n)&&t.prop("selectedIndex",0).trigger("change"),e.container.find(".nav-menu-widget-form-controls:first").toggle(0!==i),e.container.find(".nav-menu-widget-no-menus-message:first").toggle(0===i),e.container.find("option[value="+String(n)+"]").remove())}),(e=m("#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )")).find(".nav-menu-widget-form-controls:first").toggle(0!==i),e.find(".nav-menu-widget-no-menus-message:first").toggle(0===i),e.find("option[value="+String(n)+"]").remove()},_setupTitle:function(){var d=this;d.setting.bind(function(e){var t,n,i,a,o,s,r;e&&(t=u.section(d.section()),n=d.params.menu_id,i=t.headContainer.find(".accordion-section-title"),a=t.contentContainer.find(".customize-section-title h3"),o=t.headContainer.find(".menu-in-location"),s=a.find(".customize-action"),r=c(e.name),i.text(r),o.length&&o.appendTo(i),a.text(r),s.length&&s.prependTo(a),u.control.each(function(e){/^nav_menu_locations\[/.test(e.id)&&e.container.find("option[value="+n+"]").text(r)}),t.contentContainer.find(".customize-control-checkbox input").each(function(){m(this).prop("checked")&&m(".current-menu-location-name-"+m(this).data("location-id")).text(r)}))})},toggleReordering:function(e){var t=this.container.find(".add-new-menu-item"),n=this.container.find(".reorder-toggle"),i=this.$sectionContent.find(".item-title");(e=Boolean(e))!==this.$sectionContent.hasClass("reordering")&&(this.isReordering=e,this.$sectionContent.toggleClass("reordering",e),this.$sectionContent.sortable(this.isReordering?"disable":"enable"),this.isReordering?(t.attr({tabindex:"-1","aria-hidden":"true"}),n.attr("aria-label",u.Menus.data.l10n.reorderLabelOff),l.a11y.speak(u.Menus.data.l10n.reorderModeOn),i.attr("aria-hidden","false")):(t.removeAttr("tabindex aria-hidden"),n.attr("aria-label",u.Menus.data.l10n.reorderLabelOn),l.a11y.speak(u.Menus.data.l10n.reorderModeOff),i.attr("aria-hidden","true")),e)&&_(this.getMenuItemControls()).each(function(e){e.collapseForm()})},getMenuItemControls:function(){var t=[],n=this.params.menu_id;return u.control.each(function(e){"nav_menu_item"===e.params.type&&e.setting()&&n===e.setting().nav_menu_term_id&&t.push(e)}),t},reflowMenuItems:function(){var e=this.getMenuItemControls(),a=function(n){var t=[],i=n.currentParent;_.each(n.menuItemControls,function(e){i===e.setting().menu_item_parent&&t.push(e)}),t.sort(function(e,t){return e.setting().position-t.setting().position}),_.each(t,function(t){n.currentAbsolutePosition+=1,t.priority.set(n.currentAbsolutePosition),t.container.hasClass("menu-item-depth-"+String(n.currentDepth))||(_.each(t.container.prop("className").match(/menu-item-depth-\d+/g),function(e){t.container.removeClass(e)}),t.container.addClass("menu-item-depth-"+String(n.currentDepth))),t.container.data("item-depth",n.currentDepth),n.currentDepth+=1,n.currentParent=t.params.menu_item_id,a(n),--n.currentDepth,n.currentParent=i}),t.length&&(_(t).each(function(e){e.container.removeClass("move-up-disabled move-down-disabled move-left-disabled move-right-disabled"),0===n.currentDepth?e.container.addClass("move-left-disabled"):10===n.currentDepth&&e.container.addClass("move-right-disabled")}),t[0].container.addClass("move-up-disabled").addClass("move-right-disabled").toggleClass("move-down-disabled",1===t.length),t[t.length-1].container.addClass("move-down-disabled").toggleClass("move-up-disabled",1===t.length))};a({menuItemControls:e,currentParent:0,currentDepth:0,currentAbsolutePosition:0}),this.updateInvitationVisibility(e),this.container.find(".reorder-toggle").toggle(1<e.length)},debouncedReflowMenuItems:_.debounce(function(){this.reflowMenuItems.apply(this,arguments)},0),addItemToMenu:function(e){var t,n,i,a=0,o=10,s=e.id||"";return _.each(this.getMenuItemControls(),function(e){!1!==e.setting()&&(o=Math.max(o,e.priority()),0===e.setting().menu_item_parent)&&(a=Math.max(a,e.setting().position))}),a+=1,o+=1,delete(e=m.extend({},u.Menus.data.defaultSettingValues.nav_menu_item,e,{nav_menu_term_id:this.params.menu_id,original_title:e.title,position:a})).id,i=u.Menus.generatePlaceholderAutoIncrementId(),t="nav_menu_item["+String(i)+"]",n={type:"nav_menu_item",transport:u.Menus.data.settingTransport,previewer:u.previewer},(n=u.create(t,t,{},n)).set(e),e=new u.controlConstructor.nav_menu_item(t,{type:"nav_menu_item",section:this.id,priority:o,settings:{default:t},menu_item_id:i,original_item_id:s}),u.control.add(e),n.preview(),this.debouncedReflowMenuItems(),l.a11y.speak(u.Menus.data.l10n.itemAdded),e},updateInvitationVisibility:function(e){e=e||this.getMenuItemControls();this.container.find(".new-menu-item-invitation").toggle(0===e.length)}}),m.extend(u.controlConstructor,{nav_menu_location:u.Menus.MenuLocationControl,nav_menu_item:u.Menus.MenuItemControl,nav_menu:u.Menus.MenuControl,nav_menu_name:u.Menus.MenuNameControl,nav_menu_locations:u.Menus.MenuLocationsControl,nav_menu_auto_add:u.Menus.MenuAutoAddControl}),m.extend(u.panelConstructor,{nav_menus:u.Menus.MenusPanel}),m.extend(u.sectionConstructor,{nav_menu:u.Menus.MenuSection,new_menu:u.Menus.NewMenuSection}),u.bind("ready",function(){u.Menus.availableMenuItemsPanel=new u.Menus.AvailableMenuItemsPanelView({collection:u.Menus.availableMenuItems}),u.bind("saved",function(e){(e.nav_menu_updates||e.nav_menu_item_updates)&&u.Menus.applySavedData(e)}),u.state("changesetStatus").bind(function(e){"publish"===e&&(u("nav_menus_created_posts")._value=[])}),u.previewer.bind("focus-nav-menu-item-control",u.Menus.focusMenuItemControl)}),u.Menus.applySavedData=function(e){var c={},r={};_(e.nav_menu_updates).each(function(n){var e,t,i,a,o,s,r,d;if("inserted"===n.status){if(!n.previous_term_id)throw new Error("Expected previous_term_id");if(!n.term_id)throw new Error("Expected term_id");if(e="nav_menu["+String(n.previous_term_id)+"]",!u.has(e))throw new Error("Expected setting to exist: "+e);if(i=u(e),!u.section.has(e))throw new Error("Expected control to exist: "+e);if(o=u.section(e),!(s=i.get()))throw new Error("Did not expect setting to be empty (deleted).");s=m.extend(_.clone(s),n.saved_value),c[n.previous_term_id]=n.term_id,a="nav_menu["+String(n.term_id)+"]",t=u.create(a,a,s,{type:"nav_menu",transport:u.Menus.data.settingTransport,previewer:u.previewer}),(d=o.expanded())&&o.collapse(),a=new u.Menus.MenuSection(a,{panel:"nav_menus",title:s.name,customizeAction:u.Menus.data.l10n.customizingMenus,type:"nav_menu",priority:o.priority.get(),menu_id:n.term_id}),u.section.add(a),u.control.each(function(e){var t;e.extended(u.controlConstructor.widget_form)&&"nav_menu"===e.params.widget_id_base&&(t=(e=e.container.find("select")).find("option[value="+String(n.previous_term_id)+"]"),e.find("option[value="+String(n.term_id)+"]").prop("selected",t.prop("selected")),t.remove())}),i.callbacks.disable(),i.set(!1),i.preview(),t.preview(),i._dirty=!1,o.container.remove(),u.section.remove(e),r=0,u.each(function(e){/^nav_menu\[/.test(e.id)&&!1!==e()&&(r+=1)}),(s=m("#available-widgets-list .widget-tpl:has( input.id_base[ value=nav_menu ] )")).find(".nav-menu-widget-form-controls:first").toggle(0!==r),s.find(".nav-menu-widget-no-menus-message:first").toggle(0===r),s.find("option[value="+String(n.previous_term_id)+"]").remove(),l.customize.control.each(function(e){/^nav_menu_locations\[/.test(e.id)&&e.container.find("option[value="+String(n.previous_term_id)+"]").remove()}),u.each(function(e){var t=u.state("saved").get();/^nav_menu_locations\[/.test(e.id)&&e.get()===n.previous_term_id&&(e.set(n.term_id),e._dirty=!1,u.state("saved").set(t),e.preview())}),d&&a.expand()}else if("updated"===n.status){if(t="nav_menu["+String(n.term_id)+"]",!u.has(t))throw new Error("Expected setting to exist: "+t);i=u(t),_.isEqual(n.saved_value,i.get())||(o=u.state("saved").get(),i.set(n.saved_value),i._dirty=!1,u.state("saved").set(o))}}),_(e.nav_menu_item_updates).each(function(e){e.previous_post_id&&(r[e.previous_post_id]=e.post_id)}),_(e.nav_menu_item_updates).each(function(e){var t,n,i,a,o,s;if("inserted"===e.status){if(!e.previous_post_id)throw new Error("Expected previous_post_id");if(!e.post_id)throw new Error("Expected post_id");if(t="nav_menu_item["+String(e.previous_post_id)+"]",!u.has(t))throw new Error("Expected setting to exist: "+t);if(i=u(t),!u.control.has(t))throw new Error("Expected control to exist: "+t);if(o=u.control(t),!(s=i.get()))throw new Error("Did not expect setting to be empty (deleted).");if((s=_.clone(s)).menu_item_parent<0){if(!r[s.menu_item_parent])throw new Error("inserted ID for menu_item_parent not available");s.menu_item_parent=r[s.menu_item_parent]}c[s.nav_menu_term_id]&&(s.nav_menu_term_id=c[s.nav_menu_term_id]),n="nav_menu_item["+String(e.post_id)+"]",a=u.create(n,n,s,{type:"nav_menu_item",transport:u.Menus.data.settingTransport,previewer:u.previewer}),s=new u.controlConstructor.nav_menu_item(n,{type:"nav_menu_item",menu_id:e.post_id,section:"nav_menu["+String(s.nav_menu_term_id)+"]",priority:o.priority.get(),settings:{default:n},menu_item_id:e.post_id}),o.container.remove(),u.control.remove(t),u.control.add(s),i.callbacks.disable(),i.set(!1),i.preview(),a.preview(),i._dirty=!1,s.container.toggleClass("menu-item-edit-inactive",o.container.hasClass("menu-item-edit-inactive"))}}),_.each(e.widget_nav_menu_updates,function(e,t){t=u(t);t&&(t._value=e,t.preview())})},u.Menus.focusMenuItemControl=function(e){e=u.Menus.getMenuItemControl(e);e&&e.focus()},u.Menus.getMenuControl=function(e){return u.control("nav_menu["+e+"]")},u.Menus.getMenuItemControl=function(e){return u.control("nav_menu_item["+e+"]")}}(wp.customize,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 2ba8aee..56459ad 100644 --- a/wp-admin/js/customize-widgets.js +++ b/wp-admin/js/customize-widgets.js @@ -388,7 +388,7 @@ }, /** - * Adds keyboard accessiblity to the panel. + * Adds keyboard accessibility to the panel. */ keyboardAccessible: function( event ) { var isEnter = ( event.which === 13 ), @@ -1623,7 +1623,8 @@ // @todo This should use the Notifications API introduced to panels. See <https://core.trac.wordpress.org/ticket/38794>. noticeContainer = $( '<div></div>', { - 'class': 'no-widget-areas-rendered-notice' + 'class': 'no-widget-areas-rendered-notice', + 'role': 'alert' }); panelMetaContainer.append( noticeContainer ); diff --git a/wp-admin/js/customize-widgets.min.js b/wp-admin/js/customize-widgets.min.js index 83179a9..8111ac8 100644 --- a/wp-admin/js/customize-widgets.min.js +++ b/wp-admin/js/customize-widgets.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(u,h){var p,f;function c(e){var t={number:null,id_base:null},i=e.match(/^(.+)-(\d+)$/);return i?(t.id_base=i[1],t.number=parseInt(i[2],10)):t.id_base=e,t}u&&u.customize&&((p=u.customize).Widgets=p.Widgets||{},p.Widgets.savedWidgetIds={},p.Widgets.data=_wpCustomizeWidgetsSettings||{},f=p.Widgets.data.l10n,p.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:null,params:[],width:null,height:null,search_matched:!0}),p.Widgets.WidgetCollection=Backbone.Collection.extend({model:p.Widgets.WidgetModel,doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms)&&this.each(function(e){e.set("search_matched",!0)})},search:function(e){var t,i;e=(e=e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),t=new RegExp("^(?=.*"+e+").+","i"),this.each(function(e){i=[e.get("name"),e.get("description")].join(" "),e.set("search_matched",t.test(i))})}}),p.Widgets.availableWidgets=new p.Widgets.WidgetCollection(p.Widgets.data.availableWidgets),p.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}),p.Widgets.SidebarCollection=Backbone.Collection.extend({model:p.Widgets.SidebarModel}),p.Widgets.registeredSidebars=new p.Widgets.SidebarCollection(p.Widgets.data.registeredSidebars),p.Widgets.AvailableWidgetsPanelView=u.Backbone.View.extend({el:"#available-widgets",events:{"input #widgets-search":"search","focus .widget-tpl":"focus","click .widget-tpl":"_submit","keypress .widget-tpl":"_submit",keydown:"keyboardAccessible"},selected:null,currentSidebarControl:null,$search:null,$clearResults:null,searchMatchesCount:null,initialize:function(){var t=this;this.$search=h("#widgets-search"),this.$clearResults=this.$el.find(".clear-results"),_.bindAll(this,"close"),this.listenTo(this.collection,"change",this.updateList),this.updateList(),this.searchMatchesCount=this.collection.length,h("#customize-controls, #available-widgets .customize-section-title").on("click keydown",function(e){e=h(e.target).is(".add-new-widget, .add-new-widget *");h("body").hasClass("adding-widget")&&!e&&t.close()}),this.$clearResults.on("click",function(){t.$search.val("").trigger("focus").trigger("input")}),p.previewer.bind("url",this.close)},search:_.debounce(function(e){var t;this.collection.doSearch(e.target.value),this.updateSearchMatchesCount(),this.announceSearchMatches(),this.selected&&!this.selected.is(":visible")&&(this.selected.removeClass("selected"),this.selected=null),this.selected&&!e.target.value&&(this.selected.removeClass("selected"),this.selected=null),!this.selected&&e.target.value&&(t=this.$el.find("> .widget-tpl:visible:first")).length&&this.select(t),""!==e.target.value?this.$clearResults.addClass("is-visible"):""===e.target.value&&this.$clearResults.removeClass("is-visible"),this.searchMatchesCount?this.$el.removeClass("no-widgets-found"):this.$el.addClass("no-widgets-found")},500),updateSearchMatchesCount:function(){this.searchMatchesCount=this.collection.where({search_matched:!0}).length},announceSearchMatches:function(){var e=f.widgetsFound.replace("%d",this.searchMatchesCount);this.searchMatchesCount||(e=f.noWidgetsFound),u.a11y.speak(e)},updateList:function(){this.collection.each(function(e){var t=h("#widget-tpl-"+e.id);t.toggle(e.get("search_matched")&&!e.get("is_disabled")),e.get("is_disabled")&&t.is(this.selected)&&(this.selected=null)})},select:function(e){this.selected=h(e),this.selected.siblings(".widget-tpl").removeClass("selected"),this.selected.addClass("selected")},focus:function(e){this.select(h(e.currentTarget))},_submit:function(e){"keypress"===e.type&&13!==e.which&&32!==e.which||this.submit(h(e.currentTarget))},submit:function(e){(e=e||this.selected)&&this.currentSidebarControl&&(this.select(e),e=h(this.selected).data("widget-id"),e=this.collection.findWhere({id:e}))&&((e=this.currentSidebarControl.addWidget(e.get("id_base")))&&e.focus(),this.close())},open:function(e){this.currentSidebarControl=e,_(this.currentSidebarControl.getWidgetFormControls()).each(function(e){e.params.is_wide&&e.collapseForm()}),p.section.has("publish_settings")&&p.section("publish_settings").collapse(),h("body").addClass("adding-widget"),this.$el.find(".selected").removeClass("selected"),this.collection.doSearch(""),p.settings.browser.mobile||this.$search.trigger("focus")},close:function(e){(e=e||{}).returnFocus&&this.currentSidebarControl&&this.currentSidebarControl.container.find(".add-new-widget").focus(),this.currentSidebarControl=null,this.selected=null,h("body").removeClass("adding-widget"),this.$search.val("").trigger("input")},keyboardAccessible:function(e){var t=13===e.which,i=27===e.which,n=40===e.which,s=38===e.which,d=9===e.which,a=e.shiftKey,o=null,r=this.$el.find("> .widget-tpl:visible:first"),l=this.$el.find("> .widget-tpl:visible:last"),c=h(e.target).is(this.$search),g=h(e.target).is(".widget-tpl:visible:last");n||s?(n?c?o=r:this.selected&&0!==this.selected.nextAll(".widget-tpl:visible").length&&(o=this.selected.nextAll(".widget-tpl:visible:first")):s&&(c?o=l:this.selected&&0!==this.selected.prevAll(".widget-tpl:visible").length&&(o=this.selected.prevAll(".widget-tpl:visible:first"))),this.select(o),(o||this.$search).trigger("focus")):t&&!this.$search.val()||(t?this.submit():i&&this.close({returnFocus:!0}),this.currentSidebarControl&&d&&(a&&c||!a&&g)&&(this.currentSidebarControl.container.find(".add-new-widget").focus(),e.preventDefault()))}}),p.Widgets.formSyncHandlers={rss:function(e,t,i){var n=t.find(".widget-error:first"),i=h("<div>"+i+"</div>").find(".widget-error:first");n.length&&i.length?n.replaceWith(i):n.length?n.remove():i.length&&t.find(".widget-content:first").prepend(i)}},p.Widgets.WidgetControl=p.Control.extend({defaultExpandedArguments:{duration:"fast",completeCallback:h.noop},initialize:function(e,t){var i=this;i.widgetControlEmbedded=!1,i.widgetContentEmbedded=!1,i.expanded=new p.Value(!1),i.expandedArgumentsQueue=[],i.expanded.bind(function(e){var t=i.expandedArgumentsQueue.shift(),t=h.extend({},i.defaultExpandedArguments,t);i.onChangeExpanded(e,t)}),i.altNotice=!0,p.Control.prototype.initialize.call(i,e,t)},ready:function(){var n=this;n.section()?p.section(n.section(),function(t){function i(e){e&&(n.embedWidgetControl(),t.expanded.unbind(i))}t.expanded()?i(!0):t.expanded.bind(i)}):n.embedWidgetControl()},embedWidgetControl:function(){var e,t=this;t.widgetControlEmbedded||(t.widgetControlEmbedded=!0,e=h(t.params.widget_control),t.container.append(e),t._setupModel(),t._setupWideWidget(),t._setupControlToggle(),t._setupWidgetTitle(),t._setupReorderUI(),t._setupHighlightEffects(),t._setupUpdateUI(),t._setupRemoveUI())},embedWidgetContent:function(){var e,t=this;t.embedWidgetControl(),t.widgetContentEmbedded||(t.widgetContentEmbedded=!0,t.notifications.container=t.getNotificationsContainerElement(),t.notifications.render(),e=h(t.params.widget_content),t.container.find(".widget-content:first").append(e),h(document).trigger("widget-added",[t.container.find(".widget:first")]))},_setupModel:function(){var i=this,e=function(){p.Widgets.savedWidgetIds[i.params.widget_id]=!0};p.bind("ready",e),p.bind("saved",e),this._updateCount=0,this.isWidgetUpdating=!1,this.liveUpdateMode=!0,this.setting.bind(function(e,t){_(t).isEqual(e)||i.isWidgetUpdating||i.updateWidget({instance:e})})},_setupWideWidget:function(){var n,s,e,t,i,d=this;!this.params.is_wide||h(window).width()<=640||(n=this.container.find(".widget-inside"),s=n.find("> .form"),e=h(".wp-full-overlay-sidebar-content:first"),this.container.addClass("wide-widget-control"),this.container.find(".form:first").css({"max-width":this.params.width,"min-height":this.params.height}),i=function(){var e=d.container.offset().top,t=h(window).height(),i=s.outerHeight();n.css("max-height",t),e=Math.max(0,Math.min(Math.max(e,0),t-i)),n.css("top",e)},t=h("#customize-theme-controls"),this.container.on("expand",function(){i(),e.on("scroll",i),h(window).on("resize",i),t.on("expanded collapsed",i)}),this.container.on("collapsed",function(){e.off("scroll",i),h(window).off("resize",i),t.off("expanded collapsed",i)}),p.each(function(e){0===e.id.indexOf("sidebars_widgets[")&&e.bind(function(){d.container.hasClass("expanded")&&i()})}))},_setupControlToggle:function(){var t=this;this.container.find(".widget-top").on("click",function(e){e.preventDefault(),t.getSidebarWidgetsControl().isReordering||t.expanded(!t.expanded())}),this.container.find(".widget-control-close").on("click",function(){t.collapse(),t.container.find(".widget-top .widget-action:first").focus()})},_setupWidgetTitle:function(){var i=this,e=function(){var e=i.setting().title,t=i.container.find(".in-widget-title");e?t.text(": "+e):t.text("")};this.setting.bind(e),e()},_setupReorderUI:function(){var t,e,d=this,s=function(e){e.siblings(".selected").removeClass("selected"),e.addClass("selected");e=e.data("id")===d.params.sidebar_id;d.container.find(".move-widget-btn").prop("disabled",e)};this.container.find(".widget-title-action").after(h(p.Widgets.data.tpl.widgetReorderNav)),e=_.template(p.Widgets.data.tpl.moveWidgetArea),t=h(e({sidebars:_(p.Widgets.registeredSidebars.toArray()).pluck("attributes")})),this.container.find(".widget-top").after(t),(e=function(){var e=t.find("li"),i=0,n=e.filter(function(){return h(this).data("id")===d.params.sidebar_id});e.each(function(){var e=h(this),t=e.data("id"),t=p.Widgets.registeredSidebars.get(t).get("is_rendered");e.toggle(t),t&&(i+=1),e.hasClass("selected")&&!t&&s(n)}),1<i?d.container.find(".move-widget").show():d.container.find(".move-widget").hide()})(),p.Widgets.registeredSidebars.on("change:is_rendered",e),this.container.find(".widget-reorder-nav").find(".move-widget, .move-widget-down, .move-widget-up").each(function(){h(this).prepend(d.container.find(".widget-title").text()+": ")}).on("click keypress",function(e){var t,i;"keypress"===e.type&&13!==e.which&&32!==e.which||(h(this).trigger("focus"),h(this).is(".move-widget")?d.toggleWidgetMoveArea():(e=h(this).is(".move-widget-down"),t=h(this).is(".move-widget-up"),i=d.getWidgetSidebarPosition(),t&&0===i||e&&i===d.getSidebarWidgetsControl().setting().length-1||(t?(d.moveUp(),u.a11y.speak(f.widgetMovedUp)):(d.moveDown(),u.a11y.speak(f.widgetMovedDown)),h(this).trigger("focus"))))}),this.container.find(".widget-area-select").on("click keypress","li",function(e){"keypress"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),s(h(this)))}),this.container.find(".move-widget-btn").click(function(){d.getSidebarWidgetsControl().toggleReordering(!1);var e=d.params.sidebar_id,t=d.container.find(".widget-area-select li.selected").data("id"),e=p("sidebars_widgets["+e+"]"),t=p("sidebars_widgets["+t+"]"),i=Array.prototype.slice.call(e()),n=Array.prototype.slice.call(t()),s=d.getWidgetSidebarPosition();i.splice(s,1),n.push(d.params.widget_id),e(i),t(n),d.focus()})},_setupHighlightEffects:function(){var e=this;this.container.on("mouseenter click",function(){e.setting.previewer.send("highlight-widget",e.params.widget_id)}),this.setting.bind(function(){e.setting.previewer.send("highlight-widget",e.params.widget_id)})},_setupUpdateUI:function(){var t,i,n=this,s=this.container.find(".widget:first"),e=s.find(".widget-content:first"),d=this.container.find(".widget-control-save");d.val(f.saveBtnLabel),d.attr("title",f.saveBtnTooltip),d.removeClass("button-primary"),d.on("click",function(e){e.preventDefault(),n.updateWidget({disable_form:!0})}),t=_.debounce(function(){n.updateWidget()},250),e.on("keydown","input",function(e){13===e.which&&(e.preventDefault(),n.updateWidget({ignoreActiveElement:!0}))}),e.on("change input propertychange",":input",function(e){n.liveUpdateMode&&("change"===e.type||this.checkValidity&&this.checkValidity())&&t()}),this.setting.previewer.channel.bind("synced",function(){n.container.removeClass("previewer-loading")}),p.previewer.bind("widget-updated",function(e){e===n.params.widget_id&&n.container.removeClass("previewer-loading")}),(i=p.Widgets.formSyncHandlers[this.params.widget_id_base])&&h(document).on("widget-synced",function(e,t){s.is(t)&&i.apply(document,arguments)})},onChangeActive:function(e,t){this.container.toggleClass("widget-rendered",e),t.completeCallback&&t.completeCallback()},_setupRemoveUI:function(){var e,s=this,t=this.container.find(".widget-control-remove");t.on("click",function(){var n=s.container.next().is(".customize-control-widget_form")?s.container.next().find(".widget-action:first"):s.container.prev().is(".customize-control-widget_form")?s.container.prev().find(".widget-action:first"):s.container.next(".customize-control-sidebar_widgets").find(".add-new-widget:first");s.container.slideUp(function(){var e,t,i=p.Widgets.getSidebarWidgetControlContainingWidget(s.params.widget_id);i&&(e=i.setting().slice(),-1!==(t=_.indexOf(e,s.params.widget_id)))&&(e.splice(t,1),i.setting(e),n.focus())})}),e=function(){t.text(f.removeBtnLabel),t.attr("title",f.removeBtnTooltip)},this.params.is_new?p.bind("saved",e):e()},_getInputs:function(e){return h(e).find(":input[name]")},_getInputsSignature:function(e){return _(e).map(function(e){e=h(e),e=e.is(":checkbox, :radio")?[e.attr("id"),e.attr("name"),e.prop("value")]:[e.attr("id"),e.attr("name")];return e.join(",")}).join(";")},_getInputState:function(e){return(e=h(e)).is(":radio, :checkbox")?e.prop("checked"):e.is("select[multiple]")?e.find("option:selected").map(function(){return h(this).val()}).get():e.val()},_setInputState:function(e,t){(e=h(e)).is(":radio, :checkbox")?e.prop("checked",t):e.is("select[multiple]")?(t=Array.isArray(t)?_.map(t,function(e){return String(e)}):[],e.find("option").each(function(){h(this).prop("selected",-1!==_.indexOf(t,String(this.value)))})):e.val(t)},getSidebarWidgetsControl:function(){var e="sidebars_widgets["+this.params.sidebar_id+"]",e=p.control(e);if(e)return e},updateWidget:function(s){var d,a,o,r,e,l,t,i,c,g=this;g.embedWidgetContent(),i=(s=h.extend({instance:null,complete:null,ignoreActiveElement:!1},s)).instance,d=s.complete,this._updateCount+=1,r=this._updateCount,a=this.container.find(".widget:first"),(o=a.find(".widget-content:first")).find(".widget-error").remove(),this.container.addClass("widget-form-loading"),this.container.addClass("previewer-loading"),(t=p.state("processing"))(t()+1),this.liveUpdateMode||this.container.addClass("widget-form-disabled"),(e={action:"update-widget",wp_customize:"on"}).nonce=p.settings.nonce["update-widget"],e.customize_theme=p.settings.theme.stylesheet,e.customized=u.customize.previewer.query().customized,e=h.param(e),(l=this._getInputs(o)).each(function(){h(this).data("state"+r,g._getInputState(this))}),e=(e+=i?"&"+h.param({sanitized_widget_setting:JSON.stringify(i)}):"&"+l.serialize())+"&"+o.find("~ :input").serialize(),this._previousUpdateRequest&&this._previousUpdateRequest.abort(),i=h.post(u.ajax.settings.url,e),(this._previousUpdateRequest=i).done(function(e){var n,t,i=!1;"0"===e?(p.previewer.preview.iframe.hide(),p.previewer.login().done(function(){g.updateWidget(s),p.previewer.preview.iframe.show()})):"-1"===e?p.previewer.cheatin():e.success?(t=h("<div>"+e.data.form+"</div>"),n=g._getInputs(t),(t=g._getInputsSignature(l)===g._getInputsSignature(n))&&!g.liveUpdateMode&&(g.liveUpdateMode=!0,g.container.removeClass("widget-form-disabled"),g.container.find('input[name="savewidget"]').hide()),t&&g.liveUpdateMode?(l.each(function(e){var t=h(this),e=h(n[e]),i=t.data("state"+r),e=g._getInputState(e);t.data("sanitized",e),_.isEqual(i,e)||!s.ignoreActiveElement&&t.is(document.activeElement)||g._setInputState(t,e)}),h(document).trigger("widget-synced",[a,e.data.form])):g.liveUpdateMode?(g.liveUpdateMode=!1,g.container.find('input[name="savewidget"]').show(),i=!0):(o.html(e.data.form),g.container.removeClass("widget-form-disabled"),h(document).trigger("widget-updated",[a])),(c=!i&&!_(g.setting()).isEqual(e.data.instance))?(g.isWidgetUpdating=!0,g.setting(e.data.instance),g.isWidgetUpdating=!1):g.container.removeClass("previewer-loading"),d&&d.call(g,null,{noChange:!c,ajaxFinished:!0})):(t=f.error,e.data&&e.data.message&&(t=e.data.message),d?d.call(g,t):o.prepend('<p class="widget-error"><strong>'+t+"</strong></p>"))}),i.fail(function(e,t){d&&d.call(g,t)}),i.always(function(){g.container.removeClass("widget-form-loading"),l.each(function(){h(this).removeData("state"+r)}),t(t()-1)})},expandControlSection:function(){p.Control.prototype.expand.call(this)},_toggleExpanded:p.Section.prototype._toggleExpanded,expand:p.Section.prototype.expand,expandForm:function(){this.expand()},collapse:p.Section.prototype.collapse,collapseForm:function(){this.collapse()},toggleForm:function(e){void 0===e&&(e=!this.expanded()),this.expanded(e)},onChangeExpanded:function(e,t){var i,n,s,d,a,o=this;o.embedWidgetControl(),e&&o.embedWidgetContent(),t.unchanged?e&&p.Control.prototype.expand.call(o,{completeCallback:t.completeCallback}):(i=this.container.find("div.widget:first"),n=i.find(".widget-inside:first"),e=function(){p.control.each(function(e){o.params.type===e.params.type&&o!==e&&e.collapse()}),s=function(){o.container.removeClass("expanding"),o.container.addClass("expanded"),i.addClass("open"),a.attr("aria-expanded","true"),o.container.trigger("expanded")},t.completeCallback&&(d=s,s=function(){d(),t.completeCallback()}),o.params.is_wide?n.fadeIn(t.duration,s):n.slideDown(t.duration,s),o.container.trigger("expand"),o.container.addClass("expanding")},"false"===(a=this.container.find(".widget-top button.widget-action")).attr("aria-expanded")?p.section.has(o.section())?p.section(o.section()).expand({completeCallback:e}):e():(s=function(){o.container.removeClass("collapsing"),o.container.removeClass("expanded"),i.removeClass("open"),a.attr("aria-expanded","false"),o.container.trigger("collapsed")},t.completeCallback&&(d=s,s=function(){d(),t.completeCallback()}),o.container.trigger("collapse"),o.container.addClass("collapsing"),o.params.is_wide?n.fadeOut(t.duration,s):n.slideUp(t.duration,function(){i.css({width:"",margin:""}),s()})))},getWidgetSidebarPosition:function(){var e=this.getSidebarWidgetsControl().setting(),e=_.indexOf(e,this.params.widget_id);if(-1!==e)return e},moveUp:function(){this._moveWidgetByOne(-1)},moveDown:function(){this._moveWidgetByOne(1)},_moveWidgetByOne:function(e){var t=this.getWidgetSidebarPosition(),i=this.getSidebarWidgetsControl().setting,n=Array.prototype.slice.call(i()),s=n[t+e];n[t+e]=this.params.widget_id,n[t]=s,i(n)},toggleWidgetMoveArea:function(e){var t=this,i=this.container.find(".move-widget-area");(e=void 0===e?!i.hasClass("active"):e)&&(i.find(".selected").removeClass("selected"),i.find("li").filter(function(){return h(this).data("id")===t.params.sidebar_id}).addClass("selected"),this.container.find(".move-widget-btn").prop("disabled",!0)),i.toggleClass("active",e)},highlightSectionAndControl:function(){var e=this.container.is(":hidden")?this.container.closest(".control-section"):this.container;h(".highlighted").removeClass("highlighted"),e.addClass("highlighted"),setTimeout(function(){e.removeClass("highlighted")},500)}}),p.Widgets.WidgetsPanel=p.Panel.extend({ready:function(){var d=this;p.Panel.prototype.ready.call(d),d.deferred.embedded.done(function(){var t,i,n,e=d.container.find(".panel-meta"),s=h("<div></div>",{class:"no-widget-areas-rendered-notice"});e.append(s),i=function(){return _.filter(d.sections(),function(e){return"sidebar"===e.params.type&&e.active()}).length},n=function(){var e=i();return 0===e||e!==p.Widgets.data.registeredSidebars.length},(t=function(){var e,t=i();s.empty(),t!==(e=p.Widgets.data.registeredSidebars.length)&&((e=0!==t?f.someAreasShown[e-t]:f.noAreasShown)&&s.append(h("<p></p>",{text:e})),s.append(h("<p></p>",{text:f.navigatePreview})))})(),s.toggle(n()),p.previewer.deferred.active.done(function(){s.toggle(n())}),p.bind("pane-contents-reflowed",function(){var e="resolved"===p.previewer.deferred.active.state()?"fast":0;t(),n()?s.slideDown(e):s.slideUp(e)})})},isContextuallyActive:function(){return this.active()}}),p.Widgets.SidebarSection=p.Section.extend({ready:function(){var t;p.Section.prototype.ready.call(this),t=p.Widgets.registeredSidebars.get(this.params.sidebarId),this.active.bind(function(e){t.set("is_rendered",e)}),t.set("is_rendered",this.active())}}),p.Widgets.SidebarControl=p.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 s=this;this.setting.bind(function(i,e){var t,n,e=_(e).difference(i);i=_(i).filter(function(e){e=c(e);return!!p.Widgets.availableWidgets.findWhere({id_base:e.id_base})}),(t=_(i).map(function(e){return p.Widgets.getWidgetFormControlForWidget(e)||s.addWidget(e)})).sort(function(e,t){return _.indexOf(i,e.params.widget_id)-_.indexOf(i,t.params.widget_id)}),n=0,_(t).each(function(e){e.priority(n),e.section(s.section()),n+=1}),s.priority(n),s._applyCardinalOrderClassNames(),_(t).each(function(e){e.params.sidebar_id=s.params.sidebar_id}),_(e).each(function(n){setTimeout(function(){var e,t,i=!1;p.each(function(e){e.id!==s.setting.id&&0===e.id.indexOf("sidebars_widgets[")&&"sidebars_widgets[wp_inactive_widgets]"!==e.id&&(e=e(),-1!==_.indexOf(e,n))&&(i=!0)}),i||(t=(e=p.Widgets.getWidgetFormControlForWidget(n))&&h.contains(document,e.container[0])&&!h.contains(s.$sectionContent[0],e.container[0]),e&&!t&&(p.control.remove(e.id),e.container.remove()),p.Widgets.savedWidgetIds[n]&&((t=p.value("sidebars_widgets[wp_inactive_widgets]")().slice()).push(n),p.value("sidebars_widgets[wp_inactive_widgets]")(_(t).unique())),e=c(n).id_base,(t=p.Widgets.availableWidgets.findWhere({id_base:e}))&&!t.get("is_multi")&&t.set("is_disabled",!1))})})})},_setupSortable:function(){var t=this;this.isReordering=!1,this.$sectionContent.sortable({items:"> .customize-control-widget_form",handle:".widget-top",axis:"y",tolerance:"pointer",connectWith:".accordion-section-content:has(.customize-control-sidebar_widgets)",update:function(){var e=t.$sectionContent.sortable("toArray"),e=h.map(e,function(e){return h("#"+e).find(":input[name=widget-id]").val()});t.setting(e)}}),this.$controlSection.find(".accordion-section-title").droppable({accept:".customize-control-widget_form",over:function(){p.section(t.section.get()).expand({allowMultiple:!0,completeCallback:function(){p.section.each(function(e){e.container.find(".customize-control-sidebar_widgets").length&&e.container.find(".accordion-section-content:first").sortable("refreshPositions")})}})}}),this.container.find(".reorder-toggle").on("click",function(){t.toggleReordering(!t.isReordering)})},_setupAddition:function(){var t=this;this.container.find(".add-new-widget").on("click",function(){var e=h(this);t.$sectionContent.hasClass("reordering")||(h("body").hasClass("adding-widget")?(e.attr("aria-expanded","false"),p.Widgets.availableWidgetsPanel.close()):(e.attr("aria-expanded","true"),p.Widgets.availableWidgetsPanel.open(t)))})},_applyCardinalOrderClassNames:function(){var t=[];_.each(this.setting(),function(e){e=p.Widgets.getWidgetFormControlForWidget(e);e&&t.push(e)}),0===t.length||1===p.Widgets.registeredSidebars.length&&t.length<=1?this.container.find(".reorder-toggle").hide():(this.container.find(".reorder-toggle").show(),h(t).each(function(){h(this.container).removeClass("first-widget").removeClass("last-widget").find(".move-widget-down, .move-widget-up").prop("tabIndex",0)}),_.first(t).container.addClass("first-widget").find(".move-widget-up").prop("tabIndex",-1),_.last(t).container.addClass("last-widget").find(".move-widget-down").prop("tabIndex",-1))},toggleReordering:function(e){var t=this.$sectionContent.find(".add-new-widget"),i=this.container.find(".reorder-toggle"),n=this.$sectionContent.find(".widget-title");(e=Boolean(e))!==this.$sectionContent.hasClass("reordering")&&(this.isReordering=e,this.$sectionContent.toggleClass("reordering",e),e?(_(this.getWidgetFormControls()).each(function(e){e.collapse()}),t.attr({tabindex:"-1","aria-hidden":"true"}),i.attr("aria-label",f.reorderLabelOff),u.a11y.speak(f.reorderModeOn),n.attr("aria-hidden","true")):(t.removeAttr("tabindex aria-hidden"),i.attr("aria-label",f.reorderLabelOn),u.a11y.speak(f.reorderModeOff),n.attr("aria-hidden","false")))},getWidgetFormControls:function(){var t=[];return _(this.setting()).each(function(e){e=function(e){var t,e=c(e);t="widget_"+e.id_base,e.number&&(t+="["+e.number+"]");return t}(e),e=p.control(e);e&&t.push(e)}),t},addWidget:function(n){var e,t,i,s,d,a=this,o="widget_form",r=c(n),l=r.number,r=r.id_base,r=p.Widgets.availableWidgets.findWhere({id_base:r});return!(!r||l&&!r.get("is_multi"))&&(r.get("is_multi")&&!l&&(r.set("multi_number",r.get("multi_number")+1),l=r.get("multi_number")),e=h("#widget-tpl-"+r.get("id")).html().trim(),r.get("is_multi")?e=e.replace(/<[^<>]+>/g,function(e){return e.replace(/__i__|%i%/g,l)}):r.set("is_disabled",!0),e=h(e),(e=h("<li/>").addClass("customize-control").addClass("customize-control-"+o).append(e)).find("> .widget-icon").remove(),r.get("is_multi")&&(e.find('input[name="widget_number"]').val(l),e.find('input[name="multi_number"]').val(l)),n=e.find('[name="widget-id"]').val(),e.hide(),t="widget_"+r.get("id_base"),r.get("is_multi")&&(t+="["+l+"]"),e.attr("id","customize-control-"+t.replace(/\]/g,"").replace(/\[/g,"-")),(i=p.has(t))||(d={transport:p.Widgets.data.selectiveRefreshableWidgets[r.get("id_base")]?"postMessage":"refresh",previewer:this.setting.previewer},p.create(t,t,"",d).set({})),d=p.controlConstructor[o],s=new d(t,{settings:{default:t},content:e,sidebar_id:a.params.sidebar_id,widget_id:n,widget_id_base:r.get("id_base"),type:o,is_new:!i,width:r.get("width"),height:r.get("height"),is_wide:r.get("is_wide")}),p.control.add(s),p.each(function(e){var t,i;e.id!==a.setting.id&&0===e.id.indexOf("sidebars_widgets[")&&(t=e().slice(),-1!==(i=_.indexOf(t,n)))&&(t.splice(i),e(t))}),d=this.setting().slice(),-1===_.indexOf(d,n)&&(d.push(n),this.setting(d)),e.slideDown(function(){i&&s.updateWidget({instance:s.setting()})}),s)}}),h.extend(p.panelConstructor,{widgets:p.Widgets.WidgetsPanel}),h.extend(p.sectionConstructor,{sidebar:p.Widgets.SidebarSection}),h.extend(p.controlConstructor,{widget_form:p.Widgets.WidgetControl,sidebar_widgets:p.Widgets.SidebarControl}),p.bind("ready",function(){p.Widgets.availableWidgetsPanel=new p.Widgets.AvailableWidgetsPanelView({collection:p.Widgets.availableWidgets}),p.previewer.bind("highlight-widget-control",p.Widgets.highlightWidgetFormControl),p.previewer.bind("focus-widget-control",p.Widgets.focusWidgetFormControl)}),p.Widgets.highlightWidgetFormControl=function(e){e=p.Widgets.getWidgetFormControlForWidget(e);e&&e.highlightSectionAndControl()},p.Widgets.focusWidgetFormControl=function(e){e=p.Widgets.getWidgetFormControlForWidget(e);e&&e.focus()},p.Widgets.getSidebarWidgetControlContainingWidget=function(t){var i=null;return p.control.each(function(e){"sidebar_widgets"===e.params.type&&-1!==_.indexOf(e.setting(),t)&&(i=e)}),i},p.Widgets.getWidgetFormControlForWidget=function(t){var i=null;return p.control.each(function(e){"widget_form"===e.params.type&&e.params.widget_id===t&&(i=e)}),i},h(document).on("widget-added",function(e,t){var s,d,i,n=c(t.find("> .widget-inside > .form > .widget-id").val());"nav_menu"===n.id_base&&(s=p.control("widget_nav_menu["+String(n.number)+"]"))&&(d=t.find('select[name*="nav_menu"]'),i=t.find(".edit-selected-nav-menu > button"),0!==d.length)&&0!==i.length&&(d.on("change",function(){p.section.has("nav_menu["+d.val()+"]")?i.parent().show():i.parent().hide()}),i.on("click",function(){var i,n,e=p.section("nav_menu["+d.val()+"]");e&&(n=s,(i=e).focus(),i.expanded.bind(function e(t){t||(i.expanded.unbind(e),n.focus())}))}))}))}(window.wp,jQuery);
\ No newline at end of file +!function(u,h){var p,f;function c(e){var t={number:null,id_base:null},i=e.match(/^(.+)-(\d+)$/);return i?(t.id_base=i[1],t.number=parseInt(i[2],10)):t.id_base=e,t}u&&u.customize&&((p=u.customize).Widgets=p.Widgets||{},p.Widgets.savedWidgetIds={},p.Widgets.data=_wpCustomizeWidgetsSettings||{},f=p.Widgets.data.l10n,p.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:null,params:[],width:null,height:null,search_matched:!0}),p.Widgets.WidgetCollection=Backbone.Collection.extend({model:p.Widgets.WidgetModel,doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms)&&this.each(function(e){e.set("search_matched",!0)})},search:function(e){var t,i;e=(e=e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),t=new RegExp("^(?=.*"+e+").+","i"),this.each(function(e){i=[e.get("name"),e.get("description")].join(" "),e.set("search_matched",t.test(i))})}}),p.Widgets.availableWidgets=new p.Widgets.WidgetCollection(p.Widgets.data.availableWidgets),p.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}),p.Widgets.SidebarCollection=Backbone.Collection.extend({model:p.Widgets.SidebarModel}),p.Widgets.registeredSidebars=new p.Widgets.SidebarCollection(p.Widgets.data.registeredSidebars),p.Widgets.AvailableWidgetsPanelView=u.Backbone.View.extend({el:"#available-widgets",events:{"input #widgets-search":"search","focus .widget-tpl":"focus","click .widget-tpl":"_submit","keypress .widget-tpl":"_submit",keydown:"keyboardAccessible"},selected:null,currentSidebarControl:null,$search:null,$clearResults:null,searchMatchesCount:null,initialize:function(){var t=this;this.$search=h("#widgets-search"),this.$clearResults=this.$el.find(".clear-results"),_.bindAll(this,"close"),this.listenTo(this.collection,"change",this.updateList),this.updateList(),this.searchMatchesCount=this.collection.length,h("#customize-controls, #available-widgets .customize-section-title").on("click keydown",function(e){e=h(e.target).is(".add-new-widget, .add-new-widget *");h("body").hasClass("adding-widget")&&!e&&t.close()}),this.$clearResults.on("click",function(){t.$search.val("").trigger("focus").trigger("input")}),p.previewer.bind("url",this.close)},search:_.debounce(function(e){var t;this.collection.doSearch(e.target.value),this.updateSearchMatchesCount(),this.announceSearchMatches(),this.selected&&!this.selected.is(":visible")&&(this.selected.removeClass("selected"),this.selected=null),this.selected&&!e.target.value&&(this.selected.removeClass("selected"),this.selected=null),!this.selected&&e.target.value&&(t=this.$el.find("> .widget-tpl:visible:first")).length&&this.select(t),""!==e.target.value?this.$clearResults.addClass("is-visible"):""===e.target.value&&this.$clearResults.removeClass("is-visible"),this.searchMatchesCount?this.$el.removeClass("no-widgets-found"):this.$el.addClass("no-widgets-found")},500),updateSearchMatchesCount:function(){this.searchMatchesCount=this.collection.where({search_matched:!0}).length},announceSearchMatches:function(){var e=f.widgetsFound.replace("%d",this.searchMatchesCount);this.searchMatchesCount||(e=f.noWidgetsFound),u.a11y.speak(e)},updateList:function(){this.collection.each(function(e){var t=h("#widget-tpl-"+e.id);t.toggle(e.get("search_matched")&&!e.get("is_disabled")),e.get("is_disabled")&&t.is(this.selected)&&(this.selected=null)})},select:function(e){this.selected=h(e),this.selected.siblings(".widget-tpl").removeClass("selected"),this.selected.addClass("selected")},focus:function(e){this.select(h(e.currentTarget))},_submit:function(e){"keypress"===e.type&&13!==e.which&&32!==e.which||this.submit(h(e.currentTarget))},submit:function(e){(e=e||this.selected)&&this.currentSidebarControl&&(this.select(e),e=h(this.selected).data("widget-id"),e=this.collection.findWhere({id:e}))&&((e=this.currentSidebarControl.addWidget(e.get("id_base")))&&e.focus(),this.close())},open:function(e){this.currentSidebarControl=e,_(this.currentSidebarControl.getWidgetFormControls()).each(function(e){e.params.is_wide&&e.collapseForm()}),p.section.has("publish_settings")&&p.section("publish_settings").collapse(),h("body").addClass("adding-widget"),this.$el.find(".selected").removeClass("selected"),this.collection.doSearch(""),p.settings.browser.mobile||this.$search.trigger("focus")},close:function(e){(e=e||{}).returnFocus&&this.currentSidebarControl&&this.currentSidebarControl.container.find(".add-new-widget").focus(),this.currentSidebarControl=null,this.selected=null,h("body").removeClass("adding-widget"),this.$search.val("").trigger("input")},keyboardAccessible:function(e){var t=13===e.which,i=27===e.which,n=40===e.which,s=38===e.which,d=9===e.which,a=e.shiftKey,o=null,r=this.$el.find("> .widget-tpl:visible:first"),l=this.$el.find("> .widget-tpl:visible:last"),c=h(e.target).is(this.$search),g=h(e.target).is(".widget-tpl:visible:last");n||s?(n?c?o=r:this.selected&&0!==this.selected.nextAll(".widget-tpl:visible").length&&(o=this.selected.nextAll(".widget-tpl:visible:first")):s&&(c?o=l:this.selected&&0!==this.selected.prevAll(".widget-tpl:visible").length&&(o=this.selected.prevAll(".widget-tpl:visible:first"))),this.select(o),(o||this.$search).trigger("focus")):t&&!this.$search.val()||(t?this.submit():i&&this.close({returnFocus:!0}),this.currentSidebarControl&&d&&(a&&c||!a&&g)&&(this.currentSidebarControl.container.find(".add-new-widget").focus(),e.preventDefault()))}}),p.Widgets.formSyncHandlers={rss:function(e,t,i){var n=t.find(".widget-error:first"),i=h("<div>"+i+"</div>").find(".widget-error:first");n.length&&i.length?n.replaceWith(i):n.length?n.remove():i.length&&t.find(".widget-content:first").prepend(i)}},p.Widgets.WidgetControl=p.Control.extend({defaultExpandedArguments:{duration:"fast",completeCallback:h.noop},initialize:function(e,t){var i=this;i.widgetControlEmbedded=!1,i.widgetContentEmbedded=!1,i.expanded=new p.Value(!1),i.expandedArgumentsQueue=[],i.expanded.bind(function(e){var t=i.expandedArgumentsQueue.shift(),t=h.extend({},i.defaultExpandedArguments,t);i.onChangeExpanded(e,t)}),i.altNotice=!0,p.Control.prototype.initialize.call(i,e,t)},ready:function(){var n=this;n.section()?p.section(n.section(),function(t){function i(e){e&&(n.embedWidgetControl(),t.expanded.unbind(i))}t.expanded()?i(!0):t.expanded.bind(i)}):n.embedWidgetControl()},embedWidgetControl:function(){var e,t=this;t.widgetControlEmbedded||(t.widgetControlEmbedded=!0,e=h(t.params.widget_control),t.container.append(e),t._setupModel(),t._setupWideWidget(),t._setupControlToggle(),t._setupWidgetTitle(),t._setupReorderUI(),t._setupHighlightEffects(),t._setupUpdateUI(),t._setupRemoveUI())},embedWidgetContent:function(){var e,t=this;t.embedWidgetControl(),t.widgetContentEmbedded||(t.widgetContentEmbedded=!0,t.notifications.container=t.getNotificationsContainerElement(),t.notifications.render(),e=h(t.params.widget_content),t.container.find(".widget-content:first").append(e),h(document).trigger("widget-added",[t.container.find(".widget:first")]))},_setupModel:function(){var i=this,e=function(){p.Widgets.savedWidgetIds[i.params.widget_id]=!0};p.bind("ready",e),p.bind("saved",e),this._updateCount=0,this.isWidgetUpdating=!1,this.liveUpdateMode=!0,this.setting.bind(function(e,t){_(t).isEqual(e)||i.isWidgetUpdating||i.updateWidget({instance:e})})},_setupWideWidget:function(){var n,s,e,t,i,d=this;!this.params.is_wide||h(window).width()<=640||(n=this.container.find(".widget-inside"),s=n.find("> .form"),e=h(".wp-full-overlay-sidebar-content:first"),this.container.addClass("wide-widget-control"),this.container.find(".form:first").css({"max-width":this.params.width,"min-height":this.params.height}),i=function(){var e=d.container.offset().top,t=h(window).height(),i=s.outerHeight();n.css("max-height",t),e=Math.max(0,Math.min(Math.max(e,0),t-i)),n.css("top",e)},t=h("#customize-theme-controls"),this.container.on("expand",function(){i(),e.on("scroll",i),h(window).on("resize",i),t.on("expanded collapsed",i)}),this.container.on("collapsed",function(){e.off("scroll",i),h(window).off("resize",i),t.off("expanded collapsed",i)}),p.each(function(e){0===e.id.indexOf("sidebars_widgets[")&&e.bind(function(){d.container.hasClass("expanded")&&i()})}))},_setupControlToggle:function(){var t=this;this.container.find(".widget-top").on("click",function(e){e.preventDefault(),t.getSidebarWidgetsControl().isReordering||t.expanded(!t.expanded())}),this.container.find(".widget-control-close").on("click",function(){t.collapse(),t.container.find(".widget-top .widget-action:first").focus()})},_setupWidgetTitle:function(){var i=this,e=function(){var e=i.setting().title,t=i.container.find(".in-widget-title");e?t.text(": "+e):t.text("")};this.setting.bind(e),e()},_setupReorderUI:function(){var t,e,d=this,s=function(e){e.siblings(".selected").removeClass("selected"),e.addClass("selected");e=e.data("id")===d.params.sidebar_id;d.container.find(".move-widget-btn").prop("disabled",e)};this.container.find(".widget-title-action").after(h(p.Widgets.data.tpl.widgetReorderNav)),e=_.template(p.Widgets.data.tpl.moveWidgetArea),t=h(e({sidebars:_(p.Widgets.registeredSidebars.toArray()).pluck("attributes")})),this.container.find(".widget-top").after(t),(e=function(){var e=t.find("li"),i=0,n=e.filter(function(){return h(this).data("id")===d.params.sidebar_id});e.each(function(){var e=h(this),t=e.data("id"),t=p.Widgets.registeredSidebars.get(t).get("is_rendered");e.toggle(t),t&&(i+=1),e.hasClass("selected")&&!t&&s(n)}),1<i?d.container.find(".move-widget").show():d.container.find(".move-widget").hide()})(),p.Widgets.registeredSidebars.on("change:is_rendered",e),this.container.find(".widget-reorder-nav").find(".move-widget, .move-widget-down, .move-widget-up").each(function(){h(this).prepend(d.container.find(".widget-title").text()+": ")}).on("click keypress",function(e){var t,i;"keypress"===e.type&&13!==e.which&&32!==e.which||(h(this).trigger("focus"),h(this).is(".move-widget")?d.toggleWidgetMoveArea():(e=h(this).is(".move-widget-down"),t=h(this).is(".move-widget-up"),i=d.getWidgetSidebarPosition(),t&&0===i||e&&i===d.getSidebarWidgetsControl().setting().length-1||(t?(d.moveUp(),u.a11y.speak(f.widgetMovedUp)):(d.moveDown(),u.a11y.speak(f.widgetMovedDown)),h(this).trigger("focus"))))}),this.container.find(".widget-area-select").on("click keypress","li",function(e){"keypress"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),s(h(this)))}),this.container.find(".move-widget-btn").click(function(){d.getSidebarWidgetsControl().toggleReordering(!1);var e=d.params.sidebar_id,t=d.container.find(".widget-area-select li.selected").data("id"),e=p("sidebars_widgets["+e+"]"),t=p("sidebars_widgets["+t+"]"),i=Array.prototype.slice.call(e()),n=Array.prototype.slice.call(t()),s=d.getWidgetSidebarPosition();i.splice(s,1),n.push(d.params.widget_id),e(i),t(n),d.focus()})},_setupHighlightEffects:function(){var e=this;this.container.on("mouseenter click",function(){e.setting.previewer.send("highlight-widget",e.params.widget_id)}),this.setting.bind(function(){e.setting.previewer.send("highlight-widget",e.params.widget_id)})},_setupUpdateUI:function(){var t,i,n=this,s=this.container.find(".widget:first"),e=s.find(".widget-content:first"),d=this.container.find(".widget-control-save");d.val(f.saveBtnLabel),d.attr("title",f.saveBtnTooltip),d.removeClass("button-primary"),d.on("click",function(e){e.preventDefault(),n.updateWidget({disable_form:!0})}),t=_.debounce(function(){n.updateWidget()},250),e.on("keydown","input",function(e){13===e.which&&(e.preventDefault(),n.updateWidget({ignoreActiveElement:!0}))}),e.on("change input propertychange",":input",function(e){n.liveUpdateMode&&("change"===e.type||this.checkValidity&&this.checkValidity())&&t()}),this.setting.previewer.channel.bind("synced",function(){n.container.removeClass("previewer-loading")}),p.previewer.bind("widget-updated",function(e){e===n.params.widget_id&&n.container.removeClass("previewer-loading")}),(i=p.Widgets.formSyncHandlers[this.params.widget_id_base])&&h(document).on("widget-synced",function(e,t){s.is(t)&&i.apply(document,arguments)})},onChangeActive:function(e,t){this.container.toggleClass("widget-rendered",e),t.completeCallback&&t.completeCallback()},_setupRemoveUI:function(){var e,s=this,t=this.container.find(".widget-control-remove");t.on("click",function(){var n=s.container.next().is(".customize-control-widget_form")?s.container.next().find(".widget-action:first"):s.container.prev().is(".customize-control-widget_form")?s.container.prev().find(".widget-action:first"):s.container.next(".customize-control-sidebar_widgets").find(".add-new-widget:first");s.container.slideUp(function(){var e,t,i=p.Widgets.getSidebarWidgetControlContainingWidget(s.params.widget_id);i&&(e=i.setting().slice(),-1!==(t=_.indexOf(e,s.params.widget_id)))&&(e.splice(t,1),i.setting(e),n.focus())})}),e=function(){t.text(f.removeBtnLabel),t.attr("title",f.removeBtnTooltip)},this.params.is_new?p.bind("saved",e):e()},_getInputs:function(e){return h(e).find(":input[name]")},_getInputsSignature:function(e){return _(e).map(function(e){e=h(e),e=e.is(":checkbox, :radio")?[e.attr("id"),e.attr("name"),e.prop("value")]:[e.attr("id"),e.attr("name")];return e.join(",")}).join(";")},_getInputState:function(e){return(e=h(e)).is(":radio, :checkbox")?e.prop("checked"):e.is("select[multiple]")?e.find("option:selected").map(function(){return h(this).val()}).get():e.val()},_setInputState:function(e,t){(e=h(e)).is(":radio, :checkbox")?e.prop("checked",t):e.is("select[multiple]")?(t=Array.isArray(t)?_.map(t,function(e){return String(e)}):[],e.find("option").each(function(){h(this).prop("selected",-1!==_.indexOf(t,String(this.value)))})):e.val(t)},getSidebarWidgetsControl:function(){var e="sidebars_widgets["+this.params.sidebar_id+"]",e=p.control(e);if(e)return e},updateWidget:function(s){var d,a,o,r,e,l,t,i,c,g=this;g.embedWidgetContent(),i=(s=h.extend({instance:null,complete:null,ignoreActiveElement:!1},s)).instance,d=s.complete,this._updateCount+=1,r=this._updateCount,a=this.container.find(".widget:first"),(o=a.find(".widget-content:first")).find(".widget-error").remove(),this.container.addClass("widget-form-loading"),this.container.addClass("previewer-loading"),(t=p.state("processing"))(t()+1),this.liveUpdateMode||this.container.addClass("widget-form-disabled"),(e={action:"update-widget",wp_customize:"on"}).nonce=p.settings.nonce["update-widget"],e.customize_theme=p.settings.theme.stylesheet,e.customized=u.customize.previewer.query().customized,e=h.param(e),(l=this._getInputs(o)).each(function(){h(this).data("state"+r,g._getInputState(this))}),e=(e+=i?"&"+h.param({sanitized_widget_setting:JSON.stringify(i)}):"&"+l.serialize())+"&"+o.find("~ :input").serialize(),this._previousUpdateRequest&&this._previousUpdateRequest.abort(),i=h.post(u.ajax.settings.url,e),(this._previousUpdateRequest=i).done(function(e){var n,t,i=!1;"0"===e?(p.previewer.preview.iframe.hide(),p.previewer.login().done(function(){g.updateWidget(s),p.previewer.preview.iframe.show()})):"-1"===e?p.previewer.cheatin():e.success?(t=h("<div>"+e.data.form+"</div>"),n=g._getInputs(t),(t=g._getInputsSignature(l)===g._getInputsSignature(n))&&!g.liveUpdateMode&&(g.liveUpdateMode=!0,g.container.removeClass("widget-form-disabled"),g.container.find('input[name="savewidget"]').hide()),t&&g.liveUpdateMode?(l.each(function(e){var t=h(this),e=h(n[e]),i=t.data("state"+r),e=g._getInputState(e);t.data("sanitized",e),_.isEqual(i,e)||!s.ignoreActiveElement&&t.is(document.activeElement)||g._setInputState(t,e)}),h(document).trigger("widget-synced",[a,e.data.form])):g.liveUpdateMode?(g.liveUpdateMode=!1,g.container.find('input[name="savewidget"]').show(),i=!0):(o.html(e.data.form),g.container.removeClass("widget-form-disabled"),h(document).trigger("widget-updated",[a])),(c=!i&&!_(g.setting()).isEqual(e.data.instance))?(g.isWidgetUpdating=!0,g.setting(e.data.instance),g.isWidgetUpdating=!1):g.container.removeClass("previewer-loading"),d&&d.call(g,null,{noChange:!c,ajaxFinished:!0})):(t=f.error,e.data&&e.data.message&&(t=e.data.message),d?d.call(g,t):o.prepend('<p class="widget-error"><strong>'+t+"</strong></p>"))}),i.fail(function(e,t){d&&d.call(g,t)}),i.always(function(){g.container.removeClass("widget-form-loading"),l.each(function(){h(this).removeData("state"+r)}),t(t()-1)})},expandControlSection:function(){p.Control.prototype.expand.call(this)},_toggleExpanded:p.Section.prototype._toggleExpanded,expand:p.Section.prototype.expand,expandForm:function(){this.expand()},collapse:p.Section.prototype.collapse,collapseForm:function(){this.collapse()},toggleForm:function(e){void 0===e&&(e=!this.expanded()),this.expanded(e)},onChangeExpanded:function(e,t){var i,n,s,d,a,o=this;o.embedWidgetControl(),e&&o.embedWidgetContent(),t.unchanged?e&&p.Control.prototype.expand.call(o,{completeCallback:t.completeCallback}):(i=this.container.find("div.widget:first"),n=i.find(".widget-inside:first"),e=function(){p.control.each(function(e){o.params.type===e.params.type&&o!==e&&e.collapse()}),s=function(){o.container.removeClass("expanding"),o.container.addClass("expanded"),i.addClass("open"),a.attr("aria-expanded","true"),o.container.trigger("expanded")},t.completeCallback&&(d=s,s=function(){d(),t.completeCallback()}),o.params.is_wide?n.fadeIn(t.duration,s):n.slideDown(t.duration,s),o.container.trigger("expand"),o.container.addClass("expanding")},"false"===(a=this.container.find(".widget-top button.widget-action")).attr("aria-expanded")?p.section.has(o.section())?p.section(o.section()).expand({completeCallback:e}):e():(s=function(){o.container.removeClass("collapsing"),o.container.removeClass("expanded"),i.removeClass("open"),a.attr("aria-expanded","false"),o.container.trigger("collapsed")},t.completeCallback&&(d=s,s=function(){d(),t.completeCallback()}),o.container.trigger("collapse"),o.container.addClass("collapsing"),o.params.is_wide?n.fadeOut(t.duration,s):n.slideUp(t.duration,function(){i.css({width:"",margin:""}),s()})))},getWidgetSidebarPosition:function(){var e=this.getSidebarWidgetsControl().setting(),e=_.indexOf(e,this.params.widget_id);if(-1!==e)return e},moveUp:function(){this._moveWidgetByOne(-1)},moveDown:function(){this._moveWidgetByOne(1)},_moveWidgetByOne:function(e){var t=this.getWidgetSidebarPosition(),i=this.getSidebarWidgetsControl().setting,n=Array.prototype.slice.call(i()),s=n[t+e];n[t+e]=this.params.widget_id,n[t]=s,i(n)},toggleWidgetMoveArea:function(e){var t=this,i=this.container.find(".move-widget-area");(e=void 0===e?!i.hasClass("active"):e)&&(i.find(".selected").removeClass("selected"),i.find("li").filter(function(){return h(this).data("id")===t.params.sidebar_id}).addClass("selected"),this.container.find(".move-widget-btn").prop("disabled",!0)),i.toggleClass("active",e)},highlightSectionAndControl:function(){var e=this.container.is(":hidden")?this.container.closest(".control-section"):this.container;h(".highlighted").removeClass("highlighted"),e.addClass("highlighted"),setTimeout(function(){e.removeClass("highlighted")},500)}}),p.Widgets.WidgetsPanel=p.Panel.extend({ready:function(){var d=this;p.Panel.prototype.ready.call(d),d.deferred.embedded.done(function(){var t,i,n,e=d.container.find(".panel-meta"),s=h("<div></div>",{class:"no-widget-areas-rendered-notice",role:"alert"});e.append(s),i=function(){return _.filter(d.sections(),function(e){return"sidebar"===e.params.type&&e.active()}).length},n=function(){var e=i();return 0===e||e!==p.Widgets.data.registeredSidebars.length},(t=function(){var e,t=i();s.empty(),t!==(e=p.Widgets.data.registeredSidebars.length)&&((e=0!==t?f.someAreasShown[e-t]:f.noAreasShown)&&s.append(h("<p></p>",{text:e})),s.append(h("<p></p>",{text:f.navigatePreview})))})(),s.toggle(n()),p.previewer.deferred.active.done(function(){s.toggle(n())}),p.bind("pane-contents-reflowed",function(){var e="resolved"===p.previewer.deferred.active.state()?"fast":0;t(),n()?s.slideDown(e):s.slideUp(e)})})},isContextuallyActive:function(){return this.active()}}),p.Widgets.SidebarSection=p.Section.extend({ready:function(){var t;p.Section.prototype.ready.call(this),t=p.Widgets.registeredSidebars.get(this.params.sidebarId),this.active.bind(function(e){t.set("is_rendered",e)}),t.set("is_rendered",this.active())}}),p.Widgets.SidebarControl=p.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 s=this;this.setting.bind(function(i,e){var t,n,e=_(e).difference(i);i=_(i).filter(function(e){e=c(e);return!!p.Widgets.availableWidgets.findWhere({id_base:e.id_base})}),(t=_(i).map(function(e){return p.Widgets.getWidgetFormControlForWidget(e)||s.addWidget(e)})).sort(function(e,t){return _.indexOf(i,e.params.widget_id)-_.indexOf(i,t.params.widget_id)}),n=0,_(t).each(function(e){e.priority(n),e.section(s.section()),n+=1}),s.priority(n),s._applyCardinalOrderClassNames(),_(t).each(function(e){e.params.sidebar_id=s.params.sidebar_id}),_(e).each(function(n){setTimeout(function(){var e,t,i=!1;p.each(function(e){e.id!==s.setting.id&&0===e.id.indexOf("sidebars_widgets[")&&"sidebars_widgets[wp_inactive_widgets]"!==e.id&&(e=e(),-1!==_.indexOf(e,n))&&(i=!0)}),i||(t=(e=p.Widgets.getWidgetFormControlForWidget(n))&&h.contains(document,e.container[0])&&!h.contains(s.$sectionContent[0],e.container[0]),e&&!t&&(p.control.remove(e.id),e.container.remove()),p.Widgets.savedWidgetIds[n]&&((t=p.value("sidebars_widgets[wp_inactive_widgets]")().slice()).push(n),p.value("sidebars_widgets[wp_inactive_widgets]")(_(t).unique())),e=c(n).id_base,(t=p.Widgets.availableWidgets.findWhere({id_base:e}))&&!t.get("is_multi")&&t.set("is_disabled",!1))})})})},_setupSortable:function(){var t=this;this.isReordering=!1,this.$sectionContent.sortable({items:"> .customize-control-widget_form",handle:".widget-top",axis:"y",tolerance:"pointer",connectWith:".accordion-section-content:has(.customize-control-sidebar_widgets)",update:function(){var e=t.$sectionContent.sortable("toArray"),e=h.map(e,function(e){return h("#"+e).find(":input[name=widget-id]").val()});t.setting(e)}}),this.$controlSection.find(".accordion-section-title").droppable({accept:".customize-control-widget_form",over:function(){p.section(t.section.get()).expand({allowMultiple:!0,completeCallback:function(){p.section.each(function(e){e.container.find(".customize-control-sidebar_widgets").length&&e.container.find(".accordion-section-content:first").sortable("refreshPositions")})}})}}),this.container.find(".reorder-toggle").on("click",function(){t.toggleReordering(!t.isReordering)})},_setupAddition:function(){var t=this;this.container.find(".add-new-widget").on("click",function(){var e=h(this);t.$sectionContent.hasClass("reordering")||(h("body").hasClass("adding-widget")?(e.attr("aria-expanded","false"),p.Widgets.availableWidgetsPanel.close()):(e.attr("aria-expanded","true"),p.Widgets.availableWidgetsPanel.open(t)))})},_applyCardinalOrderClassNames:function(){var t=[];_.each(this.setting(),function(e){e=p.Widgets.getWidgetFormControlForWidget(e);e&&t.push(e)}),0===t.length||1===p.Widgets.registeredSidebars.length&&t.length<=1?this.container.find(".reorder-toggle").hide():(this.container.find(".reorder-toggle").show(),h(t).each(function(){h(this.container).removeClass("first-widget").removeClass("last-widget").find(".move-widget-down, .move-widget-up").prop("tabIndex",0)}),_.first(t).container.addClass("first-widget").find(".move-widget-up").prop("tabIndex",-1),_.last(t).container.addClass("last-widget").find(".move-widget-down").prop("tabIndex",-1))},toggleReordering:function(e){var t=this.$sectionContent.find(".add-new-widget"),i=this.container.find(".reorder-toggle"),n=this.$sectionContent.find(".widget-title");(e=Boolean(e))!==this.$sectionContent.hasClass("reordering")&&(this.isReordering=e,this.$sectionContent.toggleClass("reordering",e),e?(_(this.getWidgetFormControls()).each(function(e){e.collapse()}),t.attr({tabindex:"-1","aria-hidden":"true"}),i.attr("aria-label",f.reorderLabelOff),u.a11y.speak(f.reorderModeOn),n.attr("aria-hidden","true")):(t.removeAttr("tabindex aria-hidden"),i.attr("aria-label",f.reorderLabelOn),u.a11y.speak(f.reorderModeOff),n.attr("aria-hidden","false")))},getWidgetFormControls:function(){var t=[];return _(this.setting()).each(function(e){e=function(e){var t,e=c(e);t="widget_"+e.id_base,e.number&&(t+="["+e.number+"]");return t}(e),e=p.control(e);e&&t.push(e)}),t},addWidget:function(n){var e,t,i,s,d,a=this,o="widget_form",r=c(n),l=r.number,r=r.id_base,r=p.Widgets.availableWidgets.findWhere({id_base:r});return!(!r||l&&!r.get("is_multi"))&&(r.get("is_multi")&&!l&&(r.set("multi_number",r.get("multi_number")+1),l=r.get("multi_number")),e=h("#widget-tpl-"+r.get("id")).html().trim(),r.get("is_multi")?e=e.replace(/<[^<>]+>/g,function(e){return e.replace(/__i__|%i%/g,l)}):r.set("is_disabled",!0),e=h(e),(e=h("<li/>").addClass("customize-control").addClass("customize-control-"+o).append(e)).find("> .widget-icon").remove(),r.get("is_multi")&&(e.find('input[name="widget_number"]').val(l),e.find('input[name="multi_number"]').val(l)),n=e.find('[name="widget-id"]').val(),e.hide(),t="widget_"+r.get("id_base"),r.get("is_multi")&&(t+="["+l+"]"),e.attr("id","customize-control-"+t.replace(/\]/g,"").replace(/\[/g,"-")),(i=p.has(t))||(d={transport:p.Widgets.data.selectiveRefreshableWidgets[r.get("id_base")]?"postMessage":"refresh",previewer:this.setting.previewer},p.create(t,t,"",d).set({})),d=p.controlConstructor[o],s=new d(t,{settings:{default:t},content:e,sidebar_id:a.params.sidebar_id,widget_id:n,widget_id_base:r.get("id_base"),type:o,is_new:!i,width:r.get("width"),height:r.get("height"),is_wide:r.get("is_wide")}),p.control.add(s),p.each(function(e){var t,i;e.id!==a.setting.id&&0===e.id.indexOf("sidebars_widgets[")&&(t=e().slice(),-1!==(i=_.indexOf(t,n)))&&(t.splice(i),e(t))}),d=this.setting().slice(),-1===_.indexOf(d,n)&&(d.push(n),this.setting(d)),e.slideDown(function(){i&&s.updateWidget({instance:s.setting()})}),s)}}),h.extend(p.panelConstructor,{widgets:p.Widgets.WidgetsPanel}),h.extend(p.sectionConstructor,{sidebar:p.Widgets.SidebarSection}),h.extend(p.controlConstructor,{widget_form:p.Widgets.WidgetControl,sidebar_widgets:p.Widgets.SidebarControl}),p.bind("ready",function(){p.Widgets.availableWidgetsPanel=new p.Widgets.AvailableWidgetsPanelView({collection:p.Widgets.availableWidgets}),p.previewer.bind("highlight-widget-control",p.Widgets.highlightWidgetFormControl),p.previewer.bind("focus-widget-control",p.Widgets.focusWidgetFormControl)}),p.Widgets.highlightWidgetFormControl=function(e){e=p.Widgets.getWidgetFormControlForWidget(e);e&&e.highlightSectionAndControl()},p.Widgets.focusWidgetFormControl=function(e){e=p.Widgets.getWidgetFormControlForWidget(e);e&&e.focus()},p.Widgets.getSidebarWidgetControlContainingWidget=function(t){var i=null;return p.control.each(function(e){"sidebar_widgets"===e.params.type&&-1!==_.indexOf(e.setting(),t)&&(i=e)}),i},p.Widgets.getWidgetFormControlForWidget=function(t){var i=null;return p.control.each(function(e){"widget_form"===e.params.type&&e.params.widget_id===t&&(i=e)}),i},h(document).on("widget-added",function(e,t){var s,d,i,n=c(t.find("> .widget-inside > .form > .widget-id").val());"nav_menu"===n.id_base&&(s=p.control("widget_nav_menu["+String(n.number)+"]"))&&(d=t.find('select[name*="nav_menu"]'),i=t.find(".edit-selected-nav-menu > button"),0!==d.length)&&0!==i.length&&(d.on("change",function(){p.section.has("nav_menu["+d.val()+"]")?i.parent().show():i.parent().hide()}),i.on("click",function(){var i,n,e=p.section("nav_menu["+d.val()+"]");e&&(n=s,(i=e).focus(),i.expanded.bind(function e(t){t||(i.expanded.unbind(e),n.focus())}))}))}))}(window.wp,jQuery);
\ No newline at end of file diff --git a/wp-admin/js/dashboard.js b/wp-admin/js/dashboard.js index 3354790..0115611 100644 --- a/wp-admin/js/dashboard.js +++ b/wp-admin/js/dashboard.js @@ -92,7 +92,7 @@ jQuery( function($) { setTimeout( function(){ // Request the widget content. p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function() { - // Hide the parent and slide it out for visual fancyness. + // Hide the parent and slide it out for visual fanciness. p.hide().slideDown('normal', function(){ $(this).css('display', ''); }); diff --git a/wp-admin/js/editor-expand.js b/wp-admin/js/editor-expand.js index a47c548..04b001e 100644 --- a/wp-admin/js/editor-expand.js +++ b/wp-admin/js/editor-expand.js @@ -1552,7 +1552,7 @@ // Bind and unbind based on the distraction free writing focus. $document.on( 'dfw-on.focus', mceBind ).on( 'dfw-off.focus', mceUnbind ); - // Focuse the editor when it is the target of the click event. + // Focus the editor when it is the target of the click event. editor.on( 'click', function( event ) { if ( event.target === editor.getDoc().documentElement ) { editor.focus(); diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js index d5fe958..2465af3 100644 --- a/wp-admin/js/editor.js +++ b/wp-admin/js/editor.js @@ -265,7 +265,7 @@ window.wp = window.wp || {}; } /** - * Gets a list of unique shortcodes or shortcode-look-alikes in the content. + * Gets a list of unique shortcodes or shortcode-lookalikes in the content. * * @param {string} content The content we want to scan for shortcodes. */ @@ -561,7 +561,7 @@ window.wp = window.wp || {}; * By default TinyMCE wraps loose inline tags in a `<p>`. * When removing selection markers an empty `<p>` may be left behind, remove it. * - * @param {Object} $marker The marker to be removed from the editor DOM, wrapped in an instnce of `editor.$` + * @param {Object} $marker The marker to be removed from the editor DOM, wrapped in an instance of `editor.$` */ function removeSelectionMarker( $marker ) { var $markerParent = $marker.parent(); diff --git a/wp-admin/js/nav-menu.js b/wp-admin/js/nav-menu.js index 9877f78..789c3b6 100644 --- a/wp-admin/js/nav-menu.js +++ b/wp-admin/js/nav-menu.js @@ -449,12 +449,13 @@ } var thisLink, thisLinkText, primaryItems, itemPosition, title, - parentItem, parentItemId, parentItemName, subItems, + parentItem, parentItemId, parentItemName, subItems, totalSubItems, $this = $( itemToRefresh ), menuItem = $this.closest( 'li.menu-item' ).first(), depth = menuItem.menuItemDepth(), isPrimaryMenuItem = ( 0 === depth ), itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), + menuItemType = $this.closest( '.menu-item-handle' ).find( '.item-controls' ).find( '.item-type' ).text(), position = parseInt( menuItem.index(), 10 ), prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1, 10 ), prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), @@ -503,18 +504,22 @@ primaryItems = $( '.menu-item-depth-0' ), itemPosition = primaryItems.index( menuItem ) + 1, totalMenuItems = primaryItems.length, - // String together help text for primary menu items. - title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); + title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$s', menuItemType ).replace( '%3$d', itemPosition ).replace( '%4$d', totalMenuItems ); } else { parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(), parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), parentItemName = parentItem.find( '.menu-item-title' ).text(), subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), + totalSubItems = subItems.length, itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; // String together help text for sub menu items. - title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName ); + if ( depth < 2 ) { + title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$s', menuItemType ).replace( '%3$d', itemPosition ).replace( '%4$d', totalSubItems ).replace( '%5$s', parentItemName ); + } else { + title = menus.subMenuMoreDepthFocus.replace( '%1$s', itemName ).replace( '%2$s', menuItemType ).replace( '%3$d', itemPosition ).replace( '%4$d', totalSubItems ).replace( '%5$s', parentItemName ).replace( '%6$d', depth ); + } } $this.attr( 'aria-label', title ); @@ -732,6 +737,7 @@ api.refreshKeyboardAccessibility(); api.refreshAdvancedAccessibility(); + api.refreshAdvancedAccessibilityOfItem( ui.item.find( 'a.item-edit' ) ); }, change: function(e, ui) { // Make sure the placeholder is inside the menu. diff --git a/wp-admin/js/nav-menu.min.js b/wp-admin/js/nav-menu.min.js index ce28b70..e644243 100644 --- a/wp-admin/js/nav-menu.min.js +++ b/wp-admin/js/nav-menu.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(k){var I=window.wpNavMenu={options:{menuItemDepthPerLevel:30,globalMaxDepth:11,sortableItems:"> *",targetTolerance:0},menuList:void 0,targetList:void 0,menusChanged:!1,isRTL:!("undefined"==typeof isRtl||!isRtl),negateIfRTL:"undefined"!=typeof isRtl&&isRtl?-1:1,lastSearch:"",init:function(){I.menuList=k("#menu-to-edit"),I.targetList=I.menuList,this.jQueryExtensions(),this.attachMenuEditListeners(),this.attachBulkSelectButtonListeners(),this.attachMenuCheckBoxListeners(),this.attachMenuItemDeleteButton(),this.attachPendingMenuItemsListForDeletion(),this.attachQuickSearchListeners(),this.attachThemeLocationsListeners(),this.attachMenuSaveSubmitListeners(),this.attachTabsPanelListeners(),this.attachUnsavedChangesListener(),I.menuList.length&&this.initSortables(),menus.oneThemeLocationNoMenus&&k("#posttype-page").addSelectedToMenu(I.addMenuItemToBottom),this.initManageLocations(),this.initAccessibility(),this.initToggles(),this.initPreviewing()},jQueryExtensions:function(){k.fn.extend({menuItemDepth:function(){var e=I.isRTL?this.eq(0).css("margin-right"):this.eq(0).css("margin-left");return I.pxToDepth(e&&-1!=e.indexOf("px")?e.slice(0,-2):0)},updateDepthClass:function(t,n){return this.each(function(){var e=k(this);n=n||e.menuItemDepth(),k(this).removeClass("menu-item-depth-"+n).addClass("menu-item-depth-"+t)})},shiftDepthClass:function(i){return this.each(function(){var e=k(this),t=e.menuItemDepth(),n=t+i;e.removeClass("menu-item-depth-"+t).addClass("menu-item-depth-"+n),0===n&&e.find(".is-submenu").hide()})},childMenuItems:function(){var i=k();return this.each(function(){for(var e=k(this),t=e.menuItemDepth(),n=e.next(".menu-item");n.length&&n.menuItemDepth()>t;)i=i.add(n),n=n.next(".menu-item")}),i},shiftHorizontally:function(n){return this.each(function(){var e=k(this),t=e.menuItemDepth();e.moveHorizontally(t+n,t)})},moveHorizontally:function(a,s){return this.each(function(){var e=k(this),t=e.childMenuItems(),n=a-s,i=e.find(".is-submenu");e.updateDepthClass(a,s).updateParentMenuItemDBId(),t&&t.each(function(){var e=k(this),t=e.menuItemDepth();e.updateDepthClass(t+n,t).updateParentMenuItemDBId()}),0===a?i.hide():i.show()})},updateParentMenuItemDBId:function(){return this.each(function(){var e=k(this),t=e.find(".menu-item-data-parent-id"),n=parseInt(e.menuItemDepth(),10),e=e.prevAll(".menu-item-depth-"+(n-1)).first();0===n?t.val(0):t.val(e.find(".menu-item-data-db-id").val())})},hideAdvancedMenuItemFields:function(){return this.each(function(){var e=k(this);k(".hide-column-tog").not(":checked").each(function(){e.find(".field-"+k(this).val()).addClass("hidden-field")})})},addSelectedToMenu:function(a){return 0!==k("#menu-to-edit").length&&this.each(function(){var e=k(this),n={},t=menus.oneThemeLocationNoMenus&&0===e.find(".tabs-panel-active .categorychecklist li input:checked").length?e.find('#page-all li input[type="checkbox"]'):e.find(".tabs-panel-active .categorychecklist li input:checked"),i=/menu-item\[([^\]]*)/;if(a=a||I.addMenuItemToBottom,!t.length)return!1;e.find(".button-controls .spinner").addClass("is-active"),k(t).each(function(){var e=k(this),t=i.exec(e.attr("name")),t=void 0===t[1]?0:parseInt(t[1],10);this.className&&-1!=this.className.indexOf("add-to-top")&&(a=I.addMenuItemToTop),n[t]=e.closest("li").getItemData("add-menu-item",t)}),I.addItemToMenu(n,a,function(){t.prop("checked",!1),e.find(".button-controls .select-all").prop("checked",!1),e.find(".button-controls .spinner").removeClass("is-active")})})},getItemData:function(t,n){t=t||"menu-item";var i,a={},s=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"];return(n=n||"menu-item"!=t?n:this.find(".menu-item-data-db-id").val())&&this.find("input").each(function(){var e;for(i=s.length;i--;)"menu-item"==t?e=s[i]+"["+n+"]":"add-menu-item"==t&&(e="menu-item["+n+"]["+s[i]+"]"),this.name&&e==this.name&&(a[s[i]]=this.value)}),a},setItemData:function(e,a,s){return a=a||"menu-item",(s=s||"menu-item"!=a?s:k(".menu-item-data-db-id",this).val())&&this.find("input").each(function(){var n,i=k(this);k.each(e,function(e,t){"menu-item"==a?n=e+"["+s+"]":"add-menu-item"==a&&(n="menu-item["+s+"]["+e+"]"),n==i.attr("name")&&i.val(t)})}),this}})},countMenuItems:function(e){return k(".menu-item-depth-"+e).length},moveMenuItem:function(e,t){var n,i,a=k("#menu-to-edit li"),s=a.length,m=e.parents("li.menu-item"),o=m.childMenuItems(),u=m.getItemData(),c=parseInt(m.menuItemDepth(),10),l=parseInt(m.index(),10),d=m.next(),r=d.childMenuItems(),h=parseInt(d.menuItemDepth(),10)+1,p=m.prev(),f=parseInt(p.menuItemDepth(),10),v=p.getItemData()["menu-item-db-id"],p=menus["moved"+t.charAt(0).toUpperCase()+t.slice(1)];switch(t){case"up":i=l-1,0!==l&&(0==i&&0!==c&&m.moveHorizontally(0,c),0!==f&&m.moveHorizontally(f,c),(o?n=m.add(o):m).detach().insertBefore(a.eq(i)).updateParentMenuItemDBId());break;case"down":if(o){if(n=m.add(o),(r=0!==(d=a.eq(n.length+l)).childMenuItems().length)&&(i=parseInt(d.menuItemDepth(),10)+1,m.moveHorizontally(i,c)),s===l+n.length)break;n.detach().insertAfter(a.eq(l+n.length)).updateParentMenuItemDBId()}else{if(0!==r.length&&m.moveHorizontally(h,c),s===l+1)break;m.detach().insertAfter(a.eq(l+1)).updateParentMenuItemDBId()}break;case"top":0!==l&&(o?n=m.add(o):m).detach().insertBefore(a.eq(0)).updateParentMenuItemDBId();break;case"left":0!==c&&m.shiftHorizontally(-1);break;case"right":0!==l&&u["menu-item-parent-id"]!==v&&m.shiftHorizontally(1)}e.trigger("focus"),I.registerChange(),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),p&&wp.a11y.speak(p)},initAccessibility:function(){var e=k("#menu-to-edit");I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),e.on("mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility",".menu-item",function(){I.refreshAdvancedAccessibilityOfItem(k(this).find("a.item-edit"))}),e.on("click","a.item-edit",function(){I.refreshAdvancedAccessibilityOfItem(k(this))}),e.on("click",".menus-move",function(){var e=k(this).data("dir");void 0!==e&&I.moveMenuItem(k(this).parents("li.menu-item").find("a.item-edit"),e)})},refreshAdvancedAccessibilityOfItem:function(e){var t,n,i,a,s,m,o,u,c,l,d,r;!0===k(e).data("needs_accessibility_refresh")&&(m=0===(s=(a=(e=k(e)).closest("li.menu-item").first()).menuItemDepth()),o=e.closest(".menu-item-handle").find(".menu-item-title").text(),u=parseInt(a.index(),10),c=m?s:parseInt(s-1,10),c=a.prevAll(".menu-item-depth-"+c).first().find(".menu-item-title").text(),l=a.prevAll(".menu-item-depth-"+s).first().find(".menu-item-title").text(),d=k("#menu-to-edit li").length,r=a.nextAll(".menu-item-depth-"+s).length,a.find(".field-move").toggle(1<d),0!==u&&(i=a.find(".menus-move-up")).attr("aria-label",menus.moveUp).css("display","inline"),0!==u&&m&&(i=a.find(".menus-move-top")).attr("aria-label",menus.moveToTop).css("display","inline"),u+1!==d&&0!==u&&(i=a.find(".menus-move-down")).attr("aria-label",menus.moveDown).css("display","inline"),0===u&&0!==r&&(i=a.find(".menus-move-down")).attr("aria-label",menus.moveDown).css("display","inline"),m||(i=a.find(".menus-move-left"),n=menus.outFrom.replace("%s",c),i.attr("aria-label",menus.moveOutFrom.replace("%s",c)).text(n).css("display","inline")),0!==u&&a.find(".menu-item-data-parent-id").val()!==a.prev().find(".menu-item-data-db-id").val()&&(i=a.find(".menus-move-right"),n=menus.under.replace("%s",l),i.attr("aria-label",menus.moveUnder.replace("%s",l)).text(n).css("display","inline")),n=m?(t=(r=k(".menu-item-depth-0")).index(a)+1,d=r.length,menus.menuFocus.replace("%1$s",o).replace("%2$d",t).replace("%3$d",d)):(u=(c=a.prevAll(".menu-item-depth-"+parseInt(s-1,10)).first()).find(".menu-item-data-db-id").val(),i=c.find(".menu-item-title").text(),l=k('.menu-item .menu-item-data-parent-id[value="'+u+'"]'),t=k(l.parents(".menu-item").get().reverse()).index(a)+1,menus.subMenuFocus.replace("%1$s",o).replace("%2$d",t).replace("%3$s",i)),e.attr("aria-label",n),e.data("needs_accessibility_refresh",!1))},refreshAdvancedAccessibility:function(){k(".menu-item-settings .field-move .menus-move").hide(),k("a.item-edit").data("needs_accessibility_refresh",!0),k(".menu-item-edit-active a.item-edit").each(function(){I.refreshAdvancedAccessibilityOfItem(this)})},refreshKeyboardAccessibility:function(){k("a.item-edit").off("focus").on("focus",function(){k(this).off("keydown").on("keydown",function(e){var t,n=k(this),i=n.parents("li.menu-item").getItemData();if((37==e.which||38==e.which||39==e.which||40==e.which)&&(n.off("keydown"),1!==k("#menu-to-edit li").length)){switch(t={38:"up",40:"down",37:"left",39:"right"},(t=k("body").hasClass("rtl")?{38:"up",40:"down",39:"left",37:"right"}:t)[e.which]){case"up":I.moveMenuItem(n,"up");break;case"down":I.moveMenuItem(n,"down");break;case"left":I.moveMenuItem(n,"left");break;case"right":I.moveMenuItem(n,"right")}return k("#edit-"+i["menu-item-db-id"]).trigger("focus"),!1}})})},initPreviewing:function(){k("#menu-to-edit").on("change input",".edit-menu-item-title",function(e){var e=k(e.currentTarget),t=e.val(),e=e.closest(".menu-item").find(".menu-item-title");t?e.text(t).removeClass("no-title"):e.text(wp.i18n._x("(no label)","missing menu item navigation label")).addClass("no-title")})},initToggles:function(){postboxes.add_postbox_toggles("nav-menus"),columns.useCheckboxesForHidden(),columns.checked=function(e){k(".field-"+e).removeClass("hidden-field")},columns.unchecked=function(e){k(".field-"+e).addClass("hidden-field")},I.menuList.hideAdvancedMenuItemFields(),k(".hide-postbox-tog").on("click",function(){var e=k(".accordion-container li.accordion-section").filter(":hidden").map(function(){return this.id}).get().join(",");k.post(ajaxurl,{action:"closed-postboxes",hidden:e,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:"nav-menus"})})},initSortables:function(){var m,a,s,n,o,u,c,l,d,r,e,h=0,p=I.menuList.offset().left,f=k("body"),v=f[0].className&&(e=f[0].className.match(/menu-max-depth-(\d+)/))&&e[1]?parseInt(e[1],10):0;function g(e){n=e.placeholder.prev(".menu-item"),o=e.placeholder.next(".menu-item"),n[0]==e.item[0]&&(n=n.prev(".menu-item")),o[0]==e.item[0]&&(o=o.next(".menu-item")),u=n.length?n.offset().top+n.height():0,c=o.length?o.offset().top+o.height()/3:0,a=o.length?o.menuItemDepth():0,s=n.length?(e=n.menuItemDepth()+1)>I.options.globalMaxDepth?I.options.globalMaxDepth:e:0}function b(e,t){e.placeholder.updateDepthClass(t,h),h=t}0!==k("#menu-to-edit li").length&&k(".drag-instructions").show(),p+=I.isRTL?I.menuList.width():0,I.menuList.sortable({handle:".menu-item-handle",placeholder:"sortable-placeholder",items:I.options.sortableItems,start:function(e,t){var n,i;I.isRTL&&(t.item[0].style.right="auto"),d=t.item.children(".menu-item-transport"),m=t.item.menuItemDepth(),b(t,m),i=(t.item.next()[0]==t.placeholder[0]?t.item.next():t.item).childMenuItems(),d.append(i),n=d.outerHeight(),n=(n+=0<n?+t.placeholder.css("margin-top").slice(0,-2):0)+t.helper.outerHeight(),l=n,t.placeholder.height(n-=2),r=m,i.each(function(){var e=k(this).menuItemDepth();r=r<e?e:r}),n=t.helper.find(".menu-item-handle").outerWidth(),n+=I.depthToPx(r-m),t.placeholder.width(n-=2),(i=t.placeholder.next(".menu-item")).css("margin-top",l+"px"),t.placeholder.detach(),k(this).sortable("refresh"),t.item.after(t.placeholder),i.css("margin-top",0),g(t)},stop:function(e,t){var n=h-m,i=d.children().insertAfter(t.item),a=t.item.find(".item-title .is-submenu");if(0<h?a.show():a.hide(),0!=n){t.item.updateDepthClass(h),i.shiftDepthClass(n);var a=n,s=v;if(0!==a){if(0<a)v<(i=r+a)&&(s=i);else if(a<0&&r==v)for(;!k(".menu-item-depth-"+s,I.menuList).length&&0<s;)s--;f.removeClass("menu-max-depth-"+v).addClass("menu-max-depth-"+s),v=s}}I.registerChange(),t.item.updateParentMenuItemDBId(),t.item[0].style.top=0,I.isRTL&&(t.item[0].style.left="auto",t.item[0].style.right=0),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility()},change:function(e,t){t.placeholder.parent().hasClass("menu")||(n.length?n.after(t.placeholder):I.menuList.prepend(t.placeholder)),g(t)},sort:function(e,t){var n=t.helper.offset(),i=I.isRTL?n.left+t.helper.width():n.left,i=I.negateIfRTL*I.pxToDepth(i-p);s<i||n.top<u-I.options.targetTolerance?i=s:i<a&&(i=a),i!=h&&b(t,i),c&&n.top+l>c&&(o.after(t.placeholder),g(t),k(this).sortable("refreshPositions"))}})},initManageLocations:function(){k("#menu-locations-wrap form").on("submit",function(){window.onbeforeunload=null}),k(".menu-location-menus select").on("change",function(){var e=k(this).closest("tr").find(".locations-edit-menu-link");k(this).find("option:selected").data("orig")?e.show():e.hide()})},attachMenuEditListeners:function(){var t=this;k("#update-nav-menu").on("click",function(e){if(e.target&&e.target.className)return-1!=e.target.className.indexOf("item-edit")?t.eventOnClickEditLink(e.target):-1!=e.target.className.indexOf("menu-save")?t.eventOnClickMenuSave(e.target):-1!=e.target.className.indexOf("menu-delete")?t.eventOnClickMenuDelete(e.target):-1!=e.target.className.indexOf("item-delete")?t.eventOnClickMenuItemDelete(e.target):-1!=e.target.className.indexOf("item-cancel")?t.eventOnClickCancelLink(e.target):void 0}),k("#menu-name").on("input",_.debounce(function(){var e=k(document.getElementById("menu-name")),t=e.val();t&&t.replace(/\s+/,"")?e.parent().removeClass("form-invalid"):e.parent().addClass("form-invalid")},500)),k('#add-custom-links input[type="text"]').on("keypress",function(e){k("#customlinkdiv").removeClass("form-invalid"),13===e.keyCode&&(e.preventDefault(),k("#submit-customlinkdiv").trigger("click"))})},attachBulkSelectButtonListeners:function(){var e=this;k(".bulk-select-switcher").on("change",function(){this.checked?(k(".bulk-select-switcher").prop("checked",!0),e.enableBulkSelection()):(k(".bulk-select-switcher").prop("checked",!1),e.disableBulkSelection())})},enableBulkSelection:function(){var e=k("#menu-to-edit .menu-item-checkbox");k("#menu-to-edit").addClass("bulk-selection"),k("#nav-menu-bulk-actions-top").addClass("bulk-selection"),k("#nav-menu-bulk-actions-bottom").addClass("bulk-selection"),k.each(e,function(){k(this).prop("disabled",!1)})},disableBulkSelection:function(){var e=k("#menu-to-edit .menu-item-checkbox");k("#menu-to-edit").removeClass("bulk-selection"),k("#nav-menu-bulk-actions-top").removeClass("bulk-selection"),k("#nav-menu-bulk-actions-bottom").removeClass("bulk-selection"),k(".menu-items-delete").is('[aria-describedby="pending-menu-items-to-delete"]')&&k(".menu-items-delete").removeAttr("aria-describedby"),k.each(e,function(){k(this).prop("disabled",!0).prop("checked",!1)}),k(".menu-items-delete").addClass("disabled"),k("#pending-menu-items-to-delete ul").empty()},attachMenuCheckBoxListeners:function(){var e=this;k("#menu-to-edit").on("change",".menu-item-checkbox",function(){e.setRemoveSelectedButtonStatus()})},attachMenuItemDeleteButton:function(){var t=this;k(document).on("click",".menu-items-delete",function(e){var n,i;e.preventDefault(),k(this).hasClass("disabled")||(k.each(k(".menu-item-checkbox:checked"),function(e,t){k(t).parents("li").find("a.item-delete").trigger("click")}),k(".menu-items-delete").addClass("disabled"),k(".bulk-select-switcher").prop("checked",!1),n="",i=k("#pending-menu-items-to-delete ul li"),k.each(i,function(e,t){t=k(t).find(".pending-menu-item-name").text(),t=menus.menuItemDeletion.replace("%s",t);n+=t,e+1<i.length&&(n+=", ")}),e=menus.itemsDeleted.replace("%s",n),wp.a11y.speak(e,"polite"),t.disableBulkSelection())})},attachPendingMenuItemsListForDeletion:function(){k("#post-body-content").on("change",".menu-item-checkbox",function(){var e,t,n,i;k(".menu-items-delete").is('[aria-describedby="pending-menu-items-to-delete"]')||k(".menu-items-delete").attr("aria-describedby","pending-menu-items-to-delete"),e=k(this).next().text(),t=k(this).parent().next(".item-controls").find(".item-type").text(),n=k(this).attr("data-menu-item-id"),0<(i=k("#pending-menu-items-to-delete ul").find("[data-menu-item-id="+n+"]")).length&&i.remove(),!0===this.checked&&k("#pending-menu-items-to-delete ul").append('<li data-menu-item-id="'+n+'"><span class="pending-menu-item-name">'+e+'</span> <span class="pending-menu-item-type">('+t+')</span><span class="separator"></span></li>'),k("#pending-menu-items-to-delete li .separator").html(", "),k("#pending-menu-items-to-delete li .separator").last().html(".")})},setBulkDeleteCheckboxStatus:function(){var e=k("#menu-to-edit .menu-item-checkbox");k.each(e,function(){k(this).prop("disabled")?k(this).prop("disabled",!1):k(this).prop("disabled",!0),k(this).is(":checked")&&k(this).prop("checked",!1)}),this.setRemoveSelectedButtonStatus()},setRemoveSelectedButtonStatus:function(){var e=k(".menu-items-delete");0<k(".menu-item-checkbox:checked").length?e.removeClass("disabled"):e.addClass("disabled")},attachMenuSaveSubmitListeners:function(){k("#update-nav-menu").on("submit",function(){var e=k("#update-nav-menu").serializeArray();k('[name="nav-menu-data"]').val(JSON.stringify(e))})},attachThemeLocationsListeners:function(){var e=k("#nav-menu-theme-locations"),t={action:"menu-locations-save"};t["menu-settings-column-nonce"]=k("#menu-settings-column-nonce").val(),e.find('input[type="submit"]').on("click",function(){return e.find("select").each(function(){t[this.name]=k(this).val()}),e.find(".spinner").addClass("is-active"),k.post(ajaxurl,t,function(){e.find(".spinner").removeClass("is-active")}),!1})},attachQuickSearchListeners:function(){var t;k("#nav-menu-meta").on("submit",function(e){e.preventDefault()}),k("#nav-menu-meta").on("input",".quick-search",function(){var e=k(this);e.attr("autocomplete","off"),t&&clearTimeout(t),t=setTimeout(function(){I.updateQuickSearchResults(e)},500)}).on("blur",".quick-search",function(){I.lastSearch=""})},updateQuickSearchResults:function(e){var t,n,i=e.val();i.length<2||I.lastSearch==i||(I.lastSearch=i,t=e.parents(".tabs-panel"),n={action:"menu-quick-search","response-format":"markup",menu:k("#menu").val(),"menu-settings-column-nonce":k("#menu-settings-column-nonce").val(),q:i,type:e.attr("name")},k(".spinner",t).addClass("is-active"),k.post(ajaxurl,n,function(e){I.processQuickSearchQueryResponse(e,n,t)}))},addCustomLink:function(e){var t=k("#custom-menu-item-url").val().toString(),n=k("#custom-menu-item-name").val();if(""!==t&&(t=t.trim()),e=e||I.addMenuItemToBottom,""===t||"https://"==t||"http://"==t)return k("#customlinkdiv").addClass("form-invalid"),!1;k(".customlinkdiv .spinner").addClass("is-active"),this.addLinkToMenu(t,n,e,function(){k(".customlinkdiv .spinner").removeClass("is-active"),k("#custom-menu-item-name").val("").trigger("blur"),k("#custom-menu-item-url").val("").attr("placeholder","https://")})},addLinkToMenu:function(e,t,n,i){n=n||I.addMenuItemToBottom,I.addItemToMenu({"-1":{"menu-item-type":"custom","menu-item-url":e,"menu-item-title":t}},n,i=i||function(){})},addItemToMenu:function(e,n,i){var a,t=k("#menu").val(),s=k("#menu-settings-column-nonce").val();n=n||function(){},i=i||function(){},a={action:"add-menu-item",menu:t,"menu-settings-column-nonce":s,"menu-item":e},k.post(ajaxurl,a,function(e){var t=k("#menu-instructions");e=(e=e||"").toString().trim(),n(e,a),k("li.pending").hide().fadeIn("slow"),k(".drag-instructions").show(),!t.hasClass("menu-instructions-inactive")&&t.siblings().length&&t.addClass("menu-instructions-inactive"),i()})},addMenuItemToBottom:function(e){e=k(e);e.hideAdvancedMenuItemFields().appendTo(I.targetList),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),wp.a11y.speak(menus.itemAdded),k(document).trigger("menu-item-added",[e])},addMenuItemToTop:function(e){e=k(e);e.hideAdvancedMenuItemFields().prependTo(I.targetList),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),wp.a11y.speak(menus.itemAdded),k(document).trigger("menu-item-added",[e])},attachUnsavedChangesListener:function(){k("#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select").on("change",function(){I.registerChange()}),0!==k("#menu-to-edit").length||0!==k(".menu-location-menus select").length?window.onbeforeunload=function(){if(I.menusChanged)return wp.i18n.__("The changes you made will be lost if you navigate away from this page.")}:k("#menu-settings-column").find("input,select").end().find("a").attr("href","#").off("click")},registerChange:function(){I.menusChanged=!0},attachTabsPanelListeners:function(){k("#menu-settings-column").on("click",function(e){var t,n,i,a,s=k(e.target);if(s.hasClass("nav-tab-link"))n=s.data("type"),i=s.parents(".accordion-section-content").first(),k("input",i).prop("checked",!1),k(".tabs-panel-active",i).removeClass("tabs-panel-active").addClass("tabs-panel-inactive"),k("#"+n,i).removeClass("tabs-panel-inactive").addClass("tabs-panel-active"),k(".tabs",i).removeClass("tabs"),s.parent().addClass("tabs"),k(".quick-search",i).trigger("focus"),i.find(".tabs-panel-active .menu-item-title").length?i.removeClass("has-no-menu-item"):i.addClass("has-no-menu-item"),e.preventDefault();else if(s.hasClass("select-all"))(t=s.closest(".button-controls").data("items-type"))&&((a=k("#"+t+" .tabs-panel-active .menu-item-title input")).length!==a.filter(":checked").length||s.is(":checked")?s.is(":checked")&&a.prop("checked",!0):a.prop("checked",!1));else if(s.hasClass("menu-item-checkbox"))(t=s.closest(".tabs-panel-active").parent().attr("id"))&&(a=k("#"+t+" .tabs-panel-active .menu-item-title input"),n=k('.button-controls[data-items-type="'+t+'"] .select-all'),a.length!==a.filter(":checked").length||n.is(":checked")?n.is(":checked")&&n.prop("checked",!1):n.prop("checked",!0));else if(s.hasClass("submit-add-to-menu"))return I.registerChange(),e.target.id&&"submit-customlinkdiv"==e.target.id?I.addCustomLink(I.addMenuItemToBottom):e.target.id&&-1!=e.target.id.indexOf("submit-")&&k("#"+e.target.id.replace(/submit-/,"")).addSelectedToMenu(I.addMenuItemToBottom),!1}),k("#nav-menu-meta").on("click","a.page-numbers",function(){var n=k(this).closest(".inside");return k.post(ajaxurl,this.href.replace(/.*\?/,"").replace(/action=([^&]*)/,"")+"&action=menu-get-metabox",function(e){var t=JSON.parse(e);-1!==e.indexOf("replace-id")&&(e=document.getElementById(t["replace-id"]),t.markup)&&e&&n.html(t.markup)}),!1})},eventOnClickEditLink:function(e){var t,e=/#(.*)$/.exec(e.href);if(e&&e[1]&&0!==(t=(e=k("#"+e[1])).parent()).length)return t.hasClass("menu-item-edit-inactive")?(e.data("menu-item-data")||e.data("menu-item-data",e.getItemData()),e.slideDown("fast"),t.removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active")):(e.slideUp("fast"),t.removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive")),!1},eventOnClickCancelLink:function(e){var t=k(e).closest(".menu-item-settings"),e=k(e).closest(".menu-item");return e.removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive"),t.setItemData(t.data("menu-item-data")).hide(),e.find(".menu-item-title").text(t.data("menu-item-data")["menu-item-title"]),!1},eventOnClickMenuSave:function(){var e="",t=k("#menu-name"),n=t.val();return n&&n.replace(/\s+/,"")?(k("#nav-menu-theme-locations select").each(function(){e+='<input type="hidden" name="'+this.name+'" value="'+k(this).val()+'" />'}),k("#update-nav-menu").append(e),I.menuList.find(".menu-item-data-position").val(function(e){return e+1}),!(window.onbeforeunload=null)):(t.parent().addClass("form-invalid"),!1)},eventOnClickMenuDelete:function(){return!!window.confirm(wp.i18n.__("You are about to permanently delete this menu.\n'Cancel' to stop, 'OK' to delete."))&&!(window.onbeforeunload=null)},eventOnClickMenuItemDelete:function(e){e=parseInt(e.id.replace("delete-",""),10);return I.removeMenuItem(k("#menu-item-"+e)),I.registerChange(),!1},processQuickSearchQueryResponse:function(e,t,n){var i,a,s,m={},o=document.getElementById("nav-menu-meta"),u=/menu-item[(\[^]\]*/,e=k("<div>").html(e).find("li"),c=n.closest(".accordion-section-content"),l=c.find(".button-controls .select-all");e.length?(e.each(function(){if(s=k(this),(i=u.exec(s.html()))&&i[1]){for(a=i[1];o.elements["menu-item["+a+"][menu-item-type]"]||m[a];)a--;m[a]=!0,a!=i[1]&&s.html(s.html().replace(new RegExp("menu-item\\["+i[1]+"\\]","g"),"menu-item["+a+"]"))}}),k(".categorychecklist",n).html(e),k(".spinner",n).removeClass("is-active"),c.removeClass("has-no-menu-item"),l.is(":checked")&&l.prop("checked",!1)):(k(".categorychecklist",n).html("<li><p>"+wp.i18n.__("No results found.")+"</p></li>"),k(".spinner",n).removeClass("is-active"),c.addClass("has-no-menu-item"))},removeMenuItem:function(t){var n=t.childMenuItems();k(document).trigger("menu-removing-item",[t]),t.addClass("deleting").animate({opacity:0,height:0},350,function(){var e=k("#menu-instructions");t.remove(),n.shiftDepthClass(-1).updateParentMenuItemDBId(),0===k("#menu-to-edit li").length&&(k(".drag-instructions").hide(),e.removeClass("menu-instructions-inactive")),I.refreshAdvancedAccessibility(),wp.a11y.speak(menus.itemRemoved)})},depthToPx:function(e){return e*I.options.menuItemDepthPerLevel},pxToDepth:function(e){return Math.floor(e/I.options.menuItemDepthPerLevel)}};k(function(){wpNavMenu.init(),k(".menu-edit a, .menu-edit button, .menu-edit input, .menu-edit textarea, .menu-edit select").on("focus",function(){var e,t,n;783<=window.innerWidth&&(e=k("#nav-menu-footer").height()+20,0<(t=k(this).offset().top-(k(window).scrollTop()+k(window).height()-k(this).height()))&&(t=0),(t*=-1)<e)&&(n=k(document).scrollTop(),k(document).scrollTop(n+(e-t)))})}),k(document).on("menu-item-added",function(){k(".bulk-actions").is(":visible")||k(".bulk-actions").show()}),k(document).on("menu-removing-item",function(e,t){1===k(t).parents("#menu-to-edit").find("li").length&&k(".bulk-actions").is(":visible")&&k(".bulk-actions").hide()})}(jQuery);
\ No newline at end of file +!function(k){var I=window.wpNavMenu={options:{menuItemDepthPerLevel:30,globalMaxDepth:11,sortableItems:"> *",targetTolerance:0},menuList:void 0,targetList:void 0,menusChanged:!1,isRTL:!("undefined"==typeof isRtl||!isRtl),negateIfRTL:"undefined"!=typeof isRtl&&isRtl?-1:1,lastSearch:"",init:function(){I.menuList=k("#menu-to-edit"),I.targetList=I.menuList,this.jQueryExtensions(),this.attachMenuEditListeners(),this.attachBulkSelectButtonListeners(),this.attachMenuCheckBoxListeners(),this.attachMenuItemDeleteButton(),this.attachPendingMenuItemsListForDeletion(),this.attachQuickSearchListeners(),this.attachThemeLocationsListeners(),this.attachMenuSaveSubmitListeners(),this.attachTabsPanelListeners(),this.attachUnsavedChangesListener(),I.menuList.length&&this.initSortables(),menus.oneThemeLocationNoMenus&&k("#posttype-page").addSelectedToMenu(I.addMenuItemToBottom),this.initManageLocations(),this.initAccessibility(),this.initToggles(),this.initPreviewing()},jQueryExtensions:function(){k.fn.extend({menuItemDepth:function(){var e=I.isRTL?this.eq(0).css("margin-right"):this.eq(0).css("margin-left");return I.pxToDepth(e&&-1!=e.indexOf("px")?e.slice(0,-2):0)},updateDepthClass:function(t,n){return this.each(function(){var e=k(this);n=n||e.menuItemDepth(),k(this).removeClass("menu-item-depth-"+n).addClass("menu-item-depth-"+t)})},shiftDepthClass:function(i){return this.each(function(){var e=k(this),t=e.menuItemDepth(),n=t+i;e.removeClass("menu-item-depth-"+t).addClass("menu-item-depth-"+n),0===n&&e.find(".is-submenu").hide()})},childMenuItems:function(){var i=k();return this.each(function(){for(var e=k(this),t=e.menuItemDepth(),n=e.next(".menu-item");n.length&&n.menuItemDepth()>t;)i=i.add(n),n=n.next(".menu-item")}),i},shiftHorizontally:function(n){return this.each(function(){var e=k(this),t=e.menuItemDepth();e.moveHorizontally(t+n,t)})},moveHorizontally:function(a,s){return this.each(function(){var e=k(this),t=e.childMenuItems(),n=a-s,i=e.find(".is-submenu");e.updateDepthClass(a,s).updateParentMenuItemDBId(),t&&t.each(function(){var e=k(this),t=e.menuItemDepth();e.updateDepthClass(t+n,t).updateParentMenuItemDBId()}),0===a?i.hide():i.show()})},updateParentMenuItemDBId:function(){return this.each(function(){var e=k(this),t=e.find(".menu-item-data-parent-id"),n=parseInt(e.menuItemDepth(),10),e=e.prevAll(".menu-item-depth-"+(n-1)).first();0===n?t.val(0):t.val(e.find(".menu-item-data-db-id").val())})},hideAdvancedMenuItemFields:function(){return this.each(function(){var e=k(this);k(".hide-column-tog").not(":checked").each(function(){e.find(".field-"+k(this).val()).addClass("hidden-field")})})},addSelectedToMenu:function(a){return 0!==k("#menu-to-edit").length&&this.each(function(){var e=k(this),n={},t=menus.oneThemeLocationNoMenus&&0===e.find(".tabs-panel-active .categorychecklist li input:checked").length?e.find('#page-all li input[type="checkbox"]'):e.find(".tabs-panel-active .categorychecklist li input:checked"),i=/menu-item\[([^\]]*)/;if(a=a||I.addMenuItemToBottom,!t.length)return!1;e.find(".button-controls .spinner").addClass("is-active"),k(t).each(function(){var e=k(this),t=i.exec(e.attr("name")),t=void 0===t[1]?0:parseInt(t[1],10);this.className&&-1!=this.className.indexOf("add-to-top")&&(a=I.addMenuItemToTop),n[t]=e.closest("li").getItemData("add-menu-item",t)}),I.addItemToMenu(n,a,function(){t.prop("checked",!1),e.find(".button-controls .select-all").prop("checked",!1),e.find(".button-controls .spinner").removeClass("is-active")})})},getItemData:function(t,n){t=t||"menu-item";var i,a={},s=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"];return(n=n||"menu-item"!=t?n:this.find(".menu-item-data-db-id").val())&&this.find("input").each(function(){var e;for(i=s.length;i--;)"menu-item"==t?e=s[i]+"["+n+"]":"add-menu-item"==t&&(e="menu-item["+n+"]["+s[i]+"]"),this.name&&e==this.name&&(a[s[i]]=this.value)}),a},setItemData:function(e,a,s){return a=a||"menu-item",(s=s||"menu-item"!=a?s:k(".menu-item-data-db-id",this).val())&&this.find("input").each(function(){var n,i=k(this);k.each(e,function(e,t){"menu-item"==a?n=e+"["+s+"]":"add-menu-item"==a&&(n="menu-item["+s+"]["+e+"]"),n==i.attr("name")&&i.val(t)})}),this}})},countMenuItems:function(e){return k(".menu-item-depth-"+e).length},moveMenuItem:function(e,t){var n,i,a=k("#menu-to-edit li"),s=a.length,m=e.parents("li.menu-item"),o=m.childMenuItems(),u=m.getItemData(),c=parseInt(m.menuItemDepth(),10),l=parseInt(m.index(),10),d=m.next(),r=d.childMenuItems(),h=parseInt(d.menuItemDepth(),10)+1,p=m.prev(),f=parseInt(p.menuItemDepth(),10),v=p.getItemData()["menu-item-db-id"],p=menus["moved"+t.charAt(0).toUpperCase()+t.slice(1)];switch(t){case"up":i=l-1,0!==l&&(0==i&&0!==c&&m.moveHorizontally(0,c),0!==f&&m.moveHorizontally(f,c),(o?n=m.add(o):m).detach().insertBefore(a.eq(i)).updateParentMenuItemDBId());break;case"down":if(o){if(n=m.add(o),(r=0!==(d=a.eq(n.length+l)).childMenuItems().length)&&(i=parseInt(d.menuItemDepth(),10)+1,m.moveHorizontally(i,c)),s===l+n.length)break;n.detach().insertAfter(a.eq(l+n.length)).updateParentMenuItemDBId()}else{if(0!==r.length&&m.moveHorizontally(h,c),s===l+1)break;m.detach().insertAfter(a.eq(l+1)).updateParentMenuItemDBId()}break;case"top":0!==l&&(o?n=m.add(o):m).detach().insertBefore(a.eq(0)).updateParentMenuItemDBId();break;case"left":0!==c&&m.shiftHorizontally(-1);break;case"right":0!==l&&u["menu-item-parent-id"]!==v&&m.shiftHorizontally(1)}e.trigger("focus"),I.registerChange(),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),p&&wp.a11y.speak(p)},initAccessibility:function(){var e=k("#menu-to-edit");I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),e.on("mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility",".menu-item",function(){I.refreshAdvancedAccessibilityOfItem(k(this).find("a.item-edit"))}),e.on("click","a.item-edit",function(){I.refreshAdvancedAccessibilityOfItem(k(this))}),e.on("click",".menus-move",function(){var e=k(this).data("dir");void 0!==e&&I.moveMenuItem(k(this).parents("li.menu-item").find("a.item-edit"),e)})},refreshAdvancedAccessibilityOfItem:function(e){var t,n,i,a,s,m,o,u,c,l,d,r,h;!0===k(e).data("needs_accessibility_refresh")&&(m=0===(s=(a=(e=k(e)).closest("li.menu-item").first()).menuItemDepth()),o=e.closest(".menu-item-handle").find(".menu-item-title").text(),u=e.closest(".menu-item-handle").find(".item-controls").find(".item-type").text(),c=parseInt(a.index(),10),l=m?s:parseInt(s-1,10),l=a.prevAll(".menu-item-depth-"+l).first().find(".menu-item-title").text(),d=a.prevAll(".menu-item-depth-"+s).first().find(".menu-item-title").text(),r=k("#menu-to-edit li").length,h=a.nextAll(".menu-item-depth-"+s).length,a.find(".field-move").toggle(1<r),0!==c&&(n=a.find(".menus-move-up")).attr("aria-label",menus.moveUp).css("display","inline"),0!==c&&m&&(n=a.find(".menus-move-top")).attr("aria-label",menus.moveToTop).css("display","inline"),c+1!==r&&0!==c&&(n=a.find(".menus-move-down")).attr("aria-label",menus.moveDown).css("display","inline"),0===c&&0!==h&&(n=a.find(".menus-move-down")).attr("aria-label",menus.moveDown).css("display","inline"),m||(n=a.find(".menus-move-left"),i=menus.outFrom.replace("%s",l),n.attr("aria-label",menus.moveOutFrom.replace("%s",l)).text(i).css("display","inline")),0!==c&&a.find(".menu-item-data-parent-id").val()!==a.prev().find(".menu-item-data-db-id").val()&&(n=a.find(".menus-move-right"),i=menus.under.replace("%s",d),n.attr("aria-label",menus.moveUnder.replace("%s",d)).text(i).css("display","inline")),m=m?(t=(h=k(".menu-item-depth-0")).index(a)+1,r=h.length,menus.menuFocus.replace("%1$s",o).replace("%2$s",u).replace("%3$d",t).replace("%4$d",r)):(c=(l=a.prevAll(".menu-item-depth-"+parseInt(s-1,10)).first()).find(".menu-item-data-db-id").val(),n=l.find(".menu-item-title").text(),i=(d=k('.menu-item .menu-item-data-parent-id[value="'+c+'"]')).length,t=k(d.parents(".menu-item").get().reverse()).index(a)+1,s<2?menus.subMenuFocus.replace("%1$s",o).replace("%2$s",u).replace("%3$d",t).replace("%4$d",i).replace("%5$s",n):menus.subMenuMoreDepthFocus.replace("%1$s",o).replace("%2$s",u).replace("%3$d",t).replace("%4$d",i).replace("%5$s",n).replace("%6$d",s)),e.attr("aria-label",m),e.data("needs_accessibility_refresh",!1))},refreshAdvancedAccessibility:function(){k(".menu-item-settings .field-move .menus-move").hide(),k("a.item-edit").data("needs_accessibility_refresh",!0),k(".menu-item-edit-active a.item-edit").each(function(){I.refreshAdvancedAccessibilityOfItem(this)})},refreshKeyboardAccessibility:function(){k("a.item-edit").off("focus").on("focus",function(){k(this).off("keydown").on("keydown",function(e){var t,n=k(this),i=n.parents("li.menu-item").getItemData();if((37==e.which||38==e.which||39==e.which||40==e.which)&&(n.off("keydown"),1!==k("#menu-to-edit li").length)){switch(t={38:"up",40:"down",37:"left",39:"right"},(t=k("body").hasClass("rtl")?{38:"up",40:"down",39:"left",37:"right"}:t)[e.which]){case"up":I.moveMenuItem(n,"up");break;case"down":I.moveMenuItem(n,"down");break;case"left":I.moveMenuItem(n,"left");break;case"right":I.moveMenuItem(n,"right")}return k("#edit-"+i["menu-item-db-id"]).trigger("focus"),!1}})})},initPreviewing:function(){k("#menu-to-edit").on("change input",".edit-menu-item-title",function(e){var e=k(e.currentTarget),t=e.val(),e=e.closest(".menu-item").find(".menu-item-title");t?e.text(t).removeClass("no-title"):e.text(wp.i18n._x("(no label)","missing menu item navigation label")).addClass("no-title")})},initToggles:function(){postboxes.add_postbox_toggles("nav-menus"),columns.useCheckboxesForHidden(),columns.checked=function(e){k(".field-"+e).removeClass("hidden-field")},columns.unchecked=function(e){k(".field-"+e).addClass("hidden-field")},I.menuList.hideAdvancedMenuItemFields(),k(".hide-postbox-tog").on("click",function(){var e=k(".accordion-container li.accordion-section").filter(":hidden").map(function(){return this.id}).get().join(",");k.post(ajaxurl,{action:"closed-postboxes",hidden:e,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:"nav-menus"})})},initSortables:function(){var m,a,s,n,o,u,c,l,d,r,e,h=0,p=I.menuList.offset().left,f=k("body"),v=f[0].className&&(e=f[0].className.match(/menu-max-depth-(\d+)/))&&e[1]?parseInt(e[1],10):0;function g(e){n=e.placeholder.prev(".menu-item"),o=e.placeholder.next(".menu-item"),n[0]==e.item[0]&&(n=n.prev(".menu-item")),o[0]==e.item[0]&&(o=o.next(".menu-item")),u=n.length?n.offset().top+n.height():0,c=o.length?o.offset().top+o.height()/3:0,a=o.length?o.menuItemDepth():0,s=n.length?(e=n.menuItemDepth()+1)>I.options.globalMaxDepth?I.options.globalMaxDepth:e:0}function b(e,t){e.placeholder.updateDepthClass(t,h),h=t}0!==k("#menu-to-edit li").length&&k(".drag-instructions").show(),p+=I.isRTL?I.menuList.width():0,I.menuList.sortable({handle:".menu-item-handle",placeholder:"sortable-placeholder",items:I.options.sortableItems,start:function(e,t){var n,i;I.isRTL&&(t.item[0].style.right="auto"),d=t.item.children(".menu-item-transport"),m=t.item.menuItemDepth(),b(t,m),i=(t.item.next()[0]==t.placeholder[0]?t.item.next():t.item).childMenuItems(),d.append(i),n=d.outerHeight(),n=(n+=0<n?+t.placeholder.css("margin-top").slice(0,-2):0)+t.helper.outerHeight(),l=n,t.placeholder.height(n-=2),r=m,i.each(function(){var e=k(this).menuItemDepth();r=r<e?e:r}),n=t.helper.find(".menu-item-handle").outerWidth(),n+=I.depthToPx(r-m),t.placeholder.width(n-=2),(i=t.placeholder.next(".menu-item")).css("margin-top",l+"px"),t.placeholder.detach(),k(this).sortable("refresh"),t.item.after(t.placeholder),i.css("margin-top",0),g(t)},stop:function(e,t){var n=h-m,i=d.children().insertAfter(t.item),a=t.item.find(".item-title .is-submenu");if(0<h?a.show():a.hide(),0!=n){t.item.updateDepthClass(h),i.shiftDepthClass(n);var a=n,s=v;if(0!==a){if(0<a)v<(i=r+a)&&(s=i);else if(a<0&&r==v)for(;!k(".menu-item-depth-"+s,I.menuList).length&&0<s;)s--;f.removeClass("menu-max-depth-"+v).addClass("menu-max-depth-"+s),v=s}}I.registerChange(),t.item.updateParentMenuItemDBId(),t.item[0].style.top=0,I.isRTL&&(t.item[0].style.left="auto",t.item[0].style.right=0),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),I.refreshAdvancedAccessibilityOfItem(t.item.find("a.item-edit"))},change:function(e,t){t.placeholder.parent().hasClass("menu")||(n.length?n.after(t.placeholder):I.menuList.prepend(t.placeholder)),g(t)},sort:function(e,t){var n=t.helper.offset(),i=I.isRTL?n.left+t.helper.width():n.left,i=I.negateIfRTL*I.pxToDepth(i-p);s<i||n.top<u-I.options.targetTolerance?i=s:i<a&&(i=a),i!=h&&b(t,i),c&&n.top+l>c&&(o.after(t.placeholder),g(t),k(this).sortable("refreshPositions"))}})},initManageLocations:function(){k("#menu-locations-wrap form").on("submit",function(){window.onbeforeunload=null}),k(".menu-location-menus select").on("change",function(){var e=k(this).closest("tr").find(".locations-edit-menu-link");k(this).find("option:selected").data("orig")?e.show():e.hide()})},attachMenuEditListeners:function(){var t=this;k("#update-nav-menu").on("click",function(e){if(e.target&&e.target.className)return-1!=e.target.className.indexOf("item-edit")?t.eventOnClickEditLink(e.target):-1!=e.target.className.indexOf("menu-save")?t.eventOnClickMenuSave(e.target):-1!=e.target.className.indexOf("menu-delete")?t.eventOnClickMenuDelete(e.target):-1!=e.target.className.indexOf("item-delete")?t.eventOnClickMenuItemDelete(e.target):-1!=e.target.className.indexOf("item-cancel")?t.eventOnClickCancelLink(e.target):void 0}),k("#menu-name").on("input",_.debounce(function(){var e=k(document.getElementById("menu-name")),t=e.val();t&&t.replace(/\s+/,"")?e.parent().removeClass("form-invalid"):e.parent().addClass("form-invalid")},500)),k('#add-custom-links input[type="text"]').on("keypress",function(e){k("#customlinkdiv").removeClass("form-invalid"),13===e.keyCode&&(e.preventDefault(),k("#submit-customlinkdiv").trigger("click"))})},attachBulkSelectButtonListeners:function(){var e=this;k(".bulk-select-switcher").on("change",function(){this.checked?(k(".bulk-select-switcher").prop("checked",!0),e.enableBulkSelection()):(k(".bulk-select-switcher").prop("checked",!1),e.disableBulkSelection())})},enableBulkSelection:function(){var e=k("#menu-to-edit .menu-item-checkbox");k("#menu-to-edit").addClass("bulk-selection"),k("#nav-menu-bulk-actions-top").addClass("bulk-selection"),k("#nav-menu-bulk-actions-bottom").addClass("bulk-selection"),k.each(e,function(){k(this).prop("disabled",!1)})},disableBulkSelection:function(){var e=k("#menu-to-edit .menu-item-checkbox");k("#menu-to-edit").removeClass("bulk-selection"),k("#nav-menu-bulk-actions-top").removeClass("bulk-selection"),k("#nav-menu-bulk-actions-bottom").removeClass("bulk-selection"),k(".menu-items-delete").is('[aria-describedby="pending-menu-items-to-delete"]')&&k(".menu-items-delete").removeAttr("aria-describedby"),k.each(e,function(){k(this).prop("disabled",!0).prop("checked",!1)}),k(".menu-items-delete").addClass("disabled"),k("#pending-menu-items-to-delete ul").empty()},attachMenuCheckBoxListeners:function(){var e=this;k("#menu-to-edit").on("change",".menu-item-checkbox",function(){e.setRemoveSelectedButtonStatus()})},attachMenuItemDeleteButton:function(){var t=this;k(document).on("click",".menu-items-delete",function(e){var n,i;e.preventDefault(),k(this).hasClass("disabled")||(k.each(k(".menu-item-checkbox:checked"),function(e,t){k(t).parents("li").find("a.item-delete").trigger("click")}),k(".menu-items-delete").addClass("disabled"),k(".bulk-select-switcher").prop("checked",!1),n="",i=k("#pending-menu-items-to-delete ul li"),k.each(i,function(e,t){t=k(t).find(".pending-menu-item-name").text(),t=menus.menuItemDeletion.replace("%s",t);n+=t,e+1<i.length&&(n+=", ")}),e=menus.itemsDeleted.replace("%s",n),wp.a11y.speak(e,"polite"),t.disableBulkSelection())})},attachPendingMenuItemsListForDeletion:function(){k("#post-body-content").on("change",".menu-item-checkbox",function(){var e,t,n,i;k(".menu-items-delete").is('[aria-describedby="pending-menu-items-to-delete"]')||k(".menu-items-delete").attr("aria-describedby","pending-menu-items-to-delete"),e=k(this).next().text(),t=k(this).parent().next(".item-controls").find(".item-type").text(),n=k(this).attr("data-menu-item-id"),0<(i=k("#pending-menu-items-to-delete ul").find("[data-menu-item-id="+n+"]")).length&&i.remove(),!0===this.checked&&k("#pending-menu-items-to-delete ul").append('<li data-menu-item-id="'+n+'"><span class="pending-menu-item-name">'+e+'</span> <span class="pending-menu-item-type">('+t+')</span><span class="separator"></span></li>'),k("#pending-menu-items-to-delete li .separator").html(", "),k("#pending-menu-items-to-delete li .separator").last().html(".")})},setBulkDeleteCheckboxStatus:function(){var e=k("#menu-to-edit .menu-item-checkbox");k.each(e,function(){k(this).prop("disabled")?k(this).prop("disabled",!1):k(this).prop("disabled",!0),k(this).is(":checked")&&k(this).prop("checked",!1)}),this.setRemoveSelectedButtonStatus()},setRemoveSelectedButtonStatus:function(){var e=k(".menu-items-delete");0<k(".menu-item-checkbox:checked").length?e.removeClass("disabled"):e.addClass("disabled")},attachMenuSaveSubmitListeners:function(){k("#update-nav-menu").on("submit",function(){var e=k("#update-nav-menu").serializeArray();k('[name="nav-menu-data"]').val(JSON.stringify(e))})},attachThemeLocationsListeners:function(){var e=k("#nav-menu-theme-locations"),t={action:"menu-locations-save"};t["menu-settings-column-nonce"]=k("#menu-settings-column-nonce").val(),e.find('input[type="submit"]').on("click",function(){return e.find("select").each(function(){t[this.name]=k(this).val()}),e.find(".spinner").addClass("is-active"),k.post(ajaxurl,t,function(){e.find(".spinner").removeClass("is-active")}),!1})},attachQuickSearchListeners:function(){var t;k("#nav-menu-meta").on("submit",function(e){e.preventDefault()}),k("#nav-menu-meta").on("input",".quick-search",function(){var e=k(this);e.attr("autocomplete","off"),t&&clearTimeout(t),t=setTimeout(function(){I.updateQuickSearchResults(e)},500)}).on("blur",".quick-search",function(){I.lastSearch=""})},updateQuickSearchResults:function(e){var t,n,i=e.val();i.length<2||I.lastSearch==i||(I.lastSearch=i,t=e.parents(".tabs-panel"),n={action:"menu-quick-search","response-format":"markup",menu:k("#menu").val(),"menu-settings-column-nonce":k("#menu-settings-column-nonce").val(),q:i,type:e.attr("name")},k(".spinner",t).addClass("is-active"),k.post(ajaxurl,n,function(e){I.processQuickSearchQueryResponse(e,n,t)}))},addCustomLink:function(e){var t=k("#custom-menu-item-url").val().toString(),n=k("#custom-menu-item-name").val();if(""!==t&&(t=t.trim()),e=e||I.addMenuItemToBottom,""===t||"https://"==t||"http://"==t)return k("#customlinkdiv").addClass("form-invalid"),!1;k(".customlinkdiv .spinner").addClass("is-active"),this.addLinkToMenu(t,n,e,function(){k(".customlinkdiv .spinner").removeClass("is-active"),k("#custom-menu-item-name").val("").trigger("blur"),k("#custom-menu-item-url").val("").attr("placeholder","https://")})},addLinkToMenu:function(e,t,n,i){n=n||I.addMenuItemToBottom,I.addItemToMenu({"-1":{"menu-item-type":"custom","menu-item-url":e,"menu-item-title":t}},n,i=i||function(){})},addItemToMenu:function(e,n,i){var a,t=k("#menu").val(),s=k("#menu-settings-column-nonce").val();n=n||function(){},i=i||function(){},a={action:"add-menu-item",menu:t,"menu-settings-column-nonce":s,"menu-item":e},k.post(ajaxurl,a,function(e){var t=k("#menu-instructions");e=(e=e||"").toString().trim(),n(e,a),k("li.pending").hide().fadeIn("slow"),k(".drag-instructions").show(),!t.hasClass("menu-instructions-inactive")&&t.siblings().length&&t.addClass("menu-instructions-inactive"),i()})},addMenuItemToBottom:function(e){e=k(e);e.hideAdvancedMenuItemFields().appendTo(I.targetList),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),wp.a11y.speak(menus.itemAdded),k(document).trigger("menu-item-added",[e])},addMenuItemToTop:function(e){e=k(e);e.hideAdvancedMenuItemFields().prependTo(I.targetList),I.refreshKeyboardAccessibility(),I.refreshAdvancedAccessibility(),wp.a11y.speak(menus.itemAdded),k(document).trigger("menu-item-added",[e])},attachUnsavedChangesListener:function(){k("#menu-management input, #menu-management select, #menu-management, #menu-management textarea, .menu-location-menus select").on("change",function(){I.registerChange()}),0!==k("#menu-to-edit").length||0!==k(".menu-location-menus select").length?window.onbeforeunload=function(){if(I.menusChanged)return wp.i18n.__("The changes you made will be lost if you navigate away from this page.")}:k("#menu-settings-column").find("input,select").end().find("a").attr("href","#").off("click")},registerChange:function(){I.menusChanged=!0},attachTabsPanelListeners:function(){k("#menu-settings-column").on("click",function(e){var t,n,i,a,s=k(e.target);if(s.hasClass("nav-tab-link"))n=s.data("type"),i=s.parents(".accordion-section-content").first(),k("input",i).prop("checked",!1),k(".tabs-panel-active",i).removeClass("tabs-panel-active").addClass("tabs-panel-inactive"),k("#"+n,i).removeClass("tabs-panel-inactive").addClass("tabs-panel-active"),k(".tabs",i).removeClass("tabs"),s.parent().addClass("tabs"),k(".quick-search",i).trigger("focus"),i.find(".tabs-panel-active .menu-item-title").length?i.removeClass("has-no-menu-item"):i.addClass("has-no-menu-item"),e.preventDefault();else if(s.hasClass("select-all"))(t=s.closest(".button-controls").data("items-type"))&&((a=k("#"+t+" .tabs-panel-active .menu-item-title input")).length!==a.filter(":checked").length||s.is(":checked")?s.is(":checked")&&a.prop("checked",!0):a.prop("checked",!1));else if(s.hasClass("menu-item-checkbox"))(t=s.closest(".tabs-panel-active").parent().attr("id"))&&(a=k("#"+t+" .tabs-panel-active .menu-item-title input"),n=k('.button-controls[data-items-type="'+t+'"] .select-all'),a.length!==a.filter(":checked").length||n.is(":checked")?n.is(":checked")&&n.prop("checked",!1):n.prop("checked",!0));else if(s.hasClass("submit-add-to-menu"))return I.registerChange(),e.target.id&&"submit-customlinkdiv"==e.target.id?I.addCustomLink(I.addMenuItemToBottom):e.target.id&&-1!=e.target.id.indexOf("submit-")&&k("#"+e.target.id.replace(/submit-/,"")).addSelectedToMenu(I.addMenuItemToBottom),!1}),k("#nav-menu-meta").on("click","a.page-numbers",function(){var n=k(this).closest(".inside");return k.post(ajaxurl,this.href.replace(/.*\?/,"").replace(/action=([^&]*)/,"")+"&action=menu-get-metabox",function(e){var t=JSON.parse(e);-1!==e.indexOf("replace-id")&&(e=document.getElementById(t["replace-id"]),t.markup)&&e&&n.html(t.markup)}),!1})},eventOnClickEditLink:function(e){var t,e=/#(.*)$/.exec(e.href);if(e&&e[1]&&0!==(t=(e=k("#"+e[1])).parent()).length)return t.hasClass("menu-item-edit-inactive")?(e.data("menu-item-data")||e.data("menu-item-data",e.getItemData()),e.slideDown("fast"),t.removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active")):(e.slideUp("fast"),t.removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive")),!1},eventOnClickCancelLink:function(e){var t=k(e).closest(".menu-item-settings"),e=k(e).closest(".menu-item");return e.removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive"),t.setItemData(t.data("menu-item-data")).hide(),e.find(".menu-item-title").text(t.data("menu-item-data")["menu-item-title"]),!1},eventOnClickMenuSave:function(){var e="",t=k("#menu-name"),n=t.val();return n&&n.replace(/\s+/,"")?(k("#nav-menu-theme-locations select").each(function(){e+='<input type="hidden" name="'+this.name+'" value="'+k(this).val()+'" />'}),k("#update-nav-menu").append(e),I.menuList.find(".menu-item-data-position").val(function(e){return e+1}),!(window.onbeforeunload=null)):(t.parent().addClass("form-invalid"),!1)},eventOnClickMenuDelete:function(){return!!window.confirm(wp.i18n.__("You are about to permanently delete this menu.\n'Cancel' to stop, 'OK' to delete."))&&!(window.onbeforeunload=null)},eventOnClickMenuItemDelete:function(e){e=parseInt(e.id.replace("delete-",""),10);return I.removeMenuItem(k("#menu-item-"+e)),I.registerChange(),!1},processQuickSearchQueryResponse:function(e,t,n){var i,a,s,m={},o=document.getElementById("nav-menu-meta"),u=/menu-item[(\[^]\]*/,e=k("<div>").html(e).find("li"),c=n.closest(".accordion-section-content"),l=c.find(".button-controls .select-all");e.length?(e.each(function(){if(s=k(this),(i=u.exec(s.html()))&&i[1]){for(a=i[1];o.elements["menu-item["+a+"][menu-item-type]"]||m[a];)a--;m[a]=!0,a!=i[1]&&s.html(s.html().replace(new RegExp("menu-item\\["+i[1]+"\\]","g"),"menu-item["+a+"]"))}}),k(".categorychecklist",n).html(e),k(".spinner",n).removeClass("is-active"),c.removeClass("has-no-menu-item"),l.is(":checked")&&l.prop("checked",!1)):(k(".categorychecklist",n).html("<li><p>"+wp.i18n.__("No results found.")+"</p></li>"),k(".spinner",n).removeClass("is-active"),c.addClass("has-no-menu-item"))},removeMenuItem:function(t){var n=t.childMenuItems();k(document).trigger("menu-removing-item",[t]),t.addClass("deleting").animate({opacity:0,height:0},350,function(){var e=k("#menu-instructions");t.remove(),n.shiftDepthClass(-1).updateParentMenuItemDBId(),0===k("#menu-to-edit li").length&&(k(".drag-instructions").hide(),e.removeClass("menu-instructions-inactive")),I.refreshAdvancedAccessibility(),wp.a11y.speak(menus.itemRemoved)})},depthToPx:function(e){return e*I.options.menuItemDepthPerLevel},pxToDepth:function(e){return Math.floor(e/I.options.menuItemDepthPerLevel)}};k(function(){wpNavMenu.init(),k(".menu-edit a, .menu-edit button, .menu-edit input, .menu-edit textarea, .menu-edit select").on("focus",function(){var e,t,n;783<=window.innerWidth&&(e=k("#nav-menu-footer").height()+20,0<(t=k(this).offset().top-(k(window).scrollTop()+k(window).height()-k(this).height()))&&(t=0),(t*=-1)<e)&&(n=k(document).scrollTop(),k(document).scrollTop(n+(e-t)))})}),k(document).on("menu-item-added",function(){k(".bulk-actions").is(":visible")||k(".bulk-actions").show()}),k(document).on("menu-removing-item",function(e,t){1===k(t).parents("#menu-to-edit").find("li").length&&k(".bulk-actions").is(":visible")&&k(".bulk-actions").hide()})}(jQuery);
\ No newline at end of file diff --git a/wp-admin/js/privacy-tools.js b/wp-admin/js/privacy-tools.js index e5fceb8..4e12939 100644 --- a/wp-admin/js/privacy-tools.js +++ b/wp-admin/js/privacy-tools.js @@ -47,7 +47,7 @@ jQuery( function( $ ) { $requestRow.after( function() { return '<tr class="' + resultRowClasses + '"><th colspan="5">' + - '<div class="notice inline notice-alt ' + classes + '">' + + '<div class="notice inline notice-alt ' + classes + '" role="alert">' + '<p>' + summaryMessage + '</p>' + itemList + '</div>' + diff --git a/wp-admin/js/privacy-tools.min.js b/wp-admin/js/privacy-tools.min.js index 41596c3..7e53cce 100644 --- a/wp-admin/js/privacy-tools.min.js +++ b/wp-admin/js/privacy-tools.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -jQuery(function(v){var r,h=wp.i18n.__;function w(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function x(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function T(e,t,a,o){var s="",n="request-results";x(e),o.length&&(v.each(o,function(e,t){s=s+"<li>"+t+"</li>"}),s="<ul>"+s+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(n+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(n+=" status-request-failed"),e.after(function(){return'<tr class="'+n+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+a+"</p>"+s+"</div></td></tr>"})}v(".export-personal-data-handle").on("click",function(e){var t=v(this),n=t.parents(".export-personal-data"),r=t.parents("tr"),a=r.find(".export-progress"),i=t.parents(".row-actions"),c=n.data("request-id"),d=n.data("nonce"),l=n.data("exporters-count"),u=!!n.data("send-as-email");function p(e){var t=h("An error occurred while attempting to export personal data.");w(n,"export-personal-data-failed"),e&&T(r,"notice-error",t,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){e=Math.round(100*(0<l?e/l:0)).toString()+"%";a.html(e)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),n.trigger("blur"),x(r),m(0),w(n,"export-personal-data-processing"),function t(o,s){v.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:o,id:c,page:s,security:d,sendAsEmail:u},method:"post"}).done(function(e){var a=e.data;e.success?a.done?(m(o),o<l?setTimeout(t(o+1,1)):setTimeout(function(){var e,t;e=a.url,t=h("This user’s personal data export link was sent."),void 0!==e&&(t=h("This user’s personal data export file was downloaded.")),w(n,"export-personal-data-success"),T(r,"notice-success",t,[]),void 0!==e?window.location=e:u||p(h("No personal data export file was generated.")),setTimeout(function(){i.removeClass("processing")},500)},500)):setTimeout(t(o,s+1)):setTimeout(function(){p(e.data)},500)}).fail(function(e,t,a){setTimeout(function(){p(a)},500)})}(1,1)}),v(".remove-personal-data-handle").on("click",function(e){var t=v(this),n=t.parents(".remove-personal-data"),r=t.parents("tr"),a=r.find(".erasure-progress"),i=t.parents(".row-actions"),c=n.data("request-id"),d=n.data("nonce"),l=n.data("erasers-count"),u=!1,p=!1,m=[];function f(){var e=h("An error occurred while attempting to find and erase personal data.");w(n,"remove-personal-data-failed"),T(r,"notice-error",e,[]),setTimeout(function(){i.removeClass("processing")},500)}function g(e){e=Math.round(100*(0<l?e/l:0)).toString()+"%";a.html(e)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),n.trigger("blur"),x(r),g(0),w(n,"remove-personal-data-processing"),function a(o,s){v.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:o,id:c,page:s,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(u=u||t.items_removed),t.items_retained&&(p=p||t.items_retained),t.messages&&(m=m.concat(t.messages)),t.done?(g(o),o<l?setTimeout(a(o+1,1)):setTimeout(function(){var e,t;e=h("No personal data was found for this user."),t="notice-success",w(n,"remove-personal-data-success"),!1===u?!1===p?e=h("No personal data was found for this user."):(e=h("Personal data was found for this user but was not erased."),t="notice-warning"):!1===p?e=h("All of the personal data found for this user was erased."):(e=h("Personal data was found for this user but some of the personal data found was not erased."),t="notice-warning"),T(r,t,e,m),setTimeout(function(){i.removeClass("processing")},500)},500)):setTimeout(a(o,s+1))):setTimeout(function(){f()},500)}).fail(function(){setTimeout(function(){f()},500)})}(1,1)}),v(document).on("click",function(e){var t,a,e=v(e.target),o=e.siblings(".success");if(clearTimeout(r),e.is("button.privacy-text-copy")&&(t=e.closest(".privacy-settings-accordion-panel")).length)try{var s=document.documentElement.scrollTop,n=document.body.scrollTop;window.getSelection().removeAllRanges(),a=document.createRange(),t.addClass("hide-privacy-policy-tutorial"),a.selectNodeContents(t[0]),window.getSelection().addRange(a),document.execCommand("copy"),t.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges(),0<s&&s!==document.documentElement.scrollTop?document.documentElement.scrollTop=s:0<n&&n!==document.body.scrollTop&&(document.body.scrollTop=n),o.addClass("visible"),wp.a11y.speak(h("The suggested policy text has been copied to your clipboard.")),r=setTimeout(function(){o.removeClass("visible")},3e3)}catch(e){}}),v("body.options-privacy-php label[for=create-page]").on("click",function(e){e.preventDefault(),v("input#create-page").trigger("focus")}),v(".privacy-settings-accordion").on("click",".privacy-settings-accordion-trigger",function(){"true"===v(this).attr("aria-expanded")?(v(this).attr("aria-expanded","false"),v("#"+v(this).attr("aria-controls")).attr("hidden",!0)):(v(this).attr("aria-expanded","true"),v("#"+v(this).attr("aria-controls")).attr("hidden",!1))})});
\ No newline at end of file +jQuery(function(v){var r,h=wp.i18n.__;function w(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function x(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function T(e,t,a,o){var s="",n="request-results";x(e),o.length&&(v.each(o,function(e,t){s=s+"<li>"+t+"</li>"}),s="<ul>"+s+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(n+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(n+=" status-request-failed"),e.after(function(){return'<tr class="'+n+'"><th colspan="5"><div class="notice inline notice-alt '+t+'" role="alert"><p>'+a+"</p>"+s+"</div></td></tr>"})}v(".export-personal-data-handle").on("click",function(e){var t=v(this),n=t.parents(".export-personal-data"),r=t.parents("tr"),a=r.find(".export-progress"),i=t.parents(".row-actions"),c=n.data("request-id"),d=n.data("nonce"),l=n.data("exporters-count"),u=!!n.data("send-as-email");function p(e){var t=h("An error occurred while attempting to export personal data.");w(n,"export-personal-data-failed"),e&&T(r,"notice-error",t,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){e=Math.round(100*(0<l?e/l:0)).toString()+"%";a.html(e)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),n.trigger("blur"),x(r),m(0),w(n,"export-personal-data-processing"),function t(o,s){v.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:o,id:c,page:s,security:d,sendAsEmail:u},method:"post"}).done(function(e){var a=e.data;e.success?a.done?(m(o),o<l?setTimeout(t(o+1,1)):setTimeout(function(){var e,t;e=a.url,t=h("This user’s personal data export link was sent."),void 0!==e&&(t=h("This user’s personal data export file was downloaded.")),w(n,"export-personal-data-success"),T(r,"notice-success",t,[]),void 0!==e?window.location=e:u||p(h("No personal data export file was generated.")),setTimeout(function(){i.removeClass("processing")},500)},500)):setTimeout(t(o,s+1)):setTimeout(function(){p(e.data)},500)}).fail(function(e,t,a){setTimeout(function(){p(a)},500)})}(1,1)}),v(".remove-personal-data-handle").on("click",function(e){var t=v(this),n=t.parents(".remove-personal-data"),r=t.parents("tr"),a=r.find(".erasure-progress"),i=t.parents(".row-actions"),c=n.data("request-id"),d=n.data("nonce"),l=n.data("erasers-count"),u=!1,p=!1,m=[];function f(){var e=h("An error occurred while attempting to find and erase personal data.");w(n,"remove-personal-data-failed"),T(r,"notice-error",e,[]),setTimeout(function(){i.removeClass("processing")},500)}function g(e){e=Math.round(100*(0<l?e/l:0)).toString()+"%";a.html(e)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),n.trigger("blur"),x(r),g(0),w(n,"remove-personal-data-processing"),function a(o,s){v.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:o,id:c,page:s,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(u=u||t.items_removed),t.items_retained&&(p=p||t.items_retained),t.messages&&(m=m.concat(t.messages)),t.done?(g(o),o<l?setTimeout(a(o+1,1)):setTimeout(function(){var e,t;e=h("No personal data was found for this user."),t="notice-success",w(n,"remove-personal-data-success"),!1===u?!1===p?e=h("No personal data was found for this user."):(e=h("Personal data was found for this user but was not erased."),t="notice-warning"):!1===p?e=h("All of the personal data found for this user was erased."):(e=h("Personal data was found for this user but some of the personal data found was not erased."),t="notice-warning"),T(r,t,e,m),setTimeout(function(){i.removeClass("processing")},500)},500)):setTimeout(a(o,s+1))):setTimeout(function(){f()},500)}).fail(function(){setTimeout(function(){f()},500)})}(1,1)}),v(document).on("click",function(e){var t,a,e=v(e.target),o=e.siblings(".success");if(clearTimeout(r),e.is("button.privacy-text-copy")&&(t=e.closest(".privacy-settings-accordion-panel")).length)try{var s=document.documentElement.scrollTop,n=document.body.scrollTop;window.getSelection().removeAllRanges(),a=document.createRange(),t.addClass("hide-privacy-policy-tutorial"),a.selectNodeContents(t[0]),window.getSelection().addRange(a),document.execCommand("copy"),t.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges(),0<s&&s!==document.documentElement.scrollTop?document.documentElement.scrollTop=s:0<n&&n!==document.body.scrollTop&&(document.body.scrollTop=n),o.addClass("visible"),wp.a11y.speak(h("The suggested policy text has been copied to your clipboard.")),r=setTimeout(function(){o.removeClass("visible")},3e3)}catch(e){}}),v("body.options-privacy-php label[for=create-page]").on("click",function(e){e.preventDefault(),v("input#create-page").trigger("focus")}),v(".privacy-settings-accordion").on("click",".privacy-settings-accordion-trigger",function(){"true"===v(this).attr("aria-expanded")?(v(this).attr("aria-expanded","false"),v("#"+v(this).attr("aria-controls")).attr("hidden",!0)):(v(this).attr("aria-expanded","true"),v("#"+v(this).attr("aria-controls")).attr("hidden",!1))})});
\ No newline at end of file diff --git a/wp-admin/js/theme-plugin-editor.js b/wp-admin/js/theme-plugin-editor.js index 8871b04..2fd8665 100644 --- a/wp-admin/js/theme-plugin-editor.js +++ b/wp-admin/js/theme-plugin-editor.js @@ -191,7 +191,7 @@ wp.themePluginEditor = (function( $ ) { return; } - // Scroll ot the line that has the error. + // Scroll to the line that has the error. if ( component.lintErrors.length ) { component.instance.codemirror.setCursor( component.lintErrors[0].from.line ); return; diff --git a/wp-admin/js/theme.js b/wp-admin/js/theme.js index 13ed5aa..65b5b4c 100644 --- a/wp-admin/js/theme.js +++ b/wp-admin/js/theme.js @@ -96,7 +96,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ }, // Defines search element container. - searchContainer: $( '.search-form' ), + searchContainer: $( '.search-form .search-box' ), // Search input and view // for current theme collection. @@ -118,7 +118,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ // Render and append after screen title. view.render(); this.searchContainer - .append( $.parseHTML( '<label class="screen-reader-text" for="wp-filter-search-input">' + l10n.search + '</label>' ) ) + .append( $.parseHTML( '<label for="wp-filter-search-input">' + l10n.search + '</label>' ) ) .append( view.el ) .on( 'submit', function( event ) { event.preventDefault(); @@ -926,7 +926,7 @@ themes.view.Preview = themes.view.Details.extend({ currentPreviewDevice = this.$el.data( 'current-preview-device' ); if ( currentPreviewDevice ) { - self.tooglePreviewDeviceButtons( currentPreviewDevice ); + self.togglePreviewDeviceButtons( currentPreviewDevice ); } themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: false } ); @@ -988,10 +988,10 @@ themes.view.Preview = themes.view.Details.extend({ .addClass( 'preview-' + device ) .data( 'current-preview-device', device ); - this.tooglePreviewDeviceButtons( device ); + this.togglePreviewDeviceButtons( device ); }, - tooglePreviewDeviceButtons: function( newDevice ) { + togglePreviewDeviceButtons: function( newDevice ) { var $devices = $( '.wp-full-overlay-footer .devices' ); $devices.find( 'button' ) @@ -1359,7 +1359,6 @@ themes.view.Search = wp.Backbone.View.extend({ searching: false, attributes: { - placeholder: l10n.searchPlaceholder, type: 'search', 'aria-describedby': 'live-search-desc' }, diff --git a/wp-admin/js/theme.min.js b/wp-admin/js/theme.min.js index 8f26e38..e8745ff 100644 --- a/wp-admin/js/theme.min.js +++ b/wp-admin/js/theme.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.wp=window.wp||{},function(n){var o,a;function e(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}(o=wp.themes=wp.themes||{}).data=_wpThemeSettings,a=o.data.l10n,o.isInstall=!!o.data.settings.isInstall,_.extend(o,{model:{},view:{},routes:{},router:{},template:wp.template}),o.Model=Backbone.Model.extend({initialize:function(){var e;this.get("slug")&&(-1!==_.indexOf(o.data.installedThemes,this.get("slug"))&&this.set({installed:!0}),o.data.activeTheme===this.get("slug"))&&this.set({active:!0}),this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e}))}}),o.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:n(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView||o.view.Search,this.window.on("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new o.view.Themes({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:n(".search-form"),search:function(){var e;1!==o.data.themes.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(n.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+a.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e=this,t=this.window.scrollTop()+e.window.height(),e=e.$el.offset().top+e.$el.outerHeight(!1)-e.window.height();Math.round(.9*e)<t&&this.trigger("theme:scroll")}}),o.Collection=Backbone.Collection.extend({model:o.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(o.data.themes),n("body").removeClass("no-results")),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(o.data.themes,{silent:!0}),t=(t=(t=t.trim()).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return s=e.get("name").replace(/(<([^>]+)>)/gi,""),r=e.get("description").replace(/(<([^>]+)>)/gi,""),a=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([s,e.get("id"),r,a,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):n("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(20*e)),t=_(t.first(20))},count:!1,query:function(t){var e,i,s,r=this.queries,a=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){a.add(e.themes),a.trigger("query:success"),a.loadingThemes=!1}).fail(function(){a.trigger("query:fail")});0===e.themes.length?a.trigger("query:empty"):n("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.themes),e.total||(this.count=this.length),this.trigger("themes:update"),this.trigger("query:success",this.count)}else this.apiCall(t).done(function(e){e.themes&&(a.reset(e.themes),s=e.info.results,r.push({themes:e.themes,request:t,total:s})),a.trigger("themes:update"),a.trigger("query:success",s),e.themes&&0===e.themes.length&&a.trigger("query:empty")}).fail(function(){a.trigger("query:fail")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-themes",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||n("body").addClass("loading-content").removeClass("no-results")}})},loadingThemes:!1}),o.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:o.template("theme"),events:{click:o.isInstall?"preview":"expand",keydown:o.isInstall?"preview":"expand",touchend:o.isInstall?"preview":"expand",keyup:"addFocus",touchmove:"preventExpand","click .theme-install":"installTheme","click .update-message":"updateTheme"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr("data-slug",e.id),this.activeTheme(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeTheme:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var e=n(":focus").hasClass("theme")?n(":focus"):n(":focus").parents(".theme");n(".theme.focus").removeClass("focus"),e.addClass("focus")},expand:function(e){if("keydown"!==(e=e||window.event).type||13===e.which||32===e.which)return!0===this.touchDrag?this.touchDrag=!1:void(n(e.target).is(".theme-actions a")||n(e.target).is(".theme-actions a, .update-message, .button-link, .notice-dismiss")||(o.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid)))},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,s=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;n(e.target).not(".install-theme-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&n(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,o.focusedTheme=this.$el,o.preview=i=new o.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),n("div.wrap").append(i.el),this.listenTo(i,"theme:next",function(){if(t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("theme:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),n(".next-theme").trigger("focus")}).listenTo(i,"theme:previous",function(){t=s.model,0===s.model.collection.indexOf(s.current)||(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current))||(i.model=s.current,i.render(),this.setNavButtonsState(),n(".previous-theme").trigger("focus"))}),this.listenTo(i,"preview:close",function(){s.current=s.model}))},setNavButtonsState:function(){var e=n(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),e=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),e.trigger("focus")),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(e.addClass("disabled").prop("disabled",!0),i.trigger("focus"))},installTheme:function(e){var i=this;e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-install-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({installed:!0}),t.blockTheme&&i.model.set({block_theme:!0})}),wp.updates.installTheme({slug:n(e.target).data("slug")})},updateTheme:function(e){var i=this;this.model.get("hasPackage")&&(e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-update-success",function(e,t){i.model.off("change",i.render,i),i.model.get("id")===t.slug&&i.model.set({hasUpdate:!1,version:t.newVersion}),i.model.on("change",i.render,i)}),wp.updates.updateTheme({slug:n(e.target).parents("div.theme").first().data("slug")}))}}),o.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-theme":"deleteTheme","click .left":"previousTheme","click .right":"nextTheme","click #update-theme":"updateTheme","click .toggle-auto-update":"autoupdateState"},html:o.template("theme-single"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),this.activeTheme(),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el)},activeTheme:function(){this.$el.toggleClass("active",this.model.get("active"))},containFocus:function(s){_.delay(function(){n(".theme-overlay").trigger("focus")},100),s.on("keydown.wp-themes",function(e){var t=s.find(".theme-header button:not(.disabled)").first(),i=s.find(".theme-actions a:visible").last();9===e.which&&(t[0]===e.target&&e.shiftKey?(i.trigger("focus"),e.preventDefault()):i[0]!==e.target||e.shiftKey||(t.trigger("focus"),e.preventDefault()))})},collapse:function(e){var t,i=this;e=e||window.event,1!==o.data.themes.length&&(n(e.target).is(".theme-backdrop")||n(e.target).is(".close")||27===e.keyCode)&&(n("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){n("body").removeClass("closing-overlay"),i.closeOverlay(),t=document.body.scrollTop,o.router.navigate(o.router.baseUrl("")),document.body.scrollTop=t,o.focusedTheme&&o.focusedTheme.find(".more-details").trigger("focus")}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled").prop("disabled",!0),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled").prop("disabled",!0)},closeOverlay:function(){n("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("theme:collapse")},autoupdateState:function(){var s=this,r=function(e,t){var i;s.model.get("id")===t.asset&&((i=s.model.get("autoupdate")).enabled="enable"===t.state,s.model.set({autoupdate:i}),n(document).off("wp-auto-update-setting-changed",r))};n(document).on("wp-auto-update-setting-changed",r)},updateTheme:function(e){var i=this;e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-update-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({hasUpdate:!1,version:t.newVersion}),i.render()}),wp.updates.updateTheme({slug:n(e.target).data("slug")})},deleteTheme:function(e){var i=this,s=i.model.collection,r=o;e.preventDefault(),window.confirm(wp.themes.data.settings.confirmDelete)&&(wp.updates.maybeRequestFilesystemCredentials(e),n(document).one("wp-theme-delete-success",function(e,t){i.$el.find(".close").trigger("click"),n('[data-slug="'+t.slug+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){n(this).remove(),r.data.themes=_.without(r.data.themes,_.findWhere(r.data.themes,{id:t.slug})),n(".wp-filter-search").val(""),s.doSearch(""),s.remove(i.model),s.trigger("themes:update")})}),wp.updates.deleteTheme({slug:this.model.get("id")}))},nextTheme:function(){return this.trigger("theme:next",this.model.cid),!1},previousTheme:function(){return this.trigger("theme:previous",this.model.cid),!1},screenshotCheck:function(e){var t=e.find(".screenshot img"),i=new Image;i.src=t.attr("src"),i.width&&i.width<=300&&e.addClass("small-screenshot")}}),o.view.Preview=o.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousTheme","click .next-theme":"nextTheme",keyup:"keyEvent","click .theme-install":"installTheme"},html:o.template("theme-preview"),render:function(){var e=this,t=this.model.toJSON(),i=n(document.body);i.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(t)),(t=this.$el.data("current-preview-device"))&&e.tooglePreviewDeviceButtons(t),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){i.addClass("theme-installer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){e.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),n(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){n("body").removeClass("theme-installer-active full-overlay-active"),o.focusedTheme&&o.focusedTheme.find(".more-details").trigger("focus")}).removeClass("iframe-ready"),o.router.selectedTab?(o.router.navigate(o.router.baseUrl("?browse="+o.router.selectedTab)),o.router.selectedTab=!1):o.router.navigate(o.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){e=n(e.currentTarget);return"true"===e.attr("aria-expanded")?e.attr({"aria-expanded":"false","aria-label":a.expandSidebar}):e.attr({"aria-expanded":"true","aria-label":a.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){e=n(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+e).data("current-preview-device",e),this.tooglePreviewDeviceButtons(e)},tooglePreviewDeviceButtons:function(e){var t=n(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextTheme()),37===e.keyCode&&this.previousTheme()},installTheme:function(e){var t=this,i=n(e.target);e.preventDefault(),i.hasClass("disabled")||(wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-install-success",function(){t.model.set({installed:!0})}),wp.updates.installTheme({slug:i.data("slug")}))}}),o.view.Themes=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:n("div.theme-overlay"),index:0,count:n(".wrap .theme-count"),liveThemeCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.currentTheme(),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.currentTheme(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){n("body").addClass("no-results")}),this.listenTo(this.parent,"theme:scroll",function(){t.renderThemes(t.parent.page)}),this.listenTo(this.parent,"theme:close",function(){t.overlay&&t.overlay.closeOverlay()}),n("body").on("keyup",function(e){!t.overlay||n("#request-filesystem-credentials-dialog").is(":visible")||(39===e.keyCode&&t.overlay.nextTheme(),37===e.keyCode&&t.overlay.previousTheme(),27===e.keyCode&&t.overlay.collapse(e))})},render:function(){this.$el.empty(),1===o.data.themes.length&&(this.singleTheme=new o.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),0<this.options.collection.size()&&this.renderThemes(this.parent.page),this.liveThemeCount=this.collection.count||this.collection.length,this.count.text(this.liveThemeCount),o.isInstall||this.announceSearchResults(this.liveThemeCount)},renderThemes:function(e){var t=this;t.instance=t.collection.paginate(e),0===t.instance.size()?this.parent.trigger("theme:end"):(!o.isInstall&&1<=e&&n(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new o.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,"theme:expand",t.expand,t)}),!o.isInstall&&o.data.settings.canInstall&&this.$el.append('<div class="theme add-new-theme"><a href="'+o.data.settings.installURI+'"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+a.addNew+"</h2></a></div>"),this.parent.page++)},currentTheme:function(){var e=this.collection.findWhere({active:!0});e&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},expand:function(e){var t,i=this;this.model=i.collection.get(e),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.id)),this.setView("detail"),n("body").addClass("modal-open"),this.overlay=new o.view.Details({model:i.model}),this.overlay.render(),this.model.get("hasUpdate")&&(e=n('[data-slug="'+this.model.id+'"]'),t=n(this.overlay.el),e.find(".updating-message").length?(t.find(".notice-warning h3").remove(),t.find(".notice-warning").removeClass("notice-large").addClass("updating-message").find("p").text(wp.updates.l10n.updating)):e.find(".notice-error").length&&t.find(".notice-warning").remove()),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){i.next([i.model.cid])}).listenTo(this.overlay,"theme:previous",function(){i.previous([i.model.cid])})},next:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&(this.overlay.closeOverlay(),this.theme.trigger("theme:expand",e.cid))},previous:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)-1);void 0!==e&&(this.overlay.closeOverlay(),this.theme.trigger("theme:expand",e.cid))},announceSearchResults:function(e){0===e?wp.a11y.speak(a.noThemesFound):wp.a11y.speak(a.themesFound.replace("%d",e))}}),o.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:a.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?o.router.navigate(o.router.baseUrl(o.router.searchPath+e.target.value),t):o.router.navigate(o.router.baseUrl(""))},pushState:function(e){var t=o.router.baseUrl("");e.target.value&&(t=o.router.baseUrl(o.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,o.router.navigate(t)}}),o.Router=Backbone.Router.extend({routes:{"themes.php?theme=:slug":"theme","themes.php?search=:query":"search","themes.php?s=:query":"search","themes.php":"themes","":"themes"},baseUrl:function(e){return"themes.php"+e},themePath:"?theme=",searchPath:"?search=",search:function(e){n(".wp-filter-search").val(e.replace(/\+/g," "))},themes:function(){n(".wp-filter-search").val("")},navigate:e}),o.Run={init:function(){this.themes=new o.Collection(o.data.themes),this.view=new o.view.Appearance({collection:this.themes}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:o.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this;o.router=new o.Router,o.router.on("route:theme",function(e){t.view.view.expand(e)}),o.router.on("route:themes",function(){t.themes.doSearch(""),t.view.trigger("theme:close")}),o.router.on("route:search",function(){n(".wp-filter-search").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},o.view.InstallerSearch=o.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e.target.value))},doSearch:function(e){var t={};this.terms!==e&&(this.terms=e,"author:"===(t.search=e).substring(0,7)&&(t.search="",t.author=e.slice(7)),"tag:"===e.substring(0,4)&&(t.search="",t.tag=[e.slice(4)]),n(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),n("body").removeClass("show-filters filters-applied show-favorites-form"),n(".drawer-toggle").attr("aria-expanded","false"),this.collection.query(t),o.router.navigate(o.router.baseUrl(o.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),o.view.Installer=o.view.Appearance.extend({el:"#wpbody-content .wrap",events:{"click .filter-links li > a":"onSort","click .theme-filter":"onFilter","click .drawer-toggle":"moreFilters","click .filter-drawer .apply-filters":"applyFilters",'click .filter-group [type="checkbox"]':"addFilter","click .filter-drawer .clear-filters":"clearFilters","click .edit-filters":"backToFilters","click .favorites-form-submit":"saveUsername","keyup #wporg-username-input":"saveUsername"},render:function(){var e=this;this.search(),this.uploader(),this.collection=new o.Collection,this.listenTo(this,"theme:end",function(){e.collection.loadingThemes||(e.collection.loadingThemes=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove()}),this.listenTo(this.collection,"query:fail",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),n(".theme-browser").find("div.themes").before('<div class="error"><p>'+a.error+'</p><p><button class="button try-again">'+a.tryAgain+"</button></p></div>"),n(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),n("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new o.view.Themes({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e){"block-themes"===e?this.collection.query({tag:"full-site-editing"}):this.collection.query({browse:e})},onSort:function(e){var t=n(e.target),i=t.data("sort");e.preventDefault(),n("body").removeClass("filters-applied show-filters"),n(".drawer-toggle").attr("aria-expanded","false"),t.hasClass(this.activeClass)||(this.sort(i),o.router.navigate(o.router.baseUrl(o.router.browsePath+i)))},sort:function(e){this.clearSearch(),o.router.selectedTab=e,n(".filter-links li > a, .theme-filter").removeClass(this.activeClass).removeAttr("aria-current"),n('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),"favorites"===e?n("body").addClass("show-favorites-form"):n("body").removeClass("show-favorites-form"),this.browse(e)},onFilter:function(e){var e=n(e.target),t=e.data("filter");e.hasClass(this.activeClass)||(n(".filter-links li > a, .theme-section").removeClass(this.activeClass).removeAttr("aria-current"),e.addClass(this.activeClass).attr("aria-current","page"),t&&(t=_.union([t,this.filtersChecked()]),this.collection.query({tag:[t]})))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=this.filtersChecked(),s={tag:i},r=n(".filtered-by .tags");e&&e.preventDefault(),i?(n("body").addClass("filters-applied"),n(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),r.empty(),_.each(i,function(e){t=n('label[for="filter-id-'+e+'"]').text(),r.append('<span class="tag">'+t+"</span>")}),this.collection.query(s)):wp.a11y.speak(a.selectFeatureFilter)},saveUsername:function(e){var t=n("#wporg-username-input").val(),i=n("#wporg-username-nonce").val(),s={browse:"favorites",user:t},r=this;if(e&&e.preventDefault(),"keyup"!==e.type||13===e.which)return wp.ajax.send("save-wporg-username",{data:{_wpnonce:i,username:t},success:function(){r.collection.query(s)}})},filtersChecked:function(){var e=n(".filter-group").find(":checkbox"),t=[];return _.each(e.filter(":checked"),function(e){t.push(n(e).prop("value"))}),0===t.length?(n(".filter-drawer .apply-filters").find("span").text(""),n(".filter-drawer .clear-filters").hide(),n("body").removeClass("filters-applied"),!1):(n(".filter-drawer .apply-filters").find("span").text(t.length),n(".filter-drawer .clear-filters").css("display","inline-block"),t)},activeClass:"current",uploader:function(){var e=n(".upload-view-toggle"),t=n(document.body);e.on("click",function(){t.toggleClass("show-upload-view"),e.attr("aria-expanded",t.hasClass("show-upload-view"))})},moreFilters:function(e){var t=n("body"),i=n(".drawer-toggle");if(e.preventDefault(),t.hasClass("filters-applied"))return this.backToFilters();this.clearSearch(),o.router.navigate(o.router.baseUrl("")),t.toggleClass("show-filters"),i.attr("aria-expanded",t.hasClass("show-filters"))},clearFilters:function(e){var t=n(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return n(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),n("body").removeClass("filters-applied")},clearSearch:function(){n("#wp-filter-search-input").val("")}}),o.InstallerRouter=Backbone.Router.extend({routes:{"theme-install.php?theme=:slug":"preview","theme-install.php?browse=:sort":"sort","theme-install.php?search=:query":"search","theme-install.php":"sort"},baseUrl:function(e){return"theme-install.php"+e},themePath:"?theme=",browsePath:"?browse=",searchPath:"?search=",search:function(e){n(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:e}),o.RunInstaller={init:function(){this.view=new o.view.Installer({section:"popular",SearchView:o.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:o.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this,i={};o.router=new o.InstallerRouter,o.router.on("route:preview",function(e){o.preview&&(o.preview.undelegateEvents(),o.preview.unbind()),t.view.view.theme&&t.view.view.theme.preview?(t.view.view.theme.model=t.view.collection.findWhere({slug:e}),t.view.view.theme.preview()):(i.theme=e,t.view.collection.query(i),t.view.collection.trigger("update"),t.view.collection.once("query:success",function(){n('div[data-slug="'+e+'"]').trigger("click")}))}),o.router.on("route:sort",function(e){e||(e="popular",o.router.navigate(o.router.baseUrl("?browse=popular"),{replace:!0})),t.view.sort(e),o.preview&&o.preview.close()}),o.router.on("route:search",function(){n(".wp-filter-search").trigger("focus").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},n(function(){(o.isInstall?o.RunInstaller:o.Run).init(),n(document.body).on("click",".load-customize",function(){var e=n(this),t=document.createElement("a");t.href=e.prop("href"),t.search=n.param(_.extend(wp.customize.utils.parseQueryString(t.search.substr(1)),{return:window.location.href})),e.prop("href",t.href)}),n(".broken-themes .delete-theme").on("click",function(){return confirm(_wpThemeSettings.settings.confirmDelete)})})}(jQuery),jQuery(function(r){window.tb_position=function(){var e=r("#TB_window"),t=r(window).width(),i=r(window).height(),t=1040<t?1040:t,s=0;r("#wpadminbar").length&&(s=parseInt(r("#wpadminbar").css("height"),10)),1<=e.length&&(e.width(t-50).height(i-45-s),r("#TB_iframeContent").width(t-50).height(i-75-s),e.css({"margin-left":"-"+parseInt((t-50)/2,10)+"px"}),void 0!==document.body.style.maxWidth)&&e.css({top:20+s+"px","margin-top":"0"})},r(window).on("resize",function(){tb_position()})});
\ No newline at end of file +window.wp=window.wp||{},function(n){var o,a;function e(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}(o=wp.themes=wp.themes||{}).data=_wpThemeSettings,a=o.data.l10n,o.isInstall=!!o.data.settings.isInstall,_.extend(o,{model:{},view:{},routes:{},router:{},template:wp.template}),o.Model=Backbone.Model.extend({initialize:function(){var e;this.get("slug")&&(-1!==_.indexOf(o.data.installedThemes,this.get("slug"))&&this.set({installed:!0}),o.data.activeTheme===this.get("slug"))&&this.set({active:!0}),this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e}))}}),o.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:n(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView||o.view.Search,this.window.on("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new o.view.Themes({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:n(".search-form .search-box"),search:function(){var e;1!==o.data.themes.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(n.parseHTML('<label for="wp-filter-search-input">'+a.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e=this,t=this.window.scrollTop()+e.window.height(),e=e.$el.offset().top+e.$el.outerHeight(!1)-e.window.height();Math.round(.9*e)<t&&this.trigger("theme:scroll")}}),o.Collection=Backbone.Collection.extend({model:o.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(o.data.themes),n("body").removeClass("no-results")),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(o.data.themes,{silent:!0}),t=(t=(t=t.trim()).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return s=e.get("name").replace(/(<([^>]+)>)/gi,""),r=e.get("description").replace(/(<([^>]+)>)/gi,""),a=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([s,e.get("id"),r,a,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):n("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(20*e)),t=_(t.first(20))},count:!1,query:function(t){var e,i,s,r=this.queries,a=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){a.add(e.themes),a.trigger("query:success"),a.loadingThemes=!1}).fail(function(){a.trigger("query:fail")});0===e.themes.length?a.trigger("query:empty"):n("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.themes),e.total||(this.count=this.length),this.trigger("themes:update"),this.trigger("query:success",this.count)}else this.apiCall(t).done(function(e){e.themes&&(a.reset(e.themes),s=e.info.results,r.push({themes:e.themes,request:t,total:s})),a.trigger("themes:update"),a.trigger("query:success",s),e.themes&&0===e.themes.length&&a.trigger("query:empty")}).fail(function(){a.trigger("query:fail")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-themes",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||n("body").addClass("loading-content").removeClass("no-results")}})},loadingThemes:!1}),o.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:o.template("theme"),events:{click:o.isInstall?"preview":"expand",keydown:o.isInstall?"preview":"expand",touchend:o.isInstall?"preview":"expand",keyup:"addFocus",touchmove:"preventExpand","click .theme-install":"installTheme","click .update-message":"updateTheme"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr("data-slug",e.id),this.activeTheme(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeTheme:function(){this.model.get("active")&&this.$el.addClass("active")},addFocus:function(){var e=n(":focus").hasClass("theme")?n(":focus"):n(":focus").parents(".theme");n(".theme.focus").removeClass("focus"),e.addClass("focus")},expand:function(e){if("keydown"!==(e=e||window.event).type||13===e.which||32===e.which)return!0===this.touchDrag?this.touchDrag=!1:void(n(e.target).is(".theme-actions a")||n(e.target).is(".theme-actions a, .update-message, .button-link, .notice-dismiss")||(o.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid)))},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,s=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;n(e.target).not(".install-theme-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&n(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,o.focusedTheme=this.$el,o.preview=i=new o.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),n("div.wrap").append(i.el),this.listenTo(i,"theme:next",function(){if(t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("theme:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),n(".next-theme").trigger("focus")}).listenTo(i,"theme:previous",function(){t=s.model,0===s.model.collection.indexOf(s.current)||(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current))||(i.model=s.current,i.render(),this.setNavButtonsState(),n(".previous-theme").trigger("focus"))}),this.listenTo(i,"preview:close",function(){s.current=s.model}))},setNavButtonsState:function(){var e=n(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),e=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),e.trigger("focus")),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(e.addClass("disabled").prop("disabled",!0),i.trigger("focus"))},installTheme:function(e){var i=this;e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-install-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({installed:!0}),t.blockTheme&&i.model.set({block_theme:!0})}),wp.updates.installTheme({slug:n(e.target).data("slug")})},updateTheme:function(e){var i=this;this.model.get("hasPackage")&&(e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-update-success",function(e,t){i.model.off("change",i.render,i),i.model.get("id")===t.slug&&i.model.set({hasUpdate:!1,version:t.newVersion}),i.model.on("change",i.render,i)}),wp.updates.updateTheme({slug:n(e.target).parents("div.theme").first().data("slug")}))}}),o.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-theme":"deleteTheme","click .left":"previousTheme","click .right":"nextTheme","click #update-theme":"updateTheme","click .toggle-auto-update":"autoupdateState"},html:o.template("theme-single"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),this.activeTheme(),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el)},activeTheme:function(){this.$el.toggleClass("active",this.model.get("active"))},containFocus:function(s){_.delay(function(){n(".theme-overlay").trigger("focus")},100),s.on("keydown.wp-themes",function(e){var t=s.find(".theme-header button:not(.disabled)").first(),i=s.find(".theme-actions a:visible").last();9===e.which&&(t[0]===e.target&&e.shiftKey?(i.trigger("focus"),e.preventDefault()):i[0]!==e.target||e.shiftKey||(t.trigger("focus"),e.preventDefault()))})},collapse:function(e){var t,i=this;e=e||window.event,1!==o.data.themes.length&&(n(e.target).is(".theme-backdrop")||n(e.target).is(".close")||27===e.keyCode)&&(n("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){n("body").removeClass("closing-overlay"),i.closeOverlay(),t=document.body.scrollTop,o.router.navigate(o.router.baseUrl("")),document.body.scrollTop=t,o.focusedTheme&&o.focusedTheme.find(".more-details").trigger("focus")}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled").prop("disabled",!0),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled").prop("disabled",!0)},closeOverlay:function(){n("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("theme:collapse")},autoupdateState:function(){var s=this,r=function(e,t){var i;s.model.get("id")===t.asset&&((i=s.model.get("autoupdate")).enabled="enable"===t.state,s.model.set({autoupdate:i}),n(document).off("wp-auto-update-setting-changed",r))};n(document).on("wp-auto-update-setting-changed",r)},updateTheme:function(e){var i=this;e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-update-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({hasUpdate:!1,version:t.newVersion}),i.render()}),wp.updates.updateTheme({slug:n(e.target).data("slug")})},deleteTheme:function(e){var i=this,s=i.model.collection,r=o;e.preventDefault(),window.confirm(wp.themes.data.settings.confirmDelete)&&(wp.updates.maybeRequestFilesystemCredentials(e),n(document).one("wp-theme-delete-success",function(e,t){i.$el.find(".close").trigger("click"),n('[data-slug="'+t.slug+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){n(this).remove(),r.data.themes=_.without(r.data.themes,_.findWhere(r.data.themes,{id:t.slug})),n(".wp-filter-search").val(""),s.doSearch(""),s.remove(i.model),s.trigger("themes:update")})}),wp.updates.deleteTheme({slug:this.model.get("id")}))},nextTheme:function(){return this.trigger("theme:next",this.model.cid),!1},previousTheme:function(){return this.trigger("theme:previous",this.model.cid),!1},screenshotCheck:function(e){var t=e.find(".screenshot img"),i=new Image;i.src=t.attr("src"),i.width&&i.width<=300&&e.addClass("small-screenshot")}}),o.view.Preview=o.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousTheme","click .next-theme":"nextTheme",keyup:"keyEvent","click .theme-install":"installTheme"},html:o.template("theme-preview"),render:function(){var e=this,t=this.model.toJSON(),i=n(document.body);i.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(t)),(t=this.$el.data("current-preview-device"))&&e.togglePreviewDeviceButtons(t),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){i.addClass("theme-installer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){e.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),n(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){n("body").removeClass("theme-installer-active full-overlay-active"),o.focusedTheme&&o.focusedTheme.find(".more-details").trigger("focus")}).removeClass("iframe-ready"),o.router.selectedTab?(o.router.navigate(o.router.baseUrl("?browse="+o.router.selectedTab)),o.router.selectedTab=!1):o.router.navigate(o.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){e=n(e.currentTarget);return"true"===e.attr("aria-expanded")?e.attr({"aria-expanded":"false","aria-label":a.expandSidebar}):e.attr({"aria-expanded":"true","aria-label":a.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){e=n(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+e).data("current-preview-device",e),this.togglePreviewDeviceButtons(e)},togglePreviewDeviceButtons:function(e){var t=n(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextTheme()),37===e.keyCode&&this.previousTheme()},installTheme:function(e){var t=this,i=n(e.target);e.preventDefault(),i.hasClass("disabled")||(wp.updates.maybeRequestFilesystemCredentials(e),n(document).on("wp-theme-install-success",function(){t.model.set({installed:!0})}),wp.updates.installTheme({slug:i.data("slug")}))}}),o.view.Themes=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:n("div.theme-overlay"),index:0,count:n(".wrap .theme-count"),liveThemeCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.currentTheme(),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.currentTheme(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){n("body").addClass("no-results")}),this.listenTo(this.parent,"theme:scroll",function(){t.renderThemes(t.parent.page)}),this.listenTo(this.parent,"theme:close",function(){t.overlay&&t.overlay.closeOverlay()}),n("body").on("keyup",function(e){!t.overlay||n("#request-filesystem-credentials-dialog").is(":visible")||(39===e.keyCode&&t.overlay.nextTheme(),37===e.keyCode&&t.overlay.previousTheme(),27===e.keyCode&&t.overlay.collapse(e))})},render:function(){this.$el.empty(),1===o.data.themes.length&&(this.singleTheme=new o.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),0<this.options.collection.size()&&this.renderThemes(this.parent.page),this.liveThemeCount=this.collection.count||this.collection.length,this.count.text(this.liveThemeCount),o.isInstall||this.announceSearchResults(this.liveThemeCount)},renderThemes:function(e){var t=this;t.instance=t.collection.paginate(e),0===t.instance.size()?this.parent.trigger("theme:end"):(!o.isInstall&&1<=e&&n(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new o.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,"theme:expand",t.expand,t)}),!o.isInstall&&o.data.settings.canInstall&&this.$el.append('<div class="theme add-new-theme"><a href="'+o.data.settings.installURI+'"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+a.addNew+"</h2></a></div>"),this.parent.page++)},currentTheme:function(){var e=this.collection.findWhere({active:!0});e&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},expand:function(e){var t,i=this;this.model=i.collection.get(e),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.id)),this.setView("detail"),n("body").addClass("modal-open"),this.overlay=new o.view.Details({model:i.model}),this.overlay.render(),this.model.get("hasUpdate")&&(e=n('[data-slug="'+this.model.id+'"]'),t=n(this.overlay.el),e.find(".updating-message").length?(t.find(".notice-warning h3").remove(),t.find(".notice-warning").removeClass("notice-large").addClass("updating-message").find("p").text(wp.updates.l10n.updating)):e.find(".notice-error").length&&t.find(".notice-warning").remove()),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){i.next([i.model.cid])}).listenTo(this.overlay,"theme:previous",function(){i.previous([i.model.cid])})},next:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&(this.overlay.closeOverlay(),this.theme.trigger("theme:expand",e.cid))},previous:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)-1);void 0!==e&&(this.overlay.closeOverlay(),this.theme.trigger("theme:expand",e.cid))},announceSearchResults:function(e){0===e?wp.a11y.speak(a.noThemesFound):wp.a11y.speak(a.themesFound.replace("%d",e))}}),o.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?o.router.navigate(o.router.baseUrl(o.router.searchPath+e.target.value),t):o.router.navigate(o.router.baseUrl(""))},pushState:function(e){var t=o.router.baseUrl("");e.target.value&&(t=o.router.baseUrl(o.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,o.router.navigate(t)}}),o.Router=Backbone.Router.extend({routes:{"themes.php?theme=:slug":"theme","themes.php?search=:query":"search","themes.php?s=:query":"search","themes.php":"themes","":"themes"},baseUrl:function(e){return"themes.php"+e},themePath:"?theme=",searchPath:"?search=",search:function(e){n(".wp-filter-search").val(e.replace(/\+/g," "))},themes:function(){n(".wp-filter-search").val("")},navigate:e}),o.Run={init:function(){this.themes=new o.Collection(o.data.themes),this.view=new o.view.Appearance({collection:this.themes}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:o.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this;o.router=new o.Router,o.router.on("route:theme",function(e){t.view.view.expand(e)}),o.router.on("route:themes",function(){t.themes.doSearch(""),t.view.trigger("theme:close")}),o.router.on("route:search",function(){n(".wp-filter-search").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},o.view.InstallerSearch=o.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e.target.value))},doSearch:function(e){var t={};this.terms!==e&&(this.terms=e,"author:"===(t.search=e).substring(0,7)&&(t.search="",t.author=e.slice(7)),"tag:"===e.substring(0,4)&&(t.search="",t.tag=[e.slice(4)]),n(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),n("body").removeClass("show-filters filters-applied show-favorites-form"),n(".drawer-toggle").attr("aria-expanded","false"),this.collection.query(t),o.router.navigate(o.router.baseUrl(o.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),o.view.Installer=o.view.Appearance.extend({el:"#wpbody-content .wrap",events:{"click .filter-links li > a":"onSort","click .theme-filter":"onFilter","click .drawer-toggle":"moreFilters","click .filter-drawer .apply-filters":"applyFilters",'click .filter-group [type="checkbox"]':"addFilter","click .filter-drawer .clear-filters":"clearFilters","click .edit-filters":"backToFilters","click .favorites-form-submit":"saveUsername","keyup #wporg-username-input":"saveUsername"},render:function(){var e=this;this.search(),this.uploader(),this.collection=new o.Collection,this.listenTo(this,"theme:end",function(){e.collection.loadingThemes||(e.collection.loadingThemes=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove()}),this.listenTo(this.collection,"query:fail",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),n(".theme-browser").find("div.themes").before('<div class="error"><p>'+a.error+'</p><p><button class="button try-again">'+a.tryAgain+"</button></p></div>"),n(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),n("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new o.view.Themes({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e){"block-themes"===e?this.collection.query({tag:"full-site-editing"}):this.collection.query({browse:e})},onSort:function(e){var t=n(e.target),i=t.data("sort");e.preventDefault(),n("body").removeClass("filters-applied show-filters"),n(".drawer-toggle").attr("aria-expanded","false"),t.hasClass(this.activeClass)||(this.sort(i),o.router.navigate(o.router.baseUrl(o.router.browsePath+i)))},sort:function(e){this.clearSearch(),o.router.selectedTab=e,n(".filter-links li > a, .theme-filter").removeClass(this.activeClass).removeAttr("aria-current"),n('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),"favorites"===e?n("body").addClass("show-favorites-form"):n("body").removeClass("show-favorites-form"),this.browse(e)},onFilter:function(e){var e=n(e.target),t=e.data("filter");e.hasClass(this.activeClass)||(n(".filter-links li > a, .theme-section").removeClass(this.activeClass).removeAttr("aria-current"),e.addClass(this.activeClass).attr("aria-current","page"),t&&(t=_.union([t,this.filtersChecked()]),this.collection.query({tag:[t]})))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=this.filtersChecked(),s={tag:i},r=n(".filtered-by .tags");e&&e.preventDefault(),i?(n("body").addClass("filters-applied"),n(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),r.empty(),_.each(i,function(e){t=n('label[for="filter-id-'+e+'"]').text(),r.append('<span class="tag">'+t+"</span>")}),this.collection.query(s)):wp.a11y.speak(a.selectFeatureFilter)},saveUsername:function(e){var t=n("#wporg-username-input").val(),i=n("#wporg-username-nonce").val(),s={browse:"favorites",user:t},r=this;if(e&&e.preventDefault(),"keyup"!==e.type||13===e.which)return wp.ajax.send("save-wporg-username",{data:{_wpnonce:i,username:t},success:function(){r.collection.query(s)}})},filtersChecked:function(){var e=n(".filter-group").find(":checkbox"),t=[];return _.each(e.filter(":checked"),function(e){t.push(n(e).prop("value"))}),0===t.length?(n(".filter-drawer .apply-filters").find("span").text(""),n(".filter-drawer .clear-filters").hide(),n("body").removeClass("filters-applied"),!1):(n(".filter-drawer .apply-filters").find("span").text(t.length),n(".filter-drawer .clear-filters").css("display","inline-block"),t)},activeClass:"current",uploader:function(){var e=n(".upload-view-toggle"),t=n(document.body);e.on("click",function(){t.toggleClass("show-upload-view"),e.attr("aria-expanded",t.hasClass("show-upload-view"))})},moreFilters:function(e){var t=n("body"),i=n(".drawer-toggle");if(e.preventDefault(),t.hasClass("filters-applied"))return this.backToFilters();this.clearSearch(),o.router.navigate(o.router.baseUrl("")),t.toggleClass("show-filters"),i.attr("aria-expanded",t.hasClass("show-filters"))},clearFilters:function(e){var t=n(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return n(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),n("body").removeClass("filters-applied")},clearSearch:function(){n("#wp-filter-search-input").val("")}}),o.InstallerRouter=Backbone.Router.extend({routes:{"theme-install.php?theme=:slug":"preview","theme-install.php?browse=:sort":"sort","theme-install.php?search=:query":"search","theme-install.php":"sort"},baseUrl:function(e){return"theme-install.php"+e},themePath:"?theme=",browsePath:"?browse=",searchPath:"?search=",search:function(e){n(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:e}),o.RunInstaller={init:function(){this.view=new o.view.Installer({section:"popular",SearchView:o.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:o.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this,i={};o.router=new o.InstallerRouter,o.router.on("route:preview",function(e){o.preview&&(o.preview.undelegateEvents(),o.preview.unbind()),t.view.view.theme&&t.view.view.theme.preview?(t.view.view.theme.model=t.view.collection.findWhere({slug:e}),t.view.view.theme.preview()):(i.theme=e,t.view.collection.query(i),t.view.collection.trigger("update"),t.view.collection.once("query:success",function(){n('div[data-slug="'+e+'"]').trigger("click")}))}),o.router.on("route:sort",function(e){e||(e="popular",o.router.navigate(o.router.baseUrl("?browse=popular"),{replace:!0})),t.view.sort(e),o.preview&&o.preview.close()}),o.router.on("route:search",function(){n(".wp-filter-search").trigger("focus").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},n(function(){(o.isInstall?o.RunInstaller:o.Run).init(),n(document.body).on("click",".load-customize",function(){var e=n(this),t=document.createElement("a");t.href=e.prop("href"),t.search=n.param(_.extend(wp.customize.utils.parseQueryString(t.search.substr(1)),{return:window.location.href})),e.prop("href",t.href)}),n(".broken-themes .delete-theme").on("click",function(){return confirm(_wpThemeSettings.settings.confirmDelete)})})}(jQuery),jQuery(function(r){window.tb_position=function(){var e=r("#TB_window"),t=r(window).width(),i=r(window).height(),t=1040<t?1040:t,s=0;r("#wpadminbar").length&&(s=parseInt(r("#wpadminbar").css("height"),10)),1<=e.length&&(e.width(t-50).height(i-45-s),r("#TB_iframeContent").width(t-50).height(i-75-s),e.css({"margin-left":"-"+parseInt((t-50)/2,10)+"px"}),void 0!==document.body.style.maxWidth)&&e.css({top:20+s+"px","margin-top":"0"})},r(window).on("resize",function(){tb_position()})});
\ No newline at end of file diff --git a/wp-admin/js/updates.js b/wp-admin/js/updates.js index a7c949a..806dd62 100644 --- a/wp-admin/js/updates.js +++ b/wp-admin/js/updates.js @@ -875,7 +875,7 @@ $card .addClass( 'plugin-card-update-failed' ) - .append( '<div class="notice notice-error notice-alt is-dismissible"><p>' + errorMessage + '</p></div>' ); + .append( '<div class="notice notice-error notice-alt is-dismissible" role="alert"><p>' + errorMessage + '</p></div>' ); $card.on( 'click', '.notice.is-dismissible .notice-dismiss', function() { @@ -2260,7 +2260,7 @@ // Remove any existing error. $filesystemForm.find( '.notice' ).remove(); - $filesystemForm.find( '#request-filesystem-credentials-title' ).after( '<div class="notice notice-alt notice-error"><p>' + message + '</p></div>' ); + $filesystemForm.find( '#request-filesystem-credentials-title' ).after( '<div class="notice notice-alt notice-error" role="alert"><p>' + message + '</p></div>' ); }; /** @@ -2913,13 +2913,41 @@ wp.updates.adminNotice = wp.template( 'wp-bulk-updates-admin-notice' ); + var successMessage = null; + + if ( success ) { + if ( 'plugin' === response.update ) { + successMessage = sprintf( + /* translators: %s: Number of plugins. */ + _n( '%s plugin successfully updated.', '%s plugins successfully updated.', success ), + success + ); + } else { + successMessage = sprintf( + /* translators: %s: Number of themes. */ + _n( '%s theme successfully updated.', '%s themes successfully updated.', success ), + success + ); + } + } + + var errorMessage = null; + + if ( error ) { + errorMessage = sprintf( + /* translators: %s: Number of failed updates. */ + _n( '%s update failed.', '%s updates failed.', error ), + error + ); + } + wp.updates.addAdminNotice( { id: 'bulk-action-notice', className: 'bulk-action-notice', - successes: success, - errors: error, - errorMessages: errorMessages, - type: response.update + successMessage: successMessage, + errorMessage: errorMessage, + errorMessages: errorMessages, + type: response.update } ); $bulkActionNotice = $( '#bulk-action-notice' ).on( 'click', 'button', function() { diff --git a/wp-admin/js/updates.min.js b/wp-admin/js/updates.min.js index 5f34e5b..d53b501 100644 --- a/wp-admin/js/updates.min.js +++ b/wp-admin/js/updates.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(c,g,m){var f=c(document),h=g.i18n.__,d=g.i18n._x,i=g.i18n._n,o=g.i18n._nx,r=g.i18n.sprintf;(g=g||{}).updates={},g.updates.l10n={searchResults:"",searchResultsLabel:"",noPlugins:"",noItemsSelected:"",updating:"",pluginUpdated:"",themeUpdated:"",update:"",updateNow:"",pluginUpdateNowLabel:"",updateFailedShort:"",updateFailed:"",pluginUpdatingLabel:"",pluginUpdatedLabel:"",pluginUpdateFailedLabel:"",updatingMsg:"",updatedMsg:"",updateCancel:"",beforeunload:"",installNow:"",pluginInstallNowLabel:"",installing:"",pluginInstalled:"",themeInstalled:"",installFailedShort:"",installFailed:"",pluginInstallingLabel:"",themeInstallingLabel:"",pluginInstalledLabel:"",themeInstalledLabel:"",pluginInstallFailedLabel:"",themeInstallFailedLabel:"",installingMsg:"",installedMsg:"",importerInstalledMsg:"",aysDelete:"",aysDeleteUninstall:"",aysBulkDelete:"",aysBulkDeleteThemes:"",deleting:"",deleteFailed:"",pluginDeleted:"",themeDeleted:"",livePreview:"",activatePlugin:"",activateTheme:"",activatePluginLabel:"",activateThemeLabel:"",activateImporter:"",activateImporterLabel:"",unknownError:"",connectionError:"",nonceError:"",pluginsFound:"",noPluginsFound:"",autoUpdatesEnable:"",autoUpdatesEnabling:"",autoUpdatesEnabled:"",autoUpdatesDisable:"",autoUpdatesDisabling:"",autoUpdatesDisabled:"",autoUpdatesError:""},g.updates.l10n=window.wp.deprecateL10nObject("wp.updates.l10n",g.updates.l10n,"5.5.0"),g.updates.ajaxNonce=m.ajax_nonce,g.updates.searchTerm="",g.updates.shouldRequestFilesystemCredentials=!1,g.updates.filesystemCredentials={ftp:{host:"",username:"",password:"",connectionType:""},ssh:{publicKey:"",privateKey:""},fsNonce:"",available:!1},g.updates.ajaxLocked=!1,g.updates.adminNotice=g.template("wp-updates-admin-notice"),g.updates.queue=[],g.updates.$elToReturnFocusToFromCredentialsModal=void 0,g.updates.addAdminNotice=function(e){var t,a=c(e.selector),s=c(".wp-header-end");delete e.selector,t=g.updates.adminNotice(e),(a=a.length?a:c("#"+e.id)).length?a.replaceWith(t):s.length?s.after(t):"customize"===pagenow?c(".customize-themes-notifications").append(t):c(".wrap").find("> h1").after(t),f.trigger("wp-updates-notice-added")},g.updates.ajax=function(e,t){var a={};return g.updates.ajaxLocked?(g.updates.queue.push({action:e,data:t}),c.Deferred()):(g.updates.ajaxLocked=!0,t.success&&(a.success=t.success,delete t.success),t.error&&(a.error=t.error,delete t.error),a.data=_.extend(t,{action:e,_ajax_nonce:g.updates.ajaxNonce,_fs_nonce:g.updates.filesystemCredentials.fsNonce,username:g.updates.filesystemCredentials.ftp.username,password:g.updates.filesystemCredentials.ftp.password,hostname:g.updates.filesystemCredentials.ftp.hostname,connection_type:g.updates.filesystemCredentials.ftp.connectionType,public_key:g.updates.filesystemCredentials.ssh.publicKey,private_key:g.updates.filesystemCredentials.ssh.privateKey}),g.ajax.send(a).always(g.updates.ajaxAlways))},g.updates.ajaxAlways=function(e){e.errorCode&&"unable_to_connect_to_filesystem"===e.errorCode||(g.updates.ajaxLocked=!1,g.updates.queueChecker()),void 0!==e.debug&&window.console&&window.console.log&&_.map(e.debug,function(e){window.console.log(g.sanitize.stripTagsAndEncodeText(e))})},g.updates.refreshCount=function(){var e,t=c("#wp-admin-bar-updates"),a=c('a[href="update-core.php"] .update-plugins'),s=c('a[href="plugins.php"] .update-plugins'),n=c('a[href="themes.php"] .update-plugins');t.find(".ab-label").text(m.totals.counts.total),t.find(".updates-available-text").text(r(i("%s update available","%s updates available",m.totals.counts.total),m.totals.counts.total)),0===m.totals.counts.total&&t.find(".ab-label").parents("li").remove(),a.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+m.totals.counts.total)}),0<m.totals.counts.total?a.find(".update-count").text(m.totals.counts.total):a.remove(),s.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+m.totals.counts.plugins)}),0<m.totals.counts.total?s.find(".plugin-count").text(m.totals.counts.plugins):s.remove(),n.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+m.totals.counts.themes)}),0<m.totals.counts.total?n.find(".theme-count").text(m.totals.counts.themes):n.remove(),"plugins"===pagenow||"plugins-network"===pagenow?e=m.totals.counts.plugins:"themes"!==pagenow&&"themes-network"!==pagenow||(e=m.totals.counts.themes),0<e?c(".subsubsub .upgrade .count").text("("+e+")"):(c(".subsubsub .upgrade").remove(),c(".subsubsub li:last").html(function(){return c(this).children()}))},g.updates.setCardButtonStatus=function(e){var t=window.parent===window?null:window.parent;c.support.postMessage=!!window.postMessage,!1!==c.support.postMessage&&null!==t&&-1===window.parent.location.pathname.indexOf("index.php")&&t.postMessage(JSON.stringify(e),window.location.origin)},g.updates.decrementCount=function(e){m.totals.counts.total=Math.max(--m.totals.counts.total,0),"plugin"===e?m.totals.counts.plugins=Math.max(--m.totals.counts.plugins,0):"theme"===e&&(m.totals.counts.themes=Math.max(--m.totals.counts.themes,0)),g.updates.refreshCount(e)},g.updates.updatePlugin=function(e){var t,a,s,n=c("#wp-admin-bar-updates"),i=h("Updating..."),l="plugin-install"===pagenow||"plugin-install-network"===pagenow;return e=_.extend({success:g.updates.updatePluginSuccess,error:g.updates.updatePluginError},e),"plugins"===pagenow||"plugins-network"===pagenow?(a=(s=c('tr[data-plugin="'+e.plugin+'"]')).find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning").find("p"),s=r(d("Updating %s...","plugin"),s.find(".plugin-title strong").text())):l&&(a=(t=c(".plugin-card-"+e.slug+", #plugin-information-footer")).find(".update-now").addClass("updating-message"),s=r(d("Updating %s...","plugin"),a.data("name")),t.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),n.addClass("spin"),a.html()!==h("Updating...")&&a.data("originaltext",a.html()),a.attr("aria-label",s).text(i),f.trigger("wp-plugin-updating",e),l&&"plugin-information-footer"===t.attr("id")&&g.updates.setCardButtonStatus({status:"updating-plugin",slug:e.slug,addClasses:"updating-message",text:i,ariaLabel:s}),g.updates.ajax("update-plugin",e)},g.updates.updatePluginSuccess=function(e){var t,a,s,n=c("#wp-admin-bar-updates"),i=d("Updated!","plugin"),l=r(d("%s updated!","plugin"),e.pluginName);"plugins"===pagenow||"plugins-network"===pagenow?(a=(t=c('tr[data-plugin="'+e.plugin+'"]').removeClass("update is-enqueued").addClass("updated")).find(".update-message").removeClass("updating-message notice-warning").addClass("updated-message notice-success").find("p"),s=t.find(".plugin-version-author-uri").html().replace(e.oldVersion,e.newVersion),t.find(".plugin-version-author-uri").html(s),t.find(".auto-update-time").empty()):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(a=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".update-now").removeClass("updating-message").addClass("button-disabled updated-message")),n.removeClass("spin"),a.attr("aria-label",l).text(i),g.a11y.speak(h("Update completed successfully.")),"plugin_install_from_iframe"!==a.attr("id")?g.updates.decrementCount("plugin"):g.updates.setCardButtonStatus({status:"updated-plugin",slug:e.slug,removeClasses:"updating-message",addClasses:"button-disabled updated-message",text:i,ariaLabel:l}),f.trigger("wp-plugin-update-success",e)},g.updates.updatePluginError=function(e){var t,a,s,n,i,l=c("#wp-admin-bar-updates");g.updates.isValidResponse(e,"update")&&!g.updates.maybeHandleCredentialError(e,"update-plugin")&&(s=r(h("Update failed: %s"),e.errorMessage),"plugins"===pagenow||"plugins-network"===pagenow?(c('tr[data-plugin="'+e.plugin+'"]').removeClass("is-enqueued"),(a=(e.plugin?c('tr[data-plugin="'+e.plugin+'"]'):c('tr[data-slug="'+e.slug+'"]')).find(".update-message")).removeClass("updating-message notice-warning").addClass("notice-error").find("p").html(s),e.pluginName?a.find("p").attr("aria-label",r(d("%s update failed.","plugin"),e.pluginName)):a.find("p").removeAttr("aria-label")):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(n=h("Update failed."),(t=c(".plugin-card-"+e.slug+", #plugin-information-footer").append(g.updates.adminNotice({className:"update-message notice-error notice-alt is-dismissible",message:s}))).hasClass("plugin-card-"+e.slug)&&t.addClass("plugin-card-update-failed"),t.find(".update-now").text(n).removeClass("updating-message"),e.pluginName?(i=r(d("%s update failed.","plugin"),e.pluginName),t.find(".update-now").attr("aria-label",i)):(i="",t.find(".update-now").removeAttr("aria-label")),t.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){t.removeClass("plugin-card-update-failed").find(".column-name a").trigger("focus"),t.find(".update-now").attr("aria-label",!1).text(h("Update Now"))},200)})),l.removeClass("spin"),g.a11y.speak(s,"assertive"),"plugin-information-footer"===t.attr("id")&&g.updates.setCardButtonStatus({status:"plugin-update-failed",slug:e.slug,removeClasses:"updating-message",text:n,ariaLabel:i}),f.trigger("wp-plugin-update-error",e))},g.updates.installPlugin=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer"),s=a.find(".install-now"),n=h("Installing...");return e=_.extend({success:g.updates.installPluginSuccess,error:g.updates.installPluginError},e),(s="import"===pagenow?c('[data-slug="'+e.slug+'"]'):s).html()!==h("Installing...")&&s.data("originaltext",s.html()),t=r(d("Installing %s...","plugin"),s.data("name")),s.addClass("updating-message").attr("aria-label",t).text(n),g.a11y.speak(h("Installing... please wait.")),a.removeClass("plugin-card-install-failed").find(".notice.notice-error").remove(),f.trigger("wp-plugin-installing",e),"plugin-information-footer"===s.parent().attr("id")&&g.updates.setCardButtonStatus({status:"installing-plugin",slug:e.slug,addClasses:"updating-message",text:n,ariaLabel:t}),g.updates.ajax("install-plugin",e)},g.updates.installPluginSuccess=function(e){var t=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".install-now"),a=d("Installed!","plugin"),s=r(d("%s installed!","plugin"),e.pluginName);t.removeClass("updating-message").addClass("updated-message installed button-disabled").attr("aria-label",s).text(a),g.a11y.speak(h("Installation completed successfully.")),f.trigger("wp-plugin-install-success",e),e.activateUrl&&setTimeout(function(){g.updates.checkPluginDependencies({slug:e.slug})},1e3),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"installed-plugin",slug:e.slug,removeClasses:"updating-message",addClasses:"updated-message installed button-disabled",text:a,ariaLabel:s})},g.updates.installPluginError=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer"),s=a.find(".install-now"),n=h("Installation failed."),i=r(d("%s installation failed","plugin"),s.data("name"));g.updates.isValidResponse(e,"install")&&!g.updates.maybeHandleCredentialError(e,"install-plugin")&&(t=r(h("Installation failed: %s"),e.errorMessage),a.addClass("plugin-card-update-failed").append('<div class="notice notice-error notice-alt is-dismissible"><p>'+t+"</p></div>"),a.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){a.removeClass("plugin-card-update-failed").find(".column-name a").trigger("focus")},200)}),s.removeClass("updating-message").addClass("button-disabled").attr("aria-label",i).text(n),g.a11y.speak(t,"assertive"),g.updates.setCardButtonStatus({status:"plugin-install-failed",slug:e.slug,removeClasses:"updating-message",addClasses:"button-disabled",text:n,ariaLabel:i}),f.trigger("wp-plugin-install-error",e))},g.updates.checkPluginDependencies=function(e){return e=_.extend({success:g.updates.checkPluginDependenciesSuccess,error:g.updates.checkPluginDependenciesError},e),g.a11y.speak(h("Checking plugin dependencies... please wait.")),f.trigger("wp-checking-plugin-dependencies",e),g.updates.ajax("check_plugin_dependencies",e)},g.updates.checkPluginDependenciesSuccess=function(e){var t,a,s=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".install-now");s.removeClass("install-now installed button-disabled updated-message").addClass("activate-now button-primary").attr("href",e.activateUrl),g.a11y.speak(h("Plugin dependencies check completed successfully.")),f.trigger("wp-check-plugin-dependencies-success",e),("plugins-network"===pagenow?(t=d("Network Activate","plugin"),a=r(d("Network Activate %s","plugin"),e.pluginName),s.attr("aria-label",a)):(t=d("Activate","plugin"),a=r(d("Activate %s","plugin"),e.pluginName),s.attr("aria-label",a).attr("data-name",e.pluginName).attr("data-slug",e.slug).attr("data-plugin",e.plugin))).text(t),"plugin-information-footer"===s.parent().attr("id")&&g.updates.setCardButtonStatus({status:"dependencies-check-success",slug:e.slug,removeClasses:"install-now installed button-disabled updated-message",addClasses:"activate-now button-primary",text:t,ariaLabel:a,pluginName:e.pluginName,plugin:e.plugin,href:e.activateUrl})},g.updates.checkPluginDependenciesError=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".install-now"),s=d("Activate","plugin"),n=r(d("Cannot activate %1$s. %2$s","plugin"),e.pluginName,e.errorMessage);g.updates.isValidResponse(e,"check-dependencies")&&(t=r(h("Activation failed: %s"),e.errorMessage),g.a11y.speak(t,"assertive"),f.trigger("wp-check-plugin-dependencies-error",e),a.removeClass("install-now installed updated-message").addClass("activate-now button-primary").attr("aria-label",n).text(s),"plugin-information-footer"===a.parent().attr("id"))&&g.updates.setCardButtonStatus({status:"dependencies-check-failed",slug:e.slug,removeClasses:"install-now installed updated-message",addClasses:"activate-now button-primary",text:s,ariaLabel:n})},g.updates.activatePlugin=function(e){var t=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".activate-now, .activating-message");return e=_.extend({success:g.updates.activatePluginSuccess,error:g.updates.activatePluginError},e),g.a11y.speak(h("Activating... please wait.")),f.trigger("wp-activating-plugin",e),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"activating-plugin",slug:e.slug,removeClasses:"installed updated-message button-primary",addClasses:"activating-message",text:h("Activating..."),ariaLabel:r(d("Activating %s","plugin"),e.name)}),g.updates.ajax("activate-plugin",e)},g.updates.activatePluginSuccess=function(e){var t=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".activating-message"),a=d("Activated!","plugin"),s=r("%s activated successfully.",e.pluginName);g.a11y.speak(h("Activation completed successfully.")),f.trigger("wp-plugin-activate-success",e),t.removeClass("activating-message").addClass("activated-message button-disabled").attr("aria-label",s).text(a),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"activated-plugin",slug:e.slug,removeClasses:"activating-message",addClasses:"activated-message button-disabled",text:a,ariaLabel:s}),setTimeout(function(){t.removeClass("activated-message").text(d("Active","plugin")),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"plugin-active",slug:e.slug,removeClasses:"activated-message",text:d("Active","plugin"),ariaLabel:r("%s is active.",e.pluginName)})},1e3)},g.updates.activatePluginError=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".activating-message"),s=h("Activation failed."),n=r(d("%s activation failed","plugin"),e.pluginName);g.updates.isValidResponse(e,"activate")&&(t=r(h("Activation failed: %s"),e.errorMessage),g.a11y.speak(t,"assertive"),f.trigger("wp-plugin-activate-error",e),a.removeClass("install-now installed activating-message").addClass("button-disabled").attr("aria-label",n).text(s),"plugin-information-footer"===a.parent().attr("id"))&&g.updates.setCardButtonStatus({status:"plugin-activation-failed",slug:e.slug,removeClasses:"install-now installed activating-message",addClasses:"button-disabled",text:s,ariaLabel:n})},g.updates.installImporterSuccess=function(e){g.updates.addAdminNotice({id:"install-success",className:"notice-success is-dismissible",message:r(h('Importer installed successfully. <a href="%s">Run importer</a>'),e.activateUrl+"&from=import")}),c('[data-slug="'+e.slug+'"]').removeClass("install-now updating-message").addClass("activate-now").attr({href:e.activateUrl+"&from=import","aria-label":r(h("Run %s"),e.pluginName)}).text(h("Run Importer")),g.a11y.speak(h("Installation completed successfully.")),f.trigger("wp-importer-install-success",e)},g.updates.installImporterError=function(e){var t=r(h("Installation failed: %s"),e.errorMessage),a=c('[data-slug="'+e.slug+'"]'),s=a.data("name");g.updates.isValidResponse(e,"install")&&!g.updates.maybeHandleCredentialError(e,"install-plugin")&&(g.updates.addAdminNotice({id:e.errorCode,className:"notice-error is-dismissible",message:t}),a.removeClass("updating-message").attr("aria-label",r(d("Install %s now","plugin"),s)).text(d("Install Now","plugin")),g.a11y.speak(t,"assertive"),f.trigger("wp-importer-install-error",e))},g.updates.deletePlugin=function(e){var t=c('[data-plugin="'+e.plugin+'"]').find(".row-actions a.delete");return e=_.extend({success:g.updates.deletePluginSuccess,error:g.updates.deletePluginError},e),t.html()!==h("Deleting...")&&t.data("originaltext",t.html()).text(h("Deleting...")),g.a11y.speak(h("Deleting...")),f.trigger("wp-plugin-deleting",e),g.updates.ajax("delete-plugin",e)},g.updates.deletePluginSuccess=function(u){c('[data-plugin="'+u.plugin+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=c("#bulk-action-form"),t=c(".subsubsub"),a=c(this),s=t.find('[aria-current="page"]'),n=c(".displaying-num"),i=e.find("thead th:not(.hidden), thead td").length,l=g.template("item-deleted-row"),d=m.plugins;a.hasClass("plugin-update-tr")||a.after(l({slug:u.slug,plugin:u.plugin,colspan:i,name:u.pluginName})),a.remove(),-1!==_.indexOf(d.upgrade,u.plugin)&&(d.upgrade=_.without(d.upgrade,u.plugin),g.updates.decrementCount("plugin")),-1!==_.indexOf(d.inactive,u.plugin)&&(d.inactive=_.without(d.inactive,u.plugin),d.inactive.length?t.find(".inactive .count").text("("+d.inactive.length+")"):t.find(".inactive").remove()),-1!==_.indexOf(d.active,u.plugin)&&(d.active=_.without(d.active,u.plugin),d.active.length?t.find(".active .count").text("("+d.active.length+")"):t.find(".active").remove()),-1!==_.indexOf(d.recently_activated,u.plugin)&&(d.recently_activated=_.without(d.recently_activated,u.plugin),d.recently_activated.length?t.find(".recently_activated .count").text("("+d.recently_activated.length+")"):t.find(".recently_activated").remove()),-1!==_.indexOf(d["auto-update-enabled"],u.plugin)&&(d["auto-update-enabled"]=_.without(d["auto-update-enabled"],u.plugin),d["auto-update-enabled"].length?t.find(".auto-update-enabled .count").text("("+d["auto-update-enabled"].length+")"):t.find(".auto-update-enabled").remove()),-1!==_.indexOf(d["auto-update-disabled"],u.plugin)&&(d["auto-update-disabled"]=_.without(d["auto-update-disabled"],u.plugin),d["auto-update-disabled"].length?t.find(".auto-update-disabled .count").text("("+d["auto-update-disabled"].length+")"):t.find(".auto-update-disabled").remove()),d.all=_.without(d.all,u.plugin),d.all.length?t.find(".all .count").text("("+d.all.length+")"):(e.find(".tablenav").css({visibility:"hidden"}),t.find(".all").remove(),e.find("tr.no-items").length||e.find("#the-list").append('<tr class="no-items"><td class="colspanchange" colspan="'+i+'">'+h("No plugins are currently available.")+"</td></tr>")),n.length&&s.length&&(l=d[s.parent("li").attr("class")].length,n.text(r(o("%s item","%s items",l,"plugin/plugins"),l)))}),g.a11y.speak(d("Deleted!","plugin")),f.trigger("wp-plugin-delete-success",u)},g.updates.deletePluginError=function(e){var t,a=g.template("item-update-row"),s=g.updates.adminNotice({className:"update-message notice-error notice-alt",message:e.errorMessage}),n=e.plugin?(t=c('tr.inactive[data-plugin="'+e.plugin+'"]')).siblings('[data-plugin="'+e.plugin+'"]'):(t=c('tr.inactive[data-slug="'+e.slug+'"]')).siblings('[data-slug="'+e.slug+'"]');g.updates.isValidResponse(e,"delete")&&!g.updates.maybeHandleCredentialError(e,"delete-plugin")&&(n.length?(n.find(".notice-error").remove(),n.find(".plugin-update").append(s)):t.addClass("update").after(a({slug:e.slug,plugin:e.plugin||e.slug,colspan:c("#bulk-action-form").find("thead th:not(.hidden), thead td").length,content:s})),f.trigger("wp-plugin-delete-error",e))},g.updates.updateTheme=function(e){var t;return e=_.extend({success:g.updates.updateThemeSuccess,error:g.updates.updateThemeError},e),(t=("themes-network"===pagenow?c('[data-slug="'+e.slug+'"]').find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning"):(t="customize"===pagenow?((t=c('[data-slug="'+e.slug+'"].notice').removeClass("notice-large")).find("h3").remove(),t.add(c("#customize-control-installed_theme_"+e.slug).find(".update-message"))):((t=c("#update-theme").closest(".notice").removeClass("notice-large")).find("h3").remove(),t.add(c('[data-slug="'+e.slug+'"]').find(".update-message")))).addClass("updating-message")).find("p")).html()!==h("Updating...")&&t.data("originaltext",t.html()),g.a11y.speak(h("Updating... please wait.")),t.text(h("Updating...")),f.trigger("wp-theme-updating",e),g.updates.ajax("update-theme",e)},g.updates.updateThemeSuccess=function(e){var t,a,s=c("body.modal-open").length,n=c('[data-slug="'+e.slug+'"]'),i={className:"updated-message notice-success notice-alt",message:d("Updated!","theme")};"customize"===pagenow?((n=c(".updating-message").siblings(".theme-name")).length&&(a=n.html().replace(e.oldVersion,e.newVersion),n.html(a)),t=c(".theme-info .notice").add(g.customize.control("installed_theme_"+e.slug).container.find(".theme").find(".update-message"))):"themes-network"===pagenow?(t=n.find(".update-message"),a=n.find(".theme-version-author-uri").html().replace(e.oldVersion,e.newVersion),n.find(".theme-version-author-uri").html(a),n.find(".auto-update-time").empty()):(t=c(".theme-info .notice").add(n.find(".update-message")),s?(c(".load-customize:visible").trigger("focus"),c(".theme-info .theme-autoupdate").find(".auto-update-time").empty()):n.find(".load-customize").trigger("focus")),g.updates.addAdminNotice(_.extend({selector:t},i)),g.a11y.speak(h("Update completed successfully.")),g.updates.decrementCount("theme"),f.trigger("wp-theme-update-success",e),s&&"customize"!==pagenow&&c(".theme-info .theme-author").after(g.updates.adminNotice(i))},g.updates.updateThemeError=function(e){var t,a=c('[data-slug="'+e.slug+'"]'),s=r(h("Update failed: %s"),e.errorMessage);g.updates.isValidResponse(e,"update")&&!g.updates.maybeHandleCredentialError(e,"update-theme")&&("customize"===pagenow&&(a=g.customize.control("installed_theme_"+e.slug).container.find(".theme")),"themes-network"===pagenow?t=a.find(".update-message "):(t=c(".theme-info .notice").add(a.find(".notice")),(c("body.modal-open").length?c(".load-customize:visible"):a.find(".load-customize")).trigger("focus")),g.updates.addAdminNotice({selector:t,className:"update-message notice-error notice-alt is-dismissible",message:s}),g.a11y.speak(s),f.trigger("wp-theme-update-error",e))},g.updates.installTheme=function(e){var t=c('.theme-install[data-slug="'+e.slug+'"]');return e=_.extend({success:g.updates.installThemeSuccess,error:g.updates.installThemeError},e),t.addClass("updating-message"),t.parents(".theme").addClass("focus"),t.html()!==h("Installing...")&&t.data("originaltext",t.html()),t.attr("aria-label",r(d("Installing %s...","theme"),t.data("name"))).text(h("Installing...")),g.a11y.speak(h("Installing... please wait.")),c('.install-theme-info, [data-slug="'+e.slug+'"]').removeClass("theme-install-failed").find(".notice.notice-error").remove(),f.trigger("wp-theme-installing",e),g.updates.ajax("install-theme",e)},g.updates.installThemeSuccess=function(e){var t,a=c(".wp-full-overlay-header, [data-slug="+e.slug+"]");f.trigger("wp-theme-install-success",e),t=a.find(".button-primary").removeClass("updating-message").addClass("updated-message disabled").attr("aria-label",r(d("%s installed!","theme"),e.themeName)).text(d("Installed!","theme")),g.a11y.speak(h("Installation completed successfully.")),setTimeout(function(){e.activateUrl&&(t.attr("href",e.activateUrl).removeClass("theme-install updated-message disabled").addClass("activate"),"themes-network"===pagenow?t.attr("aria-label",r(d("Network Activate %s","theme"),e.themeName)).text(h("Network Enable")):t.attr("aria-label",r(d("Activate %s","theme"),e.themeName)).text(d("Activate","theme"))),e.customizeUrl&&t.siblings(".preview").replaceWith(function(){return c("<a>").attr("href",e.customizeUrl).addClass("button load-customize").text(h("Live Preview"))})},1e3)},g.updates.installThemeError=function(e){var t,a=r(h("Installation failed: %s"),e.errorMessage),s=g.updates.adminNotice({className:"update-message notice-error notice-alt",message:a});g.updates.isValidResponse(e,"install")&&!g.updates.maybeHandleCredentialError(e,"install-theme")&&("customize"===pagenow?(f.find("body").hasClass("modal-open")?(t=c('.theme-install[data-slug="'+e.slug+'"]'),c(".theme-overlay .theme-info").prepend(s)):(t=c('.theme-install[data-slug="'+e.slug+'"]')).closest(".theme").addClass("theme-install-failed").append(s),g.customize.notifications.remove("theme_installing")):f.find("body").hasClass("full-overlay-active")?(t=c('.theme-install[data-slug="'+e.slug+'"]'),c(".install-theme-info").prepend(s)):t=c('[data-slug="'+e.slug+'"]').removeClass("focus").addClass("theme-install-failed").append(s).find(".theme-install"),t.removeClass("updating-message").attr("aria-label",r(d("%s installation failed","theme"),t.data("name"))).text(h("Installation failed.")),g.a11y.speak(a,"assertive"),f.trigger("wp-theme-install-error",e))},g.updates.deleteTheme=function(e){var t;return"themes"===pagenow?t=c(".theme-actions .delete-theme"):"themes-network"===pagenow&&(t=c('[data-slug="'+e.slug+'"]').find(".row-actions a.delete")),e=_.extend({success:g.updates.deleteThemeSuccess,error:g.updates.deleteThemeError},e),t&&t.html()!==h("Deleting...")&&t.data("originaltext",t.html()).text(h("Deleting...")),g.a11y.speak(h("Deleting...")),c(".theme-info .update-message").remove(),f.trigger("wp-theme-deleting",e),g.updates.ajax("delete-theme",e)},g.updates.deleteThemeSuccess=function(n){var e=c('[data-slug="'+n.slug+'"]');"themes-network"===pagenow&&e.css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=c(".subsubsub"),t=c(this),a=m.themes,s=g.template("item-deleted-row");t.hasClass("plugin-update-tr")||t.after(s({slug:n.slug,colspan:c("#bulk-action-form").find("thead th:not(.hidden), thead td").length,name:t.find(".theme-title strong").text()})),t.remove(),-1!==_.indexOf(a.upgrade,n.slug)&&(a.upgrade=_.without(a.upgrade,n.slug),g.updates.decrementCount("theme")),-1!==_.indexOf(a.disabled,n.slug)&&(a.disabled=_.without(a.disabled,n.slug),a.disabled.length?e.find(".disabled .count").text("("+a.disabled.length+")"):e.find(".disabled").remove()),-1!==_.indexOf(a["auto-update-enabled"],n.slug)&&(a["auto-update-enabled"]=_.without(a["auto-update-enabled"],n.slug),a["auto-update-enabled"].length?e.find(".auto-update-enabled .count").text("("+a["auto-update-enabled"].length+")"):e.find(".auto-update-enabled").remove()),-1!==_.indexOf(a["auto-update-disabled"],n.slug)&&(a["auto-update-disabled"]=_.without(a["auto-update-disabled"],n.slug),a["auto-update-disabled"].length?e.find(".auto-update-disabled .count").text("("+a["auto-update-disabled"].length+")"):e.find(".auto-update-disabled").remove()),a.all=_.without(a.all,n.slug),e.find(".all .count").text("("+a.all.length+")")}),"themes"===pagenow&&_.find(_wpThemeSettings.themes,{id:n.slug}).hasUpdate&&g.updates.decrementCount("theme"),g.a11y.speak(d("Deleted!","theme")),f.trigger("wp-theme-delete-success",n)},g.updates.deleteThemeError=function(e){var t=c('tr.inactive[data-slug="'+e.slug+'"]'),a=c(".theme-actions .delete-theme"),s=g.template("item-update-row"),n=t.siblings("#"+e.slug+"-update"),i=r(h("Deletion failed: %s"),e.errorMessage),l=g.updates.adminNotice({className:"update-message notice-error notice-alt",message:i});g.updates.maybeHandleCredentialError(e,"delete-theme")||("themes-network"===pagenow?n.length?(n.find(".notice-error").remove(),n.find(".plugin-update").append(l)):t.addClass("update").after(s({slug:e.slug,colspan:c("#bulk-action-form").find("thead th:not(.hidden), thead td").length,content:l})):c(".theme-info .theme-description").before(l),a.html(a.data("originaltext")),g.a11y.speak(i,"assertive"),f.trigger("wp-theme-delete-error",e))},g.updates._addCallbacks=function(e,t){return"import"===pagenow&&"install-plugin"===t&&(e.success=g.updates.installImporterSuccess,e.error=g.updates.installImporterError),e},g.updates.queueChecker=function(){var e;if(!g.updates.ajaxLocked&&g.updates.queue.length)switch((e=g.updates.queue.shift()).action){case"install-plugin":g.updates.installPlugin(e.data);break;case"update-plugin":g.updates.updatePlugin(e.data);break;case"delete-plugin":g.updates.deletePlugin(e.data);break;case"install-theme":g.updates.installTheme(e.data);break;case"update-theme":g.updates.updateTheme(e.data);break;case"delete-theme":g.updates.deleteTheme(e.data)}},g.updates.requestFilesystemCredentials=function(e){!1===g.updates.filesystemCredentials.available&&(e&&!g.updates.$elToReturnFocusToFromCredentialsModal&&(g.updates.$elToReturnFocusToFromCredentialsModal=c(e.target)),g.updates.ajaxLocked=!0,g.updates.requestForCredentialsModalOpen())},g.updates.maybeRequestFilesystemCredentials=function(e){g.updates.shouldRequestFilesystemCredentials&&!g.updates.ajaxLocked&&g.updates.requestFilesystemCredentials(e)},g.updates.keydown=function(e){27===e.keyCode?g.updates.requestForCredentialsModalCancel():9===e.keyCode&&("upgrade"!==e.target.id||e.shiftKey?"hostname"===e.target.id&&e.shiftKey&&(c("#upgrade").trigger("focus"),e.preventDefault()):(c("#hostname").trigger("focus"),e.preventDefault()))},g.updates.requestForCredentialsModalOpen=function(){var e=c("#request-filesystem-credentials-dialog");c("body").addClass("modal-open"),e.show(),e.find("input:enabled:first").trigger("focus"),e.on("keydown",g.updates.keydown)},g.updates.requestForCredentialsModalClose=function(){c("#request-filesystem-credentials-dialog").hide(),c("body").removeClass("modal-open"),g.updates.$elToReturnFocusToFromCredentialsModal&&g.updates.$elToReturnFocusToFromCredentialsModal.trigger("focus")},g.updates.requestForCredentialsModalCancel=function(){(g.updates.ajaxLocked||g.updates.queue.length)&&(_.each(g.updates.queue,function(e){f.trigger("credential-modal-cancel",e)}),g.updates.ajaxLocked=!1,g.updates.queue=[],g.updates.requestForCredentialsModalClose())},g.updates.showErrorInCredentialsForm=function(e){var t=c("#request-filesystem-credentials-form");t.find(".notice").remove(),t.find("#request-filesystem-credentials-title").after('<div class="notice notice-alt notice-error"><p>'+e+"</p></div>")},g.updates.credentialError=function(e,t){e=g.updates._addCallbacks(e,t),g.updates.queue.unshift({action:t,data:e}),g.updates.filesystemCredentials.available=!1,g.updates.showErrorInCredentialsForm(e.errorMessage),g.updates.requestFilesystemCredentials()},g.updates.maybeHandleCredentialError=function(e,t){return!(!g.updates.shouldRequestFilesystemCredentials||!e.errorCode||"unable_to_connect_to_filesystem"!==e.errorCode||(g.updates.credentialError(e,t),0))},g.updates.isValidResponse=function(e,t){var a,s=h("Something went wrong.");if(_.isObject(e)&&!_.isFunction(e.always))return!0;switch(_.isString(e)&&"-1"===e?s=h("An error has occurred. Please reload the page and try again."):_.isString(e)?s=e:void 0!==e.readyState&&0===e.readyState?s=h("Connection lost or the server is busy. Please try again later."):_.isString(e.responseText)&&""!==e.responseText?s=e.responseText:_.isString(e.statusText)&&(s=e.statusText),t){case"update":a=h("Update failed: %s");break;case"install":a=h("Installation failed: %s");break;case"check-dependencies":a=h("Dependencies check failed: %s");break;case"activate":a=h("Activation failed: %s");break;case"delete":a=h("Deletion failed: %s")}return s=s.replace(/<[\/a-z][^<>]*>/gi,""),a=a.replace("%s",s),g.updates.addAdminNotice({id:"unknown_error",className:"notice-error is-dismissible",message:_.escape(a)}),g.updates.ajaxLocked=!1,g.updates.queue=[],c(".button.updating-message").removeClass("updating-message").removeAttr("aria-label").prop("disabled",!0).text(h("Update failed.")),c(".updating-message:not(.button):not(.thickbox)").removeClass("updating-message notice-warning").addClass("notice-error").find("p").removeAttr("aria-label").text(a),g.a11y.speak(a,"assertive"),!1},g.updates.beforeunload=function(){if(g.updates.ajaxLocked)return h("Updates may not complete if you navigate away from this page.")},c(function(){var i=c("#plugin-filter, #plugin-information-footer"),o=c("#bulk-action-form"),e=c("#request-filesystem-credentials-form"),t=c("#request-filesystem-credentials-dialog"),a=c(".plugins-php .wp-filter-search"),s=c(".plugin-install-php .wp-filter-search");(m=_.extend(m,window._wpUpdatesItemCounts||{})).totals&&g.updates.refreshCount(),g.updates.shouldRequestFilesystemCredentials=0<t.length,t.on("submit","form",function(e){e.preventDefault(),g.updates.filesystemCredentials.ftp.hostname=c("#hostname").val(),g.updates.filesystemCredentials.ftp.username=c("#username").val(),g.updates.filesystemCredentials.ftp.password=c("#password").val(),g.updates.filesystemCredentials.ftp.connectionType=c('input[name="connection_type"]:checked').val(),g.updates.filesystemCredentials.ssh.publicKey=c("#public_key").val(),g.updates.filesystemCredentials.ssh.privateKey=c("#private_key").val(),g.updates.filesystemCredentials.fsNonce=c("#_fs_nonce").val(),g.updates.filesystemCredentials.available=!0,g.updates.ajaxLocked=!1,g.updates.queueChecker(),g.updates.requestForCredentialsModalClose()}),t.on("click",'[data-js-action="close"], .notification-dialog-background',g.updates.requestForCredentialsModalCancel),e.on("change",'input[name="connection_type"]',function(){c("#ssh-keys").toggleClass("hidden","ssh"!==c(this).val())}).trigger("change"),f.on("credential-modal-cancel",function(e,t){var a,s=c(".updating-message");"import"===pagenow?s.removeClass("updating-message"):"plugins"===pagenow||"plugins-network"===pagenow?"update-plugin"===t.action?a=c('tr[data-plugin="'+t.data.plugin+'"]').find(".update-message"):"delete-plugin"===t.action&&(a=c('[data-plugin="'+t.data.plugin+'"]').find(".row-actions a.delete")):"themes"===pagenow||"themes-network"===pagenow?"update-theme"===t.action?a=c('[data-slug="'+t.data.slug+'"]').find(".update-message"):"delete-theme"===t.action&&"themes-network"===pagenow?a=c('[data-slug="'+t.data.slug+'"]').find(".row-actions a.delete"):"delete-theme"===t.action&&"themes"===pagenow&&(a=c(".theme-actions .delete-theme")):a=s,a&&a.hasClass("updating-message")&&(void 0===(s=a.data("originaltext"))&&(s=c("<p>").html(a.find("p").data("originaltext"))),a.removeClass("updating-message").html(s),"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||("update-plugin"===t.action?a.attr("aria-label",r(d("Update %s now","plugin"),a.data("name"))):"install-plugin"===t.action&&a.attr("aria-label",r(d("Install %s now","plugin"),a.data("name"))))),g.a11y.speak(h("Update canceled."))}),o.on("click","[data-plugin] .update-link",function(e){var t=c(e.target),a=t.parents("tr");e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.maybeRequestFilesystemCredentials(e),g.updates.$elToReturnFocusToFromCredentialsModal=a.find(".check-column input"),g.updates.updatePlugin({plugin:a.data("plugin"),slug:a.data("slug")}))}),i.on("click",".update-now",function(e){var t=c(e.target);e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.maybeRequestFilesystemCredentials(e),g.updates.updatePlugin({plugin:t.data("plugin"),slug:t.data("slug")}))}),i.on("click",".install-now",function(e){var t=c(e.target);e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.shouldRequestFilesystemCredentials&&!g.updates.ajaxLocked&&(g.updates.requestFilesystemCredentials(e),f.on("credential-modal-cancel",function(){c(".install-now.updating-message").removeClass("updating-message").text(d("Install Now","plugin")),g.a11y.speak(h("Update canceled."))})),g.updates.installPlugin({slug:t.data("slug")}))}),f.on("click","#plugin-information-footer .activate-now",function(e){e.preventDefault(),window.parent.location.href=c(e.target).attr("href")}),f.on("click",".importer-item .install-now",function(e){var t=c(e.target),a=c(this).data("name");e.preventDefault(),t.hasClass("updating-message")||(g.updates.shouldRequestFilesystemCredentials&&!g.updates.ajaxLocked&&(g.updates.requestFilesystemCredentials(e),f.on("credential-modal-cancel",function(){t.removeClass("updating-message").attr("aria-label",r(d("Install %s now","plugin"),a)).text(d("Install Now","plugin")),g.a11y.speak(h("Update canceled."))})),g.updates.installPlugin({slug:t.data("slug"),pagenow:pagenow,success:g.updates.installImporterSuccess,error:g.updates.installImporterError}))}),o.on("click","[data-plugin] a.delete",function(e){var t=c(e.target).parents("tr"),a=t.hasClass("is-uninstallable")?r(h("Are you sure you want to delete %s and its data?"),t.find(".plugin-title strong").text()):r(h("Are you sure you want to delete %s?"),t.find(".plugin-title strong").text());e.preventDefault(),window.confirm(a)&&(g.updates.maybeRequestFilesystemCredentials(e),g.updates.deletePlugin({plugin:t.data("plugin"),slug:t.data("slug")}))}),f.on("click",".themes-php.network-admin .update-link",function(e){var t=c(e.target),a=t.parents("tr");e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.maybeRequestFilesystemCredentials(e),g.updates.$elToReturnFocusToFromCredentialsModal=a.find(".check-column input"),g.updates.updateTheme({slug:a.data("slug")}))}),f.on("click",".themes-php.network-admin a.delete",function(e){var t=c(e.target).parents("tr"),a=r(h("Are you sure you want to delete %s?"),t.find(".theme-title strong").text());e.preventDefault(),window.confirm(a)&&(g.updates.maybeRequestFilesystemCredentials(e),g.updates.deleteTheme({slug:t.data("slug")}))}),o.on("click",'[type="submit"]:not([name="clear-recent-list"])',function(e){var t,s,n=c(e.target).siblings("select").val(),a=o.find('input[name="checked[]"]:checked'),i=0,l=0,d=[];switch(pagenow){case"plugins":case"plugins-network":t="plugin";break;case"themes-network":t="theme";break;default:return}if(!a.length)return e.preventDefault(),c("html, body").animate({scrollTop:0}),g.updates.addAdminNotice({id:"no-items-selected",className:"notice-error is-dismissible",message:h("Please select at least one item to perform this action on.")});switch(n){case"update-selected":s=n.replace("selected",t);break;case"delete-selected":var u=h("plugin"===t?"Are you sure you want to delete the selected plugins and their data?":"Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?");if(!window.confirm(u))return void e.preventDefault();s=n.replace("selected",t);break;default:return}g.updates.maybeRequestFilesystemCredentials(e),e.preventDefault(),o.find('.manage-column [type="checkbox"]').prop("checked",!1),f.trigger("wp-"+t+"-bulk-"+n,a),a.each(function(e,t){var t=c(t),a=t.parents("tr");"update-selected"!==n||a.hasClass("update")&&!a.find("notice-error").length?"update-selected"===n&&a.hasClass("is-enqueued")||(a.addClass("is-enqueued"),g.updates.queue.push({action:s,data:{plugin:a.data("plugin"),slug:a.data("slug")}})):t.prop("checked",!1)}),f.on("wp-plugin-update-success wp-plugin-update-error wp-theme-update-success wp-theme-update-error",function(e,t){var a,s=c('[data-slug="'+t.slug+'"]');"wp-"+t.update+"-update-success"===e.type?i++:(e=t.pluginName||s.find(".column-primary strong").text(),l++,d.push(e+": "+t.errorMessage)),s.find('input[name="checked[]"]:checked').prop("checked",!1),g.updates.adminNotice=g.template("wp-bulk-updates-admin-notice"),g.updates.addAdminNotice({id:"bulk-action-notice",className:"bulk-action-notice",successes:i,errors:l,errorMessages:d,type:t.update}),a=c("#bulk-action-notice").on("click","button",function(){c(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!c(this).hasClass("bulk-action-errors-collapsed")),a.find(".bulk-action-errors").toggleClass("hidden")}),0<l&&!g.updates.queue.length&&c("html, body").animate({scrollTop:0})}),f.on("wp-updates-notice-added",function(){g.updates.adminNotice=g.template("wp-updates-admin-notice")}),g.updates.queueChecker()}),s.length&&s.attr("aria-describedby","live-search-desc"),s.on("keyup input",_.debounce(function(e,t){var a=c(".plugin-install-search"),s={_ajax_nonce:g.updates.ajaxNonce,s:encodeURIComponent(e.target.value),tab:"search",type:c("#typeselector").val(),pagenow:pagenow},n=location.href.split("?")[0]+"?"+c.param(_.omit(s,["_ajax_nonce","pagenow"]));"keyup"===e.type&&27===e.which&&(e.target.value=""),g.updates.searchTerm===s.s&&"typechange"!==t||(i.empty(),g.updates.searchTerm=s.s,window.history&&window.history.replaceState&&window.history.replaceState(null,"",n),a.length||(a=c('<li class="plugin-install-search" />').append(c("<a />",{class:"current",href:n,text:h("Search Results")})),c(".wp-filter .filter-links .current").removeClass("current").parents(".filter-links").prepend(a),i.prev("p").remove(),c(".plugins-popular-tags-wrapper").remove()),void 0!==g.updates.searchRequest&&g.updates.searchRequest.abort(),c("body").addClass("loading-content"),g.updates.searchRequest=g.ajax.post("search-install-plugins",s).done(function(e){c("body").removeClass("loading-content"),i.append(e.items),delete g.updates.searchRequest,0===e.count?g.a11y.speak(h("You do not appear to have any plugins available at this time.")):g.a11y.speak(r(h("Number of plugins found: %d"),e.count))}))},1e3)),a.length&&a.attr("aria-describedby","live-search-desc"),a.on("keyup input",_.debounce(function(e){var s={_ajax_nonce:g.updates.ajaxNonce,s:encodeURIComponent(e.target.value),pagenow:pagenow,plugin_status:"all"};"keyup"===e.type&&27===e.which&&(e.target.value=""),g.updates.searchTerm!==s.s&&(g.updates.searchTerm=s.s,e=_.object(_.compact(_.map(location.search.slice(1).split("&"),function(e){if(e)return e.split("=")}))),s.plugin_status=e.plugin_status||"all",window.history&&window.history.replaceState&&window.history.replaceState(null,"",location.href.split("?")[0]+"?s="+s.s+"&plugin_status="+s.plugin_status),void 0!==g.updates.searchRequest&&g.updates.searchRequest.abort(),o.empty(),c("body").addClass("loading-content"),c(".subsubsub .current").removeClass("current"),g.updates.searchRequest=g.ajax.post("search-plugins",s).done(function(e){var t=c("<span />").addClass("subtitle").html(r(h("Search results for: %s"),"<strong>"+_.escape(decodeURIComponent(s.s))+"</strong>")),a=c(".wrap .subtitle");s.s.length?a.length?a.replaceWith(t):c(".wp-header-end").before(t):(a.remove(),c(".subsubsub ."+s.plugin_status+" a").addClass("current")),c("body").removeClass("loading-content"),o.append(e.items),delete g.updates.searchRequest,0===e.count?g.a11y.speak(h("No plugins found. Try a different search.")):g.a11y.speak(r(h("Number of plugins found: %d"),e.count))}))},500)),f.on("submit",".search-plugins",function(e){e.preventDefault(),c("input.wp-filter-search").trigger("input")}),f.on("click",".try-again",function(e){e.preventDefault(),s.trigger("input")}),c("#typeselector").on("change",function(){var e=c('input[name="s"]');e.val().length&&e.trigger("input","typechange")}),c("#plugin_update_from_iframe").on("click",function(e){var t=window.parent===window?null:window.parent;c.support.postMessage=!!window.postMessage,!1!==c.support.postMessage&&null!==t&&-1===window.parent.location.pathname.indexOf("update-core.php")&&(e.preventDefault(),e={action:"update-plugin",data:{plugin:c(this).data("plugin"),slug:c(this).data("slug")}},t.postMessage(JSON.stringify(e),window.location.origin))}),c(window).on("message",function(e){var t,e=e.originalEvent,a=document.location.protocol+"//"+document.location.host;if(e.origin===a){try{t=JSON.parse(e.data)}catch(e){return}if(t)if(void 0!==t.status&&void 0!==t.slug&&void 0!==t.text&&void 0!==t.ariaLabel&&(a=c(".plugin-card-"+t.slug).find('[data-slug="'+t.slug+'"]'),void 0!==t.removeClasses&&a.removeClass(t.removeClasses),void 0!==t.addClasses&&a.addClass(t.addClasses),""===t.ariaLabel?a.removeAttr("aria-label"):a.attr("aria-label",t.ariaLabel),"dependencies-check-success"===t.status&&a.attr("data-name",t.pluginName).attr("data-slug",t.slug).attr("data-plugin",t.plugin).attr("href",t.href),a.text(t.text)),void 0!==t.action)switch(t.action){case"decrementUpdateCount":g.updates.decrementCount(t.upgradeType);break;case"install-plugin":case"update-plugin":void 0!==t.data&&void 0!==t.data.slug&&(t.data=g.updates._addCallbacks(t.data,t.action),g.updates.queue.push(t),g.updates.queueChecker())}}}),c(window).on("beforeunload",g.updates.beforeunload),f.on("keydown",".column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update",function(e){32===e.which&&e.preventDefault()}),f.on("click keyup",".column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update",function(e){var l,d,u,o=c(this),r=o.attr("data-wp-action"),p=o.find(".label");if(("keyup"!==e.type||32===e.which)&&(u="themes"!==pagenow?o.closest(".column-auto-updates"):o.closest(".theme-autoupdate"),e.preventDefault(),"yes"!==o.attr("data-doing-ajax"))){switch(o.attr("data-doing-ajax","yes"),pagenow){case"plugins":case"plugins-network":d="plugin",l=o.closest("tr").attr("data-plugin");break;case"themes-network":d="theme",l=o.closest("tr").attr("data-slug");break;case"themes":d="theme",l=o.attr("data-slug")}u.find(".notice.notice-error").addClass("hidden"),"enable"===r?p.text(h("Enabling...")):p.text(h("Disabling...")),o.find(".dashicons-update").removeClass("hidden"),e={action:"toggle-auto-updates",_ajax_nonce:m.ajax_nonce,state:r,type:d,asset:l},c.post(window.ajaxurl,e).done(function(e){var t,a,s,n,i=o.attr("href");if(e.success){if("themes"!==pagenow){switch(n=c(".auto-update-enabled span"),t=c(".auto-update-disabled span"),a=parseInt(n.text().replace(/[^\d]+/g,""),10)||0,s=parseInt(t.text().replace(/[^\d]+/g,""),10)||0,r){case"enable":++a,--s;break;case"disable":--a,++s}a=Math.max(0,a),s=Math.max(0,s),n.text("("+a+")"),t.text("("+s+")")}"enable"===r?(o[0].hasAttribute("href")&&(i=i.replace("action=enable-auto-update","action=disable-auto-update"),o.attr("href",i)),o.attr("data-wp-action","disable"),p.text(h("Disable auto-updates")),u.find(".auto-update-time").removeClass("hidden"),g.a11y.speak(h("Auto-updates enabled"))):(o[0].hasAttribute("href")&&(i=i.replace("action=disable-auto-update","action=enable-auto-update"),o.attr("href",i)),o.attr("data-wp-action","enable"),p.text(h("Enable auto-updates")),u.find(".auto-update-time").addClass("hidden"),g.a11y.speak(h("Auto-updates disabled"))),f.trigger("wp-auto-update-setting-changed",{state:r,type:d,asset:l})}else n=e.data&&e.data.error?e.data.error:h("The request could not be completed."),u.find(".notice.notice-error").removeClass("hidden").find("p").text(n),g.a11y.speak(n,"assertive")}).fail(function(){u.find(".notice.notice-error").removeClass("hidden").find("p").text(h("The request could not be completed.")),g.a11y.speak(h("The request could not be completed."),"assertive")}).always(function(){o.removeAttr("data-doing-ajax").find(".dashicons-update").addClass("hidden")})}})})}(jQuery,window.wp,window._wpUpdatesSettings);
\ No newline at end of file +!function(c,g,m){var f=c(document),h=g.i18n.__,d=g.i18n._x,r=g.i18n._n,o=g.i18n._nx,p=g.i18n.sprintf;(g=g||{}).updates={},g.updates.l10n={searchResults:"",searchResultsLabel:"",noPlugins:"",noItemsSelected:"",updating:"",pluginUpdated:"",themeUpdated:"",update:"",updateNow:"",pluginUpdateNowLabel:"",updateFailedShort:"",updateFailed:"",pluginUpdatingLabel:"",pluginUpdatedLabel:"",pluginUpdateFailedLabel:"",updatingMsg:"",updatedMsg:"",updateCancel:"",beforeunload:"",installNow:"",pluginInstallNowLabel:"",installing:"",pluginInstalled:"",themeInstalled:"",installFailedShort:"",installFailed:"",pluginInstallingLabel:"",themeInstallingLabel:"",pluginInstalledLabel:"",themeInstalledLabel:"",pluginInstallFailedLabel:"",themeInstallFailedLabel:"",installingMsg:"",installedMsg:"",importerInstalledMsg:"",aysDelete:"",aysDeleteUninstall:"",aysBulkDelete:"",aysBulkDeleteThemes:"",deleting:"",deleteFailed:"",pluginDeleted:"",themeDeleted:"",livePreview:"",activatePlugin:"",activateTheme:"",activatePluginLabel:"",activateThemeLabel:"",activateImporter:"",activateImporterLabel:"",unknownError:"",connectionError:"",nonceError:"",pluginsFound:"",noPluginsFound:"",autoUpdatesEnable:"",autoUpdatesEnabling:"",autoUpdatesEnabled:"",autoUpdatesDisable:"",autoUpdatesDisabling:"",autoUpdatesDisabled:"",autoUpdatesError:""},g.updates.l10n=window.wp.deprecateL10nObject("wp.updates.l10n",g.updates.l10n,"5.5.0"),g.updates.ajaxNonce=m.ajax_nonce,g.updates.searchTerm="",g.updates.shouldRequestFilesystemCredentials=!1,g.updates.filesystemCredentials={ftp:{host:"",username:"",password:"",connectionType:""},ssh:{publicKey:"",privateKey:""},fsNonce:"",available:!1},g.updates.ajaxLocked=!1,g.updates.adminNotice=g.template("wp-updates-admin-notice"),g.updates.queue=[],g.updates.$elToReturnFocusToFromCredentialsModal=void 0,g.updates.addAdminNotice=function(e){var t,a=c(e.selector),s=c(".wp-header-end");delete e.selector,t=g.updates.adminNotice(e),(a=a.length?a:c("#"+e.id)).length?a.replaceWith(t):s.length?s.after(t):"customize"===pagenow?c(".customize-themes-notifications").append(t):c(".wrap").find("> h1").after(t),f.trigger("wp-updates-notice-added")},g.updates.ajax=function(e,t){var a={};return g.updates.ajaxLocked?(g.updates.queue.push({action:e,data:t}),c.Deferred()):(g.updates.ajaxLocked=!0,t.success&&(a.success=t.success,delete t.success),t.error&&(a.error=t.error,delete t.error),a.data=_.extend(t,{action:e,_ajax_nonce:g.updates.ajaxNonce,_fs_nonce:g.updates.filesystemCredentials.fsNonce,username:g.updates.filesystemCredentials.ftp.username,password:g.updates.filesystemCredentials.ftp.password,hostname:g.updates.filesystemCredentials.ftp.hostname,connection_type:g.updates.filesystemCredentials.ftp.connectionType,public_key:g.updates.filesystemCredentials.ssh.publicKey,private_key:g.updates.filesystemCredentials.ssh.privateKey}),g.ajax.send(a).always(g.updates.ajaxAlways))},g.updates.ajaxAlways=function(e){e.errorCode&&"unable_to_connect_to_filesystem"===e.errorCode||(g.updates.ajaxLocked=!1,g.updates.queueChecker()),void 0!==e.debug&&window.console&&window.console.log&&_.map(e.debug,function(e){window.console.log(g.sanitize.stripTagsAndEncodeText(e))})},g.updates.refreshCount=function(){var e,t=c("#wp-admin-bar-updates"),a=c('a[href="update-core.php"] .update-plugins'),s=c('a[href="plugins.php"] .update-plugins'),n=c('a[href="themes.php"] .update-plugins');t.find(".ab-label").text(m.totals.counts.total),t.find(".updates-available-text").text(p(r("%s update available","%s updates available",m.totals.counts.total),m.totals.counts.total)),0===m.totals.counts.total&&t.find(".ab-label").parents("li").remove(),a.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+m.totals.counts.total)}),0<m.totals.counts.total?a.find(".update-count").text(m.totals.counts.total):a.remove(),s.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+m.totals.counts.plugins)}),0<m.totals.counts.total?s.find(".plugin-count").text(m.totals.counts.plugins):s.remove(),n.each(function(e,t){t.className=t.className.replace(/count-\d+/,"count-"+m.totals.counts.themes)}),0<m.totals.counts.total?n.find(".theme-count").text(m.totals.counts.themes):n.remove(),"plugins"===pagenow||"plugins-network"===pagenow?e=m.totals.counts.plugins:"themes"!==pagenow&&"themes-network"!==pagenow||(e=m.totals.counts.themes),0<e?c(".subsubsub .upgrade .count").text("("+e+")"):(c(".subsubsub .upgrade").remove(),c(".subsubsub li:last").html(function(){return c(this).children()}))},g.updates.setCardButtonStatus=function(e){var t=window.parent===window?null:window.parent;c.support.postMessage=!!window.postMessage,!1!==c.support.postMessage&&null!==t&&-1===window.parent.location.pathname.indexOf("index.php")&&t.postMessage(JSON.stringify(e),window.location.origin)},g.updates.decrementCount=function(e){m.totals.counts.total=Math.max(--m.totals.counts.total,0),"plugin"===e?m.totals.counts.plugins=Math.max(--m.totals.counts.plugins,0):"theme"===e&&(m.totals.counts.themes=Math.max(--m.totals.counts.themes,0)),g.updates.refreshCount(e)},g.updates.updatePlugin=function(e){var t,a,s,n=c("#wp-admin-bar-updates"),i=h("Updating..."),l="plugin-install"===pagenow||"plugin-install-network"===pagenow;return e=_.extend({success:g.updates.updatePluginSuccess,error:g.updates.updatePluginError},e),"plugins"===pagenow||"plugins-network"===pagenow?(a=(s=c('tr[data-plugin="'+e.plugin+'"]')).find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning").find("p"),s=p(d("Updating %s...","plugin"),s.find(".plugin-title strong").text())):l&&(a=(t=c(".plugin-card-"+e.slug+", #plugin-information-footer")).find(".update-now").addClass("updating-message"),s=p(d("Updating %s...","plugin"),a.data("name")),t.removeClass("plugin-card-update-failed").find(".notice.notice-error").remove()),n.addClass("spin"),a.html()!==h("Updating...")&&a.data("originaltext",a.html()),a.attr("aria-label",s).text(i),f.trigger("wp-plugin-updating",e),l&&"plugin-information-footer"===t.attr("id")&&g.updates.setCardButtonStatus({status:"updating-plugin",slug:e.slug,addClasses:"updating-message",text:i,ariaLabel:s}),g.updates.ajax("update-plugin",e)},g.updates.updatePluginSuccess=function(e){var t,a,s,n=c("#wp-admin-bar-updates"),i=d("Updated!","plugin"),l=p(d("%s updated!","plugin"),e.pluginName);"plugins"===pagenow||"plugins-network"===pagenow?(a=(t=c('tr[data-plugin="'+e.plugin+'"]').removeClass("update is-enqueued").addClass("updated")).find(".update-message").removeClass("updating-message notice-warning").addClass("updated-message notice-success").find("p"),s=t.find(".plugin-version-author-uri").html().replace(e.oldVersion,e.newVersion),t.find(".plugin-version-author-uri").html(s),t.find(".auto-update-time").empty()):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(a=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".update-now").removeClass("updating-message").addClass("button-disabled updated-message")),n.removeClass("spin"),a.attr("aria-label",l).text(i),g.a11y.speak(h("Update completed successfully.")),"plugin_install_from_iframe"!==a.attr("id")?g.updates.decrementCount("plugin"):g.updates.setCardButtonStatus({status:"updated-plugin",slug:e.slug,removeClasses:"updating-message",addClasses:"button-disabled updated-message",text:i,ariaLabel:l}),f.trigger("wp-plugin-update-success",e)},g.updates.updatePluginError=function(e){var t,a,s,n,i,l=c("#wp-admin-bar-updates");g.updates.isValidResponse(e,"update")&&!g.updates.maybeHandleCredentialError(e,"update-plugin")&&(s=p(h("Update failed: %s"),e.errorMessage),"plugins"===pagenow||"plugins-network"===pagenow?(c('tr[data-plugin="'+e.plugin+'"]').removeClass("is-enqueued"),(a=(e.plugin?c('tr[data-plugin="'+e.plugin+'"]'):c('tr[data-slug="'+e.slug+'"]')).find(".update-message")).removeClass("updating-message notice-warning").addClass("notice-error").find("p").html(s),e.pluginName?a.find("p").attr("aria-label",p(d("%s update failed.","plugin"),e.pluginName)):a.find("p").removeAttr("aria-label")):"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||(n=h("Update failed."),(t=c(".plugin-card-"+e.slug+", #plugin-information-footer").append(g.updates.adminNotice({className:"update-message notice-error notice-alt is-dismissible",message:s}))).hasClass("plugin-card-"+e.slug)&&t.addClass("plugin-card-update-failed"),t.find(".update-now").text(n).removeClass("updating-message"),e.pluginName?(i=p(d("%s update failed.","plugin"),e.pluginName),t.find(".update-now").attr("aria-label",i)):(i="",t.find(".update-now").removeAttr("aria-label")),t.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){t.removeClass("plugin-card-update-failed").find(".column-name a").trigger("focus"),t.find(".update-now").attr("aria-label",!1).text(h("Update Now"))},200)})),l.removeClass("spin"),g.a11y.speak(s,"assertive"),"plugin-information-footer"===t.attr("id")&&g.updates.setCardButtonStatus({status:"plugin-update-failed",slug:e.slug,removeClasses:"updating-message",text:n,ariaLabel:i}),f.trigger("wp-plugin-update-error",e))},g.updates.installPlugin=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer"),s=a.find(".install-now"),n=h("Installing...");return e=_.extend({success:g.updates.installPluginSuccess,error:g.updates.installPluginError},e),(s="import"===pagenow?c('[data-slug="'+e.slug+'"]'):s).html()!==h("Installing...")&&s.data("originaltext",s.html()),t=p(d("Installing %s...","plugin"),s.data("name")),s.addClass("updating-message").attr("aria-label",t).text(n),g.a11y.speak(h("Installing... please wait.")),a.removeClass("plugin-card-install-failed").find(".notice.notice-error").remove(),f.trigger("wp-plugin-installing",e),"plugin-information-footer"===s.parent().attr("id")&&g.updates.setCardButtonStatus({status:"installing-plugin",slug:e.slug,addClasses:"updating-message",text:n,ariaLabel:t}),g.updates.ajax("install-plugin",e)},g.updates.installPluginSuccess=function(e){var t=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".install-now"),a=d("Installed!","plugin"),s=p(d("%s installed!","plugin"),e.pluginName);t.removeClass("updating-message").addClass("updated-message installed button-disabled").attr("aria-label",s).text(a),g.a11y.speak(h("Installation completed successfully.")),f.trigger("wp-plugin-install-success",e),e.activateUrl&&setTimeout(function(){g.updates.checkPluginDependencies({slug:e.slug})},1e3),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"installed-plugin",slug:e.slug,removeClasses:"updating-message",addClasses:"updated-message installed button-disabled",text:a,ariaLabel:s})},g.updates.installPluginError=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer"),s=a.find(".install-now"),n=h("Installation failed."),i=p(d("%s installation failed","plugin"),s.data("name"));g.updates.isValidResponse(e,"install")&&!g.updates.maybeHandleCredentialError(e,"install-plugin")&&(t=p(h("Installation failed: %s"),e.errorMessage),a.addClass("plugin-card-update-failed").append('<div class="notice notice-error notice-alt is-dismissible" role="alert"><p>'+t+"</p></div>"),a.on("click",".notice.is-dismissible .notice-dismiss",function(){setTimeout(function(){a.removeClass("plugin-card-update-failed").find(".column-name a").trigger("focus")},200)}),s.removeClass("updating-message").addClass("button-disabled").attr("aria-label",i).text(n),g.a11y.speak(t,"assertive"),g.updates.setCardButtonStatus({status:"plugin-install-failed",slug:e.slug,removeClasses:"updating-message",addClasses:"button-disabled",text:n,ariaLabel:i}),f.trigger("wp-plugin-install-error",e))},g.updates.checkPluginDependencies=function(e){return e=_.extend({success:g.updates.checkPluginDependenciesSuccess,error:g.updates.checkPluginDependenciesError},e),g.a11y.speak(h("Checking plugin dependencies... please wait.")),f.trigger("wp-checking-plugin-dependencies",e),g.updates.ajax("check_plugin_dependencies",e)},g.updates.checkPluginDependenciesSuccess=function(e){var t,a,s=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".install-now");s.removeClass("install-now installed button-disabled updated-message").addClass("activate-now button-primary").attr("href",e.activateUrl),g.a11y.speak(h("Plugin dependencies check completed successfully.")),f.trigger("wp-check-plugin-dependencies-success",e),("plugins-network"===pagenow?(t=d("Network Activate","plugin"),a=p(d("Network Activate %s","plugin"),e.pluginName),s.attr("aria-label",a)):(t=d("Activate","plugin"),a=p(d("Activate %s","plugin"),e.pluginName),s.attr("aria-label",a).attr("data-name",e.pluginName).attr("data-slug",e.slug).attr("data-plugin",e.plugin))).text(t),"plugin-information-footer"===s.parent().attr("id")&&g.updates.setCardButtonStatus({status:"dependencies-check-success",slug:e.slug,removeClasses:"install-now installed button-disabled updated-message",addClasses:"activate-now button-primary",text:t,ariaLabel:a,pluginName:e.pluginName,plugin:e.plugin,href:e.activateUrl})},g.updates.checkPluginDependenciesError=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".install-now"),s=d("Activate","plugin"),n=p(d("Cannot activate %1$s. %2$s","plugin"),e.pluginName,e.errorMessage);g.updates.isValidResponse(e,"check-dependencies")&&(t=p(h("Activation failed: %s"),e.errorMessage),g.a11y.speak(t,"assertive"),f.trigger("wp-check-plugin-dependencies-error",e),a.removeClass("install-now installed updated-message").addClass("activate-now button-primary").attr("aria-label",n).text(s),"plugin-information-footer"===a.parent().attr("id"))&&g.updates.setCardButtonStatus({status:"dependencies-check-failed",slug:e.slug,removeClasses:"install-now installed updated-message",addClasses:"activate-now button-primary",text:s,ariaLabel:n})},g.updates.activatePlugin=function(e){var t=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".activate-now, .activating-message");return e=_.extend({success:g.updates.activatePluginSuccess,error:g.updates.activatePluginError},e),g.a11y.speak(h("Activating... please wait.")),f.trigger("wp-activating-plugin",e),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"activating-plugin",slug:e.slug,removeClasses:"installed updated-message button-primary",addClasses:"activating-message",text:h("Activating..."),ariaLabel:p(d("Activating %s","plugin"),e.name)}),g.updates.ajax("activate-plugin",e)},g.updates.activatePluginSuccess=function(e){var t=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".activating-message"),a=d("Activated!","plugin"),s=p("%s activated successfully.",e.pluginName);g.a11y.speak(h("Activation completed successfully.")),f.trigger("wp-plugin-activate-success",e),t.removeClass("activating-message").addClass("activated-message button-disabled").attr("aria-label",s).text(a),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"activated-plugin",slug:e.slug,removeClasses:"activating-message",addClasses:"activated-message button-disabled",text:a,ariaLabel:s}),setTimeout(function(){t.removeClass("activated-message").text(d("Active","plugin")),"plugin-information-footer"===t.parent().attr("id")&&g.updates.setCardButtonStatus({status:"plugin-active",slug:e.slug,removeClasses:"activated-message",text:d("Active","plugin"),ariaLabel:p("%s is active.",e.pluginName)})},1e3)},g.updates.activatePluginError=function(e){var t,a=c(".plugin-card-"+e.slug+", #plugin-information-footer").find(".activating-message"),s=h("Activation failed."),n=p(d("%s activation failed","plugin"),e.pluginName);g.updates.isValidResponse(e,"activate")&&(t=p(h("Activation failed: %s"),e.errorMessage),g.a11y.speak(t,"assertive"),f.trigger("wp-plugin-activate-error",e),a.removeClass("install-now installed activating-message").addClass("button-disabled").attr("aria-label",n).text(s),"plugin-information-footer"===a.parent().attr("id"))&&g.updates.setCardButtonStatus({status:"plugin-activation-failed",slug:e.slug,removeClasses:"install-now installed activating-message",addClasses:"button-disabled",text:s,ariaLabel:n})},g.updates.installImporterSuccess=function(e){g.updates.addAdminNotice({id:"install-success",className:"notice-success is-dismissible",message:p(h('Importer installed successfully. <a href="%s">Run importer</a>'),e.activateUrl+"&from=import")}),c('[data-slug="'+e.slug+'"]').removeClass("install-now updating-message").addClass("activate-now").attr({href:e.activateUrl+"&from=import","aria-label":p(h("Run %s"),e.pluginName)}).text(h("Run Importer")),g.a11y.speak(h("Installation completed successfully.")),f.trigger("wp-importer-install-success",e)},g.updates.installImporterError=function(e){var t=p(h("Installation failed: %s"),e.errorMessage),a=c('[data-slug="'+e.slug+'"]'),s=a.data("name");g.updates.isValidResponse(e,"install")&&!g.updates.maybeHandleCredentialError(e,"install-plugin")&&(g.updates.addAdminNotice({id:e.errorCode,className:"notice-error is-dismissible",message:t}),a.removeClass("updating-message").attr("aria-label",p(d("Install %s now","plugin"),s)).text(d("Install Now","plugin")),g.a11y.speak(t,"assertive"),f.trigger("wp-importer-install-error",e))},g.updates.deletePlugin=function(e){var t=c('[data-plugin="'+e.plugin+'"]').find(".row-actions a.delete");return e=_.extend({success:g.updates.deletePluginSuccess,error:g.updates.deletePluginError},e),t.html()!==h("Deleting...")&&t.data("originaltext",t.html()).text(h("Deleting...")),g.a11y.speak(h("Deleting...")),f.trigger("wp-plugin-deleting",e),g.updates.ajax("delete-plugin",e)},g.updates.deletePluginSuccess=function(u){c('[data-plugin="'+u.plugin+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=c("#bulk-action-form"),t=c(".subsubsub"),a=c(this),s=t.find('[aria-current="page"]'),n=c(".displaying-num"),i=e.find("thead th:not(.hidden), thead td").length,l=g.template("item-deleted-row"),d=m.plugins;a.hasClass("plugin-update-tr")||a.after(l({slug:u.slug,plugin:u.plugin,colspan:i,name:u.pluginName})),a.remove(),-1!==_.indexOf(d.upgrade,u.plugin)&&(d.upgrade=_.without(d.upgrade,u.plugin),g.updates.decrementCount("plugin")),-1!==_.indexOf(d.inactive,u.plugin)&&(d.inactive=_.without(d.inactive,u.plugin),d.inactive.length?t.find(".inactive .count").text("("+d.inactive.length+")"):t.find(".inactive").remove()),-1!==_.indexOf(d.active,u.plugin)&&(d.active=_.without(d.active,u.plugin),d.active.length?t.find(".active .count").text("("+d.active.length+")"):t.find(".active").remove()),-1!==_.indexOf(d.recently_activated,u.plugin)&&(d.recently_activated=_.without(d.recently_activated,u.plugin),d.recently_activated.length?t.find(".recently_activated .count").text("("+d.recently_activated.length+")"):t.find(".recently_activated").remove()),-1!==_.indexOf(d["auto-update-enabled"],u.plugin)&&(d["auto-update-enabled"]=_.without(d["auto-update-enabled"],u.plugin),d["auto-update-enabled"].length?t.find(".auto-update-enabled .count").text("("+d["auto-update-enabled"].length+")"):t.find(".auto-update-enabled").remove()),-1!==_.indexOf(d["auto-update-disabled"],u.plugin)&&(d["auto-update-disabled"]=_.without(d["auto-update-disabled"],u.plugin),d["auto-update-disabled"].length?t.find(".auto-update-disabled .count").text("("+d["auto-update-disabled"].length+")"):t.find(".auto-update-disabled").remove()),d.all=_.without(d.all,u.plugin),d.all.length?t.find(".all .count").text("("+d.all.length+")"):(e.find(".tablenav").css({visibility:"hidden"}),t.find(".all").remove(),e.find("tr.no-items").length||e.find("#the-list").append('<tr class="no-items"><td class="colspanchange" colspan="'+i+'">'+h("No plugins are currently available.")+"</td></tr>")),n.length&&s.length&&(l=d[s.parent("li").attr("class")].length,n.text(p(o("%s item","%s items",l,"plugin/plugins"),l)))}),g.a11y.speak(d("Deleted!","plugin")),f.trigger("wp-plugin-delete-success",u)},g.updates.deletePluginError=function(e){var t,a=g.template("item-update-row"),s=g.updates.adminNotice({className:"update-message notice-error notice-alt",message:e.errorMessage}),n=e.plugin?(t=c('tr.inactive[data-plugin="'+e.plugin+'"]')).siblings('[data-plugin="'+e.plugin+'"]'):(t=c('tr.inactive[data-slug="'+e.slug+'"]')).siblings('[data-slug="'+e.slug+'"]');g.updates.isValidResponse(e,"delete")&&!g.updates.maybeHandleCredentialError(e,"delete-plugin")&&(n.length?(n.find(".notice-error").remove(),n.find(".plugin-update").append(s)):t.addClass("update").after(a({slug:e.slug,plugin:e.plugin||e.slug,colspan:c("#bulk-action-form").find("thead th:not(.hidden), thead td").length,content:s})),f.trigger("wp-plugin-delete-error",e))},g.updates.updateTheme=function(e){var t;return e=_.extend({success:g.updates.updateThemeSuccess,error:g.updates.updateThemeError},e),(t=("themes-network"===pagenow?c('[data-slug="'+e.slug+'"]').find(".update-message").removeClass("notice-error").addClass("updating-message notice-warning"):(t="customize"===pagenow?((t=c('[data-slug="'+e.slug+'"].notice').removeClass("notice-large")).find("h3").remove(),t.add(c("#customize-control-installed_theme_"+e.slug).find(".update-message"))):((t=c("#update-theme").closest(".notice").removeClass("notice-large")).find("h3").remove(),t.add(c('[data-slug="'+e.slug+'"]').find(".update-message")))).addClass("updating-message")).find("p")).html()!==h("Updating...")&&t.data("originaltext",t.html()),g.a11y.speak(h("Updating... please wait.")),t.text(h("Updating...")),f.trigger("wp-theme-updating",e),g.updates.ajax("update-theme",e)},g.updates.updateThemeSuccess=function(e){var t,a,s=c("body.modal-open").length,n=c('[data-slug="'+e.slug+'"]'),i={className:"updated-message notice-success notice-alt",message:d("Updated!","theme")};"customize"===pagenow?((n=c(".updating-message").siblings(".theme-name")).length&&(a=n.html().replace(e.oldVersion,e.newVersion),n.html(a)),t=c(".theme-info .notice").add(g.customize.control("installed_theme_"+e.slug).container.find(".theme").find(".update-message"))):"themes-network"===pagenow?(t=n.find(".update-message"),a=n.find(".theme-version-author-uri").html().replace(e.oldVersion,e.newVersion),n.find(".theme-version-author-uri").html(a),n.find(".auto-update-time").empty()):(t=c(".theme-info .notice").add(n.find(".update-message")),s?(c(".load-customize:visible").trigger("focus"),c(".theme-info .theme-autoupdate").find(".auto-update-time").empty()):n.find(".load-customize").trigger("focus")),g.updates.addAdminNotice(_.extend({selector:t},i)),g.a11y.speak(h("Update completed successfully.")),g.updates.decrementCount("theme"),f.trigger("wp-theme-update-success",e),s&&"customize"!==pagenow&&c(".theme-info .theme-author").after(g.updates.adminNotice(i))},g.updates.updateThemeError=function(e){var t,a=c('[data-slug="'+e.slug+'"]'),s=p(h("Update failed: %s"),e.errorMessage);g.updates.isValidResponse(e,"update")&&!g.updates.maybeHandleCredentialError(e,"update-theme")&&("customize"===pagenow&&(a=g.customize.control("installed_theme_"+e.slug).container.find(".theme")),"themes-network"===pagenow?t=a.find(".update-message "):(t=c(".theme-info .notice").add(a.find(".notice")),(c("body.modal-open").length?c(".load-customize:visible"):a.find(".load-customize")).trigger("focus")),g.updates.addAdminNotice({selector:t,className:"update-message notice-error notice-alt is-dismissible",message:s}),g.a11y.speak(s),f.trigger("wp-theme-update-error",e))},g.updates.installTheme=function(e){var t=c('.theme-install[data-slug="'+e.slug+'"]');return e=_.extend({success:g.updates.installThemeSuccess,error:g.updates.installThemeError},e),t.addClass("updating-message"),t.parents(".theme").addClass("focus"),t.html()!==h("Installing...")&&t.data("originaltext",t.html()),t.attr("aria-label",p(d("Installing %s...","theme"),t.data("name"))).text(h("Installing...")),g.a11y.speak(h("Installing... please wait.")),c('.install-theme-info, [data-slug="'+e.slug+'"]').removeClass("theme-install-failed").find(".notice.notice-error").remove(),f.trigger("wp-theme-installing",e),g.updates.ajax("install-theme",e)},g.updates.installThemeSuccess=function(e){var t,a=c(".wp-full-overlay-header, [data-slug="+e.slug+"]");f.trigger("wp-theme-install-success",e),t=a.find(".button-primary").removeClass("updating-message").addClass("updated-message disabled").attr("aria-label",p(d("%s installed!","theme"),e.themeName)).text(d("Installed!","theme")),g.a11y.speak(h("Installation completed successfully.")),setTimeout(function(){e.activateUrl&&(t.attr("href",e.activateUrl).removeClass("theme-install updated-message disabled").addClass("activate"),"themes-network"===pagenow?t.attr("aria-label",p(d("Network Activate %s","theme"),e.themeName)).text(h("Network Enable")):t.attr("aria-label",p(d("Activate %s","theme"),e.themeName)).text(d("Activate","theme"))),e.customizeUrl&&t.siblings(".preview").replaceWith(function(){return c("<a>").attr("href",e.customizeUrl).addClass("button load-customize").text(h("Live Preview"))})},1e3)},g.updates.installThemeError=function(e){var t,a=p(h("Installation failed: %s"),e.errorMessage),s=g.updates.adminNotice({className:"update-message notice-error notice-alt",message:a});g.updates.isValidResponse(e,"install")&&!g.updates.maybeHandleCredentialError(e,"install-theme")&&("customize"===pagenow?(f.find("body").hasClass("modal-open")?(t=c('.theme-install[data-slug="'+e.slug+'"]'),c(".theme-overlay .theme-info").prepend(s)):(t=c('.theme-install[data-slug="'+e.slug+'"]')).closest(".theme").addClass("theme-install-failed").append(s),g.customize.notifications.remove("theme_installing")):f.find("body").hasClass("full-overlay-active")?(t=c('.theme-install[data-slug="'+e.slug+'"]'),c(".install-theme-info").prepend(s)):t=c('[data-slug="'+e.slug+'"]').removeClass("focus").addClass("theme-install-failed").append(s).find(".theme-install"),t.removeClass("updating-message").attr("aria-label",p(d("%s installation failed","theme"),t.data("name"))).text(h("Installation failed.")),g.a11y.speak(a,"assertive"),f.trigger("wp-theme-install-error",e))},g.updates.deleteTheme=function(e){var t;return"themes"===pagenow?t=c(".theme-actions .delete-theme"):"themes-network"===pagenow&&(t=c('[data-slug="'+e.slug+'"]').find(".row-actions a.delete")),e=_.extend({success:g.updates.deleteThemeSuccess,error:g.updates.deleteThemeError},e),t&&t.html()!==h("Deleting...")&&t.data("originaltext",t.html()).text(h("Deleting...")),g.a11y.speak(h("Deleting...")),c(".theme-info .update-message").remove(),f.trigger("wp-theme-deleting",e),g.updates.ajax("delete-theme",e)},g.updates.deleteThemeSuccess=function(n){var e=c('[data-slug="'+n.slug+'"]');"themes-network"===pagenow&&e.css({backgroundColor:"#faafaa"}).fadeOut(350,function(){var e=c(".subsubsub"),t=c(this),a=m.themes,s=g.template("item-deleted-row");t.hasClass("plugin-update-tr")||t.after(s({slug:n.slug,colspan:c("#bulk-action-form").find("thead th:not(.hidden), thead td").length,name:t.find(".theme-title strong").text()})),t.remove(),-1!==_.indexOf(a.upgrade,n.slug)&&(a.upgrade=_.without(a.upgrade,n.slug),g.updates.decrementCount("theme")),-1!==_.indexOf(a.disabled,n.slug)&&(a.disabled=_.without(a.disabled,n.slug),a.disabled.length?e.find(".disabled .count").text("("+a.disabled.length+")"):e.find(".disabled").remove()),-1!==_.indexOf(a["auto-update-enabled"],n.slug)&&(a["auto-update-enabled"]=_.without(a["auto-update-enabled"],n.slug),a["auto-update-enabled"].length?e.find(".auto-update-enabled .count").text("("+a["auto-update-enabled"].length+")"):e.find(".auto-update-enabled").remove()),-1!==_.indexOf(a["auto-update-disabled"],n.slug)&&(a["auto-update-disabled"]=_.without(a["auto-update-disabled"],n.slug),a["auto-update-disabled"].length?e.find(".auto-update-disabled .count").text("("+a["auto-update-disabled"].length+")"):e.find(".auto-update-disabled").remove()),a.all=_.without(a.all,n.slug),e.find(".all .count").text("("+a.all.length+")")}),"themes"===pagenow&&_.find(_wpThemeSettings.themes,{id:n.slug}).hasUpdate&&g.updates.decrementCount("theme"),g.a11y.speak(d("Deleted!","theme")),f.trigger("wp-theme-delete-success",n)},g.updates.deleteThemeError=function(e){var t=c('tr.inactive[data-slug="'+e.slug+'"]'),a=c(".theme-actions .delete-theme"),s=g.template("item-update-row"),n=t.siblings("#"+e.slug+"-update"),i=p(h("Deletion failed: %s"),e.errorMessage),l=g.updates.adminNotice({className:"update-message notice-error notice-alt",message:i});g.updates.maybeHandleCredentialError(e,"delete-theme")||("themes-network"===pagenow?n.length?(n.find(".notice-error").remove(),n.find(".plugin-update").append(l)):t.addClass("update").after(s({slug:e.slug,colspan:c("#bulk-action-form").find("thead th:not(.hidden), thead td").length,content:l})):c(".theme-info .theme-description").before(l),a.html(a.data("originaltext")),g.a11y.speak(i,"assertive"),f.trigger("wp-theme-delete-error",e))},g.updates._addCallbacks=function(e,t){return"import"===pagenow&&"install-plugin"===t&&(e.success=g.updates.installImporterSuccess,e.error=g.updates.installImporterError),e},g.updates.queueChecker=function(){var e;if(!g.updates.ajaxLocked&&g.updates.queue.length)switch((e=g.updates.queue.shift()).action){case"install-plugin":g.updates.installPlugin(e.data);break;case"update-plugin":g.updates.updatePlugin(e.data);break;case"delete-plugin":g.updates.deletePlugin(e.data);break;case"install-theme":g.updates.installTheme(e.data);break;case"update-theme":g.updates.updateTheme(e.data);break;case"delete-theme":g.updates.deleteTheme(e.data)}},g.updates.requestFilesystemCredentials=function(e){!1===g.updates.filesystemCredentials.available&&(e&&!g.updates.$elToReturnFocusToFromCredentialsModal&&(g.updates.$elToReturnFocusToFromCredentialsModal=c(e.target)),g.updates.ajaxLocked=!0,g.updates.requestForCredentialsModalOpen())},g.updates.maybeRequestFilesystemCredentials=function(e){g.updates.shouldRequestFilesystemCredentials&&!g.updates.ajaxLocked&&g.updates.requestFilesystemCredentials(e)},g.updates.keydown=function(e){27===e.keyCode?g.updates.requestForCredentialsModalCancel():9===e.keyCode&&("upgrade"!==e.target.id||e.shiftKey?"hostname"===e.target.id&&e.shiftKey&&(c("#upgrade").trigger("focus"),e.preventDefault()):(c("#hostname").trigger("focus"),e.preventDefault()))},g.updates.requestForCredentialsModalOpen=function(){var e=c("#request-filesystem-credentials-dialog");c("body").addClass("modal-open"),e.show(),e.find("input:enabled:first").trigger("focus"),e.on("keydown",g.updates.keydown)},g.updates.requestForCredentialsModalClose=function(){c("#request-filesystem-credentials-dialog").hide(),c("body").removeClass("modal-open"),g.updates.$elToReturnFocusToFromCredentialsModal&&g.updates.$elToReturnFocusToFromCredentialsModal.trigger("focus")},g.updates.requestForCredentialsModalCancel=function(){(g.updates.ajaxLocked||g.updates.queue.length)&&(_.each(g.updates.queue,function(e){f.trigger("credential-modal-cancel",e)}),g.updates.ajaxLocked=!1,g.updates.queue=[],g.updates.requestForCredentialsModalClose())},g.updates.showErrorInCredentialsForm=function(e){var t=c("#request-filesystem-credentials-form");t.find(".notice").remove(),t.find("#request-filesystem-credentials-title").after('<div class="notice notice-alt notice-error" role="alert"><p>'+e+"</p></div>")},g.updates.credentialError=function(e,t){e=g.updates._addCallbacks(e,t),g.updates.queue.unshift({action:t,data:e}),g.updates.filesystemCredentials.available=!1,g.updates.showErrorInCredentialsForm(e.errorMessage),g.updates.requestFilesystemCredentials()},g.updates.maybeHandleCredentialError=function(e,t){return!(!g.updates.shouldRequestFilesystemCredentials||!e.errorCode||"unable_to_connect_to_filesystem"!==e.errorCode||(g.updates.credentialError(e,t),0))},g.updates.isValidResponse=function(e,t){var a,s=h("Something went wrong.");if(_.isObject(e)&&!_.isFunction(e.always))return!0;switch(_.isString(e)&&"-1"===e?s=h("An error has occurred. Please reload the page and try again."):_.isString(e)?s=e:void 0!==e.readyState&&0===e.readyState?s=h("Connection lost or the server is busy. Please try again later."):_.isString(e.responseText)&&""!==e.responseText?s=e.responseText:_.isString(e.statusText)&&(s=e.statusText),t){case"update":a=h("Update failed: %s");break;case"install":a=h("Installation failed: %s");break;case"check-dependencies":a=h("Dependencies check failed: %s");break;case"activate":a=h("Activation failed: %s");break;case"delete":a=h("Deletion failed: %s")}return s=s.replace(/<[\/a-z][^<>]*>/gi,""),a=a.replace("%s",s),g.updates.addAdminNotice({id:"unknown_error",className:"notice-error is-dismissible",message:_.escape(a)}),g.updates.ajaxLocked=!1,g.updates.queue=[],c(".button.updating-message").removeClass("updating-message").removeAttr("aria-label").prop("disabled",!0).text(h("Update failed.")),c(".updating-message:not(.button):not(.thickbox)").removeClass("updating-message notice-warning").addClass("notice-error").find("p").removeAttr("aria-label").text(a),g.a11y.speak(a,"assertive"),!1},g.updates.beforeunload=function(){if(g.updates.ajaxLocked)return h("Updates may not complete if you navigate away from this page.")},c(function(){var i=c("#plugin-filter, #plugin-information-footer"),o=c("#bulk-action-form"),e=c("#request-filesystem-credentials-form"),t=c("#request-filesystem-credentials-dialog"),a=c(".plugins-php .wp-filter-search"),s=c(".plugin-install-php .wp-filter-search");(m=_.extend(m,window._wpUpdatesItemCounts||{})).totals&&g.updates.refreshCount(),g.updates.shouldRequestFilesystemCredentials=0<t.length,t.on("submit","form",function(e){e.preventDefault(),g.updates.filesystemCredentials.ftp.hostname=c("#hostname").val(),g.updates.filesystemCredentials.ftp.username=c("#username").val(),g.updates.filesystemCredentials.ftp.password=c("#password").val(),g.updates.filesystemCredentials.ftp.connectionType=c('input[name="connection_type"]:checked').val(),g.updates.filesystemCredentials.ssh.publicKey=c("#public_key").val(),g.updates.filesystemCredentials.ssh.privateKey=c("#private_key").val(),g.updates.filesystemCredentials.fsNonce=c("#_fs_nonce").val(),g.updates.filesystemCredentials.available=!0,g.updates.ajaxLocked=!1,g.updates.queueChecker(),g.updates.requestForCredentialsModalClose()}),t.on("click",'[data-js-action="close"], .notification-dialog-background',g.updates.requestForCredentialsModalCancel),e.on("change",'input[name="connection_type"]',function(){c("#ssh-keys").toggleClass("hidden","ssh"!==c(this).val())}).trigger("change"),f.on("credential-modal-cancel",function(e,t){var a,s=c(".updating-message");"import"===pagenow?s.removeClass("updating-message"):"plugins"===pagenow||"plugins-network"===pagenow?"update-plugin"===t.action?a=c('tr[data-plugin="'+t.data.plugin+'"]').find(".update-message"):"delete-plugin"===t.action&&(a=c('[data-plugin="'+t.data.plugin+'"]').find(".row-actions a.delete")):"themes"===pagenow||"themes-network"===pagenow?"update-theme"===t.action?a=c('[data-slug="'+t.data.slug+'"]').find(".update-message"):"delete-theme"===t.action&&"themes-network"===pagenow?a=c('[data-slug="'+t.data.slug+'"]').find(".row-actions a.delete"):"delete-theme"===t.action&&"themes"===pagenow&&(a=c(".theme-actions .delete-theme")):a=s,a&&a.hasClass("updating-message")&&(void 0===(s=a.data("originaltext"))&&(s=c("<p>").html(a.find("p").data("originaltext"))),a.removeClass("updating-message").html(s),"plugin-install"!==pagenow&&"plugin-install-network"!==pagenow||("update-plugin"===t.action?a.attr("aria-label",p(d("Update %s now","plugin"),a.data("name"))):"install-plugin"===t.action&&a.attr("aria-label",p(d("Install %s now","plugin"),a.data("name"))))),g.a11y.speak(h("Update canceled."))}),o.on("click","[data-plugin] .update-link",function(e){var t=c(e.target),a=t.parents("tr");e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.maybeRequestFilesystemCredentials(e),g.updates.$elToReturnFocusToFromCredentialsModal=a.find(".check-column input"),g.updates.updatePlugin({plugin:a.data("plugin"),slug:a.data("slug")}))}),i.on("click",".update-now",function(e){var t=c(e.target);e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.maybeRequestFilesystemCredentials(e),g.updates.updatePlugin({plugin:t.data("plugin"),slug:t.data("slug")}))}),i.on("click",".install-now",function(e){var t=c(e.target);e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.shouldRequestFilesystemCredentials&&!g.updates.ajaxLocked&&(g.updates.requestFilesystemCredentials(e),f.on("credential-modal-cancel",function(){c(".install-now.updating-message").removeClass("updating-message").text(d("Install Now","plugin")),g.a11y.speak(h("Update canceled."))})),g.updates.installPlugin({slug:t.data("slug")}))}),f.on("click","#plugin-information-footer .activate-now",function(e){e.preventDefault(),window.parent.location.href=c(e.target).attr("href")}),f.on("click",".importer-item .install-now",function(e){var t=c(e.target),a=c(this).data("name");e.preventDefault(),t.hasClass("updating-message")||(g.updates.shouldRequestFilesystemCredentials&&!g.updates.ajaxLocked&&(g.updates.requestFilesystemCredentials(e),f.on("credential-modal-cancel",function(){t.removeClass("updating-message").attr("aria-label",p(d("Install %s now","plugin"),a)).text(d("Install Now","plugin")),g.a11y.speak(h("Update canceled."))})),g.updates.installPlugin({slug:t.data("slug"),pagenow:pagenow,success:g.updates.installImporterSuccess,error:g.updates.installImporterError}))}),o.on("click","[data-plugin] a.delete",function(e){var t=c(e.target).parents("tr"),a=t.hasClass("is-uninstallable")?p(h("Are you sure you want to delete %s and its data?"),t.find(".plugin-title strong").text()):p(h("Are you sure you want to delete %s?"),t.find(".plugin-title strong").text());e.preventDefault(),window.confirm(a)&&(g.updates.maybeRequestFilesystemCredentials(e),g.updates.deletePlugin({plugin:t.data("plugin"),slug:t.data("slug")}))}),f.on("click",".themes-php.network-admin .update-link",function(e){var t=c(e.target),a=t.parents("tr");e.preventDefault(),t.hasClass("updating-message")||t.hasClass("button-disabled")||(g.updates.maybeRequestFilesystemCredentials(e),g.updates.$elToReturnFocusToFromCredentialsModal=a.find(".check-column input"),g.updates.updateTheme({slug:a.data("slug")}))}),f.on("click",".themes-php.network-admin a.delete",function(e){var t=c(e.target).parents("tr"),a=p(h("Are you sure you want to delete %s?"),t.find(".theme-title strong").text());e.preventDefault(),window.confirm(a)&&(g.updates.maybeRequestFilesystemCredentials(e),g.updates.deleteTheme({slug:t.data("slug")}))}),o.on("click",'[type="submit"]:not([name="clear-recent-list"])',function(e){var t,s,n=c(e.target).siblings("select").val(),a=o.find('input[name="checked[]"]:checked'),i=0,l=0,d=[];switch(pagenow){case"plugins":case"plugins-network":t="plugin";break;case"themes-network":t="theme";break;default:return}if(!a.length)return e.preventDefault(),c("html, body").animate({scrollTop:0}),g.updates.addAdminNotice({id:"no-items-selected",className:"notice-error is-dismissible",message:h("Please select at least one item to perform this action on.")});switch(n){case"update-selected":s=n.replace("selected",t);break;case"delete-selected":var u=h("plugin"===t?"Are you sure you want to delete the selected plugins and their data?":"Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?");if(!window.confirm(u))return void e.preventDefault();s=n.replace("selected",t);break;default:return}g.updates.maybeRequestFilesystemCredentials(e),e.preventDefault(),o.find('.manage-column [type="checkbox"]').prop("checked",!1),f.trigger("wp-"+t+"-bulk-"+n,a),a.each(function(e,t){var t=c(t),a=t.parents("tr");"update-selected"!==n||a.hasClass("update")&&!a.find("notice-error").length?"update-selected"===n&&a.hasClass("is-enqueued")||(a.addClass("is-enqueued"),g.updates.queue.push({action:s,data:{plugin:a.data("plugin"),slug:a.data("slug")}})):t.prop("checked",!1)}),f.on("wp-plugin-update-success wp-plugin-update-error wp-theme-update-success wp-theme-update-error",function(e,t){var a,s=c('[data-slug="'+t.slug+'"]'),e=("wp-"+t.update+"-update-success"===e.type?i++:(e=t.pluginName||s.find(".column-primary strong").text(),l++,d.push(e+": "+t.errorMessage)),s.find('input[name="checked[]"]:checked').prop("checked",!1),g.updates.adminNotice=g.template("wp-bulk-updates-admin-notice"),null),s=(i&&(e="plugin"===t.update?p(r("%s plugin successfully updated.","%s plugins successfully updated.",i),i):p(r("%s theme successfully updated.","%s themes successfully updated.",i),i)),null);l&&(s=p(r("%s update failed.","%s updates failed.",l),l)),g.updates.addAdminNotice({id:"bulk-action-notice",className:"bulk-action-notice",successMessage:e,errorMessage:s,errorMessages:d,type:t.update}),a=c("#bulk-action-notice").on("click","button",function(){c(this).toggleClass("bulk-action-errors-collapsed").attr("aria-expanded",!c(this).hasClass("bulk-action-errors-collapsed")),a.find(".bulk-action-errors").toggleClass("hidden")}),0<l&&!g.updates.queue.length&&c("html, body").animate({scrollTop:0})}),f.on("wp-updates-notice-added",function(){g.updates.adminNotice=g.template("wp-updates-admin-notice")}),g.updates.queueChecker()}),s.length&&s.attr("aria-describedby","live-search-desc"),s.on("keyup input",_.debounce(function(e,t){var a=c(".plugin-install-search"),s={_ajax_nonce:g.updates.ajaxNonce,s:encodeURIComponent(e.target.value),tab:"search",type:c("#typeselector").val(),pagenow:pagenow},n=location.href.split("?")[0]+"?"+c.param(_.omit(s,["_ajax_nonce","pagenow"]));"keyup"===e.type&&27===e.which&&(e.target.value=""),g.updates.searchTerm===s.s&&"typechange"!==t||(i.empty(),g.updates.searchTerm=s.s,window.history&&window.history.replaceState&&window.history.replaceState(null,"",n),a.length||(a=c('<li class="plugin-install-search" />').append(c("<a />",{class:"current",href:n,text:h("Search Results")})),c(".wp-filter .filter-links .current").removeClass("current").parents(".filter-links").prepend(a),i.prev("p").remove(),c(".plugins-popular-tags-wrapper").remove()),void 0!==g.updates.searchRequest&&g.updates.searchRequest.abort(),c("body").addClass("loading-content"),g.updates.searchRequest=g.ajax.post("search-install-plugins",s).done(function(e){c("body").removeClass("loading-content"),i.append(e.items),delete g.updates.searchRequest,0===e.count?g.a11y.speak(h("You do not appear to have any plugins available at this time.")):g.a11y.speak(p(h("Number of plugins found: %d"),e.count))}))},1e3)),a.length&&a.attr("aria-describedby","live-search-desc"),a.on("keyup input",_.debounce(function(e){var s={_ajax_nonce:g.updates.ajaxNonce,s:encodeURIComponent(e.target.value),pagenow:pagenow,plugin_status:"all"};"keyup"===e.type&&27===e.which&&(e.target.value=""),g.updates.searchTerm!==s.s&&(g.updates.searchTerm=s.s,e=_.object(_.compact(_.map(location.search.slice(1).split("&"),function(e){if(e)return e.split("=")}))),s.plugin_status=e.plugin_status||"all",window.history&&window.history.replaceState&&window.history.replaceState(null,"",location.href.split("?")[0]+"?s="+s.s+"&plugin_status="+s.plugin_status),void 0!==g.updates.searchRequest&&g.updates.searchRequest.abort(),o.empty(),c("body").addClass("loading-content"),c(".subsubsub .current").removeClass("current"),g.updates.searchRequest=g.ajax.post("search-plugins",s).done(function(e){var t=c("<span />").addClass("subtitle").html(p(h("Search results for: %s"),"<strong>"+_.escape(decodeURIComponent(s.s))+"</strong>")),a=c(".wrap .subtitle");s.s.length?a.length?a.replaceWith(t):c(".wp-header-end").before(t):(a.remove(),c(".subsubsub ."+s.plugin_status+" a").addClass("current")),c("body").removeClass("loading-content"),o.append(e.items),delete g.updates.searchRequest,0===e.count?g.a11y.speak(h("No plugins found. Try a different search.")):g.a11y.speak(p(h("Number of plugins found: %d"),e.count))}))},500)),f.on("submit",".search-plugins",function(e){e.preventDefault(),c("input.wp-filter-search").trigger("input")}),f.on("click",".try-again",function(e){e.preventDefault(),s.trigger("input")}),c("#typeselector").on("change",function(){var e=c('input[name="s"]');e.val().length&&e.trigger("input","typechange")}),c("#plugin_update_from_iframe").on("click",function(e){var t=window.parent===window?null:window.parent;c.support.postMessage=!!window.postMessage,!1!==c.support.postMessage&&null!==t&&-1===window.parent.location.pathname.indexOf("update-core.php")&&(e.preventDefault(),e={action:"update-plugin",data:{plugin:c(this).data("plugin"),slug:c(this).data("slug")}},t.postMessage(JSON.stringify(e),window.location.origin))}),c(window).on("message",function(e){var t,e=e.originalEvent,a=document.location.protocol+"//"+document.location.host;if(e.origin===a){try{t=JSON.parse(e.data)}catch(e){return}if(t)if(void 0!==t.status&&void 0!==t.slug&&void 0!==t.text&&void 0!==t.ariaLabel&&(a=c(".plugin-card-"+t.slug).find('[data-slug="'+t.slug+'"]'),void 0!==t.removeClasses&&a.removeClass(t.removeClasses),void 0!==t.addClasses&&a.addClass(t.addClasses),""===t.ariaLabel?a.removeAttr("aria-label"):a.attr("aria-label",t.ariaLabel),"dependencies-check-success"===t.status&&a.attr("data-name",t.pluginName).attr("data-slug",t.slug).attr("data-plugin",t.plugin).attr("href",t.href),a.text(t.text)),void 0!==t.action)switch(t.action){case"decrementUpdateCount":g.updates.decrementCount(t.upgradeType);break;case"install-plugin":case"update-plugin":void 0!==t.data&&void 0!==t.data.slug&&(t.data=g.updates._addCallbacks(t.data,t.action),g.updates.queue.push(t),g.updates.queueChecker())}}}),c(window).on("beforeunload",g.updates.beforeunload),f.on("keydown",".column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update",function(e){32===e.which&&e.preventDefault()}),f.on("click keyup",".column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update",function(e){var l,d,u,o=c(this),r=o.attr("data-wp-action"),p=o.find(".label");if(("keyup"!==e.type||32===e.which)&&(u="themes"!==pagenow?o.closest(".column-auto-updates"):o.closest(".theme-autoupdate"),e.preventDefault(),"yes"!==o.attr("data-doing-ajax"))){switch(o.attr("data-doing-ajax","yes"),pagenow){case"plugins":case"plugins-network":d="plugin",l=o.closest("tr").attr("data-plugin");break;case"themes-network":d="theme",l=o.closest("tr").attr("data-slug");break;case"themes":d="theme",l=o.attr("data-slug")}u.find(".notice.notice-error").addClass("hidden"),"enable"===r?p.text(h("Enabling...")):p.text(h("Disabling...")),o.find(".dashicons-update").removeClass("hidden"),e={action:"toggle-auto-updates",_ajax_nonce:m.ajax_nonce,state:r,type:d,asset:l},c.post(window.ajaxurl,e).done(function(e){var t,a,s,n,i=o.attr("href");if(e.success){if("themes"!==pagenow){switch(n=c(".auto-update-enabled span"),t=c(".auto-update-disabled span"),a=parseInt(n.text().replace(/[^\d]+/g,""),10)||0,s=parseInt(t.text().replace(/[^\d]+/g,""),10)||0,r){case"enable":++a,--s;break;case"disable":--a,++s}a=Math.max(0,a),s=Math.max(0,s),n.text("("+a+")"),t.text("("+s+")")}"enable"===r?(o[0].hasAttribute("href")&&(i=i.replace("action=enable-auto-update","action=disable-auto-update"),o.attr("href",i)),o.attr("data-wp-action","disable"),p.text(h("Disable auto-updates")),u.find(".auto-update-time").removeClass("hidden"),g.a11y.speak(h("Auto-updates enabled"))):(o[0].hasAttribute("href")&&(i=i.replace("action=disable-auto-update","action=enable-auto-update"),o.attr("href",i)),o.attr("data-wp-action","enable"),p.text(h("Enable auto-updates")),u.find(".auto-update-time").addClass("hidden"),g.a11y.speak(h("Auto-updates disabled"))),f.trigger("wp-auto-update-setting-changed",{state:r,type:d,asset:l})}else n=e.data&&e.data.error?e.data.error:h("The request could not be completed."),u.find(".notice.notice-error").removeClass("hidden").find("p").text(n),g.a11y.speak(n,"assertive")}).fail(function(){u.find(".notice.notice-error").removeClass("hidden").find("p").text(h("The request could not be completed.")),g.a11y.speak(h("The request could not be completed."),"assertive")}).always(function(){o.removeAttr("data-doing-ajax").find(".dashicons-update").addClass("hidden")})}})})}(jQuery,window.wp,window._wpUpdatesSettings);
\ No newline at end of file diff --git a/wp-admin/js/user-profile.js b/wp-admin/js/user-profile.js index e4f249f..54215c7 100644 --- a/wp-admin/js/user-profile.js +++ b/wp-admin/js/user-profile.js @@ -5,6 +5,7 @@ /* global ajaxurl, pwsL10n, userProfileL10n */ (function($) { var updateLock = false, + isSubmitting = false, __ = wp.i18n.__, $pass1Row, $pass1, @@ -15,6 +16,8 @@ $submitButtons, $submitButton, currentPass, + $form, + originalFormContent, $passwordWrapper; function generatePassword() { @@ -148,7 +151,9 @@ * @param {string} message The message to insert. */ function addInlineNotice( $this, success, message ) { - var resultDiv = $( '<div />' ); + var resultDiv = $( '<div />', { + role: 'alert' + } ); // Set up the notice div. resultDiv.addClass( 'notice inline' ); @@ -454,6 +459,12 @@ bindPasswordForm(); bindPasswordResetLink(); + $submitButtons.on( 'click', function() { + isSubmitting = true; + }); + + $form = $( '#your-profile, #createuser' ); + originalFormContent = $form.serialize(); }); $( '#destroy-sessions' ).on( 'click', function( e ) { @@ -465,10 +476,10 @@ }).done( function( response ) { $this.prop( 'disabled', true ); $this.siblings( '.notice' ).remove(); - $this.before( '<div class="notice notice-success inline"><p>' + response.message + '</p></div>' ); + $this.before( '<div class="notice notice-success inline" role="alert"><p>' + response.message + '</p></div>' ); }).fail( function( response ) { $this.siblings( '.notice' ).remove(); - $this.before( '<div class="notice notice-error inline"><p>' + response.message + '</p></div>' ); + $this.before( '<div class="notice notice-error inline" role="alert"><p>' + response.message + '</p></div>' ); }); e.preventDefault(); @@ -481,7 +492,10 @@ if ( true === updateLock ) { return __( 'Your new password has not been saved.' ); } - } ); + if ( originalFormContent !== $form.serialize() && ! isSubmitting ) { + return __( 'The changes you made will be lost if you navigate away from this page.' ); + } + }); /* * We need to generate a password as soon as the Reset Password page is loaded, diff --git a/wp-admin/js/user-profile.min.js b/wp-admin/js/user-profile.min.js index 31f3609..4fac7e9 100644 --- a/wp-admin/js/user-profile.min.js +++ b/wp-admin/js/user-profile.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -!function(o){var e,a,t,n,i,r,p,d,l,c,u=!1,h=wp.i18n.__;function f(){"function"!=typeof zxcvbn?setTimeout(f,50):(!a.val()||c.hasClass("is-open")?(a.val(a.data("pw")),a.trigger("pwupdate")):b(),_(),m(),1!==parseInt(r.data("start-masked"),10)?a.attr("type","text"):r.trigger("click"),o("#pw-weak-text-label").text(h("Confirm use of weak password")),"mailserver_pass"!==a.prop("id")&&o(a).trigger("focus"))}function w(s){r.attr({"aria-label":h(s?"Show password":"Hide password")}).find(".text").text(h(s?"Show":"Hide")).end().find(".dashicons").removeClass(s?"dashicons-hidden":"dashicons-visibility").addClass(s?"dashicons-visibility":"dashicons-hidden")}function m(){r||(r=e.find(".wp-hide-pw")).show().on("click",function(){"password"===a.attr("type")?(a.attr("type","text"),w(!1)):(a.attr("type","password"),w(!0))})}function v(s,e,a){var t=o("<div />");t.addClass("notice inline"),t.addClass("notice-"+(e?"success":"error")),t.text(o(o.parseHTML(a)).text()).wrapInner("<p />"),s.prop("disabled",e),s.siblings(".notice").remove(),s.before(t)}function g(){var s;e=o(".user-pass1-wrap, .user-pass-wrap, .mailserver-pass-wrap, .reset-pass-submit"),o(".user-pass2-wrap").hide(),d=o("#submit, #wp-submit").on("click",function(){u=!1}),p=d.add(" #createusersub"),n=o(".pw-weak"),(i=n.find(".pw-checkbox")).on("change",function(){p.prop("disabled",!i.prop("checked"))}),(a=o("#pass1, #mailserver_pass")).length?(l=a.val(),1===parseInt(a.data("reveal"),10)&&f(),a.on("input pwupdate",function(){a.val()!==l&&(l=a.val(),a.removeClass("short bad good strong"),_())})):a=o("#user_pass"),t=o("#pass2").on("input",function(){0<t.val().length&&(a.val(t.val()),t.val(""),l="",a.trigger("pwupdate"))}),a.is(":hidden")&&(a.prop("disabled",!0),t.prop("disabled",!0)),c=e.find(".wp-pwd"),s=e.find("button.wp-generate-pw"),m(),s.show(),s.on("click",function(){u=!0,s.not(".skip-aria-expanded").attr("aria-expanded","true"),c.show().addClass("is-open"),a.attr("disabled",!1),t.attr("disabled",!1),f(),w(!1),wp.ajax.post("generate-password").done(function(s){a.data("pw",s)})}),e.find("button.wp-cancel-pw").on("click",function(){u=!1,a.prop("disabled",!0),t.prop("disabled",!0),a.val("").trigger("pwupdate"),w(!1),c.hide().removeClass("is-open"),p.prop("disabled",!1),s.attr("aria-expanded","false")}),e.closest("form").on("submit",function(){u=!1,a.prop("disabled",!1),t.prop("disabled",!1),t.val(a.val())})}function b(){var s=o("#pass1").val();if(o("#pass-strength-result").removeClass("short bad good strong empty"),s&&""!==s.trim())switch(wp.passwordStrength.meter(s,wp.passwordStrength.userInputDisallowedList(),s)){case-1:o("#pass-strength-result").addClass("bad").html(pwsL10n.unknown);break;case 2:o("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:o("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:o("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:o("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:o("#pass-strength-result").addClass("short").html(pwsL10n.short)}else o("#pass-strength-result").addClass("empty").html(" ")}function _(){var s=o("#pass-strength-result");s.length&&(s=s[0]).className&&(a.addClass(s.className),o(s).is(".short, .bad")?(i.prop("checked")||p.prop("disabled",!0),n.show()):(o(s).is(".empty")?(p.prop("disabled",!0),i.prop("checked",!1)):p.prop("disabled",!1),n.hide()))}o(function(){var s,a,t,n,i=o("#display_name"),e=i.val(),r=o("#wp-admin-bar-my-account").find(".display-name");o("#pass1").val("").on("input pwupdate",b),o("#pass-strength-result").show(),o(".color-palette").on("click",function(){o(this).siblings('input[name="admin_color"]').prop("checked",!0)}),i.length&&(o("#first_name, #last_name, #nickname").on("blur.user_profile",function(){var a=[],t={display_nickname:o("#nickname").val()||"",display_username:o("#user_login").val()||"",display_firstname:o("#first_name").val()||"",display_lastname:o("#last_name").val()||""};t.display_firstname&&t.display_lastname&&(t.display_firstlast=t.display_firstname+" "+t.display_lastname,t.display_lastfirst=t.display_lastname+" "+t.display_firstname),o.each(o("option",i),function(s,e){a.push(e.value)}),o.each(t,function(s,e){e&&(e=e.replace(/<\/?[a-z][^>]*>/gi,""),t[s].length)&&-1===o.inArray(e,a)&&(a.push(e),o("<option />",{text:e}).appendTo(i))})}),i.on("change",function(){var s;t===n&&(s=this.value.trim()||e,r.text(s))})),s=o("#color-picker"),a=o("#colors-css"),t=o("input#user_id").val(),n=o('input[name="checkuser_id"]').val(),s.on("click.colorpicker",".color-option",function(){var s,e=o(this);if(!e.hasClass("selected")&&(e.siblings(".selected").removeClass("selected"),e.addClass("selected").find('input[type="radio"]').prop("checked",!0),t===n)){if((a=0===a.length?o('<link rel="stylesheet" />').appendTo("head"):a).attr("href",e.children(".css_url").val()),"undefined"!=typeof wp&&wp.svgPainter){try{s=JSON.parse(e.children(".icon_colors").val())}catch(s){}s&&(wp.svgPainter.setColors(s),wp.svgPainter.paint())}o.post(ajaxurl,{action:"save-user-color-scheme",color_scheme:e.children('input[name="admin_color"]').val(),nonce:o("#color-nonce").val()}).done(function(s){s.success&&o("body").removeClass(s.data.previousScheme).addClass(s.data.currentScheme)})}}),g(),o("#generate-reset-link").on("click",function(){var e=o(this),s={user_id:userProfileL10n.user_id,nonce:userProfileL10n.nonce},s=(e.parent().find(".notice-error").remove(),wp.ajax.post("send-password-reset",s));s.done(function(s){v(e,!0,s)}),s.fail(function(s){v(e,!1,s)})})}),o("#destroy-sessions").on("click",function(s){var e=o(this);wp.ajax.post("destroy-sessions",{nonce:o("#_wpnonce").val(),user_id:o("#user_id").val()}).done(function(s){e.prop("disabled",!0),e.siblings(".notice").remove(),e.before('<div class="notice notice-success inline"><p>'+s.message+"</p></div>")}).fail(function(s){e.siblings(".notice").remove(),e.before('<div class="notice notice-error inline"><p>'+s.message+"</p></div>")}),s.preventDefault()}),window.generatePassword=f,o(window).on("beforeunload",function(){if(!0===u)return h("Your new password has not been saved.")}),o(function(){o(".reset-pass-submit").length&&o(".reset-pass-submit button.wp-generate-pw").trigger("click")})}(jQuery);
\ No newline at end of file +!function(o){var s,a,t,n,i,r,l,p,d,c,u,h,f=!1,w=!1,m=wp.i18n.__;function v(){"function"!=typeof zxcvbn?setTimeout(v,50):(!a.val()||h.hasClass("is-open")?(a.val(a.data("pw")),a.trigger("pwupdate")):_(),C(),b(),1!==parseInt(r.data("start-masked"),10)?a.attr("type","text"):r.trigger("click"),o("#pw-weak-text-label").text(m("Confirm use of weak password")),"mailserver_pass"!==a.prop("id")&&o(a).trigger("focus"))}function g(e){r.attr({"aria-label":m(e?"Show password":"Hide password")}).find(".text").text(m(e?"Show":"Hide")).end().find(".dashicons").removeClass(e?"dashicons-hidden":"dashicons-visibility").addClass(e?"dashicons-visibility":"dashicons-hidden")}function b(){r||(r=s.find(".wp-hide-pw")).show().on("click",function(){"password"===a.attr("type")?(a.attr("type","text"),g(!1)):(a.attr("type","password"),g(!0))})}function y(e,s,a){var t=o("<div />",{role:"alert"});t.addClass("notice inline"),t.addClass("notice-"+(s?"success":"error")),t.text(o(o.parseHTML(a)).text()).wrapInner("<p />"),e.prop("disabled",s),e.siblings(".notice").remove(),e.before(t)}function k(){var e;s=o(".user-pass1-wrap, .user-pass-wrap, .mailserver-pass-wrap, .reset-pass-submit"),o(".user-pass2-wrap").hide(),p=o("#submit, #wp-submit").on("click",function(){f=!1}),l=p.add(" #createusersub"),n=o(".pw-weak"),(i=n.find(".pw-checkbox")).on("change",function(){l.prop("disabled",!i.prop("checked"))}),(a=o("#pass1, #mailserver_pass")).length?(d=a.val(),1===parseInt(a.data("reveal"),10)&&v(),a.on("input pwupdate",function(){a.val()!==d&&(d=a.val(),a.removeClass("short bad good strong"),C())})):a=o("#user_pass"),t=o("#pass2").on("input",function(){0<t.val().length&&(a.val(t.val()),t.val(""),d="",a.trigger("pwupdate"))}),a.is(":hidden")&&(a.prop("disabled",!0),t.prop("disabled",!0)),h=s.find(".wp-pwd"),e=s.find("button.wp-generate-pw"),b(),e.show(),e.on("click",function(){f=!0,e.not(".skip-aria-expanded").attr("aria-expanded","true"),h.show().addClass("is-open"),a.attr("disabled",!1),t.attr("disabled",!1),v(),g(!1),wp.ajax.post("generate-password").done(function(e){a.data("pw",e)})}),s.find("button.wp-cancel-pw").on("click",function(){f=!1,a.prop("disabled",!0),t.prop("disabled",!0),a.val("").trigger("pwupdate"),g(!1),h.hide().removeClass("is-open"),l.prop("disabled",!1),e.attr("aria-expanded","false")}),s.closest("form").on("submit",function(){f=!1,a.prop("disabled",!1),t.prop("disabled",!1),t.val(a.val())})}function _(){var e=o("#pass1").val();if(o("#pass-strength-result").removeClass("short bad good strong empty"),e&&""!==e.trim())switch(wp.passwordStrength.meter(e,wp.passwordStrength.userInputDisallowedList(),e)){case-1:o("#pass-strength-result").addClass("bad").html(pwsL10n.unknown);break;case 2:o("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:o("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:o("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:o("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:o("#pass-strength-result").addClass("short").html(pwsL10n.short)}else o("#pass-strength-result").addClass("empty").html(" ")}function C(){var e=o("#pass-strength-result");e.length&&(e=e[0]).className&&(a.addClass(e.className),o(e).is(".short, .bad")?(i.prop("checked")||l.prop("disabled",!0),n.show()):(o(e).is(".empty")?(l.prop("disabled",!0),i.prop("checked",!1)):l.prop("disabled",!1),n.hide()))}o(function(){var e,a,t,n,i=o("#display_name"),s=i.val(),r=o("#wp-admin-bar-my-account").find(".display-name");o("#pass1").val("").on("input pwupdate",_),o("#pass-strength-result").show(),o(".color-palette").on("click",function(){o(this).siblings('input[name="admin_color"]').prop("checked",!0)}),i.length&&(o("#first_name, #last_name, #nickname").on("blur.user_profile",function(){var a=[],t={display_nickname:o("#nickname").val()||"",display_username:o("#user_login").val()||"",display_firstname:o("#first_name").val()||"",display_lastname:o("#last_name").val()||""};t.display_firstname&&t.display_lastname&&(t.display_firstlast=t.display_firstname+" "+t.display_lastname,t.display_lastfirst=t.display_lastname+" "+t.display_firstname),o.each(o("option",i),function(e,s){a.push(s.value)}),o.each(t,function(e,s){s&&(s=s.replace(/<\/?[a-z][^>]*>/gi,""),t[e].length)&&-1===o.inArray(s,a)&&(a.push(s),o("<option />",{text:s}).appendTo(i))})}),i.on("change",function(){var e;t===n&&(e=this.value.trim()||s,r.text(e))})),e=o("#color-picker"),a=o("#colors-css"),t=o("input#user_id").val(),n=o('input[name="checkuser_id"]').val(),e.on("click.colorpicker",".color-option",function(){var e,s=o(this);if(!s.hasClass("selected")&&(s.siblings(".selected").removeClass("selected"),s.addClass("selected").find('input[type="radio"]').prop("checked",!0),t===n)){if((a=0===a.length?o('<link rel="stylesheet" />').appendTo("head"):a).attr("href",s.children(".css_url").val()),"undefined"!=typeof wp&&wp.svgPainter){try{e=JSON.parse(s.children(".icon_colors").val())}catch(e){}e&&(wp.svgPainter.setColors(e),wp.svgPainter.paint())}o.post(ajaxurl,{action:"save-user-color-scheme",color_scheme:s.children('input[name="admin_color"]').val(),nonce:o("#color-nonce").val()}).done(function(e){e.success&&o("body").removeClass(e.data.previousScheme).addClass(e.data.currentScheme)})}}),k(),o("#generate-reset-link").on("click",function(){var s=o(this),e={user_id:userProfileL10n.user_id,nonce:userProfileL10n.nonce},e=(s.parent().find(".notice-error").remove(),wp.ajax.post("send-password-reset",e));e.done(function(e){y(s,!0,e)}),e.fail(function(e){y(s,!1,e)})}),l.on("click",function(){w=!0}),c=o("#your-profile, #createuser"),u=c.serialize()}),o("#destroy-sessions").on("click",function(e){var s=o(this);wp.ajax.post("destroy-sessions",{nonce:o("#_wpnonce").val(),user_id:o("#user_id").val()}).done(function(e){s.prop("disabled",!0),s.siblings(".notice").remove(),s.before('<div class="notice notice-success inline" role="alert"><p>'+e.message+"</p></div>")}).fail(function(e){s.siblings(".notice").remove(),s.before('<div class="notice notice-error inline" role="alert"><p>'+e.message+"</p></div>")}),e.preventDefault()}),window.generatePassword=v,o(window).on("beforeunload",function(){return!0===f?m("Your new password has not been saved."):u===c.serialize()||w?void 0:m("The changes you made will be lost if you navigate away from this page.")}),o(function(){o(".reset-pass-submit").length&&o(".reset-pass-submit button.wp-generate-pw").trigger("click")})}(jQuery);
\ No newline at end of file diff --git a/wp-admin/js/widgets/custom-html-widgets.js b/wp-admin/js/widgets/custom-html-widgets.js index e36d115..3987eb4 100644 --- a/wp-admin/js/widgets/custom-html-widgets.js +++ b/wp-admin/js/widgets/custom-html-widgets.js @@ -148,7 +148,7 @@ wp.customHtmlWidgets = ( function( $ ) { } ) ); } } else if ( 0 !== errorAnnotations.length ) { - errorNotice = $( '<div class="inline notice notice-error notice-alt"></div>' ); + errorNotice = $( '<div class="inline notice notice-error notice-alt" role="alert"></div>' ); errorNotice.append( $( '<p></p>', { text: message } ) ); diff --git a/wp-admin/js/widgets/custom-html-widgets.min.js b/wp-admin/js/widgets/custom-html-widgets.min.js index 8baa98f..e34397c 100644 --- a/wp-admin/js/widgets/custom-html-widgets.min.js +++ b/wp-admin/js/widgets/custom-html-widgets.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -wp.customHtmlWidgets=function(a){"use strict";var s={idBases:["custom_html"],codeEditorSettings:{},l10n:{errorNotice:{singular:"",plural:""}}};return s.CustomHtmlWidgetControl=Backbone.View.extend({events:{},initialize:function(e){var n=this;if(!e.el)throw new Error("Missing options.el");if(!e.syncContainer)throw new Error("Missing options.syncContainer");Backbone.View.prototype.initialize.call(n,e),n.syncContainer=e.syncContainer,n.widgetIdBase=n.syncContainer.parent().find(".id_base").val(),n.widgetNumber=n.syncContainer.parent().find(".widget_number").val(),n.customizeSettingId="widget_"+n.widgetIdBase+"["+String(n.widgetNumber)+"]",n.$el.addClass("custom-html-widget-fields"),n.$el.html(wp.template("widget-custom-html-control-fields")({codeEditorDisabled:s.codeEditorSettings.disabled})),n.errorNoticeContainer=n.$el.find(".code-editor-error-container"),n.currentErrorAnnotations=[],n.saveButton=n.syncContainer.add(n.syncContainer.parent().find(".widget-control-actions")).find(".widget-control-save, #savewidget"),n.saveButton.addClass("custom-html-widget-save-button"),n.fields={title:n.$el.find(".title"),content:n.$el.find(".content")},_.each(n.fields,function(t,i){t.on("input change",function(){var e=n.syncContainer.find(".sync-input."+i);e.val()!==t.val()&&(e.val(t.val()),e.trigger("change"))}),t.val(n.syncContainer.find(".sync-input."+i).val())})},updateFields:function(){var e,t=this;t.fields.title.is(document.activeElement)||(e=t.syncContainer.find(".sync-input.title"),t.fields.title.val(e.val())),t.contentUpdateBypassed=t.fields.content.is(document.activeElement)||t.editor&&t.editor.codemirror.state.focused||0!==t.currentErrorAnnotations.length,t.contentUpdateBypassed||(e=t.syncContainer.find(".sync-input.content"),t.fields.content.val(e.val()))},updateErrorNotice:function(e){var t,i=this,n="";1===e.length?n=s.l10n.errorNotice.singular.replace("%d","1"):1<e.length&&(n=s.l10n.errorNotice.plural.replace("%d",String(e.length))),i.fields.content[0].setCustomValidity&&i.fields.content[0].setCustomValidity(n),wp.customize&&wp.customize.has(i.customizeSettingId)?((t=wp.customize(i.customizeSettingId)).notifications.remove("htmlhint_error"),0!==e.length&&t.notifications.add("htmlhint_error",new wp.customize.Notification("htmlhint_error",{message:n,type:"error"}))):0!==e.length?((t=a('<div class="inline notice notice-error notice-alt"></div>')).append(a("<p></p>",{text:n})),i.errorNoticeContainer.empty(),i.errorNoticeContainer.append(t),i.errorNoticeContainer.slideDown("fast"),wp.a11y.speak(n)):i.errorNoticeContainer.slideUp("fast")},initializeEditor:function(){var e,t=this;s.codeEditorSettings.disabled||(e=_.extend({},s.codeEditorSettings,{onTabPrevious:function(){t.fields.title.focus()},onTabNext:function(){t.syncContainer.add(t.syncContainer.parent().find(".widget-position, .widget-control-actions")).find(":tabbable").first().focus()},onChangeLintingErrors:function(e){t.currentErrorAnnotations=e},onUpdateErrorNotice:function(e){t.saveButton.toggleClass("validation-blocked disabled",0<e.length),t.updateErrorNotice(e)}}),t.editor=wp.codeEditor.initialize(t.fields.content,e),a(t.editor.codemirror.display.lineDiv).attr({role:"textbox","aria-multiline":"true","aria-labelledby":t.fields.content[0].id+"-label","aria-describedby":"editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"}),a("#"+t.fields.content[0].id+"-label").on("click",function(){t.editor.codemirror.focus()}),t.fields.content.on("change",function(){this.value!==t.editor.codemirror.getValue()&&t.editor.codemirror.setValue(this.value)}),t.editor.codemirror.on("change",function(){var e=t.editor.codemirror.getValue();e!==t.fields.content.val()&&t.fields.content.val(e).trigger("change")}),t.editor.codemirror.on("blur",function(){t.contentUpdateBypassed&&t.syncContainer.find(".sync-input.content").trigger("change")}),wp.customize&&t.editor.codemirror.on("keydown",function(e,t){27===t.keyCode&&t.stopPropagation()}))}}),s.widgetControls={},s.handleWidgetAdded=function(e,t){var i,n,o,d=t.find("> .widget-inside > .form, > .widget-inside > form"),r=d.find("> .id_base").val();-1===s.idBases.indexOf(r)||(r=d.find(".widget-id").val(),s.widgetControls[r])||(d=a("<div></div>"),(o=t.find(".widget-content:first")).before(d),i=new s.CustomHtmlWidgetControl({el:d,syncContainer:o}),s.widgetControls[r]=i,(n=function(){(wp.customize?t.parent().hasClass("expanded"):t.hasClass("open"))?i.initializeEditor():setTimeout(n,50)})())},s.setupAccessibleMode=function(){var e,t=a(".editwidget > form");0!==t.length&&(e=t.find(".id_base").val(),-1!==s.idBases.indexOf(e))&&(e=a("<div></div>"),(t=t.find("> .widget-inside")).before(e),new s.CustomHtmlWidgetControl({el:e,syncContainer:t}).initializeEditor())},s.handleWidgetUpdated=function(e,t){var t=t.find("> .widget-inside > .form, > .widget-inside > form"),i=t.find("> .id_base").val();-1!==s.idBases.indexOf(i)&&(i=t.find("> .widget-id").val(),t=s.widgetControls[i])&&t.updateFields()},s.init=function(e){var t=a(document);_.extend(s.codeEditorSettings,e),t.on("widget-added",s.handleWidgetAdded),t.on("widget-synced widget-updated",s.handleWidgetUpdated),a(function(){"widgets"===window.pagenow&&(a(".widgets-holder-wrap:not(#available-widgets)").find("div.widget").one("click.toggle-widget-expanded",function(){var e=a(this);s.handleWidgetAdded(new jQuery.Event("widget-added"),e)}),"complete"===document.readyState?s.setupAccessibleMode():a(window).on("load",function(){s.setupAccessibleMode()}))})},s}(jQuery);
\ No newline at end of file +wp.customHtmlWidgets=function(a){"use strict";var s={idBases:["custom_html"],codeEditorSettings:{},l10n:{errorNotice:{singular:"",plural:""}}};return s.CustomHtmlWidgetControl=Backbone.View.extend({events:{},initialize:function(e){var n=this;if(!e.el)throw new Error("Missing options.el");if(!e.syncContainer)throw new Error("Missing options.syncContainer");Backbone.View.prototype.initialize.call(n,e),n.syncContainer=e.syncContainer,n.widgetIdBase=n.syncContainer.parent().find(".id_base").val(),n.widgetNumber=n.syncContainer.parent().find(".widget_number").val(),n.customizeSettingId="widget_"+n.widgetIdBase+"["+String(n.widgetNumber)+"]",n.$el.addClass("custom-html-widget-fields"),n.$el.html(wp.template("widget-custom-html-control-fields")({codeEditorDisabled:s.codeEditorSettings.disabled})),n.errorNoticeContainer=n.$el.find(".code-editor-error-container"),n.currentErrorAnnotations=[],n.saveButton=n.syncContainer.add(n.syncContainer.parent().find(".widget-control-actions")).find(".widget-control-save, #savewidget"),n.saveButton.addClass("custom-html-widget-save-button"),n.fields={title:n.$el.find(".title"),content:n.$el.find(".content")},_.each(n.fields,function(t,i){t.on("input change",function(){var e=n.syncContainer.find(".sync-input."+i);e.val()!==t.val()&&(e.val(t.val()),e.trigger("change"))}),t.val(n.syncContainer.find(".sync-input."+i).val())})},updateFields:function(){var e,t=this;t.fields.title.is(document.activeElement)||(e=t.syncContainer.find(".sync-input.title"),t.fields.title.val(e.val())),t.contentUpdateBypassed=t.fields.content.is(document.activeElement)||t.editor&&t.editor.codemirror.state.focused||0!==t.currentErrorAnnotations.length,t.contentUpdateBypassed||(e=t.syncContainer.find(".sync-input.content"),t.fields.content.val(e.val()))},updateErrorNotice:function(e){var t,i=this,n="";1===e.length?n=s.l10n.errorNotice.singular.replace("%d","1"):1<e.length&&(n=s.l10n.errorNotice.plural.replace("%d",String(e.length))),i.fields.content[0].setCustomValidity&&i.fields.content[0].setCustomValidity(n),wp.customize&&wp.customize.has(i.customizeSettingId)?((t=wp.customize(i.customizeSettingId)).notifications.remove("htmlhint_error"),0!==e.length&&t.notifications.add("htmlhint_error",new wp.customize.Notification("htmlhint_error",{message:n,type:"error"}))):0!==e.length?((t=a('<div class="inline notice notice-error notice-alt" role="alert"></div>')).append(a("<p></p>",{text:n})),i.errorNoticeContainer.empty(),i.errorNoticeContainer.append(t),i.errorNoticeContainer.slideDown("fast"),wp.a11y.speak(n)):i.errorNoticeContainer.slideUp("fast")},initializeEditor:function(){var e,t=this;s.codeEditorSettings.disabled||(e=_.extend({},s.codeEditorSettings,{onTabPrevious:function(){t.fields.title.focus()},onTabNext:function(){t.syncContainer.add(t.syncContainer.parent().find(".widget-position, .widget-control-actions")).find(":tabbable").first().focus()},onChangeLintingErrors:function(e){t.currentErrorAnnotations=e},onUpdateErrorNotice:function(e){t.saveButton.toggleClass("validation-blocked disabled",0<e.length),t.updateErrorNotice(e)}}),t.editor=wp.codeEditor.initialize(t.fields.content,e),a(t.editor.codemirror.display.lineDiv).attr({role:"textbox","aria-multiline":"true","aria-labelledby":t.fields.content[0].id+"-label","aria-describedby":"editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"}),a("#"+t.fields.content[0].id+"-label").on("click",function(){t.editor.codemirror.focus()}),t.fields.content.on("change",function(){this.value!==t.editor.codemirror.getValue()&&t.editor.codemirror.setValue(this.value)}),t.editor.codemirror.on("change",function(){var e=t.editor.codemirror.getValue();e!==t.fields.content.val()&&t.fields.content.val(e).trigger("change")}),t.editor.codemirror.on("blur",function(){t.contentUpdateBypassed&&t.syncContainer.find(".sync-input.content").trigger("change")}),wp.customize&&t.editor.codemirror.on("keydown",function(e,t){27===t.keyCode&&t.stopPropagation()}))}}),s.widgetControls={},s.handleWidgetAdded=function(e,t){var i,n,o,d=t.find("> .widget-inside > .form, > .widget-inside > form"),r=d.find("> .id_base").val();-1===s.idBases.indexOf(r)||(r=d.find(".widget-id").val(),s.widgetControls[r])||(d=a("<div></div>"),(o=t.find(".widget-content:first")).before(d),i=new s.CustomHtmlWidgetControl({el:d,syncContainer:o}),s.widgetControls[r]=i,(n=function(){(wp.customize?t.parent().hasClass("expanded"):t.hasClass("open"))?i.initializeEditor():setTimeout(n,50)})())},s.setupAccessibleMode=function(){var e,t=a(".editwidget > form");0!==t.length&&(e=t.find(".id_base").val(),-1!==s.idBases.indexOf(e))&&(e=a("<div></div>"),(t=t.find("> .widget-inside")).before(e),new s.CustomHtmlWidgetControl({el:e,syncContainer:t}).initializeEditor())},s.handleWidgetUpdated=function(e,t){var t=t.find("> .widget-inside > .form, > .widget-inside > form"),i=t.find("> .id_base").val();-1!==s.idBases.indexOf(i)&&(i=t.find("> .widget-id").val(),t=s.widgetControls[i])&&t.updateFields()},s.init=function(e){var t=a(document);_.extend(s.codeEditorSettings,e),t.on("widget-added",s.handleWidgetAdded),t.on("widget-synced widget-updated",s.handleWidgetUpdated),a(function(){"widgets"===window.pagenow&&(a(".widgets-holder-wrap:not(#available-widgets)").find("div.widget").one("click.toggle-widget-expanded",function(){var e=a(this);s.handleWidgetAdded(new jQuery.Event("widget-added"),e)}),"complete"===document.readyState?s.setupAccessibleMode():a(window).on("load",function(){s.setupAccessibleMode()}))})},s}(jQuery);
\ No newline at end of file diff --git a/wp-admin/js/widgets/media-widgets.js b/wp-admin/js/widgets/media-widgets.js index 2ee00a8..d67e71f 100644 --- a/wp-admin/js/widgets/media-widgets.js +++ b/wp-admin/js/widgets/media-widgets.js @@ -158,7 +158,7 @@ wp.mediaWidgets = ( function( $ ) { } } else { if ( ! noticeContainer.length ) { - noticeContainer = $( '<div class="media-widget-embed-notice notice notice-error notice-alt"></div>' ); + noticeContainer = $( '<div class="media-widget-embed-notice notice notice-error notice-alt" role="alert"></div>' ); noticeContainer.hide(); embedLinkView.views.parent.$el.prepend( noticeContainer ); } diff --git a/wp-admin/js/widgets/media-widgets.min.js b/wp-admin/js/widgets/media-widgets.min.js index 1e3b45d..936b3cd 100644 --- a/wp-admin/js/widgets/media-widgets.min.js +++ b/wp-admin/js/widgets/media-widgets.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -wp.mediaWidgets=function(c){"use strict";var m={controlConstructors:{},modelConstructors:{}};return m.PersistentDisplaySettingsLibrary=wp.media.controller.Library.extend({initialize:function(e){_.bindAll(this,"handleDisplaySettingChange"),wp.media.controller.Library.prototype.initialize.call(this,e)},handleDisplaySettingChange:function(e){this.get("selectedDisplaySettings").set(e.attributes)},display:function(e){var t=this.get("selectedDisplaySettings"),e=wp.media.controller.Library.prototype.display.call(this,e);return e.off("change",this.handleDisplaySettingChange),e.set(t.attributes),"custom"===t.get("link_type")&&(e.linkUrl=t.get("link_url")),e.on("change",this.handleDisplaySettingChange),e}}),m.MediaEmbedView=wp.media.view.Embed.extend({initialize:function(e){var t=this;wp.media.view.Embed.prototype.initialize.call(t,e),"image"!==t.controller.options.mimeType&&(e=t.controller.states.get("embed")).off("scan",e.scanImage,e)},refresh:function(){var e="image"===this.controller.options.mimeType?wp.media.view.EmbedImage:wp.media.view.EmbedLink.extend({setAddToWidgetButtonDisabled:function(e){this.views.parent.views.parent.views.get(".media-frame-toolbar")[0].$el.find(".media-button-select").prop("disabled",e)},setErrorNotice:function(e){var t=this.views.parent.$el.find("> .notice:first-child");e?(t.length||((t=c('<div class="media-widget-embed-notice notice notice-error notice-alt"></div>')).hide(),this.views.parent.$el.prepend(t)),t.empty(),t.append(c("<p>",{html:e})),t.slideDown("fast")):t.length&&t.slideUp("fast")},updateoEmbed:function(){var e=this,t=e.model.get("url");t?(t.match(/^(http|https):\/\/.+\//)||(e.controller.$el.find("#embed-url-field").addClass("invalid"),e.setAddToWidgetButtonDisabled(!0)),wp.media.view.EmbedLink.prototype.updateoEmbed.call(e)):(e.setErrorNotice(""),e.setAddToWidgetButtonDisabled(!0))},fetch:function(){var t,e,i=this,n=i.model.get("url");i.dfd&&"pending"===i.dfd.state()&&i.dfd.abort(),t=function(e){i.renderoEmbed({data:{body:e}}),i.controller.$el.find("#embed-url-field").removeClass("invalid"),i.setErrorNotice(""),i.setAddToWidgetButtonDisabled(!1)},(e=document.createElement("a")).href=n,(e=e.pathname.toLowerCase().match(/\.(\w+)$/))?(e=e[1],!wp.media.view.settings.embedMimes[e]||0!==wp.media.view.settings.embedMimes[e].indexOf(i.controller.options.mimeType)?i.renderFail():t("\x3c!--success--\x3e")):((e=/https?:\/\/www\.youtube\.com\/embed\/([^/]+)/.exec(n))&&(n="https://www.youtube.com/watch?v="+e[1],i.model.attributes.url=n),i.dfd=wp.apiRequest({url:wp.media.view.settings.oEmbedProxyUrl,data:{url:n,maxwidth:i.model.get("width"),maxheight:i.model.get("height"),discover:!1},type:"GET",dataType:"json",context:i}),i.dfd.done(function(e){i.controller.options.mimeType!==e.type?i.renderFail():t(e.html)}),i.dfd.fail(_.bind(i.renderFail,i)))},renderFail:function(){var e=this;e.controller.$el.find("#embed-url-field").addClass("invalid"),e.setErrorNotice(e.controller.options.invalidEmbedTypeError||"ERROR"),e.setAddToWidgetButtonDisabled(!0)}});this.settings(new e({controller:this.controller,model:this.model.props,priority:40}))}}),m.MediaFrameSelect=wp.media.view.MediaFrame.Post.extend({createStates:function(){var t=this.options.mimeType,i=[];_.each(wp.media.view.settings.embedMimes,function(e){0===e.indexOf(t)&&i.push(e)}),0<i.length&&(t=i),this.states.add([new m.PersistentDisplaySettingsLibrary({id:"insert",title:this.options.title,selection:this.options.selection,priority:20,toolbar:"main-insert",filterable:"dates",library:wp.media.query({type:t}),multiple:!1,editable:!0,selectedDisplaySettings:this.options.selectedDisplaySettings,displaySettings:!!_.isUndefined(this.options.showDisplaySettings)||this.options.showDisplaySettings,displayUserSettings:!1}),new wp.media.controller.EditImage({model:this.options.editImage}),new wp.media.controller.Embed({metadata:this.options.metadata,type:"image"===this.options.mimeType?"image":"link",invalidEmbedTypeError:this.options.invalidEmbedTypeError})])},mainInsertToolbar:function(e){var i=this;e.set("insert",{style:"primary",priority:80,text:i.options.text,requires:{selection:!0},click:function(){var e=i.state(),t=e.get("selection");i.close(),e.trigger("insert",t).reset()}})},mainEmbedToolbar:function(e){e.view=new wp.media.view.Toolbar.Embed({controller:this,text:this.options.text,event:"insert"})},embedContent:function(){var e=new m.MediaEmbedView({controller:this,model:this.state()}).render();this.content.set(e)}}),m.MediaWidgetControl=Backbone.View.extend({l10n:{add_to_widget:"{{add_to_widget}}",add_media:"{{add_media}}"},id_base:"",mime_type:"",events:{"click .notice-missing-attachment a":"handleMediaLibraryLinkClick","click .select-media":"selectMedia","click .placeholder":"selectMedia","click .edit-media":"editMedia"},showDisplaySettings:!0,initialize:function(e){var i=this;if(Backbone.View.prototype.initialize.call(i,e),!(i.model instanceof m.MediaWidgetModel))throw new Error("Missing options.model");if(!e.el)throw new Error("Missing options.el");if(!e.syncContainer)throw new Error("Missing options.syncContainer");if(i.syncContainer=e.syncContainer,i.$el.addClass("media-widget-control"),_.bindAll(i,"syncModelToInputs","render","updateSelectedAttachment","renderPreview"),!i.id_base&&(_.find(m.controlConstructors,function(e,t){return i instanceof e&&(i.id_base=t,!0)}),!i.id_base))throw new Error("Missing id_base.");i.previewTemplateProps=new Backbone.Model(i.mapModelToPreviewTemplateProps()),i.selectedAttachment=new wp.media.model.Attachment,i.renderPreview=_.debounce(i.renderPreview),i.listenTo(i.previewTemplateProps,"change",i.renderPreview),i.model.on("change:attachment_id",i.updateSelectedAttachment),i.model.on("change:url",i.updateSelectedAttachment),i.updateSelectedAttachment(),i.listenTo(i.model,"change",i.syncModelToInputs),i.listenTo(i.model,"change",i.syncModelToPreviewProps),i.listenTo(i.model,"change",i.render),i.$el.on("input change",".title",function(){i.model.set({title:c(this).val().trim()})}),i.$el.on("input change",".link",function(){var e=c(this).val().trim(),t="custom";i.selectedAttachment.get("linkUrl")===e||i.selectedAttachment.get("link")===e?t="post":i.selectedAttachment.get("url")===e&&(t="file"),i.model.set({link_url:e,link_type:t}),i.displaySettings.set({link:t,linkUrl:e})}),i.displaySettings=new Backbone.Model(_.pick(i.mapModelToMediaFrameProps(_.extend(i.model.defaults(),i.model.toJSON())),_.keys(wp.media.view.settings.defaultProps)))},updateSelectedAttachment:function(){var e,t=this;0===t.model.get("attachment_id")?(t.selectedAttachment.clear(),t.model.set("error",!1)):t.model.get("attachment_id")!==t.selectedAttachment.get("id")&&(e=new wp.media.model.Attachment({id:t.model.get("attachment_id")})).fetch().done(function(){t.model.set("error",!1),t.selectedAttachment.set(e.toJSON())}).fail(function(){t.model.set("error","missing_attachment")})},syncModelToPreviewProps:function(){this.previewTemplateProps.set(this.mapModelToPreviewTemplateProps())},syncModelToInputs:function(){var n=this;n.syncContainer.find(".media-widget-instance-property").each(function(){var e=c(this),t=e.data("property"),i=n.model.get(t);_.isUndefined(i)||(i="array"===n.model.schema[t].type&&_.isArray(i)?i.join(","):"boolean"===n.model.schema[t].type?i?"1":"":String(i),e.val()!==i&&(e.val(i),e.trigger("change")))})},template:function(){if(c("#tmpl-widget-media-"+this.id_base+"-control").length)return wp.template("widget-media-"+this.id_base+"-control");throw new Error("Missing widget control template for "+this.id_base)},render:function(){var e,t=this;t.templateRendered||(t.$el.html(t.template()(t.model.toJSON())),t.renderPreview(),t.templateRendered=!0),(e=t.$el.find(".title")).is(document.activeElement)||e.val(t.model.get("title")),t.$el.toggleClass("selected",t.isSelected())},renderPreview:function(){throw new Error("renderPreview must be implemented")},isSelected:function(){return!this.model.get("error")&&Boolean(this.model.get("attachment_id")||this.model.get("url"))},handleMediaLibraryLinkClick:function(e){e.preventDefault(),this.selectMedia()},selectMedia:function(){var i,t,e,n=this,d=[];n.isSelected()&&0!==n.model.get("attachment_id")&&d.push(n.selectedAttachment),d=new wp.media.model.Selection(d,{multiple:!1}),(e=n.mapModelToMediaFrameProps(n.model.toJSON())).size&&n.displaySettings.set("size",e.size),i=new m.MediaFrameSelect({title:n.l10n.add_media,frame:"post",text:n.l10n.add_to_widget,selection:d,mimeType:n.mime_type,selectedDisplaySettings:n.displaySettings,showDisplaySettings:n.showDisplaySettings,metadata:e,state:n.isSelected()&&0===n.model.get("attachment_id")?"embed":"insert",invalidEmbedTypeError:n.l10n.unsupported_file_type}),(wp.media.frame=i).on("insert",function(){var e={},t=i.state();"embed"===t.get("id")?_.extend(e,{id:0},t.props.toJSON()):_.extend(e,t.get("selection").first().toJSON()),n.selectedAttachment.set(e),n.model.set("error",!1),n.model.set(n.getModelPropsFromMediaFrame(i))}),t=wp.media.model.Attachment.prototype.sync,wp.media.model.Attachment.prototype.sync=function(e){return"delete"===e?t.apply(this,arguments):c.Deferred().rejectWith(this).promise()},i.on("close",function(){wp.media.model.Attachment.prototype.sync=t}),i.$el.addClass("media-widget"),i.open(),d&&d.on("destroy",function(e){n.model.get("attachment_id")===e.get("id")&&n.model.set({attachment_id:0,url:""})}),i.$el.find(".media-frame-menu .media-menu-item.active").focus()},getModelPropsFromMediaFrame:function(e){var t,i,n=this,d=e.state();if("insert"===d.get("id"))(t=d.get("selection").first().toJSON()).postUrl=t.link,n.showDisplaySettings&&_.extend(t,e.content.get(".attachments-browser").sidebar.get("display").model.toJSON()),t.sizes&&t.size&&t.sizes[t.size]&&(t.url=t.sizes[t.size].url);else{if("embed"!==d.get("id"))throw new Error("Unexpected state: "+d.get("id"));t=_.extend(d.props.toJSON(),{attachment_id:0},n.model.getEmbedResetProps())}return t.id&&(t.attachment_id=t.id),i=n.mapMediaToModelProps(t),_.each(wp.media.view.settings.embedExts,function(e){e in n.model.schema&&i.url!==i[e]&&(i[e]="")}),i},mapMediaToModelProps:function(e){var t,i=this,n={},d={};return _.each(i.model.schema,function(e,t){"title"!==t&&(n[e.media_prop||t]=t)}),_.each(e,function(e,t){t=n[t]||t;i.model.schema[t]&&(d[t]=e)}),"custom"===e.size&&(d.width=e.customWidth,d.height=e.customHeight),"post"===e.link?d.link_url=e.postUrl||e.linkUrl:"file"===e.link&&(d.link_url=e.url),!e.attachment_id&&e.id&&(d.attachment_id=e.id),e.url&&(t=e.url.replace(/#.*$/,"").replace(/\?.*$/,"").split(".").pop().toLowerCase())in i.model.schema&&(d[t]=e.url),_.omit(d,"title")},mapModelToMediaFrameProps:function(e){var n=this,d={};return _.each(e,function(e,t){var i=n.model.schema[t]||{};d[i.media_prop||t]=e}),d.attachment_id=d.id,"custom"===d.size&&(d.customWidth=n.model.get("width"),d.customHeight=n.model.get("height")),d},mapModelToPreviewTemplateProps:function(){var i=this,n={};return _.each(i.model.schema,function(e,t){e.hasOwnProperty("should_preview_update")&&!e.should_preview_update||(n[t]=i.model.get(t))}),n.error=i.model.get("error"),n},editMedia:function(){throw new Error("editMedia not implemented")}}),m.MediaWidgetModel=Backbone.Model.extend({idAttribute:"widget_id",schema:{title:{type:"string",default:""},attachment_id:{type:"integer",default:0},url:{type:"string",default:""}},defaults:function(){var i={};return _.each(this.schema,function(e,t){i[t]=e.default}),i},set:function(e,t,i){var n,d,o=this;return null===e?o:(e="object"==typeof e?(n=e,t):((n={})[e]=t,i),d={},_.each(n,function(e,t){var i;o.schema[t]?"array"===(i=o.schema[t].type)?(d[t]=e,_.isArray(d[t])||(d[t]=d[t].split(/,/)),o.schema[t].items&&"integer"===o.schema[t].items.type&&(d[t]=_.filter(_.map(d[t],function(e){return parseInt(e,10)},function(e){return"number"==typeof e})))):d[t]="integer"===i?parseInt(e,10):"boolean"===i?!(!e||"0"===e||"false"===e):e:d[t]=e}),Backbone.Model.prototype.set.call(this,d,e))},getEmbedResetProps:function(){return{id:0}}}),m.modelCollection=new(Backbone.Collection.extend({model:m.MediaWidgetModel})),m.widgetControls={},m.handleWidgetAdded=function(e,t){var i,n,d,o,a,s,r=t.find("> .widget-inside > .form, > .widget-inside > form"),l=r.find("> .id_base").val(),r=r.find("> .widget-id").val();m.widgetControls[r]||(d=m.controlConstructors[l])&&(l=m.modelConstructors[l]||m.MediaWidgetModel,i=c("<div></div>"),(n=t.find(".widget-content:first")).before(i),o={},n.find(".media-widget-instance-property").each(function(){var e=c(this);o[e.data("property")]=e.val()}),o.widget_id=r,r=new l(o),a=new d({el:i,syncContainer:n,model:r}),(s=function(){t.hasClass("open")?a.render():setTimeout(s,50)})(),m.modelCollection.add([r]),m.widgetControls[r.get("widget_id")]=a)},m.setupAccessibleMode=function(){var e,t,i,n,d,o=c(".editwidget > form");0!==o.length&&(i=o.find(".id_base").val(),t=m.controlConstructors[i])&&(e=o.find("> .widget-control-actions > .widget-id").val(),i=m.modelConstructors[i]||m.MediaWidgetModel,d=c("<div></div>"),(o=o.find("> .widget-inside")).before(d),n={},o.find(".media-widget-instance-property").each(function(){var e=c(this);n[e.data("property")]=e.val()}),n.widget_id=e,e=new t({el:d,syncContainer:o,model:new i(n)}),m.modelCollection.add([e.model]),(m.widgetControls[e.model.get("widget_id")]=e).render())},m.handleWidgetUpdated=function(e,t){var i={},t=t.find("> .widget-inside > .form, > .widget-inside > form"),n=t.find("> .widget-id").val(),n=m.widgetControls[n];n&&(t.find("> .widget-content").find(".media-widget-instance-property").each(function(){var e=c(this).data("property");i[e]=c(this).val()}),n.stopListening(n.model,"change",n.syncModelToInputs),n.model.set(i),n.listenTo(n.model,"change",n.syncModelToInputs))},m.init=function(){var e=c(document);e.on("widget-added",m.handleWidgetAdded),e.on("widget-synced widget-updated",m.handleWidgetUpdated),c(function(){"widgets"===window.pagenow&&(c(".widgets-holder-wrap:not(#available-widgets)").find("div.widget").one("click.toggle-widget-expanded",function(){var e=c(this);m.handleWidgetAdded(new jQuery.Event("widget-added"),e)}),"complete"===document.readyState?m.setupAccessibleMode():c(window).on("load",function(){m.setupAccessibleMode()}))})},m}(jQuery);
\ No newline at end of file +wp.mediaWidgets=function(c){"use strict";var m={controlConstructors:{},modelConstructors:{}};return m.PersistentDisplaySettingsLibrary=wp.media.controller.Library.extend({initialize:function(e){_.bindAll(this,"handleDisplaySettingChange"),wp.media.controller.Library.prototype.initialize.call(this,e)},handleDisplaySettingChange:function(e){this.get("selectedDisplaySettings").set(e.attributes)},display:function(e){var t=this.get("selectedDisplaySettings"),e=wp.media.controller.Library.prototype.display.call(this,e);return e.off("change",this.handleDisplaySettingChange),e.set(t.attributes),"custom"===t.get("link_type")&&(e.linkUrl=t.get("link_url")),e.on("change",this.handleDisplaySettingChange),e}}),m.MediaEmbedView=wp.media.view.Embed.extend({initialize:function(e){var t=this;wp.media.view.Embed.prototype.initialize.call(t,e),"image"!==t.controller.options.mimeType&&(e=t.controller.states.get("embed")).off("scan",e.scanImage,e)},refresh:function(){var e="image"===this.controller.options.mimeType?wp.media.view.EmbedImage:wp.media.view.EmbedLink.extend({setAddToWidgetButtonDisabled:function(e){this.views.parent.views.parent.views.get(".media-frame-toolbar")[0].$el.find(".media-button-select").prop("disabled",e)},setErrorNotice:function(e){var t=this.views.parent.$el.find("> .notice:first-child");e?(t.length||((t=c('<div class="media-widget-embed-notice notice notice-error notice-alt" role="alert"></div>')).hide(),this.views.parent.$el.prepend(t)),t.empty(),t.append(c("<p>",{html:e})),t.slideDown("fast")):t.length&&t.slideUp("fast")},updateoEmbed:function(){var e=this,t=e.model.get("url");t?(t.match(/^(http|https):\/\/.+\//)||(e.controller.$el.find("#embed-url-field").addClass("invalid"),e.setAddToWidgetButtonDisabled(!0)),wp.media.view.EmbedLink.prototype.updateoEmbed.call(e)):(e.setErrorNotice(""),e.setAddToWidgetButtonDisabled(!0))},fetch:function(){var t,e,i=this,n=i.model.get("url");i.dfd&&"pending"===i.dfd.state()&&i.dfd.abort(),t=function(e){i.renderoEmbed({data:{body:e}}),i.controller.$el.find("#embed-url-field").removeClass("invalid"),i.setErrorNotice(""),i.setAddToWidgetButtonDisabled(!1)},(e=document.createElement("a")).href=n,(e=e.pathname.toLowerCase().match(/\.(\w+)$/))?(e=e[1],!wp.media.view.settings.embedMimes[e]||0!==wp.media.view.settings.embedMimes[e].indexOf(i.controller.options.mimeType)?i.renderFail():t("\x3c!--success--\x3e")):((e=/https?:\/\/www\.youtube\.com\/embed\/([^/]+)/.exec(n))&&(n="https://www.youtube.com/watch?v="+e[1],i.model.attributes.url=n),i.dfd=wp.apiRequest({url:wp.media.view.settings.oEmbedProxyUrl,data:{url:n,maxwidth:i.model.get("width"),maxheight:i.model.get("height"),discover:!1},type:"GET",dataType:"json",context:i}),i.dfd.done(function(e){i.controller.options.mimeType!==e.type?i.renderFail():t(e.html)}),i.dfd.fail(_.bind(i.renderFail,i)))},renderFail:function(){var e=this;e.controller.$el.find("#embed-url-field").addClass("invalid"),e.setErrorNotice(e.controller.options.invalidEmbedTypeError||"ERROR"),e.setAddToWidgetButtonDisabled(!0)}});this.settings(new e({controller:this.controller,model:this.model.props,priority:40}))}}),m.MediaFrameSelect=wp.media.view.MediaFrame.Post.extend({createStates:function(){var t=this.options.mimeType,i=[];_.each(wp.media.view.settings.embedMimes,function(e){0===e.indexOf(t)&&i.push(e)}),0<i.length&&(t=i),this.states.add([new m.PersistentDisplaySettingsLibrary({id:"insert",title:this.options.title,selection:this.options.selection,priority:20,toolbar:"main-insert",filterable:"dates",library:wp.media.query({type:t}),multiple:!1,editable:!0,selectedDisplaySettings:this.options.selectedDisplaySettings,displaySettings:!!_.isUndefined(this.options.showDisplaySettings)||this.options.showDisplaySettings,displayUserSettings:!1}),new wp.media.controller.EditImage({model:this.options.editImage}),new wp.media.controller.Embed({metadata:this.options.metadata,type:"image"===this.options.mimeType?"image":"link",invalidEmbedTypeError:this.options.invalidEmbedTypeError})])},mainInsertToolbar:function(e){var i=this;e.set("insert",{style:"primary",priority:80,text:i.options.text,requires:{selection:!0},click:function(){var e=i.state(),t=e.get("selection");i.close(),e.trigger("insert",t).reset()}})},mainEmbedToolbar:function(e){e.view=new wp.media.view.Toolbar.Embed({controller:this,text:this.options.text,event:"insert"})},embedContent:function(){var e=new m.MediaEmbedView({controller:this,model:this.state()}).render();this.content.set(e)}}),m.MediaWidgetControl=Backbone.View.extend({l10n:{add_to_widget:"{{add_to_widget}}",add_media:"{{add_media}}"},id_base:"",mime_type:"",events:{"click .notice-missing-attachment a":"handleMediaLibraryLinkClick","click .select-media":"selectMedia","click .placeholder":"selectMedia","click .edit-media":"editMedia"},showDisplaySettings:!0,initialize:function(e){var i=this;if(Backbone.View.prototype.initialize.call(i,e),!(i.model instanceof m.MediaWidgetModel))throw new Error("Missing options.model");if(!e.el)throw new Error("Missing options.el");if(!e.syncContainer)throw new Error("Missing options.syncContainer");if(i.syncContainer=e.syncContainer,i.$el.addClass("media-widget-control"),_.bindAll(i,"syncModelToInputs","render","updateSelectedAttachment","renderPreview"),!i.id_base&&(_.find(m.controlConstructors,function(e,t){return i instanceof e&&(i.id_base=t,!0)}),!i.id_base))throw new Error("Missing id_base.");i.previewTemplateProps=new Backbone.Model(i.mapModelToPreviewTemplateProps()),i.selectedAttachment=new wp.media.model.Attachment,i.renderPreview=_.debounce(i.renderPreview),i.listenTo(i.previewTemplateProps,"change",i.renderPreview),i.model.on("change:attachment_id",i.updateSelectedAttachment),i.model.on("change:url",i.updateSelectedAttachment),i.updateSelectedAttachment(),i.listenTo(i.model,"change",i.syncModelToInputs),i.listenTo(i.model,"change",i.syncModelToPreviewProps),i.listenTo(i.model,"change",i.render),i.$el.on("input change",".title",function(){i.model.set({title:c(this).val().trim()})}),i.$el.on("input change",".link",function(){var e=c(this).val().trim(),t="custom";i.selectedAttachment.get("linkUrl")===e||i.selectedAttachment.get("link")===e?t="post":i.selectedAttachment.get("url")===e&&(t="file"),i.model.set({link_url:e,link_type:t}),i.displaySettings.set({link:t,linkUrl:e})}),i.displaySettings=new Backbone.Model(_.pick(i.mapModelToMediaFrameProps(_.extend(i.model.defaults(),i.model.toJSON())),_.keys(wp.media.view.settings.defaultProps)))},updateSelectedAttachment:function(){var e,t=this;0===t.model.get("attachment_id")?(t.selectedAttachment.clear(),t.model.set("error",!1)):t.model.get("attachment_id")!==t.selectedAttachment.get("id")&&(e=new wp.media.model.Attachment({id:t.model.get("attachment_id")})).fetch().done(function(){t.model.set("error",!1),t.selectedAttachment.set(e.toJSON())}).fail(function(){t.model.set("error","missing_attachment")})},syncModelToPreviewProps:function(){this.previewTemplateProps.set(this.mapModelToPreviewTemplateProps())},syncModelToInputs:function(){var n=this;n.syncContainer.find(".media-widget-instance-property").each(function(){var e=c(this),t=e.data("property"),i=n.model.get(t);_.isUndefined(i)||(i="array"===n.model.schema[t].type&&_.isArray(i)?i.join(","):"boolean"===n.model.schema[t].type?i?"1":"":String(i),e.val()!==i&&(e.val(i),e.trigger("change")))})},template:function(){if(c("#tmpl-widget-media-"+this.id_base+"-control").length)return wp.template("widget-media-"+this.id_base+"-control");throw new Error("Missing widget control template for "+this.id_base)},render:function(){var e,t=this;t.templateRendered||(t.$el.html(t.template()(t.model.toJSON())),t.renderPreview(),t.templateRendered=!0),(e=t.$el.find(".title")).is(document.activeElement)||e.val(t.model.get("title")),t.$el.toggleClass("selected",t.isSelected())},renderPreview:function(){throw new Error("renderPreview must be implemented")},isSelected:function(){return!this.model.get("error")&&Boolean(this.model.get("attachment_id")||this.model.get("url"))},handleMediaLibraryLinkClick:function(e){e.preventDefault(),this.selectMedia()},selectMedia:function(){var i,t,e,n=this,d=[];n.isSelected()&&0!==n.model.get("attachment_id")&&d.push(n.selectedAttachment),d=new wp.media.model.Selection(d,{multiple:!1}),(e=n.mapModelToMediaFrameProps(n.model.toJSON())).size&&n.displaySettings.set("size",e.size),i=new m.MediaFrameSelect({title:n.l10n.add_media,frame:"post",text:n.l10n.add_to_widget,selection:d,mimeType:n.mime_type,selectedDisplaySettings:n.displaySettings,showDisplaySettings:n.showDisplaySettings,metadata:e,state:n.isSelected()&&0===n.model.get("attachment_id")?"embed":"insert",invalidEmbedTypeError:n.l10n.unsupported_file_type}),(wp.media.frame=i).on("insert",function(){var e={},t=i.state();"embed"===t.get("id")?_.extend(e,{id:0},t.props.toJSON()):_.extend(e,t.get("selection").first().toJSON()),n.selectedAttachment.set(e),n.model.set("error",!1),n.model.set(n.getModelPropsFromMediaFrame(i))}),t=wp.media.model.Attachment.prototype.sync,wp.media.model.Attachment.prototype.sync=function(e){return"delete"===e?t.apply(this,arguments):c.Deferred().rejectWith(this).promise()},i.on("close",function(){wp.media.model.Attachment.prototype.sync=t}),i.$el.addClass("media-widget"),i.open(),d&&d.on("destroy",function(e){n.model.get("attachment_id")===e.get("id")&&n.model.set({attachment_id:0,url:""})}),i.$el.find(".media-frame-menu .media-menu-item.active").focus()},getModelPropsFromMediaFrame:function(e){var t,i,n=this,d=e.state();if("insert"===d.get("id"))(t=d.get("selection").first().toJSON()).postUrl=t.link,n.showDisplaySettings&&_.extend(t,e.content.get(".attachments-browser").sidebar.get("display").model.toJSON()),t.sizes&&t.size&&t.sizes[t.size]&&(t.url=t.sizes[t.size].url);else{if("embed"!==d.get("id"))throw new Error("Unexpected state: "+d.get("id"));t=_.extend(d.props.toJSON(),{attachment_id:0},n.model.getEmbedResetProps())}return t.id&&(t.attachment_id=t.id),i=n.mapMediaToModelProps(t),_.each(wp.media.view.settings.embedExts,function(e){e in n.model.schema&&i.url!==i[e]&&(i[e]="")}),i},mapMediaToModelProps:function(e){var t,i=this,n={},d={};return _.each(i.model.schema,function(e,t){"title"!==t&&(n[e.media_prop||t]=t)}),_.each(e,function(e,t){t=n[t]||t;i.model.schema[t]&&(d[t]=e)}),"custom"===e.size&&(d.width=e.customWidth,d.height=e.customHeight),"post"===e.link?d.link_url=e.postUrl||e.linkUrl:"file"===e.link&&(d.link_url=e.url),!e.attachment_id&&e.id&&(d.attachment_id=e.id),e.url&&(t=e.url.replace(/#.*$/,"").replace(/\?.*$/,"").split(".").pop().toLowerCase())in i.model.schema&&(d[t]=e.url),_.omit(d,"title")},mapModelToMediaFrameProps:function(e){var n=this,d={};return _.each(e,function(e,t){var i=n.model.schema[t]||{};d[i.media_prop||t]=e}),d.attachment_id=d.id,"custom"===d.size&&(d.customWidth=n.model.get("width"),d.customHeight=n.model.get("height")),d},mapModelToPreviewTemplateProps:function(){var i=this,n={};return _.each(i.model.schema,function(e,t){e.hasOwnProperty("should_preview_update")&&!e.should_preview_update||(n[t]=i.model.get(t))}),n.error=i.model.get("error"),n},editMedia:function(){throw new Error("editMedia not implemented")}}),m.MediaWidgetModel=Backbone.Model.extend({idAttribute:"widget_id",schema:{title:{type:"string",default:""},attachment_id:{type:"integer",default:0},url:{type:"string",default:""}},defaults:function(){var i={};return _.each(this.schema,function(e,t){i[t]=e.default}),i},set:function(e,t,i){var n,d,o=this;return null===e?o:(e="object"==typeof e?(n=e,t):((n={})[e]=t,i),d={},_.each(n,function(e,t){var i;o.schema[t]?"array"===(i=o.schema[t].type)?(d[t]=e,_.isArray(d[t])||(d[t]=d[t].split(/,/)),o.schema[t].items&&"integer"===o.schema[t].items.type&&(d[t]=_.filter(_.map(d[t],function(e){return parseInt(e,10)},function(e){return"number"==typeof e})))):d[t]="integer"===i?parseInt(e,10):"boolean"===i?!(!e||"0"===e||"false"===e):e:d[t]=e}),Backbone.Model.prototype.set.call(this,d,e))},getEmbedResetProps:function(){return{id:0}}}),m.modelCollection=new(Backbone.Collection.extend({model:m.MediaWidgetModel})),m.widgetControls={},m.handleWidgetAdded=function(e,t){var i,n,d,o,a,s,r=t.find("> .widget-inside > .form, > .widget-inside > form"),l=r.find("> .id_base").val(),r=r.find("> .widget-id").val();m.widgetControls[r]||(d=m.controlConstructors[l])&&(l=m.modelConstructors[l]||m.MediaWidgetModel,i=c("<div></div>"),(n=t.find(".widget-content:first")).before(i),o={},n.find(".media-widget-instance-property").each(function(){var e=c(this);o[e.data("property")]=e.val()}),o.widget_id=r,r=new l(o),a=new d({el:i,syncContainer:n,model:r}),(s=function(){t.hasClass("open")?a.render():setTimeout(s,50)})(),m.modelCollection.add([r]),m.widgetControls[r.get("widget_id")]=a)},m.setupAccessibleMode=function(){var e,t,i,n,d,o=c(".editwidget > form");0!==o.length&&(i=o.find(".id_base").val(),t=m.controlConstructors[i])&&(e=o.find("> .widget-control-actions > .widget-id").val(),i=m.modelConstructors[i]||m.MediaWidgetModel,d=c("<div></div>"),(o=o.find("> .widget-inside")).before(d),n={},o.find(".media-widget-instance-property").each(function(){var e=c(this);n[e.data("property")]=e.val()}),n.widget_id=e,e=new t({el:d,syncContainer:o,model:new i(n)}),m.modelCollection.add([e.model]),(m.widgetControls[e.model.get("widget_id")]=e).render())},m.handleWidgetUpdated=function(e,t){var i={},t=t.find("> .widget-inside > .form, > .widget-inside > form"),n=t.find("> .widget-id").val(),n=m.widgetControls[n];n&&(t.find("> .widget-content").find(".media-widget-instance-property").each(function(){var e=c(this).data("property");i[e]=c(this).val()}),n.stopListening(n.model,"change",n.syncModelToInputs),n.model.set(i),n.listenTo(n.model,"change",n.syncModelToInputs))},m.init=function(){var e=c(document);e.on("widget-added",m.handleWidgetAdded),e.on("widget-synced widget-updated",m.handleWidgetUpdated),c(function(){"widgets"===window.pagenow&&(c(".widgets-holder-wrap:not(#available-widgets)").find("div.widget").one("click.toggle-widget-expanded",function(){var e=c(this);m.handleWidgetAdded(new jQuery.Event("widget-added"),e)}),"complete"===document.readyState?m.setupAccessibleMode():c(window).on("load",function(){m.setupAccessibleMode()}))})},m}(jQuery);
\ No newline at end of file |