mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 08:11:52 +01:00
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:
parent
b837d374bf
commit
78167b8a4c
@ -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();
|
||||
};
|
||||
|
4
wp-admin/js/customize-nav-menus.min.js
vendored
4
wp-admin/js/customize-nav-menus.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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);
|
||||
|
2
wp-admin/js/nav-menu.min.js
vendored
2
wp-admin/js/nav-menu.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user