Nav menu: Allow the sortable items selector in wpNavMenu to be overridden.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-06-13 14:03:25 +00:00
parent 489db97ea3
commit fe31ed1e5f
3 changed files with 12 additions and 10 deletions

View File

@ -20,7 +20,8 @@ var wpNavMenu;
options : {
menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
globalMaxDepth : 11
globalMaxDepth : 11,
sortableItems: '> *'
},
menuList : undefined, // Set in init.
@ -87,10 +88,10 @@ var wpNavMenu;
childMenuItems : function() {
var result = $();
this.each(function(){
var t = $(this), depth = t.menuItemDepth(), next = t.next();
var t = $(this), depth = t.menuItemDepth(), next = t.next( '.menu-item' );
while( next.length && next.menuItemDepth() > depth ) {
result = result.add( next );
next = next.next();
next = next.next( '.menu-item' );
}
});
return result;
@ -620,6 +621,7 @@ var wpNavMenu;
api.menuList.sortable({
handle: '.menu-item-handle',
placeholder: 'sortable-placeholder',
items: api.options.sortableItems,
start: function(e, ui) {
var height, width, parent, children, tempHolder;
@ -660,7 +662,7 @@ var wpNavMenu;
ui.placeholder.width(width);
// Update the list of menu items.
tempHolder = ui.placeholder.next();
tempHolder = ui.placeholder.next( '.menu-item' );
tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder
ui.placeholder.detach(); // detach or jQuery UI will think the placeholder is a menu item
$(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQ UI know.
@ -740,12 +742,12 @@ var wpNavMenu;
function updateSharedVars(ui) {
var depth;
prev = ui.placeholder.prev();
next = ui.placeholder.next();
prev = ui.placeholder.prev( '.menu-item' );
next = ui.placeholder.next( '.menu-item' );
// Make sure we don't select the moving item.
if( prev[0] == ui.item[0] ) prev = prev.prev();
if( next[0] == ui.item[0] ) next = next.next();
if( prev[0] == ui.item[0] ) prev = prev.prev( '.menu-item' );
if( next[0] == ui.item[0] ) next = next.next( '.menu-item' );
prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
nextThreshold = (next.length) ? next.offset().top + next.height() / 3 : 0;

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-32744';
$wp_version = '4.3-alpha-32745';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.