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:
parent
489db97ea3
commit
fe31ed1e5f
|
@ -20,7 +20,8 @@ var wpNavMenu;
|
||||||
|
|
||||||
options : {
|
options : {
|
||||||
menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
|
menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
|
||||||
globalMaxDepth : 11
|
globalMaxDepth : 11,
|
||||||
|
sortableItems: '> *'
|
||||||
},
|
},
|
||||||
|
|
||||||
menuList : undefined, // Set in init.
|
menuList : undefined, // Set in init.
|
||||||
|
@ -87,10 +88,10 @@ var wpNavMenu;
|
||||||
childMenuItems : function() {
|
childMenuItems : function() {
|
||||||
var result = $();
|
var result = $();
|
||||||
this.each(function(){
|
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 ) {
|
while( next.length && next.menuItemDepth() > depth ) {
|
||||||
result = result.add( next );
|
result = result.add( next );
|
||||||
next = next.next();
|
next = next.next( '.menu-item' );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
@ -620,6 +621,7 @@ var wpNavMenu;
|
||||||
api.menuList.sortable({
|
api.menuList.sortable({
|
||||||
handle: '.menu-item-handle',
|
handle: '.menu-item-handle',
|
||||||
placeholder: 'sortable-placeholder',
|
placeholder: 'sortable-placeholder',
|
||||||
|
items: api.options.sortableItems,
|
||||||
start: function(e, ui) {
|
start: function(e, ui) {
|
||||||
var height, width, parent, children, tempHolder;
|
var height, width, parent, children, tempHolder;
|
||||||
|
|
||||||
|
@ -660,7 +662,7 @@ var wpNavMenu;
|
||||||
ui.placeholder.width(width);
|
ui.placeholder.width(width);
|
||||||
|
|
||||||
// Update the list of menu items.
|
// 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
|
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
|
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.
|
$(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQ UI know.
|
||||||
|
@ -740,12 +742,12 @@ var wpNavMenu;
|
||||||
function updateSharedVars(ui) {
|
function updateSharedVars(ui) {
|
||||||
var depth;
|
var depth;
|
||||||
|
|
||||||
prev = ui.placeholder.prev();
|
prev = ui.placeholder.prev( '.menu-item' );
|
||||||
next = ui.placeholder.next();
|
next = ui.placeholder.next( '.menu-item' );
|
||||||
|
|
||||||
// Make sure we don't select the moving item.
|
// Make sure we don't select the moving item.
|
||||||
if( prev[0] == ui.item[0] ) prev = prev.prev();
|
if( prev[0] == ui.item[0] ) prev = prev.prev( '.menu-item' );
|
||||||
if( next[0] == ui.item[0] ) next = next.next();
|
if( next[0] == ui.item[0] ) next = next.next( '.menu-item' );
|
||||||
|
|
||||||
prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
|
prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
|
||||||
nextThreshold = (next.length) ? next.offset().top + next.height() / 3 : 0;
|
nextThreshold = (next.length) ? next.offset().top + next.height() / 3 : 0;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue