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:
parent
3d610ad782
commit
444f8cc6c4
|
@ -163,7 +163,7 @@ var wpNavMenu;
|
||||||
},
|
},
|
||||||
|
|
||||||
initSortables : function() {
|
initSortables : function() {
|
||||||
var currentDepth = 0, originalDepth, minDepth, maxDepth,
|
var currentDepth = 0, originalDepth, minDepth, maxDepth, prevBottom,
|
||||||
menuLeft = api.menuList.offset().left,
|
menuLeft = api.menuList.offset().left,
|
||||||
newItem, transport;
|
newItem, transport;
|
||||||
|
|
||||||
|
@ -232,10 +232,13 @@ var wpNavMenu;
|
||||||
updateDepthRange(ui);
|
updateDepthRange(ui);
|
||||||
},
|
},
|
||||||
sort: function(e, 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.
|
// Check and correct if depth is not within range.
|
||||||
if ( depth < minDepth ) depth = minDepth;
|
// Also, if the dragged element is dragged upwards over
|
||||||
else if ( depth > maxDepth ) depth = maxDepth;
|
// 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 )
|
if( depth != currentDepth )
|
||||||
updateCurrentDepth(ui, depth);
|
updateCurrentDepth(ui, depth);
|
||||||
|
@ -250,6 +253,7 @@ var wpNavMenu;
|
||||||
if( prev[0] == ui.item[0] ) prev = prev.prev();
|
if( prev[0] == ui.item[0] ) prev = prev.prev();
|
||||||
if( next[0] == ui.item[0] ) next = next.next();
|
if( next[0] == ui.item[0] ) next = next.next();
|
||||||
|
|
||||||
|
prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
|
||||||
minDepth = (next.length) ? next.menuItemDepth() : 0;
|
minDepth = (next.length) ? next.menuItemDepth() : 0;
|
||||||
|
|
||||||
if( prev.length )
|
if( prev.length )
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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, '20100506b' );
|
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", false, '20100508' );
|
||||||
$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