1 | /* |
---|
2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net |
---|
3 | * Copyright (C) 2003-2007 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * == BEGIN LICENSE == |
---|
6 | * |
---|
7 | * Licensed under the terms of any of the following licenses at your |
---|
8 | * choice: |
---|
9 | * |
---|
10 | * - GNU General Public License Version 2 or later (the "GPL") |
---|
11 | * http://www.gnu.org/licenses/gpl.html |
---|
12 | * |
---|
13 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
---|
14 | * http://www.gnu.org/licenses/lgpl.html |
---|
15 | * |
---|
16 | * - Mozilla Public License Version 1.1 or later (the "MPL") |
---|
17 | * http://www.mozilla.org/MPL/MPL-1.1.html |
---|
18 | * |
---|
19 | * == END LICENSE == |
---|
20 | * |
---|
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... |
---|
23 | * |
---|
24 | * The following properties and methods must be implemented when inheriting from |
---|
25 | * this class: |
---|
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 ] |
---|
29 | */ |
---|
30 | |
---|
31 | var FCKToolbarSpecialCombo = function() |
---|
32 | { |
---|
33 | this.SourceView = false ; |
---|
34 | this.ContextSensitive = true ; |
---|
35 | this._LastValue = null ; |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | function FCKToolbarSpecialCombo_OnSelect( itemId, item ) |
---|
40 | { |
---|
41 | FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ; |
---|
42 | } |
---|
43 | |
---|
44 | FCKToolbarSpecialCombo.prototype.Create = function( targetElement ) |
---|
45 | { |
---|
46 | this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ; |
---|
47 | |
---|
48 | /* |
---|
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 ; |
---|
52 | */ |
---|
53 | |
---|
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 ; |
---|
58 | |
---|
59 | this.CreateItems( this._Combo ) ; |
---|
60 | |
---|
61 | this._Combo.Create( targetElement ) ; |
---|
62 | |
---|
63 | this._Combo.CommandName = this.CommandName ; |
---|
64 | |
---|
65 | this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ; |
---|
66 | } |
---|
67 | |
---|
68 | function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value ) |
---|
69 | { |
---|
70 | combo.DeselectAll() ; |
---|
71 | combo.SelectItem( value ) ; |
---|
72 | combo.SetLabelById( value ) ; |
---|
73 | } |
---|
74 | |
---|
75 | FCKToolbarSpecialCombo.prototype.RefreshState = function() |
---|
76 | { |
---|
77 | // Gets the actual state. |
---|
78 | var eState ; |
---|
79 | |
---|
80 | // if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView ) |
---|
81 | // eState = FCK_TRISTATE_DISABLED ; |
---|
82 | // else |
---|
83 | // { |
---|
84 | var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ; |
---|
85 | |
---|
86 | // FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ; |
---|
87 | |
---|
88 | if ( sValue != FCK_TRISTATE_DISABLED ) |
---|
89 | { |
---|
90 | eState = FCK_TRISTATE_ON ; |
---|
91 | |
---|
92 | if ( this.RefreshActiveItems ) |
---|
93 | this.RefreshActiveItems( this._Combo, sValue ) ; |
---|
94 | else |
---|
95 | { |
---|
96 | if ( this._LastValue != sValue ) |
---|
97 | { |
---|
98 | this._LastValue = sValue ; |
---|
99 | FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ; |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | else |
---|
104 | eState = FCK_TRISTATE_DISABLED ; |
---|
105 | // } |
---|
106 | |
---|
107 | // If there are no state changes then do nothing and return. |
---|
108 | if ( eState == this.State ) return ; |
---|
109 | |
---|
110 | if ( eState == FCK_TRISTATE_DISABLED ) |
---|
111 | { |
---|
112 | this._Combo.DeselectAll() ; |
---|
113 | this._Combo.SetLabel( '' ) ; |
---|
114 | } |
---|
115 | |
---|
116 | // Sets the actual state. |
---|
117 | this.State = eState ; |
---|
118 | |
---|
119 | // Updates the graphical state. |
---|
120 | this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ; |
---|
121 | } |
---|
122 | |
---|
123 | FCKToolbarSpecialCombo.prototype.Enable = function() |
---|
124 | { |
---|
125 | this.RefreshState() ; |
---|
126 | } |
---|
127 | |
---|
128 | FCKToolbarSpecialCombo.prototype.Disable = function() |
---|
129 | { |
---|
130 | this.State = FCK_TRISTATE_DISABLED ; |
---|
131 | this._Combo.DeselectAll() ; |
---|
132 | this._Combo.SetLabel( '' ) ; |
---|
133 | this._Combo.SetEnabled( false ) ; |
---|
134 | } |
---|