X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftoolbar%2Fplugin.js;h=d29462eef29d2e332c84ad6d565ad18996d34ffa;hb=fb481ba0a7d298e3e7b9034fcb9f2afdc6e8e796;hp=891b450142078fadabc1e75b049daaaa1b6000a4;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git
diff --git a/_source/plugins/toolbar/plugin.js b/_source/plugins/toolbar/plugin.js
index 891b450..d29462e 100644
--- a/_source/plugins/toolbar/plugin.js
+++ b/_source/plugins/toolbar/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -36,6 +36,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
toolbarFocus :
{
modes : { wysiwyg : 1, source : 1 },
+ readOnly : 1,
exec : function( editor )
{
@@ -56,86 +57,98 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
CKEDITOR.plugins.add( 'toolbar',
{
+ requires : [ 'button' ],
init : function( editor )
{
+ var endFlag;
+
var itemKeystroke = function( item, keystroke )
{
- var next, nextToolGroup, groupItemsCount;
- var rtl = editor.lang.dir == 'rtl';
+ var next, toolbar;
+ var rtl = editor.lang.dir == 'rtl',
+ toolbarGroupCycling = editor.config.toolbarGroupCycling;
+
+ toolbarGroupCycling = toolbarGroupCycling === undefined || toolbarGroupCycling;
switch ( keystroke )
{
- case rtl ? 37 : 39 : // RIGHT-ARROW
case 9 : // TAB
- do
+ case CKEDITOR.SHIFT + 9 : // SHIFT + TAB
+ // Cycle through the toolbars, starting from the one
+ // closest to the current item.
+ while ( !toolbar || !toolbar.items.length )
{
- // Look for the next item in the toolbar.
- next = item.next;
+ toolbar = keystroke == 9 ?
+ ( ( toolbar ? toolbar.next : item.toolbar.next ) || editor.toolbox.toolbars[ 0 ] ) :
+ ( ( toolbar ? toolbar.previous : item.toolbar.previous ) || editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ] );
- if ( !next )
+ // Look for the first item that accepts focus.
+ if ( toolbar.items.length )
{
- nextToolGroup = item.toolbar.next;
- groupItemsCount = nextToolGroup && nextToolGroup.items.length;
-
- // Bypass the empty toolgroups.
- while ( groupItemsCount === 0 )
+ item = toolbar.items[ endFlag ? ( toolbar.items.length - 1 ) : 0 ];
+ while ( item && !item.focus )
{
- nextToolGroup = nextToolGroup.next;
- groupItemsCount = nextToolGroup && nextToolGroup.items.length;
- }
+ item = endFlag ? item.previous : item.next;
- if ( nextToolGroup )
- next = nextToolGroup.items[ 0 ];
+ if ( !item )
+ toolbar = 0;
+ }
}
-
- item = next;
}
- while ( item && !item.focus )
- // If available, just focus it, otherwise focus the
- // first one.
if ( item )
item.focus();
- else
- editor.toolbox.focus();
return false;
- case rtl ? 39 : 37 : // LEFT-ARROW
- case CKEDITOR.SHIFT + 9 : // SHIFT + TAB
+ case rtl ? 37 : 39 : // RIGHT-ARROW
+ case 40 : // DOWN-ARROW
+ next = item;
do
{
- // Look for the previous item in the toolbar.
- next = item.previous;
+ // Look for the next item in the toolbar.
+ next = next.next;
- if ( !next )
- {
- nextToolGroup = item.toolbar.previous;
- groupItemsCount = nextToolGroup && nextToolGroup.items.length;
+ // If it's the last item, cycle to the first one.
+ if ( !next && toolbarGroupCycling )
+ next = item.toolbar.items[ 0 ];
+ }
+ while ( next && !next.focus )
- // Bypass the empty toolgroups.
- while ( groupItemsCount === 0 )
- {
- nextToolGroup = nextToolGroup.previous;
- groupItemsCount = nextToolGroup && nextToolGroup.items.length;
- }
+ // If available, just focus it, otherwise focus the
+ // first one.
+ if ( next )
+ next.focus();
+ else
+ // Send a TAB.
+ itemKeystroke( item, 9 );
- if ( nextToolGroup )
- next = nextToolGroup.items[ groupItemsCount - 1 ];
- }
+ return false;
+
+ case rtl ? 39 : 37 : // LEFT-ARROW
+ case 38 : // UP-ARROW
+ next = item;
+ do
+ {
+ // Look for the previous item in the toolbar.
+ next = next.previous;
- item = next;
+ // If it's the first item, cycle to the last one.
+ if ( !next && toolbarGroupCycling )
+ next = item.toolbar.items[ item.toolbar.items.length - 1 ];
}
- while ( item && !item.focus )
+ while ( next && !next.focus )
// If available, just focus it, otherwise focus the
// last one.
- if ( item )
- item.focus();
+ if ( next )
+ next.focus();
else
{
- var lastToolbarItems = editor.toolbox.toolbars[ editor.toolbox.toolbars.length - 1 ].items;
- lastToolbarItems[ lastToolbarItems.length - 1 ].focus();
+ endFlag = 1;
+ // Send a SHIFT + TAB.
+ itemKeystroke( item, CKEDITOR.SHIFT + 9 );
+ endFlag = 0;
}
return false;
@@ -160,14 +173,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var labelId = CKEDITOR.tools.getNextId();
- var output = [ '
' : ' style="display:none">' );
// Sends the ARIA label.
- output.push( '', editor.lang.toolbar, '' );
+ output.push( '', editor.lang.toolbars, '' );
var toolbars = editor.toolbox.toolbars,
toolbar =
@@ -178,7 +191,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
for ( var r = 0 ; r < toolbar.length ; r++ )
{
- var row = toolbar[ r ];
+ var toolbarId,
+ toolbarObj = 0,
+ toolbarName,
+ row = toolbar[ r ],
+ items;
// It's better to check if the row object is really
// available because it's a common mistake to leave
@@ -188,9 +205,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( !row )
continue;
- var toolbarId = CKEDITOR.tools.getNextId(),
- toolbarObj = { id : toolbarId, items : [] };
-
if ( groupStarted )
{
output.push( '
' );
@@ -203,33 +217,52 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
continue;
}
- output.push( '' );
-
- // Add the toolbar to the "editor.toolbox.toolbars"
- // array.
- var index = toolbars.push( toolbarObj ) - 1;
-
- // Create the next/previous reference.
- if ( index > 0 )
- {
- toolbarObj.previous = toolbars[ index - 1 ];
- toolbarObj.previous.next = toolbarObj;
- }
+ items = row.items || row;
// Create all items defined for this toolbar.
- for ( var i = 0 ; i < row.length ; i++ )
+ for ( var i = 0 ; i < items.length ; i++ )
{
var item,
- itemName = row[ i ];
+ itemName = items[ i ],
+ canGroup;
- if ( itemName == '-' )
- item = CKEDITOR.ui.separator;
- else
- item = editor.ui.create( itemName );
+ item = editor.ui.create( itemName );
if ( item )
{
- if ( item.canGroup )
+ canGroup = item.canGroup !== false;
+
+ // Initialize the toolbar first, if needed.
+ if ( !toolbarObj )
+ {
+ // Create the basic toolbar object.
+ toolbarId = CKEDITOR.tools.getNextId();
+ toolbarObj = { id : toolbarId, items : [] };
+ toolbarName = row.name && ( editor.lang.toolbarGroups[ row.name ] || row.name );
+
+ // Output the toolbar opener.
+ output.push( '' );
+
+ // If a toolbar name is available, send the voice label.
+ toolbarName && output.push( '', toolbarName, '' );
+
+ output.push( '' );
+
+ // Add the toolbar to the "editor.toolbox.toolbars"
+ // array.
+ var index = toolbars.push( toolbarObj ) - 1;
+
+ // Create the next/previous reference.
+ if ( index > 0 )
+ {
+ toolbarObj.previous = toolbars[ index - 1 ];
+ toolbarObj.previous.next = toolbarObj;
+ }
+ }
+
+ if ( canGroup )
{
if ( !groupStarted )
{
@@ -273,7 +306,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
groupStarted = 0;
}
- output.push( '' );
+ if ( toolbarObj )
+ output.push( '' );
}
output.push( '' );
@@ -294,6 +328,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
editor.addCommand( 'toolbarCollapse',
{
+ readOnly : 1,
exec : function( editor )
{
var collapser = CKEDITOR.document.getById( collapserId ),
@@ -359,30 +394,31 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
instance = items[ i ];
if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
-
- if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;
}
}
});
editor.addCommand( 'toolbarFocus', commands.toolbarFocus );
+
+ editor.ui.add( '-', CKEDITOR.UI_SEPARATOR, {} );
+ editor.ui.addHandler( CKEDITOR.UI_SEPARATOR,
+ {
+ create: function()
+ {
+ return {
+ render : function( editor, output )
+ {
+ output.push( '' );
+ return {};
+ }
+ };
+ }
+ });
}
});
})();
-/**
- * The UI element that renders a toolbar separator.
- * @type Object
- * @example
- */
-CKEDITOR.ui.separator =
-{
- render : function( editor, output )
- {
- output.push( '' );
- return {};
- }
-};
+CKEDITOR.UI_SEPARATOR = 'separator';
/**
* The "theme space" to which rendering the toolbar. For the default theme,
@@ -427,40 +463,36 @@ CKEDITOR.config.toolbar_Basic =
* // This is actually the default value.
* config.toolbar_Full =
* [
- * ['Source','-','Save','NewPage','Preview','-','Templates'],
- * ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
- * ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
- * ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
+ * { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
+ * { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
+ * { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
+ * { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
* '/',
- * ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
- * ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
- * ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
- * ['BidiLtr', 'BidiRtl' ],
- * ['Link','Unlink','Anchor'],
- * ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],
+ * { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
+ * { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
+ * { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
+ * { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak' ] },
* '/',
- * ['Styles','Format','Font','FontSize'],
- * ['TextColor','BGColor'],
- * ['Maximize', 'ShowBlocks','-','About']
+ * { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
+ * { name: 'colors', items : [ 'TextColor','BGColor' ] },
+ * { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
* ];
*/
CKEDITOR.config.toolbar_Full =
[
- ['Source','-','Save','NewPage','Preview','-','Templates'],
- ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
- ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
- ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
+ { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
+ { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
+ { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
+ { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
'/',
- ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
- ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
- ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
- ['BidiLtr', 'BidiRtl' ],
- ['Link','Unlink','Anchor'],
- ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],
+ { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
+ { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
+ { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
+ { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
'/',
- ['Styles','Format','Font','FontSize'],
- ['TextColor','BGColor'],
- ['Maximize', 'ShowBlocks','-','About']
+ { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
+ { name: 'colors', items : [ 'TextColor','BGColor' ] },
+ { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];
/**
@@ -499,3 +531,16 @@ CKEDITOR.config.toolbarCanCollapse = true;
* @example
* config.toolbarStartupExpanded = false;
*/
+
+/**
+ * When enabled, makes the arrow keys navigation cycle within the current
+ * toolbar group. Otherwise the arrows will move trought all items available in
+ * the toolbar. The TAB key will still be used to quickly jump among the
+ * toolbar groups.
+ * @name CKEDITOR.config.toolbarGroupCycling
+ * @since 3.6
+ * @type Boolean
+ * @default true
+ * @example
+ * config.toolbarGroupCycling = false;
+ */