varwpNavMenu;(function($){varapi=wpNavMenu={options:{menuItemDepthPerLevel:30,globalMaxDepth:11},menuList:undefined,targetList:undefined,menusChanged:false,isRTL:!!("undefined"!=typeofisRtl&&isRtl),init:function(){api.menuList=$("#menu-to-edit");api.targetList=api.menuList;this.jQueryExtensions();this.attachMenuEditListeners();this.setupInputWithDefaultTitle();this.attachQuickSearchListeners();this.attachThemeLocationsListeners();this.attachTabsPanelListeners();this.attachUnsavedChangesListener();if(api.menuList.length){this.initSortables()}this.initToggles();this.initTabManager()},jQueryExtensions:function(){$.fn.extend({menuItemDepth:function(){varmargin=api.isRTL?this.eq(0).css("margin-right"):this.eq(0).css("margin-left");returnapi.pxToDepth(margin&&-1!=margin.indexOf("px")?margin.slice(0,-2):0)},updateDepthClass:function(current,prev){returnthis.each(function(){vart=$(this);prev=prev||t.menuItemDepth();$(this).removeClass("menu-item-depth-"+prev).addClass("menu-item-depth-"+current)})},shiftDepthClass:function(change){returnthis.each(function(){vart=$(this),depth=t.menuItemDepth();$(this).removeClass("menu-item-depth-"+depth).addClass("menu-item-depth-"+(depth+change))})},childMenuItems:function(){varresult=$();this.each(function(){vart=$(this),depth=t.menuItemDepth(),next=t.next();while(next.length&&next.menuItemDepth()>depth){result=result.add(next);next=next.next()}});returnresult},updateParentMenuItemDBId:function(){returnthis.each(function(){varitem=$(this),input=item.find(".menu-item-data-parent-id"),depth=item.menuItemDepth(),parent=item.prev();if(depth==0){input.val(0)}else{while(!parent[0]||!parent[0].className||-1==parent[0].className.indexOf("menu-item")||(parent.menuItemDepth()!=depth-1)){parent=parent.prev()}input.val(parent.find(".menu-item-data-db-id").val())}})},hideAdvancedMenuItemFields:function(){returnthis.each(function(){varthat=$(this);$(".hide-column-tog").not(":checked").each(function(){that.find(".field-"+$(this).val()).addClass("hidden-field")})})},addSelectedToMenu:function(processMethod){if(0==$("#menu-to-edit").length){returnfalse}returnthis.each(function(){vart=$(this),menuItems={},checkboxes=t.find(".tabs-panel-active .categorychecklist li input:checked"),re=newRegExp("menu-item\\[([^\\]]*)");processMethod=processMethod||api.addMenuItemToBottom;if(!checkboxes.length){returnfalse}t.find("img.waiting").show();$(checkboxes).each(function(){vart=$(this),listItemDBIDMatch=re.exec(t.attr("name")),listItemDBID="undefined"==typeoflistItemDBIDMatch[1]?0:parseInt(listItemDBIDMatch[1],10);if(this.className&&-1!=this.className.indexOf("add-to-top")){processMethod=api.addMenuItemToTop}menuItems[listItemDBID]=t.closest("li").getItemData("add-menu-item",listItemDBID)});api.addItemToMenu(menuItems,processMethod,function(){checkboxes.removeAttr("checked");t.find("img.waiting").hide()})})},getItemData:function(itemType,id){itemType=itemType||"menu-item";varitemData={},i,fields=["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"];if(!id&&itemType=="menu-item"){id=this.find(".menu-item-data-db-id").val()}if(!id){returnitemData}this.find("input").each(function(){varfield;i=fields.length;while(i--){if(itemType=="menu-item"){field=fields[i]+"["+id+"]"}else{if(itemType=="add-menu-item"){field="menu-item["+id+"]["+fields[i]+"]"}}if(this.name&&field==this.name){itemData[fields[i]]=this.value}}});returnitemData},setItemData:function(itemData,itemType,id){itemType=itemType||"menu-item";if(!id&&itemType=="menu-item"){id=$(".menu-item-data-db-id",this).val()}if(!id){returnthis}this.find("input").each(function(){vart=$(this),field;$.each(itemData,function(attr,val){if(itemType=="menu-item"){field=attr+"["+id+"]"}else{if(itemType=="add-menu-item"){field="menu-item["+id+"]["+attr+"]"}}if(field==t.attr("name")){t.val(val)}})});returnthis}})},initToggles:function(){postboxes.add_postbox_to