source: trunk/admin/inc/FCKeditor/editor/_source/classes/fcktoolbarspecialcombo.js@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 3.7 KB
Line 
1/*
2 * FCKeditor - The text editor for internet
3 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
4 *
5 * Licensed under the terms of the GNU Lesser General Public License:
6 * http://www.opensource.org/licenses/lgpl-license.php
7 *
8 * For further information visit:
9 * http://www.fckeditor.net/
10 *
11 * "Support Open Source software. What about a donation today?"
12 *
13 * File Name: fcktoolbarspecialcombo.js
14 * FCKToolbarSpecialCombo Class: This is a "abstract" base class to be used
15 * by the special combo toolbar elements like font name, font size, paragraph format, etc...
16 *
17 * The following properties and methods must be implemented when inheriting from
18 * this class:
19 * - Property: CommandName [ The command name to be executed ]
20 * - Method: GetLabel() [ Returns the label ]
21 * - CreateItems( targetSpecialCombo ) [ Add all items in the special combo ]
22 *
23 * File Authors:
24 * Frederico Caldeira Knabben (fredck@fckeditor.net)
25 */
26
27var FCKToolbarSpecialCombo = function()
28{
29 this.SourceView = false ;
30 this.ContextSensitive = true ;
31}
32
33
34function FCKToolbarSpecialCombo_OnSelect( itemId, item )
35{
36 FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ;
37}
38
39FCKToolbarSpecialCombo.prototype.Create = function( targetElement )
40{
41 this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ;
42
43 /*
44 this._Combo.FieldWidth = this.FieldWidth != null ? this.FieldWidth : 100 ;
45 this._Combo.PanelWidth = this.PanelWidth != null ? this.PanelWidth : 150 ;
46 this._Combo.PanelMaxHeight = this.PanelMaxHeight != null ? this.PanelMaxHeight : 150 ;
47 */
48
49 //this._Combo.Command.Name = this.Command.Name;
50// this._Combo.Label = this.Label ;
51 this._Combo.Tooltip = this.Tooltip ;
52 this._Combo.Style = this.Style ;
53
54 this.CreateItems( this._Combo ) ;
55
56 this._Combo.Create( targetElement ) ;
57
58 this._Combo.CommandName = this.CommandName ;
59
60 this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ;
61}
62
63function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value )
64{
65 combo.DeselectAll() ;
66 combo.SelectItem( value ) ;
67 combo.SetLabelById( value ) ;
68}
69
70FCKToolbarSpecialCombo.prototype.RefreshState = function()
71{
72 // Gets the actual state.
73 var eState ;
74
75// if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )
76// eState = FCK_TRISTATE_DISABLED ;
77// else
78// {
79 var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;
80
81// FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ;
82
83 if ( sValue != FCK_TRISTATE_DISABLED )
84 {
85 eState = FCK_TRISTATE_ON ;
86
87 if ( this.RefreshActiveItems )
88 this.RefreshActiveItems( this._Combo, sValue ) ;
89 else
90 {
91 if ( this._LastValue != sValue )
92 {
93 this._LastValue = sValue ;
94 FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ;
95 }
96 }
97 }
98 else
99 eState = FCK_TRISTATE_DISABLED ;
100// }
101
102 // If there are no state changes then do nothing and return.
103 if ( eState == this.State ) return ;
104
105 if ( eState == FCK_TRISTATE_DISABLED )
106 {
107 this._Combo.DeselectAll() ;
108 this._Combo.SetLabel( '' ) ;
109 }
110
111 // Sets the actual state.
112 this.State = eState ;
113
114 // Updates the graphical state.
115 this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ;
116}
117
118FCKToolbarSpecialCombo.prototype.Enable = function()
119{
120 this.RefreshState() ;
121}
122
123FCKToolbarSpecialCombo.prototype.Disable = function()
124{
125 this.State = FCK_TRISTATE_DISABLED ;
126 this._Combo.DeselectAll() ;
127 this._Combo.SetLabel( '' ) ;
128 this._Combo.SetEnabled( false ) ;
129}
Note: See TracBrowser for help on using the repository browser.