Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1921
Line 1... Line 1...
1
/*
1
/*
2
 * FCKeditor - The text editor for internet
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
3
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
-
 
4
 *
-
 
5
 * == BEGIN LICENSE ==
4
 * 
6
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
7
 * Licensed under the terms of any of the following licenses at your
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
8
 * choice:
7
 * 
9
 *
8
 * For further information visit:
10
 *  - GNU General Public License Version 2 or later (the "GPL")
9
 * 		http://www.fckeditor.net/
11
 *    http://www.gnu.org/licenses/gpl.html
10
 * 
12
 *
11
 * "Support Open Source software. What about a donation today?"
13
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
-
 
14
 *    http://www.gnu.org/licenses/lgpl.html
12
 * 
15
 *
13
 * File Name: fck_flash.js
16
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
14
 * 	Scripts related to the Flash dialog window (see fck_flash.html).
17
 *    http://www.mozilla.org/MPL/MPL-1.1.html
15
 * 
18
 *
16
 * File Authors:
19
 * == END LICENSE ==
-
 
20
 *
17
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
21
 * Scripts related to the Flash dialog window (see fck_flash.html).
18
 */
22
 */
Line -... Line 23...
-
 
23
 
19
 
24
var dialog		= window.parent ;
20
var oEditor		= window.parent.InnerDialogLoaded() ;
25
var oEditor		= dialog.InnerDialogLoaded() ;
21
var FCK			= oEditor.FCK ;
26
var FCK			= oEditor.FCK ;
22
var FCKLang		= oEditor.FCKLang ;
27
var FCKLang		= oEditor.FCKLang ;
-
 
28
var FCKConfig	= oEditor.FCKConfig ;
Line 23... Line 29...
23
var FCKConfig	= oEditor.FCKConfig ;
29
var FCKTools	= oEditor.FCKTools ;
Line 24... Line 30...
24
 
30
 
25
//#### Dialog Tabs
31
//#### Dialog Tabs
Line 26... Line 32...
26
 
32
 
27
// Set the dialog tabs.
33
// Set the dialog tabs.
Line 28... Line 34...
28
window.parent.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
34
dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
29
 
35
 
Line 30... Line 36...
30
if ( FCKConfig.FlashUpload )
36
if ( FCKConfig.FlashUpload )
31
	window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
37
	dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
32
 
38
 
33
if ( !FCKConfig.FlashDlgHideAdvanced )
39
if ( !FCKConfig.FlashDlgHideAdvanced )
34
	window.parent.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
40
	dialog.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
35
 
41
 
36
// Function called when a dialog tag is selected.
42
// Function called when a dialog tag is selected.
Line 37... Line 43...
37
function OnDialogTabChange( tabCode )
43
function OnDialogTabChange( tabCode )
38
{
44
{
39
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
45
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
Line 40... Line 46...
40
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
46
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
41
	ShowE('divAdvanced'	, ( tabCode == 'Advanced' ) ) ;
47
	ShowE('divAdvanced'	, ( tabCode == 'Advanced' ) ) ;
42
}
48
}
Line 66... Line 72...
66
 
72
 
67
	// Set the actual uploader URL.
73
	// Set the actual uploader URL.
68
	if ( FCKConfig.FlashUpload )
74
	if ( FCKConfig.FlashUpload )
Line 69... Line 75...
69
		GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
75
		GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
Line 70... Line 76...
70
 
76
 
71
	window.parent.SetAutoSize( true ) ;
77
	dialog.SetAutoSize( true ) ;
-
 
78
 
-
 
79
	// Activate the "OK" button.
72
 
80
	dialog.SetOkButton( true ) ;
Line 73... Line 81...
73
	// Activate the "OK" button.
81
 
74
	window.parent.SetOkButton( true ) ;
82
	SelectField( 'txtUrl' ) ;
75
}
83
}
Line 76... Line -...
76
 
-
 
77
function LoadSelection()
-
 
