Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 ddelon 1
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 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
 * File Name: fck_othercommands.js
12
 * 	Definition of other commands that are not available internaly in the
13
 * 	browser (see FCKNamedCommand).
14
 *
15
 * File Authors:
16
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
17
 */
18
 
19
// ### General Dialog Box Commands.
20
var FCKDialogCommand = function( name, title, url, width, height, getStateFunction, getStateParam )
21
{
22
	this.Name	= name ;
23
	this.Title	= title ;
24
	this.Url	= url ;
25
	this.Width	= width ;
26
	this.Height	= height ;
27
 
28
	this.GetStateFunction	= getStateFunction ;
29
	this.GetStateParam		= getStateParam ;
30
}
31
 
32
FCKDialogCommand.prototype.Execute = function()
33
{
34
	FCKDialog.OpenDialog( 'FCKDialog_' + this.Name , this.Title, this.Url, this.Width, this.Height ) ;
35
}
36
 
37
FCKDialogCommand.prototype.GetState = function()
38
{
39
	if ( this.GetStateFunction )
40
		return this.GetStateFunction( this.GetStateParam ) ;
41
	else
42
		return FCK_TRISTATE_OFF ;
43
}
44
 
45
// Generic Undefined command (usually used when a command is under development).
46
var FCKUndefinedCommand = function()
47
{
48
	this.Name = 'Undefined' ;
49
}
50
 
51
FCKUndefinedCommand.prototype.Execute = function()
52
{
53
	alert( FCKLang.NotImplemented ) ;
54
}
55
 
56
FCKUndefinedCommand.prototype.GetState = function()
57
{
58
	return FCK_TRISTATE_OFF ;
59
}
60
 
61
// ### FontName
62
var FCKFontNameCommand = function()
63
{
64
	this.Name = 'FontName' ;
65
}
66
 
67
FCKFontNameCommand.prototype.Execute = function( fontName )
68
{
69
	if (fontName == null || fontName == "")
70
	{
71
		// TODO: Remove font name attribute.
72
	}
73
	else
74
		FCK.ExecuteNamedCommand( 'FontName', fontName ) ;
75
}
76
 
77
FCKFontNameCommand.prototype.GetState = function()
78
{
79
	return FCK.GetNamedCommandValue( 'FontName' ) ;
80
}
81
 
82
// ### FontSize
83
var FCKFontSizeCommand = function()
84
{
85
	this.Name = 'FontSize' ;
86
}
87
 
88
FCKFontSizeCommand.prototype.Execute = function( fontSize )
89
{
90
	if ( typeof( fontSize ) == 'string' ) fontSize = parseInt(fontSize) ;
91
 
92
	if ( fontSize == null || fontSize == '' )
93
	{
94
		// TODO: Remove font size attribute (Now it works with size 3. Will it work forever?)
95
		FCK.ExecuteNamedCommand( 'FontSize', 3 ) ;
96
	}
97
	else
98
		FCK.ExecuteNamedCommand( 'FontSize', fontSize ) ;
99
}
100
 
101
FCKFontSizeCommand.prototype.GetState = function()
102
{
103
	return FCK.GetNamedCommandValue( 'FontSize' ) ;
104
}
105
 
106
// ### FormatBlock
107
var FCKFormatBlockCommand = function()
108
{
109
	this.Name = 'FormatBlock' ;
110
}
111
 
112
FCKFormatBlockCommand.prototype.Execute = function( formatName )
113
{
114
	if ( formatName == null || formatName == '' )
115
		FCK.ExecuteNamedCommand( 'FormatBlock', '<P>' ) ;
116
	else
117
		FCK.ExecuteNamedCommand( 'FormatBlock', '<' + formatName + '>' ) ;
118
}
119
 
120
FCKFormatBlockCommand.prototype.GetState = function()
121
{
122
	return FCK.GetNamedCommandValue( 'FormatBlock' ) ;
123
}
124
 
125
// ### Preview
126
var FCKPreviewCommand = function()
127
{
128
	this.Name = 'Preview' ;
129
}
130
 
131
FCKPreviewCommand.prototype.Execute = function()
132
{
133
     FCK.Preview() ;
134
}
135
 
