2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* FCKTextColorCommand Class: represents the text color comand. It shows the
22
* color selection panel.
25
// FCKTextColorCommand Contructor
26
// type: can be 'ForeColor' or 'BackColor'.
27
var FCKTextColorCommand = function( type )
29
this.Name = type == 'ForeColor' ? 'TextColor' : 'BGColor' ;
34
if ( FCKBrowserInfo.IsIE )
36
else if ( FCK.ToolbarSet._IFrame )
37
oWindow = FCKTools.GetElementWindow( FCK.ToolbarSet._IFrame ) ;
39
oWindow = window.parent ;
41
this._Panel = new FCKPanel( oWindow ) ;
42
this._Panel.AppendStyleSheet( FCKConfig.SkinPath + 'fck_editor.css' ) ;
43
this._Panel.MainNode.className = 'FCK_Panel' ;
44
this._CreatePanelBody( this._Panel.Document, this._Panel.MainNode ) ;
46
FCKTools.DisableSelection( this._Panel.Document.body ) ;
49
FCKTextColorCommand.prototype.Execute = function( panelX, panelY, relElement )
51
// We must "cache" the actual panel type to be used in the SetColor method.
52
FCK._ActiveColorPanelType = this.Type ;
54
// Show the Color Panel at the desired position.
55
this._Panel.Show( panelX, panelY, relElement ) ;
58
FCKTextColorCommand.prototype.SetColor = function( color )
60
if ( FCK._ActiveColorPanelType == 'ForeColor' )
61
FCK.ExecuteNamedCommand( 'ForeColor', color ) ;
62
else if ( FCKBrowserInfo.IsGeckoLike )
64
if ( FCKBrowserInfo.IsGecko && !FCKConfig.GeckoUseSPAN )
65
FCK.EditorDocument.execCommand( 'useCSS', false, false ) ;
67
FCK.ExecuteNamedCommand( 'hilitecolor', color ) ;
69
if ( FCKBrowserInfo.IsGecko && !FCKConfig.GeckoUseSPAN )
70
FCK.EditorDocument.execCommand( 'useCSS', false, true ) ;
73
FCK.ExecuteNamedCommand( 'BackColor', color ) ;
75
// Delete the "cached" active panel type.
76
delete FCK._ActiveColorPanelType ;
79
FCKTextColorCommand.prototype.GetState = function()
81
return FCK_TRISTATE_OFF ;
84
function FCKTextColorCommand_OnMouseOver() { this.className='ColorSelected' ; }
86
function FCKTextColorCommand_OnMouseOut() { this.className='ColorDeselected' ; }
88
function FCKTextColorCommand_OnClick()
90
this.className = 'ColorDeselected' ;
91
this.Command.SetColor( '#' + this.Color ) ;
92
this.Command._Panel.Hide() ;
95
function FCKTextColorCommand_AutoOnClick()
97
this.className = 'ColorDeselected' ;
98
this.Command.SetColor( '' ) ;
99
this.Command._Panel.Hide() ;
102
function FCKTextColorCommand_MoreOnClick()
104
this.className = 'ColorDeselected' ;
105
this.Command._Panel.Hide() ;
106
FCKDialog.OpenDialog( 'FCKDialog_Color', FCKLang.DlgColorTitle, 'dialog/fck_colorselector.html', 400, 330, this.Command.SetColor ) ;
109
FCKTextColorCommand.prototype._CreatePanelBody = function( targetDocument, targetDiv )
111
function CreateSelectionDiv()
113
var oDiv = targetDocument.createElement( "DIV" ) ;
114
oDiv.className = 'ColorDeselected' ;
115
oDiv.onmouseover = FCKTextColorCommand_OnMouseOver ;
116
oDiv.onmouseout = FCKTextColorCommand_OnMouseOut ;
121
// Create the Table that will hold all colors.
122
var oTable = targetDiv.appendChild( targetDocument.createElement( "TABLE" ) ) ;
123
oTable.className = 'ForceBaseFont' ; // Firefox 1.5 Bug.
124
oTable.style.tableLayout = 'fixed' ;
125
oTable.cellPadding = 0 ;
126
oTable.cellSpacing = 0 ;
130
var oCell = oTable.insertRow(-1).insertCell(-1) ;
133
// Create the Button for the "Automatic" color selection.
134
var oDiv = oCell.appendChild( CreateSelectionDiv() ) ;
136
'<table cellspacing="0" cellpadding="0" width="100%" border="0">\
138
<td><div class="ColorBoxBorder"><div class="ColorBox" style="background-color: #000000"></div></div></td>\
139
<td nowrap width="100%" align="center">' + FCKLang.ColorAutomatic + '</td>\
143
oDiv.Command = this ;
144
oDiv.onclick = FCKTextColorCommand_AutoOnClick ;
146
// Create an array of colors based on the configuration file.
147
var aColors = FCKConfig.FontColors.toString().split(',') ;
149
// Create the colors table based on the array.
151
while ( iCounter < aColors.length )
153
var oRow = oTable.insertRow(-1) ;
155
for ( var i = 0 ; i < 8 && iCounter < aColors.length ; i++, iCounter++ )
157
oDiv = oRow.insertCell(-1).appendChild( CreateSelectionDiv() ) ;
158
oDiv.Color = aColors[iCounter] ;
159
oDiv.innerHTML = '<div class="ColorBoxBorder"><div class="ColorBox" style="background-color: #' + aColors[iCounter] + '"></div></div>' ;
161
oDiv.Command = this ;
162
oDiv.onclick = FCKTextColorCommand_OnClick ;
166
// Create the Row and the Cell for the "More Colors..." button.
167
oCell = oTable.insertRow(-1).insertCell(-1) ;
170
oDiv = oCell.appendChild( CreateSelectionDiv() ) ;
171
oDiv.innerHTML = '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td nowrap align="center">' + FCKLang.ColorMoreColors + '</td></tr></table>' ;
173
oDiv.Command = this ;
174
oDiv.onclick = FCKTextColorCommand_MoreOnClick ;
b'\\ No newline at end of file'