2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fcktoolbarstylecombo.js
14
* FCKToolbarPanelButton Class: Handles the Fonts combo selector.
17
* Frederico Caldeira Knabben (fredck@fckeditor.net)
20
var FCKToolbarStyleCombo = function( tooltip, style )
22
this.Command = FCKCommands.GetCommand( 'Style' ) ;
23
this.Label = this.GetLabel() ;
24
this.Tooltip = tooltip ? tooltip : this.Label ;
25
this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ;
28
// Inherit from FCKToolbarSpecialCombo.
29
FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ;
31
FCKToolbarStyleCombo.prototype.GetLabel = function()
33
return FCKLang.Style ;
36
FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo )
38
// Add the Editor Area CSS to the Styles panel so the style classes are previewed correctly.
39
FCKTools.AppendStyleSheet( targetSpecialCombo._Panel.Document, FCKConfig.EditorAreaCSS ) ;
41
targetSpecialCombo._Panel.Document.body.className += ' ForceBaseFont' ;
43
// For some reason Gecko is blocking inside the "RefreshVisibleItems" function.
44
if ( ! FCKBrowserInfo.IsGecko )
45
targetSpecialCombo.OnBeforeClick = this.RefreshVisibleItems ;
47
// Add the styles to the special combo.
48
for ( var s in this.Command.Styles )
50
var oStyle = this.Command.Styles[s] ;
53
if ( oStyle.IsObjectElement )
54
oItem = targetSpecialCombo.AddItem( s, s ) ;
56
oItem = targetSpecialCombo.AddItem( s, oStyle.GetOpenerTag() + s + oStyle.GetCloserTag() ) ;
58
oItem.Style = oStyle ;
62
FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo )
64
// Clear the actual selection.
65
targetSpecialCombo.DeselectAll() ;
67
// Get the active styles.
68
var aStyles = this.Command.GetActiveStyles() ;
70
if ( aStyles.length > 0 )
72
// Select the active styles in the combo.
73
for ( var i = 0 ; i < aStyles.length ; i++ )
74
targetSpecialCombo.SelectItem( aStyles[i].Name ) ;
76
// Set the combo label to the first style in the collection.
77
targetSpecialCombo.SetLabelById( aStyles[0].Name ) ;
80
targetSpecialCombo.SetLabel('') ;
83
FCKToolbarStyleCombo.prototype.RefreshVisibleItems = function( targetSpecialCombo )
85
if ( FCKSelection.GetType() == 'Control' )
86
var sTagName = FCKSelection.GetSelectedElement().tagName ;
88
for ( var i in targetSpecialCombo.Items )
90
var oItem = targetSpecialCombo.Items[i] ;
91
if ( ( sTagName && oItem.Style.Element == sTagName ) || ( ! sTagName && ! oItem.Style.IsObjectElement ) )
92
oItem.style.display = '' ;
94
oItem.style.display = 'none' ; // For some reason Gecko is blocking here.
b'\\ No newline at end of file'