X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Ftoolbar%2Fplugin.js;h=4b59f6d33bde4add33503d8fe6a6eebad295d9f6;hp=c1701a4808c1c03ad726d6100d04cb21469b953f;hb=refs%2Ftags%2Fv3.2;hpb=c6e377a02b54abc07129d72b632763c727476a15 diff --git a/_source/plugins/toolbar/plugin.js b/_source/plugins/toolbar/plugin.js index c1701a4..4b59f6d 100644 --- a/_source/plugins/toolbar/plugin.js +++ b/_source/plugins/toolbar/plugin.js @@ -59,13 +59,36 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var itemKeystroke = function( item, keystroke ) { + var next, nextToolGroup, groupItemsCount; + switch ( keystroke ) { case 39 : // RIGHT-ARROW case 9 : // TAB - // Look for the next item in the toolbar. - while ( ( item = item.next || ( item.toolbar.next && item.toolbar.next.items[ 0 ] ) ) && !item.focus ) - { /*jsl:pass*/ } + do + { + // Look for the previous item in the toolbar. + next = item.next; + + if ( !next ) + { + nextToolGroup = item.toolbar.next; + groupItemsCount = nextToolGroup && nextToolGroup.items.length; + + // Bypass the empty toolgroups. + while ( groupItemsCount === 0 ) + { + nextToolGroup = nextToolGroup.next; + groupItemsCount = nextToolGroup && nextToolGroup.items.length; + } + + if ( nextToolGroup ) + next = nextToolGroup.items[ 0 ]; + } + + item = next; + } + while ( item && !item.focus ) // If available, just focus it, otherwise focus the // first one. @@ -78,9 +101,30 @@ For licensing, see LICENSE.html or http://ckeditor.com/license case 37 : // LEFT-ARROW case CKEDITOR.SHIFT + 9 : // SHIFT + TAB - // Look for the previous item in the toolbar. - while ( ( item = item.previous || ( item.toolbar.previous && item.toolbar.previous.items[ item.toolbar.previous.items.length - 1 ] ) ) && !item.focus ) - { /*jsl:pass*/ } + do + { + // Look for the previous item in the toolbar. + next = item.previous; + + if ( !next ) + { + nextToolGroup = item.toolbar.previous; + groupItemsCount = nextToolGroup && nextToolGroup.items.length; + + // Bypass the empty toolgroups. + while ( groupItemsCount === 0 ) + { + nextToolGroup = nextToolGroup.previous; + groupItemsCount = nextToolGroup && nextToolGroup.items.length; + } + + if ( nextToolGroup ) + next = nextToolGroup.items[ groupItemsCount - 1 ]; + } + + item = next; + } + while ( item && !item.focus ) // If available, just focus it, otherwise focus the // last one. @@ -112,12 +156,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { editor.toolbox = new toolbox(); - var output = [ '