From e6dee5ed5ac1aec507965f221fb2df9164df9bed Mon Sep 17 00:00:00 2001 From: desrosj Date: Wed, 20 Nov 2024 13:33:18 +0000 Subject: [PATCH] I18N: Adjust translator comments in `nav-menu.js`. Includes: * Moving the comments directly above `wp.i18n._x()` so that they can be picked up properly. * Simplifying the context to avoid unnecessarily translating the string twice for the same use case. * Using the established translator comments format for consistency. Follow-up to [59428]. Reviewed by SergeyBiryukov, desrosj. Merges [59431 to the 6.7 branch. Fixes #62402. Built from https://develop.svn.wordpress.org/branches/6.7@59432 git-svn-id: http://core.svn.wordpress.org/branches/6.7@58818 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/nav-menu.js | 8 ++++---- wp-admin/js/nav-menu.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-admin/js/nav-menu.js b/wp-admin/js/nav-menu.js index 3b1daa9970..398f54ecfd 100644 --- a/wp-admin/js/nav-menu.js +++ b/wp-admin/js/nav-menu.js @@ -364,9 +364,9 @@ if ( i == itemPosition ) { $selected = 'selected'; } - // Translators: %1$s is the current menu item number, %2$s is the total number of menu items. var itemString = wp.i18n.sprintf( - wp.i18n._x( '%1$s of %2$s', 'indicating a part of a total number of items in a navigation menu' ), + /* translators: 1: The current menu item number, 2: The total number of menu items. */ + wp.i18n._x( '%1$s of %2$s', 'part of a total number of menu items' ), i, totalMenuItems ); @@ -386,9 +386,9 @@ if ( i == itemPosition ) { $selected = 'selected'; } - // Translators: %1$s is the current submenu item number, %2$s is the total number of submenu items. var submenuString = wp.i18n.sprintf( - wp.i18n._x( '%1$s of %2$s', 'indicating a part of a total number of items in a submenu' ), + /* translators: 1: The current submenu item number, 2: The total number of submenu items. */ + wp.i18n._x( '%1$s of %2$s', 'part of a total number of menu items' ), i, totalSubMenuItems ); diff --git a/wp-admin/js/nav-menu.min.js b/wp-admin/js/nav-menu.min.js index 9a21c88408..aa8b1a8c51 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"),e.updateParentDropdown(),e.updateOrderDropdown()})})},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},updateParentDropdown:function(){return this.each(function(){var o=k("#menu-to-edit li"),e=k(".edit-menu-item-parent");k.each(e,function(){var e=k(this),i="",t="",n=e.closest("li.menu-item").find(".menu-item-data-db-id").val(),a=e.closest("li.menu-item").find(".menu-item-data-parent-id").val(),s=e.closest("li.menu-item").childMenuItems(),m=[n];0'+wp.i18n._x("No Parent","menu item without a parent in navigation menu")+"",k.each(o,function(){var e=k(this),t="",n=e.find(".menu-item-data-db-id").val(),e=e.find(".edit-menu-item-title").val();m.includes(n)||(i+="")}),e.html(i)})})},updateOrderDropdown:function(){return this.each(function(){var l,e=k(".edit-menu-item-order");k.each(e,function(){var e=k(this),t=e.closest("li.menu-item").first(),n=t.menuItemDepth(),i="",a="";if(0===n){var s=k(".menu-item-depth-0"),m=s.length;l=s.index(t)+1;for(let e=1;e'+o+""}}else{var s=t.prevAll(".menu-item-depth-"+parseInt(n-1,10)).first().find(".menu-item-data-db-id").val(),n=k('.menu-item .menu-item-data-parent-id[value="'+s+'"]'),u=n.length;l=k(n.parents(".menu-item").get().reverse()).index(t)+1;for(let e=1;e'+d+""}}e.html(i)})})}})},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(),d=parseInt(m.menuItemDepth(),10),l=parseInt(m.index(),10),r=m.next(),c=r.childMenuItems(),h=parseInt(r.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!==d&&m.moveHorizontally(0,d),0!==f&&m.moveHorizontally(f,d),(o?n=m.add(o):m).detach().insertBefore(a.eq(i)).updateParentMenuItemDBId());break;case"down":if(o){if(n=m.add(o),(c=0!==(r=a.eq(n.length+l)).childMenuItems().length)&&(i=parseInt(r.menuItemDepth(),10)+1,m.moveHorizontally(i,d)),s===l+n.length)break;n.detach().insertAfter(a.eq(l+n.length)).updateParentMenuItemDBId()}else{if(0!==c.length&&m.moveHorizontally(h,d),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!==d&&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(),m.updateParentDropdown(),m.updateOrderDropdown(),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)}),e.updateParentDropdown(),e.updateOrderDropdown(),e.on("change",".edit-menu-item-parent",function(){I.changeMenuParent(k(this))}),e.on("change",".edit-menu-item-order",function(){I.changeMenuOrder(k(this))})},changeMenuParent:function(e){var t=k("#menu-to-edit li"),e=k(e),n=e.val(),i=e.closest("li.menu-item").first(),a=i.menuItemDepth(),s=i.childMenuItems(),m=parseInt(i.childMenuItems().length,10),o=k("#menu-item-"+n),u=o.menuItemDepth(),u=parseInt(u)+1,u=(0==n&&(u=0),i.find(".menu-item-data-parent-id").val(n),i.moveHorizontally(u,a),(i=0I.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"),r=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(),r.append(i),n=r.outerHeight(),n=(n+=0d&&(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'+e+' ('+t+')'),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("#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("
").html(e).find("li"),d=n.closest(".accordion-section-content"),l=d.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"),d.removeClass("has-no-menu-item"),l.is(":checked")&&l.prop("checked",!1)):(k(".categorychecklist",n).html("
  • "+wp.i18n.__("No results found.")+"

  • "),k(".spinner",n).removeClass("is-active"),d.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),menus.updateParentDropdown(),menus.updateOrderDropdown()})},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) *",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"),e.updateParentDropdown(),e.updateOrderDropdown()})})},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},updateParentDropdown:function(){return this.each(function(){var o=k("#menu-to-edit li"),e=k(".edit-menu-item-parent");k.each(e,function(){var e=k(this),i="",t="",n=e.closest("li.menu-item").find(".menu-item-data-db-id").val(),a=e.closest("li.menu-item").find(".menu-item-data-parent-id").val(),s=e.closest("li.menu-item").childMenuItems(),m=[n];0'+wp.i18n._x("No Parent","menu item without a parent in navigation menu")+"",k.each(o,function(){var e=k(this),t="",n=e.find(".menu-item-data-db-id").val(),e=e.find(".edit-menu-item-title").val();m.includes(n)||(i+="")}),e.html(i)})})},updateOrderDropdown:function(){return this.each(function(){var l,e=k(".edit-menu-item-order");k.each(e,function(){var e=k(this),t=e.closest("li.menu-item").first(),n=t.menuItemDepth(),i="",a="";if(0===n){var s=k(".menu-item-depth-0"),m=s.length;l=s.index(t)+1;for(let e=1;e'+o+""}}else{var s=t.prevAll(".menu-item-depth-"+parseInt(n-1,10)).first().find(".menu-item-data-db-id").val(),n=k('.menu-item .menu-item-data-parent-id[value="'+s+'"]'),u=n.length;l=k(n.parents(".menu-item").get().reverse()).index(t)+1;for(let e=1;e'+d+""}}e.html(i)})})}})},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(),d=parseInt(m.menuItemDepth(),10),l=parseInt(m.index(),10),r=m.next(),c=r.childMenuItems(),h=parseInt(r.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!==d&&m.moveHorizontally(0,d),0!==f&&m.moveHorizontally(f,d),(o?n=m.add(o):m).detach().insertBefore(a.eq(i)).updateParentMenuItemDBId());break;case"down":if(o){if(n=m.add(o),(c=0!==(r=a.eq(n.length+l)).childMenuItems().length)&&(i=parseInt(r.menuItemDepth(),10)+1,m.moveHorizontally(i,d)),s===l+n.length)break;n.detach().insertAfter(a.eq(l+n.length)).updateParentMenuItemDBId()}else{if(0!==c.length&&m.moveHorizontally(h,d),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!==d&&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(),m.updateParentDropdown(),m.updateOrderDropdown(),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)}),e.updateParentDropdown(),e.updateOrderDropdown(),e.on("change",".edit-menu-item-parent",function(){I.changeMenuParent(k(this))}),e.on("change",".edit-menu-item-order",function(){I.changeMenuOrder(k(this))})},changeMenuParent:function(e){var t=k("#menu-to-edit li"),e=k(e),n=e.val(),i=e.closest("li.menu-item").first(),a=i.menuItemDepth(),s=i.childMenuItems(),m=parseInt(i.childMenuItems().length,10),o=k("#menu-item-"+n),u=o.menuItemDepth(),u=parseInt(u)+1,u=(0==n&&(u=0),i.find(".menu-item-data-parent-id").val(n),i.moveHorizontally(u,a),(i=0I.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"),r=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(),r.append(i),n=r.outerHeight(),n=(n+=0d&&(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'+e+' ('+t+')'),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("#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("
    ").html(e).find("li"),d=n.closest(".accordion-section-content"),l=d.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"),d.removeClass("has-no-menu-item"),l.is(":checked")&&l.prop("checked",!1)):(k(".categorychecklist",n).html("
  • "+wp.i18n.__("No results found.")+"

  • "),k(".spinner",n).removeClass("is-active"),d.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),menus.updateParentDropdown(),menus.updateOrderDropdown()})},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)