136
FCKPreviewCommand.prototype.GetState = function()
137
{
138
	return FCK_TRISTATE_OFF ;
139
}
140
 
141
// ### Save
142
var FCKSaveCommand = function()
143
{
144
	this.Name = 'Save' ;
145
}
146
 
147
FCKSaveCommand.prototype.Execute = function()
148
{
149
	// Get the linked field form.
150
	var oForm = FCK.LinkedField.form ;
151
 
152
	if ( typeof( oForm.onsubmit ) == 'function' )
153
	{
154
		var bRet = oForm.onsubmit() ;
155
		if ( bRet != null && bRet === false )
156
			return ;
157
	}
158
 
159
	// Submit the form.
160
	oForm.submit() ;
161
}
162
 
163
FCKSaveCommand.prototype.GetState = function()
164
{
165
	return FCK_TRISTATE_OFF ;
166
}
167
 
168
// ### NewPage
169
var FCKNewPageCommand = function()
170
{
171
	this.Name = 'NewPage' ;
172
}
173
 
174
FCKNewPageCommand.prototype.Execute = function()
175
{
176
	FCKUndo.SaveUndoStep() ;
177
	FCK.SetHTML( '' ) ;
178
//	FCK.SetHTML( FCKBrowserInfo.IsGecko ? '&nbsp;' : '' ) ;
179
//	FCK.SetHTML( FCKBrowserInfo.IsGecko ? '<br _moz_editor_bogus_node="TRUE">' : '' ) ;
180
}
181
 
182
FCKNewPageCommand.prototype.GetState = function()
183
{
184
	return FCK_TRISTATE_OFF ;
185
}
186
 
187
// ### Source button
188
var FCKSourceCommand = function()
189
{
190
	this.Name = 'Source' ;
191
}
192
 
193
FCKSourceCommand.prototype.Execute = function()
194
{
195
	if ( FCKBrowserInfo.IsGecko )
196
	{
197
		var iWidth	= screen.width * 0.65 ;
198
		var iHeight	= screen.height * 0.65 ;
199
		FCKDialog.OpenDialog( 'FCKDialog_Source', FCKLang.Source, 'dialog/fck_source.html', iWidth, iHeight, null, null, true ) ;
200
	}
201
	else
202
	    FCK.SwitchEditMode() ;
203
}
204
 
205
FCKSourceCommand.prototype.GetState = function()
206
{
207
	return ( FCK.EditMode == FCK_EDITMODE_WYSIWYG ? FCK_TRISTATE_OFF : FCK_TRISTATE_ON ) ;
208
}
209
 
210
// ### Undo
211
var FCKUndoCommand = function()
212
{
213
	this.Name = 'Undo' ;
214
}
215
 
216
FCKUndoCommand.prototype.Execute = function()
217
{
218
	if ( FCKBrowserInfo.IsIE )
219
		FCKUndo.Undo() ;
220
	else
221
		FCK.ExecuteNamedCommand( 'Undo' ) ;
222
}
223
 
224
FCKUndoCommand.prototype.GetState = function()
225
{
226
	if ( FCKBrowserInfo.IsIE )
227
		return ( FCKUndo.Typing || FCKUndo.CurrentIndex > 0 ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ;
228
	else
229
		return FCK.GetNamedCommandState( 'Undo' ) ;
230
}
231
 
232
// ### Redo
233
var FCKRedoCommand = function()
234
{
235
	this.Name = 'Redo' ;
236
}
237
 
238
FCKRedoCommand.prototype.Execute = function()
239
{
240
	if ( FCKBrowserInfo.IsIE )
241
		FCKUndo.Redo() ;
242
	else
243
		FCK.ExecuteNamedCommand( 'Redo' ) ;
244
}
245
 
246
FCKRedoCommand.prototype.GetState = function()
247
{
248
	if ( FCKBrowserInfo.IsIE )
249
		return ( !FCKUndo.Typing && FCKUndo.CurrentIndex < ( FCKUndo.SavedData.length - 1 ) ? FCK_TRISTATE_OFF : FCK_TRISTATE_DISABLED ) ;
250
	else
251
		return FCK.GetNamedCommandState( 'Redo' ) ;
252
}