78
{
84
 
79
	if ( ! oEmbed ) return ;
85
function LoadSelection()
80
 
86
{
Line 81... Line 87...
81
	var sUrl = GetAttribute( oEmbed, 'src', '' ) ;
87
	if ( ! oEmbed ) return ;
82
 
88
 
83
	GetE('txtUrl').value    = GetAttribute( oEmbed, 'src', '' ) ;
89
	GetE('txtUrl').value    = GetAttribute( oEmbed, 'src', '' ) ;
84
	GetE('txtWidth').value  = GetAttribute( oEmbed, 'width', '' ) ;
90
	GetE('txtWidth').value  = GetAttribute( oEmbed, 'width', '' ) ;
85
	GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
91
	GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
86
 
92
 
87
	// Get Advances Attributes
93
	// Get Advances Attributes
88
	GetE('txtAttId').value		= oEmbed.id ;
94
	GetE('txtAttId').value		= oEmbed.id ;
Line 89... Line 95...
89
	GetE('chkAutoPlay').checked	= GetAttribute( oEmbed, 'play', 'true' ) == 'true' ;
95
	GetE('chkAutoPlay').checked	= GetAttribute( oEmbed, 'play', 'true' ) == 'true' ;
90
	GetE('chkLoop').checked		= GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ;
96
	GetE('chkLoop').checked		= GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ;
91
	GetE('chkMenu').checked		= GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ;
97
	GetE('chkMenu').checked		= GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ;
92
	GetE('cmbScale').value		= GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ;
98
	GetE('cmbScale').value		= GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ;
93
	
99
 
94
	GetE('txtAttTitle').value		= oEmbed.title ;
100
	GetE('txtAttTitle').value		= oEmbed.title ;
95
 
101
 
96
	if ( oEditor.FCKBrowserInfo.IsIE )
102
	if ( oEditor.FCKBrowserInfo.IsIE )
97
	{
103
	{
98
		GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ;
104
		GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ;
Line 99... Line 105...
99
		GetE('txtAttStyle').value = oEmbed.style.cssText ;
105
		GetE('txtAttStyle').value = oEmbed.style.cssText ;
100
	}
106
	}
Line 101... Line 107...
101
	else
107
	else
102
	{
108
	{
103
		GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ;
109
		GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ;
104
		GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) ;
110
		GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) || '' ;
105
	}
111
	}
106
 
112
 
107
	UpdatePreview() ;
113
	UpdatePreview() ;
Line 108... Line 114...
108
}
114
}
Line 109... Line 115...
109
 
115
 
110
//#### The OK button was hit.
116
//#### The OK button was hit.
Line -... Line 117...
-
 
117
function Ok()
111
function Ok()
118
{
112
{
119
	if ( GetE('txtUrl').value.length == 0 )
113
	if ( GetE('txtUrl').value.length == 0 )
120
	{
114
	{
121
		dialog.SetSelectedTab( 'Info' ) ;
115
		window.parent.SetSelectedTab( 'Info' ) ;
122
		GetE('txtUrl').focus() ;
116
		GetE('txtUrl').focus() ;
123
 
117
 
124
		alert( oEditor.FCKLang.DlgAlertUrl ) ;
118
		alert( oEditor.FCKLang.DlgAlertUrl ) ;
125
 
119
 
126
		return false ;
120
		return false ;
127
	}
121
	}
128
 
122
 
129
	oEditor.FCKUndo.SaveUndoStep() ;
123
	if ( !oEmbed )
130
	if ( !oEmbed )
124
	{
-
 
125
		oEmbed		= FCK.EditorDocument.createElement( 'EMBED' ) ;
-
 
126
		oFakeImage  = null ;
131
	{
127
	}
132
		oEmbed		= FCK.EditorDocument.createElement( 'EMBED' ) ;
Line 128... Line 133...
128
	UpdateEmbed( oEmbed ) ;
133
		oFakeImage  = null ;
129
	
134
	}
Line 130... Line 135...
130
	if ( !oFakeImage )
135
	UpdateEmbed( oEmbed ) ;
131
	{
136
 
132
		oFakeImage	= oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
137
	if ( !oFakeImage )
133
		oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
138
	{
Line 134... Line 139...
134
		oFakeImage	= FCK.InsertElementAndGetIt( oFakeImage ) ;
139
		oFakeImage	= oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
135
	}
140
		oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
136
	else
141
		oFakeImage	= FCK.InsertElement( oFakeImage ) ;
137
		oEditor.FCKUndo.SaveUndoStep() ;
142
	}
138
	
143
 
Line 139... Line 144...
139
	oEditor.FCKFlashProcessor.RefreshView( oFakeImage, oEmbed ) ;
144
	oEditor.FCKEmbedAndObjectProcessor.RefreshView( oFakeImage, oEmbed ) ;
140
 
145
 
141
	return true ;
146
	return true ;
142
}
147
}
143
 
148
 
