Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 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
 * File Name: fcktoolbarspecialcombo.js
12
 * 	FCKToolbarSpecialCombo Class: This is a "abstract" base class to be used
13
 * 	by the special combo toolbar elements like font name, font size, paragraph format, etc...
14
 *
15
 * 	The following properties and methods must be implemented when inheriting from
16
 * 	this class:
17
 * 		- Property:	Command								[ The command to be executed ]
18
 * 		- Method:	GetLabel()							[ Returns the label ]
19
 * 		-			CreateItems( targetSpecialCombo )	[ Add all items in the special combo ]
20
 *
21
 * File Authors:
22
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
23
 */
24
 
25
var FCKToolbarSpecialCombo = function()
26
{
27
	this.SourceView			= false ;
28
	this.ContextSensitive	= true ;
29
}
30
 
31
function FCKToolbarSpecialCombo_OnSelect( itemId, item )
32
{
33
	this.Command.Execute( itemId, item ) ;
34
}
35
 
36
FCKToolbarSpecialCombo.prototype.CreateInstance = function( parentToolbar )
37
{
38
	this._Combo = new FCKSpecialCombo( this.GetLabel() ) ;
39
	this._Combo.FieldWidth = 100 ;
40
	this._Combo.PanelWidth = 150 ;
41
	this._Combo.PanelMaxHeight = 150 ;
42
 
43
	this.CreateItems( this._Combo ) ;
44
 
45
	this._Combo.Create( parentToolbar.DOMRow.insertCell(-1) ) ;
46
 
47
	this._Combo.Command = this.Command ;
48
 
49
	this._Combo.OnSelect = FCKToolbarSpecialCombo_OnSelect ;
50
}
51
 
52
function FCKToolbarSpecialCombo_RefreshActiveItems( combo, value )
53
{
54
	combo.DeselectAll() ;
55
	combo.SelectItem( value ) ;
56
	combo.SetLabelById( value ) ;
57
}
58
 
59
FCKToolbarSpecialCombo.prototype.RefreshState = function()
60
{
61
	// Gets the actual state.
62
	var eState ;
63
 
64
//	if ( FCK.EditMode == FCK_EDITMODE_SOURCE && ! this.SourceView )
65
//		eState = FCK_TRISTATE_DISABLED ;
66
//	else
67
//	{
68
		var sValue = this.Command.GetState() ;
69
 
70
		if ( sValue != FCK_TRISTATE_DISABLED )
71
		{
72
			eState = FCK_TRISTATE_ON ;
73
 
74
			if ( this.RefreshActiveItems )
75
				this.RefreshActiveItems( this._Combo, sValue ) ;
76
			else
77
				FCKToolbarSpecialCombo_RefreshActiveItems( this._Combo, sValue ) ;
78
		}
79
		else
80
			eState = FCK_TRISTATE_DISABLED ;
81
//	}
82
 
83
	// If there are no state changes then do nothing and return.
84
	if ( eState == this.State ) return ;
85
 
86
	if ( eState == FCK_TRISTATE_DISABLED )
87
	{
88
		this._Combo.DeselectAll() ;
89
		this._Combo.SetLabel( '' ) ;
90
	}
91
 
92
	// Sets the actual state.
93
	this.State = eState ;
94
 
95
	// Updates the graphical state.
96
	this._Combo.SetEnabled( eState != FCK_TRISTATE_DISABLED ) ;
97
}
98
 
99
FCKToolbarSpecialCombo.prototype.Enable = function()
100
{
101
	this.RefreshState() ;
102
}
103
 
104
FCKToolbarSpecialCombo.prototype.Disable = function()
105
{
106
	this.State = FCK_TRISTATE_DISABLED ;
107
	this._Combo.DeselectAll() ;
108
	this._Combo.SetLabel( '' ) ;
109
	this._Combo.SetEnabled( false ) ;
110
}