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