source: extensions/FCKEditor/editor/_source/classes/fcktoolbarspecialcombo.js @ 3295

Last change on this file since 3295 was 3295, checked in by patdenice, 15 years ago

New extension added:
FCK Editor (2.0.a)

File size: 4.2 KB
Line 
1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2009 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
31var FCKToolbarSpecialCombo = function()
32{
33        this.SourceView                 = false ;
34        this.ContextSensitive   = true ;
35        this.FieldWidth                 = null ;
36        this.PanelWidth                 = null ;
37        this.PanelMaxHeight             = null ;
38        //this._LastValue                       = null ;
39}
40
41
42FCKToolbarSpecialCombo.prototype.DefaultLabel = '' ;
43
44function FCKToolbarSpecialCombo_OnSelect( itemId, item )
45{
46        FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Execute( itemId, item ) ;
47}
48
49FCKToolbarSpecialCombo.prototype.Create = function( targetElement )
50{
51        this._Combo = new FCKSpecialCombo( this.GetLabel(), this.FieldWidth, this.PanelWidth, this.PanelMaxHeight, FCKBrowserInfo.IsIE ? window : FCKTools.GetElementWindow( targetElement ).parent ) ;
52
53        /*
54        this._Combo.FieldWidth          = this.FieldWidth               != null ? this.FieldWidth               : 100 ;
55        this._Combo.PanelWidth          = this.PanelWidth               != null ? this.PanelWidth               : 150 ;
56        this._Combo.PanelMaxHeight      = this.PanelMaxHeight   != null ? this.PanelMaxHeight   : 150 ;
57        */
58
59        //this._Combo.Command.Name = this.Command.Name;
60//      this._Combo.Label       = this.Label ;
61        this._Combo.Tooltip     = this.Tooltip ;
62        this._Combo.Style       = this.Style ;
63
64        this.CreateItems( this._Combo ) ;
65
66        this._Combo.Create( targetElement ) ;
67
68        this._Combo.CommandName = this.CommandName ;
69
70        this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ;
71}
72
73function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value )
74{
75        combo.DeselectAll() ;
76        combo.SelectItem( value ) ;
77        combo.SetLabelById( value ) ;
78}
79
80FCKToolbarSpecialCombo.prototype.RefreshState = function()
81{
82        // Gets the actual state.
83        var eState ;
84
85//      if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )
86//              eState = FCK_TRISTATE_DISABLED ;
87//      else
88//      {
89                var sValue = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetState() ;
90
91//              FCKDebug.Output( 'RefreshState of Special Combo "' + this.TypeOf + '" - State: ' + sValue ) ;
92
93                if ( sValue != FCK_TRISTATE_DISABLED )
94                {
95                        eState = FCK_TRISTATE_ON ;
96
97                        if ( this.RefreshActiveItems )
98                                this.RefreshActiveItems( this._Combo, sValue ) ;
99                        else
100                        {
101                                if ( this._LastValue !== sValue)
102                                {
103                                        this._LastValue = sValue ;
104
105                                        if ( !sValue || sValue.length == 0 )
106                                        {
107                                                this._Combo.DeselectAll() ;
108                                                this._Combo.SetLabel( this.DefaultLabel ) ;
109                                        }
110                                        else
111                                                FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ;
112                                }
113                        }
114                }
115                else
116                        eState = FCK_TRISTATE_DISABLED ;
117//      }
118
119        // If there are no state changes then do nothing and return.
120        if ( eState == this.State ) return ;
121
122        if ( eState == FCK_TRISTATE_DISABLED )
123        {
124                this._Combo.DeselectAll() ;
125                this._Combo.SetLabel( '' ) ;
126        }
127
128        // Sets the actual state.
129        this.State = eState ;
130
131        // Updates the graphical state.
132        this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ;
133}
134
135FCKToolbarSpecialCombo.prototype.Enable = function()
136{
137        this.RefreshState() ;
138}
139
140FCKToolbarSpecialCombo.prototype.Disable = function()
141{
142        this.State = FCK_TRISTATE_DISABLED ;
143        this._Combo.DeselectAll() ;
144        this._Combo.SetLabel( '' ) ;
145        this._Combo.SetEnabled( false ) ;
146}
Note: See TracBrowser for help on using the repository browser.