From 337df6e3374928d97cae5cb669aa69f08c266a7d Mon Sep 17 00:00:00 2001 From: nacin Date: Thu, 20 May 2010 14:55:11 +0000 Subject: [PATCH] Remove AYS for deleting a menu item. fixes #13330. git-svn-id: http://svn.automattic.com/wordpress/trunk@14756 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/nav-menu.dev.js | 37 +++++++++++++++-------------------- wp-admin/js/nav-menu.js | 2 +- wp-includes/script-loader.php | 3 +-- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/wp-admin/js/nav-menu.dev.js b/wp-admin/js/nav-menu.dev.js index f99b0657f3..2a1d297649 100644 --- a/wp-admin/js/nav-menu.dev.js +++ b/wp-admin/js/nav-menu.dev.js @@ -692,29 +692,24 @@ var wpNavMenu; matchedSection, that = this; - // Delete warning AYS - if ( confirm( navMenuL10n.warnDeleteMenuItem ) ) { - matchedSection = /_wpnonce=([a-zA-Z0-9]*)$/.exec(clickedEl.href); - if ( matchedSection && matchedSection[1] ) { - itemID = parseInt(clickedEl.id.replace('delete-', ''), 10); - $.post( - ajaxurl, - { - action:'delete-menu-item', - 'menu-item':itemID, - '_wpnonce':matchedSection[1] - }, - function (resp) { - if ( '1' == resp ) - that.removeMenuItem(document.getElementById('menu-item-' + itemID)); - } - ); - return false; - } - return true; - } else { + matchedSection = /_wpnonce=([a-zA-Z0-9]*)$/.exec(clickedEl.href); + if ( matchedSection && matchedSection[1] ) { + itemID = parseInt(clickedEl.id.replace('delete-', ''), 10); + $.post( + ajaxurl, + { + action:'delete-menu-item', + 'menu-item':itemID, + '_wpnonce':matchedSection[1] + }, + function (resp) { + if ( '1' == resp ) + that.removeMenuItem(document.getElementById('menu-item-' + itemID)); + } + ); return false; } + return true; }, /** diff --git a/wp-admin/js/nav-menu.js b/wp-admin/js/nav-menu.js index 101e81d19f..ab70d4bc04 100644 --- a/wp-admin/js/nav-menu.js +++ b/wp-admin/js/nav-menu.js @@ -1 +1 @@ -var wpNavMenu;(function($){var api=wpNavMenu={options:{menuItemDepthPerLevel:30,globalMaxDepth:11},menuList:undefined,targetList:undefined,menusChanged:false,init:function(){api.menuList=$("#menu-to-edit");api.targetList=api.menuList;this.jQueryExtensions();this.attachMenuEditListeners();this.setupInputWithDefaultTitle();this.attachAddMenuItemListeners();this.attachQuickSearchListeners();this.attachThemeLocationsListeners();this.attachTabsPanelListeners();this.attachHomeLinkListener();this.attachUnsavedChangesListener();if(api.menuList.length){this.initSortables()}this.initToggles();this.initTabManager()},jQueryExtensions:function(){$.fn.extend({menuItemDepth:function(){return api.pxToDepth(this.eq(0).css("margin-left").slice(0,-2))},updateDepthClass:function(current,prev){return this.each(function(){var t=$(this);prev=prev||t.menuItemDepth();$(this).removeClass("menu-item-depth-"+prev).addClass("menu-item-depth-"+current)})},shiftDepthClass:function(change){return this.each(function(){var t=$(this),depth=t.menuItemDepth();$(this).removeClass("menu-item-depth-"+depth).addClass("menu-item-depth-"+(depth+change))})},childMenuItems:function(){var result=$();this.each(function(){var t=$(this),depth=t.menuItemDepth(),next=t.next();while(next.length&&next.menuItemDepth()>depth){result=result.add(next);next=next.next()}});return result},updateParentMenuItemDBId:function(){return this.each(function(){var item=$(this),input=item.find(".menu-item-data-parent-id"),depth=item.menuItemDepth(),parent=item.prev();if(depth==0){input.val(0)}else{while(parent.menuItemDepth()!=depth-1){parent=parent.prev()}input.val(parent.find(".menu-item-data-db-id").val())}})},hideAdvancedMenuItemFields:function(){return this.each(function(){var that=$(this);$(".hide-column-tog").not(":checked").each(function(){that.find(".field-"+$(this).val()).addClass("hidden-field")})})},addSelectedToMenu:function(processMethod){return this.each(function(){var t=$(this),menuItems={},checkboxes=t.find(".tabs-panel-active .categorychecklist li input:checked"),re=new RegExp("menu-item\\[([^\\]]*)");processMethod=processMethod||api.addMenuItemToBottom;if(!checkboxes.length){return false}t.find("img.waiting").show();$(checkboxes).each(function(){var listItemDBIDMatch=re.exec($(this).attr("name")),listItemDBID="undefined"==typeof listItemDBIDMatch[1]?0:parseInt(listItemDBIDMatch[1],10);menuItems[listItemDBID]=api.getListDataFromID(listItemDBID)});api.addItemToMenu(menuItems,processMethod,function(){checkboxes.removeAttr("checked");t.find("img.waiting").hide()})})}})},initToggles:function(){postboxes.add_postbox_toggles("nav-menus");columns.useCheckboxesForHidden();columns.checked=function(field){$(".field-"+field).removeClass("hidden-field")};columns.unchecked=function(field){$(".field-"+field).addClass("hidden-field")};api.menuList.hideAdvancedMenuItemFields()},initSortables:function(){var currentDepth=0,originalDepth,minDepth,maxDepth,prev,next,prevBottom,nextThreshold,helperHeight,transport,menuLeft=api.menuList.offset().left;api.menuList.sortable({handle:".menu-item-handle",placeholder:"sortable-placeholder",start:function(e,ui){var height,width,parent,children,maxChildDepth,tempHolder;transport=ui.item.children(".menu-item-transport");originalDepth=ui.item.menuItemDepth();updateCurrentDepth(ui,originalDepth);parent=(ui.item.next()[0]==ui.placeholder[0])?ui.item.next():ui.item;children=parent.childMenuItems();transport.append(children);height=transport.outerHeight();height+=(height>0)?(ui.placeholder.css("margin-top").slice(0,-2)*1):0;height+=ui.helper.outerHeight();helperHeight=height;height-=2;ui.placeholder.height(height);maxChildDepth=originalDepth;children.each(function(){var depth=$(this).menuItemDepth();maxChildDepth=(depth>maxChildDepth)?depth:maxChildDepth});width=ui.helper.find(".menu-item-handle").outerWidth();width+=api.depthToPx(maxChildDepth-originalDepth);width-=2;ui.placeholder.width(width);tempHolder=ui.placeholder.next();tempHolder.css("margin-top",helperHeight+"px");ui.placeholder.detach();$(this).sortable("refresh");ui.item.after(ui.placeholder);tempHolder.css("margin-top",0);updateSharedVars(ui)},stop:function(e,ui){var children,depthChange=currentDepth-originalDepth;children=transport.children().insertAfter(ui.item);if(depthChange!=0){ui.item.updateDepthClass(currentDepth);children.shiftDepthClass(depthChange);api.registerChange()}ui.item.updateParentMenuItemDBId()},change:function(e,ui){if(!ui.placeholder.parent().hasClass("menu")){(prev.length)?prev.after(ui.placeholder):api.menuList.prepend(ui.placeholder)}updateSharedVars(ui)},sort:function(e,ui){var offset=ui.helper.offset(),depth=api.pxToDepth(offset.left-menuLeft);if(depth>maxDepth||offset.topnextThreshold){next.after(ui.placeholder);updateSharedVars(ui);$(this).sortable("refreshPositions")}},update:function(e,ui){api.registerChange()}});function updateSharedVars(ui){var depth;prev=ui.placeholder.prev();next=ui.placeholder.next();if(prev[0]==ui.item[0]){prev=prev.prev()}if(next[0]==ui.item[0]){next=next.next()}prevBottom=(prev.length)?prev.offset().top+prev.height():0;nextThreshold=(next.length)?next.offset().top+next.height()/3:0;minDepth=(next.length)?next.menuItemDepth():0;if(prev.length){maxDepth=((depth=prev.menuItemDepth()+1)>api.options.globalMaxDepth)?api.options.globalMaxDepth:depth}else{maxDepth=0}}function updateCurrentDepth(ui,depth){ui.placeholder.updateDepthClass(depth,currentDepth);currentDepth=depth}},attachMenuEditListeners:function(){var that=this;$("#update-nav-menu").bind("click",function(e){if(e.target&&e.target.className){if(-1!=e.target.className.indexOf("item-edit")){return that.eventOnClickEditLink(e.target)}else{if(-1!=e.target.className.indexOf("menu-save")){return that.eventOnClickMenuSave(e.target)}else{if(-1!=e.target.className.indexOf("menu-delete")){return that.eventOnClickMenuDelete(e.target)}else{if(-1!=e.target.className.indexOf("item-delete")){return that.eventOnClickMenuItemDelete(e.target)}else{if(-1!=e.target.className.indexOf("item-close")){return that.eventOnClickCloseLink(e.target)}}}}}}})},setupInputWithDefaultTitle:function(){var name="input-with-default-title";$("."+name).each(function(){var $t=$(this),title=$t.attr("title"),val=$t.val();$t.data(name,title);if(""==val){$t.val(title)}else{if(title==val){return}else{$t.removeClass(name)}}}).focus(function(){var $t=$(this);if($t.val()==$t.data(name)){$t.val("").removeClass(name)}}).blur(function(){var $t=$(this);if(""==$t.val()){$t.addClass(name).val($t.data(name))}})},attachAddMenuItemListeners:function(){var form=$("#nav-menu-meta");form.find(".add-to-menu input").click(function(){api.registerChange();$(this).trigger("wp-add-menu-item",[api.addMenuItemToBottom]);return false});form.find(".customlinkdiv").bind("wp-add-menu-item",function(e,processMethod){api.addCustomLink(processMethod)});form.find(".posttypediv, .taxonomydiv").bind("wp-add-menu-item",function(e,processMethod){$(this).addSelectedToMenu(processMethod)})},attachThemeLocationsListeners:function(){var loc=$("#nav-menu-theme-locations"),params={action:"menu-locations-save","menu-locations":loc.find("select").serialize(),"menu-settings-column-nonce":$("#menu-settings-column-nonce").val()};loc.find("input[type=submit]").click(function(){loc.find(".waiting").show();$.post(ajaxurl,params,function(r){loc.find(".waiting").hide()});return false})},attachQuickSearchListeners:function(){var searchTimer;$(".quick-search").keypress(function(e){var t=$(this);if(13==e.which){api.updateQuickSearchResults(t);return false}if(searchTimer){clearTimeout(searchTimer)}searchTimer=setTimeout(function(){api.updateQuickSearchResults(t)},400)}).attr("autocomplete","off")},updateQuickSearchResults:function(input){var panel,params,minSearchLength=2,q=input.val();if(q.lengthfixedRight){fluid.animate({"margin-left":"+="+(fixedRight-right)+"px"},"fast")}else{if(left=fixedLeft)?true:false}});tabs.each(function(){tabsWidth+=$(this).outerWidth(true)});if(tabsWidth<=fixed.width()-fluid.css("padding-left").slice(0,-2)-fluid.css("padding-right").slice(0,-2)){return}fluid.css({"margin-right":(-1*tabsWidth)+"px",padding:0});arrowLeft=$('');arrowRight=$('');fixed.wrap('