Only save menu item positions on save. Had implications for draft items otherwise. see #13337, props koopersmith.
git-svn-id: https://develop.svn.wordpress.org/trunk@14615 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
599c19481e
commit
ae2148a866
@ -227,8 +227,6 @@ var wpNavMenu;
|
|||||||
}
|
}
|
||||||
// Update the item data.
|
// Update the item data.
|
||||||
ui.item.updateParentMenuItemDBId();
|
ui.item.updateParentMenuItemDBId();
|
||||||
// Update positions
|
|
||||||
api.recalculateMenuItemPositions();
|
|
||||||
},
|
},
|
||||||
change: function(e, ui) {
|
change: function(e, ui) {
|
||||||
// Make sure the placeholder is inside the menu.
|
// Make sure the placeholder is inside the menu.
|
||||||
@ -291,6 +289,8 @@ var wpNavMenu;
|
|||||||
if ( e.target && e.target.className ) {
|
if ( e.target && e.target.className ) {
|
||||||
if ( -1 != e.target.className.indexOf('item-edit') ) {
|
if ( -1 != e.target.className.indexOf('item-edit') ) {
|
||||||
return that.eventOnClickEditLink(e.target);
|
return that.eventOnClickEditLink(e.target);
|
||||||
|
} else if ( -1 != e.target.className.indexOf('menu-save') ) {
|
||||||
|
return that.eventOnClickMenuSave(e.target);
|
||||||
} else if ( -1 != e.target.className.indexOf('menu-delete') ) {
|
} else if ( -1 != e.target.className.indexOf('menu-delete') ) {
|
||||||
return that.eventOnClickMenuDelete(e.target);
|
return that.eventOnClickMenuDelete(e.target);
|
||||||
} else if ( -1 != e.target.className.indexOf('item-delete') ) {
|
} else if ( -1 != e.target.className.indexOf('item-delete') ) {
|
||||||
@ -456,7 +456,7 @@ var wpNavMenu;
|
|||||||
|
|
||||||
attachHomeLinkListener : function() {
|
attachHomeLinkListener : function() {
|
||||||
$('.add-home-link', '.customlinkdiv').click(function(e) {
|
$('.add-home-link', '.customlinkdiv').click(function(e) {
|
||||||
api.addLinkToMenu( navMenuL10n.homeurl, navMenuL10n.home, api.addMenuItemToTop, api.recalculateMenuItemPositions );
|
api.addLinkToMenu( navMenuL10n.homeurl, navMenuL10n.home, api.addMenuItemToTop );
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -669,6 +669,12 @@ var wpNavMenu;
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
eventOnClickMenuSave : function(clickedEl) {
|
||||||
|
// Update menu item position data
|
||||||
|
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
eventOnClickMenuDelete : function(clickedEl) {
|
eventOnClickMenuDelete : function(clickedEl) {
|
||||||
// Delete warning AYS
|
// Delete warning AYS
|
||||||
if ( confirm( navMenuL10n.warnDeleteMenu ) )
|
if ( confirm( navMenuL10n.warnDeleteMenu ) )
|
||||||
@ -775,7 +781,6 @@ var wpNavMenu;
|
|||||||
el.addClass('deleting').fadeOut( 350 , function() {
|
el.addClass('deleting').fadeOut( 350 , function() {
|
||||||
el.remove();
|
el.remove();
|
||||||
children.shiftDepthClass(-1).updateParentMenuItemDBId();
|
children.shiftDepthClass(-1).updateParentMenuItemDBId();
|
||||||
api.recalculateMenuItemPositions();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -838,10 +843,6 @@ var wpNavMenu;
|
|||||||
return itemData;
|
return itemData;
|
||||||
},
|
},
|
||||||
|
|
||||||
recalculateMenuItemPositions : function() {
|
|
||||||
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
|
|
||||||
},
|
|
||||||
|
|
||||||
depthToPx : function(depth) {
|
depthToPx : function(depth) {
|
||||||
return depth * api.options.menuItemDepthPerLevel;
|
return depth * api.options.menuItemDepthPerLevel;
|
||||||
},
|
},
|
||||||
|
File diff suppressed because one or more lines are too long
@ -484,7 +484,7 @@ require_once( 'admin-header.php' );
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="publishing-action">
|
<div class="publishing-action">
|
||||||
<input class="button-primary" name="save_menu" type="submit" value="<?php empty($nav_menu_selected_id) ? esc_attr_e('Create Menu') : esc_attr_e('Save Menu'); ?>" />
|
<input class="button-primary menu-save" name="save_menu" type="submit" value="<?php empty($nav_menu_selected_id) ? esc_attr_e('Create Menu') : esc_attr_e('Save Menu'); ?>" />
|
||||||
</div><!--END .publishing-action-->
|
</div><!--END .publishing-action-->
|
||||||
|
|
||||||
<?php if ( ! empty( $nav_menu_selected_id ) ) : ?>
|
<?php if ( ! empty( $nav_menu_selected_id ) ) : ?>
|
||||||
|
@ -393,7 +393,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
) );
|
) );
|
||||||
|
|
||||||
// Custom Navigation
|
// Custom Navigation
|
||||||
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100510' );
|
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100513' );
|
||||||
$scripts->localize( 'nav-menu', 'navMenuL10n', array(
|
$scripts->localize( 'nav-menu', 'navMenuL10n', array(
|
||||||
'home' => _x('Home', 'nav menu home label'),
|
'home' => _x('Home', 'nav menu home label'),
|
||||||
'homeurl' => home_url('/'),
|
'homeurl' => home_url('/'),
|
||||||
|
Loading…
Reference in New Issue
Block a user