Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1921
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
 */
-
 
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 ;
23
var FCKConfig	= oEditor.FCKConfig ;
28
var FCKConfig	= oEditor.FCKConfig ;
-
 
29
var FCKTools	= oEditor.FCKTools ;
24
 
30
 
25
//#### Dialog Tabs
31
//#### Dialog Tabs
26
 
32
 
27
// Set the dialog tabs.
33
// Set the dialog tabs.
28
window.parent.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
34
dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
29
 
35
 
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.
37
function OnDialogTabChange( tabCode )
43
function OnDialogTabChange( tabCode )
38
{
44
{
39
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
45
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
40
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
46
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
41
	ShowE('divAdvanced'	, ( tabCode == 'Advanced' ) ) ;
47
	ShowE('divAdvanced'	, ( tabCode == 'Advanced' ) ) ;
42
}
48
}
43
 
49
 
44
// Get the selected flash embed (if available).
50
// Get the selected flash embed (if available).
45
var oFakeImage = FCK.Selection.GetSelectedElement() ;
51
var oFakeImage = dialog.Selection.GetSelectedElement() ;
46
var oEmbed ;
52
var oEmbed ;
47
 
53
 
48
if ( oFakeImage )
54
if ( oFakeImage )
49
{
55
{
50
	if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') )
56
	if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') )
51
		oEmbed = FCK.GetRealElement( oFakeImage ) ;
57
		oEmbed = FCK.GetRealElement( oFakeImage ) ;
52
	else
58
	else
53
		oFakeImage = null ;
59
		oFakeImage = null ;
54
}
60
}
55
 
61
 
56
window.onload = function()
62
window.onload = function()
57
{
63
{
58
	// Translate the dialog box texts.
64
	// Translate the dialog box texts.
59
	oEditor.FCKLanguageManager.TranslatePage(document) ;
65
	oEditor.FCKLanguageManager.TranslatePage(document) ;
60
 
66
 
61
	// Load the selected element information (if any).
67
	// Load the selected element information (if any).
62
	LoadSelection() ;
68
	LoadSelection() ;
63
 
69
 
64
	// Show/Hide the "Browse Server" button.
70
	// Show/Hide the "Browse Server" button.
65
	GetE('tdBrowse').style.display = FCKConfig.FlashBrowser	? '' : 'none' ;
71
	GetE('tdBrowse').style.display = FCKConfig.FlashBrowser	? '' : 'none' ;
66
 
72
 
67
	// Set the actual uploader URL.
73
	// Set the actual uploader URL.
68
	if ( FCKConfig.FlashUpload )
74
	if ( FCKConfig.FlashUpload )
69
		GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
75
		GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
70
 
76
 
71
	window.parent.SetAutoSize( true ) ;
77
	dialog.SetAutoSize( true ) ;
72
 
78
 
-
 
79
	// Activate the "OK" button.
-
 
80
	dialog.SetOkButton( true ) ;
73
	// Activate the "OK" button.
81
 
74
	window.parent.SetOkButton( true ) ;
82
	SelectField( 'txtUrl' ) ;
75
}
83
}
76
 
84
 
77
function LoadSelection()
85
function LoadSelection()
78
{
86
{
79
	if ( ! oEmbed ) return ;
87
	if ( ! oEmbed ) return ;
80
 
-
 
81
	var sUrl = GetAttribute( oEmbed, 'src', '' ) ;
-
 
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 ;
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') || '' ;
99
		GetE('txtAttStyle').value = oEmbed.style.cssText ;
105
		GetE('txtAttStyle').value = oEmbed.style.cssText ;
100
	}
106
	}
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() ;
108
}
114
}
109
 
115
 
