2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* FCKToolbarSpecialCombo Class: This is a "abstract" base class to be used
22
* by the special combo toolbar elements like font name, font size, paragraph format, etc...
24
* The following properties and methods must be implemented when inheriting from
26
* - Property: CommandName [ The command name to be executed ]
27
* - Method: GetLabel() [ Returns the label ]
28
* - CreateItems( targetSpecialCombo ) [ Add all items in the special combo ]
31
var FCKToolbarSpecialCombo = function()
33
this.SourceView = false ;
34
this.ContextSensitive = true ;
35
this._LastValue = null ;
39
function FCKToolbarSpecialCombo_OnSelect( itemId, item )
41
FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ;
44
FCKToolbarSpecialCombo.prototype.Create = function( targetElement )
46
this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ;
49
this._Combo.FieldWidth = this.FieldWidth != null ? this.FieldWidth : 100 ;
50
this._Combo.PanelWidth = this.PanelWidth != null ? this.PanelWidth : 150 ;
51
this._Combo.PanelMaxHeight = this.PanelMaxHeight != null ? this.PanelMaxHeight : 150 ;
54
//this._Combo.Command.Name = this.Command.Name;
55
// this._Combo.Label = this.Label ;
56
this._Combo.Tooltip = this.Tooltip ;
57
this._Combo.Style = this.Style ;
59
this.CreateItems( this._Combo ) ;
61
this._Combo.Create( targetElement ) ;
63
this._Combo.CommandName = this.CommandName ;
65
this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ;
68
function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value )
71
combo.SelectItem( value ) ;
72
combo.SetLabelById( value ) ;
75
FCKToolbarSpecialCombo.prototype.RefreshState = function()
77
// Gets the actual state.
80
// if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )
81
// eState = FCK_TRISTATE_DISABLED ;
84
var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;
86
// FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ;
88
if ( sValue != FCK_TRISTATE_DISABLED )
90
eState = FCK_TRISTATE_ON ;
92
if ( this.RefreshActiveItems )
93
this.RefreshActiveItems( this._Combo, sValue ) ;
96
if ( this._LastValue != sValue )
98
this._LastValue = sValue ;
99
FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ;
104
eState = FCK_TRISTATE_DISABLED ;
107
// If there are no state changes then do nothing and return.
108
if ( eState == this.State ) return ;
110
if ( eState == FCK_TRISTATE_DISABLED )
112
this._Combo.DeselectAll() ;
113
this._Combo.SetLabel( '' ) ;
116
// Sets the actual state.
117
this.State = eState ;
119
// Updates the graphical state.
120
this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ;
123
FCKToolbarSpecialCombo.prototype.Enable = function()
125
this.RefreshState() ;
128
FCKToolbarSpecialCombo.prototype.Disable = function()
130
this.State = FCK_TRISTATE_DISABLED ;
131
this._Combo.DeselectAll() ;
132
this._Combo.SetLabel( '' ) ;
133
this._Combo.SetEnabled( false ) ;