<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23727] trunk/wp-admin: Accessibility revamp for nav menus.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23727">23727</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2013-03-16 04:47:19 +0000 (Sat, 16 Mar 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Accessibility revamp for nav menus.

props lessbloat. fixes <a href="http://core.trac.wordpress.org/ticket/14045">#14045</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsscolorsfreshcss">trunk/wp-admin/css/colors-fresh.css</a></li>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadminincludesnavmenuphp">trunk/wp-admin/includes/nav-menu.php</a></li>
<li><a href="#trunkwpadminjsnavmenujs">trunk/wp-admin/js/nav-menu.js</a></li>
<li><a href="#trunkwpadminnavmenusphp">trunk/wp-admin/nav-menus.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsscolorsfreshcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/colors-fresh.css (23726 => 23727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/colors-fresh.css        2013-03-15 22:58:35 UTC (rev 23726)
+++ trunk/wp-admin/css/colors-fresh.css        2013-03-16 04:47:19 UTC (rev 23727)
</span><span class="lines">@@ -1789,10 +1789,6 @@
</span><span class="cx">         background: #fbfbfb;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.menu-settings {
-        border-top: 1px solid #eeeeee;
-}
-
</del><span class="cx"> .theme-location-set {
</span><span class="cx">         color: #999999;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (23726 => 23727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2013-03-15 22:58:35 UTC (rev 23726)
+++ trunk/wp-admin/css/wp-admin.css        2013-03-16 04:47:19 UTC (rev 23727)
</span><span class="lines">@@ -7305,9 +7305,12 @@
</span><span class="cx">         margin: .3em 0 .6em;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.menu-edit #post-body-content h3 {
+        margin: 0 0 10px;
+}
+
</ins><span class="cx"> .menu-settings {
</span><span class="cx">         margin-top: 2em;
</span><del>-        padding-top: 16px;
</del><span class="cx">         overflow: hidden;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -7801,6 +7804,11 @@
</span><span class="cx">         border-bottom-right-radius: 3px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.menu-item-settings .field-move a {
+        display: none;
+        margin: 0 2px;
+}
+
</ins><span class="cx"> .menu-item-edit-active .menu-item-settings {
</span><span class="cx">         display: block;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesnavmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/nav-menu.php (23726 => 23727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/nav-menu.php        2013-03-15 22:58:35 UTC (rev 23726)
+++ trunk/wp-admin/includes/nav-menu.php        2013-03-16 04:47:19 UTC (rev 23727)
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx">                 &lt;li id=&quot;menu-item-&lt;?php echo $item_id; ?&gt;&quot; class=&quot;&lt;?php echo implode(' ', $classes ); ?&gt;&quot;&gt;
</span><span class="cx">                         &lt;dl class=&quot;menu-item-bar&quot;&gt;
</span><span class="cx">                                 &lt;dt class=&quot;menu-item-handle&quot;&gt;
</span><del>-                                        &lt;span class=&quot;item-title&quot;&gt;&lt;?php echo esc_html( $title ); ?&gt; &lt;span class=&quot;is-submenu&quot; &lt;?php echo $submenu_text; ?&gt;&gt;&lt;?php _e( 'sub item' ); ?&gt;&lt;/span&gt;&lt;/span&gt;
</del><ins>+                                        &lt;span class=&quot;item-title&quot;&gt;&lt;span class=&quot;menu-item-title&quot;&gt;&lt;?php echo esc_html( $title ); ?&gt;&lt;/span&gt; &lt;span class=&quot;is-submenu&quot; &lt;?php echo $submenu_text; ?&gt;&gt;&lt;?php _e( 'sub item' ); ?&gt;&lt;/span&gt;&lt;/span&gt;
</ins><span class="cx">                                         &lt;span class=&quot;item-controls&quot;&gt;
</span><span class="cx">                                                 &lt;span class=&quot;item-type&quot;&gt;&lt;?php echo esc_html( $item-&gt;type_label ); ?&gt;&lt;/span&gt;
</span><span class="cx">                                                 &lt;span class=&quot;item-order hide-if-js&quot;&gt;
</span><span class="lines">@@ -173,6 +173,17 @@
</span><span class="cx">                                         &lt;/label&gt;
</span><span class="cx">                                 &lt;/p&gt;
</span><span class="cx"> 
</span><ins>+                                &lt;p class=&quot;field-move description description-wide&quot;&gt;
+                                        &lt;label&gt;
+                                                &lt;?php _e( 'Move' ); ?&gt;
+                                                &lt;a href=&quot;#&quot; class=&quot;menus-move-up&quot;&gt;&lt;?php _e( 'Up one' ); ?&gt;&lt;/a&gt;
+                                                &lt;a href=&quot;#&quot; class=&quot;menus-move-down&quot;&gt;&lt;?php _e( 'Down one' ); ?&gt;&lt;/a&gt;
+                                                &lt;a href=&quot;#&quot; class=&quot;menus-move-left&quot;&gt;&lt;/a&gt;
+                                                &lt;a href=&quot;#&quot; class=&quot;menus-move-right&quot;&gt;&lt;/a&gt;
+                                                &lt;a href=&quot;#&quot; class=&quot;menus-move-top&quot;&gt;&lt;?php _e( 'To the top' ); ?&gt;&lt;/a&gt;
+                                        &lt;/label&gt;
+                                &lt;/p&gt;
+
</ins><span class="cx">                                 &lt;div class=&quot;menu-item-actions description-wide submitbox&quot;&gt;
</span><span class="cx">                                         &lt;?php if( 'custom' != $item-&gt;type &amp;&amp; $original_title !== false ) : ?&gt;
</span><span class="cx">                                                 &lt;p class=&quot;link-to-original&quot;&gt;
</span></span></pre></div>
<a id="trunkwpadminjsnavmenujs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/nav-menu.js (23726 => 23727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/nav-menu.js        2013-03-15 22:58:35 UTC (rev 23726)
+++ trunk/wp-admin/js/nav-menu.js        2013-03-16 04:47:19 UTC (rev 23727)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">                         if( api.menuList.length )
</span><span class="cx">                                 this.initSortables();
</span><span class="cx"> 
</span><del>-                        if( oneThemeLocationNoMenus )
</del><ins>+                        if( menu.oneThemeLocationNoMenus )
</ins><span class="cx">                                 $( '#posttype-page' ).addSelectedToMenu( api.addMenuItemToBottom );
</span><span class="cx"> 
</span><span class="cx">                         this.initAccessibility();
</span><span class="lines">@@ -162,7 +162,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         return this.each(function() {
</span><span class="cx">                                                 var t = $(this), menuItems = {},
</span><del>-                                                        checkboxes = ( oneThemeLocationNoMenus &amp;&amp; 0 == t.find('.tabs-panel-active .categorychecklist li input:checked').length ) ? t.find('#page-all li input[type=&quot;checkbox&quot;]') : t.find('.tabs-panel-active .categorychecklist li input:checked'),
</del><ins>+                                                        checkboxes = ( menu.oneThemeLocationNoMenus &amp;&amp; 0 == t.find('.tabs-panel-active .categorychecklist li input:checked').length ) ? t.find('#page-all li input[type=&quot;checkbox&quot;]') : t.find('.tabs-panel-active .categorychecklist li input:checked'),
</ins><span class="cx">                                                         re = new RegExp('menu-item\\[(\[^\\]\]*)');
</span><span class="cx"> 
</span><span class="cx">                                                 processMethod = processMethod || api.addMenuItemToBottom;
</span><span class="lines">@@ -271,9 +271,226 @@
</span><span class="cx">                         accordionOptions.filter(':visible').first().addClass( 'open' );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><ins>+                countMenuItems : function( depth ) {
+                        return $( '.menu-item-depth-' + depth ).length;
+                },
+
+                moveMenuItem : function( $this, dir ) {
+
+                        var menuItems = $('#menu-to-edit li');
+                                menuItemsCount = menuItems.length,
+                                thisItem = $this.parents( 'li.menu-item' ),
+                                thisItemChildren = thisItem.childMenuItems(),
+                                thisItemData = thisItem.getItemData(),
+                                thisItemDepth = parseInt( thisItem.menuItemDepth() ),
+                                thisItemPosition = parseInt( thisItem.index() ),
+                                nextItem = thisItem.next(),
+                                nextItemChildren = nextItem.childMenuItems(),
+                                nextItemDepth = parseInt( nextItem.menuItemDepth() ) + 1,
+                                prevItem = thisItem.prev(),
+                                prevItemDepth = parseInt( prevItem.menuItemDepth() ),
+                                prevItemId = prevItem.getItemData()['menu-item-db-id'];
+
+                        switch ( dir ) {
+                        case 'up':
+                                var newItemPosition = thisItemPosition - 1;
+
+                                // Already at top
+                                if ( 0 === thisItemPosition )
+                                        break;
+
+                                // If a sub item is moved to top, shift it to 0 depth
+                                if ( 0 === newItemPosition &amp;&amp; 0 !== thisItemDepth )
+                                        thisItem.moveHorizontally( 0, thisItemDepth );
+
+                                // If prev item is sub item, shift to match depth
+                                if ( 0 !== prevItemDepth )
+                                        thisItem.moveHorizontally( prevItemDepth, thisItemDepth );
+
+                                // Does this item have sub items?
+                                if ( thisItemChildren ) {
+                                        var items = thisItem.add( thisItemChildren );
+                                        // Move the entire block
+                                        items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId();
+                                } else {
+                                        thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId();
+                                }
+                                break;
+                        case 'down':
+                                // Does this item have sub items?
+                                if ( thisItemChildren ) {
+                                        var items = thisItem.add( thisItemChildren ),
+                                                nextItem = menuItems.eq( items.length + thisItemPosition ),
+                                                nextItemChildren = 0 !== nextItem.childMenuItems().length;
+
+                                        if ( nextItemChildren ) {
+                                                var newDepth = parseInt( nextItem.menuItemDepth() ) + 1;
+                                                thisItem.moveHorizontally( newDepth, thisItemDepth );
+                                        }
+
+                                        // Have we reached the bottom?
+                                        if ( menuItemsCount === thisItemPosition + items.length )
+                                                break;
+
+                                        items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId();
+                                } else {
+                                        // If next item has sub items, shift depth
+                                        if ( 0 !== nextItemChildren.length )
+                                                thisItem.moveHorizontally( nextItemDepth, thisItemDepth );
+
+                                        // Have we reached the bottom
+                                        if ( menuItemsCount === thisItemPosition + 1 )
+                                                break;
+                                        thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId();
+                                }
+                                break;
+                        case 'top':
+                                // Already at top
+                                if ( 0 === thisItemPosition )
+                                        break;
+                                // Does this item have sub items?
+                                if ( thisItemChildren ) {
+                                        var items = thisItem.add( thisItemChildren );
+                                        // Move the entire block
+                                        items.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId();
+                                } else {
+                                        thisItem.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId();
+                                }
+                                break;
+                        case 'left':
+                                // As far left as possible
+                                if ( 0 === thisItemDepth )
+                                        break;
+                                thisItem.shiftHorizontally( -1 );
+                                break;
+                        case 'right':
+                                // Can't be sub item at top
+                                if ( 0 === thisItemPosition )
+                                        break;
+                                // Already sub item of prevItem
+                                if ( thisItemData['menu-item-parent-id'] === prevItemId )
+                                        break;
+                                thisItem.shiftHorizontally( 1 );
+                                break;
+                        }
+                        $this.focus();
+                        api.registerChange();
+                        api.refreshKeyboardAccessibility();
+                        api.refreshAdvancedAccessibility();
+                },
+
</ins><span class="cx">                 initAccessibility : function() {
</span><ins>+                        api.refreshKeyboardAccessibility();
+                        api.refreshAdvancedAccessibility();
+
+                        // Events
+                        $( '.menus-move-up' ).on( 'click', function ( e ) {
+                                api.moveMenuItem( $( this ).parents( 'li.menu-item' ).find( 'a.item-edit' ), 'up' );
+                                e.preventDefault();
+                        });
+                        $( '.menus-move-down' ).on( 'click', function ( e ) {
+                                api.moveMenuItem( $( this ).parents( 'li.menu-item' ).find( 'a.item-edit' ), 'down' );
+                                e.preventDefault();
+                        });
+                        $( '.menus-move-top' ).on( 'click', function ( e ) {
+                                api.moveMenuItem( $( this ).parents( 'li.menu-item' ).find( 'a.item-edit' ), 'top' );
+                                e.preventDefault();
+                        });
+                        $( '.menus-move-left' ).on( 'click', function ( e ) {
+                                api.moveMenuItem( $( this ).parents( 'li.menu-item' ).find( 'a.item-edit' ), 'left' );
+                                e.preventDefault();
+                        });
+                        $( '.menus-move-right' ).on( 'click', function ( e ) {
+                                api.moveMenuItem( $( this ).parents( 'li.menu-item' ).find( 'a.item-edit' ), 'right' );
+                                e.preventDefault();
+                        });
+                },
+
+                refreshAdvancedAccessibility : function() {
+
+                        // Hide all links by default
+                        $( '.menu-item-settings .field-move a' ).hide();
+
+                        $( '.item-edit' ).each( function() {
+                                var $this = $(this),
+                                        movement = [],
+                                        availableMovement = '',
+                                        menuItem = $this.parents( 'li.menu-item' ).first(),
+                                        depth = menuItem.menuItemDepth(),
+                                        isPrimaryMenuItem = ( 0 === depth ),
+                                        itemName = $this.parents( '.menu-item-handle' ).find( '.menu-item-title' ).text(),
+                                        position = parseInt( menuItem.index() ),
+                                        prevItemDepth = ( isPrimaryMenuItem ) ? depth : parseInt( depth - 1 ),
+                                        prevItemNameLeft = menuItem.prevAll('.menu-item-depth-' + prevItemDepth).first().find( '.menu-item-title' ).text(),
+                                        prevItemNameRight = menuItem.prevAll('.menu-item-depth-' + depth).first().find( '.menu-item-title' ).text(),
+                                        totalMenuItems = $('#menu-to-edit li').length,
+                                        hasSameDepthSibling = menuItem.nextAll( '.menu-item-depth-' + depth ).length;
+
+                                // Where can they move this menu item?
+                                if ( 0 !== position ) {
+                                        var thisLink = menuItem.find( '.menus-move-up' ),
+                                                thisLinkText = thisLink.text();
+                                        thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
+                                }
+
+                                if ( 0 !== position &amp;&amp; isPrimaryMenuItem ) {
+                                        var thisLink = menuItem.find( '.menus-move-top' ),
+                                                thisLinkText = thisLink.text();
+                                        thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
+                                }
+
+                                if ( position + 1 !== totalMenuItems &amp;&amp; 0 !== position ) {
+                                        var thisLink = menuItem.find( '.menus-move-down' ),
+                                                thisLinkText = thisLink.text();
+                                        thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
+                                }
+
+                                if ( 0 === position &amp;&amp; 0 !== hasSameDepthSibling ) {
+                                        var thisLink = menuItem.find( '.menus-move-down' ),
+                                                thisLinkText = thisLink.text();
+                                        thisLink.prop('title', menus.move + ' ' + thisLinkText).show();
+                                }
+
+                                if ( ! isPrimaryMenuItem ) {
+                                        var thisLink = menuItem.find( '.menus-move-left' ),
+                                                thisLinkText = menus.outFrom + ' ' + prevItemNameLeft;
+                                        thisLink.prop('title', menus.move + ' ' + thisLinkText).html(thisLinkText).show();
+                                }
+
+                                if ( 0 !== position ) {
+                                        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' ),
+                                                        thisLinkText = menus.under + ' ' + prevItemNameRight;
+                                                thisLink.prop('title', menus.move + ' ' + thisLinkText).html(thisLinkText).show();
+                                        }
+                                }
+
+                                if ( isPrimaryMenuItem ) {
+                                        var primaryItems = $( '.menu-item-depth-0' ),
+                                                itemPosition = primaryItems.index( menuItem ) + 1,
+                                                totalMenuItems = primaryItems.length,
+
+                                                // String together help text for primary menu items
+                                                title = itemName + '. ' + menus.menuFocus.replace('%d', itemPosition).replace('%d', totalMenuItems) + '.';
+                                } else {
+                                        var parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1 ) ).first(),
+                                                parentItemId = parentItem.find( '.menu-item-data-db-id' ).val(),
+                                                parentItemName = parentItem.find( '.menu-item-title' ).text(),
+                                                subItems = $( '.menu-item .menu-item-data-parent-id[value=&quot;' + parentItemId + '&quot;]' ),
+                                                itemPosition = $(subItems.parents('.menu-item').get().reverse()).index( menuItem ) + 1;
+
+                                                // String together help text for sub menu items
+
+                                                title = itemName + '. ' + menus.subMenuFocus.replace('%d', itemPosition) + parentItemName + '.';
+                                }
+
+                                $this.prop('title', title).html( title );
+                        });
+                },
+
+                refreshKeyboardAccessibility : function() {
</ins><span class="cx">                         $( '.item-edit' ).off( 'focus' ).on( 'focus', function(){
</span><del>-                                $(this).on( 'keydown', function(e){
</del><ins>+                                $(this).off( 'keydown' ).on( 'keydown', function(e){
</ins><span class="cx"> 
</span><span class="cx">                                         var $this = $(this);
</span><span class="cx"> 
</span><span class="lines">@@ -284,22 +501,8 @@
</span><span class="cx">                                         // Avoid multiple keydown events
</span><span class="cx">                                         $this.off('keydown');
</span><span class="cx"> 
</span><del>-                                        var menuItems = $('#menu-to-edit li');
-                                                menuItemsCount = menuItems.length,
-                                                thisItem = $this.parents( 'li.menu-item' ),
-                                                thisItemChildren = thisItem.childMenuItems(),
-                                                thisItemData = thisItem.getItemData(),
-                                                thisItemDepth = parseInt( thisItem.menuItemDepth() ),
-                                                thisItemPosition = parseInt( thisItem.index() ),
-                                                nextItem = thisItem.next(),
-                                                nextItemChildren = nextItem.childMenuItems(),
-                                                nextItemDepth = parseInt( nextItem.menuItemDepth() ) + 1,
-                                                prevItem = thisItem.prev(),
-                                                prevItemDepth = parseInt( prevItem.menuItemDepth() ),
-                                                prevItemId = prevItem.getItemData()['menu-item-db-id'];
-
</del><span class="cx">                                         // Bail if there is only one menu item
</span><del>-                                        if ( 1 === menuItemsCount )
</del><ins>+                                        if ( 1 === $('#menu-to-edit li').length )
</ins><span class="cx">                                                 return;
</span><span class="cx"> 
</span><span class="cx">                                         // If RTL, swap left/right arrows
</span><span class="lines">@@ -309,80 +512,22 @@
</span><span class="cx"> 
</span><span class="cx">                                         switch ( arrows[e.which] ) {
</span><span class="cx">                                         case 'up':
</span><del>-                                                var newItemPosition = thisItemPosition - 1;
-
-                                                // Already at top
-                                                if ( 0 === thisItemPosition )
-                                                        break;
-
-                                                // If a sub item is moved to top, shift it to 0 depth
-                                                if ( 0 === newItemPosition &amp;&amp; 0 !== thisItemDepth )
-                                                        thisItem.moveHorizontally( 0, thisItemDepth );
-
-                                                // If prev item is sub item, shift to match depth
-                                                if ( 0 !== prevItemDepth )
-                                                        thisItem.moveHorizontally( prevItemDepth, thisItemDepth );
-
-                                                // Does this item have sub items?
-                                                if ( thisItemChildren ) {
-                                                        var items = thisItem.add( thisItemChildren );
-                                                        // Move the entire block
-                                                        items.detach().insertBefore( menuItems.eq( newItemPosition ) );
-                                                } else {
-                                                        thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) );
-                                                }
</del><ins>+                                                api.moveMenuItem( $this, 'up' );
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         case 'down':
</span><del>-                                                // Does this item have sub items?
-                                                if ( thisItemChildren ) {
-                                                        var items = thisItem.add( thisItemChildren ),
-                                                                nextItem = menuItems.eq( items.length + thisItemPosition ),
-                                                                nextItemChildren = 0 !== nextItem.childMenuItems().length;
-
-                                                        if ( nextItemChildren ) {
-                                                                var newDepth = parseInt( nextItem.menuItemDepth() ) + 1;
-                                                                thisItem.moveHorizontally( newDepth, thisItemDepth );
-                                                        }
-
-                                                        // Have we reached the bottom?
-                                                        if ( menuItemsCount === thisItemPosition + items.length )
-                                                                break;
-
-                                                        items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) );
-                                                } else {
-                                                        // If next item has sub items, shift depth
-                                                        if ( 0 !== nextItemChildren.length )
-                                                                thisItem.moveHorizontally( nextItemDepth, thisItemDepth );
-
-                                                        // Have we reached the bottom
-                                                        if ( menuItemsCount === thisItemPosition + 1 )
-                                                                break;
-                                                        thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) );
-                                                }
</del><ins>+                                                api.moveMenuItem( $this, 'down' );
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         case 'left':
</span><del>-                                                // As far left as possible
-                                                if ( 0 === thisItemDepth )
-                                                        break;
-                                                thisItem.shiftHorizontally( -1 );
</del><ins>+                                                api.moveMenuItem( $this, 'left' );
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         case 'right':
</span><del>-                                                // Can't be sub item at top
-                                                if ( 0 === thisItemPosition )
-                                                        break;
-                                                // Already sub item of prevItem
-                                                if ( thisItemData['menu-item-parent-id'] === prevItemId )
-                                                        break;
-                                                thisItem.shiftHorizontally( 1 );
</del><ins>+                                                api.moveMenuItem( $this, 'right' );
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span><del>-                                        api.registerChange();
</del><span class="cx">                                         // Put focus back on same menu item
</span><span class="cx">                                         $( '#edit-' + thisItemData['menu-item-db-id'] ).focus();
</span><span class="cx">                                         return false;
</span><span class="cx">                                 });
</span><del>-                        }).blur(function () {
-                                $(this).off( 'keydown' );
</del><span class="cx">                         });
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="lines">@@ -512,6 +657,9 @@
</span><span class="cx">                                                 ui.item[0].style.left = 'auto';
</span><span class="cx">                                                 ui.item[0].style.right = 0;
</span><span class="cx">                                         }
</span><ins>+
+                                        api.refreshKeyboardAccessibility();
+                                        api.refreshAdvancedAccessibility();
</ins><span class="cx">                                 },
</span><span class="cx">                                 change: function(e, ui) {
</span><span class="cx">                                         // Make sure the placeholder is inside the menu.
</span><span class="lines">@@ -773,12 +921,14 @@
</span><span class="cx">                  */
</span><span class="cx">                 addMenuItemToBottom : function( menuMarkup, req ) {
</span><span class="cx">                         $(menuMarkup).hideAdvancedMenuItemFields().appendTo( api.targetList );
</span><del>-                        api.initAccessibility();
</del><ins>+                        api.refreshKeyboardAccessibility();
+                        api.refreshAdvancedAccessibility();
</ins><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 addMenuItemToTop : function( menuMarkup, req ) {
</span><span class="cx">                         $(menuMarkup).hideAdvancedMenuItemFields().prependTo( api.targetList );
</span><del>-                        api.initAccessibility();
</del><ins>+                        api.refreshKeyboardAccessibility();
+                        api.refreshAdvancedAccessibility();
</ins><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 attachUnsavedChangesListener : function() {
</span></span></pre></div>
<a id="trunkwpadminnavmenusphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/nav-menus.php (23726 => 23727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/nav-menus.php        2013-03-15 22:58:35 UTC (rev 23726)
+++ trunk/wp-admin/nav-menus.php        2013-03-16 04:47:19 UTC (rev 23727)
</span><span class="lines">@@ -354,6 +354,16 @@
</span><span class="cx"> $page_count = wp_count_posts( 'page' );
</span><span class="cx"> $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) &amp;&amp; ! $add_new_screen &amp;&amp; empty( $nav_menus ) &amp;&amp; ! empty( $page_count-&gt;publish ) ) ? true : false;
</span><span class="cx"> 
</span><ins>+$l10n = array(
+        &quot;oneThemeLocationNoMenus&quot; =&gt; ( $one_theme_location_no_menus ) ? 'true' : 'false',
+        &quot;move&quot; =&gt; __( 'Move' ),
+        &quot;menuFocus&quot; =&gt; __( 'Menu item %d of %d' ),
+        &quot;subMenuFocus&quot; =&gt; __( 'Sub item number %d under' ),
+        &quot;under&quot; =&gt; __( 'Under' ),
+        &quot;outFrom&quot; =&gt; __( 'Out from under' )
+);
+wp_localize_script( 'nav-menu', 'menus', $l10n );
+
</ins><span class="cx"> // Redirect to add screen if there are no menus and this users has either zero, or more than 1 theme locations
</span><span class="cx"> if ( 0 == $menu_count &amp;&amp; ! $add_new_screen &amp;&amp; ! $one_theme_location_no_menus )
</span><span class="cx">         wp_redirect( admin_url( 'nav-menus.php?action=edit&amp;menu=0' ) );
</span><span class="lines">@@ -543,6 +553,7 @@
</span><span class="cx">                                         &lt;div id=&quot;post-body&quot;&gt;
</span><span class="cx">                                                 &lt;div id=&quot;post-body-content&quot;&gt;
</span><span class="cx">                                                         &lt;?php if ( ! $add_new_screen ) : ?&gt;
</span><ins>+                                                        &lt;h3&gt;&lt;?php _e( 'Menu Structure' ); ?&gt;&lt;/h3&gt;
</ins><span class="cx">                                                         &lt;?php $starter_copy = ( $one_theme_location_no_menus ) ? __( 'Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.' ) : __( 'Drag each item into the order you prefer. Click an item to reveal additional configuration options.' ); ?&gt;
</span><span class="cx">                                                         &lt;div class=&quot;drag-instructions post-body-plain&quot; &lt;?php if ( isset( $menu_items ) &amp;&amp; 0 == count( $menu_items ) ) { ?&gt;style=&quot;display: none;&quot;&lt;?php } ?&gt;&gt;
</span><span class="cx">                                                                 &lt;p&gt;&lt;?php echo $starter_copy; ?&gt;&lt;/p&gt;
</span><span class="lines">@@ -559,6 +570,7 @@
</span><span class="cx">                                                                 &lt;p class=&quot;post-body-plain&quot;&gt;&lt;?php _e( 'Give your menu a name above, then click Create Menu.' ); ?&gt;&lt;/p&gt;
</span><span class="cx">                                                         &lt;?php endif; ?&gt;
</span><span class="cx">                                                         &lt;div class=&quot;menu-settings&quot; &lt;?php if ( $one_theme_location_no_menus ) { ?&gt;style=&quot;display: none;&quot;&lt;?php } ?&gt;&gt;
</span><ins>+                                                                &lt;h3&gt;&lt;?php _e( 'Menu Settings' ); ?&gt;&lt;/h3&gt;
</ins><span class="cx">                                                                 &lt;?php
</span><span class="cx">                                                                 if ( ! isset( $auto_add ) ) {
</span><span class="cx">                                                                         $auto_add = get_option( 'nav_menu_options' );
</span><span class="lines">@@ -612,5 +624,4 @@
</span><span class="cx">         &lt;/div&gt;&lt;!-- /#menu-management-liquid --&gt;
</span><span class="cx">         &lt;/div&gt;&lt;!-- /#nav-menus-frame --&gt;
</span><span class="cx"> &lt;/div&gt;&lt;!-- /.wrap--&gt;
</span><del>-&lt;script type=&quot;text/javascript&quot;&gt;var oneThemeLocationNoMenus = &lt;?php if ( $one_theme_location_no_menus ) echo 'true'; else echo 'false'; ?&gt;;&lt;/script&gt;
</del><span class="cx"> &lt;?php include( './admin-footer.php' ); ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>