<!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>[14436] trunk/wp-admin/js: Have 'Add to Menu' and multiple-item drag/
drop only affect one meta box at a time.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14436">14436</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-05-04 08:31:40 +0000 (Tue, 04 May 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Have 'Add to Menu' and multiple-item drag/drop only affect one meta box at a time. props ptahdunbar, with koopersmith. Non-JS will still handle the meta boxes all together as one form. see <a href="http://trac.wordpress.org/ticket/13220">#13220</a>, see <a href="http://trac.wordpress.org/ticket/13219">#13219</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 (14435 => 14436)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.dev.js        2010-05-04 08:21:35 UTC (rev 14435)
+++ trunk/wp-admin/js/nav-menu.dev.js        2010-05-04 08:31:40 UTC (rev 14436)
</span><span class="lines">@@ -196,7 +196,6 @@
</span><span class="cx">                                 handle: '.menu-item-handle',
</span><span class="cx">                                 placeholder: 'sortable-placeholder',
</span><span class="cx">                                 start: function(e, ui) {
</span><del>-                                        console.log('sort start', e, ui);
</del><span class="cx">                                         var next, height, width, parent, children, maxChildDepth;
</span><span class="cx">
</span><span class="cx">                                         transport = ui.item.children('.menu-item-transport');
</span><span class="lines">@@ -367,7 +366,7 @@
</span><span class="cx">                                         ui.helper.children('div').addClass('hidden-handle');
</span><span class="cx">                                         
</span><span class="cx">                                         // Trigger the ajax
</span><del>-                                        li.parents('.inside').find('.add-to-menu input').trigger('submit');
</del><ins>+                                        li.parents('.inside').find('.add-to-menu input').click();
</ins><span class="cx">                                         
</span><span class="cx">                                         // Lock dimensions
</span><span class="cx">                                         ui.helper.width( ui.helper.width() );
</span><span class="lines">@@ -438,13 +437,87 @@
</span><span class="cx">                                 that.setupQuickSearchEventListeners(el);
</span><span class="cx">                         });
</span><span class="cx">
</span><del>-                        $(formEL).bind('submit', function(e) {
-                                return that.eventSubmitMetaForm.call(that, this, e);
</del><ins>+                        // If a "Add to Menu" button was clicked, submit that metabox ajax style.
+                        $(formEL).click(function(e) {
+                                // based on the input, call that function
+                                var divcontainer = $(e.target).parent().parent().parent();
+                        
+                                if ( $(e.target).is('input') && $(e.target).hasClass('button-secondary') && !$(e.target).hasClass('quick-search-submit') ) {
+                                        if ( $(divcontainer).hasClass('customlinkdiv') ) {
+                                                that.addCustomLink();
+                                        } else if ( $(divcontainer).hasClass('posttypediv') || $(divcontainer).hasClass('taxonomydiv') ) {
+                                                that.addItemsToMenu( $(divcontainer).attr('id') );
+                                        };
+                                        return false;
+                                } else if ( $(e.target).is('input') && $(e.target).hasClass('quick-search-submit') ) {
+                                        that.quickSearch( $(divcontainer).attr('id') );
+                                        return false;
+                                };
</ins><span class="cx">                         });
</span><del>-                        $(formEL).find('input:submit').click(function() {
-                                $(this).siblings('img.waiting').show();
</del><ins>+                },
+                
+                quickSearch : function(id) {
+                        var type = $('#' + id + ' .quick-search').attr('name'),
+                        q = $('#' + id + ' .quick-search').val(),
+                        menu = $('#menu').val(),
+                        nonce = $('#menu-settings-column-nonce').val(),
+                        params = {},
+                        that = this,
+                        processMethod = function(){};
+
+                        processMethod = that.processQuickSearchQueryResponse;
+
+                        params = {
+                                'action': 'menu-quick-search',
+                                'response-format': 'markup',
+                                'menu': menu,
+                                'menu-settings-column-nonce': nonce,
+                                'q': q,
+                                'type': type
+                        };
+
+                        $.post( ajaxurl, params, function(menuMarkup) {
+                                processMethod.call(that, menuMarkup, params);
</ins><span class="cx">                         });
</span><span class="cx">                 },
</span><ins>+                
+                addCustomLink : function() {
+                        var url = $('#custom-menu-item-url').val(),
+                        label = $('#custom-menu-item-name').val(),
+                        menu = $('#menu').val(),
+                        nonce = $('#menu-settings-column-nonce').val(),
+                        params = {},
+                        that = this,
+                        processMethod = function(){};
+                        
+                        if ( '' == url || 'http://' == url )
+                                return false;
+                        
+                        // Show the ajax spinner
+                        $('.customlinkdiv img.waiting').show();
+                        
+                        params = {
+                                'action': 'add-menu-item',
+                                'menu': menu,
+                                'menu-settings-column-nonce': nonce,
+                                'menu-item': {
+                                        '-1': {
+                                                'menu-item-type': 'custom',
+                                                'menu-item-url': url,
+                                                'menu-item-title': label
+                                        }
+                                }
+                        };
+                        
+                        processMethod = that.eventAddMenuItem;
+                        
+                        $.post( ajaxurl, params, function(menuMarkup) {
+                                processMethod.call(that, menuMarkup, params);
+                                
+                                // Remove the ajax spinner
+                                $('.customlinkdiv img.waiting').hide();
+                        });
+                },
</ins><span class="cx">
</span><span class="cx">                 attachTabsPanelListeners : function() {
</span><span class="cx">                         $('#menu-settings-column').bind('click', function(e) {
</span><span class="lines">@@ -690,73 +763,53 @@
</span><span class="cx">                 },
</span><span class="cx">
</span><span class="cx">                 /**
</span><del>-                 * Callback for the meta form submit action listener.
</del><ins>+                 * Adds menu items to the menu.
</ins><span class="cx">                  *
</span><del>-                 * @param object thisForm The submitted form.
-                 * @param object e The event object.
</del><ins>+                 * @param string id The id of the metabox
</ins><span class="cx">                  */
</span><del>-                eventSubmitMetaForm : function(thisForm, e) {
-                        var inputs = thisForm.getElementsByTagName('input'),
-                        len = inputs.length,
-                        i, j,
-                        listItemData,
-                        listItemDBID,
-                        listItemDBIDMatch,
</del><ins>+                addItemsToMenu : function(id) {
+                        var items = $( '.tabs-panel-active .categorychecklist li input:checked', '#' + id),
+                        menu = $('#menu').val(),
+                        nonce = $('#menu-settings-column-nonce').val(),
</ins><span class="cx">                         params = {},
</span><ins>+                        that = this,
</ins><span class="cx">                         processMethod = function(){},
</span><span class="cx">                         re = new RegExp('menu-item\\[(\[^\\]\]*)');
</span><ins>+                        
+                        processMethod = that.eventAddMenuItem;
+                        
+                        // If no items are checked, bail.
+                        if ( !items.length )
+                                return false;
+                        
+                        // Show the ajax spinner
+                        $('#' + id + ' img.waiting').show();
</ins><span class="cx">
</span><del>-                        that = this;
-                        params['action'] = '';
</del><ins>+                        // do stuff
+                        $(items).each(function(){
+                                listItemDBIDMatch = re.exec( $(this).attr('name') );
+                                listItemDBID = 'undefined' == typeof listItemDBIDMatch[1] ? 0 : parseInt(listItemDBIDMatch[1], 10);
+                                listItemData = getListDataFromID(listItemDBID);
</ins><span class="cx">
</span><del>-                        for ( i = 0; i < len; i++ ) {
-                                if (         // we're submitting a checked item
-                                        inputs[i].name &&
-                                        -1 != inputs[i].name.indexOf('menu-item-object-id') &&
-                                        inputs[i].checked ||
-                                        ( // or we're dealing with a custom link
-                                                'undefined' != typeof inputs[i].id &&
-                                                'custom-menu-item-url' == inputs[i].id &&
-                                                '' != inputs[i].value &&
-                                                'http://' != inputs[i].value
-                                        )
-                                ) {
-                                        params['action'] = 'add-menu-item';
-                                        processMethod = that.processAddMenuItemResponse;
</del><ins>+                                params = {
+                                        'action': 'add-menu-item',
+                                        'menu': menu,
+                                        'menu-settings-column-nonce': nonce,
+                                        'menu-item': {}
+                                };
</ins><span class="cx">
</span><del>-                                        listItemDBIDMatch = re.exec(inputs[i].name);
-                                        listItemDBID = 'undefined' == typeof listItemDBIDMatch[1] ? 0 : parseInt(listItemDBIDMatch[1], 10);
-                                        listItemData = getListDataFromID(listItemDBID);
</del><ins>+                                params['menu-item'][listItemDBID] = listItemData;
</ins><span class="cx">
</span><del>-                                        for ( j in listItemData ) {
-                                                params['menu-item[' + listItemDBID + '][' + j + ']'] = listItemData[j];
-                                        }
</del><ins>+                                $.post( ajaxurl, params, function(menuMarkup) {
+                                        processMethod.call(that, menuMarkup, params);
+                                });
</ins><span class="cx">
</span><del>-                                        inputs[i].checked = false;
-
-                                // we're submitting a search term
-                                } else if (
-                                        '' == params['action'] && // give precedence to adding items
-                                        '' != inputs[i].value &&
-                                        inputs[i].className &&
-                                        -1 != inputs[i].className.search(/quick-search\b[^-]/)
-                                ) {
-                                        params['action'] = 'menu-quick-search';
-                                        params['q'] = inputs[i].value;
-                                        params['response-format'] = 'markup';
-                                        params['type'] = inputs[i].name;
-                                        processMethod = that.processQuickSearchQueryResponse;
-                                }
-                        }
-                        params['menu'] = thisForm.elements['menu'].value;
-                        params['menu-settings-column-nonce'] = thisForm.elements['menu-settings-column-nonce'].value;
-
-                        $.post( ajaxurl, params, function(menuMarkup) {
-                                processMethod.call(that, menuMarkup, params);
-                                $(thisForm).find('img.waiting').hide();
</del><ins>+                                // Uncheck the item
+                                $(this).attr('checked', false);
</ins><span class="cx">                         });
</span><span class="cx">
</span><del>-                        return false;
</del><ins>+                        // Remove the ajax spinner
+                        $('#' + id + ' img.waiting').hide();
</ins><span class="cx">                 },
</span><span class="cx">
</span><span class="cx">                 /**
</span><span class="lines">@@ -765,12 +818,8 @@
</span><span class="cx">                  * @param string menuMarkup The text server response of menu item markup.
</span><span class="cx">                  * @param object req The request arguments.
</span><span class="cx">                  */
</span><del>-                processAddMenuItemResponse : function( menuMarkup, req ) {
</del><ins>+                eventAddMenuItem : function( menuMarkup, req ) {
</ins><span class="cx">                         $(menuMarkup).hideAdvancedMenuItemFields().appendTo( targetList );
</span><del>-
-                        /* set custom link form back to defaults */
-                        $('#custom-menu-item-name').val('').blur();
-                        $('#custom-menu-item-url').val('http://');
</del><span class="cx">                 },
</span><span class="cx">
</span><span class="cx">                 /**
</span></span></pre></div>
<a id="trunkwpadminjsnavmenujs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu.js (14435 => 14436)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.js        2010-05-04 08:21:35 UTC (rev 14435)
+++ trunk/wp-admin/js/nav-menu.js        2010-05-04 08:31:40 UTC (rev 14436)
</span><span class="lines">@@ -1 +1 @@
</span><del>-var WPNavMenuHandler=function(d){var h={},f=30,c=11,k=function(m,q,n,p){if(m&&m[0]){var o=d.parseJSON(m[0]);if(o.post_title){if(o.ID&&o.post_type){h[o.post_title]={ID:o.ID,object_type:o.post_type}}return o.post_title}}},l=function(m,q,n,p){if(m&&m[0]){var o=d.parseJSON(m[0]);if(o.post_title){return o.post_title}}},b=function(s,r){if(!s){return false}r=r||document;var n=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-append","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"],m={},o=r.getElementsByTagName("input"),q=o.length,p,t=document.getElementById("nav-menu-meta-object-id").value;while(q--){p=n.length;while(p--){if(o[q]&&o[q].name&&"menu-item["+s+"]["+n[p]+"]"==o[q].name){m[n[p]]=o[q].value}}}return m},a=function(){g.find(".menu-item-data-position").val(function(m){return m+1})},e=function(m){return m*f},i=function(m){return Math.floor(m/f)},g,j;d.fn.extend({menuItemDepth:function(){return i(this.eq(0).css("margin-left").slice(0,-2))},updateDepthClass:function(n,m){return this.each(function(){var o=d(this);m=m||o.menuItemDepth();d(this).removeClass("menu-item-depth-"+m).addClass("menu-item-depth-"+n)})},shiftDepthClass:function(m){return this.each(function(){var n=d(this),o=n.menuItemDepth();d(this).removeClass("menu-item-depth-"+o).addClass("menu-item-depth-"+(o+m))})},childMenuItems:function(){var m=d();this.each(function(){var n=d(this),p=n.menuItemDepth(),o=n.next();while(o.length&&o.menuItemDepth()>p){m=m.add(o);o=o.next()}});return m},updateParentMenuItemDBId:function(){return this.each(function(){var o=d(this),m=o.find(".menu-item-data-parent-id"),p=o.menuItemDepth(),n=o.prev();if(p==0){m.val(0)}else{while(n.menuItemDepth()!=p-1){n=n.prev()}m.val(n.find(".menu-item-data-object-id").val())}})},hideAdvancedMenuItemFields:function(){return this.each(function(){var m=d(this);d(".hide-column-tog").not(":checked").each(function(){m.find(".field-"+d(this).val()).addClass("hidden-field")})})},});return{init:function(){g=d("#menu-to-edit");j=g;this.attachMenuEditListeners();this.attachMenuMetaListeners(document.getElementById("nav-menu-meta"));this.attachTabsPanelListeners();if(g.length){this.initSortables()}this.initToggles();this.initTabManager();this.initAddMenuItemDraggables()},initToggles:function(){postboxes.add_postbox_toggles("nav-menus");columns.useCheckboxesForHidden();columns.checked=function(m){d(".field-"+m).removeClass("hidden-field")};columns.unchecked=function(m){d(".field-"+m).addClass("hidden-field")};g.hideAdvancedMenuItemFields()},initSortables:function(){var s=0,r,q,m,p=g.offset().left,t,o;g.sortable({handle:".menu-item-handle",placeholder:"sortable-placeholder",start:function(C,B){console.log("sort start",C,B);var A,v,z,y,w,x;o=B.item.children(".menu-item-transport");t=(B.helper.hasClass("new-menu-item"));r=(t)?0:B.item.menuItemDepth();n(B,r);if(!t){y=(B.item.next()[0]==B.placeholder[0])?B.item.next():B.item;w=y.childMenuItems();o.append(w)}u(B);v=o.outerHeight();v+=(v>0)?(B.placeholder.css("margin-top").slice(0,-2)*1):0;v+=B.helper.outerHeight();v-=2;B.placeholder.height(v);x=r;if(!t){w.each(function(){var D=d(this).menuItemDepth();x=(D>x)?D:x})}z=B.helper.find(".menu-item-handle").outerWidth();z+=e(x-r);z-=2;B.placeholder.width(z)},stop:function(y,x){var w,v=s-r;w=o.children().insertAfter(x.item);if(t){x.item.remove();if(v!=0){w.shiftDepthClass(v)}w.updateParentMenuItemDBId()}else{if(v!=0){x.item.updateDepthClass(s);w.shiftDepthClass(v)}x.item.updateParentMenuItemDBId()}a()},change:function(w,v){if(!v.placeholder.parent().hasClass("menu")){v.placeholder.appendTo(g)}u(v)},sort:function(w,v){var x=i(v.helper.offset().left-p);if(x<q){x=q}else{if(x>m){x=m}}if(x!=s){n(v,x)}},receive:function(w,v){o=v.sender.children(".menu-item-transport")}});function u(x){var w=x.placeholder.prev(),v=x.placeholder.next(),y;if(w[0]==x.item[0]){w=w.prev()}if(v[0]==x.item[0]){v=v.next()}q=(v.length)?v.menuItemDepth():0;if(w.length){m=((y=w.menuItemDepth()+1)>c)?c:y}else{m=0}}function n(v,w){v.placeholder.updateDepthClass(w,s);s=w}},initAddMenuItemDraggables:function(){d.fn.extend({checkItem:function(){return this.each(function(){d(this).addClass("selected-menu-item").next().children("input").attr("checked","checked")})},uncheckItem:function(){return this.each(function(){d(this).removeClass("selected-menu-item").next().children("input").removeAttr("checked")})},toggleItem:function(){return this.each(function(){var n=d(this);if(n.hasClass("selected-menu-item")){n.uncheckItem()}else{n.checkItem()}})}});var m=d(".potential-menu-item");m.click(function(n){d(this).toggleItem()}).children().draggable({helper:"clone",connectToSortable:"ul#menu-to-edit",distance:5,zIndex:100,start:function(s,q){var r=d(s.target),p=r.parent(),n=p.parent(),o;p.checkItem();j=r.children(".menu-item-transport");o=m.filter(".selected-menu-item").children().not(q.helper).clone();q.helper.children(".additional-menu-items").append(o);q.helper.addClass("new-menu-item");q.helper.children("div").hide();o.first().css("margin-top",0);o.children("div").addClass("menu-item-handle");q.helper.children("div").addClass("hidden-handle");n.parents(".inside").find(".add-to-menu input").trigger("submit");q.helper.width(q.helper.width());q.helper.height(q.helper.height())},stop:function(o,n){j=g;m.filter(".selected-menu-item").uncheckItem()}})},attachMenuEditListeners:function(){var m=this;d("#update-nav-menu").bind("click",function(n){if(n.target&&n.target.className){if(-1!=n.target.className.indexOf("item-edit")){return m.eventOnClickEditLink(n.target)}else{if(-1!=n.target.className.indexOf("menu-delete")){return m.eventOnClickMenuDelete(n.target)}else{if(-1!=n.target.className.indexOf("item-delete")){return m.eventOnClickMenuItemDelete(n.target)}else{if(-1!=n.target.className.indexOf("item-close")){return m.eventOnClickCloseLink(n.target)}}}}}})},setupInputWithDefaultTitle:function(){var m="input-with-default-title";d("."+m).each(function(){var p=d(this),o=p.attr("title"),n=p.val();p.data(m,o);if(""==n){p.val(o)}else{if(o==n){return}else{p.removeClass(m)}}}).focus(function(){var n=d(this);if(n.val()==n.data(m)){n.val("").removeClass(m)}}).blur(function(){var n=d(this);if(""==n.val()){n.val(n.data(m)).addClass(m)}})},attachMenuMetaListeners:function(m){if(!m){return}var n=this;this.setupInputWithDefaultTitle();d("input.quick-search").each(function(o,p){n.setupQuickSearchEventListeners(p)});d(m).bind("submit",function(o){return n.eventSubmitMetaForm.call(n,this,o)});d(m).find("input:submit").click(function(){d(this).siblings("img.waiting").show()})},attachTabsPanelListeners:function(){d("#menu-settings-column").bind("click",function(r){if(r.target&&r.target.className&&-1!=r.target.className.indexOf("nav-tab-link")){var s,n=/#(.*)$/.exec(r.target.href),q,t=d(r.target).parents(".inside").first()[0],m=t?t.getElementsByTagName("input"):[],o=m.length;while(o--){m[o].checked=false}d(".tabs-panel",t).each(function(){if(this.className){this.className=this.className.replace("tabs-panel-active","tabs-panel-inactive")}});d(".tabs",t).each(function(){this.className=this.className.replace("tabs","")});r.target.parentNode.className+=" tabs";if(n&&n[1]){s=document.getElementById(n[1]);if(s){s.className=s.className.replace("tabs-panel-inactive","tabs-panel-active")}}return false}else{if(r.target&&r.target.className&&-1!=r.target.className.indexOf("select-all")){var p=/#(.*)$/.exec(r.target.href);if(p&&p[1]){d("#"+p[1]+" .tabs-panel-active input[type=checkbox]").attr("checked","checked");return false}}}})},initTabManager:function(){var r=d(".nav-tabs-wrapper"),s=r.children(".nav-tabs"),q=s.children(".nav-tab-active"),u=s.children(".nav-tab"),o=0,v,p,t,n;resizing=false;function m(){p=r.offset().left;v=p+r.width();q.makeTabVisible()}d.fn.extend({makeTabVisible:function(){var x=this.eq(0),y,w;if(!x.length){return}y=x.offset().left;w=y+x.outerWidth();if(w>v){s.animate({"margin-left":"+="+(v-w)+"px",},"fast")}else{if(y<p){s.animate({"margin-left":"-="+(y-p)+"px",},"fast")}}return x},isTabVisible:function(){var x=this.eq(0),y=x.offset().left,w=y+x.outerWidth();return(w<=v&&y>=p)?true:false}});u.each(function(){o+=d(this).outerWidth(true)});if(o<=r.width()-s.css("padding-left").slice(0,-2)-s.css("padding-right").slice(0,-2)){return}s.css({"margin-right":(-1*o)+"px",padding:0,});t=d('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div>');n=d('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div>');r.wrap('<div class="nav-tabs-nav"/>').parent().prepend(t).append(n);m();d(window).resize(function(){if(resizing){return}resizing=true;setTimeout(function(){m();resizing=false},1000)});d.each([{arrow:t,next:"next",last:"first",operator:"+=",},{arrow:n,next:"prev",last:"last",operator:"-=",}],function(){var w=this;this.arrow.mousedown(function(){var y=u[w.last](),x=function(){if(!y.isTabVisible()){s.animate({"margin-left":w.operator+"90px",},300,"linear",x)}};x()}).mouseup(function(){var y,x;s.stop(true);y=u[w.last]();while((x=y[w.next]())&&x.length&&!x.isTabVisible()){y=x}y.makeTabVisible()})})},setupQuickSearchEventListeners:function(m){var n=this;d(m).autocomplete(ajaxurl+"?action=menu-quick-search&type="+m.name,{delay:500,formatItem:k,formatResult:l,minchars:2,multiple:false}).bind("blur",function(q){var o=h[this.value],p=this;if(o){d.post(ajaxurl+"?action=menu-quick-search&type=get-post-item&response-format=markup",o,function(s){n.processQuickSearchQueryResponse.call(n,s,o);h[p.value]=false})}})},eventOnClickEditLink:function(m){var o,n=/#(.*)$/.exec(m.href);if(n&&n[1]){o=d("#"+n[1]);if(0!=o.length){if(o.hasClass("menu-item-edit-inactive")){o.slideDown("fast").siblings("dl").andSelf().removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active")}else{o.slideUp("fast").siblings("dl").andSelf().removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive")}return false}}},eventOnClickCloseLink:function(m){d(m).closest(".menu-item-settings").siblings("dl").find(".item-edit").click();return false},eventOnClickMenuDelete:function(m){if(confirm(navMenuL10n.warnDeleteMenu)){return true}else{return false}},eventOnClickMenuItemDelete:function(m){var p,o,n=this;if(confirm(navMenuL10n.warnDeleteMenuItem)){o=/_wpnonce=([a-zA-Z0-9]*)$/.exec(m.href);if(o&&o[1]){p=parseInt(m.id.replace("delete-",""),10);d.post(ajaxurl,{action:"delete-menu-item","menu-item":p,_wpnonce:o[1]},function(q){if("1"==q){n.removeMenuItem(document.getElementById("menu-item-"+p))}});return false}return true}else{return false}},eventSubmitMetaForm:function(n,u){var r=n.getElementsByTagName("input"),t=r.length,q,p,w,m,s,o={},v=function(){},x=new RegExp("menu-item\\[([^\\]]*)");that=this;o.action="";for(q=0;q<t;q++){if(r[q].name&&-1!=r[q].name.indexOf("menu-item-object-id")&&r[q].checked||("undefined"!=typeof r[q].id&&"custom-menu-item-url"==r[q].id&&""!=r[q].value&&"http://"!=r[q].value)){o.action="add-menu-item";v=that.processAddMenuItemResponse;s=x.exec(r[q].name);m="undefined"==typeof s[1]?0:parseInt(s[1],10);w=b(m);for(p in w){o["menu-item["+m+"]["+p+"]"]=w[p]}r[q].checked=false}else{if(""==o.action&&""!=r[q].value&&r[q].className&&-1!=r[q].className.search(/quick-search\b[^-]/)){o.action="menu-quick-search";o.q=r[q].value;o["response-format"]="markup";o.type=r[q].name;v=that.processQuickSearchQueryResponse}}}o.menu=n.elements.menu.value;o["menu-settings-column-nonce"]=n.elements["menu-settings-column-nonce"].value;d.post(ajaxurl,o,function(y){v.call(that,y,o);d(n).find("img.waiting").hide()});return false},processAddMenuItemResponse:function(m,n){d(m).hideAdvancedMenuItemFields().appendTo(j);d("#custom-menu-item-name").val("").blur();d("#custom-menu-item-url").val("http://")},processQuickSearchQueryResponse:function(q,v){if(!v){v={}}var n=document.createElement("ul"),m=document.getElementById("nav-menu-meta"),r,u,o,w,s,t=new RegExp("menu-item\\[([^\\]]*)"),p;o=t.exec(q);if(o&&o[1]){s=o[1];while(m.elements["menu-item["+s+"][menu-item-type]"]){s--}if(s!=o[1]){q=q.replace(new RegExp("menu-item\\["+o[1]+"\\]","g"),"menu-item["+s+"]")}}n.innerHTML=q;u=n.getElementsByTagName("li");if(u[0]&&v.object_type){p=document.getElementById(v.object_type+"-search-checklist");if(p){p.appendChild(u[0])}}else{if(v.type){o=/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*)/.exec(v.type);if(o&&o[2]){p=document.getElementById(o[2]+"-search-checklist");if(p){r=u.length;if(!r){w=document.createElement("li");w.appendChild(document.createTextNode(navMenuL10n.noResultsFound));p.appendChild(w)}while(r--){p.appendChild(u[r])}}}}}},removeMenuItem:function(n){n=d(n);var m=n.childMenuItems();n.addClass("deleting").fadeOut(350,function(){n.remove();m.shiftDepthClass(-1).updateParentMenuItemDBId();a()})}}};var wpNavMenu=new WPNavMenuHandler(jQuery);jQuery(function(){wpNavMenu.init()});
</del><span class="cx">\ No newline at end of file
</span><ins>+var WPNavMenuHandler=function(d){var h={},f=30,c=11,k=function(m,q,n,p){if(m&&m[0]){var o=d.parseJSON(m[0]);if(o.post_title){if(o.ID&&o.post_type){h[o.post_title]={ID:o.ID,object_type:o.post_type}}return o.post_title}}},l=function(m,q,n,p){if(m&&m[0]){var o=d.parseJSON(m[0]);if(o.post_title){return o.post_title}}},b=function(s,r){if(!s){return false}r=r||document;var n=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-append","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"],m={},o=r.getElementsByTagName("input"),q=o.length,p,t=document.getElementById("nav-menu-meta-object-id").value;while(q--){p=n.length;while(p--){if(o[q]&&o[q].name&&"menu-item["+s+"]["+n[p]+"]"==o[q].name){m[n[p]]=o[q].value}}}return m},a=function(){g.find(".menu-item-data-position").val(function(m){return m+1})},e=function(m){return m*f},i=function(m){return Math.floor(m/f)},g,j;d.fn.extend({menuItemDepth:function(){return i(this.eq(0).css("margin-left").slice(0,-2))},updateDepthClass:function(n,m){return this.each(function(){var o=d(this);m=m||o.menuItemDepth();d(this).removeClass("menu-item-depth-"+m).addClass("menu-item-depth-"+n)})},shiftDepthClass:function(m){return this.each(function(){var n=d(this),o=n.menuItemDepth();d(this).removeClass("menu-item-depth-"+o).addClass("menu-item-depth-"+(o+m))})},childMenuItems:function(){var m=d();this.each(function(){var n=d(this),p=n.menuItemDepth(),o=n.next();while(o.length&&o.menuItemDepth()>p){m=m.add(o);o=o.next()}});return m},updateParentMenuItemDBId:function(){return this.each(function(){var o=d(this),m=o.find(".menu-item-data-parent-id"),p=o.menuItemDepth(),n=o.prev();if(p==0){m.val(0)}else{while(n.menuItemDepth()!=p-1){n=n.prev()}m.val(n.find(".menu-item-data-object-id").val())}})},hideAdvancedMenuItemFields:function(){return this.each(function(){var m=d(this);d(".hide-column-tog").not(":checked").each(function(){m.find(".field-"+d(this).val()).addClass("hidden-field")})})},});return{init:function(){g=d("#menu-to-edit");j=g;this.attachMenuEditListeners();this.attachMenuMetaListeners(document.getElementById("nav-menu-meta"));this.attachTabsPanelListeners();if(g.length){this.initSortables()}this.initToggles();this.initTabManager();this.initAddMenuItemDraggables()},initToggles:function(){postboxes.add_postbox_toggles("nav-menus");columns.useCheckboxesForHidden();columns.checked=function(m){d(".field-"+m).removeClass("hidden-field")};columns.unchecked=function(m){d(".field-"+m).addClass("hidden-field")};g.hideAdvancedMenuItemFields()},initSortables:function(){var s=0,r,q,m,p=g.offset().left,t,o;g.sortable({handle:".menu-item-handle",placeholder:"sortable-placeholder",start:function(C,B){var A,v,z,y,w,x;o=B.item.children(".menu-item-transport");t=(B.helper.hasClass("new-menu-item"));r=(t)?0:B.item.menuItemDepth();n(B,r);if(!t){y=(B.item.next()[0]==B.placeholder[0])?B.item.next():B.item;w=y.childMenuItems();o.append(w)}u(B);v=o.outerHeight();v+=(v>0)?(B.placeholder.css("margin-top").slice(0,-2)*1):0;v+=B.helper.outerHeight();v-=2;B.placeholder.height(v);x=r;if(!t){w.each(function(){var D=d(this).menuItemDepth();x=(D>x)?D:x})}z=B.helper.find(".menu-item-handle").outerWidth();z+=e(x-r);z-=2;B.placeholder.width(z)},stop:function(y,x){var w,v=s-r;w=o.children().insertAfter(x.item);if(t){x.item.remove();if(v!=0){w.shiftDepthClass(v)}w.updateParentMenuItemDBId()}else{if(v!=0){x.item.updateDepthClass(s);w.shiftDepthClass(v)}x.item.updateParentMenuItemDBId()}a()},change:function(w,v){if(!v.placeholder.parent().hasClass("menu")){v.placeholder.appendTo(g)}u(v)},sort:function(w,v){var x=i(v.helper.offset().left-p);if(x<q){x=q}else{if(x>m){x=m}}if(x!=s){n(v,x)}},receive:function(w,v){o=v.sender.children(".menu-item-transport")}});function u(x){var w=x.placeholder.prev(),v=x.placeholder.next(),y;if(w[0]==x.item[0]){w=w.prev()}if(v[0]==x.item[0]){v=v.next()}q=(v.length)?v.menuItemDepth():0;if(w.length){m=((y=w.menuItemDepth()+1)>c)?c:y}else{m=0}}function n(v,w){v.placeholder.updateDepthClass(w,s);s=w}},initAddMenuItemDraggables:function(){d.fn.extend({checkItem:function(){return this.each(function(){d(this).addClass("selected-menu-item").next().children("input").attr("checked","checked")})},uncheckItem:function(){return this.each(function(){d(this).removeClass("selected-menu-item").next().children("input").removeAttr("checked")})},toggleItem:function(){return this.each(function(){var n=d(this);if(n.hasClass("selected-menu-item")){n.uncheckItem()}else{n.checkItem()}})}});var m=d(".potential-menu-item");m.click(function(n){d(this).toggleItem()}).children().draggable({helper:"clone",connectToSortable:"ul#menu-to-edit",distance:5,zIndex:100,start:function(s,q){var r=d(s.target),p=r.parent(),n=p.parent(),o;p.checkItem();j=r.children(".menu-item-transport");o=m.filter(".selected-menu-item").children().not(q.helper).clone();q.helper.children(".additional-menu-items").append(o);q.helper.addClass("new-menu-item");q.helper.children("div").hide();o.first().css("margin-top",0);o.children("div").addClass("menu-item-handle");q.helper.children("div").addClass("hidden-handle");n.parents(".inside").find(".add-to-menu input").click();q.helper.width(q.helper.width());q.helper.height(q.helper.height())},stop:function(o,n){j=g;m.filter(".selected-menu-item").uncheckItem()}})},attachMenuEditListeners:function(){var m=this;d("#update-nav-menu").bind("click",function(n){if(n.target&&n.target.className){if(-1!=n.target.className.indexOf("item-edit")){return m.eventOnClickEditLink(n.target)}else{if(-1!=n.target.className.indexOf("menu-delete")){return m.eventOnClickMenuDelete(n.target)}else{if(-1!=n.target.className.indexOf("item-delete")){return m.eventOnClickMenuItemDelete(n.target)}else{if(-1!=n.target.className.indexOf("item-close")){return m.eventOnClickCloseLink(n.target)}}}}}})},setupInputWithDefaultTitle:function(){var m="input-with-default-title";d("."+m).each(function(){var p=d(this),o=p.attr("title"),n=p.val();p.data(m,o);if(""==n){p.val(o)}else{if(o==n){return}else{p.removeClass(m)}}}).focus(function(){var n=d(this);if(n.val()==n.data(m)){n.val("").removeClass(m)}}).blur(function(){var n=d(this);if(""==n.val()){n.val(n.data(m)).addClass(m)}})},attachMenuMetaListeners:function(m){if(!m){return}var n=this;this.setupInputWithDefaultTitle();d("input.quick-search").each(function(o,p){n.setupQuickSearchEventListeners(p)});d(m).click(function(p){var o=d(p.target).parent().parent().parent();if(d(p.target).is("input")&&d(p.target).hasClass("button-secondary")&&!d(p.target).hasClass("quick-search-submit")){if(d(o).hasClass("customlinkdiv")){n.addCustomLink()}else{if(d(o).hasClass("posttypediv")||d(o).hasClass("taxonomydiv")){n.addItemsToMenu(d(o).attr("id"))}}return false}else{if(d(p.target).is("input")&&d(p.target).hasClass("quick-search-submit")){n.quickSearch(d(o).attr("id"));return false}}})},quickSearch:function(u){var o=d("#"+u+" .quick-search").attr("name"),r=d("#"+u+" .quick-search").val(),t=d("#menu").val(),n=d("#menu-settings-column-nonce").val(),s={},p=this,m=function(){};m=p.processQuickSearchQueryResponse;s={action:"menu-quick-search","response-format":"markup",menu:t,"menu-settings-column-nonce":n,q:r,type:o};d.post(ajaxurl,s,function(q){m.call(p,q,s)})},addCustomLink:function(){var o=d("#custom-menu-item-url").val(),n=d("#custom-menu-item-name").val(),s=d("#menu").val(),p=d("#menu-settings-column-nonce").val(),r={},q=this,m=function(){};if(""==o||"http://"==o){return false}d(".customlinkdiv img.waiting").show();r={action:"add-menu-item",menu:s,"menu-settings-column-nonce":p,"menu-item":{"-1":{"menu-item-type":"custom","menu-item-url":o,"menu-item-title":n}}};m=q.eventAddMenuItem;d.post(ajaxurl,r,function(t){m.call(q,t,r);d(".customlinkdiv img.waiting").hide()})},attachTabsPanelListeners:function(){d("#menu-settings-column").bind("click",function(r){if(r.target&&r.target.className&&-1!=r.target.className.indexOf("nav-tab-link")){var s,n=/#(.*)$/.exec(r.target.href),q,t=d(r.target).parents(".inside").first()[0],m=t?t.getElementsByTagName("input"):[],o=m.length;while(o--){m[o].checked=false}d(".tabs-panel",t).each(function(){if(this.className){this.className=this.className.replace("tabs-panel-active","tabs-panel-inactive")}});d(".tabs",t).each(function(){this.className=this.className.replace("tabs","")});r.target.parentNode.className+=" tabs";if(n&&n[1]){s=document.getElementById(n[1]);if(s){s.className=s.className.replace("tabs-panel-inactive","tabs-panel-active")}}return false}else{if(r.target&&r.target.className&&-1!=r.target.className.indexOf("select-all")){var p=/#(.*)$/.exec(r.target.href);if(p&&p[1]){d("#"+p[1]+" .tabs-panel-active input[type=checkbox]").attr("checked","checked");return false}}}})},initTabManager:function(){var r=d(".nav-tabs-wrapper"),s=r.children(".nav-tabs"),q=s.children(".nav-tab-active"),u=s.children(".nav-tab"),o=0,v,p,t,n;resizing=false;function m(){p=r.offset().left;v=p+r.width();q.makeTabVisible()}d.fn.extend({makeTabVisible:function(){var x=this.eq(0),y,w;if(!x.length){return}y=x.offset().left;w=y+x.outerWidth();if(w>v){s.animate({"margin-left":"+="+(v-w)+"px",},"fast")}else{if(y<p){s.animate({"margin-left":"-="+(y-p)+"px",},"fast")}}return x},isTabVisible:function(){var x=this.eq(0),y=x.offset().left,w=y+x.outerWidth();return(w<=v&&y>=p)?true:false}});u.each(function(){o+=d(this).outerWidth(true)});if(o<=r.width()-s.css("padding-left").slice(0,-2)-s.css("padding-right").slice(0,-2)){return}s.css({"margin-right":(-1*o)+"px",padding:0,});t=d('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div>');n=d('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div>');r.wrap('<div class="nav-tabs-nav"/>').parent().prepend(t).append(n);m();d(window).resize(function(){if(resizing){return}resizing=true;setTimeout(function(){m();resizing=false},1000)});d.each([{arrow:t,next:"next",last:"first",operator:"+=",},{arrow:n,next:"prev",last:"last",operator:"-=",}],function(){var w=this;this.arrow.mousedown(function(){var y=u[w.last](),x=function(){if(!y.isTabVisible()){s.animate({"margin-left":w.operator+"90px",},300,"linear",x)}};x()}).mouseup(function(){var y,x;s.stop(true);y=u[w.last]();while((x=y[w.next]())&&x.length&&!x.isTabVisible()){y=x}y.makeTabVisible()})})},setupQuickSearchEventListeners:function(m){var n=this;d(m).autocomplete(ajaxurl+"?action=menu-quick-search&type="+m.name,{delay:500,formatItem:k,formatResult:l,minchars:2,multiple:false}).bind("blur",function(q){var o=h[this.value],p=this;if(o){d.post(ajaxurl+"?action=menu-quick-search&type=get-post-item&response-format=markup",o,function(s){n.processQuickSearchQueryResponse.call(n,s,o);h[p.value]=false})}})},eventOnClickEditLink:function(m){var o,n=/#(.*)$/.exec(m.href);if(n&&n[1]){o=d("#"+n[1]);if(0!=o.length){if(o.hasClass("menu-item-edit-inactive")){o.slideDown("fast").siblings("dl").andSelf().removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active")}else{o.slideUp("fast").siblings("dl").andSelf().removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive")}return false}}},eventOnClickCloseLink:function(m){d(m).closest(".menu-item-settings").siblings("dl").find(".item-edit").click();return false},eventOnClickMenuDelete:function(m){if(confirm(navMenuL10n.warnDeleteMenu)){return true}else{return false}},eventOnClickMenuItemDelete:function(m){var p,o,n=this;if(confirm(navMenuL10n.warnDeleteMenuItem)){o=/_wpnonce=([a-zA-Z0-9]*)$/.exec(m.href);if(o&&o[1]){p=parseInt(m.id.replace("delete-",""),10);d.post(ajaxurl,{action:"delete-menu-item","menu-item":p,_wpnonce:o[1]},function(q){if("1"==q){n.removeMenuItem(document.getElementById("menu-item-"+p))}});return false}return true}else{return false}},addItemsToMenu:function(t){var n=d(".tabs-panel-active .categorychecklist li input:checked","#"+t),s=d("#menu").val(),p=d("#menu-settings-column-nonce").val(),r={},q=this,m=function(){},o=new RegExp("menu-item\\[([^\\]]*)");m=q.eventAddMenuItem;if(!n.length){return false}d("#"+t+" img.waiting").show();d(n).each(function(){listItemDBIDMatch=o.exec(d(this).attr("name"));listItemDBID="undefined"==typeof listItemDBIDMatch[1]?0:parseInt(listItemDBIDMatch[1],10);listItemData=b(listItemDBID);r={action:"add-menu-item",menu:s,"menu-settings-column-nonce":p,"menu-item":{}};r["menu-item"][listItemDBID]=listItemData;d.post(ajaxurl,r,function(u){m.call(q,u,r)});d(this).attr("checked",false)});d("#"+t+" img.waiting").hide()},eventAddMenuItem:function(m,n){d(m).hideAdvancedMenuItemFields().appendTo(j)},processQuickSearchQueryResponse:function(q,v){if(!v){v={}}var n=document.createElement("ul"),m=document.getElementById("nav-menu-meta"),r,u,o,w,s,t=new RegExp("menu-item\\[([^\\]]*)"),p;o=t.exec(q);if(o&&o[1]){s=o[1];while(m.elements["menu-item["+s+"][menu-item-type]"]){s--}if(s!=o[1]){q=q.replace(new RegExp("menu-item\\["+o[1]+"\\]","g"),"menu-item["+s+"]")}}n.innerHTML=q;u=n.getElementsByTagName("li");if(u[0]&&v.object_type){p=document.getElementById(v.object_type+"-search-checklist");if(p){p.appendChild(u[0])}}else{if(v.type){o=/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*)/.exec(v.type);if(o&&o[2]){p=document.getElementById(o[2]+"-search-checklist");if(p){r=u.length;if(!r){w=document.createElement("li");w.appendChild(document.createTextNode(navMenuL10n.noResultsFound));p.appendChild(w)}while(r--){p.appendChild(u[r])}}}}}},removeMenuItem:function(n){n=d(n);var m=n.childMenuItems();n.addClass("deleting").fadeOut(350,function(){n.remove();m.shiftDepthClass(-1).updateParentMenuItemDBId();a()})}}};var wpNavMenu=new WPNavMenuHandler(jQuery);jQuery(function(){wpNavMenu.init()});
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>