Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 2:57 PM

in-portal

Index: trunk/admin/editor/cmseditor/editor/dialog/fck_image/fck_image.js
===================================================================
--- trunk/admin/editor/cmseditor/editor/dialog/fck_image/fck_image.js (revision 1452)
+++ trunk/admin/editor/cmseditor/editor/dialog/fck_image/fck_image.js (revision 1453)
@@ -1,414 +1,414 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 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/
*
* 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 (fredck@fckeditor.net)
*/
var oEditor = window.parent.InnerDialogLoaded() ;
var FCK = oEditor.FCK ;
var from = 0;
var label = '';
//#### Dialog Tabs
// Set the dialog tabs.
/*
window.parent.AddTab( 'Info', oEditor.FCKLang.DlgImgInfoTab ) ;
window.parent.AddTab( 'Link', oEditor.FCKLang.DlgLinkTag ) ;
*/
var activeTab = 'Info';
// Function called when a dialog tag is selected.
-var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ;
+//var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ;
// Get the selected image (if available).
var oImage = FCK.Selection.GetSelectedElement() ;
function OnDialogTabChange( tabCode )
{
// if (tabCode == 'Info')
// ShowE('divInfo', 1 ) ;
if (tabCode == 'Link') {
if (ValidateUrl()) {
window.parent.parentData['imageTxtUrl'] = GetE('txtUrl').value;
window.parent.parentData['imageTxtAlt'] = GetE('txtAlt').value;
window.parent.parentData['imageTxtVSpace'] = GetE('txtVSpace').value;
window.parent.parentData['imageTxtHSpace'] = GetE('txtHSpace').value;
window.parent.parentData['imageTxtBorder'] = GetE('txtBorder').value;
window.parent.parentData['imageCmbAlign'] = GetE('cmbAlign').value;
window.parent.parentData['imageTxtWidth'] = GetE('txtWidth').value;
window.parent.parentData['imageTxtHeight'] = GetE('txtHeight').value;
window.location.href = 'dialog/fck_link.html?from';
}
}
}
if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) )
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 ;
}
window.onload = function()
{
// Translate the dialog box texts.
oEditor.FCKLanguageManager.TranslatePage(document) ;
GetE('btnLockSizes').title = oEditor.FCKLang.DlgImgLockRatio ;
GetE('btnResetSize').title = oEditor.FCKLang.DlgBtnResetSize ;
// Load the selected element information (if any).
LoadSelection() ;
// Show/Hide the "Browse Server" button.
GetE('tdBrowse').style.display = oEditor.FCKConfig.ImageBrowser ? '' : 'none' ;
UpdateOriginal() ;
window.parent.SetAutoSize( true ) ;
// Activate the "OK" button.
window.parent.SetOkButton( true ) ;
if (window.location.search.substr(1) == 'create') {
window.parent.Ok()
window.parent.close()
}
}
function AddTabs()
{
window.parent.AddTab( 'Info', oEditor.FCKLang.DlgImgInfoTab ) ;
window.parent.AddTab( 'Link', oEditor.FCKLang.DlgLinkTag ) ;
}
function LoadSelection()
{
var sUrl = '';
if (window.parent.parentData['imageTxtUrl'])
{
sUrl = window.parent.parentData['imageTxtUrl'];
GetE('txtUrl').value = window.parent.parentData['imageTxtUrl'];
GetE('txtAlt').value = window.parent.parentData['imageTxtAlt'];
GetE('txtVSpace').value = window.parent.parentData['imageTxtVSpace'];
GetE('txtHSpace').value = window.parent.parentData['imageTxtHSpace'];
GetE('txtBorder').value = window.parent.parentData['imageTxtBorder'];
GetE('cmbAlign').value = window.parent.parentData['imageCmbAlign'];
GetE('txtWidth').value = window.parent.parentData['imageTxtWidth'];
GetE('txtHeight').value = window.parent.parentData['imageTxtHeight'];
}
else if ( ! oImage ) {
AddTabs();
return ;
}
AddTabs();
if (!sUrl) {
sUrl = GetAttribute( oImage, 'src', '' ) ;
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', '' ) ;
label = GetAttribute( oImage, 'label', '' ) ;
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
GetE('txtAttId').value = oImage.id ;
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 ;
else
GetE('txtAttStyle').value = oImage.getAttribute('style',2) ;
}
UpdatePreview() ;
}
//#### The OK button was hit.
function ValidateUrl()
{
if ( GetE('txtUrl').value.length == 0 )
{
window.parent.SetSelectedTab( 'Info' ) ;
GetE('txtUrl').focus() ;
alert( oEditor.FCKLang.DlgImgAlertUrl ) ;
return false ;
} else
return true;
}
function Ok()
{
if (ValidateUrl() == false)
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 ;
}
-
+*/
oImage = null ;
if ( !oImage )
{
//if ( bImageButton )
//{
// oImage = FCK.EditorDocument.createElement( 'INPUT' ) ;
// oImage.type = 'image' ;
// oImage = FCK.InsertElementAndGetIt( oImage ) ;
//}
//else
if (window.location.search.substr(1) != 'create'){
oImage = FCK.CreateElement( 'IMG' ) ;
}
}
if (window.location.search.substr(1) != 'create')
UpdateImage( oImage ) ;
//if (oImage)
if (window.location.search.substr(1) == 'create') {
return CreateMyLink();
} else
return true ;
}
function CreateMyLink()
{
var txtAlt = '';
var sHRef = window.parent.parentData['linkTxtUrl'];
if (window.parent.parentData['linkTxtAlt'])
txtAlt = window.parent.parentData['linkTxtAlt'];
var sType = window.parent.parentData['linkType'];
var sTarget = window.parent.parentData['linkCmbTarget'];
var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
if ( oLink ) {
FCK.Selection.MoveToNode( oLink ) ;
if ( oLink )
oLink.href = sHRef ;
else
{
oLink = oEditor.FCK.CreateLink( sHRef ) ;
if ( ! oLink ) {
return true ;
}
}
if( sTarget != 'popup' )
SetAttribute( oLink, 'target', sTarget) ;
else
SetAttribute( oLink, 'target', null ) ;
if (txtAlt) {
SetAttribute( oLink, 'alt', txtAlt) ;
SetAttribute( oLink, 'title', txtAlt) ;
}
SetAttribute( oLink, 'label', sType);
return true;
} else {
var insert = '<a label="'+sType+'" alt="'+txtAlt+'" title="'+txtAlt+'" href="'+sHRef+'"><img src="'+GetE('imgPreview').src+'" '+GetData('alt','txtAlt')+' '+GetData('width','txtWidth')+' '+GetData('height','txtHeight')+' '+GetData('vspace','txtVSpace')+' '+GetData('hspace','txtHSpace')+' '+GetData('border','txtBorder')+' '+GetData('align','cmbAlign')+' label="'+label+'"></a>';
oEditor.FCK.InsertHtml(insert);
}
}
function GetData(el, el_name)
{
if ( GetE(el_name).value != '') {
return el+'="'+GetE(el_name).value+'"';
} else
return '';
}
function show_props(obj, objName) {
var result = "";
for (var i in obj) {
alert( objName + "." + i + " = " + obj[i] + " \n" );
}
}
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 ) ;
if (GetE('txtBorder').value == '')
GetE('txtBorder').value = 0;
SetAttribute( e, "border", GetE('txtBorder').value ) ;
SetAttribute( e, "align" , GetE('cmbAlign').value ) ;
SetAttribute( e, "label" , label ) ;
// Advances Attributes
if ( ! skipId )
SetAttribute( e, 'id', GetE('txtAttId').value ) ;
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.style.cssText = GetE('txtAttStyle').value ;
else
SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
}
function UpdatePreview()
{
if ( GetE('txtUrl').value.length == 0 )
GetE('imgPreview').style.display = 'none' ;
else
UpdateImage( GetE('imgPreview'), true ) ;
}
var bLockRatio = true ;
function SwitchLock( lockButton )
{
bLockRatio = !bLockRatio ;
lockButton.className = bLockRatio ? 'BtnLocked' : 'BtnUnlocked' ;
lockButton.title = bLockRatio ? 'Lock sizes' : 'Unlock sizes' ;
if ( bLockRatio )
{
if ( GetE('txtWidth').value.length > 0 )
OnSizeChanged( 'Width', GetE('txtWidth').value ) ;
else
OnSizeChanged( 'Height', GetE('txtHeight').value ) ;
}
}
// 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, size )
{
GetE('txtUrl').value = url ;
GetE('txtWidth').value = width ? width : '' ;
GetE('txtHeight').value = height ? height : '' ;
if ( alt )
GetE('txtAlt').value = alt;
UpdatePreview() ;
UpdateOriginal( true ) ;
}
Property changes on: trunk/admin/editor/cmseditor/editor/dialog/fck_image/fck_image.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property

Event Timeline