<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13365] trunk/wp-admin/js: Increment the menu ID so the first menu works.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13365">13365</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2010-02-24 07:58:14 +0000 (Wed, 24 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Increment the menu ID so the first menu works. props junsuijin. fixes <a href="http://trac.wordpress.org/ticket/12339">#12339</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjscustomnavigationdynamicfunctionsdevjs">trunk/wp-admin/js/custom-navigation-dynamic-functions.dev.js</a></li>
<li><a href="#trunkwpadminjscustomnavigationdynamicfunctionsjs">trunk/wp-admin/js/custom-navigation-dynamic-functions.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjscustomnavigationdynamicfunctionsdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/custom-navigation-dynamic-functions.dev.js (13364 => 13365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/custom-navigation-dynamic-functions.dev.js        2010-02-24 07:52:48 UTC (rev 13364)
+++ trunk/wp-admin/js/custom-navigation-dynamic-functions.dev.js        2010-02-24 07:58:14 UTC (rev 13365)
</span><span class="lines">@@ -180,7 +180,7 @@
</span><span class="cx">                 inputdescription = '';
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        var count=document.getElementById('custom-nav').getElementsByTagName('li').length;
</del><ins>+        var count=document.getElementById('custom-nav').getElementsByTagName('li').length + 1;
</ins><span class="cx">
</span><span class="cx">         var randomnumber = count;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminjscustomnavigationdynamicfunctionsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/custom-navigation-dynamic-functions.js (13364 => 13365)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/custom-navigation-dynamic-functions.js        2010-02-24 07:52:48 UTC (rev 13364)
+++ trunk/wp-admin/js/custom-navigation-dynamic-functions.js        2010-02-24 07:58:14 UTC (rev 13365)
</span><span class="lines">@@ -1 +1 @@
</span><del>-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=jQuery("#title"+a).attr("value");itemURL=jQuery("#linkurl"+a).attr("value");itemAnchorTitle=jQuery("#anchortitle"+a).attr("value");itemNewWindow=jQuery("#newwindow"+a).attr("value");itemDesc=jQuery("#description"+a).attr("value");jQuery("#dialog-confirm").dialog("option","itemID",a);jQuery("#dialog-confirm").dialog("open");jQuery("#edittitle").attr("value",itemTitle);jQuery("#editlink").attr("value",itemURL);jQuery("#editanchortitle").attr("value",itemAnchorTitle);jQuery("#editnewwindow option[value='"+itemNewWindow+"']").attr("selected","selected");jQuery("#editdescription").attr("value",itemDesc)}function updatepostdata(){var a=0;jQuery("#custom-nav").find("li").each(function(c){c=c+1;var b=jQuery(this).attr("value");jQuery(this).find("#position"+b).attr("value",c);jQuery(this).attr("id","menu-"+c);jQuery(this).attr("value",c);jQuery(this).find("#dbid"+b).attr("name","dbid"+c);jQuery(this).find("#dbid"+b).attr("id","dbid"+c);jQuery(this).find("#postmenu"+b).attr("name","postmenu"+c);jQuery(this).find("#postmenu"+b).attr("id","postmenu"+c);var d=jQuery(this).find("#parent"+b).parent().parent().parent().attr("value");jQuery(this).find("#parent"+b).attr("name","parent"+c);jQuery(this).find("#parent"+b).attr("id","parent"+c);if(d){}else{d=0}jQuery(this).find("#parent"+b).attr("value",d);jQuery(this).find("#title"+b).attr("name","title"+c);jQuery(this).find("#title"+b).attr("id","title"+c);jQuery(this).find("#linkurl"+b).attr("name","linkurl"+c);jQuery(this).find("#linkurl"+b).attr("id","linkurl"+c);jQuery(this).find("#description"+b).attr("name","description"+c);jQuery(this).find("#description"+b).attr("id","description"+c);jQuery(this).find("#icon"+b).attr("name","icon"+c);jQuery(this).find("#icon"+b).attr("id","icon"+c);jQuery(this).find("#position"+b).attr("name","position"+c);jQuery(this).find("#position"+b).attr("id","position"+c);jQuery(this).find("#linktype"+b).attr("name","linktype"+c);jQuery(this).find("#linktype"+b).attr("id","linktype"+c);jQuery(this).find("#anchortitle"+b).attr("name","anchortitle"+c);jQuery(this).find("#anchortitle"+b).attr("id","anchortitle"+c);jQuery(this).find("#newwindow"+b).attr("name","newwindow"+c);jQuery(this).find("#newwindow"+b).attr("id","newwindow"+c);jQuery(this).find("dl > dt > span > #remove"+b).attr("value",c);jQuery(this).find("dl > dt > span > #remove"+b).attr("onClick","removeitem("+c+")");jQuery(this).find("dl > dt > span > #remove"+b).attr("id","remove"+c);jQuery("#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}}jQuery(".maintitle").after('<div id="message" class="updated fade below-h2"><p>Menu Item added!</p></div>');jQuery("#message").animate({opacity:1},2000).fadeOut(300,function(){jQuery(this).remove()});jQuery("#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>');jQuery("#menu-"+p+"").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery("#menu-"+p+" dl, #menu-"+p+" .dropzone").droppable({accept:"#"+p+", #custom-nav li",tolerance:"pointer",drop:function(x,w){var t=jQuery(this).parent();var y=!jQuery(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);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var t=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}});updatepostdata()};
</del><span class="cx">\ No newline at end of file
</span><ins>+function removeitem(o){var todelete=document.getElementById("menu-"+o);if(todelete){var parenttodelete=document.getElementById("menu-"+o).parentNode;throwaway_node=parenttodelete.removeChild(todelete)}updatepostdata()}function edititem(o){itemTitle=jQuery("#title"+o).attr("value");itemURL=jQuery("#linkurl"+o).attr("value");itemAnchorTitle=jQuery("#anchortitle"+o).attr("value");itemNewWindow=jQuery("#newwindow"+o).attr("value");itemDesc=jQuery("#description"+o).attr("value");jQuery("#dialog-confirm").dialog("option","itemID",o);jQuery("#dialog-confirm").dialog("open");jQuery("#edittitle").attr("value",itemTitle);jQuery("#editlink").attr("value",itemURL);jQuery("#editanchortitle").attr("value",itemAnchorTitle);jQuery("#editnewwindow option[value='"+itemNewWindow+"']").attr("selected","selected");jQuery("#editdescription").attr("value",itemDesc)}function updatepostdata(){var i=0;jQuery("#custom-nav").find("li").each(function(i){i=i+1;var j=jQuery(this).attr("value");jQuery(this).find("#position"+j).attr("value",i);jQuery(this).attr("id","menu-"+i);jQuery(this).attr("value",i);jQuery(this).find("#dbid"+j).attr("name","dbid"+i);jQuery(this).find("#dbid"+j).attr("id","dbid"+i);jQuery(this).find("#postmenu"+j).attr("name","postmenu"+i);jQuery(this).find("#postmenu"+j).attr("id","postmenu"+i);var p=jQuery(this).find("#parent"+j).parent().parent().parent().attr("value");jQuery(this).find("#parent"+j).attr("name","parent"+i);jQuery(this).find("#parent"+j).attr("id","parent"+i);if(p){}else{p=0}jQuery(this).find("#parent"+j).attr("value",p);jQuery(this).find("#title"+j).attr("name","title"+i);jQuery(this).find("#title"+j).attr("id","title"+i);jQuery(this).find("#linkurl"+j).attr("name","linkurl"+i);jQuery(this).find("#linkurl"+j).attr("id","linkurl"+i);jQuery(this).find("#description"+j).attr("name","description"+i);jQuery(this).find("#description"+j).attr("id","description"+i);jQuery(this).find("#icon"+j).attr("name","icon"+i);jQuery(this).find("#icon"+j).attr("id","icon"+i);jQuery(this).find("#position"+j).attr("name","position"+i);jQuery(this).find("#position"+j).attr("id","position"+i);jQuery(this).find("#linktype"+j).attr("name","linktype"+i);jQuery(this).find("#linktype"+j).attr("id","linktype"+i);jQuery(this).find("#anchortitle"+j).attr("name","anchortitle"+i);jQuery(this).find("#anchortitle"+j).attr("id","anchortitle"+i);jQuery(this).find("#newwindow"+j).attr("name","newwindow"+i);jQuery(this).find("#newwindow"+j).attr("id","newwindow"+i);jQuery(this).find("dl > dt > span > #remove"+j).attr("value",i);jQuery(this).find("dl > dt > span > #remove"+j).attr("onClick","removeitem("+i+")");jQuery(this).find("dl > dt > span > #remove"+j).attr("id","remove"+i);jQuery("#licount").attr("value",i)})}function appendToList(templatedir,additemtype,itemtext,itemurl,itemid,itemparentid,itemdescription){var inputvaluevarname="";var inputvaluevarurl="";var inputitemid="";var inputparentid="";var inputdescription="";var inputicon="";if(additemtype=="Custom"){inputvaluevarname=document.getElementById("custom_menu_item_name").value;inputvaluevarurl=document.getElementById("custom_menu_item_url").value;inputitemid="";inputparentid="";inputlinktype="custom";inputdescription=document.getElementById("custom_menu_item_description").value}else{if(additemtype=="Page"){inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid.toString();inputparentid="0";inputlinktype="page";inputdescription=htmlentities(itemdescription.toString())}else{if(additemtype=="Category"){inputvaluevarname=htmlentities(itemtext.toString());inputvaluevarurl=itemurl.toString();inputitemid=itemid.toString();inputparentid="0";inputlinktype="category";inputdescription=htmlentities(itemdescription.toString())}else{inputvaluevarname="";inputvaluevarname="";inputitemid="";inputparentid="";inputlinktype="custom";inputdescription=""}}}var count=document.getElementById("custom-nav").getElementsByTagName("li").length+1;var randomnumber=count;var validatetest=0;try{var test=document.getElementById("menu-"+randomnumber.toString()).value}catch(err){validatetest=1}while(validatetest==0){randomnumber=randomnumber+1;try{var test2=document.getElementById("menu-"+randomnumber.toString()).value}catch(err){validatetest=1}}jQuery(".maintitle").after('<div id="message" class="updated fade below-h2"><p>Menu Item added!</p></div>');jQuery("#message").animate({opacity:1},2000).fadeOut(300,function(){jQuery(this).remove()});jQuery("#custom-nav").append('<li id="menu-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="title">'+inputvaluevarname+'</span><span class="controls"><span class="type">'+additemtype+'</span><a id="edit'+randomnumber+'" onclick="edititem('+randomnumber+')" value="'+randomnumber+'"><img class="edit" alt="Edit Menu Item" title="Edit Menu Item" src="'+templatedir+'/wp-admin/images/ico-edit.png" /></a> <a id="remove'+randomnumber+'" onclick="removeitem('+randomnumber+')" value="'+randomnumber+'"><img class="remove" alt="Remove from Custom Menu" title="Remove from Custom Menu" src="'+templatedir+'/wp-admin/images/ico-close.png" /></a> <a href="'+inputvaluevarurl+'" target="_blank"><img alt="View Custom Link" title="View Custom Link" src="'+templatedir+'/wp-admin/images/ico-viewpage.png" /></a></span></dt></dl><a class="hide" href="'+inputvaluevarurl+'">'+inputvaluevarname+'</a><input type="hidden" name="postmenu'+randomnumber+'" id="postmenu'+randomnumber+'" value="'+inputitemid+'" /><input type="hidden" name="parent'+randomnumber+'" id="parent'+randomnumber+'" value="'+inputparentid+'" /><input type="hidden" name="title'+randomnumber+'" id="title'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="linkurl'+randomnumber+'" id="linkurl'+randomnumber+'" value="'+inputvaluevarurl+'" /><input type="hidden" name="description'+randomnumber+'" id="description'+randomnumber+'" value="'+inputdescription+'" /><input type="hidden" name="icon'+randomnumber+'" id="icon'+randomnumber+'" value="'+inputicon+'" /><input type="hidden" name="position'+randomnumber+'" id="position'+randomnumber+'" value="'+randomnumber+'" /><input type="hidden" name="linktype'+randomnumber+'" id="linktype'+randomnumber+'" value="'+inputlinktype+'" /><input type="hidden" name="anchortitle'+randomnumber+'" id="anchortitle'+randomnumber+'" value="'+inputvaluevarname+'" /><input type="hidden" name="newwindow'+randomnumber+'" id="newwindow'+randomnumber+'" value="0" /></li>');jQuery("#menu-"+randomnumber+"").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});jQuery("#menu-"+randomnumber+" dl, #menu-"+randomnumber+" .dropzone").droppable({accept:"#"+randomnumber+", #custom-nav li",tolerance:"pointer",drop:function(e,ui){var li=jQuery(this).parent();var child=!jQuery(this).hasClass("dropzone");if(child&&li.children("ul").length==0){li.append("<ul/>")}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style")},over:function(){if(jQuery(this).attr("class")=="dropzone ui-droppable"){jQuery(this).parent().find("div:first").css("background","none").css("height","50px")}else{if(jQuery(this).attr("class")=="ui-droppable"){jQuery(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}var parentid=jQuery(this).parent().attr("id")},out:function(){jQuery(this).parent().find("dt").removeAttr("style");jQuery(this).parent().find("div:first").removeAttr("style");jQuery(this).filter(".dropzone").css({borderColor:""})}});updatepostdata()};
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>