Ticket #14045: 14045.diff
File 14045.diff, 6.1 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/nav-menu.php
89 89 <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>"> 90 90 <dl class="menu-item-bar"> 91 91 <dt class="menu-item-handle"> 92 <span class="item-title">< ?php echo esc_html( $title ); ?> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span>92 <span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span> 93 93 <span class="item-controls"> 94 94 <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> 95 95 <span class="item-order hide-if-js"> -
wp-admin/js/nav-menu.js
53 53 this.initAccessibility(); 54 54 55 55 this.initToggles(); 56 57 this.refreshVerbalAccessibility(); 56 58 }, 57 59 58 60 jQueryExtensions : function() { … … 264 266 }); 265 267 }, 266 268 269 countMenuItems : function( depth ) { 270 return $( '.menu-item-depth-' + depth ).length; 271 }, 272 273 refreshVerbalAccessibility : function() { 274 $( '.item-edit' ).each( function() { 275 var $this = $(this), 276 movement = [], 277 availableMovement = '', 278 menuItem = $this.parents( 'li.menu-item' ), 279 depth = menuItem.menuItemDepth(), 280 isPrimaryMenuItem = ( 0 === depth ), 281 itemName = $this.parents( '.menu-item-handle' ).find( '.menu-item-title' ).text(), 282 position = parseInt( menuItem.index() ), 283 totalMenuItems = $('#menu-to-edit li').length, 284 hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length; 285 286 // Where can they move this menu item? 287 if ( 0 !== position ) 288 movement.push( 'up' ); 289 290 if ( position + 1 !== totalMenuItems && 0 !== position ) 291 movement.push( 'down' ); 292 293 if ( 0 === position && 0 !== hasSameDepthSibling ) 294 movement.push( 'down' ); 295 296 if ( ! isPrimaryMenuItem ) 297 movement.push( 'left' ); 298 299 if ( 0 !== position ) { 300 if ( menuItem.find( '.menu-item-data-parent-id' ).val() !== menuItem.prev().find( '.menu-item-data-db-id' ).val() ) 301 movement.push( 'right' ); 302 } 303 304 for ( i=0; i<movement.length; i++ ) { 305 306 if ( 1 !== movement.length && i + 1 === movement.length ) 307 availableMovement = availableMovement + ' or'; 308 309 availableMovement = availableMovement + ' ' + movement[i] + ','; 310 } 311 312 availableMovement = availableMovement.substring(0, availableMovement.length - 1); 313 314 if ( isPrimaryMenuItem ) { 315 var primaryItems = $( '.menu-item-depth-0' ), 316 itemPosition = primaryItems.index( menuItem ) + 1, 317 totalMenuItems = primaryItems.length, 318 319 // String together help text for primary menu items 320 title = itemName + '. ' + api.getGetOrdinal( itemPosition ) + ' of ' + totalMenuItems + ' primary menu items. Move this item' + availableMovement + '.'; 321 } else { 322 var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(), 323 parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(), 324 parentItemName = parentItem.find( '.menu-item-title' ).text(), 325 subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), 326 itemPosition = $(subItems.parents('.menu-item').get().reverse()).index( menuItem ) + 1, 327 totalMenuItems = subItems.length; 328 329 // String together help text for sub menu items 330 title = itemName + '. ' + api.getGetOrdinal( itemPosition ) + ' of ' + totalMenuItems + ' subb menu items under ' + parentItemName + '. Move this item' + availableMovement + '.'; 331 } 332 333 $this.prop('title', title); 334 }); 335 }, 336 337 getGetOrdinal : function(n) { 338 var s=["th","st","nd","rd"], 339 v=n%100; 340 return n+(s[(v-20)%10]||s[v]||s[0]); 341 }, 342 267 343 initAccessibility : function() { 268 344 $( '.item-edit' ).off( 'focus' ).on( 'focus', function(){ 269 345 $(this).on( 'keydown', function(e){ … … 320 396 if ( thisItemChildren ) { 321 397 var items = thisItem.add( thisItemChildren ); 322 398 // Move the entire block 323 items.detach().insertBefore( menuItems.eq( newItemPosition ) ) ;399 items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); 324 400 } else { 325 thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ) ;401 thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); 326 402 } 327 403 break; 328 404 case 'down': … … 341 417 if ( menuItemsCount === thisItemPosition + items.length ) 342 418 break; 343 419 344 items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ) ;420 items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId(); 345 421 } else { 346 422 // If next item has sub items, shift depth 347 423 if ( 0 !== nextItemChildren.length ) … … 350 426 // Have we reached the bottom 351 427 if ( menuItemsCount === thisItemPosition + 1 ) 352 428 break; 353 thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ) ;429 thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId(); 354 430 } 355 431 break; 356 432 case 'left': … … 358 434 if ( 0 === thisItemDepth ) 359 435 break; 360 436 thisItem.shiftHorizontally( -1 ); 437 $( '#menu-name' ).focus(); 361 438 break; 362 439 case 'right': 363 440 // Can't be sub item at top … … 367 444 if ( thisItemData['menu-item-parent-id'] === prevItemId ) 368 445 break; 369 446 thisItem.shiftHorizontally( 1 ); 447 $( '#menu-name' ).focus(); 370 448 break; 371 449 } 372 450 api.registerChange(); 451 api.refreshVerbalAccessibility(); 373 452 // Put focus back on same menu item 374 453 $( '#edit-' + thisItemData['menu-item-db-id'] ).focus(); 375 454 return false;