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: fcktoolbarfontformatcombo.js
|
|
|
14 |
* FCKToolbarPanelButton Class: Handles the Fonts combo selector.
|
|
|
15 |
*
|
|
|
16 |
* File Authors:
|
|
|
17 |
* Frederico Caldeira Knabben (fredck@fckeditor.net)
|
|
|
18 |
*/
|
|
|
19 |
|
|
|
20 |
var FCKToolbarFontFormatCombo = function( tooltip, style )
|
|
|
21 |
{
|
|
|
22 |
this.CommandName = 'FontFormat' ;
|
|
|
23 |
this.Label = this.GetLabel() ;
|
|
|
24 |
this.Tooltip = tooltip ? tooltip : this.Label ;
|
|
|
25 |
this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ;
|
|
|
26 |
|
|
|
27 |
this.NormalLabel = 'Normal' ;
|
|
|
28 |
|
|
|
29 |
this.PanelWidth = 190 ;
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
// Inherit from FCKToolbarSpecialCombo.
|
|
|
33 |
FCKToolbarFontFormatCombo.prototype = new FCKToolbarSpecialCombo ;
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
FCKToolbarFontFormatCombo.prototype.GetLabel = function()
|
|
|
37 |
{
|
|
|
38 |
return FCKLang.FontFormat ;
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
FCKToolbarFontFormatCombo.prototype.CreateItems = function( targetSpecialCombo )
|
|
|
42 |
{
|
|
|
43 |
// Add the Editor Area CSS to the panel to create a realistic preview.
|
|
|
44 |
FCKTools.AppendStyleSheet( targetSpecialCombo._Panel.Document, FCKConfig.ToolbarComboPreviewCSS ) ;
|
|
|
45 |
|
|
|
46 |
// Get the format names from the language file.
|
|
|
47 |
var aNames = FCKLang['FontFormats'].split(';') ;
|
|
|
48 |
var oNames = {
|
|
|
49 |
p : aNames[0],
|
|
|
50 |
pre : aNames[1],
|
|
|
51 |
address : aNames[2],
|
|
|
52 |
h1 : aNames[3],
|
|
|
53 |
h2 : aNames[4],
|
|
|
54 |
h3 : aNames[5],
|
|
|
55 |
h4 : aNames[6],
|
|
|
56 |
h5 : aNames[7],
|
|
|
57 |
h6 : aNames[8],
|
|
|
58 |
div : aNames[9]
|
|
|
59 |
} ;
|
|
|
60 |
|
|
|
61 |
// Get the available formats from the configuration file.
|
|
|
62 |
var aTags = FCKConfig.FontFormats.split(';') ;
|
|
|
63 |
|
|
|
64 |
for ( var i = 0 ; i < aTags.length ; i++ )
|
|
|
65 |
{
|
|
|
66 |
// Support for DIV in Firefox has been reintroduced on version 2.2.
|
|
|
67 |
// if ( aTags[i] == 'div' && FCKBrowserInfo.IsGecko )
|
|
|
68 |
// continue ;
|
|
|
69 |
|
|
|
70 |
var sTag = aTags[i] ;
|
|
|
71 |
var sLabel = oNames[sTag] ;
|
|
|
72 |
|
|
|
73 |
if ( sTag == 'p' )
|
|
|
74 |
this.NormalLabel = sLabel ;
|
|
|
75 |
|
|
|
76 |
this._Combo.AddItem( sTag, '<div class="BaseFont"><' + sTag + '>' + sLabel + '</' + sTag + '></div>', sLabel ) ;
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
if ( FCKBrowserInfo.IsIE )
|
|
|
81 |
{
|
|
|
82 |
FCKToolbarFontFormatCombo.prototype.RefreshActiveItems = function( combo, value )
|
|
|
83 |
{
|
|
|
84 |
// FCKDebug.Output( 'FCKToolbarFontFormatCombo Value: ' + value ) ;
|
|
|
85 |
|
|
|
86 |
// IE returns normal for DIV and P, so to avoid confusion, we will not show it if normal.
|
|
|
87 |
if ( value == this.NormalLabel )
|
|
|
88 |
{
|
|
|
89 |
if ( combo.Label != ' ' )
|
|
|
90 |
combo.DeselectAll(true) ;
|
|
|
91 |
}
|
|
|
92 |
else
|
|
|
93 |
{
|
|
|
94 |
if ( this._LastValue == value )
|
|
|
95 |
return ;
|
|
|
96 |
|
|
|
97 |
combo.SelectItemByLabel( value, true ) ;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
this._LastValue = value ;
|
|
|
101 |
}
|
|
|
102 |
}
|