fck_flash.js
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:8k
源码类别:

OA系统

开发平台:

C#

  1. /*
  2.  * FCKeditor - The text editor for internet
  3.  * Copyright (C) 2003-2006 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.  * "Support Open Source software. What about a donation today?"
  12.  * 
  13.  * File Name: fck_flash.js
  14.  *  Scripts related to the Flash dialog window (see fck_flash.html).
  15.  * 
  16.  * File Authors:
  17.  *  Frederico Caldeira Knabben (fredck@fckeditor.net)
  18.  */
  19. var oEditor = window.parent.InnerDialogLoaded() ;
  20. var FCK = oEditor.FCK ;
  21. var FCKLang = oEditor.FCKLang ;
  22. var FCKConfig = oEditor.FCKConfig ;
  23. //#### Dialog Tabs
  24. // Set the dialog tabs.
  25. window.parent.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ;
  26. if ( FCKConfig.FlashUpload )
  27. window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
  28. if ( !FCKConfig.FlashDlgHideAdvanced )
  29. window.parent.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ;
  30. // Function called when a dialog tag is selected.
  31. function OnDialogTabChange( tabCode )
  32. {
  33. ShowE('divInfo' , ( tabCode == 'Info' ) ) ;
  34. ShowE('divUpload' , ( tabCode == 'Upload' ) ) ;
  35. ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ;
  36. }
  37. // Get the selected flash embed (if available).
  38. var oFakeImage = FCK.Selection.GetSelectedElement() ;
  39. var oEmbed ;
  40. if ( oFakeImage )
  41. {
  42. if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') )
  43. oEmbed = FCK.GetRealElement( oFakeImage ) ;
  44. else
  45. oFakeImage = null ;
  46. }
  47. window.onload = function()
  48. {
  49. // Translate the dialog box texts.
  50. oEditor.FCKLanguageManager.TranslatePage(document) ;
  51. // Load the selected element information (if any).
  52. LoadSelection() ;
  53. // Show/Hide the "Browse Server" button.
  54. GetE('tdBrowse').style.display = FCKConfig.FlashBrowser ? '' : 'none' ;
  55. // Set the actual uploader URL.
  56. if ( FCKConfig.FlashUpload )
  57. GetE('frmUpload').action = FCKConfig.FlashUploadURL ;
  58. window.parent.SetAutoSize( true ) ;
  59. // Activate the "OK" button.
  60. window.parent.SetOkButton( true ) ;
  61. }
  62. function LoadSelection()
  63. {
  64. if ( ! oEmbed ) return ;
  65. var sUrl = GetAttribute( oEmbed, 'src', '' ) ;
  66. GetE('txtUrl').value    = GetAttribute( oEmbed, 'src', '' ) ;
  67. GetE('txtWidth').value  = GetAttribute( oEmbed, 'width', '' ) ;
  68. GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ;
  69. // Get Advances Attributes
  70. GetE('txtAttId').value = oEmbed.id ;
  71. GetE('chkAutoPlay').checked = GetAttribute( oEmbed, 'play', 'true' ) == 'true' ;
  72. GetE('chkLoop').checked = GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ;
  73. GetE('chkMenu').checked = GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ;
  74. GetE('cmbScale').value = GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ;
  75. GetE('txtAttTitle').value = oEmbed.title ;
  76. if ( oEditor.FCKBrowserInfo.IsIE )
  77. {
  78. GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ;
  79. GetE('txtAttStyle').value = oEmbed.style.cssText ;
  80. }
  81. else
  82. {
  83. GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ;
  84. GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) ;
  85. }
  86. UpdatePreview() ;
  87. }
  88. //#### The OK button was hit.
  89. function Ok()
  90. {
  91. if ( GetE('txtUrl').value.length == 0 )
  92. {
  93. window.parent.SetSelectedTab( 'Info' ) ;
  94. GetE('txtUrl').focus() ;
  95. alert( oEditor.FCKLang.DlgAlertUrl ) ;
  96. return false ;
  97. }
  98. if ( !oEmbed )
  99. {
  100. oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ;
  101. oFakeImage  = null ;
  102. }
  103. UpdateEmbed( oEmbed ) ;
  104. if ( !oFakeImage )
  105. {
  106. oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ;
  107. oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ;
  108. oFakeImage = FCK.InsertElementAndGetIt( oFakeImage ) ;
  109. }
  110. else
  111. oEditor.FCKUndo.SaveUndoStep() ;
  112. oEditor.FCKFlashProcessor.RefreshView( oFakeImage, oEmbed ) ;
  113. return true ;
  114. }
  115. function UpdateEmbed( e )
  116. {
  117. SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;
  118. SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ;
  119. e.src = GetE('txtUrl').value ;
  120. SetAttribute( e, "width" , GetE('txtWidth').value ) ;
  121. SetAttribute( e, "height", GetE('txtHeight').value ) ;
  122. // Advances Attributes
  123. SetAttribute( e, 'id' , GetE('txtAttId').value ) ;
  124. SetAttribute( e, 'scale', GetE('cmbScale').value ) ;
  125. SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
  126. SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ;
  127. SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ;
  128. SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ;
  129. if ( oEditor.FCKBrowserInfo.IsIE )
  130. {
  131. SetAttribute( e, 'className', GetE('txtAttClasses').value ) ;
  132. e.style.cssText = GetE('txtAttStyle').value ;
  133. }
  134. else
  135. {
  136. SetAttribute( e, 'class', GetE('txtAttClasses').value ) ;
  137. SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
  138. }
  139. }
  140. var ePreview ;
  141. function SetPreviewElement( previewEl )
  142. {
  143. ePreview = previewEl ;
  144. if ( GetE('txtUrl').value.length > 0 )
  145. UpdatePreview() ;
  146. }
  147. function UpdatePreview()
  148. {
  149. if ( !ePreview )
  150. return ;
  151. while ( ePreview.firstChild )
  152. ePreview.removeChild( ePreview.firstChild ) ;
  153. if ( GetE('txtUrl').value.length == 0 )
  154. ePreview.innerHTML = ' ' ;
  155. else
  156. {
  157. var oDoc = ePreview.ownerDocument || ePreview.document ;
  158. var e = oDoc.createElement( 'EMBED' ) ;
  159. e.src = GetE('txtUrl').value ;
  160. e.type = 'application/x-shockwave-flash' ;
  161. e.width = '100%' ;
  162. e.height = '100%' ;
  163. ePreview.appendChild( e ) ;
  164. }
  165. }
  166. // <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">
  167. function BrowseServer()
  168. {
  169. OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ;
  170. }
  171. function SetUrl( url, width, height )
  172. {
  173. GetE('txtUrl').value = url ;
  174. if ( width )
  175. GetE('txtWidth').value = width ;
  176. if ( height ) 
  177. GetE('txtHeight').value = height ;
  178. UpdatePreview() ;
  179. window.parent.SetSelectedTab( 'Info' ) ;
  180. }
  181. function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
  182. {
  183. switch ( errorNumber )
  184. {
  185. case 0 : // No errors
  186. alert( 'Your file has been successfully uploaded' ) ;
  187. break ;
  188. case 1 : // Custom error
  189. alert( customMsg ) ;
  190. return ;
  191. case 101 : // Custom warning
  192. alert( customMsg ) ;
  193. break ;
  194. case 201 :
  195. alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
  196. break ;
  197. case 202 :
  198. alert( 'Invalid file type' ) ;
  199. return ;
  200. case 203 :
  201. alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
  202. return ;
  203. default :
  204. alert( 'Error on file upload. Error number: ' + errorNumber ) ;
  205. return ;
  206. }
  207. SetUrl( fileUrl ) ;
  208. GetE('frmUpload').reset() ;
  209. }
  210. var oUploadAllowedExtRegex = new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ;
  211. var oUploadDeniedExtRegex = new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ;
  212. function CheckUpload()
  213. {
  214. var sFile = GetE('txtUploadFile').value ;
  215. if ( sFile.length == 0 )
  216. {
  217. alert( 'Please select a file to upload' ) ;
  218. return false ;
  219. }
  220. if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
  221. ( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
  222. {
  223. OnUploadCompleted( 202 ) ;
  224. return false ;
  225. }
  226. return true ;
  227. }