Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1688 → Rev 1921

/branches/livraison_aha/api/fckeditor/editor/dialog/fck_image/fck_image.js
1,27 → 1,33
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2006 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fck_image.js
* Scripts related to the Image dialog window (see fck_image.html).
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* Scripts related to the Image dialog window (see fck_image.html).
*/
 
var oEditor = window.parent.InnerDialogLoaded() ;
var dialog = window.parent ;
var oEditor = dialog.InnerDialogLoaded() ;
var FCK = oEditor.FCK ;
var FCKLang = oEditor.FCKLang ;
var FCKConfig = oEditor.FCKConfig ;
var FCKDebug = oEditor.FCKDebug ;
var FCKTools = oEditor.FCKTools ;
 
var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ;
 
28,16 → 34,16
//#### Dialog Tabs
 
// Set the dialog tabs.
window.parent.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ;
dialog.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ;
 
if ( !bImageButton && !FCKConfig.ImageDlgHideLink )
window.parent.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ;
dialog.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ;
 
if ( FCKConfig.ImageUpload )
window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ;
 
if ( !FCKConfig.ImageDlgHideAdvanced )
window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
 
// Function called when a dialog tag is selected.
function OnDialogTabChange( tabCode )
49,13 → 55,13
}
 
// Get the selected image (if available).
var oImage = FCK.Selection.GetSelectedElement() ;
var oImage = dialog.Selection.GetSelectedElement() ;
 
if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) )
oImage = null ;
 
// Get the active link.
var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;
 
var oImageOriginal ;
 
63,13 → 69,13
{
if ( !eImgPreview )
return ;
 
if ( GetE('txtUrl').value.length == 0 )
{
oImageOriginal = null ;
return ;
}
 
oImageOriginal = document.createElement( 'IMG' ) ; // new Image() ;
 
if ( resetSize )
107,10 → 113,12
if ( FCKConfig.ImageUpload )
GetE('frmUpload').action = FCKConfig.ImageUploadURL ;
 
window.parent.SetAutoSize( true ) ;
dialog.SetAutoSize( true ) ;
 
// Activate the "OK" button.
window.parent.SetOkButton( true ) ;
dialog.SetOkButton( true ) ;
 
SelectField( 'txtUrl' ) ;
}
 
function LoadSelection()
131,24 → 139,26
var iWidth, iHeight ;
 
var regexSize = /^\s*(\d+)px\s*$/i ;
 
if ( oImage.style.width )
{
var aMatch = oImage.style.width.match( regexSize ) ;
if ( aMatch )
var aMatchW = oImage.style.width.match( regexSize ) ;
if ( aMatchW )
{
iWidth = aMatch[1] ;
iWidth = aMatchW[1] ;
oImage.style.width = '' ;
SetAttribute( oImage, 'width' , iWidth ) ;
}
}
 
if ( oImage.style.height )
{
var aMatch = oImage.style.height.match( regexSize ) ;
if ( aMatch )
var aMatchH = oImage.style.height.match( regexSize ) ;
if ( aMatchH )
{
iHeight = aMatch[1] ;
iHeight = aMatchH[1] ;
oImage.style.height = '' ;
SetAttribute( oImage, 'height', iHeight ) ;
}
}
 
160,21 → 170,26
GetE('cmbAttLangDir').value = oImage.dir ;
GetE('txtAttLangCode').value = oImage.lang ;
GetE('txtAttTitle').value = oImage.title ;
GetE('txtAttClasses').value = oImage.getAttribute('class',2) || '' ;
GetE('txtLongDesc').value = oImage.longDesc ;
 
if ( oEditor.FCKBrowserInfo.IsIE )
GetE('txtAttStyle').value = oImage.style.cssText ;
{
GetE('txtAttClasses').value = oImage.className || '' ;
GetE('txtAttStyle').value = oImage.style.cssText ;
}
else
GetE('txtAttStyle').value = oImage.getAttribute('style',2) ;
{
GetE('txtAttClasses').value = oImage.getAttribute('class',2) || '' ;
GetE('txtAttStyle').value = oImage.getAttribute('style',2) ;
}
 
if ( oLink )
{
var sUrl = oLink.getAttribute( '_fcksavedurl' ) ;
if ( sUrl == null )
sUrl = oLink.getAttribute('href',2) ;
GetE('txtLnkUrl').value = sUrl ;
var sLinkUrl = oLink.getAttribute( '_fcksavedurl' ) ;
if ( sLinkUrl == null )
sLinkUrl = oLink.getAttribute('href',2) ;
 
GetE('txtLnkUrl').value = sLinkUrl ;
GetE('cmbLnkTarget').value = oLink.target ;
}
 
