2
* FCKeditor - The text editor for internet
3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
5
* Licensed under the terms of the GNU Lesser General Public License:
6
* http://www.opensource.org/licenses/lgpl-license.php
8
* For further information visit:
9
* http://www.fckeditor.net/
11
* "Support Open Source software. What about a donation today?"
13
* File Name: fck_othercommands.js
14
* Definition of other commands that are not available internaly in the
15
* browser (see FCKNamedCommand).
18
* Frederico Caldeira Knabben (fredck@fckeditor.net)
21
// ### General Dialog Box Commands.
22
var FCKDialogCommand = function( name, title, url, width, height, getStateFunction, getStateParam )
28
this.Height = height ;
30
this.GetStateFunction = getStateFunction ;
31
this.GetStateParam = getStateParam ;
34
FCKDialogCommand.prototype.Execute = function()
36
FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, this.Width, this.Height ) ;
39
FCKDialogCommand.prototype.GetState = function()
41
if ( this.GetStateFunction )
42
return this.GetStateFunction( this.GetStateParam ) ;
44
return FCK_TRISTATE_OFF ;
47
// Generic Undefined command (usually used when a command is under development).
48
var FCKUndefinedCommand = function()
50
this.Name = 'Undefined' ;
53
FCKUndefinedCommand.prototype.Execute = function()
55
alert( FCKLang.NotImplemented ) ;
58
FCKUndefinedCommand.prototype.GetState = function()
60
return FCK_TRISTATE_OFF ;
64
var FCKFontNameCommand = function()
66
this.Name = 'FontName' ;
69
FCKFontNameCommand.prototype.Execute = function( fontName )
71
if (fontName == null || fontName == "")
73
// TODO: Remove font name attribute.
76
FCK.ExecuteNamedCommand( 'FontName', fontName ) ;
79
FCKFontNameCommand.prototype.GetState = function()
81
return FCK.GetNamedCommandValue( 'FontName' ) ;
85
var FCKFontSizeCommand = function()
87
this.Name = 'FontSize' ;
90
FCKFontSizeCommand.prototype.Execute = function( fontSize )
92
if ( typeof( fontSize ) == 'string' ) fontSize = parseInt(fontSize) ;
94
if ( fontSize == null || fontSize == '' )
96
// TODO: Remove font size attribute (Now it works with size 3. Will it work forever?)
97
FCK.ExecuteNamedCommand( 'FontSize', 3 ) ;
100
FCK.ExecuteNamedCommand( 'FontSize', fontSize ) ;
103
FCKFontSizeCommand.prototype.GetState = function()
105
return FCK.GetNamedCommandValue( 'FontSize' ) ;
109
var FCKFormatBlockCommand = function()
111
this.Name = 'FormatBlock' ;
114
FCKFormatBlockCommand.prototype.Execute = function( formatName )
116
if ( formatName == null || formatName == '' )
117
FCK.ExecuteNamedCommand( 'FormatBlock', '<P>' ) ;
118
else if ( formatName == 'div' && FCKBrowserInfo.IsGecko )
119
FCK.ExecuteNamedCommand( 'FormatBlock', 'div' ) ;
121
FCK.ExecuteNamedCommand( 'FormatBlock', '<' + formatName + '>' ) ;
124
FCKFormatBlockCommand.prototype.GetState = function()
126
return FCK.GetNamedCommandValue( 'FormatBlock' ) ;
130
var FCKPreviewCommand = function()
132
this.Name = 'Preview' ;
135
FCKPreviewCommand.prototype.Execute = function()
140
FCKPreviewCommand.prototype.GetState = function()
142
return FCK_TRISTATE_OFF ;
146
var FCKSaveCommand = function()
151
FCKSaveCommand.prototype.Execute = function()
153
// Get the linked field form.
154
var oForm = FCK.LinkedField.form ;
156
if ( typeof( oForm.onsubmit ) == 'function' )
158
var bRet = oForm.onsubmit() ;
159
if ( bRet != null && bRet === false )
167
FCKSaveCommand.prototype.GetState = function()
169
return FCK_TRISTATE_OFF ;
173
var FCKNewPageCommand = function()
175
this.Name = 'NewPage' ;
178
FCKNewPageCommand.prototype.Execute = function()
180
FCKUndo.SaveUndoStep() ;
182
FCKUndo.Typing = true ;
183
// FCK.SetHTML( FCKBrowserInfo.IsGecko ? ' ' : '' ) ;
184
// FCK.SetHTML( FCKBrowserInfo.IsGecko ? GECKO_BOGUS : '' ) ;
187
FCKNewPageCommand.prototype.GetState = function()
189
return FCK_TRISTATE_OFF ;
193
var FCKSourceCommand = function()
195
this.Name = 'Source' ;
198
FCKSourceCommand.prototype.Execute = function()
200
if ( FCKBrowserInfo.IsGecko )
202
var iWidth = FCKConfig.ScreenWidth * 0.65 ;
203
var iHeight = FCKConfig.ScreenHeight * 0.65 ;
204
FCKDialog.OpenDialog( 'FCKDialog_Source', FCKLang.Source, 'dialog/fck_source.html', iWidth, iHeight, null, null, true ) ;
207
FCK.SwitchEditMode() ;
210
FCKSourceCommand.prototype.GetState = function()
212
return ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : FCK_TRISTATE_ON ) ;
216
var FCKUndoCommand = function()
221
FCKUndoCommand.prototype.Execute = function()
223
if ( FCKBrowserInfo.IsIE )
226
FCK.ExecuteNamedCommand( 'Undo' ) ;
229
FCKUndoCommand.prototype.GetState = function()
231
if ( FCKBrowserInfo.IsIE )
232
return ( FCKUndo.CheckUndoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ;
234
return FCK.GetNamedCommandState( 'Undo' ) ;
238
var FCKRedoCommand = function()
243
FCKRedoCommand.prototype.Execute = function()
245
if ( FCKBrowserInfo.IsIE )
248
FCK.ExecuteNamedCommand( 'Redo' ) ;
251
FCKRedoCommand.prototype.GetState = function()
253
if ( FCKBrowserInfo.IsIE )
254
return ( FCKUndo.CheckRedoState() ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ;
256
return FCK.GetNamedCommandState( 'Redo' ) ;
260
var FCKPageBreakCommand = function()
262
this.Name = 'PageBreak' ;
265
FCKPageBreakCommand.prototype.Execute = function()
267
// var e = FCK.EditorDocument.createElement( 'CENTER' ) ;
268
// e.style.pageBreakAfter = 'always' ;
270
// Tidy was removing the empty CENTER tags, so the following solution has
271
// been found. It also validates correctly as XHTML 1.0 Strict.
272
var e = FCK.EditorDocument.createElement( 'DIV' ) ;
273
e.style.pageBreakAfter = 'always' ;
274
e.innerHTML = '<span style="DISPLAY:none"> </span>' ;
276
var oFakeImage = FCKDocumentProcessors_CreateFakeImage( 'FCK__PageBreak', e ) ;
277
oFakeImage = FCK.InsertElement( oFakeImage ) ;
280
FCKPageBreakCommand.prototype.GetState = function()
282
return 0 ; // FCK_TRISTATE_OFF
b'\\ No newline at end of file'