Ticket #25112: 25112.1.diff
File 25112.1.diff, 2.4 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/nav-menu.js
59 59 // jQuery extensions 60 60 $.fn.extend({ 61 61 menuItemDepth : function() { 62 var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left'); 63 return api.pxToDepth( margin && -1 != margin.indexOf('px') ? margin.slice(0, -2) : 0 ); 62 if ( this.hasClass( 'menu-item-depth-0' ) ) 63 return 0; 64 else if ( this.hasClass( 'menu-item-depth-1' ) ) 65 return 1; 66 else if ( this.hasClass( 'menu-item-depth-2' ) ) 67 return 2; 68 else if ( this.hasClass( 'menu-item-depth-3' ) ) 69 return 3; 70 else if ( this.hasClass( 'menu-item-depth-4' ) ) 71 return 4; 72 else if ( this.hasClass( 'menu-item-depth-5' ) ) 73 return 5; 74 else if ( this.hasClass( 'menu-item-depth-6' ) ) 75 return 6; 76 else if ( this.hasClass( 'menu-item-depth-7' ) ) 77 return 7; 78 else if ( this.hasClass( 'menu-item-depth-8' ) ) 79 return 8; 80 else if ( this.hasClass( 'menu-item-depth-9' ) ) 81 return 9; 82 else if ( this.hasClass( 'menu-item-depth-10' ) ) 83 return 10; 84 else if ( this.hasClass( 'menu-item-depth-11' ) ) 85 return 11; 86 return 0; 64 87 }, 65 88 updateDepthClass : function(current, prev) { 66 89 return this.each(function(){ … … 408 431 var $this = $(this), 409 432 movement = [], 410 433 availableMovement = '', 411 menuItem = $this. parents( 'li.menu-item' ).first(),434 menuItem = $this.closest( 'li.menu-item' ).first(), 412 435 depth = menuItem.menuItemDepth(), 413 436 isPrimaryMenuItem = ( 0 === depth ), 414 itemName = $this. parents( '.menu-item-handle' ).find( '.menu-item-title' ).text(),437 itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), 415 438 position = parseInt( menuItem.index() ), 416 439 prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1 ), 417 440 prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), … … 455 478 } 456 479 457 480 if ( isPrimaryMenuItem ) { 458 var primaryItems = $( ' .menu-item-depth-0' ),481 var primaryItems = $( '#menu-to-edit' ).children( '.menu-item-depth-0' ), 459 482 itemPosition = primaryItems.index( menuItem ) + 1, 460 483 totalMenuItems = primaryItems.length, 461 484