110
//#### The OK button was hit.
116
//#### The OK button was hit.
111
function Ok()
117
function Ok()
112
{
118
{
113
	if ( GetE('txtUrl').value.length == 0 )
119
	if ( GetE('txtUrl').value.length == 0 )
114
	{
120
	{
115
		window.parent.SetSelectedTab( 'Info' ) ;
121
		dialog.SetSelectedTab( 'Info' ) ;
116
		GetE('txtUrl').focus() ;
122
		GetE('txtUrl').focus() ;
117
 
123
 
118
		alert( oEditor.FCKLang.DlgAlertUrl ) ;
124
		alert( oEditor.FCKLang.DlgAlertUrl ) ;
119
 
125
 
120
		return false ;
126
		return false ;
121
	}
127
	}
-
 
128
 
122
 
129
	oEditor.FCKUndo.SaveUndoStep() ;
123
	if ( !oEmbed )
130
	if ( !oEmbed )
124
	{
131
	{
125
		oEmbed		= FCK.EditorDocument.createElement( 'EMBED' ) ;
132
		oEmbed		= FCK.EditorDocument.createElement( 'EMBED' ) ;
126
		oFakeImage  = null ;
133
		oFakeImage  = null ;
127
	}
134
	}
128
	UpdateEmbed( oEmbed ) ;
135
	UpdateEmbed( oEmbed ) ;
129
	
136
 
130
	if ( !oFakeImage )
137
	if ( !oFakeImage )
131
	{
138
	{
132
		oFakeImage	= oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
139
		oFakeImage	= oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
133
		oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
140
		oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
134
		oFakeImage	= FCK.InsertElementAndGetIt( oFakeImage ) ;
141
		oFakeImage	= FCK.InsertElement( oFakeImage ) ;
135
	}
142
	}
136
	else
-
 
137
		oEditor.FCKUndo.SaveUndoStep() ;
-
 
138
	
143
 
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 )
145
{
150
{
146
	SetAttribute( e, 'type'			, 'application/x-shockwave-flash' ) ;
151
	SetAttribute( e, 'type'			, 'application/x-shockwave-flash' ) ;
147
	SetAttribute( e, 'pluginspage'	, 'http://www.macromedia.com/go/getflashplayer' ) ;
152
	SetAttribute( e, 'pluginspage'	, 'http://www.macromedia.com/go/getflashplayer' ) ;
148
 
153
 
149
	e.src = GetE('txtUrl').value ;
154
	SetAttribute( e, 'src', GetE('txtUrl').value ) ;
150
	SetAttribute( e, "width" , GetE('txtWidth').value ) ;
155
	SetAttribute( e, "width" , GetE('txtWidth').value ) ;
151
	SetAttribute( e, "height", GetE('txtHeight').value ) ;
156
	SetAttribute( e, "height", GetE('txtHeight').value ) ;
152
	
157
 
153
	// Advances Attributes
158
	// Advances Attributes
154
 
159
 
155
	SetAttribute( e, 'id'	, GetE('txtAttId').value ) ;
160
	SetAttribute( e, 'id'	, GetE('txtAttId').value ) ;
156
	SetAttribute( e, 'scale', GetE('cmbScale').value ) ;
161
	SetAttribute( e, 'scale', GetE('cmbScale').value ) ;
157
	
162
 
158
	SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
163
	SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
159
	SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ;
164
	SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ;
160
	SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ;
165
	SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ;
161
 
166
 
162
	SetAttribute( e, 'title'	, GetE('txtAttTitle').value ) ;
167
	SetAttribute( e, 'title'	, GetE('txtAttTitle').value ) ;
163
 
168
 
164
	if ( oEditor.FCKBrowserInfo.IsIE )
169
	if ( oEditor.FCKBrowserInfo.IsIE )
165
	{
170
	{
166
		SetAttribute( e, 'className', GetE('txtAttClasses').value ) ;
171
		SetAttribute( e, 'className', GetE('txtAttClasses').value ) ;
167
		e.style.cssText = GetE('txtAttStyle').value ;
172
		e.style.cssText = GetE('txtAttStyle').value ;
168
	}
173
	}
169
	else
174
	else
170
	{
175
	{
171
		SetAttribute( e, 'class', GetE('txtAttClasses').value ) ;
176
		SetAttribute( e, 'class', GetE('txtAttClasses').value ) ;
172
		SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
177
		SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
173
	}
178
	}
174
}
179
}
175
 
180
 
176
var ePreview ;
181
var ePreview ;
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() ;
184
}
189
}
185
 
190
 
186
function UpdatePreview()
191
function UpdatePreview()
187
{
192
{
188
	if ( !ePreview )
193
	if ( !ePreview )
189
		return ;
194
		return ;
190
		
195
 
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
 
206
		ePreview.appendChild( e ) ;
211
		ePreview.appendChild( e ) ;
207
	}
212
	}
208
}
213
}
209
 
214
 
210
// <embed id="ePreview" src="fck_flash/claims.swf" width="100%" height="100%" style="visibility:hidden" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
215
// <embed id="ePreview" src="fck_flash/claims.swf" width="100%" height="100%" style="visibility:hidden" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
211
 
216
 
212
function BrowseServer()
217
function BrowseServer()
213
{
218
{
214
	OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ;
219
	OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ;
215
}
220
}
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 )
225
		GetE('txtHeight').value = height ;
230
		GetE('txtHeight').value = height ;
226
 
231
 
227
	UpdatePreview() ;
232
	UpdatePreview() ;
228
 
233
 
229
	window.parent.SetSelectedTab( 'Info' ) ;
234
	dialog.SetSelectedTab( 'Info' ) ;
230
}
235
}
231
 
236
 
232
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
237
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
233
{
238
{
-
 
239
	// Remove animation
-
 
240
	window.parent.Throbber.Hide() ;
-
 
241
	GetE( 'divUpload' ).style.display  = '' ;
-
 
242
 
234
	switch ( errorNumber )
243
	switch ( errorNumber )
235
	{
244
	{
236
		case 0 :	// No errors
245
		case 0 :	// No errors
237
			alert( 'Your file has been successfully uploaded' ) ;
246
			alert( 'Your file has been successfully uploaded' ) ;
238
			break ;
247
			break ;
239
		case 1 :	// Custom error
248
		case 1 :	// Custom error
240
			alert( customMsg ) ;
249
			alert( customMsg ) ;
241
			return ;
250
			return ;
242
		case 101 :	// Custom warning
251
		case 101 :	// Custom warning
243
			alert( customMsg ) ;
252
			alert( customMsg ) ;
244
			break ;
253
			break ;
245
		case 201 :
254
		case 201 :
246
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
255
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
247
			break ;
256
			break ;
248
		case 202 :
257
		case 202 :
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
	}
258
 
270
 
259
	SetUrl( fileUrl ) ;
271
	SetUrl( fileUrl ) ;
260
	GetE('frmUpload').reset() ;
272
	GetE('frmUpload').reset() ;
261
}
273
}
262
 
274
 
263
var oUploadAllowedExtRegex	= new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ;
275
var oUploadAllowedExtRegex	= new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ;
264
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
276
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
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
	}
282
	
294
 
-
 
295
	// Show animation
-
 
296
	window.parent.Throbber.Show( 100 ) ;
-
 
297
	GetE( 'divUpload' ).style.display  = 'none' ;
-
 
298
 
283
	return true ;
299
	return true ;
284
}
-
 
285
300
}
-
 
301