Some menus meta box cleanups. props filosofo, see #13143.
git-svn-id: https://develop.svn.wordpress.org/trunk@14267 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
105de33875
commit
610abdf2a5
@ -87,7 +87,7 @@
|
||||
float: right;
|
||||
}
|
||||
|
||||
form.processing .add-to-menu {
|
||||
.processing .add-to-menu {
|
||||
background: url("../images/wpspin_light.gif") no-repeat top center;
|
||||
display:block;
|
||||
height:20px;
|
||||
|
@ -260,7 +260,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
* @since 3.0.0
|
||||
**/
|
||||
function wp_nav_menu_meta_boxes_setup() {
|
||||
add_meta_box( 'add-custom-links', __('Add Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
||||
add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
||||
wp_nav_menu_post_type_meta_boxes();
|
||||
wp_nav_menu_taxonomy_meta_boxes();
|
||||
}
|
||||
@ -310,7 +310,7 @@ function wp_nav_menu_post_type_meta_boxes() {
|
||||
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$id = $post_type->name;
|
||||
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 );
|
||||
add_meta_box( "add-{$id}", $post_type->label, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ function wp_nav_menu_taxonomy_meta_boxes() {
|
||||
|
||||
foreach ( $taxonomies as $tax ) {
|
||||
$id = $tax->name;
|
||||
add_meta_box( "add-{$id}", sprintf( __('Add %s'), $tax->label ), 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
|
||||
add_meta_box( "add-{$id}", $tax->label, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,7 +486,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
||||
if ( !$posts )
|
||||
$error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
|
||||
|
||||
$current_tab = 'search';
|
||||
$current_tab = 'all';
|
||||
if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
|
||||
$current_tab = $_REQUEST[$post_type_name . '-tab'];
|
||||
}
|
||||
@ -507,8 +507,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
||||
?>
|
||||
<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
|
||||
<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
<div class="tabs-panel <?php
|
||||
|
@ -111,6 +111,28 @@ var WPNavMenuHandler = function () {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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;
|
||||
},
|
||||
|
||||
makeDroppable = function(el) {
|
||||
var that = this;
|
||||
|
||||
@ -426,7 +448,8 @@ var WPNavMenuHandler = function () {
|
||||
* @param object e The event object.
|
||||
*/
|
||||
eventSubmitMetaForm : function(thisForm, e) {
|
||||
var inputs = thisForm.getElementsByTagName('input'),
|
||||
var ancestor,
|
||||
inputs = thisForm.getElementsByTagName('input'),
|
||||
i = inputs.length,
|
||||
j,
|
||||
listItemData,
|
||||
@ -436,7 +459,6 @@ var WPNavMenuHandler = function () {
|
||||
processMethod = function(){},
|
||||
re = new RegExp('menu-item\\[(\[^\\]\]*)');
|
||||
|
||||
thisForm.className = thisForm.className + ' processing',
|
||||
that = this;
|
||||
|
||||
params['action'] = '';
|
||||
@ -464,6 +486,7 @@ var WPNavMenuHandler = function () {
|
||||
params['menu-item[' + listItemDBID + '][' + j + ']'] = listItemData[j];
|
||||
}
|
||||
|
||||
ancestor = getParentWrapper(inputs[i], 'inside');
|
||||
inputs[i].checked = false;
|
||||
|
||||
// we're submitting a search term
|
||||
@ -473,6 +496,7 @@ var WPNavMenuHandler = function () {
|
||||
inputs[i].className &&
|
||||
-1 != inputs[i].className.search(/quick-search\b[^-]/)
|
||||
) {
|
||||
ancestor = getParentWrapper(inputs[i], 'inside');
|
||||
params['action'] = 'menu-quick-search';
|
||||
params['q'] = inputs[i].value;
|
||||
params['response-format'] = 'markup';
|
||||
@ -480,12 +504,16 @@ var WPNavMenuHandler = function () {
|
||||
processMethod = that.processQuickSearchQueryResponse;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ancestor )
|
||||
ancestor.className = ancestor.className + ' processing',
|
||||
|
||||
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.className = thisForm.className.replace(/processing/g, '');
|
||||
ancestor.className = ancestor.className.replace(/processing/g, '');
|
||||
});
|
||||
|
||||
return false;
|
||||
@ -592,6 +620,7 @@ var WPNavMenuHandler = function () {
|
||||
if ( items[0] && req.object_type ) {
|
||||
resultList = document.getElementById(req.object_type + '-search-checklist');
|
||||
if ( resultList ) {
|
||||
resultList.innerHTML = '';
|
||||
resultList.appendChild(items[0]);
|
||||
}
|
||||
} else if ( req.type ) {
|
||||
@ -599,6 +628,7 @@ var WPNavMenuHandler = function () {
|
||||
if ( matched && matched[1] ) {
|
||||
resultList = document.getElementById(matched[1] + '-search-checklist');
|
||||
if ( resultList ) {
|
||||
resultList.innerHTML = '';
|
||||
i = items.length;
|
||||
while( i-- ) {
|
||||
resultList.appendChild(items[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user