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