Optimize the accessibility JS on the Menus screen to avoid browser crashes with very large menus.

props atimmer.
fixes #25112.

Built from https://develop.svn.wordpress.org/trunk@25708


git-svn-id: http://core.svn.wordpress.org/trunk@25622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-10-07 13:37:08 +00:00
parent 72b7c6b912
commit d2f06ecf48
2 changed files with 10 additions and 10 deletions

View File

@ -403,16 +403,16 @@ var wpNavMenu;
refreshAdvancedAccessibility : function() { refreshAdvancedAccessibility : function() {
// Hide all links by default // Hide all links by default
$( '.menu-item-settings .field-move a' ).hide(); $( '.menu-item-settings .field-move a' ).css( 'display', 'none' );
$( '.item-edit' ).each( function() { $( '.item-edit' ).each( function() {
var $this = $(this), var $this = $(this),
movement = [], movement = [],
availableMovement = '', availableMovement = '',
menuItem = $this.parents( 'li.menu-item' ).first(), menuItem = $this.closest( 'li.menu-item' ).first(),
depth = menuItem.menuItemDepth(), depth = menuItem.menuItemDepth(),
isPrimaryMenuItem = ( 0 === depth ), isPrimaryMenuItem = ( 0 === depth ),
itemName = $this.parents( '.menu-item-handle' ).find( '.menu-item-title' ).text(), itemName = $this.closest( '.menu-item-handle' ).find( '.menu-item-title' ).text(),
position = parseInt( menuItem.index() ), position = parseInt( menuItem.index() ),
prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1 ), prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1 ),
prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(), prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(),
@ -423,35 +423,35 @@ var wpNavMenu;
// Where can they move this menu item? // Where can they move this menu item?
if ( 0 !== position ) { if ( 0 !== position ) {
var thisLink = menuItem.find( '.menus-move-up' ); var thisLink = menuItem.find( '.menus-move-up' );
thisLink.prop( 'title', menus.moveUp ).show(); thisLink.prop( 'title', menus.moveUp ).css( 'display', 'inline' );
} }
if ( 0 !== position && isPrimaryMenuItem ) { if ( 0 !== position && isPrimaryMenuItem ) {
var thisLink = menuItem.find( '.menus-move-top' ); var thisLink = menuItem.find( '.menus-move-top' );
thisLink.prop( 'title', menus.moveToTop ).show(); thisLink.prop( 'title', menus.moveToTop ).css( 'display', 'inline' );
} }
if ( position + 1 !== totalMenuItems && 0 !== position ) { if ( position + 1 !== totalMenuItems && 0 !== position ) {
var thisLink = menuItem.find( '.menus-move-down' ); var thisLink = menuItem.find( '.menus-move-down' );
thisLink.prop( 'title', menus.moveDown ).show(); thisLink.prop( 'title', menus.moveDown ).css( 'display', 'inline' );
} }
if ( 0 === position && 0 !== hasSameDepthSibling ) { if ( 0 === position && 0 !== hasSameDepthSibling ) {
var thisLink = menuItem.find( '.menus-move-down' ); var thisLink = menuItem.find( '.menus-move-down' );
thisLink.prop( 'title', menus.moveDown ).show(); thisLink.prop( 'title', menus.moveDown ).css( 'display', 'inline' );
} }
if ( ! isPrimaryMenuItem ) { if ( ! isPrimaryMenuItem ) {
var thisLink = menuItem.find( '.menus-move-left' ), var thisLink = menuItem.find( '.menus-move-left' ),
thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft ); thisLinkText = menus.outFrom.replace( '%s', prevItemNameLeft );
thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).show(); thisLink.prop( 'title', menus.moveOutFrom.replace( '%s', prevItemNameLeft ) ).html( thisLinkText ).css( 'display', 'inline' );
} }
if ( 0 !== position ) { if ( 0 !== position ) {
if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) { if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) {
var thisLink = menuItem.find( '.menus-move-right' ), var thisLink = menuItem.find( '.menus-move-right' ),
thisLinkText = menus.under.replace( '%s', prevItemNameRight ); thisLinkText = menus.under.replace( '%s', prevItemNameRight );
thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).show(); thisLink.prop( 'title', menus.moveUnder.replace( '%s', prevItemNameRight ) ).html( thisLinkText ).css( 'display', 'inline' );
} }
} }

File diff suppressed because one or more lines are too long