| 408 | | $( '.item-edit' ).each( function() { |
| 409 | | var $this = $(this), |
| 410 | | movement = [], |
| 411 | | availableMovement = '', |
| 412 | | menuItem = $this.closest( 'li.menu-item' ).first(), |
| 413 | | depth = menuItem.menuItemDepth(), |
| 414 | | isPrimaryMenuItem = ( 0 === depth ), |
| 415 | | itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), |
| 416 | | position = parseInt( menuItem.index() ), |
| 417 | | prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1 ), |
| 418 | | prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), |
| 419 | | prevItemNameRight = menuItem.prevAll('.menu-item-depth-' + depth).first().find( '.menu-item-title' ).text(), |
| 420 | | totalMenuItems = $('#menu-to-edit li').length, |
| 421 | | hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length; |
| | 414 | var movement = [], |
| | 415 | availableMovement = '', |
| | 416 | menuItem = $this.closest( 'li.menu-item' ).first(), |
| | 417 | depth = menuItem.menuItemDepth(), |
| | 418 | isPrimaryMenuItem = ( 0 === depth ), |
| | 419 | itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), |
| | 420 | position = parseInt( menuItem.index() ), |
| | 421 | prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1 ), |
| | 422 | prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), |
| | 423 | prevItemNameRight = menuItem.prevAll('.menu-item-depth-' + depth).first().find( '.menu-item-title' ).text(), |
| | 424 | totalMenuItems = $('#menu-to-edit li').length, |
| | 425 | hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length; |
| 444 | | if ( ! isPrimaryMenuItem ) { |
| 445 | | var thisLink = menuItem.find( '.menus-move-left' ), |
| 446 | | thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft ); |
| 447 | | thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| 448 | | } |
| | 448 | if ( ! isPrimaryMenuItem ) { |
| | 449 | var thisLink = menuItem.find( '.menus-move-left' ), |
| | 450 | thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft ); |
| | 451 | thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| | 452 | } |
| 450 | | if ( 0 !== position ) { |
| 451 | | if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) { |
| 452 | | var thisLink = menuItem.find( '.menus-move-right' ), |
| 453 | | thisLinkText = menus.under.replace( '%s', prevItemNameRight ); |
| 454 | | thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| 455 | | } |
| | 454 | if ( 0 !== position ) { |
| | 455 | if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) { |
| | 456 | var thisLink = menuItem.find( '.menus-move-right' ), |
| | 457 | thisLinkText = menus.under.replace( '%s', prevItemNameRight ); |
| | 458 | thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| 458 | | if ( isPrimaryMenuItem ) { |
| 459 | | var primaryItems = $( '.menu-item-depth-0' ), |
| 460 | | itemPosition = primaryItems.index( menuItem ) + 1, |
| 461 | | totalMenuItems = primaryItems.length, |
| | 462 | if ( isPrimaryMenuItem ) { |
| | 463 | var primaryItems = $( '.menu-item-depth-0' ), |
| | 464 | itemPosition = primaryItems.index( menuItem ) + 1, |
| | 465 | totalMenuItems = primaryItems.length, |
| 463 | | // String together help text for primary menu items |
| 464 | | title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); |
| 465 | | } else { |
| 466 | | var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(), |
| 467 | | parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), |
| 468 | | parentItemName = parentItem.find( '.menu-item-title' ).text(), |
| 469 | | subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), |
| 470 | | itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; |
| | 467 | // String together help text for primary menu items |
| | 468 | title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); |
| | 469 | } else { |
| | 470 | var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(), |
| | 471 | parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), |
| | 472 | parentItemName = parentItem.find( '.menu-item-title' ).text(), |
| | 473 | subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), |
| | 474 | itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; |
| | 487 | refreshAdvancedAccessibility : function() { |
| | 488 | |
| | 489 | // Hide all links by default |
| | 490 | $( '.menu-item-settings .field-move a' ).hide(); |
| | 491 | |
| | 492 | // Mark all menu items as unprocessed |
| | 493 | $( '.item-edit' ).data( 'needs_accessibility_refresh', true ); |
| | 494 | |
| | 495 | // All open items have to be refreshed or they will show no links |
| | 496 | $( '.menu-item-edit-active .item-edit' ).each( function() { |
| | 497 | api.refreshAdvancedAccessibilityOfItem( this ); |
| | 498 | } ); |
| | 499 | |
| | 500 | return; |
| | 501 | }, |
| | 502 | |