1 /*
  2 Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
  3 For licensing, see LICENSE.html or http://ckeditor.com/license
  4 */
  5 
  6 CKEDITOR.plugins.add( 'basicstyles',
  7 {
  8 	requires : [ 'styles', 'button' ],
  9 
 10 	init : function( editor )
 11 	{
 12 		// All buttons use the same code to register. So, to avoid
 13 		// duplications, let's use this tool function.
 14 		var addButtonCommand = function( buttonName, buttonLabel, commandName, styleDefiniton )
 15 		{
 16 			var style = new CKEDITOR.style( styleDefiniton );
 17 
 18 			editor.attachStyleStateChange( style, function( state )
 19 				{
 20 					!editor.readOnly && editor.getCommand( commandName ).setState( state );
 21 				});
 22 
 23 			editor.addCommand( commandName, new CKEDITOR.styleCommand( style ) );
 24 
 25 			editor.ui.addButton( buttonName,
 26 				{
 27 					label : buttonLabel,
 28 					command : commandName
 29 				});
 30 		};
 31 
 32 		var config = editor.config,
 33 			lang = editor.lang;
 34 
 35 		addButtonCommand( 'Bold'		, lang.bold		, 'bold'		, config.coreStyles_bold );
 36 		addButtonCommand( 'Italic'		, lang.italic		, 'italic'		, config.coreStyles_italic );
 37 		addButtonCommand( 'Underline'	, lang.underline		, 'underline'	, config.coreStyles_underline );
 38 		addButtonCommand( 'Strike'		, lang.strike		, 'strike'		, config.coreStyles_strike );
 39 		addButtonCommand( 'Subscript'	, lang.subscript		, 'subscript'	, config.coreStyles_subscript );
 40 		addButtonCommand( 'Superscript'	, lang.superscript		, 'superscript'	, config.coreStyles_superscript );
 41 	}
 42 });
 43 
 44 // Basic Inline Styles.
 45 
 46 /**
 47  * The style definition that applies the <strong>bold</strong> style to the text.
 48  * @type Object
 49  * @default <code>{ element : 'strong', overrides : 'b' }</code>
 50  * @example
 51  * config.coreStyles_bold = { element : 'b', overrides : 'strong' };
 52  * @example
 53  * config.coreStyles_bold =
 54  *     {
 55  *         element : 'span',
 56  *         attributes : { 'class' : 'Bold' }
 57  *     };
 58  */
 59 CKEDITOR.config.coreStyles_bold = { element : 'strong', overrides : 'b' };
 60 
 61 /**
 62  * The style definition that applies the <em>italics</em> style to the text.
 63  * @type Object
 64  * @default <code>{ element : 'em', overrides : 'i' }</code>
 65  * @example
 66  * config.coreStyles_italic = { element : 'i', overrides : 'em' };
 67  * @example
 68  * CKEDITOR.config.coreStyles_italic =
 69  *     {
 70  *         element : 'span',
 71  *         attributes : { 'class' : 'Italic' }
 72  *     };
 73  */
 74 CKEDITOR.config.coreStyles_italic = { element : 'em', overrides : 'i' };
 75 
 76 /**
 77  * The style definition that applies the <u>underline</u> style to the text.
 78  * @type Object
 79  * @default <code>{ element : 'u' }</code>
 80  * @example
 81  * CKEDITOR.config.coreStyles_underline =
 82  *     {
 83  *         element : 'span',
 84  *         attributes : { 'class' : 'Underline' }
 85  *     };
 86  */
 87 CKEDITOR.config.coreStyles_underline = { element : 'u' };
 88 
 89 /**
 90  * The style definition that applies the <strike>strike-through</strike> style to the text.
 91  * @type Object
 92  * @default <code>{ element : 'strike' }</code>
 93  * @example
 94  * CKEDITOR.config.coreStyles_strike =
 95  *     {
 96  *         element : 'span',
 97  *         attributes : { 'class' : 'StrikeThrough' },
 98  *         overrides : 'strike'
 99  *     };
100  */
101 CKEDITOR.config.coreStyles_strike = { element : 'strike' };
102 
103 /**
104  * The style definition that applies the subscript style to the text.
105  * @type Object
106  * @default <code>{ element : 'sub' }</code>
107  * @example
108  * CKEDITOR.config.coreStyles_subscript =
109  *     {
110  *         element : 'span',
111  *         attributes : { 'class' : 'Subscript' },
112  *         overrides : 'sub'
113  *     };
114  */
115 CKEDITOR.config.coreStyles_subscript = { element : 'sub' };
116 
117 /**
118  * The style definition that applies the superscript style to the text.
119  * @type Object
120  * @default <code>{ element : 'sup' }</code>
121  * @example
122  * CKEDITOR.config.coreStyles_superscript =
123  *     {
124  *         element : 'span',
125  *         attributes : { 'class' : 'Superscript' },
126  *         overrides : 'sup'
127  *     };
128  */
129 CKEDITOR.config.coreStyles_superscript = { element : 'sup' };
130