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
* Scripts related to the Flash dialog window (see fck_flash.html).
24
var oEditor = window.parent.InnerDialogLoaded() ;
25
var FCK = oEditor.FCK ;
26
var FCKLang = oEditor.FCKLang ;
27
var FCKConfig = oEditor.FCKConfig ;
31
// Set the dialog tabs.
32
window.parent.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
34
if ( FCKConfig.FlashUpload )
35
window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
37
if ( !FCKConfig.FlashDlgHideAdvanced )
38
window.parent.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
40
// Function called when a dialog tag is selected.
41
function OnDialogTabChange( tabCode )
43
ShowE('divInfo' , ( tabCode == 'Info' ) ) ;
44
ShowE('divUpload' , ( tabCode == 'Upload' ) ) ;
45
ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ;
48
// Get the selected flash embed (if available).
49
var oFakeImage = FCK.Selection.GetSelectedElement() ;
54
if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') )
55
oEmbed = FCK.GetRealElement( oFakeImage ) ;
60
window.onload = function()
62
// Translate the dialog box texts.
63
oEditor.FCKLanguageManager.TranslatePage(document) ;
65
// Load the selected element information (if any).
68
// Show/Hide the "Browse Server" button.
69
GetE('tdBrowse').style.display = FCKConfig.FlashBrowser ? '' : 'none' ;
71
// Set the actual uploader URL.
72
if ( FCKConfig.FlashUpload )
73
GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
75
window.parent.SetAutoSize( true ) ;
77
// Activate the "OK" button.
78
window.parent.SetOkButton( true ) ;
81
function LoadSelection()
83
if ( ! oEmbed ) return ;
85
GetE('txtUrl').value = GetAttribute( oEmbed, 'src', '' ) ;
86
GetE('txtWidth').value = GetAttribute( oEmbed, 'width', '' ) ;
87
GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
89
// Get Advances Attributes
90
GetE('txtAttId').value = oEmbed.id ;
91
GetE('chkAutoPlay').checked = GetAttribute( oEmbed, 'play', 'true' ) == 'true' ;
92
GetE('chkLoop').checked = GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ;
93
GetE('chkMenu').checked = GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ;
94
GetE('cmbScale').value = GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ;
96
GetE('txtAttTitle').value = oEmbed.title ;
98
if ( oEditor.FCKBrowserInfo.IsIE )
100
GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ;
101
GetE('txtAttStyle').value = oEmbed.style.cssText ;
105
GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ;
106
GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) || '' ;
112
//#### The OK button was hit.
115
if ( GetE('txtUrl').value.length == 0 )
117
window.parent.SetSelectedTab( 'Info' ) ;
118
GetE('txtUrl').focus() ;
120
alert( oEditor.FCKLang.DlgAlertUrl ) ;
125
oEditor.FCKUndo.SaveUndoStep() ;
128
oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ;
131
UpdateEmbed( oEmbed ) ;
135
oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
136
oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
137
oFakeImage = FCK.InsertElement( oFakeImage ) ;
140
oEditor.FCKFlashProcessor.RefreshView( oFakeImage, oEmbed ) ;
145
function UpdateEmbed( e )
147
SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
148
SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
150
SetAttribute( e, 'src', GetE('txtUrl').value ) ;
151
SetAttribute( e, "width" , GetE('txtWidth').value ) ;
152
SetAttribute( e, "height", GetE('txtHeight').value ) ;
154
// Advances Attributes
156
SetAttribute( e, 'id' , GetE('txtAttId').value ) ;
157
SetAttribute( e, 'scale', GetE('cmbScale').value ) ;
159
SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
160
SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ;
161
SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ;
163
SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ;
165
if ( oEditor.FCKBrowserInfo.IsIE )
167
SetAttribute( e, 'className', GetE('txtAttClasses').value ) ;
168
e.style.cssText = GetE('txtAttStyle').value ;
172
SetAttribute( e, 'class', GetE('txtAttClasses').value ) ;
173
SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
179
function SetPreviewElement( previewEl )
181
ePreview = previewEl ;
183
if ( GetE('txtUrl').value.length > 0 )
187
function UpdatePreview()
192
while ( ePreview.firstChild )
193
ePreview.removeChild( ePreview.firstChild ) ;
195
if ( GetE('txtUrl').value.length == 0 )
196
ePreview.innerHTML = ' ' ;
199
var oDoc = ePreview.ownerDocument || ePreview.document ;
200
var e = oDoc.createElement( 'EMBED' ) ;
202
SetAttribute( e, 'src', GetE('txtUrl').value ) ;
203
SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;
204
SetAttribute( e, 'width', '100%' ) ;
205
SetAttribute( e, 'height', '100%' ) ;
207
ePreview.appendChild( e ) ;
211
// <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">
213
function BrowseServer()
215
OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ;
218
function SetUrl( url, width, height )
220
GetE('txtUrl').value = url ;
223
GetE('txtWidth').value = width ;
226
GetE('txtHeight').value = height ;
230
window.parent.SetSelectedTab( 'Info' ) ;
233
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
235
switch ( errorNumber )
237
case 0 : // No errors
238
alert( 'Your file has been successfully uploaded' ) ;
240
case 1 : // Custom error
243
case 101 : // Custom warning
247
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
250
alert( 'Invalid file type' ) ;
253
alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
256
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
261
GetE('frmUpload').reset() ;
264
var oUploadAllowedExtRegex = new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ;
265
var oUploadDeniedExtRegex = new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
267
function CheckUpload()
269
var sFile = GetE('txtUploadFile').value ;
271
if ( sFile.length == 0 )
273
alert( 'Please select a file to upload' ) ;
277
if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
278
( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
280
OnUploadCompleted( 202 ) ;