Subversion Repositories Applications.papyrus

Rev

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: fcktoolbarstylecombo.js
12
 * 	FCKToolbarPanelButton Class: Handles the Fonts combo selector.
13
 *
14
 * File Authors:
15
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
16
 */
17
 
18
var FCKToolbarStyleCombo = function()
19
{
20
	this.Command = FCKCommands.GetCommand( 'Style' ) ;
21
}
22
 
23
// Inherit from FCKToolbarSpecialCombo.
24
FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ;
25
 
26
FCKToolbarStyleCombo.prototype.GetLabel = function()
27
{
28
	return FCKLang.Style ;
29
}
30
 
31
FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo )
32
{
33
	// Add the Editor Area CSS to the Styles panel so the style classes are previewed correctly.
34
	FCKTools.AppendStyleSheet( targetSpecialCombo._Panel.Document, FCKConfig.EditorAreaCSS ) ;
35
 
36
	// For some reason Gecko is blocking inside the "RefreshVisibleItems" function.
37
	if ( ! FCKBrowserInfo.IsGecko )
38
		targetSpecialCombo.OnBeforeClick = this.RefreshVisibleItems ;
39
 
40
	// Add the styles to the special combo.
41
	for ( var s in this.Command.Styles )
42
	{
43
		var oStyle = this.Command.Styles[s] ;
44
		if ( oStyle.IsObjectElement )
45
			var oItem = targetSpecialCombo.AddItem( s, s ) ;
46
		else
47
			var oItem = targetSpecialCombo.AddItem( s, oStyle.GetOpenerTag() + s + oStyle.GetCloserTag() ) ;
48
		oItem.Style = oStyle ;
49
	}
50
}
51
 
52
FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo )
53
{
54
	// Clear the actual selection.
55
	targetSpecialCombo.DeselectAll() ;
56
 
57
	// Get the active styles.
58
	var aStyles = this.Command.GetActiveStyles() ;
59
 
60
	if ( aStyles.length > 0 )
61
	{
62
		// Select the active styles in the combo.
63
		for ( var i = 0 ; i < aStyles.length ; i++ )
64
			targetSpecialCombo.SelectItem( aStyles[i].Name ) ;
65
 
66
		// Set the combo label to the first style in the collection.
67
		targetSpecialCombo.SetLabelById( aStyles[0].Name ) ;
68
	}
69
	else
70
		targetSpecialCombo.SetLabel('') ;
71
}
72
 
73
FCKToolbarStyleCombo.prototype.RefreshVisibleItems = function( targetSpecialCombo )
74
{
75
	if ( FCKSelection.GetType() == 'Control' )
76
		var sTagName = FCKSelection.GetSelectedElement().tagName ;
77
 
78
	for ( var i in targetSpecialCombo.Items )
79
	{
80
		var oItem = targetSpecialCombo.Items[i] ;
81
		if ( ( sTagName && oItem.Style.Element == sTagName ) || ( ! sTagName && ! oItem.Style.IsObjectElement ) )
82
			oItem.style.display = '' ;
83
		else
84
			oItem.style.display = 'none' ;	// For some reason Gecko is blocking here.
85
	}
86
}