import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fcktoolbarspecialcombo.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  * FCKToolbarSpecialCombo Class: This is a "abstract" base class to be used\r
22  * by the special combo toolbar elements like font name, font size, paragraph format, etc...\r
23  *\r
24  * The following properties and methods must be implemented when inheriting from\r
25  * this class:\r
26  *      - Property:     CommandName                                                     [ The command name to be executed ]\r
27  *      - Method:       GetLabel()                                                      [ Returns the label ]\r
28  *      -                       CreateItems( targetSpecialCombo )       [ Add all items in the special combo ]\r
29  */\r
30 \r
31 var FCKToolbarSpecialCombo = function()\r
32 {\r
33         this.SourceView                 = false ;\r
34         this.ContextSensitive   = true ;\r
35         this.FieldWidth                 = null ;\r
36         this.PanelWidth                 = null ;\r
37         this.PanelMaxHeight             = null ;\r
38         //this._LastValue                       = null ;\r
39 }\r
40 \r
41 \r
42 FCKToolbarSpecialCombo.prototype.DefaultLabel = '' ;\r
43 \r
44 function FCKToolbarSpecialCombo_OnSelect( itemId, item )\r
45 {\r
46         FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ;\r
47 }\r
48 \r
49 FCKToolbarSpecialCombo.prototype.Create = function( targetElement )\r
50 {\r
51         this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ;\r
52 \r
53         /*\r
54         this._Combo.FieldWidth          = this.FieldWidth               != null ? this.FieldWidth               : 100 ;\r
55         this._Combo.PanelWidth          = this.PanelWidth               != null ? this.PanelWidth               : 150 ;\r
56         this._Combo.PanelMaxHeight      = this.PanelMaxHeight   != null ? this.PanelMaxHeight   : 150 ;\r
57         */\r
58 \r
59         //this._Combo.Command.Name = this.Command.Name;\r
60 //      this._Combo.Label       = this.Label ;\r
61         this._Combo.Tooltip     = this.Tooltip ;\r
62         this._Combo.Style       = this.Style ;\r
63 \r
64         this.CreateItems( this._Combo ) ;\r
65 \r
66         this._Combo.Create( targetElement ) ;\r
67 \r
68         this._Combo.CommandName = this.CommandName ;\r
69 \r
70         this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ;\r
71 }\r
72 \r
73 function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value )\r
74 {\r
75         combo.DeselectAll() ;\r
76         combo.SelectItem( value ) ;\r
77         combo.SetLabelById( value ) ;\r
78 }\r
79 \r
80 FCKToolbarSpecialCombo.prototype.RefreshState = function()\r
81 {\r
82         // Gets the actual state.\r
83         var eState ;\r
84 \r
85 //      if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )\r
86 //              eState = FCK_TRISTATE_DISABLED ;\r
87 //      else\r
88 //      {\r
89                 var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;\r
90 \r
91 //              FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ;\r
92 \r
93                 if ( sValue != FCK_TRISTATE_DISABLED )\r
94                 {\r
95                         eState = FCK_TRISTATE_ON ;\r
96 \r
97                         if ( this.RefreshActiveItems )\r
98                                 this.RefreshActiveItems( this._Combo, sValue ) ;\r
99                         else\r
100                         {\r
101                                 if ( this._LastValue !== sValue)\r
102                                 {\r
103                                         this._LastValue = sValue ;\r
104 \r
105                                         if ( !sValue || sValue.length == 0 )\r
106                                         {\r
107                                                 this._Combo.DeselectAll() ;\r
108                                                 this._Combo.SetLabel( this.DefaultLabel ) ;\r
109                                         }\r
110                                         else\r
111                                                 FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ;\r
112                                 }\r
113                         }\r
114                 }\r
115                 else\r
116                         eState = FCK_TRISTATE_DISABLED ;\r
117 //      }\r
118 \r
119         // If there are no state changes then do nothing and return.\r
120         if ( eState == this.State ) return ;\r
121 \r
122         if ( eState == FCK_TRISTATE_DISABLED )\r
123         {\r
124                 this._Combo.DeselectAll() ;\r
125                 this._Combo.SetLabel( '' ) ;\r
126         }\r
127 \r
128         // Sets the actual state.\r
129         this.State = eState ;\r
130 \r
131         // Updates the graphical state.\r
132         this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ;\r
133 }\r
134 \r
135 FCKToolbarSpecialCombo.prototype.Enable = function()\r
136 {\r
137         this.RefreshState() ;\r
138 }\r
139 \r
140 FCKToolbarSpecialCombo.prototype.Disable = function()\r
141 {\r
142         this.State = FCK_TRISTATE_DISABLED ;\r
143         this._Combo.DeselectAll() ;\r
144         this._Combo.SetLabel( '' ) ;\r
145         this._Combo.SetEnabled( false ) ;\r
146 }\r