X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftoolbar%2Fplugin.js;h=1e5d2b759e03837024c71c7033326a6384860323;hb=039a051ccf3901311661022a30afd60fc38130c9;hp=5a3d834204a18b2f5c9ba4eca72b22f2de71d6c1;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/toolbar/plugin.js b/_source/plugins/toolbar/plugin.js index 5a3d834..1e5d2b7 100644 --- a/_source/plugins/toolbar/plugin.js +++ b/_source/plugins/toolbar/plugin.js @@ -59,13 +59,37 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var itemKeystroke = function( item, keystroke ) { + var next, nextToolGroup, groupItemsCount; + var rtl = editor.lang.dir == 'rtl'; + switch ( keystroke ) { - case 39 : // RIGHT-ARROW + case rtl ? 37 : 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 next 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. @@ -76,11 +100,32 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return false; - case 37 : // LEFT-ARROW + case rtl ? 39 : 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 +157,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { editor.toolbox = new toolbox(); - var output = [ '