From: Thyamad c. <th...@us...> - 2005-09-29 19:50:09
|
Update of /cvsroot/thyapi/thyapi/thywidgets/external/fckeditor/editor/dialog/fck_image In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv563/thywidgets/external/fckeditor/editor/dialog/fck_image Modified Files: fck_image.js Log Message: Commiting file additions and modification from SVN revision 2028 to 2029... Changes made by frank on 2005-09-29 21:42:57 +0200 (Thu, 29 Sep 2005) corresponding to SVN revision 2029 with message: updating fckeditor in dynapi Index: fck_image.js =================================================================== RCS file: /cvsroot/thyapi/thyapi/thywidgets/external/fckeditor/editor/dialog/fck_image/fck_image.js,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fck_image.js 1 Sep 2005 18:15:42 -0000 1.1 --- fck_image.js 29 Sep 2005 19:49:18 -0000 1.2 *************** *** 1,5 **** ! /* * FCKeditor - The text editor for internet ! * Copyright (C) 2003-2004 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: --- 1,5 ---- ! /* * FCKeditor - The text editor for internet ! * Copyright (C) 2003-2005 Frederico Caldeira Knabben * * Licensed under the terms of the GNU Lesser General Public License: *************** *** 10,32 **** * * File Name: fck_image.js ! * Scripts related to the Link dialog window (see fck_link.html). ! * ! * Version: 2.0 RC3 ! * Modified: 2005-02-19 17:12:36 * * File Authors: ! * Frederico Caldeira Knabben (fr...@fc...) ! */ ! var oEditor = window.parent.InnerDialogLoaded() ; ! var FCK = oEditor.FCK ; //#### Dialog Tabs // Set the dialog tabs. ! window.parent.AddTab( 'Info', oEditor.FCKLang.DlgImgInfoTab ) ; ! // TODO : Enable File Upload (1/3). ! //window.parent.AddTab( 'Upload', 'Upload', true ) ; ! window.parent.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ; // Function called when a dialog tag is selected. --- 10,39 ---- * * File Name: fck_image.js ! * Scripts related to the Image dialog window (see fck_image.html). * * File Authors: ! * Frederico Caldeira Knabben (fr...@fc...) ! */ ! var oEditor = window.parent.InnerDialogLoaded() ; ! var FCK = oEditor.FCK ; ! var FCKLang = oEditor.FCKLang ; ! var FCKConfig = oEditor.FCKConfig ; ! ! var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ; //#### Dialog Tabs // Set the dialog tabs. ! window.parent.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ; ! ! if ( !bImageButton && !FCKConfig.ImageDlgHideLink ) ! window.parent.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ; ! ! if ( FCKConfig.ImageUpload ) ! window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; ! ! if ( !FCKConfig.ImageDlgHideAdvanced ) ! window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ; // Function called when a dialog tag is selected. *************** *** 34,44 **** { ShowE('divInfo' , ( tabCode == 'Info' ) ) ; ! // TODO : Enable File Upload (2/3). ! // ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; } - var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ; - // Get the selected image (if available). var oImage = FCK.Selection.GetSelectedElement() ; --- 41,49 ---- { ShowE('divInfo' , ( tabCode == 'Info' ) ) ; ! ShowE('divLink' , ( tabCode == 'Link' ) ) ; ! ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; } // Get the selected image (if available). var oImage = FCK.Selection.GetSelectedElement() ; *************** *** 47,66 **** oImage = null ; var oImageOriginal ; function UpdateOriginal( resetSize ) { ! oImageOriginal = document.createElement( 'IMG' ) ; // new Image() ; ! ! if ( resetSize ) ! { ! oImageOriginal.onload = function() ! { ! this.onload = null ; ! ResetSizes() ; ! } } ! ! oImageOriginal.src = GetE('imgPreview').src ; } --- 52,74 ---- oImage = null ; + // Get the active link. + var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ; + var oImageOriginal ; function UpdateOriginal( resetSize ) { ! oImageOriginal = document.createElement( 'IMG' ) ; // new Image() ; ! ! if ( resetSize ) ! { ! oImageOriginal.onload = function() ! { ! this.onload = null ; ! ResetSizes() ; ! } } ! ! oImageOriginal.src = GetE('imgPreview').src ; } *************** *** 70,75 **** oEditor.FCKLanguageManager.TranslatePage(document) ; ! GetE('btnLockSizes').title = oEditor.FCKLang.DlgImgLockRatio ; ! GetE('btnResetSize').title = oEditor.FCKLang.DlgBtnResetSize ; // Load the selected element information (if any). --- 78,83 ---- oEditor.FCKLanguageManager.TranslatePage(document) ; ! GetE('btnLockSizes').title = FCKLang.DlgImgLockRatio ; ! GetE('btnResetSize').title = FCKLang.DlgBtnResetSize ; // Load the selected element information (if any). *************** *** 77,84 **** // Show/Hide the "Browse Server" button. ! GetE('tdBrowse').style.display = oEditor.FCKConfig.ImageBrowser ? '' : 'none' ; UpdateOriginal() ; window.parent.SetAutoSize( true ) ; --- 85,97 ---- // Show/Hide the "Browse Server" button. ! GetE('tdBrowse').style.display = FCKConfig.ImageBrowser ? '' : 'none' ; ! GetE('divLnkBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; UpdateOriginal() ; + // Set the actual uploader URL. + if ( FCKConfig.ImageUpload ) + GetE('frmUpload').action = FCKConfig.ImageUploadURL ; + window.parent.SetAutoSize( true ) ; *************** *** 91,116 **** if ( ! oImage ) return ; ! var sUrl = GetAttribute( oImage, 'src', '' ) ; ! // TODO: Wait stable version and remove the following commented lines. // if ( sUrl.startsWith( FCK.BaseUrl ) ) // sUrl = sUrl.remove( 0, FCK.BaseUrl.length ) ; ! GetE('txtUrl').value = sUrl ; ! GetE('txtAlt').value = GetAttribute( oImage, 'alt', '' ) ; ! GetE('txtVSpace').value = GetAttribute( oImage, 'vspace', '' ) ; ! GetE('txtHSpace').value = GetAttribute( oImage, 'hspace', '' ) ; ! GetE('txtBorder').value = GetAttribute( oImage, 'border', '' ) ; ! GetE('cmbAlign').value = GetAttribute( oImage, 'align', '' ) ; ! ! if ( oImage.style.pixelWidth > 0 ) ! GetE('txtWidth').value = oImage.style.pixelWidth ; ! else ! GetE('txtWidth').value = GetAttribute( oImage, "width", '' ) ; ! ! if ( oImage.style.pixelHeight > 0 ) ! GetE('txtHeight').value = oImage.style.pixelHeight ; ! else ! GetE('txtHeight').value = GetAttribute( oImage, "height", '' ) ; // Get Advances Attributes --- 104,129 ---- if ( ! oImage ) return ; ! var sUrl = GetAttribute( oImage, 'src', '' ) ; ! // TODO: Wait stable version and remove the following commented lines. // if ( sUrl.startsWith( FCK.BaseUrl ) ) // sUrl = sUrl.remove( 0, FCK.BaseUrl.length ) ; ! GetE('txtUrl').value = sUrl ; ! GetE('txtAlt').value = GetAttribute( oImage, 'alt', '' ) ; ! GetE('txtVSpace').value = GetAttribute( oImage, 'vspace', '' ) ; ! GetE('txtHSpace').value = GetAttribute( oImage, 'hspace', '' ) ; ! GetE('txtBorder').value = GetAttribute( oImage, 'border', '' ) ; ! GetE('cmbAlign').value = GetAttribute( oImage, 'align', '' ) ; ! ! if ( oImage.style.pixelWidth > 0 ) ! GetE('txtWidth').value = oImage.style.pixelWidth ; ! else ! GetE('txtWidth').value = GetAttribute( oImage, "width", '' ) ; ! ! if ( oImage.style.pixelHeight > 0 ) ! GetE('txtHeight').value = oImage.style.pixelHeight ; ! else ! GetE('txtHeight').value = GetAttribute( oImage, "height", '' ) ; // Get Advances Attributes *************** *** 127,130 **** --- 140,149 ---- GetE('txtAttStyle').value = oImage.getAttribute('style',2) ; + if ( oLink ) + { + GetE('txtLnkUrl').value = oLink.getAttribute('href',2) ; + GetE('cmbLnkTarget').value = oLink.target ; + } + UpdatePreview() ; } *************** *** 138,158 **** GetE('txtUrl').focus() ; ! alert( oEditor.FCKLang.DlgImgAlertUrl ) ; return false ; } ! if ( oImage && bImageButton && oImage.tagName == 'IMG' ) { if ( confirm( 'Do you want to transform the selected image on a image button?' ) ) oImage = null ; } ! else if ( oImage && !bImageButton && oImage.tagName == 'INPUT' ) { if ( confirm( 'Do you want to transform the selected image button on a simple image?' ) ) oImage = null ; } ! ! if ( !oImage ) { if ( bImageButton ) --- 157,179 ---- GetE('txtUrl').focus() ; ! alert( FCKLang.DlgImgAlertUrl ) ; return false ; } ! var bHasImage = ( oImage != null ) ; ! ! if ( bHasImage && bImageButton && oImage.tagName == 'IMG' ) { if ( confirm( 'Do you want to transform the selected image on a image button?' ) ) oImage = null ; } ! else if ( bHasImage && !bImageButton && oImage.tagName == 'INPUT' ) { if ( confirm( 'Do you want to transform the selected image button on a simple image?' ) ) oImage = null ; } ! ! if ( !bHasImage ) { if ( bImageButton ) *************** *** 165,171 **** oImage = FCK.CreateElement( 'IMG' ) ; } ! UpdateImage( oImage ) ; return true ; } --- 186,222 ---- oImage = FCK.CreateElement( 'IMG' ) ; } ! else ! oEditor.FCKUndo.SaveUndoStep() ; ! UpdateImage( oImage ) ; + var sLnkUrl = GetE('txtLnkUrl').value.trim() ; + + if ( sLnkUrl.length == 0 ) + { + if ( oLink ) + FCK.ExecuteNamedCommand( 'Unlink' ) ; + } + else + { + if ( oLink ) // Modifying an existent link. + oLink.href = sLnkUrl ; + else // Creating a new link. + { + if ( !bHasImage ) + oEditor.FCKSelection.SelectNode( oImage ) ; + + oLink = oEditor.FCK.CreateLink( sLnkUrl ) ; + + if ( !bHasImage ) + { + oEditor.FCKSelection.SelectNode( oLink ) ; + oEditor.FCKSelection.Collapse( false ) ; + } + } + + SetAttribute( oLink, 'target', GetE('cmbLnkTarget').value ) ; + } + return true ; } *************** *** 173,183 **** function UpdateImage( e, skipId ) { ! e.src = GetE('txtUrl').value ; ! SetAttribute( e, "alt" , GetE('txtAlt').value ) ; ! SetAttribute( e, "width" , GetE('txtWidth').value ) ; ! SetAttribute( e, "height", GetE('txtHeight').value ) ; ! SetAttribute( e, "vspace", GetE('txtVSpace').value ) ; ! SetAttribute( e, "hspace", GetE('txtHSpace').value ) ; ! SetAttribute( e, "border", GetE('txtBorder').value ) ; SetAttribute( e, "align" , GetE('cmbAlign').value ) ; --- 224,234 ---- function UpdateImage( e, skipId ) { ! e.src = GetE('txtUrl').value ; ! SetAttribute( e, "alt" , GetE('txtAlt').value ) ; ! SetAttribute( e, "width" , GetE('txtWidth').value ) ; ! SetAttribute( e, "height", GetE('txtHeight').value ) ; ! SetAttribute( e, "vspace", GetE('txtVSpace').value ) ; ! SetAttribute( e, "hspace", GetE('txtHSpace').value ) ; ! SetAttribute( e, "border", GetE('txtBorder').value ) ; SetAttribute( e, "align" , GetE('cmbAlign').value ) ; *************** *** 202,208 **** { if ( GetE('txtUrl').value.length == 0 ) ! GetE('imgPreview').style.display = 'none' ; else UpdateImage( GetE('imgPreview'), true ) ; } --- 253,268 ---- { if ( GetE('txtUrl').value.length == 0 ) ! GetE('lnkPreview').style.display = 'none' ; else + { UpdateImage( GetE('imgPreview'), true ) ; + + if ( GetE('txtLnkUrl').value.trim().length > 0 ) + GetE('lnkPreview').href = 'javascript:void(null);' ; + else + SetAttribute( GetE('lnkPreview'), 'href', '' ) ; + + GetE('lnkPreview').style.display = '' ; + } } *************** *** 224,288 **** } ! // Fired when the width or height input texts change ! function OnSizeChanged( dimension, value ) ! { ! // Verifies if the aspect ration has to be mantained ! if ( oImageOriginal && bLockRatio ) ! { ! if ( value.length == 0 || isNaN( value ) ) ! { ! GetE('txtHeight').value = GetE('txtWidth').value = '' ; ! return ; ! } ! ! if ( dimension == 'Width' ) ! GetE('txtHeight').value = Math.round( oImageOriginal.height * ( value / oImageOriginal.width ) ) ; ! else ! GetE('txtWidth').value = Math.round( oImageOriginal.width * ( value / oImageOriginal.height ) ) ; ! } ! ! UpdatePreview() ; } - // Fired when the Reset Size button is clicked - function ResetSizes() - { - if ( ! oImageOriginal ) return ; - - GetE('txtWidth').value = oImageOriginal.width ; - GetE('txtHeight').value = oImageOriginal.height ; - - UpdatePreview() ; - } - function BrowseServer() { ! // Set the browser window feature. ! var iWidth = oEditor.FCKConfig.ImageBrowserWindowWidth ; ! var iHeight = oEditor.FCKConfig.ImageBrowserWindowHeight ; ! var iLeft = (screen.width - iWidth) / 2 ; ! var iTop = (screen.height - iHeight) / 2 ; var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ; ! sOptions += ",width=" + iWidth ; ! sOptions += ",height=" + iHeight ; sOptions += ",left=" + iLeft ; sOptions += ",top=" + iTop ; ! // Open the browser window. ! var oWindow = window.open( oEditor.FCKConfig.ImageBrowserURL, "FCKBrowseWindow", sOptions ) ; } function SetUrl( url, width, height, alt ) { ! GetE('txtUrl').value = url ; ! GetE('txtWidth').value = width ? width : '' ; ! GetE('txtHeight').value = height ? height : '' ; ! if ( alt ) ! GetE('txtAlt').value = alt; ! UpdatePreview() ; ! UpdateOriginal( true ) ; } --- 284,430 ---- } ! // Fired when the width or height input texts change ! function OnSizeChanged( dimension, value ) ! { ! // Verifies if the aspect ration has to be mantained ! if ( oImageOriginal && bLockRatio ) ! { ! if ( value.length == 0 || isNaN( value ) ) ! { ! GetE('txtHeight').value = GetE('txtWidth').value = '' ; ! return ; ! } ! ! if ( dimension == 'Width' ) ! GetE('txtHeight').value = value == 0 ? 0 : Math.round( oImageOriginal.height * ( value / oImageOriginal.width ) ) ; ! else ! GetE('txtWidth').value = value == 0 ? 0 : Math.round( oImageOriginal.width * ( value / oImageOriginal.height ) ) ; ! } ! ! UpdatePreview() ; ! } ! ! // Fired when the Reset Size button is clicked ! function ResetSizes() ! { ! if ( ! oImageOriginal ) return ; ! ! GetE('txtWidth').value = oImageOriginal.width ; ! GetE('txtHeight').value = oImageOriginal.height ; ! ! UpdatePreview() ; } function BrowseServer() { ! OpenServerBrowser( ! 'Image', ! FCKConfig.ImageBrowserURL, ! FCKConfig.ImageBrowserWindowWidth, ! FCKConfig.ImageBrowserWindowHeight ) ; ! } ! function LnkBrowseServer() ! { ! OpenServerBrowser( ! 'Link', ! FCKConfig.LinkBrowserURL, ! FCKConfig.LinkBrowserWindowWidth, ! FCKConfig.LinkBrowserWindowHeight ) ; ! } ! ! function OpenServerBrowser( type, url, width, height ) ! { ! sActualBrowser = type ; ! ! var iLeft = (screen.width - width) / 2 ; ! var iTop = (screen.height - height) / 2 ; var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ; ! sOptions += ",width=" + width ; ! sOptions += ",height=" + height ; sOptions += ",left=" + iLeft ; sOptions += ",top=" + iTop ; ! var oWindow = window.open( url, "FCKBrowseWindow", sOptions ) ; } + var sActualBrowser ; + function SetUrl( url, width, height, alt ) { ! if ( sActualBrowser == 'Link' ) ! { ! GetE('txtLnkUrl').value = url ; ! UpdatePreview() ; ! } ! else ! { ! GetE('txtUrl').value = url ; ! GetE('txtWidth').value = width ? width : '' ; ! GetE('txtHeight').value = height ? height : '' ; ! ! if ( alt ) ! GetE('txtAlt').value = alt; ! ! UpdatePreview() ; ! UpdateOriginal( true ) ; ! } ! window.parent.SetSelectedTab( 'Info' ) ; ! } ! function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) ! { ! switch ( errorNumber ) ! { ! case 0 : // No errors ! alert( 'Your file has been successfully uploaded' ) ; ! break ; ! case 1 : // Custom error ! alert( customMsg ) ; ! return ; ! case 101 : // Custom warning ! alert( customMsg ) ; ! break ; ! case 201 : ! alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; ! break ; ! case 202 : ! alert( 'Invalid file type' ) ; ! return ; ! case 203 : ! alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; ! return ; ! default : ! alert( 'Error on file upload. Error number: ' + errorNumber ) ; ! return ; ! } ! ! sActualBrowser = '' ! SetUrl( fileUrl ) ; ! GetE('frmUpload').reset() ; } + + var oUploadAllowedExtRegex = new RegExp( FCKConfig.ImageUploadAllowedExtensions, 'i' ) ; + var oUploadDeniedExtRegex = new RegExp( FCKConfig.ImageUploadDeniedExtensions, 'i' ) ; + + function CheckUpload() + { + var sFile = GetE('txtUploadFile').value ; + + if ( sFile.length == 0 ) + { + alert( 'Please select a file to upload' ) ; + return false ; + } + + if ( ( FCKConfig.ImageUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || + ( FCKConfig.ImageUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) + { + OnUploadCompleted( 202 ) ; + return false ; + } + + return true ; + } \ No newline at end of file |