Subversion Repositories Applications.papyrus

Rev

Rev 521 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 521 Rev 875
Line 1... Line 1...
1
/*
1
/*
2
 * FCKeditor - The text editor for internet
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
3
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
4
 * 
4
 * 
5
 * Licensed under the terms of the GNU Lesser General Public License:
5
 * Licensed under the terms of the GNU Lesser General Public License:
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
7
 * 
7
 * 
8
 * For further information visit:
8
 * For further information visit:
Line 19... Line 19...
19
 
19
 
20
var oEditor		= window.parent.InnerDialogLoaded() ;
20
var oEditor		= window.parent.InnerDialogLoaded() ;
21
var FCK			= oEditor.FCK ;
21
var FCK			= oEditor.FCK ;
22
var FCKLang		= oEditor.FCKLang ;
22
var FCKLang		= oEditor.FCKLang ;
-
 
23
var FCKConfig	= oEditor.FCKConfig ;
Line 23... Line 24...
23
var FCKConfig	= oEditor.FCKConfig ;
24
var FCKDebug	= oEditor.FCKDebug ;
Line 24... Line 25...
24
 
25
 
Line 58... Line 59...
58
 
59
 
Line 59... Line 60...
59
var oImageOriginal ;
60
var oImageOriginal ;
60
 
61
 
-
 
62
function UpdateOriginal( resetSize )
-
 
63
{
-
 
64
	if ( !eImgPreview )
61
function UpdateOriginal( resetSize )
65
		return ;
Line 62... Line 66...
62
{
66
		
63
	oImageOriginal = document.createElement( 'IMG' ) ;	// new Image() ;
67
	oImageOriginal = document.createElement( 'IMG' ) ;	// new Image() ;
64
 
68
 
Line 69... Line 73...
69
			this.onload = null ;
73
			this.onload = null ;
70
			ResetSizes() ;
74
			ResetSizes() ;
71
		}
75
		}
72
	}
76
	}
Line 73... Line 77...
73
 
77
 
74
	oImageOriginal.src = GetE('imgPreview').src ;
78
	oImageOriginal.src = eImgPreview.src ;
Line -... Line 79...
-
 
79
}
-
 
80
 
75
}
81
var bPreviewInitialized ;
76
 
82
 
77
window.onload = function()
83
window.onload = function()
78
{
84
{
Line 103... Line 109...
103
 
109
 
104
function LoadSelection()
110
function LoadSelection()
105
{
111
{
Line -... Line 112...
-
 
112
	if ( ! oImage ) return ;
-
 
113
 
106
	if ( ! oImage ) return ;
114
	var sUrl = GetAttribute( oImage, '_fcksavedurl', '' ) ;
Line 107... Line 115...
107
 
115
	if ( sUrl.length == 0 )
108
	var sUrl = GetAttribute( oImage, 'src', '' ) ;
116
		sUrl = GetAttribute( oImage, 'src', '' ) ;
109
 
117
 
Line 116... Line 124...
116
	GetE('txtVSpace').value	= GetAttribute( oImage, 'vspace', '' ) ;
124
	GetE('txtVSpace').value	= GetAttribute( oImage, 'vspace', '' ) ;
117
	GetE('txtHSpace').value	= GetAttribute( oImage, 'hspace', '' ) ;
125
	GetE('txtHSpace').value	= GetAttribute( oImage, 'hspace', '' ) ;
118
	GetE('txtBorder').value	= GetAttribute( oImage, 'border', '' ) ;
126
	GetE('txtBorder').value	= GetAttribute( oImage, 'border', '' ) ;
119
	GetE('cmbAlign').value	= GetAttribute( oImage, 'align', '' ) ;
127
	GetE('cmbAlign').value	= GetAttribute( oImage, 'align', '' ) ;
Line 120... Line 128...
120
 
128
 
121
	if ( oImage.style.pixelWidth > 0 )
-
 
122
		GetE('txtWidth').value  = oImage.style.pixelWidth ;
-
 
123
	else
-
 
Line -... Line 129...
-
 
129
	var iWidth, iHeight ;
-
 
130
 
-
 
131
	var regexSize = /^\s*(\d+)px\s*$/i ;
-
 
132
	
-
 
133
	if ( oImage.style.width )
-
 
134
	{
-
 
135
		var aMatch  = oImage.style.width.match( regexSize ) ;
-
 
136
		if ( aMatch )
-
 
137
		{
-
 
138
			iWidth = aMatch[1] ;
-
 
139
			oImage.style.width = '' ;
-
 
140
		}
124
		GetE('txtWidth').value  = GetAttribute( oImage, "width", '' ) ;
141
	}
-
 
142
 
125
 
143
	if ( oImage.style.height )
-
 
144
	{
126
	if ( oImage.style.pixelHeight > 0 )
145
		var aMatch  = oImage.style.height.match( regexSize ) ;
-
 
146
		if ( aMatch )
-
 
147
		{
-
 
148
			iHeight = aMatch[1] ;
-
 
149
			oImage.style.height = '' ;
-
 
150
		}
-
 
151
	}
127
		GetE('txtHeight').value  = oImage.style.pixelHeight ;
152
 
Line 128... Line 153...
128
	else
153
	GetE('txtWidth').value	= iWidth ? iWidth : GetAttribute( oImage, "width", '' ) ;
129
		GetE('txtHeight').value = GetAttribute( oImage, "height", '' ) ;
154
	GetE('txtHeight').value	= iHeight ? iHeight : GetAttribute( oImage, "height", '' ) ;
130
 
155
 
131
	// Get Advances Attributes
156
	// Get Advances Attributes
Line 141... Line 166...
141
	else
166
	else
142
		GetE('txtAttStyle').value	= oImage.getAttribute('style',2) ;
167
		GetE('txtAttStyle').value	= oImage.getAttribute('style',2) ;
Line 143... Line 168...
143
 
168
 
144
	if ( oLink )
169
	if ( oLink )
-
 
170
	{
-
 
171
		var sUrl = GetAttribute( oLink, '_fcksavedurl', '' ) ;
145
	{
172
		if ( sUrl.length == 0 )
-
 
173
			sUrl = oLink.getAttribute('href',2) ;
-
 
174
	
146
		GetE('txtLnkUrl').value		= oLink.getAttribute('href',2) ;
175
		GetE('txtLnkUrl').value		= sUrl ;
147
		GetE('cmbLnkTarget').value	= oLink.target ;
176
		GetE('cmbLnkTarget').value	= oLink.target ;
Line 148... Line 177...
148
	}
177
	}
149
 
178
 
Line 215... Line 244...
215
				oEditor.FCKSelection.SelectNode( oLink ) ;
244
				oEditor.FCKSelection.SelectNode( oLink ) ;
216
				oEditor.FCKSelection.Collapse( false ) ;
245
				oEditor.FCKSelection.Collapse( false ) ;
217
			}
246
			}
218
		}
247
		}
Line -... Line 248...
-
 
248
 
219
 
249
		SetAttribute( oLink, '_fcksavedurl', sLnkUrl ) ;
220
		SetAttribute( oLink, 'target', GetE('cmbLnkTarget').value ) ;
250
		SetAttribute( oLink, 'target', GetE('cmbLnkTarget').value ) ;
Line 221... Line 251...
221
	}
251
	}
222
 
252
 
Line 223... Line 253...
223
	return true ;
253
	return true ;
224
}
254
}
225
 
255
 
-
 
256
function UpdateImage( e, skipId )
226
function UpdateImage( e, skipId )
257
{
227
{
258
	e.src = GetE('txtUrl').value ;
228
	e.src = GetE('txtUrl').value ;
259
	SetAttribute( e, "_fcksavedurl", GetE('txtUrl').value ) ;
229
	SetAttribute( e, "alt"   , GetE('txtAlt').value ) ;
260
	SetAttribute( e, "alt"   , GetE('txtAlt').value ) ;
230
	SetAttribute( e, "width" , GetE('txtWidth').value ) ;
261
	SetAttribute( e, "width" , GetE('txtWidth').value ) ;
Line 249... Line 280...
249
		e.style.cssText = GetE('txtAttStyle').value ;
280
		e.style.cssText = GetE('txtAttStyle').value ;
250
	else
281
	else
251
		SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
282
		SetAttribute( e, 'style', GetE('txtAttStyle').value ) ;
252
}
283
}
Line -... Line 284...
-
 
284
 
-
 
285
var eImgPreview ;
-
 
286
var eImgPreviewLink ;
-
 
287
 
-
 
288
function SetPreviewElements( imageElement, linkElement )
-
 
289
{
-
 
290
	eImgPreview = imageElement ;
-
 
291
	eImgPreviewLink = linkElement ;
-
 
292
 
-
 
293
	UpdatePreview() ;
-
 
294
	UpdateOriginal() ;
-
 
295
	
-
 
296
	bPreviewInitialized = true ;
-
 
297
}
253
 
298
 
254
function UpdatePreview()
299
function UpdatePreview()
-
 
300
{
-
 
301
	if ( !eImgPreview || !eImgPreviewLink )
-
 
302
		return ;
255
{
303
 
256
	if ( GetE('txtUrl').value.length == 0 )
304
	if ( GetE('txtUrl').value.length == 0 )
257
		GetE('lnkPreview').style.display = 'none' ;
305
		eImgPreviewLink.style.display = 'none' ;
258
	else
306
	else
259
	{
307
	{
Line 260... Line 308...
260
		UpdateImage( GetE('imgPreview'), true ) ;
308
		UpdateImage( eImgPreview, true ) ;
261
 
309
 
262
		if ( GetE('txtLnkUrl').value.trim().length > 0 )
310
		if ( GetE('txtLnkUrl').value.trim().length > 0 )
263
			GetE('lnkPreview').href = 'javascript:void(null);' ;
311
			eImgPreviewLink.href = 'javascript:void(null);' ;
Line 264... Line 312...
264
		else
312
		else
265
			SetAttribute( GetE('lnkPreview'), 'href', '' ) ;
313
			SetAttribute( eImgPreviewLink, 'href', '' ) ;
266
 
314
 
Line 267... Line 315...
267
		GetE('lnkPreview').style.display = '' ;
315
		eImgPreviewLink.style.display = '' ;
Line 289... Line 337...
289
function OnSizeChanged( dimension, value )
337
function OnSizeChanged( dimension, value )
290
{
338
{
291
	// Verifies if the aspect ration has to be mantained
339
	// Verifies if the aspect ration has to be mantained
292
	if ( oImageOriginal && bLockRatio )
340
	if ( oImageOriginal && bLockRatio )
293
	{
341
	{
-
 
342
		var e = dimension == 'Width' ? GetE('txtHeight') : GetE('txtWidth') ;
-
 
343
		
294
		if ( value.length == 0 || isNaN( value ) )
344
		if ( value.length == 0 || isNaN( value ) )
295
		{
345
		{
296
			GetE('txtHeight').value = GetE('txtWidth').value = '' ;
346
			e.value = '' ;
297
			return ;
347
			return ;
298
		}
348
		}
Line 299... Line 349...
299
 
349
 
300
		if ( dimension == 'Width' )
350
		if ( dimension == 'Width' )
301
			GetE('txtHeight').value = value == 0 ? 0 : Math.round( oImageOriginal.height * ( value  / oImageOriginal.width ) ) ;
351
			value = value == 0 ? 0 : Math.round( oImageOriginal.height * ( value  / oImageOriginal.width ) ) ;
302
		else
352
		else
-
 
353
			value = value == 0 ? 0 : Math.round( oImageOriginal.width  * ( value / oImageOriginal.height ) ) ;
-
 
354
 
-
 
355
		if ( !isNaN( value ) )
303
			GetE('txtWidth').value  = value == 0 ? 0 : Math.round( oImageOriginal.width  * ( value / oImageOriginal.height ) ) ;
356
			e.value = value ;
Line 304... Line 357...
304
	}
357
	}
305
 
358
 
Line 336... Line 389...
336
}
389
}
Line 337... Line 390...
337
 
390
 
338
function OpenServerBrowser( type, url, width, height )
391
function OpenServerBrowser( type, url, width, height )
339
{
392
{
340
	sActualBrowser = type ;
-
 
341
 
-
 
342
	var iLeft = (FCKConfig.ScreenWidth  - width) / 2 ;
-
 
343
	var iTop  = (FCKConfig.ScreenHeight - height) / 2 ;
-
 
344
 
-
 
345
	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
-
 
346
	sOptions += ",width=" + width ;
393
	sActualBrowser = type ;
347
	sOptions += ",height=" + height ;
-
 
348
	sOptions += ",left=" + iLeft ;
-
 
349
	sOptions += ",top=" + iTop ;
-
 
350
 
-
 
351
	if ( oEditor.FCKBrowserInfo.IsIE )
-
 
352
	{
-
 
353
		// The following change has been made otherwise IE will open the file 
-
 
354
		// browser on a different server session (on some cases):
-
 
355
		// http://support.microsoft.com/default.aspx?scid=kb;en-us;831678
-
 
356
		// by Simone Chiaretta.
-
 
357
		var oWindow = oEditor.window.open( url, "FCKBrowseWindow", sOptions ) ;
-
 
358
		oWindow.opener = window ;
-
 
359
    }
-
 
360
    else
-
 
361
		window.open( url, "FCKBrowseWindow", sOptions ) ;
394
	OpenFileBrowser( url, width, height ) ;
Line 362... Line 395...
362
}
395
}
Line 363... Line 396...
363
 
396