import torrus 1.0.9
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / commandclasses / fckcorestylecommand.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  * FCKCoreStyleCommand Class: controls the execution of a core style. Core\r
22  * styles are usually represented as buttons in the toolbar., like Bold and\r
23  * Italic.\r
24  */\r
25 \r
26  var FCKCoreStyleCommand = function( coreStyleName )\r
27  {\r
28         this.Name = 'CoreStyle' ;\r
29         this.StyleName = '_FCK_' + coreStyleName ;\r
30         this.IsActive = false ;\r
31 \r
32         FCKStyles.AttachStyleStateChange( this.StyleName, this._OnStyleStateChange, this ) ;\r
33  }\r
34 \r
35  FCKCoreStyleCommand.prototype =\r
36  {\r
37         Execute : function()\r
38         {\r
39                 FCKUndo.SaveUndoStep() ;\r
40 \r
41                 if ( this.IsActive )\r
42                         FCKStyles.RemoveStyle( this.StyleName ) ;\r
43                 else\r
44                         FCKStyles.ApplyStyle( this.StyleName ) ;\r
45 \r
46                 FCK.Focus() ;\r
47                 FCK.Events.FireEvent( 'OnSelectionChange' ) ;\r
48         },\r
49 \r
50         GetState : function()\r
51         {\r
52                 if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )\r
53                         return FCK_TRISTATE_DISABLED ;\r
54                 return this.IsActive ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF ;\r
55         },\r
56 \r
57         _OnStyleStateChange : function( styleName, isActive )\r
58         {\r
59                 this.IsActive = isActive ;\r
60         }\r
61  };\r