import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / classes / fcktoolbarfontscombo.js
1 /*\r
2  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
3  * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
4  *\r
5  * == BEGIN LICENSE ==\r
6  *\r
7  * Licensed under the terms of any of the following licenses at your\r
8  * choice:\r
9  *\r
10  *  - GNU General Public License Version 2 or later (the "GPL")\r
11  *    http://www.gnu.org/licenses/gpl.html\r
12  *\r
13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
14  *    http://www.gnu.org/licenses/lgpl.html\r
15  *\r
16  *  - Mozilla Public License Version 1.1 or later (the "MPL")\r
17  *    http://www.mozilla.org/MPL/MPL-1.1.html\r
18  *\r
19  * == END LICENSE ==\r
20  *\r
21  * FCKToolbarPanelButton Class: Handles the Fonts combo selector.\r
22  */\r
23 \r
24 var FCKToolbarFontsCombo = function( tooltip, style )\r
25 {\r
26         this.CommandName        = 'FontName' ;\r
27         this.Label              = this.GetLabel() ;\r
28         this.Tooltip    = tooltip ? tooltip : this.Label ;\r
29         this.Style              = style ? style : FCK_TOOLBARITEM_ICONTEXT ;\r
30 \r
31         this.DefaultLabel = FCKConfig.DefaultFontLabel || '' ;\r
32 }\r
33 \r
34 // Inherit from FCKToolbarSpecialCombo.\r
35 FCKToolbarFontsCombo.prototype = new FCKToolbarFontFormatCombo( false ) ;\r
36 \r
37 FCKToolbarFontsCombo.prototype.GetLabel = function()\r
38 {\r
39         return FCKLang.Font ;\r
40 }\r
41 \r
42 FCKToolbarFontsCombo.prototype.GetStyles = function()\r
43 {\r
44         var baseStyle = FCKStyles.GetStyle( '_FCK_FontFace' ) ;\r
45 \r
46         if ( !baseStyle )\r
47         {\r
48                 alert( "The FCKConfig.CoreStyles['Size'] setting was not found. Please check the fckconfig.js file" ) ;\r
49                 return {} ;\r
50         }\r
51 \r
52         var styles = {} ;\r
53 \r
54         var fonts = FCKConfig.FontNames.split(';') ;\r
55 \r
56         for ( var i = 0 ; i < fonts.length ; i++ )\r
57         {\r
58                 var fontParts = fonts[i].split('/') ;\r
59                 var font = fontParts[0] ;\r
60                 var caption = fontParts[1] || font ;\r
61 \r
62                 var style = FCKTools.CloneObject( baseStyle ) ;\r
63 \r
64                 style.SetVariable( 'Font', font ) ;\r
65                 style.Label = caption ;\r
66 \r
67                 styles[ caption ] = style ;\r
68         }\r
69 \r
70         return styles ;\r
71 }\r
72 \r
73 FCKToolbarFontsCombo.prototype.RefreshActiveItems = FCKToolbarStyleCombo.prototype.RefreshActiveItems ;\r
74 \r
75 FCKToolbarFontsCombo.prototype.StyleCombo_OnBeforeClick = function( targetSpecialCombo )\r
76 {\r
77         // Clear the current selection.\r
78         targetSpecialCombo.DeselectAll() ;\r
79 \r
80         var startElement = FCKSelection.GetBoundaryParentElement( true ) ;\r
81 \r
82         if ( startElement )\r
83         {\r
84                 var path = new FCKElementPath( startElement ) ;\r
85 \r
86                 for ( var i in targetSpecialCombo.Items )\r
87                 {\r
88                         var item = targetSpecialCombo.Items[i] ;\r
89                         var style = item.Style ;\r
90 \r
91                         if ( style.CheckActive( path ) )\r
92                         {\r
93                                 targetSpecialCombo.SelectItem( item ) ;\r
94                                 return ;\r
95                         }\r
96                 }\r
97         }\r
98 }\r