186,7 → 201,7
{
if ( GetE('txtUrl').value.length == 0 )
{
window.parent.SetSelectedTab( 'Info' ) ;
dialog.SetSelectedTab( 'Info' ) ;
GetE('txtUrl').focus() ;
 
alert( FCKLang.DlgImgAlertUrl ) ;
206,24 → 221,23
if ( confirm( 'Do you want to transform the selected image button on a simple image?' ) )
oImage = null ;
}
 
oEditor.FCKUndo.SaveUndoStep() ;
if ( !bHasImage )
{
if ( bImageButton )
{
oImage = FCK.EditorDocument.createElement( 'INPUT' ) ;
oImage = FCK.EditorDocument.createElement( 'input' ) ;
oImage.type = 'image' ;
oImage = FCK.InsertElementAndGetIt( oImage ) ;
oImage = FCK.InsertElement( oImage ) ;
}
else
oImage = FCK.CreateElement( 'IMG' ) ;
oImage = FCK.InsertElement( 'img' ) ;
}
else
oEditor.FCKUndo.SaveUndoStep() ;
 
UpdateImage( oImage ) ;
 
var sLnkUrl = GetE('txtLnkUrl').value.trim() ;
var sLnkUrl = GetE('txtLnkUrl').value.Trim() ;
 
if ( sLnkUrl.length == 0 )
{
239,7 → 253,7
if ( !bHasImage )
oEditor.FCKSelection.SelectNode( oImage ) ;
 
oLink = oEditor.FCK.CreateLink( sLnkUrl ) ;
oLink = oEditor.FCK.CreateLink( sLnkUrl )[0] ;
 
if ( !bHasImage )
{
275,13 → 289,18
SetAttribute( e, 'dir' , GetE('cmbAttLangDir').value ) ;
SetAttribute( e, 'lang' , GetE('txtAttLangCode').value ) ;
SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ;
SetAttribute( e, 'class' , GetE('txtAttClasses').value ) ;
SetAttribute( e, 'longDesc' , GetE('txtLongDesc').value ) ;
 
if ( oEditor.FCKBrowserInfo.IsIE )
{
e.className = GetE('txtAttClasses').value ;
e.style.cssText = GetE('txtAttStyle').value ;
}
else
{
SetAttribute( e, 'class' , GetE('txtAttClasses').value ) ;
SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
}
}
 
var eImgPreview ;
294,7 → 313,7
 
UpdatePreview() ;
UpdateOriginal() ;
 
bPreviewInitialized = true ;
}
 
309,7 → 328,7
{
UpdateImage( eImgPreview, true ) ;
 
if ( GetE('txtLnkUrl').value.trim().length > 0 )
if ( GetE('txtLnkUrl').value.Trim().length > 0 )
eImgPreviewLink.href = 'javascript:void(null);' ;
else
SetAttribute( eImgPreviewLink, 'href', '' ) ;
338,11 → 357,11
// Fired when the width or height input texts change
function OnSizeChanged( dimension, value )
{
// Verifies if the aspect ration has to be mantained
// Verifies if the aspect ration has to be maintained
if ( oImageOriginal && bLockRatio )
{
var e = dimension == 'Width' ? GetE('txtHeight') : GetE('txtWidth') ;
 
if ( value.length == 0 || isNaN( value ) )
{
e.value = '' ;
365,6 → 384,11
function ResetSizes()
{
if ( ! oImageOriginal ) return ;
if ( oEditor.FCKBrowserInfo.IsGecko && !oImageOriginal.complete )
{
setTimeout( ResetSizes, 50 ) ;
return ;
}
 
GetE('txtWidth').value = oImageOriginal.width ;
GetE('txtHeight').value = oImageOriginal.height ;
417,12 → 441,16
UpdatePreview() ;
UpdateOriginal( true ) ;
}
window.parent.SetSelectedTab( 'Info' ) ;
 
dialog.SetSelectedTab( 'Info' ) ;
}
 
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
{
// Remove animation
window.parent.Throbber.Hide() ;
GetE( 'divUpload' ).style.display = '' ;
 
switch ( errorNumber )
{
case 0 : // No errors
443,12 → 471,15
case 203 :
alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
return ;
case 500 :
alert( 'The connector is disabled' ) ;
break ;
default :
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
return ;
}
 
sActualBrowser = ''
sActualBrowser = '' ;
SetUrl( fileUrl ) ;
GetE('frmUpload').reset() ;
}
459,13 → 490,13
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 ) ) )
{
472,6 → 503,10
OnUploadCompleted( 202 ) ;
return false ;
}
 
// Show animation
window.parent.Throbber.Show( 100 ) ;
GetE( 'divUpload' ).style.display = 'none' ;
 
return true ;
}
}