source: branches/1.2/workflow/js/fckeditor/editor/_source/classes/fcktoolbarstylecombo.js @ 1349

Revision 1349, 3.5 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1/*
2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3 * Copyright (C) 2003-2007 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 * FCKToolbarPanelButton Class: Handles the Fonts combo selector.
22 */
23
24var FCKToolbarStyleCombo = function( tooltip, style )
25{
26        this.CommandName = 'Style' ;
27        this.Label              = this.GetLabel() ;
28        this.Tooltip    = tooltip ? tooltip : this.Label ;
29        this.Style              = style ? style : FCK_TOOLBARITEM_ICONTEXT ;
30}
31
32// Inherit from FCKToolbarSpecialCombo.
33FCKToolbarStyleCombo.prototype = new FCKToolbarSpecialCombo ;
34
35
36FCKToolbarStyleCombo.prototype.GetLabel = function()
37{
38        return FCKLang.Style ;
39}
40
41FCKToolbarStyleCombo.prototype.CreateItems = function( targetSpecialCombo )
42{
43        var oTargetDoc = targetSpecialCombo._Panel.Document ;
44
45        // Add the Editor Area CSS to the panel so the style classes are previewed correctly.
46        FCKTools.AppendStyleSheet( oTargetDoc, FCKConfig.ToolbarComboPreviewCSS ) ;
47        oTargetDoc.body.className += ' ForceBaseFont' ;
48
49        // Add ID and Class to the body
50        if ( FCKConfig.BodyId && FCKConfig.BodyId.length > 0 )
51                oTargetDoc.body.id = FCKConfig.BodyId ;
52        if ( FCKConfig.BodyClass && FCKConfig.BodyClass.length > 0 )
53                oTargetDoc.body.className += ' ' + FCKConfig.BodyClass ;
54
55
56        // For some reason Gecko is blocking inside the "RefreshVisibleItems" function.
57        // The problem is present only in old versions
58        if ( !( FCKBrowserInfo.IsGecko && FCKBrowserInfo.IsGecko10 ) )
59                targetSpecialCombo.OnBeforeClick = this.RefreshVisibleItems ;
60
61        // Add the styles to the special combo.
62        var aCommandStyles = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).Styles ;
63        for ( var s in aCommandStyles )
64        {
65                var oStyle = aCommandStyles[s] ;
66                var oItem ;
67
68                if ( oStyle.IsObjectElement )
69                        oItem = targetSpecialCombo.AddItem( s, s ) ;
70                else
71                        oItem = targetSpecialCombo.AddItem( s, oStyle.GetOpenerTag() + s + oStyle.GetCloserTag() ) ;
72
73                oItem.Style = oStyle ;
74        }
75}
76
77FCKToolbarStyleCombo.prototype.RefreshActiveItems = function( targetSpecialCombo )
78{
79        // Clear the actual selection.
80        targetSpecialCombo.DeselectAll() ;
81
82        // Get the active styles.
83        var aStyles = FCK.ToolbarSet.CurrentInstance.Commands.GetCommand( this.CommandName ).GetActiveStyles() ;
84
85        if ( aStyles.length > 0 )
86        {
87                // Select the active styles in the combo.
88                for ( var i = 0 ; i < aStyles.length ; i++ )
89                        targetSpecialCombo.SelectItem( aStyles[i].Name ) ;
90
91                // Set the combo label to the first style in the collection.
92                targetSpecialCombo.SetLabelById( aStyles[0].Name ) ;
93        }
94        else
95                targetSpecialCombo.SetLabel('') ;
96}
97
98FCKToolbarStyleCombo.prototype.RefreshVisibleItems = function( targetSpecialCombo )
99{
100        if ( FCKSelection.GetType() == 'Control' )
101                var sTagName = FCKSelection.GetSelectedElement().tagName ;
102
103        for ( var i in targetSpecialCombo.Items )
104        {
105                var oItem = targetSpecialCombo.Items[i] ;
106                if ( ( sTagName && oItem.Style.Element == sTagName ) || ( ! sTagName && ! oItem.Style.IsObjectElement ) )
107                        oItem.style.display = '' ;
108                else
109                        oItem.style.display = 'none' ;  // For some reason Gecko is blocking here.
110        }
111}
Note: See TracBrowser for help on using the repository browser.