import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fcktoolbarbutton.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  * FCKToolbarButton Class: represents a button in the toolbar.\r
22  */\r
23 \r
24 var FCKToolbarButton = function( commandName, label, tooltip, style, sourceView, contextSensitive, icon )\r
25 {\r
26         this.CommandName                = commandName ;\r
27         this.Label                              = label ;\r
28         this.Tooltip                    = tooltip ;\r
29         this.Style                              = style ;\r
30         this.SourceView                 = sourceView ? true : false ;\r
31         this.ContextSensitive   = contextSensitive ? true : false ;\r
32 \r
33         if ( icon == null )\r
34                 this.IconPath = FCKConfig.SkinPath + 'toolbar/' + commandName.toLowerCase() + '.gif' ;\r
35         else if ( typeof( icon ) == 'number' )\r
36                 this.IconPath = [ FCKConfig.SkinPath + 'fck_strip.gif', 16, icon ] ;\r
37         else\r
38                 this.IconPath = icon ;\r
39 }\r
40 \r
41 FCKToolbarButton.prototype.Create = function( targetElement )\r
42 {\r
43         this._UIButton = new FCKToolbarButtonUI( this.CommandName, this.Label, this.Tooltip, this.IconPath, this.Style ) ;\r
44         this._UIButton.OnClick = this.Click ;\r
45         this._UIButton._ToolbarButton = this ;\r
46         this._UIButton.Create( targetElement ) ;\r
47 }\r
48 \r
49 FCKToolbarButton.prototype.RefreshState = function()\r
50 {\r
51         var uiButton = this._UIButton ;\r
52 \r
53         if ( !uiButton )\r
54                 return ;\r
55 \r
56         // Gets the actual state.\r
57         var eState = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;\r
58 \r
59         // If there are no state changes than do nothing and return.\r
60         if ( eState == uiButton.State ) return ;\r
61 \r
62         // Sets the actual state.\r
63         uiButton.ChangeState( eState ) ;\r
64 }\r
65 \r
66 FCKToolbarButton.prototype.Click = function()\r
67 {\r
68         var oToolbarButton = this._ToolbarButton || this ;\r
69         FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( oToolbarButton.CommandName ).Execute() ;\r
70 }\r
71 \r
72 FCKToolbarButton.prototype.Enable = function()\r
73 {\r
74         this.RefreshState() ;\r
75 }\r
76 \r
77 FCKToolbarButton.prototype.Disable = function()\r
78 {\r
79         // Sets the actual state.\r
80         this._UIButton.ChangeState( FCK_TRISTATE_DISABLED ) ;\r
81 }\r