<!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>[13803] trunk/wp-admin/js:
  Prevent the nav menu walker from walking in circles.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13803">13803</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-03-22 22:26:27 +0000 (Mon, 22 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Prevent the nav menu walker from walking in circles. Don't allow an object from being a child of itself; if the functionality is desired, a workaround would be custom links. see <a href="http://trac.wordpress.org/ticket/11817">#11817</a>, see <a href="http://trac.wordpress.org/ticket/12566">#12566</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjsnavmenudevjs">trunk/wp-admin/js/nav-menu.dev.js</a></li>
<li><a href="#trunkwpadminjsnavmenujs">trunk/wp-admin/js/nav-menu.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjsnavmenudevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu.dev.js (13802 => 13803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.dev.js        2010-03-22 19:56:16 UTC (rev 13802)
+++ trunk/wp-admin/js/nav-menu.dev.js        2010-03-22 22:26:27 UTC (rev 13803)
</span><span class="lines">@@ -196,6 +196,16 @@
</span><span class="cx">                                         var li = $(this).parent();
</span><span class="cx">                                         var child = !$(this).hasClass('dropzone');
</span><span class="cx"> 
</span><ins>+                                        var parent_id = li.children('input[name=menu-item-object-id[]]').val(); 
+                                        var child_id = ui.draggable.children('input[name=menu-item-object-id[]]').val(); 

+                                        // An item cannot be a child of itself. Use a custom link for the effect.
+                                        if ( parent_id == child_id ) {
+                                                ui.draggable.find('dt').animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ) } } );
+                                                $(this).parent().find('dt').removeAttr('style');
+                                                return;
+                                        };

