X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Ftoolbar%2Fplugin.js;h=c21e6f27716d9c7b45039ea1ad9b7b24b6007f4e;hb=refs%2Ftags%2Fv3.6.3;hp=029e2dc462729519b8fbcba1de45b5cb2486cd46;hpb=614511639979907ceb0da3614122a4d8eb963ad4;p=ckeditor.git
diff --git a/_source/plugins/toolbar/plugin.js b/_source/plugins/toolbar/plugin.js
index 029e2dc..c21e6f2 100644
--- a/_source/plugins/toolbar/plugin.js
+++ b/_source/plugins/toolbar/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2010, 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 )
{
@@ -43,8 +44,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
editor.toolbox.focusCommandExecuted = true;
- // Make the first button focus accessible. (#3417)
- if ( CKEDITOR.env.ie )
+ // Make the first button focus accessible for IE. (#3417)
+ // Adobe AIR instead need while of delay.
+ if ( CKEDITOR.env.ie || CKEDITOR.env.air )
setTimeout( function(){ editor.toolbox.focus(); }, 100 );
else
editor.toolbox.focus();
@@ -57,84 +59,95 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
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;
- item = next;
+ case rtl ? 39 : 37 : // LEFT-ARROW
+ case 38 : // UP-ARROW
+ next = item;
+ do
+ {
+ // Look for the previous item in the toolbar.
+ next = next.previous;
+
+ // 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;
@@ -159,14 +172,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 =
@@ -177,7 +190,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
@@ -187,9 +204,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( '
' );
@@ -202,33 +216,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 )
{
@@ -272,7 +305,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
groupStarted = 0;
}
- output.push( '' );
+ if ( toolbarObj )
+ output.push( '' );
}
output.push( '' );
@@ -293,6 +327,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 ),
@@ -345,24 +380,44 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
});
+ editor.on( 'destroy', function()
+ {
+ var toolbars, index = 0, i,
+ items, instance;
+ toolbars = this.toolbox.toolbars;
+ for ( ; index < toolbars.length; index++ )
+ {
+ items = toolbars[ index ].items;
+ for ( i = 0; i < items.length; i++ )
+ {
+ instance = items[ i ];
+ if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );
+ if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );
+ }
+ }
+ });
+
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,
@@ -407,40 +462,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'],
+ * { 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'],
+ { 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' ] }
];
/**
@@ -479,3 +530,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;
+ */