Subversion Repositories Applications.papyrus

Rev

Rev 1371 | Details | Compare with Previous | Last modification | View Log | RSS feed

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