JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
0b2f25e185f7f593843a7cf7f109715bb34e2aca
[ckeditor.git] / _source / plugins / basicstyles / plugin.js
1 /*\r
2 Copyright (c) 2003-2010, 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.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                 var 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 to be used to apply the bold style in the text.\r
48  * @type Object\r
49  * @example\r
50  * config.coreStyles_bold = { element : 'b', overrides : 'strong' };\r
51  * @example\r
52  * config.coreStyles_bold = { element : 'span', attributes : {'class': 'Bold'} };\r
53  */\r
54 CKEDITOR.config.coreStyles_bold = { element : 'strong', overrides : 'b' };\r
55 \r
56 /**\r
57  * The style definition to be used to apply the italic style in the text.\r
58  * @type Object\r
59  * @default { element : 'em', overrides : 'i' }\r
60  * @example\r
61  * config.coreStyles_italic = { element : 'i', overrides : 'em' };\r
62  * @example\r
63  * CKEDITOR.config.coreStyles_italic = { element : 'span', attributes : {'class': 'Italic'} };\r
64  */\r
65 CKEDITOR.config.coreStyles_italic = { element : 'em', overrides : 'i' };\r
66 \r
67 /**\r
68  * The style definition to be used to apply the underline style in the text.\r
69  * @type Object\r
70  * @default { element : 'u' }\r
71  * @example\r
72  * CKEDITOR.config.coreStyles_underline = { element : 'span', attributes : {'class': 'Underline'}};\r
73  */\r
74 CKEDITOR.config.coreStyles_underline = { element : 'u' };\r
75 \r
76 /**\r
77  * The style definition to be used to apply the strike style in the text.\r
78  * @type Object\r
79  * @default { element : 'strike' }\r
80  * @example\r
81  * CKEDITOR.config.coreStyles_strike = { element : 'span', attributes : {'class': 'StrikeThrough'}, overrides : 'strike' };\r
82  */\r
83 CKEDITOR.config.coreStyles_strike = { element : 'strike' };\r
84 \r
85 /**\r
86  * The style definition to be used to apply the subscript style in the text.\r
87  * @type Object\r
88  * @default { element : 'sub' }\r
89  * @example\r
90  * CKEDITOR.config.coreStyles_subscript = { element : 'span', attributes : {'class': 'Subscript'}, overrides : 'sub' };\r
91  */\r
92 CKEDITOR.config.coreStyles_subscript = { element : 'sub' };\r
93 \r
94 /**\r
95  * The style definition to be used to apply the superscript style in the text.\r
96  * @type Object\r
97  * @default { element : 'sup' }\r
98  * @example\r
99  * CKEDITOR.config.coreStyles_superscript = { element : 'span', attributes : {'class': 'Superscript'}, overrides : 'sup' };\r
100  */\r
101 CKEDITOR.config.coreStyles_superscript = { element : 'sup' };\r