| 417 | | $( '.item-edit' ).each( function() { |
| 418 | | var thisLink, thisLinkText, primaryItems, itemPosition, title, |
| 419 | | parentItem, parentItemId, parentItemName, subItems, |
| 420 | | $this = $(this), |
| 421 | | menuItem = $this.closest( 'li.menu-item' ).first(), |
| 422 | | depth = menuItem.menuItemDepth(), |
| 423 | | isPrimaryMenuItem = ( 0 === depth ), |
| 424 | | itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), |
| 425 | | position = parseInt( menuItem.index(), 10 ), |
| 426 | | prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1, 10 ), |
| 427 | | prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), |
| 428 | | prevItemNameRight = menuItem.prevAll('.menu-item-depth-' + depth).first().find( '.menu-item-title' ).text(), |
| 429 | | totalMenuItems = $('#menu-to-edit li').length, |
| 430 | | hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length; |
| | 437 | var thisLink, thisLinkText, primaryItems, itemPosition, title, |
| | 438 | parentItem, parentItemId, parentItemName, subItems, |
| | 439 | $this = $( itemToRefresh ), |
| | 440 | menuItem = $this.closest( 'li.menu-item' ).first(), |
| | 441 | depth = menuItem.menuItemDepth(), |
| | 442 | isPrimaryMenuItem = ( 0 === depth ), |
| | 443 | itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(), |
| | 444 | position = parseInt( menuItem.index(), 10 ), |
| | 445 | prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1, 10 ), |
| | 446 | prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), |
| | 447 | prevItemNameRight = menuItem.prevAll('.menu-item-depth-' + depth).first().find( '.menu-item-title' ).text(), |
| | 448 | totalMenuItems = $('#menu-to-edit li').length, |
| | 449 | hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length; |
| 455 | | if ( ! isPrimaryMenuItem ) { |
| 456 | | thisLink = menuItem.find( '.menus-move-left' ), |
| 457 | | thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft ); |
| 458 | | thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| 459 | | } |
| | 474 | if ( ! isPrimaryMenuItem ) { |
| | 475 | thisLink = menuItem.find( '.menus-move-left' ), |
| | 476 | thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft ); |
| | 477 | thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| | 478 | } |
| 461 | | if ( 0 !== position ) { |
| 462 | | if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) { |
| 463 | | thisLink = menuItem.find( '.menus-move-right' ), |
| 464 | | thisLinkText = menus.under.replace( '%s', prevItemNameRight ); |
| 465 | | thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| 466 | | } |
| | 480 | if ( 0 !== position ) { |
| | 481 | if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) { |
| | 482 | thisLink = menuItem.find( '.menus-move-right' ), |
| | 483 | thisLinkText = menus.under.replace( '%s', prevItemNameRight ); |
| | 484 | thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).css( 'display', 'inline' ); |
| 469 | | if ( isPrimaryMenuItem ) { |
| 470 | | primaryItems = $( '.menu-item-depth-0' ), |
| 471 | | itemPosition = primaryItems.index( menuItem ) + 1, |
| 472 | | totalMenuItems = primaryItems.length, |
| | 488 | if ( isPrimaryMenuItem ) { |
| | 489 | primaryItems = $( '.menu-item-depth-0' ), |
| | 490 | itemPosition = primaryItems.index( menuItem ) + 1, |
| | 491 | totalMenuItems = primaryItems.length, |
| 474 | | // String together help text for primary menu items |
| 475 | | title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); |
| 476 | | } else { |
| 477 | | parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(), |
| 478 | | parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), |
| 479 | | parentItemName = parentItem.find( '.menu-item-title' ).text(), |
| 480 | | subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), |
| 481 | | itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; |
| | 493 | // String together help text for primary menu items |
| | 494 | title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); |
| | 495 | } else { |
| | 496 | parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(), |
| | 497 | parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), |
| | 498 | parentItemName = parentItem.find( '.menu-item-title' ).text(), |
| | 499 | subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), |
| | 500 | itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; |
| | 512 | /** |
| | 513 | * refreshAdvancedAccessibility |
| | 514 | * |
| | 515 | * Hides all advanced accessibility buttons and marks them for refreshing. |
| | 516 | */ |
| | 517 | refreshAdvancedAccessibility : function() { |
| | 518 | |
| | 519 | // Hide all links by default |
| | 520 | $( '.menu-item-settings .field-move a' ).hide(); |
| | 521 | |
| | 522 | // Mark all menu items as unprocessed |
| | 523 | $( '.item-edit' ).data( 'needs_accessibility_refresh', true ); |
| | 524 | |
| | 525 | // All open items have to be refreshed or they will show no links |
| | 526 | $( '.menu-item-edit-active .item-edit' ).each( function() { |
| | 527 | api.refreshAdvancedAccessibilityOfItem( this ); |
| | 528 | } ); |
| | 529 | }, |
| | 530 | |