<!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>[14267] trunk/wp-admin: Some menus meta box cleanups.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14267">14267</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-28 04:09:00 +0000 (Wed, 28 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Some menus meta box cleanups. props filosofo, see <a href="http://trac.wordpress.org/ticket/13143">#13143</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincssnavmenudevcss">trunk/wp-admin/css/nav-menu.dev.css</a></li>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminjsnavmenudevjs">trunk/wp-admin/js/nav-menu.dev.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincssnavmenudevcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/nav-menu.dev.css (14266 => 14267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/nav-menu.dev.css        2010-04-28 02:24:39 UTC (rev 14266)
+++ trunk/wp-admin/css/nav-menu.dev.css        2010-04-28 04:09:00 UTC (rev 14267)
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">         float: right;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-form.processing .add-to-menu {
</del><ins>+.processing .add-to-menu {
</ins><span class="cx">         background: url("../images/wpspin_light.gif") no-repeat top center;
</span><span class="cx">         display:block;
</span><span class="cx">         height:20px;
</span></span></pre></div>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (14266 => 14267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2010-04-28 02:24:39 UTC (rev 14266)
+++ trunk/wp-admin/includes/nav-menu.php        2010-04-28 04:09:00 UTC (rev 14267)
</span><span class="lines">@@ -260,7 +260,7 @@
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> **/
</span><span class="cx"> function wp_nav_menu_meta_boxes_setup() {
</span><del>-        add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
</del><ins>+        add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
</ins><span class="cx">         wp_nav_menu_post_type_meta_boxes();
</span><span class="cx">         wp_nav_menu_taxonomy_meta_boxes();
</span><span class="cx"> }
</span><span class="lines">@@ -310,7 +310,7 @@
</span><span class="cx">
</span><span class="cx">         foreach ( $post_types as $post_type ) {
</span><span class="cx">                 $id = $post_type->name;
</span><del>-                add_meta_box( "add-{$id}", sprintf( __('Add %s'), $post_type->label ), 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
</del><ins>+                add_meta_box( "add-{$id}", $post_type->label, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -327,7 +327,7 @@
</span><span class="cx">
</span><span class="cx">         foreach ( $taxonomies as $tax ) {
</span><span class="cx">                 $id = $tax->name;
</span><del>-                add_meta_box( "add-{$id}", sprintf( __('Add %s'), $tax->label ), 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
</del><ins>+                add_meta_box( "add-{$id}", $tax->label, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -486,7 +486,7 @@
</span><span class="cx">         if ( !$posts )
</span><span class="cx">                 $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
</span><span class="cx">
</span><del>-        $current_tab = 'search';
</del><ins>+        $current_tab = 'all';
</ins><span class="cx">         if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
</span><span class="cx">                 $current_tab = $_REQUEST[$post_type_name . '-tab'];
</span><span class="cx">         }
</span><span class="lines">@@ -507,8 +507,8 @@
</span><span class="cx">         ?>
</span><span class="cx">         <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
</span><span class="cx">                 <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
</span><ins>+                        <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
</ins><span class="cx">                         <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li>
</span><del>-                        <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
</del><span class="cx">                 </ul>
</span><span class="cx">
</span><span class="cx">                 <div class="tabs-panel <?php
</span></span></pre></div>
<a id="trunkwpadminjsnavmenudevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu.dev.js (14266 => 14267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.dev.js        2010-04-28 02:24:39 UTC (rev 14266)
+++ trunk/wp-admin/js/nav-menu.dev.js        2010-04-28 04:09:00 UTC (rev 14267)
</span><span class="lines">@@ -111,6 +111,28 @@
</span><span class="cx">                 }
</span><span class="cx">         },
</span><span class="cx">
</span><ins>+        /**
+         * Get the parent element with the matching class, but go no higher than the form.
+         *
+         * @param DOM-element el The descendant element up from which we'll be searching
+         * @param string parentClass The class name of the desired parent element.
+         * @return DOM-element The parent element.
+         */
+        getParentWrapper = function( el, parentClass ) {
+                var form = document.getElementById('nav-menu-meta'),
+                i;
+
+                while (
+                        el.parentNode &&
+                        ( ! el.className || -1 == el.className.indexOf(parentClass) ) &&
+                        el.parentNode != form
+                ) {
+                        el = el.parentNode;
+                }
+
+                return el;
+        },
+
</ins><span class="cx">         makeDroppable = function(el) {
</span><span class="cx">                 var that = this;
</span><span class="cx">
</span><span class="lines">@@ -426,7 +448,8 @@
</span><span class="cx">                  * @param object e The event object.
</span><span class="cx">                  */
</span><span class="cx">                 eventSubmitMetaForm : function(thisForm, e) {
</span><del>-                        var inputs = thisForm.getElementsByTagName('input'),
</del><ins>+                        var ancestor,
+                        inputs = thisForm.getElementsByTagName('input'),
</ins><span class="cx">                         i = inputs.length,
</span><span class="cx">                         j,
</span><span class="cx">                         listItemData,
</span><span class="lines">@@ -436,7 +459,6 @@
</span><span class="cx">                         processMethod = function(){},
</span><span class="cx">                         re = new RegExp('menu-item\\[(\[^\\]\]*)');
</span><span class="cx">
</span><del>-                        thisForm.className = thisForm.className + ' processing',
</del><span class="cx">                         that = this;
</span><span class="cx">
</span><span class="cx">                         params['action'] = '';
</span><span class="lines">@@ -464,6 +486,7 @@
</span><span class="cx">                                                 params['menu-item[' + listItemDBID + '][' + j + ']'] = listItemData[j];
</span><span class="cx">                                         }
</span><span class="cx">
</span><ins>+                                        ancestor = getParentWrapper(inputs[i], 'inside');
</ins><span class="cx">                                         inputs[i].checked = false;
</span><span class="cx">
</span><span class="cx">                                 // we're submitting a search term
</span><span class="lines">@@ -473,6 +496,7 @@
</span><span class="cx">                                         inputs[i].className &&
</span><span class="cx">                                         -1 != inputs[i].className.search(/quick-search\b[^-]/)
</span><span class="cx">                                 ) {
</span><ins>+                                        ancestor = getParentWrapper(inputs[i], 'inside');
</ins><span class="cx">                                         params['action'] = 'menu-quick-search';
</span><span class="cx">                                         params['q'] = inputs[i].value;
</span><span class="cx">                                         params['response-format'] = 'markup';
</span><span class="lines">@@ -480,12 +504,16 @@
</span><span class="cx">                                         processMethod = that.processQuickSearchQueryResponse;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><ins>+
+                        if ( ancestor )
+                                ancestor.className = ancestor.className + ' processing',
+
</ins><span class="cx">                         params['menu'] = thisForm.elements['menu'].value;
</span><span class="cx">                         params['menu-settings-column-nonce'] = thisForm.elements['menu-settings-column-nonce'].value;
</span><span class="cx">
</span><span class="cx">                         $.post( ajaxurl, params, function(menuMarkup) {
</span><span class="cx">                                 processMethod.call(that, menuMarkup, params);        
</span><del>-                                thisForm.className = thisForm.className.replace(/processing/g, '');
</del><ins>+                                ancestor.className = ancestor.className.replace(/processing/g, '');
</ins><span class="cx">                         });
</span><span class="cx">
</span><span class="cx">                         return false;
</span><span class="lines">@@ -592,6 +620,7 @@
</span><span class="cx">                         if ( items[0] && req.object_type ) {
</span><span class="cx">                                 resultList = document.getElementById(req.object_type + '-search-checklist');
</span><span class="cx">                                 if ( resultList ) {
</span><ins>+                                        resultList.innerHTML = '';
</ins><span class="cx">                                         resultList.appendChild(items[0]);
</span><span class="cx">                                 }
</span><span class="cx">                         } else if ( req.type ) {
</span><span class="lines">@@ -599,6 +628,7 @@
</span><span class="cx">                                 if ( matched && matched[1] ) {
</span><span class="cx">                                         resultList = document.getElementById(matched[1] + '-search-checklist');
</span><span class="cx">                                         if ( resultList ) {
</span><ins>+                                                resultList.innerHTML = '';
</ins><span class="cx">                                                 i = items.length;
</span><span class="cx">                                                 while( i-- ) {
</span><span class="cx">                                                         resultList.appendChild(items[i]);
</span></span></pre>
</div>
</div>
</body>
</html>