</ins><span class="cx">                                         // Append UL to first child
</span><span class="cx">                                         if ( child &amp;&amp; li.children('ul').length == 0 ) {
</span><span class="cx">                                                 li.append( '&lt;ul class=&quot;sub-menu&quot; /&gt;' );
</span></span></pre></div>
<a id="trunkwpadminjsnavmenujs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu.js (13802 => 13803)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.js        2010-03-22 19:56:16 UTC (rev 13802)
+++ trunk/wp-admin/js/nav-menu.js        2010-03-22 22:26:27 UTC (rev 13803)
</span><span class="lines">@@ -1 +1 @@
</span><del>-var wpNavMenu;(function(a){wpNavMenu={init:function(){wpNavMenu.initial_meta_boxes();wpNavMenu.drag_and_drop();a(&quot;#update-nav-menu .deletion&quot;).click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a(&quot;#update-nav-menu&quot;).submit(function(){wpNavMenu.update_post_data()});a(&quot;#create-menu-name&quot;).keypress(function(b){if(13==b.keyCode){a(&quot;#create-menu-button&quot;).click();return false}});a(&quot;#custom-menu-item-url, #custom-menu-item-name&quot;).keypress(function(b){if(13==b.keyCode){a(&quot;#add-custom-links a.button&quot;).click();return false}}).focus(function(){if(a(this).val()==a(this).attr(&quot;defaultValue&quot;)&amp;&amp;a(this).attr(&quot;id&quot;)!=&quot;custom-menu-item-url&quot;){a(this).val(&quot;&quot;)}}).blur(function(){if(a(this).val()==&quot;&quot;){a(this).val(a(this).attr(&quot;defaultValue&quot;))}});a(&quot;#create-menu-name&quot;).focus(function(){if(a(this).val()==a(this).attr(&quot;defaultValue&quot;)){a(this).val(&quot;&quot;)}}).blur(function(){if(a(this).val()==&quot;&quot;){a(this).val(a(this).attr(&quot;defaultValue&quot;))}});a(&quot;.if-js-closed&quot;).removeClass(&quot;if-js-closed&quot;).addClass(&quot;closed&quot;);postboxes.add_postbox_toggles(&quot;nav-menus&quot;);a(&quot;.quick-search&quot;).click(function(){a(this).attr(&quot;value&quot;,&quot;&quot;)});a(&quot;.quick-search-submit&quot;).click(function(){a(this).siblings(&quot;.quick-search&quot;).search()});a(&quot;#menu-container .item-edit&quot;).click(function(){wpNavMenu.edit_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#menu-container .item-delete&quot;).click(function(){wpNavMenu.remove_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#update-menu-item&quot;).click(function(){wpNavMenu.update_menu_item();tb_remove()});a(&quot;#cancel-save&quot;).click(function(){tb_remove()});a(&quot;.show-all&quot;).click(function(b){a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).find(&quot;li&quot;).css(&quot;display&quot;,&quot;block&quot;);a(b.currentTarget).hide();a(b.currentTarget).siblings(&quot;.hide-all&quot;).show()});a(&quot;.hide-all&quot;).click(function(b){a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;none&quot;);a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).find(&quot;li&quot;).css(&quot;display&quot;,&quot;none&quot;);a(b.currentTarget).hide();a(b.currentTarget).siblings(&quot;.show-all&quot;).show()});a(&quot;.add-to-menu&quot;).click(function(b){wpNavMenu.add_checked_items_to_menu(b.currentTarget)});a(&quot;#add-custom-links .add-to-menu a&quot;).click(function(b){if(a(&quot;#custom-menu-item-url&quot;).val()==a(&quot;#custom-menu-item-url&quot;).attr(&quot;defaultValue&quot;)){return}wpNavMenu.add_custom_link(a(&quot;#custom-menu-item-name&quot;).val(),a(&quot;#custom-menu-item-url&quot;).val());a(&quot;#custom-menu-item-name&quot;).val(a(&quot;#custom-menu-item-name&quot;).attr(&quot;defaultValue&quot;));a(&quot;#custom-menu-item-url&quot;).val(a(&quot;#custom-menu-item-url&quot;).attr(&quot;defaultValue&quot;)).focus()})},add_custom_link:function(c,b){var d={action:&quot;save-custom-link&quot;,link_name:c,link_url:b};a.post(ajaxurl,d,function(e){if(&quot;-1&quot;==e){return}wpNavMenu.add_to_menu(e,e,&quot;custom&quot;,&quot;custom&quot;,navMenuL10n.custom,0,c,b,&quot;&quot;,&quot;&quot;,&quot;_self&quot;,&quot;&quot;,&quot;&quot;)},&quot;json&quot;)},initial_meta_boxes:function(){var c=a(&quot;#hidden-metaboxes&quot;).val().split(&quot;,&quot;);if(&quot;&quot;!=c){for(var b=0;b&lt;c.length;b++){a(&quot;#&quot;+c[b]).attr(&quot;style&quot;,&quot;display: none;&quot;);a(&quot;#&quot;+c[b]+&quot;-hide&quot;).attr(&quot;checked&quot;,false)}}},drag_and_drop:function(){a(&quot;.menu li&quot;).each(function(){if(!a(this).children(&quot;.dropzone&quot;).attr(&quot;class&quot;)){a(this).prepend('&lt;div class=&quot;dropzone&quot;&gt;&lt;/div&gt;')}});a(&quot;.menu li&quot;).draggable({handle:&quot; &gt; dl&quot;,opacity:0.8,addClasses:false,helper:&quot;clone&quot;,zIndex:100});a(&quot;.menu li dl, .menu li .dropzone&quot;).droppable({accept:&quot;.menu li&quot;,tolerance:&quot;pointer&quot;,drop:function(g,f){var b=a(this).parent();var h=!a(this).hasClass(&quot;dropzone&quot;);if(h&amp;&amp;b.children(&quot;ul&quot;).length==0){b.append('&lt;ul class=&quot;sub-menu&quot; /&gt;')}if(h){b.children(&quot;ul&quot;).append(f.draggable)}else{b.before(f.draggable)}b.find(&quot;dl,.dropzone&quot;).css({backgroundColor:&quot;&quot;,borderColor:&quot;&quot;});var d=f.draggable.attr(&quot;value&quot;);var c=b.attr(&quot;value&quot;);b.find(&quot;#menu-&quot;+d).find(&quot;#parent&quot;+d).val(c);a(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);a(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;)},over:function(b){if(a(this).attr(&quot;class&quot;)==&quot;dropzone ui-droppable&quot;){a(this).parent().find(&quot;div:first&quot;).css({background:&quot;#f5f5f5&quot;,border:&quot;1px dashed #bbb&quot;,margin:&quot;10px 0px&quot;,height:&quot;40px&quot;})}else{if(a(this).attr(&quot;class&quot;)==&quot;ui-droppable&quot;){a(this).parent().find(&quot;dt:first&quot;).css(&quot;background&quot;,&quot;#d8d8d8&quot;)}else{}}},out:function(){a(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);a(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;);a(this).filter(&quot;.dropzone&quot;).css({borderColor:&quot;&quot;})}})},update_post_data:function(){var b=0;a(&quot;.menu li&quot;).each(function(){b=b+1;var d=a(this).attr(&quot;value&quot;);var e=a(this).children(&quot;input[name=menu-item-db-id[]]&quot;).val();a(this).attr(&quot;value&quot;,b);a(this).children(&quot;input[name=menu-item-position[]]&quot;).attr(&quot;value&quot;,b);var c=a(this).parent(&quot;.sub-menu&quot;).siblings(&quot;input[name=menu-item-object-id[]]&quot;).val();if(undefined==c){c=0}a(this).children(&quot;input[name=menu-item-parent-id[]]&quot;).attr(&quot;value&quot;,c);a(&quot;#li-count&quot;).attr(&quot;value&quot;,b)})},autocomplete:function(b){a(&quot;#add-&quot;+b+&quot; .quick-search&quot;).autocomplete(a(&quot;#add-&quot;+b+&quot; .autocomplete&quot;).val().split(&quot;|&quot;));a(&quot;#add-&quot;+b+&quot; .quick-search&quot;).result(function(c,e,d){a(&quot;#add-&quot;+b+&quot; .list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(&quot;#add-&quot;+b+&quot; .list-wrap li:contains('&quot;+e+&quot;')&quot;).css(&quot;display&quot;,&quot;block&quot;);a(&quot;#add-&quot;+b+&quot; .show-all&quot;).hide();a(&quot;#add-&quot;+b+&quot; .hide-all&quot;).show()})},edit_menu_item:function(b){var g=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-type[]]&quot;).val();var c=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-title[]]&quot;).val();var h=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-url[]]&quot;).val();var d=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-attr-title[]]&quot;).val();var e=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-target[]]&quot;).val();var i=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-description[]]&quot;).val();var f=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-classes[]]&quot;).val();var j=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-xfn[]]&quot;).val();if(&quot;custom&quot;!=g){a(&quot;#edit-menu-item-url&quot;).attr(&quot;disabled&quot;,&quot;disabled&quot;)}a(&quot;#edit-menu-item-id&quot;).val(b);a(&quot;#edit-menu-item-title&quot;).val(c);a(&quot;#edit-menu-item-url&quot;).val(h);a(&quot;#edit-menu-item-attr-title&quot;).val(d);a(&quot;#edit-menu-item-target&quot;).val(e);a(&quot;#edit-menu-item-target option[value='&quot;+e+&quot;']&quot;).attr(&quot;selected&quot;,&quot;selected&quot;);a(&quot;#edit-menu-item-description&quot;).val(i);a(&quot;#edit-menu-item-classes&quot;).val(f);a(&quot;#edit-menu-item-xfn&quot;).val(j)},update_menu_item:function(){var i=a(&quot;#edit-menu-item-id&quot;).val();var g=a(&quot;#edit-menu-item-title&quot;).val();var c=a(&quot;#edit-menu-item-url&quot;).val();var h=a(&quot;#edit-menu-item-attr-title&quot;).val();var e=a(&quot;#edit-menu-item-target&quot;).val();var d=a(&quot;#edit-menu-item-description&quot;).val();var b=a(&quot;#edit-menu-item-classes&quot;).val();var f=a(&quot;#edit-menu-item-xfn&quot;).val();a(&quot;.menu #menu-item-&quot;+i).find(&quot;span.item-title:first&quot;).html(g);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-title[]]&quot;).val(g);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-url[]]&quot;).val(c);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-attr-title[]]&quot;).val(h);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-target[]]&quot;).val(e);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-description[]]&quot;).val(d);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-classes[]]&quot;).val(b);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-xfn[]]&quot;).val(f);a(&quot;.menu #menu-item-&quot;+i+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})},remove_menu_item:function(c){var b=a(&quot;#menu-item-&quot;+c);if(b){a(b).find(&quot;dt&quot;).each(function(){a(this).animate({backgroundColor:&quot;#FF3333&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).parent().parent().remove()}})})}},add_to_menu:function(b,m,c,h,p,n,d,o,j,g,f,e,k){var l=a(&quot;.menu li&quot;).length+1;var i=wpNavMenu.get_hidden_inputs(l,b,m,c,h,n,d,o,j,g,f,e,k);a(&quot;.menu&quot;).append('&lt;li id=&quot;menu-item-'+l+'&quot; value=&quot;'+l+'&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;'+d+'&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;'+p+'&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'+l+'&quot; value=&quot;'+l+'&quot; onclick=&quot;wpNavMenu.edit_menu_item('+l+');&quot; title=&quot;'+navMenuL10n.thickbox+'&quot; href=&quot;#TB_inline?height=540&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'+navMenuL10n.edit+'&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete'+l+'&quot; value=&quot;'+l+'&quot; onclick=&quot;wpNavMenu.remove_menu_item('+l+');&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;'+i+&quot;&lt;/li&gt;&quot;);a(&quot;.menu #menu-item-&quot;+l+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}});wpNavMenu.drag_and_drop();tb_init(&quot;a.thickbox, area.thickbox, input.thickbox&quot;)},add_checked_items_to_menu:function(c){var b=a(c).parent().siblings(&quot;.list-wrap&quot;).find(&quot;:checked&quot;);if(0==b.length){return false}a(b).each(function(){var j=a(this).parent().siblings(&quot;.menu-item-type&quot;).val();if(&quot;custom&quot;==j){var g=a(this).parent().siblings(&quot;.menu-item-attr-title&quot;).val();var h=a(this).parent().siblings(&quot;.menu-item-target&quot;).val();var i=a(this).parent().siblings(&quot;.menu-item-classes&quot;).val();var l=a(this).parent().siblings(&quot;.menu-item-xfn&quot;).val()}else{var g=&quot;&quot;;var h=&quot;_self&quot;;var i=&quot;&quot;;var l=&quot;&quot;}var d=a(this).parent().siblings(&quot;.menu-item-db-id&quot;).val();var m=a(this).parent().siblings(&quot;.menu-item-object-id&quot;).val();var e=a(this).parent().siblings(&quot;.menu-item-object&quot;).val();var p=a(this).parent().siblings(&quot;.menu-item-append&quot;).val();var n=a(this).parent().siblings(&quot;.menu-item-parent-id&quot;).val();var f=a(this).parent().siblings(&quot;.menu-item-title&quot;).val();var o=a(this).parent().siblings(&quot;.menu-item-url&quot;).val();var k=a(this).parent().siblings(&quot;.menu-item-description&quot;).val();if(undefined==k){k=&quot;&quot;}if(undefined==g){g=&quot;&quot;}wpNavMenu.add_to_menu(d,m,e,j,p,n,f,o,k,g,h,i,l);a(this).attr(&quot;checked&quot;,false)})},get_hidden_inputs:function(l,b,m,c,h,n,d,o,j,g,f,e,k){var i=&quot;&quot;;i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-db-id[]&quot; value=&quot;'+b+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object-id[]&quot; value=&quot;'+m+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object[]&quot; value=&quot;'+c+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-type[]&quot; value=&quot;'+h+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-parent-id[]&quot; value=&quot;'+n+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-position[]&quot; value=&quot;'+l+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-title[]&quot; value=&quot;'+d+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-attr-title[]&quot; value=&quot;'+g+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-url[]&quot; value=&quot;'+o+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-target[]&quot; value=&quot;'+f+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-description[]&quot; value=&quot;'+j+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-classes[]&quot; value=&quot;'+e+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-xfn[]&quot; value=&quot;'+k+'&quot; /&gt;';return i}};a(document).ready(function(b){wpNavMenu.init()})})(jQuery);
</del><span class="cx">\ No newline at end of file
</span><ins>+var wpNavMenu;(function(a){wpNavMenu={init:function(){wpNavMenu.initial_meta_boxes();wpNavMenu.drag_and_drop();a(&quot;#update-nav-menu .deletion&quot;).click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a(&quot;#update-nav-menu&quot;).submit(function(){wpNavMenu.update_post_data()});a(&quot;#create-menu-name&quot;).keypress(function(b){if(13==b.keyCode){a(&quot;#create-menu-button&quot;).click();return false}});a(&quot;#custom-menu-item-url, #custom-menu-item-name&quot;).keypress(function(b){if(13==b.keyCode){a(&quot;#add-custom-links a.button&quot;).click();return false}}).focus(function(){if(a(this).val()==a(this).attr(&quot;defaultValue&quot;)&amp;&amp;a(this).attr(&quot;id&quot;)!=&quot;custom-menu-item-url&quot;){a(this).val(&quot;&quot;)}}).blur(function(){if(a(this).val()==&quot;&quot;){a(this).val(a(this).attr(&quot;defaultValue&quot;))}});a(&quot;#create-menu-name&quot;).focus(function(){if(a(this).val()==a(this).attr(&quot;defaultValue&quot;)){a(this).val(&quot;&quot;)}}).blur(function(){if(a(this).val()==&quot;&quot;){a(this).val(a(this).attr(&quot;defaultValue&quot;))}});a(&quot;.if-js-closed&quot;).removeClass(&quot;if-js-closed&quot;).addClass(&quot;closed&quot;);postboxes.add_postbox_toggles(&quot;nav-menus&quot;);a(&quot;.quick-search&quot;).click(function(){a(this).attr(&quot;value&quot;,&quot;&quot;)});a(&quot;.quick-search-submit&quot;).click(function(){a(this).siblings(&quot;.quick-search&quot;).search()});a(&quot;#menu-container .item-edit&quot;).click(function(){wpNavMenu.edit_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#menu-container .item-delete&quot;).click(function(){wpNavMenu.remove_menu_item(a(this).attr(&quot;value&quot;))});a(&quot;#update-menu-item&quot;).click(function(){wpNavMenu.update_menu_item();tb_remove()});a(&quot;#cancel-save&quot;).click(function(){tb_remove()});a(&quot;.show-all&quot;).click(function(b){a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).find(&quot;li&quot;).css(&quot;display&quot;,&quot;block&quot;);a(b.currentTarget).hide();a(b.currentTarget).siblings(&quot;.hide-all&quot;).show()});a(&quot;.hide-all&quot;).click(function(b){a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).css(&quot;display&quot;,&quot;none&quot;);a(b.currentTarget).parent().parent().siblings(&quot;.list-wrap&quot;).find(&quot;li&quot;).css(&quot;display&quot;,&quot;none&quot;);a(b.currentTarget).hide();a(b.currentTarget).siblings(&quot;.show-all&quot;).show()});a(&quot;.add-to-menu&quot;).click(function(b){wpNavMenu.add_checked_items_to_menu(b.currentTarget)});a(&quot;#add-custom-links .add-to-menu a&quot;).click(function(b){if(a(&quot;#custom-menu-item-url&quot;).val()==a(&quot;#custom-menu-item-url&quot;).attr(&quot;defaultValue&quot;)){return}wpNavMenu.add_custom_link(a(&quot;#custom-menu-item-name&quot;).val(),a(&quot;#custom-menu-item-url&quot;).val());a(&quot;#custom-menu-item-name&quot;).val(a(&quot;#custom-menu-item-name&quot;).attr(&quot;defaultValue&quot;));a(&quot;#custom-menu-item-url&quot;).val(a(&quot;#custom-menu-item-url&quot;).attr(&quot;defaultValue&quot;)).focus()})},add_custom_link:function(c,b){var d={action:&quot;save-custom-link&quot;,link_name:c,link_url:b};a.post(ajaxurl,d,function(e){if(&quot;-1&quot;==e){return}wpNavMenu.add_to_menu(e,e,&quot;custom&quot;,&quot;custom&quot;,navMenuL10n.custom,0,c,b,&quot;&quot;,&quot;&quot;,&quot;_self&quot;,&quot;&quot;,&quot;&quot;)},&quot;json&quot;)},initial_meta_boxes:function(){var c=a(&quot;#hidden-metaboxes&quot;).val().split(&quot;,&quot;);if(&quot;&quot;!=c){for(var b=0;b&lt;c.length;b++){a(&quot;#&quot;+c[b]).attr(&quot;style&quot;,&quot;display: none;&quot;);a(&quot;#&quot;+c[b]+&quot;-hide&quot;).attr(&quot;checked&quot;,false)}}},drag_and_drop:function(){a(&quot;.menu li&quot;).each(function(){if(!a(this).children(&quot;.dropzone&quot;).attr(&quot;class&quot;)){a(this).prepend('&lt;div class=&quot;dropzone&quot;&gt;&lt;/div&gt;')}});a(&quot;.menu li&quot;).draggable({handle:&quot; &gt; dl&quot;,opacity:0.8,addClasses:false,helper:&quot;clone&quot;,zIndex:100});a(&quot;.menu li dl, .menu li .dropzone&quot;).droppable({accept:&quot;.menu li&quot;,tolerance:&quot;pointer&quot;,drop:function(h,g){var b=a(this).parent();var j=!a(this).hasClass(&quot;dropzone&quot;);var f=b.children(&quot;input[name=menu-item-object-id[]]&quot;).val();var i=g.draggable.children(&quot;input[name=menu-item-object-id[]]&quot;).val();if(f==i){g.draggable.find(&quot;dt&quot;).animate({backgroundColor:&quot;#FF3333&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}});a(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);return}if(j&amp;&amp;b.children(&quot;ul&quot;).length==0){b.append('&lt;ul class=&quot;sub-menu&quot; /&gt;')}if(j){b.children(&quot;ul&quot;).append(g.draggable)}else{b.before(g.draggable)}b.find(&quot;dl,.dropzone&quot;).css({backgroundColor:&quot;&quot;,borderColor:&quot;&quot;});var d=g.draggable.attr(&quot;value&quot;);var c=b.attr(&quot;value&quot;);b.find(&quot;#menu-&quot;+d).find(&quot;#parent&quot;+d).val(c);a(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);a(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;)},over:function(b){if(a(this).attr(&quot;class&quot;)==&quot;dropzone ui-droppable&quot;){a(this).parent().find(&quot;div:first&quot;).css({background:&quot;#f5f5f5&quot;,border:&quot;1px dashed #bbb&quot;,margin:&quot;10px 0px&quot;,height:&quot;40px&quot;})}else{if(a(this).attr(&quot;class&quot;)==&quot;ui-droppable&quot;){a(this).parent().find(&quot;dt:first&quot;).css(&quot;background&quot;,&quot;#d8d8d8&quot;)}else{}}},out:function(){a(this).parent().find(&quot;dt&quot;).removeAttr(&quot;style&quot;);a(this).parent().find(&quot;div:first&quot;).removeAttr(&quot;style&quot;);a(this).filter(&quot;.dropzone&quot;).css({borderColor:&quot;&quot;})}})},update_post_data:function(){var b=0;a(&quot;.menu li&quot;).each(function(){b=b+1;var d=a(this).attr(&quot;value&quot;);var e=a(this).children(&quot;input[name=menu-item-db-id[]]&quot;).val();a(this).attr(&quot;value&quot;,b);a(this).children(&quot;input[name=menu-item-position[]]&quot;).attr(&quot;value&quot;,b);var c=a(this).parent(&quot;.sub-menu&quot;).siblings(&quot;input[name=menu-item-object-id[]]&quot;).val();if(undefined==c){c=0}a(this).children(&quot;input[name=menu-item-parent-id[]]&quot;).attr(&quot;value&quot;,c);a(&quot;#li-count&quot;).attr(&quot;value&quot;,b)})},autocomplete:function(b){a(&quot;#add-&quot;+b+&quot; .quick-search&quot;).autocomplete(a(&quot;#add-&quot;+b+&quot; .autocomplete&quot;).val().split(&quot;|&quot;));a(&quot;#add-&quot;+b+&quot; .quick-search&quot;).result(function(c,e,d){a(&quot;#add-&quot;+b+&quot; .list-wrap&quot;).css(&quot;display&quot;,&quot;block&quot;);a(&quot;#add-&quot;+b+&quot; .list-wrap li:contains('&quot;+e+&quot;')&quot;).css(&quot;display&quot;,&quot;block&quot;);a(&quot;#add-&quot;+b+&quot; .show-all&quot;).hide();a(&quot;#add-&quot;+b+&quot; .hide-all&quot;).show()})},edit_menu_item:function(b){var g=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-type[]]&quot;).val();var c=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-title[]]&quot;).val();var h=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-url[]]&quot;).val();var d=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-attr-title[]]&quot;).val();var e=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-target[]]&quot;).val();var i=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-description[]]&quot;).val();var f=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-classes[]]&quot;).val();var j=a(&quot;#menu-item-&quot;+b).children(&quot;input[name=menu-item-xfn[]]&quot;).val();if(&quot;custom&quot;!=g){a(&quot;#edit-menu-item-url&quot;).attr(&quot;disabled&quot;,&quot;disabled&quot;)}a(&quot;#edit-menu-item-id&quot;).val(b);a(&quot;#edit-menu-item-title&quot;).val(c);a(&quot;#edit-menu-item-url&quot;).val(h);a(&quot;#edit-menu-item-attr-title&quot;).val(d);a(&quot;#edit-menu-item-target&quot;).val(e);a(&quot;#edit-menu-item-target option[value='&quot;+e+&quot;']&quot;).attr(&quot;selected&quot;,&quot;selected&quot;);a(&quot;#edit-menu-item-description&quot;).val(i);a(&quot;#edit-menu-item-classes&quot;).val(f);a(&quot;#edit-menu-item-xfn&quot;).val(j)},update_menu_item:function(){var i=a(&quot;#edit-menu-item-id&quot;).val();var g=a(&quot;#edit-menu-item-title&quot;).val();var c=a(&quot;#edit-menu-item-url&quot;).val();var h=a(&quot;#edit-menu-item-attr-title&quot;).val();var e=a(&quot;#edit-menu-item-target&quot;).val();var d=a(&quot;#edit-menu-item-description&quot;).val();var b=a(&quot;#edit-menu-item-classes&quot;).val();var f=a(&quot;#edit-menu-item-xfn&quot;).val();a(&quot;.menu #menu-item-&quot;+i).find(&quot;span.item-title:first&quot;).html(g);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-title[]]&quot;).val(g);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-url[]]&quot;).val(c);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-attr-title[]]&quot;).val(h);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-target[]]&quot;).val(e);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-description[]]&quot;).val(d);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-classes[]]&quot;).val(b);a(&quot;#menu-item-&quot;+i).children(&quot;input[name=menu-item-xfn[]]&quot;).val(f);a(&quot;.menu #menu-item-&quot;+i+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}})},remove_menu_item:function(c){var b=a(&quot;#menu-item-&quot;+c);if(b){a(b).find(&quot;dt&quot;).each(function(){a(this).animate({backgroundColor:&quot;#FF3333&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).parent().parent().remove()}})})}},add_to_menu:function(b,m,c,h,p,n,d,o,j,g,f,e,k){var l=a(&quot;.menu li&quot;).length+1;var i=wpNavMenu.get_hidden_inputs(l,b,m,c,h,n,d,o,j,g,f,e,k);a(&quot;.menu&quot;).append('&lt;li id=&quot;menu-item-'+l+'&quot; value=&quot;'+l+'&quot;&gt;&lt;div class=&quot;dropzone ui-droppable&quot;&gt;&lt;/div&gt;&lt;dl class=&quot;ui-droppable&quot;&gt;&lt;dt&gt;&lt;span class=&quot;item-title&quot;&gt;'+d+'&lt;/span&gt;&lt;span class=&quot;item-controls&quot;&gt;&lt;span class=&quot;item-type&quot;&gt;'+p+'&lt;/span&gt;&lt;a class=&quot;item-edit thickbox&quot; id=&quot;edit'+l+'&quot; value=&quot;'+l+'&quot; onclick=&quot;wpNavMenu.edit_menu_item('+l+');&quot; title=&quot;'+navMenuL10n.thickbox+'&quot; href=&quot;#TB_inline?height=540&amp;width=300&amp;inlineId=menu-item-settings&quot;&gt;'+navMenuL10n.edit+'&lt;/a&gt; | &lt;a class=&quot;item-delete&quot; id=&quot;delete'+l+'&quot; value=&quot;'+l+'&quot; onclick=&quot;wpNavMenu.remove_menu_item('+l+');&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/dl&gt;'+i+&quot;&lt;/li&gt;&quot;);a(&quot;.menu #menu-item-&quot;+l+&quot; dt:first&quot;).animate({backgroundColor:&quot;#FFFF33&quot;},{duration:&quot;normal&quot;,complete:function(){a(this).css(&quot;backgroundColor&quot;,&quot;&quot;)}});wpNavMenu.drag_and_drop();tb_init(&quot;a.thickbox, area.thickbox, input.thickbox&quot;)},add_checked_items_to_menu:function(c){var b=a(c).parent().siblings(&quot;.list-wrap&quot;).find(&quot;:checked&quot;);if(0==b.length){return false}a(b).each(function(){var j=a(this).parent().siblings(&quot;.menu-item-type&quot;).val();if(&quot;custom&quot;==j){var g=a(this).parent().siblings(&quot;.menu-item-attr-title&quot;).val();var h=a(this).parent().siblings(&quot;.menu-item-target&quot;).val();var i=a(this).parent().siblings(&quot;.menu-item-classes&quot;).val();var l=a(this).parent().siblings(&quot;.menu-item-xfn&quot;).val()}else{var g=&quot;&quot;;var h=&quot;_self&quot;;var i=&quot;&quot;;var l=&quot;&quot;}var d=a(this).parent().siblings(&quot;.menu-item-db-id&quot;).val();var m=a(this).parent().siblings(&quot;.menu-item-object-id&quot;).val();var e=a(this).parent().siblings(&quot;.menu-item-object&quot;).val();var p=a(this).parent().siblings(&quot;.menu-item-append&quot;).val();var n=a(this).parent().siblings(&quot;.menu-item-parent-id&quot;).val();var f=a(this).parent().siblings(&quot;.menu-item-title&quot;).val();var o=a(this).parent().siblings(&quot;.menu-item-url&quot;).val();var k=a(this).parent().siblings(&quot;.menu-item-description&quot;).val();if(undefined==k){k=&quot;&quot;}if(undefined==g){g=&quot;&quot;}wpNavMenu.add_to_menu(d,m,e,j,p,n,f,o,k,g,h,i,l);a(this).attr(&quot;checked&quot;,false)})},get_hidden_inputs:function(l,b,m,c,h,n,d,o,j,g,f,e,k){var i=&quot;&quot;;i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-db-id[]&quot; value=&quot;'+b+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object-id[]&quot; value=&quot;'+m+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-object[]&quot; value=&quot;'+c+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-type[]&quot; value=&quot;'+h+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-parent-id[]&quot; value=&quot;'+n+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-position[]&quot; value=&quot;'+l+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-title[]&quot; value=&quot;'+d+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-attr-title[]&quot; value=&quot;'+g+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-url[]&quot; value=&quot;'+o+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-target[]&quot; value=&quot;'+f+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-description[]&quot; value=&quot;'+j+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-classes[]&quot; value=&quot;'+e+'&quot; /&gt;';i+='&lt;input type=&quot;hidden&quot; name=&quot;menu-item-xfn[]&quot; value=&quot;'+k+'&quot; /&gt;';return i}};a(document).ready(function(b){wpNavMenu.init()})})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>