2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\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
24 * The following properties and methods must be implemented when inheriting from
\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
31 var FCKToolbarSpecialCombo = function()
\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
42 FCKToolbarSpecialCombo.prototype.DefaultLabel = '' ;
\r
44 function FCKToolbarSpecialCombo_OnSelect( itemId, item )
\r
46 FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ;
\r
49 FCKToolbarSpecialCombo.prototype.Create = function( targetElement )
\r
51 this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ;
\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
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
64 this.CreateItems( this._Combo ) ;
\r
66 this._Combo.Create( targetElement ) ;
\r
68 this._Combo.CommandName = this.CommandName ;
\r
70 this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ;
\r
73 function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value )
\r
75 combo.DeselectAll() ;
\r
76 combo.SelectItem( value ) ;
\r
77 combo.SetLabelById( value ) ;
\r
80 FCKToolbarSpecialCombo.prototype.RefreshState = function()
\r
82 // Gets the actual state.
\r
85 // if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )
\r
86 // eState = FCK_TRISTATE_DISABLED ;
\r
89 var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;
\r
91 // FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ;
\r
93 if ( sValue != FCK_TRISTATE_DISABLED )
\r
95 eState = FCK_TRISTATE_ON ;
\r
97 if ( this.RefreshActiveItems )
\r
98 this.RefreshActiveItems( this._Combo, sValue ) ;
\r
101 if ( this._LastValue !== sValue)
\r
103 this._LastValue = sValue ;
\r
105 if ( !sValue || sValue.length == 0 )
\r
107 this._Combo.DeselectAll() ;
\r
108 this._Combo.SetLabel( this.DefaultLabel ) ;
\r
111 FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ;
\r
116 eState = FCK_TRISTATE_DISABLED ;
\r
119 // If there are no state changes then do nothing and return.
\r
120 if ( eState == this.State ) return ;
\r
122 if ( eState == FCK_TRISTATE_DISABLED )
\r
124 this._Combo.DeselectAll() ;
\r
125 this._Combo.SetLabel( '' ) ;
\r
128 // Sets the actual state.
\r
129 this.State = eState ;
\r
131 // Updates the graphical state.
\r
132 this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ;
\r
135 FCKToolbarSpecialCombo.prototype.Enable = function()
\r
137 this.RefreshState() ;
\r
140 FCKToolbarSpecialCombo.prototype.Disable = function()
\r
142 this.State = FCK_TRISTATE_DISABLED ;
\r
143 this._Combo.DeselectAll() ;
\r
144 this._Combo.SetLabel( '' ) ;
\r
145 this._Combo.SetEnabled( false ) ;
\r