Customizer: Make reordering menu items via drag and drop easier.

Introduce `wpNavMenu.options.targetTolerance` to define a tolerance when dragging items where no margins between the sortable items exists.

props adamsilverstein.
fixes #32821.
Built from https://develop.svn.wordpress.org/trunk@33030


git-svn-id: http://core.svn.wordpress.org/trunk@33001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-07-01 16:44:24 +00:00
parent b837d374bf
commit 78167b8a4c
5 changed files with 15 additions and 9 deletions

View File

@ -8,6 +8,7 @@
wpNavMenu.originalInit = wpNavMenu.init;
wpNavMenu.options.menuItemDepthPerLevel = 20;
wpNavMenu.options.sortableItems = '> .customize-control-nav_menu_item';
wpNavMenu.options.targetTolerance = 10;
wpNavMenu.init = function() {
this.jQueryExtensions();
};

File diff suppressed because one or more lines are too long

View File

@ -20,8 +20,9 @@ var wpNavMenu;
options : {
menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
globalMaxDepth : 11,
sortableItems: '> *'
globalMaxDepth: 11,
sortableItems: '> *',
targetTolerance: 0
},
menuList : undefined, // Set in init.
@ -438,7 +439,7 @@ var wpNavMenu;
totalMenuItems = $('#menu-to-edit li').length,
hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length;
menuItem.find( '.field-move' ).toggle( totalMenuItems > 1 );
menuItem.find( '.field-move' ).toggle( totalMenuItems > 1 );
// Where can they move this menu item?
if ( 0 !== position ) {
@ -721,11 +722,15 @@ var wpNavMenu;
var offset = ui.helper.offset(),
edge = api.isRTL ? offset.left + ui.helper.width() : offset.left,
depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge );
// Check and correct if depth is not within range.
// 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 > maxDepth || offset.top < ( prevBottom - api.options.targetTolerance ) ) {
depth = maxDepth;
} else if ( depth < minDepth ) {
depth = minDepth;
}
if( depth != currentDepth )
updateCurrentDepth(ui, depth);

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-33029';
$wp_version = '4.3-alpha-33030';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.