[ Index ] |
|
Code source de FCKeditor 2.4 |
1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2003-2007 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 * 21 * File Name: fck_flash.js 22 * Scripts related to the Flash dialog window (see fck_flash.html). 23 * 24 * File Authors: 25 * Frederico Caldeira Knabben (www.fckeditor.net) 26 */ 27 28 var oEditor = window.parent.InnerDialogLoaded() ; 29 var FCK = oEditor.FCK ; 30 var FCKLang = oEditor.FCKLang ; 31 var FCKConfig = oEditor.FCKConfig ; 32 33 //#### Dialog Tabs 34 35 // Set the dialog tabs. 36 window.parent.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ; 37 38 if ( FCKConfig.FlashUpload ) 39 window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; 40 41 if ( !FCKConfig.FlashDlgHideAdvanced ) 42 window.parent.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ; 43 44 // Function called when a dialog tag is selected. 45 function OnDialogTabChange( tabCode ) 46 { 47 ShowE('divInfo' , ( tabCode == 'Info' ) ) ; 48 ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; 49 ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; 50 } 51 52 // Get the selected flash embed (if available). 53 var oFakeImage = FCK.Selection.GetSelectedElement() ; 54 var oEmbed ; 55 56 if ( oFakeImage ) 57 { 58 if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') ) 59 oEmbed = FCK.GetRealElement( oFakeImage ) ; 60 else 61 oFakeImage = null ; 62 } 63 64 window.onload = function() 65 { 66 // Translate the dialog box texts. 67 oEditor.FCKLanguageManager.TranslatePage(document) ; 68 69 // Load the selected element information (if any). 70 LoadSelection() ; 71 72 // Show/Hide the "Browse Server" button. 73 GetE('tdBrowse').style.display = FCKConfig.FlashBrowser ? '' : 'none' ; 74 75 // Set the actual uploader URL. 76 if ( FCKConfig.FlashUpload ) 77 GetE('frmUpload').action = FCKConfig.FlashUploadURL ; 78 79 window.parent.SetAutoSize( true ) ; 80 81 // Activate the "OK" button. 82 window.parent.SetOkButton( true ) ; 83 } 84 85 function LoadSelection() 86 { 87 if ( ! oEmbed ) return ; 88 89 var sUrl = GetAttribute( oEmbed, 'src', '' ) ; 90 91 GetE('txtUrl').value = GetAttribute( oEmbed, 'src', '' ) ; 92 GetE('txtWidth').value = GetAttribute( oEmbed, 'width', '' ) ; 93 GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ; 94 95 // Get Advances Attributes 96 GetE('txtAttId').value = oEmbed.id ; 97 GetE('chkAutoPlay').checked = GetAttribute( oEmbed, 'play', 'true' ) == 'true' ; 98 GetE('chkLoop').checked = GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ; 99 GetE('chkMenu').checked = GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ; 100 GetE('cmbScale').value = GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ; 101 102 GetE('txtAttTitle').value = oEmbed.title ; 103 104 if ( oEditor.FCKBrowserInfo.IsIE ) 105 { 106 GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ; 107 GetE('txtAttStyle').value = oEmbed.style.cssText ; 108 } 109 else 110 { 111 GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ; 112 GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) ; 113 } 114 115 UpdatePreview() ; 116 } 117 118 //#### The OK button was hit. 119 function Ok() 120 { 121 if ( GetE('txtUrl').value.length == 0 ) 122 { 123 window.parent.SetSelectedTab( 'Info' ) ; 124 GetE('txtUrl').focus() ; 125 126 alert( oEditor.FCKLang.DlgAlertUrl ) ; 127 128 return false ; 129 } 130 131 if ( !oEmbed ) 132 { 133 oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ; 134 oFakeImage = null ; 135 } 136 UpdateEmbed( oEmbed ) ; 137 138 if ( !oFakeImage ) 139 { 140 oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ; 141 oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ; 142 oFakeImage = FCK.InsertElementAndGetIt( oFakeImage ) ; 143 } 144 else 145 oEditor.FCKUndo.SaveUndoStep() ; 146 147 oEditor.FCKFlashProcessor.RefreshView( oFakeImage, oEmbed ) ; 148 149 return true ; 150 } 151 152 function UpdateEmbed( e ) 153 { 154 SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ; 155 SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ; 156 157 e.src = GetE('txtUrl').value ; 158 SetAttribute( e, "width" , GetE('txtWidth').value ) ; 159 SetAttribute( e, "height", GetE('txtHeight').value ) ; 160 161 // Advances Attributes 162 163 SetAttribute( e, 'id' , GetE('txtAttId').value ) ; 164 SetAttribute( e, 'scale', GetE('cmbScale').value ) ; 165 166 SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ; 167 SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ; 168 SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ; 169 170 SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ; 171 172 if ( oEditor.FCKBrowserInfo.IsIE ) 173 { 174 SetAttribute( e, 'className', GetE('txtAttClasses').value ) ; 175 e.style.cssText = GetE('txtAttStyle').value ; 176 } 177 else 178 { 179 SetAttribute( e, 'class', GetE('txtAttClasses').value ) ; 180 SetAttribute( e, 'style', GetE('txtAttStyle').value ) ; 181 } 182 } 183 184 var ePreview ; 185 186 function SetPreviewElement( previewEl ) 187 { 188 ePreview = previewEl ; 189 190 if ( GetE('txtUrl').value.length > 0 ) 191 UpdatePreview() ; 192 } 193 194 function UpdatePreview() 195 { 196 if ( !ePreview ) 197 return ; 198 199 while ( ePreview.firstChild ) 200 ePreview.removeChild( ePreview.firstChild ) ; 201 202 if ( GetE('txtUrl').value.length == 0 ) 203 ePreview.innerHTML = ' ' ; 204 else 205 { 206 var oDoc = ePreview.ownerDocument || ePreview.document ; 207 var e = oDoc.createElement( 'EMBED' ) ; 208 209 e.src = GetE('txtUrl').value ; 210 e.type = 'application/x-shockwave-flash' ; 211 e.width = '100%' ; 212 e.height = '100%' ; 213 214 ePreview.appendChild( e ) ; 215 } 216 } 217 218 // <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"> 219 220 function BrowseServer() 221 { 222 OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ; 223 } 224 225 function SetUrl( url, width, height ) 226 { 227 GetE('txtUrl').value = url ; 228 229 if ( width ) 230 GetE('txtWidth').value = width ; 231 232 if ( height ) 233 GetE('txtHeight').value = height ; 234 235 UpdatePreview() ; 236 237 window.parent.SetSelectedTab( 'Info' ) ; 238 } 239 240 function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) 241 { 242 switch ( errorNumber ) 243 { 244 case 0 : // No errors 245 alert( 'Your file has been successfully uploaded' ) ; 246 break ; 247 case 1 : // Custom error 248 alert( customMsg ) ; 249 return ; 250 case 101 : // Custom warning 251 alert( customMsg ) ; 252 break ; 253 case 201 : 254 alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; 255 break ; 256 case 202 : 257 alert( 'Invalid file type' ) ; 258 return ; 259 case 203 : 260 alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; 261 return ; 262 default : 263 alert( 'Error on file upload. Error number: ' + errorNumber ) ; 264 return ; 265 } 266 267 SetUrl( fileUrl ) ; 268 GetE('frmUpload').reset() ; 269 } 270 271 var oUploadAllowedExtRegex = new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ; 272 var oUploadDeniedExtRegex = new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ; 273 274 function CheckUpload() 275 { 276 var sFile = GetE('txtUploadFile').value ; 277 278 if ( sFile.length == 0 ) 279 { 280 alert( 'Please select a file to upload' ) ; 281 return false ; 282 } 283 284 if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || 285 ( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) 286 { 287 OnUploadCompleted( 202 ) ; 288 return false ; 289 } 290 291 return true ; 292 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 15:28:05 2007 | par Balluche grâce à PHPXref 0.7 |