144
function UpdateEmbed( e )
149
function UpdateEmbed( e )
Line 145... Line 150...
145
{
150
{
Line 176... Line 181...
176
var ePreview ;
181
var ePreview ;
Line 177... Line 182...
177
 
182
 
178
function SetPreviewElement( previewEl )
183
function SetPreviewElement( previewEl )
179
{
184
{
180
	ePreview = previewEl ;
185
	ePreview = previewEl ;
181
	
186
 
182
	if ( GetE('txtUrl').value.length > 0 )
187
	if ( GetE('txtUrl').value.length > 0 )
183
		UpdatePreview() ;
188
		UpdatePreview() ;
Line 184... Line 189...
184
}
189
}
185
 
190
 
186
function UpdatePreview()
191
function UpdatePreview()
187
{
192
{
188
	if ( !ePreview )
193
	if ( !ePreview )
189
		return ;
194
		return ;
190
		
195
 
Line 191... Line 196...
191
	while ( ePreview.firstChild )
196
	while ( ePreview.firstChild )
192
		ePreview.removeChild( ePreview.firstChild ) ;
197
		ePreview.removeChild( ePreview.firstChild ) ;
193
 
198
 
194
	if ( GetE('txtUrl').value.length == 0 )
199
	if ( GetE('txtUrl').value.length == 0 )
195
		ePreview.innerHTML = ' ' ;
200
		ePreview.innerHTML = ' ' ;
196
	else
201
	else
197
	{
202
	{
198
		var oDoc	= ePreview.ownerDocument || ePreview.document ;
203
		var oDoc	= ePreview.ownerDocument || ePreview.document ;
199
		var e		= oDoc.createElement( 'EMBED' ) ;
204
		var e		= oDoc.createElement( 'EMBED' ) ;
200
		
205
 
201
		e.src		= GetE('txtUrl').value ;
206
		SetAttribute( e, 'src', GetE('txtUrl').value ) ;
202
		e.type		= 'application/x-shockwave-flash' ;
207
		SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;
203
		e.width		= '100%' ;
208
		SetAttribute( e, 'width', '100%' ) ;
204
		e.height	= '100%' ;
209
		SetAttribute( e, 'height', '100%' ) ;
205
		
210
 
Line 206... Line 211...
206
		ePreview.appendChild( e ) ;
211
		ePreview.appendChild( e ) ;
Line 215... Line 220...
215
}
220
}
Line 216... Line 221...
216
 
221
 
217
function SetUrl( url, width, height )
222
function SetUrl( url, width, height )
218
{
223
{
219
	GetE('txtUrl').value = url ;
224
	GetE('txtUrl').value = url ;
220
	
225
 
221
	if ( width )
226
	if ( width )
222
		GetE('txtWidth').value = width ;
227
		GetE('txtWidth').value = width ;
223
		
228
 
224
	if ( height ) 
229
	if ( height )
Line 225... Line 230...
225
		GetE('txtHeight').value = height ;
230
		GetE('txtHeight').value = height ;
Line 226... Line 231...
226
 
231
 
227
	UpdatePreview() ;
232
	UpdatePreview() ;
Line 228... Line 233...
228
 
233
 
229
	window.parent.SetSelectedTab( 'Info' ) ;
234
	dialog.SetSelectedTab( 'Info' ) ;
-
 
235
}
-
 
236
 
-
 
237
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
-
 
238
{
230
}
239
	// Remove animation
231
 
240
	window.parent.Throbber.Hide() ;
232
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
241
	GetE( 'divUpload' ).style.display  = '' ;
233
{
242
 
234
	switch ( errorNumber )
243
	switch ( errorNumber )
Line 249... Line 258...
249
			alert( 'Invalid file type' ) ;
258
			alert( 'Invalid file type' ) ;
250
			return ;
259
			return ;
251
		case 203 :
260
		case 203 :
252
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
261
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
253
			return ;
262
			return ;
-
 
263
		case 500 :
-
 
264
			alert( 'The connector is disabled' ) ;
-
 
265
			break ;
254
		default :
266
		default :
255
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
267
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
256
			return ;
268
			return ;
257
	}
269
	}
Line 264... Line 276...
264
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
276
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
Line 265... Line 277...
265
 
277
 
266
function CheckUpload()
278
function CheckUpload()
267
{
279
{
268
	var sFile = GetE('txtUploadFile').value ;
280
	var sFile = GetE('txtUploadFile').value ;
269
	
281
 
270
	if ( sFile.length == 0 )
282
	if ( sFile.length == 0 )
271
	{
283
	{
272
		alert( 'Please select a file to upload' ) ;
284
		alert( 'Please select a file to upload' ) ;
273
		return false ;
285
		return false ;
274
	}
286
	}
275
	
287
 
276
	if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
288
	if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
277
		( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
289
		( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
278
	{
290
	{
279
		OnUploadCompleted( 202 ) ;
291
		OnUploadCompleted( 202 ) ;
280
		return false ;
292
		return false ;
281
	}
293
	}
-
 
294
 
-
 
295
	// Show animation
-
 
296
	window.parent.Throbber.Show( 100 ) ;
-
 
297
	GetE( 'divUpload' ).style.display  = 'none' ;
282
	
298
 
283
	return true ;
-
 
284
}
299
	return true ;
-
 
300
}