import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / commandclasses / fckstylecommand.js
1 /*\r
2  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
3  * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
4  *\r
5  * == BEGIN LICENSE ==\r
6  *\r
7  * Licensed under the terms of any of the following licenses at your\r
8  * choice:\r
9  *\r
10  *  - GNU General Public License Version 2 or later (the "GPL")\r
11  *    http://www.gnu.org/licenses/gpl.html\r
12  *\r
13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
14  *    http://www.gnu.org/licenses/lgpl.html\r
15  *\r
16  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
17  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
18  *\r
19  * == END LICENSE ==\r
20  *\r
21  * FCKStyleCommand Class: represents the "Style" command.\r
22  */\r
23 \r
24 var FCKStyleCommand = function()\r
25 {}\r
26 \r
27 FCKStyleCommand.prototype =\r
28 {\r
29         Name : 'Style',\r
30 \r
31         Execute : function( styleName, styleComboItem )\r
32         {\r
33                 FCKUndo.SaveUndoStep() ;\r
34 \r
35                 if ( styleComboItem.Selected )\r
36                         FCK.Styles.RemoveStyle( styleComboItem.Style ) ;\r
37                 else\r
38                         FCK.Styles.ApplyStyle( styleComboItem.Style ) ;\r
39 \r
40                 FCKUndo.SaveUndoStep() ;\r
41 \r
42                 FCK.Focus() ;\r
43                 FCK.Events.FireEvent( 'OnSelectionChange' ) ;\r
44         },\r
45 \r
46         GetState : function()\r
47         {\r
48                 if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || !FCK.EditorDocument )\r
49                         return FCK_TRISTATE_DISABLED ;\r
50 \r
51                 if ( FCKSelection.GetType() == 'Control' )\r
52                 {\r
53                         var el = FCKSelection.GetSelectedElement() ;\r
54                         if ( !el || !FCKStyles.CheckHasObjectStyle( el.nodeName.toLowerCase() ) )\r
55                                 return FCK_TRISTATE_DISABLED ;\r
56                 }\r
57 \r
58                 return FCK_TRISTATE_OFF ;\r
59         }\r
60 };\r