Allow menu items to be dropped on a parent item in addition to just being dragged to the right. props koopersmith, see #13220.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14520 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-08 21:56:53 +00:00
parent 3d610ad782
commit 444f8cc6c4
3 changed files with 10 additions and 6 deletions

View File

@ -163,7 +163,7 @@ var wpNavMenu;
},
initSortables : function() {
var currentDepth = 0, originalDepth, minDepth, maxDepth,
var currentDepth = 0, originalDepth, minDepth, maxDepth, prevBottom,
menuLeft = api.menuList.offset().left,
newItem, transport;
@ -232,10 +232,13 @@ var wpNavMenu;
updateDepthRange(ui);
},
sort: function(e, ui) {
var depth = api.pxToDepth(ui.helper.offset().left - menuLeft);
var offset = ui.helper.offset(),
depth = api.pxToDepth( offset.left - menuLeft );
// Check and correct if depth is not within range.
if ( depth < minDepth ) depth = minDepth;
else if ( depth > maxDepth ) depth = maxDepth;
// Also, if the dragged element is dragged upwards over
// an item, shift the placeholder to a child position.
if ( depth > maxDepth || offset.top < prevBottom ) depth = maxDepth;
else if ( depth < minDepth ) depth = minDepth;
if( depth != currentDepth )
updateCurrentDepth(ui, depth);
@ -250,6 +253,7 @@ var wpNavMenu;
if( prev[0] == ui.item[0] ) prev = prev.prev();
if( next[0] == ui.item[0] ) next = next.next();
prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
minDepth = (next.length) ? next.menuItemDepth() : 0;
if( prev.length )

File diff suppressed because one or more lines are too long

View File

@ -393,7 +393,7 @@ function wp_default_scripts( &$scripts ) {
) );
// Custom Navigation
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100506b' );
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100508' );
$scripts->localize( 'nav-menu', 'navMenuL10n', array(
'home' => _x('Home', 'nav menu home label'),
'homeurl' => home_url('/'),