1 | /*
|
---|
2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
---|
3 | * Copyright (C) 2003-2009 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 |
|
---|
24 | var FCKToolbarFontsCombo = function( tooltip, style )
|
---|
25 | {
|
---|
26 | this.CommandName = 'FontName' ;
|
---|
27 | this.Label = this.GetLabel() ;
|
---|
28 | this.Tooltip = tooltip ? tooltip : this.Label ;
|
---|
29 | this.Style = style ? style : FCK_TOOLBARITEM_ICONTEXT ;
|
---|
30 |
|
---|
31 | this.DefaultLabel = FCKConfig.DefaultFontLabel || '' ;
|
---|
32 | }
|
---|
33 |
|
---|
34 | // Inherit from FCKToolbarSpecialCombo.
|
---|
35 | FCKToolbarFontsCombo.prototype = new FCKToolbarFontFormatCombo( false ) ;
|
---|
36 |
|
---|
37 | FCKToolbarFontsCombo.prototype.GetLabel = function()
|
---|
38 | {
|
---|
39 | return FCKLang.Font ;
|
---|
40 | }
|
---|
41 |
|
---|
42 | FCKToolbarFontsCombo.prototype.GetStyles = function()
|
---|
43 | {
|
---|
44 | var baseStyle = FCKStyles.GetStyle( '_FCK_FontFace' ) ;
|
---|
45 |
|
---|
46 | if ( !baseStyle )
|
---|
47 | {
|
---|
48 | alert( "The FCKConfig.CoreStyles['Size'] setting was not found. Please check the fckconfig.js file" ) ;
|
---|
49 | return {} ;
|
---|
50 | }
|
---|
51 |
|
---|
52 | var styles = {} ;
|
---|
53 |
|
---|
54 | var fonts = FCKConfig.FontNames.split(';') ;
|
---|
55 |
|
---|
56 | for ( var i = 0 ; i < fonts.length ; i++ )
|
---|
57 | {
|
---|
58 | var fontParts = fonts[i].split('/') ;
|
---|
59 | var font = fontParts[0] ;
|
---|
60 | var caption = fontParts[1] || font ;
|
---|
61 |
|
---|
62 | var style = FCKTools.CloneObject( baseStyle ) ;
|
---|
63 |
|
---|
64 | style.SetVariable( 'Font', font ) ;
|
---|
65 | style.Label = caption ;
|
---|
66 |
|
---|
67 | styles[ caption ] = style ;
|
---|
68 | }
|
---|
69 |
|
---|
70 | return styles ;
|
---|
71 | }
|
---|
72 |
|
---|
73 | FCKToolbarFontsCombo.prototype.RefreshActiveItems = FCKToolbarStyleCombo.prototype.RefreshActiveItems ;
|
---|
74 |
|
---|
75 | FCKToolbarFontsCombo.prototype.StyleCombo_OnBeforeClick = function( targetSpecialCombo )
|
---|
76 | {
|
---|
77 | // Clear the current selection.
|
---|
78 | targetSpecialCombo.DeselectAll() ;
|
---|
79 |
|
---|
80 | var startElement = FCKSelection.GetBoundaryParentElement( true ) ;
|
---|
81 |
|
---|
82 | if ( startElement )
|
---|
83 | {
|
---|
84 | var path = new FCKElementPath( startElement ) ;
|
---|
85 |
|
---|
86 | for ( var i in targetSpecialCombo.Items )
|
---|
87 | {
|
---|
88 | var item = targetSpecialCombo.Items[i] ;
|
---|
89 | var style = item.Style ;
|
---|
90 |
|
---|
91 | if ( style.CheckActive( path ) )
|
---|
92 | {
|
---|
93 | targetSpecialCombo.SelectItem( item ) ;
|
---|
94 | return ;
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|