mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-06 02:41:27 +01:00
4d203a02c6
git-svn-id: http://svn.automattic.com/wordpress/trunk@13257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
6.1 KiB
JavaScript
1 line
6.1 KiB
JavaScript
function removeitem(c){var b=document.getElementById("menu-"+c);if(b){var a=document.getElementById("menu-"+c).parentNode;throwaway_node=a.removeChild(b)}updatepostdata()}function edititem(a){itemTitle=$("#title"+a).attr("value");itemURL=$("#linkurl"+a).attr("value");itemAnchorTitle=$("#anchortitle"+a).attr("value");itemNewWindow=$("#newwindow"+a).attr("value");itemDesc=$("#description"+a).attr("value");$("#dialog-confirm").dialog("option","itemID",a);$("#dialog-confirm").dialog("open");$("#edittitle").attr("value",itemTitle);$("#editlink").attr("value",itemURL);$("#editanchortitle").attr("value",itemAnchorTitle);$("#editnewwindow option[value='"+itemNewWindow+"']").attr("selected","selected");$("#editdescription").attr("value",itemDesc)}function updatepostdata(){var a=0;$("#custom-nav").find("li").each(function(c){c=c+1;var b=$(this).attr("value");$(this).find("#position"+b).attr("value",c);$(this).attr("id","menu-"+c);$(this).attr("value",c);$(this).find("#dbid"+b).attr("name","dbid"+c);$(this).find("#dbid"+b).attr("id","dbid"+c);$(this).find("#postmenu"+b).attr("name","postmenu"+c);$(this).find("#postmenu"+b).attr("id","postmenu"+c);var d=$(this).find("#parent"+b).parent().parent().parent().attr("value");$(this).find("#parent"+b).attr("name","parent"+c);$(this).find("#parent"+b).attr("id","parent"+c);if(d){}else{d=0}$(this).find("#parent"+b).attr("value",d);$(this).find("#title"+b).attr("name","title"+c);$(this).find("#title"+b).attr("id","title"+c);$(this).find("#linkurl"+b).attr("name","linkurl"+c);$(this).find("#linkurl"+b).attr("id","linkurl"+c);$(this).find("#description"+b).attr("name","description"+c);$(this).find("#description"+b).attr("id","description"+c);$(this).find("#icon"+b).attr("name","icon"+c);$(this).find("#icon"+b).attr("id","icon"+c);$(this).find("#position"+b).attr("name","position"+c);$(this).find("#position"+b).attr("id","position"+c);$(this).find("#linktype"+b).attr("name","linktype"+c);$(this).find("#linktype"+b).attr("id","linktype"+c);$(this).find("#anchortitle"+b).attr("name","anchortitle"+c);$(this).find("#anchortitle"+b).attr("id","anchortitle"+c);$(this).find("#newwindow"+b).attr("name","newwindow"+c);$(this).find("#newwindow"+b).attr("id","newwindow"+c);$(this).find("dl > dt > span > #remove"+b).attr("value",c);$(this).find("dl > dt > span > #remove"+b).attr("onClick","removeitem("+c+")");$(this).find("dl > dt > span > #remove"+b).attr("id","remove"+c);$("#licount").attr("value",c)})}function appendToList(b,s,d,n,h,l,e){var k="";var c="";var r="";var o="";var i="";var a="";if(s=="Custom"){k=document.getElementById("custom_menu_item_name").value;c=document.getElementById("custom_menu_item_url").value;r="";o="";inputlinktype="custom";i=document.getElementById("custom_menu_item_description").value}else{if(s=="Page"){k=htmlentities(d.toString());c=n.toString();r=h.toString();o="0";inputlinktype="page";i=htmlentities(e.toString())}else{if(s=="Category"){k=htmlentities(d.toString());c=n.toString();r=h.toString();o="0";inputlinktype="category";i=htmlentities(e.toString())}else{k="";k="";r="";o="";inputlinktype="custom";i=""}}}var g=document.getElementById("custom-nav").getElementsByTagName("li").length;var p=g;var m=0;try{var q=document.getElementById("menu-"+p.toString()).value}catch(f){m=1}while(m==0){p=p+1;try{var j=document.getElementById("menu-"+p.toString()).value}catch(f){m=1}}$(".maintitle").after('<div id="message" class="updated fade below-h2"><p>Menu Item added!</p></div>');$("#message").animate({opacity:1},2000).fadeOut(300,function(){$(this).remove()});$("#custom-nav").append('<li id="menu-'+p+'" value="'+p+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="title">'+k+'</span><span class="controls"><span class="type">'+s+'</span><a id="edit'+p+'" onclick="edititem('+p+')" value="'+p+'"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="'+b+'/wp-admin/images/ico-edit.png" /></a> <a id="remove'+p+'" onclick="removeitem('+p+')" value="'+p+'"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="'+b+'/wp-admin/images/ico-close.png" /></a> <a href="'+c+'" target="_blank"><img alt="View Custom Link" title="View Custom Link" src="'+b+'/wp-admin/images/ico-viewpage.png" /></a></span></dt></dl><a class="hide" href="'+c+'">'+k+'</a><input type="hidden" name="postmenu'+p+'" id="postmenu'+p+'" value="'+r+'" /><input type="hidden" name="parent'+p+'" id="parent'+p+'" value="'+o+'" /><input type="hidden" name="title'+p+'" id="title'+p+'" value="'+k+'" /><input type="hidden" name="linkurl'+p+'" id="linkurl'+p+'" value="'+c+'" /><input type="hidden" name="description'+p+'" id="description'+p+'" value="'+i+'" /><input type="hidden" name="icon'+p+'" id="icon'+p+'" value="'+a+'" /><input type="hidden" name="position'+p+'" id="position'+p+'" value="'+p+'" /><input type="hidden" name="linktype'+p+'" id="linktype'+p+'" value="'+inputlinktype+'" /><input type="hidden" name="anchortitle'+p+'" id="anchortitle'+p+'" value="'+k+'" /><input type="hidden" name="newwindow'+p+'" id="newwindow'+p+'" value="0" /></li>');$("#menu-"+p+"").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});$("#menu-"+p+" dl, #menu-"+p+" .dropzone").droppable({accept:"#"+p+", #custom-nav li",tolerance:"pointer",drop:function(x,w){var t=$(this).parent();var y=!$(this).hasClass("dropzone");if(y&&t.children("ul").length==0){t.append("<ul/>")}if(y){t.children("ul").append(w.draggable)}else{t.before(w.draggable)}t.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var v=w.draggable.attr("value");var u=t.attr("value");t.find("#menu-"+v).find("#parent"+v).val(u);$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style")},over:function(){if($(this).attr("class")=="dropzone ui-droppable"){$(this).parent().find("div:first").css("background","none").css("height","50px")}else{if($(this).attr("class")=="ui-droppable"){$(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var t=$(this).parent().attr("id")},out:function(){$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style");$(this).filter(".dropzone").css({borderColor:""})}});updatepostdata()}; |