X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Ftoolbar%2Fplugin.js;h=5b6878acbc8a4d92699c8fb2e37e4e31beaff3ac;hb=4e70ea24db840898be8cc21c950363a52a2a6aba;hp=a891c157a28569fb8d16a54135d726828e357ee5;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git
diff --git a/_source/plugins/toolbar/plugin.js b/_source/plugins/toolbar/plugin.js
index a891c15..5b6878a 100644
--- a/_source/plugins/toolbar/plugin.js
+++ b/_source/plugins/toolbar/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2011, 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,39 +59,95 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
init : function( editor )
{
+ var endFlag;
+
var itemKeystroke = function( item, keystroke )
{
+ var next, toolbar;
+ var rtl = editor.lang.dir == 'rtl',
+ toolbarGroupCycling = editor.config.toolbarGroupCycling;
+
+ toolbarGroupCycling = toolbarGroupCycling === undefined || toolbarGroupCycling;
+
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*/ }
+ case CKEDITOR.SHIFT + 9 : // SHIFT + TAB
+ // Cycle through the toolbars, starting from the one
+ // closest to the current item.
+ while ( !toolbar || !toolbar.items.length )
+ {
+ 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 ] );
+
+ // Look for the first item that accepts focus.
+ if ( toolbar.items.length )
+ {
+ item = toolbar.items[ endFlag ? ( toolbar.items.length - 1 ) : 0 ];
+ while ( item && !item.focus )
+ {
+ item = endFlag ? item.previous : item.next;
+
+ if ( !item )
+ toolbar = 0;
+ }
+ }
+ }
- // If available, just focus it, otherwise focus the
- // first one.
if ( item )
item.focus();
+
+ return false;
+
+ case rtl ? 37 : 39 : // RIGHT-ARROW
+ case 40 : // DOWN-ARROW
+ next = item;
+ do
+ {
+ // Look for the next item in the toolbar.
+ next = next.next;
+
+ // If it's the last item, cycle to the first one.
+ if ( !next && toolbarGroupCycling )
+ next = item.toolbar.items[ 0 ];
+ }
+ while ( next && !next.focus )
+
+ // If available, just focus it, otherwise focus the
+ // first one.
+ if ( next )
+ next.focus();
else
- editor.toolbox.focus();
+ // Send a TAB.
+ itemKeystroke( item, 9 );
return false;
- 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*/ }
+ 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 ( 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;
@@ -112,12 +170,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
editor.toolbox = new toolbox();
- var output = [ '
' : ' style="display:none">' );
+ // Sends the ARIA label.
+ output.push( '', editor.lang.toolbars, '' );
+
var toolbars = editor.toolbox.toolbars,
toolbar =
( editor.config.toolbar instanceof Array ) ?
@@ -127,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
@@ -137,9 +204,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( !row )
continue;
- var toolbarId = 'cke_' + CKEDITOR.tools.getNextNumber(),
- toolbarObj = { id : toolbarId, items : [] };
-
if ( groupStarted )
{
output.push( '
' );
@@ -152,37 +216,56 @@ 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 )
{
- output.push( '' );
+ output.push( '' );
groupStarted = 1;
}
}
@@ -222,7 +305,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
groupStarted = 0;
}
- output.push( '' );
+ if ( toolbarObj )
+ output.push( '' );
}
output.push( '' );
@@ -233,22 +317,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
function()
{
editor.execCommand( 'toolbarCollapse' );
- } );
+ });
+
+ editor.on( 'destroy', function () {
+ CKEDITOR.tools.removeFunction( collapserFn );
+ });
- var collapserId = 'cke_' + CKEDITOR.tools.getNextNumber();
+ var collapserId = CKEDITOR.tools.getNextId();
editor.addCommand( 'toolbarCollapse',
{
+ readOnly : 1,
exec : function( editor )
{
- var collapser = CKEDITOR.document.getById( collapserId );
- var toolbox = collapser.getPrevious();
- var contents = editor.getThemeSpace( 'contents' );
- var toolboxContainer = toolbox.getParent();
- var contentHeight = parseInt( contents.$.style.height, 10 );
- var previousHeight = toolboxContainer.$.offsetHeight;
-
- if ( toolbox.isVisible() )
+ var collapser = CKEDITOR.document.getById( collapserId ),
+ toolbox = collapser.getPrevious(),
+ contents = editor.getThemeSpace( 'contents' ),
+ toolboxContainer = toolbox.getParent(),
+ contentHeight = parseInt( contents.$.style.height, 10 ),
+ previousHeight = toolboxContainer.$.offsetHeight,
+ collapsed = !toolbox.isVisible();
+
+ if ( !collapsed )
{
toolbox.hide();
collapser.addClass( 'cke_toolbox_collapser_min' );
@@ -261,44 +351,73 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
collapser.setAttribute( 'title', editor.lang.toolbarCollapse );
}
+ // Update collapser symbol.
+ collapser.getFirst().setText( collapsed ?
+ '\u25B2' : // BLACK UP-POINTING TRIANGLE
+ '\u25C0' ); // BLACK LEFT-POINTING TRIANGLE
+
var dy = toolboxContainer.$.offsetHeight - previousHeight;
contents.setStyle( 'height', ( contentHeight - dy ) + 'px' );
+
+ editor.fire( 'resize' );
},
modes : { wysiwyg : 1, source : 1 }
} );
output.push( '' );
+ output.push( '" onclick="CKEDITOR.tools.callFunction(' + collapserFn + ')">',
+ '▲', // BLACK UP-POINTING TRIANGLE
+ '' );
}
event.data.html += output.join( '' );
}
});
+ 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,
@@ -343,38 +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'],
- * ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
- * ['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'],
- ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
- ['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' ] }
];
/**
@@ -413,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;
+ */