1 /* 2 * CKEditor - The text editor for Internet - http://ckeditor.com 3 * Copyright (C) 2003-2008 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 */ 21 22 /** 23 * @fileOverview The "toolbar" plugin. Renders the default toolbar interface in 24 * the editor. 25 */ 26 27 CKEDITOR.plugins.add( 'toolbar', 28 { 29 init : function( editor, pluginPath ) 30 { 31 editor.on( 'themeSpace', function( event ) 32 { 33 if ( event.data.space == editor.config.toolbarLocation ) 34 { 35 var output = [ '<div class="cke_toolbox">' ]; 36 37 var toolbar = editor.config.toolbar; 38 39 for ( var r = 0 ; r < toolbar.length ; r++ ) 40 { 41 var row = toolbar[ r ]; 42 43 output.push( '<div class="cke_toolbar">' ); 44 45 for ( var i = 0 ; i < row.length ; i++ ) 46 { 47 var item, 48 itemName = row[ i ]; 49 50 if ( itemName == '-' ) 51 item = CKEDITOR.ui.separator; 52 else 53 item = editor.ui.get( row[ i ] ); 54 55 if ( item ) 56 item.render( editor, output ); 57 } 58 59 output.push( '</div>' ); 60 } 61 62 output.push( '</div>' ); 63 64 event.data.html += output.join( '' ); 65 } 66 }); 67 } 68 }); 69 70 /** 71 * The UI element that renders a toolbar separator. 72 * @type Object 73 * @example 74 */ 75 CKEDITOR.ui.separator = 76 { 77 render : function( editor, output ) 78 { 79 output.push( '<span class="cke_separator"></span>' ); 80 } 81 }; 82 83 /** 84 * The "theme space" to which rendering the toolbar. For the default theme, 85 * the recommended options are "top" and "bottom". 86 * @type String 87 * @default 'top' 88 * @see CKEDITOR.config.theme 89 * @example 90 * config.toolbarLocation = 'bottom'; 91 */ 92 CKEDITOR.config.toolbarLocation = 'top'; 93 94 /** 95 * The toolbox (alias toolbar) definition. It is an array of toolbars (strips), 96 * each one being also an array, containing a list of UI items. 97 * @type Array 98 * @example 99 * // Defines a toolbar with only one strip containing the "Source" button, a 100 * // separator and the "Bold" and "Italic" buttons. 101 * <b>CKEDITOR.config.toolbar = 102 * [ 103 * [ 'Source', '-', 'Bold', 'Italic' ] 104 * ]</b>; 105 */ 106 CKEDITOR.config.toolbar = 107 [ 108 [ 'Source', '-', 'Bold', 'Italic' ] 109 ]; 110