Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1921
1
/*
1
/*
2
 * FCKeditor - The text editor for internet
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
3
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
-
 
4
 *
-
 
5
 * == BEGIN LICENSE ==
4
 * 
6
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
7
 * Licensed under the terms of any of the following licenses at your
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
8
 * choice:
7
 * 
9
 *
8
 * For further information visit:
10
 *  - GNU General Public License Version 2 or later (the "GPL")
9
 * 		http://www.fckeditor.net/
11
 *    http://www.gnu.org/licenses/gpl.html
10
 * 
12
 *
11
 * "Support Open Source software. What about a donation today?"
13
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
-
 
14
 *    http://www.gnu.org/licenses/lgpl.html
12
 * 
15
 *
13
 * File Name: fck_link.js
16
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
14
 * 	Scripts related to the Link dialog window (see fck_link.html).
17
 *    http://www.mozilla.org/MPL/MPL-1.1.html
15
 * 
18
 *
16
 * File Authors:
19
 * == END LICENSE ==
-
 
20
 *
17
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
21
 * Scripts related to the Link dialog window (see fck_link.html).
18
 * 		Dominik Pesch ?dom? (empty selection patch) (d.pesch@11com7.de)
-
 
19
 */
22
 */
-
 
23
 
20
 
24
var dialog	= window.parent ;
-
 
25
var oEditor = dialog.InnerDialogLoaded() ;
21
var oEditor		= window.parent.InnerDialogLoaded() ;
26
 
22
var FCK			= oEditor.FCK ;
27
var FCK			= oEditor.FCK ;
23
var FCKLang		= oEditor.FCKLang ;
28
var FCKLang		= oEditor.FCKLang ;
24
var FCKConfig	= oEditor.FCKConfig ;
29
var FCKConfig	= oEditor.FCKConfig ;
-
 
30
var FCKRegexLib	= oEditor.FCKRegexLib ;
-
 
31
var FCKTools	= oEditor.FCKTools ;
25
 
32
 
26
//#### Dialog Tabs
33
//#### Dialog Tabs
27
 
34
 
28
// Set the dialog tabs.
35
// Set the dialog tabs.
29
window.parent.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;
36
dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;
30
 
37
 
31
if ( !FCKConfig.LinkDlgHideTarget )
38
if ( !FCKConfig.LinkDlgHideTarget )
32
	window.parent.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;
39
	dialog.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;
33
 
40
 
34
if ( FCKConfig.LinkUpload )
41
if ( FCKConfig.LinkUpload )
35
	window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;
42
	dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;
36
 
43
 
37
if ( !FCKConfig.LinkDlgHideAdvanced )
44
if ( !FCKConfig.LinkDlgHideAdvanced )
38
	window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
45
	dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
39
 
46
 
40
// Function called when a dialog tag is selected.
47
// Function called when a dialog tag is selected.
41
function OnDialogTabChange( tabCode )
48
function OnDialogTabChange( tabCode )
42
{
49
{
43
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
50
	ShowE('divInfo'		, ( tabCode == 'Info' ) ) ;
44
	ShowE('divTarget'	, ( tabCode == 'Target' ) ) ;
51
	ShowE('divTarget'	, ( tabCode == 'Target' ) ) ;
45
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
52
	ShowE('divUpload'	, ( tabCode == 'Upload' ) ) ;
46
	ShowE('divAttribs'	, ( tabCode == 'Advanced' ) ) ;
53
	ShowE('divAttribs'	, ( tabCode == 'Advanced' ) ) ;
47
 
54
 
48
	window.parent.SetAutoSize( true ) ;
55
	dialog.SetAutoSize( true ) ;
49
}
56
}
50
 
57
 
51
//#### Regular Expressions library.
58
//#### Regular Expressions library.
52
var oRegex = new Object() ;
59
var oRegex = new Object() ;
53
 
60
 
-
 
61
oRegex.UriProtocol = /^(((http|https|ftp|news):\/\/)|mailto:)/gi ;
54
oRegex.UriProtocol = new RegExp('') ;
62
 
55
oRegex.UriProtocol.compile( '^(((http|https|ftp|news):\/\/)|mailto:)', 'gi' ) ;
63
oRegex.UrlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi ;
56
 
-
 
57
oRegex.UrlOnChangeProtocol = new RegExp('') ;
64
 
58
oRegex.UrlOnChangeProtocol.compile( '^(http|https|ftp|news)://(?=.)', 'gi' ) ;
-
 
59
 
-
 
60
oRegex.UrlOnChangeTestOther = new RegExp('') ;
-
 
61
//oRegex.UrlOnChangeTestOther.compile( '^(javascript:|#|/)', 'gi' ) ;
65
oRegex.UrlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi ;
62
oRegex.UrlOnChangeTestOther.compile( '^((javascript:)|[#/\.])', 'gi' ) ; 
66
 
63
 
67
oRegex.ReserveTarget = /^_(blank|self|top|parent)$/i ;
64
oRegex.ReserveTarget = new RegExp('') ;
-
 
65
oRegex.ReserveTarget.compile( '^_(blank|self|top|parent)$', 'i' ) ;
68
 
66
 
69
oRegex.PopupUri = /^javascript:void\(\s*window.open\(\s*'([^']+)'\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*\)\s*$/ ;
67
oRegex.PopupUri = new RegExp('') ;
70
 
68
oRegex.PopupUri.compile( "^javascript:void\\(\\s*window.open\\(\\s*'([^']+)'\\s*,\\s*(?:'([^']*)'|null)\\s*,\\s*'([^']*)'\\s*\\)\\s*\\)\\s*$" ) ;
71
// Accessible popups
69
 
72
oRegex.OnClickPopup = /^\s*on[cC]lick="\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*"$/ ;
70
oRegex.PopupFeatures = new RegExp('') ;
73
 
71
oRegex.PopupFeatures.compile( '(?:^|,)([^=]+)=(\\d+|yes|no)', 'gi' ) ;
74
oRegex.PopupFeatures = /(?:^|,)([^=]+)=(\d+|yes|no)/gi ;
72
 
75
 
73
//#### Parser Functions
76
//#### Parser Functions
74
 
77
 
75
var oParser = new Object() ;
78
var oParser = new Object() ;
-
 
79
 
-
 
80
// This method simply returns the two inputs in numerical order. You can even
-
 
81
// provide strings, as the method would parseInt() the values.
-
 
82
oParser.SortNumerical = function(a, b)
-
 
83
{
-
 
84
	return parseInt( a, 10 ) - parseInt( b, 10 ) ;
-
 
85
}
-
 
86
 
-
 
87
oParser.ParseEMailParams = function(sParams)
-
 
88
{
-
 
89
	// Initialize the oEMailParams object.
-
 
90
	var oEMailParams = new Object() ;
-
 
91
	oEMailParams.Subject = '' ;
-
 
92
	oEMailParams.Body = '' ;
-
 
93
 
-
 
94
	var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ;
-
 
95
	if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ;
-
 
96
 
-
 
97
	aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ;
-
 
98
	if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ;
-
 
99
 
-
 
100
	return oEMailParams ;
-
 
101
}
-
 
102
 
-
 
103
// This method returns either an object containing the email info, or FALSE
76
 
104
// if the parameter is not an email link.
77
oParser.ParseEMailUrl = function( emailUrl )
105
oParser.ParseEMailUri = function( sUrl )
78
{
106
{
79
	// Initializes the EMailInfo object.
107
	// Initializes the EMailInfo object.
80
	var oEMailInfo = new Object() ;
108
	var oEMailInfo = new Object() ;
81
	oEMailInfo.Address	= '' ;
109
	oEMailInfo.Address = '' ;
82
	oEMailInfo.Subject	= '' ;
110
	oEMailInfo.Subject = '' ;
83
	oEMailInfo.Body		= '' ;
111
	oEMailInfo.Body = '' ;
-
 
112
 
-
 
113
	var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ;
-
 
114
	if ( aLinkInfo && aLinkInfo[1] == 'mailto' )
-
 
115
	{
-
 
116
		// This seems to be an unprotected email link.
-
 
117
		var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ;
-
 
118
		if ( aParts )
-
 
119
		{
-
 
120
			// Set the e-mail address.
-
 
121
			oEMailInfo.Address = aParts[1] ;
84
 
122
 
85
	var oParts = emailUrl.match( /^([^\?]+)\??(.+)?/ ) ;
123
			// Look for the optional e-mail parameters.
-
 
124
			if ( aParts[2] )
-
 
125
			{
-
 
126
				var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ;
-
 
127
				oEMailInfo.Subject = oEMailParams.Subject ;
-
 
128
				oEMailInfo.Body = oEMailParams.Body ;
-
 
129
			}
-
 
130
		}
-
 
131
		return oEMailInfo ;
-
 
132
	}
86
	if ( oParts )
133
	else if ( aLinkInfo && aLinkInfo[1] == 'javascript' )
87
	{
134
	{
88
		// Set the e-mail address.
-
 
89
		oEMailInfo.Address = oParts[1] ;
135
		// This may be a protected email.
-
 
136
 
90
 
137
		// Try to match the url against the EMailProtectionFunction.
91
		// Look for the optional e-mail parameters.
138
		var func = FCKConfig.EMailProtectionFunction ;
-
 
139
		if ( func != null )
-
 
140
		{
-
 
141
			try
92
		if ( oParts[2] )
142
			{
-
 
143
				// Escape special chars.
-
 
144
				func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ;
93
		{
145
 
-
 
146
				// Define the possible keys.
-
 
147
				var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ;
-
 
148
 
-
 
149
				// Get the order of the keys (hold them in the array <pos>) and
-
 
150
				// the function replaced by regular expression patterns.
-
 
151
				var sFunc = func ;
-
 
152
				var pos = new Array() ;
-
 
153
				for ( var i = 0 ; i < keys.length ; i ++ )
-
 
154
				{
-
 
155
					var rexp = new RegExp( keys[i] ) ;
-
 
156
					var p = func.search( rexp ) ;
-
 
157
					if ( p >= 0 )
-
 
158
					{
-
 
159
						sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ;
-
 
160
						pos[pos.length] = p + ':' + keys[i] ;
-
 
161
					}
-
 
162
				}
-
 
163
 
-
 
164
				// Sort the available keys.
-
 
165
				pos.sort( oParser.SortNumerical ) ;
-
 
166
 
-
 
167
				// Replace the excaped single quotes in the url, such they do
-
 
168
				// not affect the regexp afterwards.
-
 
169
				aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ;
-
 
170
 
-
 
171
				// Create the regexp and execute it.
-
 
172
				var rFunc = new RegExp( '^' + sFunc + '$' ) ;
-
 
173
				var aMatch = rFunc.exec( aLinkInfo[2] ) ;
-
 
174
				if ( aMatch )
-
 
175
				{
94
			var oMatch = oParts[2].match( /(^|&)subject=([^&]+)/i ) ;
176
					var aInfo = new Array();
-
 
177
					for ( var i = 1 ; i < aMatch.length ; i ++ )
-
 
178
					{
-
 
179
						var k = pos[i-1].match(/^\d+:(.+)$/) ;
-
 
180
						aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ;
-
 
181
					}
-
 
182
 
95
			if ( oMatch ) oEMailInfo.Subject = unescape( oMatch[2] ) ;
183
					// Fill the EMailInfo object that will be returned
-
 
184
					oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ;
-
 
185
					oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ;
-
 
186
					oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ;
-
 
187
 
-
 
188
					return oEMailInfo ;
-
 
189
				}
-
 
190
			}
96
 
191
			catch (e)
97
			oMatch = oParts[2].match( /(^|&)body=([^&]+)/i ) ;
-
 
-
 
192
			{
-
 
193
			}
-
 
194
		}
-
 
195
 
-
 
196
		// Try to match the email against the encode protection.
-
 
197
		var aMatch = aLinkInfo[2].match( /^location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'$/ ) ;
-
 
198
		if ( aMatch )
-
 
199
		{
-
 
200
			// The link is encoded
-
 
201
			oEMailInfo.Address = eval( aMatch[1] ) ;
-
 
202
			if ( aMatch[2] )
-
 
203
			{
98
			if ( oMatch ) oEMailInfo.Body = unescape( oMatch[2] ) ;
204
				var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ;
-
 
205
				oEMailInfo.Subject = oEMailParams.Subject ;
-
 
206
				oEMailInfo.Body = oEMailParams.Body ;
-
 
207
			}
99
		}
208
			return oEMailInfo ;
100
	}
209
		}
101
 
210
	}
102
	return oEMailInfo ;
211
	return false;
103
}
212
}
104
 
213
 
105
oParser.CreateEMailUri = function( address, subject, body )
214
oParser.CreateEMailUri = function( address, subject, body )
106
{
215
{
-
 
216
	// Switch for the EMailProtection setting.
-
 
217
	switch ( FCKConfig.EMailProtection )
-
 
218
	{
-
 
219
		case 'function' :
-
 
220
			var func = FCKConfig.EMailProtectionFunction ;
-
 
221
			if ( func == null )
-
 
222
			{
-
 
223
				if ( FCKConfig.Debug )
-
 
224
				{
-
 
225
					alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ;
-
 
226
				}
-
 
227
				return '';
-
 
228
			}
-
 
229
 
-
 
230
			// Split the email address into name and domain parts.
-
 
231
			var aAddressParts = address.split( '@', 2 ) ;
-
 
232
			if ( aAddressParts[1] == undefined )
-
 
233
			{
-
 
234
				aAddressParts[1] = '' ;
-
 
235
			}
-
 
236
 
-
 
237
			// Replace the keys by their values (embedded in single quotes).
-
 
238
			func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ;
-
 
239
			func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ;
-
 
240
			func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ;
-
 
241
			func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ;
-
 
242
 
-
 
243
			return 'javascript:' + func ;
-
 
244
 
-
 
245
		case 'encode' :
-
 
246
			var aParams = [] ;
-
 
247
			var aAddressCode = [] ;
-
 
248
 
-
 
249
			if ( subject.length > 0 )
-
 
250
				aParams.push( 'subject='+ encodeURIComponent( subject ) ) ;
-
 
251
			if ( body.length > 0 )
-
 
252
				aParams.push( 'body=' + encodeURIComponent( body ) ) ;
-
 
253
			for ( var i = 0 ; i < address.length ; i++ )
-
 
254
				aAddressCode.push( address.charCodeAt( i ) ) ;
-
 
255
 
-
 
256
			return 'javascript:location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\'' ;
-
 
257
	}
-
 
258
 
-
 
259
	// EMailProtection 'none'
-
 
260
 
107
	var sBaseUri = 'mailto:' + address ;
261
	var sBaseUri = 'mailto:' + address ;
108
 
262
 
109
	var sParams = '' ;
263
	var sParams = '' ;
110
 
264
 
111
	if ( subject.length > 0 )
265
	if ( subject.length > 0 )
112
		sParams = '?subject=' + escape( subject ) ;
266
		sParams = '?subject=' + encodeURIComponent( subject ) ;
113
 
267
 
114
	if ( body.length > 0 )
268
	if ( body.length > 0 )
115
	{
269
	{
116
		sParams += ( sParams.length == 0 ? '?' : '&' ) ;
270
		sParams += ( sParams.length == 0 ? '?' : '&' ) ;
117
		sParams += 'body=' + escape( body ) ;
271
		sParams += 'body=' + encodeURIComponent( body ) ;
118
	}
272
	}
119
 
273
 
120
	return sBaseUri + sParams ;
274
	return sBaseUri + sParams ;
121
}
275
}
122
 
276
 
123
//#### Initialization Code
277
//#### Initialization Code
124
 
278
 
125
// oLink: The actual selected link in the editor.
279
// oLink: The actual selected link in the editor.
126
var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
280
var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;
127
if ( oLink )
281
if ( oLink )
128
	FCK.Selection.SelectNode( oLink ) ;
282
	FCK.Selection.SelectNode( oLink ) ;
129
 
283
 
130
window.onload = function()
284
window.onload = function()
131
{
285
{
132
	// Translate the dialog box texts.
286
	// Translate the dialog box texts.
133
	oEditor.FCKLanguageManager.TranslatePage(document) ;
287
	oEditor.FCKLanguageManager.TranslatePage(document) ;
134
 
288
 
135
	// Fill the Anchor Names and Ids combos.
289
	// Fill the Anchor Names and Ids combos.
136
	LoadAnchorNamesAndIds() ;
290
	LoadAnchorNamesAndIds() ;
137
 
291
 
138
	// Load the selected link information (if any).
292
	// Load the selected link information (if any).
139
	LoadSelection() ;
293
	LoadSelection() ;
140
 
294
 
141
	// Update the dialog box.
295
	// Update the dialog box.
142
	SetLinkType( GetE('cmbLinkType').value ) ;
296
	SetLinkType( GetE('cmbLinkType').value ) ;
143
 
297
 
144
	// Show/Hide the "Browse Server" button.
298
	// Show/Hide the "Browse Server" button.
145
	GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ;
299
	GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ;
146
 
300
 
147
	// Show the initial dialog content.
301
	// Show the initial dialog content.
148
	GetE('divInfo').style.display = '' ;
302
	GetE('divInfo').style.display = '' ;
149
 
303
 
150
	// Set the actual uploader URL.
304
	// Set the actual uploader URL.
151
	if ( FCKConfig.LinkUpload )
305
	if ( FCKConfig.LinkUpload )
152
		GetE('frmUpload').action = FCKConfig.LinkUploadURL ;
306
		GetE('frmUpload').action = FCKConfig.LinkUploadURL ;
-
 
307
 
-
 
308
	// Set the default target (from configuration).
-
 
309
	SetDefaultTarget() ;
153
 
310
 
154
	// Activate the "OK" button.
311
	// Activate the "OK" button.
-
 
312
	dialog.SetOkButton( true ) ;
-
 
313
 
-
 
314
	// Select the first field.
-
 
315
	switch( GetE('cmbLinkType').value )
-
 
316
	{
-
 
317
		case 'url' :
-
 
318
			SelectField( 'txtUrl' ) ;
-
 
319
			break ;
-
 
320
		case 'email' :
-
 
321
			SelectField( 'txtEMailAddress' ) ;
-
 
322
			break ;
-
 
323
		case 'anchor' :
-
 
324
			if ( GetE('divSelAnchor').style.display != 'none' )
-
 
325
				SelectField( 'cmbAnchorName' ) ;
-
 
326
			else
-
 
327
				SelectField( 'cmbLinkType' ) ;
155
	window.parent.SetOkButton( true ) ;
328
	}
156
}
329
}
157
 
330
 
158
var bHasAnchors ;
331
var bHasAnchors ;
159
 
332
 
160
function LoadAnchorNamesAndIds()
333
function LoadAnchorNamesAndIds()
161
{
334
{
162
	// Since version 2.0, the anchors are replaced in the DOM by IMGs so the user see the icon 
335
	// Since version 2.0, the anchors are replaced in the DOM by IMGs so the user see the icon
163
	// to edit them. So, we must look for that images now.
336
	// to edit them. So, we must look for that images now.
164
	var aAnchors = new Array() ;
337
	var aAnchors = new Array() ;
165
	
338
	var i ;
166
	var oImages = oEditor.FCK.EditorDocument.getElementsByTagName( 'IMG' ) ;
339
	var oImages = oEditor.FCK.EditorDocument.getElementsByTagName( 'IMG' ) ;
167
	for( var i = 0 ; i < oImages.length ; i++ )
340
	for( i = 0 ; i < oImages.length ; i++ )
168
	{
341
	{
169
		if ( oImages[i].getAttribute('_fckanchor') )
342
		if ( oImages[i].getAttribute('_fckanchor') )
170
			aAnchors[ aAnchors.length ] = oEditor.FCK.GetRealElement( oImages[i] ) ;
343
			aAnchors[ aAnchors.length ] = oEditor.FCK.GetRealElement( oImages[i] ) ;
171
	}
344
	}
172
	
345
 
-
 
346
	// Add also real anchors
-
 
347
	var oLinks = oEditor.FCK.EditorDocument.getElementsByTagName( 'A' ) ;
-
 
348
	for( i = 0 ; i < oLinks.length ; i++ )
-
 
349
	{
-
 
350
		if ( oLinks[i].name && ( oLinks[i].name.length > 0 ) )
-
 
351
			aAnchors[ aAnchors.length ] = oLinks[i] ;
-
 
352
	}
-
 
353
 
173
	var aIds = oEditor.FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ;
354
	var aIds = FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ;
174
 
355
 
175
	bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ;
356
	bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ;
176
 
357
 
177
	for ( var i = 0 ; i < aAnchors.length ; i++ )
358
	for ( i = 0 ; i < aAnchors.length ; i++ )
178
	{
359
	{
179
		var sName = aAnchors[i].name ;
360
		var sName = aAnchors[i].name ;
180
		if ( sName && sName.length > 0 )
361
		if ( sName && sName.length > 0 )
181
			oEditor.FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ;
362
			FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ;
182
	}
363
	}
183
 
364
 
184
	for ( var i = 0 ; i < aIds.length ; i++ )
365
	for ( i = 0 ; i < aIds.length ; i++ )
185
	{
366
	{
186
		oEditor.FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ;
367
		FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ;
187
	}
368
	}
188
 
369
 
189
	ShowE( 'divSelAnchor'	, bHasAnchors ) ;
370
	ShowE( 'divSelAnchor'	, bHasAnchors ) ;
190
	ShowE( 'divNoAnchor'	, !bHasAnchors ) ;
371
	ShowE( 'divNoAnchor'	, !bHasAnchors ) ;
191
}
372
}
192
 
373
 
193
function LoadSelection()
374
function LoadSelection()
194
{
375
{
195
	if ( !oLink ) return ;
376
	if ( !oLink ) return ;
196
 
377
 
197
	var sType = 'url' ;
378
	var sType = 'url' ;
198
 
379
 
199
	// Get the actual Link href.
380
	// Get the actual Link href.
200
	var sHRef = oLink.getAttribute( '_fcksavedurl' ) ;
381
	var sHRef = oLink.getAttribute( '_fcksavedurl' ) ;
201
	if ( sHRef == null )
382
	if ( sHRef == null )
202
		sHRef = oLink.getAttribute( 'href' , 2 ) + '' ;
383
		sHRef = oLink.getAttribute( 'href' , 2 ) || '' ;
203
	
384
 
204
	// Look for a popup javascript link.
385
	// Look for a popup javascript link.
205
	var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ;
386
	var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ;
206
	if( oPopupMatch )
387
	if( oPopupMatch )
207
	{
388
	{
208
		GetE('cmbTarget').value = 'popup' ;
389
		GetE('cmbTarget').value = 'popup' ;
209
		sHRef = oPopupMatch[1] ;
390
		sHRef = oPopupMatch[1] ;
210
		FillPopupFields( oPopupMatch[2], oPopupMatch[3] ) ;
391
		FillPopupFields( oPopupMatch[2], oPopupMatch[3] ) ;
211
		SetTarget( 'popup' ) ;
392
		SetTarget( 'popup' ) ;
212
	}
393
	}
-
 
394
 
-
 
395
	// Accessible popups, the popup data is in the onclick attribute
-
 
396
	if ( !oPopupMatch )
-
 
397
	{
-
 
398
		var onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;
-
 
399
		if ( onclick )
-
 
400
		{
-
 
401
			// Decode the protected string
-
 
402
			onclick = decodeURIComponent( onclick ) ;
-
 
403
 
-
 
404
			oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ;
-
 
405
			if( oPopupMatch )
-
 
406
			{
-
 
407
				GetE( 'cmbTarget' ).value = 'popup' ;
-
 
408
				FillPopupFields( oPopupMatch[1], oPopupMatch[2] ) ;
-
 
409
				SetTarget( 'popup' ) ;
-
 
410
			}
-
 
411
		}
-
 
412
	}
213
 
413
 
214
	// Search for the protocol.
414
	// Search for the protocol.
215
	var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;
415
	var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;
-
 
416
 
-
 
417
	// Search for a protected email link.
-
 
418
	var oEMailInfo = oParser.ParseEMailUri( sHRef );
-
 
419
 
-
 
420
	if ( oEMailInfo )
-
 
421
	{
-
 
422
		sType = 'email' ;
-
 
423
 
-
 
424
		GetE('txtEMailAddress').value = oEMailInfo.Address ;
-
 
425
		GetE('txtEMailSubject').value = oEMailInfo.Subject ;
-
 
426
		GetE('txtEMailBody').value    = oEMailInfo.Body ;
216
 
427
	}
217
	if ( sProtocol )
428
	else if ( sProtocol )
218
	{
429
	{
219
		sProtocol = sProtocol[0].toLowerCase() ;
430
		sProtocol = sProtocol[0].toLowerCase() ;
220
		GetE('cmbLinkProtocol').value = sProtocol ;
431
		GetE('cmbLinkProtocol').value = sProtocol ;
221
 
432
 
222
		// Remove the protocol and get the remainig URL.
433
		// Remove the protocol and get the remaining URL.
223
		var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;
-
 
224
 
-
 
225
		if ( sProtocol == 'mailto:' )	// It is an e-mail link.
-
 
226
		{
-
 
227
			sType = 'email' ;
-
 
228
 
-
 
229
			var oEMailInfo = oParser.ParseEMailUrl( sUrl ) ;
-
 
230
			GetE('txtEMailAddress').value	= oEMailInfo.Address ;
-
 
231
			GetE('txtEMailSubject').value	= oEMailInfo.Subject ;
-
 
232
			GetE('txtEMailBody').value		= oEMailInfo.Body ;
-
 
233
		}
-
 
234
		else				// It is a normal link.
-
 
235
		{
434
		var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;
236
			sType = 'url' ;
435
		sType = 'url' ;
237
			GetE('txtUrl').value = sUrl ;
-
 
238
		}
436
		GetE('txtUrl').value = sUrl ;
239
	}
437
	}
240
	else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 )	// It is an anchor link.
438
	else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 )	// It is an anchor link.
241
	{
439
	{
242
		sType = 'anchor' ;
440
		sType = 'anchor' ;
243
		GetE('cmbAnchorName').value = GetE('cmbAnchorId').value = sHRef.substr(1) ;
441
		GetE('cmbAnchorName').value = GetE('cmbAnchorId').value = sHRef.substr(1) ;
244
	}
442
	}
245
	else					// It is another type of link.
443
	else					// It is another type of link.
246
	{
444
	{
247
		sType = 'url' ;
445
		sType = 'url' ;
248
 
446
 
249
		GetE('cmbLinkProtocol').value = '' ;
447
		GetE('cmbLinkProtocol').value = '' ;
250
		GetE('txtUrl').value = sHRef ;
448
		GetE('txtUrl').value = sHRef ;
251
	}
449
	}
252
 
450
 
253
	if ( !oPopupMatch )
451
	if ( !oPopupMatch )
254
	{
452
	{
255
		// Get the target.
453
		// Get the target.
256
		var sTarget = oLink.target ;
454
		var sTarget = oLink.target ;
257
 
455
 
258
		if ( sTarget && sTarget.length > 0 )
456
		if ( sTarget && sTarget.length > 0 )
259
		{
457
		{
260
			if ( oRegex.ReserveTarget.test( sTarget ) )
458
			if ( oRegex.ReserveTarget.test( sTarget ) )
261
			{
459
			{
262
				sTarget = sTarget.toLowerCase() ;
460
				sTarget = sTarget.toLowerCase() ;
263
				GetE('cmbTarget').value = sTarget ;
461
				GetE('cmbTarget').value = sTarget ;
264
			}
462
			}
265
			else
463
			else
266
				GetE('cmbTarget').value = 'frame' ;
464
				GetE('cmbTarget').value = 'frame' ;
267
			GetE('txtTargetFrame').value = sTarget ;
465
			GetE('txtTargetFrame').value = sTarget ;
268
		}
466
		}
269
	}
467
	}
270
 
468
 
271
	// Get Advances Attributes
469
	// Get Advances Attributes
272
	GetE('txtAttId').value			= oLink.id ;
470
	GetE('txtAttId').value			= oLink.id ;
273
	GetE('txtAttName').value		= oLink.name ;
471
	GetE('txtAttName').value		= oLink.name ;
274
	GetE('cmbAttLangDir').value		= oLink.dir ;
472
	GetE('cmbAttLangDir').value		= oLink.dir ;
275
	GetE('txtAttLangCode').value	= oLink.lang ;
473
	GetE('txtAttLangCode').value	= oLink.lang ;
276
	GetE('txtAttAccessKey').value	= oLink.accessKey ;
474
	GetE('txtAttAccessKey').value	= oLink.accessKey ;
277
	GetE('txtAttTabIndex').value	= oLink.tabIndex <= 0 ? '' : oLink.tabIndex ;
475
	GetE('txtAttTabIndex').value	= oLink.tabIndex <= 0 ? '' : oLink.tabIndex ;
278
	GetE('txtAttTitle').value		= oLink.title ;
476
	GetE('txtAttTitle').value		= oLink.title ;
279
	GetE('txtAttContentType').value	= oLink.type ;
477
	GetE('txtAttContentType').value	= oLink.type ;
280
	GetE('txtAttCharSet').value		= oLink.charset ;
478
	GetE('txtAttCharSet').value		= oLink.charset ;
-
 
479
 
281
 
480
	var sClass ;
282
	if ( oEditor.FCKBrowserInfo.IsIE )
481
	if ( oEditor.FCKBrowserInfo.IsIE )
283
	{
482
	{
-
 
483
		sClass	= oLink.getAttribute('className',2) || '' ;
-
 
484
		// Clean up temporary classes for internal use:
-
 
485
		sClass = sClass.replace( FCKRegexLib.FCK_Class, '' ) ;
284
		GetE('txtAttClasses').value	= oLink.getAttribute('className',2) || '' ;
486
 
285
		GetE('txtAttStyle').value	= oLink.style.cssText ;
487
		GetE('txtAttStyle').value	= oLink.style.cssText ;
286
	}
488
	}
287
	else
489
	else
288
	{
490
	{
289
		GetE('txtAttClasses').value	= oLink.getAttribute('class',2) || '' ;
491
		sClass	= oLink.getAttribute('class',2) || '' ;
290
		GetE('txtAttStyle').value	= oLink.getAttribute('style',2) ;
492
		GetE('txtAttStyle').value	= oLink.getAttribute('style',2) || '' ;
291
	}
493
	}
-
 
494
	GetE('txtAttClasses').value	= sClass ;
292
 
495
 
293
	// Update the Link type combo.
496
	// Update the Link type combo.
294
	GetE('cmbLinkType').value = sType ;
497
	GetE('cmbLinkType').value = sType ;
295
}
498
}
296
 
499
 
297
//#### Link type selection.
500
//#### Link type selection.
298
function SetLinkType( linkType )
501
function SetLinkType( linkType )
299
{
502
{
300
	ShowE('divLinkTypeUrl'		, (linkType == 'url') ) ;
503
	ShowE('divLinkTypeUrl'		, (linkType == 'url') ) ;
301
	ShowE('divLinkTypeAnchor'	, (linkType == 'anchor') ) ;
504
	ShowE('divLinkTypeAnchor'	, (linkType == 'anchor') ) ;
302
	ShowE('divLinkTypeEMail'	, (linkType == 'email') ) ;
505
	ShowE('divLinkTypeEMail'	, (linkType == 'email') ) ;
303
 
506
 
304
	if ( !FCKConfig.LinkDlgHideTarget )
507
	if ( !FCKConfig.LinkDlgHideTarget )
305
		window.parent.SetTabVisibility( 'Target'	, (linkType == 'url') ) ;
508
		dialog.SetTabVisibility( 'Target'	, (linkType == 'url') ) ;
306
 
509
 
307
	if ( FCKConfig.LinkUpload )
510
	if ( FCKConfig.LinkUpload )
308
		window.parent.SetTabVisibility( 'Upload'	, (linkType == 'url') ) ;
511
		dialog.SetTabVisibility( 'Upload'	, (linkType == 'url') ) ;
309
 
512
 
310
	if ( !FCKConfig.LinkDlgHideAdvanced )
513
	if ( !FCKConfig.LinkDlgHideAdvanced )
311
		window.parent.SetTabVisibility( 'Advanced'	, (linkType != 'anchor' || bHasAnchors) ) ;
514
		dialog.SetTabVisibility( 'Advanced'	, (linkType != 'anchor' || bHasAnchors) ) ;
312
 
515
 
313
	if ( linkType == 'email' )
516
	if ( linkType == 'email' )
314
		window.parent.SetAutoSize( true ) ;
517
		dialog.SetAutoSize( true ) ;
315
}
518
}
316
 
519
 
317
//#### Target type selection.
520
//#### Target type selection.
318
function SetTarget( targetType )
521
function SetTarget( targetType )
319
{
522
{
320
	GetE('tdTargetFrame').style.display	= ( targetType == 'popup' ? 'none' : '' ) ;
523
	GetE('tdTargetFrame').style.display	= ( targetType == 'popup' ? 'none' : '' ) ;
321
	GetE('tdPopupName').style.display	=
524
	GetE('tdPopupName').style.display	=
322
		GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ;
525
	GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ;
323
 
526
 
324
	switch ( targetType )
527
	switch ( targetType )
325
	{
528
	{
326
		case "_blank" :
529
		case "_blank" :
327
		case "_self" :
530
		case "_self" :
328
		case "_parent" :
531
		case "_parent" :
329
		case "_top" :
532
		case "_top" :
330
			GetE('txtTargetFrame').value = targetType ;
533
			GetE('txtTargetFrame').value = targetType ;
331
			break ;
534
			break ;
332
		case "" :
535
		case "" :
333
			GetE('txtTargetFrame').value = '' ;
536
			GetE('txtTargetFrame').value = '' ;
334
			break ;
537
			break ;
335
	}
538
	}
336
 
539
 
337
	if ( targetType == 'popup' )
540
	if ( targetType == 'popup' )
338
		window.parent.SetAutoSize( true ) ;
541
		dialog.SetAutoSize( true ) ;
339
}
542
}
340
 
543
 
341
//#### Called while the user types the URL.
544
//#### Called while the user types the URL.
342
function OnUrlChange()
545
function OnUrlChange()
343
{
546
{
344
	var sUrl = GetE('txtUrl').value ;
547
	var sUrl = GetE('txtUrl').value ;
345
	var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
548
	var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
346
 
549
 
347
	if ( sProtocol )
550
	if ( sProtocol )
348
	{
551
	{
349
		sUrl = sUrl.substr( sProtocol[0].length ) ;
552
		sUrl = sUrl.substr( sProtocol[0].length ) ;
350
		GetE('txtUrl').value = sUrl ;
553
		GetE('txtUrl').value = sUrl ;
351
		GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ;
554
		GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ;
352
	}
555
	}
353
	else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) )
556
	else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) )
354
	{
557
	{
355
		GetE('cmbLinkProtocol').value = '' ;
558
		GetE('cmbLinkProtocol').value = '' ;
356
	}
559
	}
357
}
560
}
358
 
561
 
359
//#### Called while the user types the target name.
562
//#### Called while the user types the target name.
360
function OnTargetNameChange()
563
function OnTargetNameChange()
361
{
564
{
362
	var sFrame = GetE('txtTargetFrame').value ;
565
	var sFrame = GetE('txtTargetFrame').value ;
363
 
566
 
364
	if ( sFrame.length == 0 )
567
	if ( sFrame.length == 0 )
365
		GetE('cmbTarget').value = '' ;
568
		GetE('cmbTarget').value = '' ;
366
	else if ( oRegex.ReserveTarget.test( sFrame ) )
569
	else if ( oRegex.ReserveTarget.test( sFrame ) )
367
		GetE('cmbTarget').value = sFrame.toLowerCase() ;
570
		GetE('cmbTarget').value = sFrame.toLowerCase() ;
368
	else
571
	else
369
		GetE('cmbTarget').value = 'frame' ;
572
		GetE('cmbTarget').value = 'frame' ;
370
}
573
}
371
 
574
 
372
//#### Builds the javascript URI to open a popup to the specified URI.
575
// Accessible popups
373
function BuildPopupUri( uri )
576
function BuildOnClickPopup()
374
{
-
 
375
	var oReg = new RegExp( "'", "g" ) ;
577
{
376
	var sWindowName = "'" + GetE('txtPopupName').value.replace(oReg, "\\'") + "'" ;
578
	var sWindowName = "'" + GetE('txtPopupName').value.replace(/\W/gi, "") + "'" ;
377
 
579
 
378
	var sFeatures = '' ;
580
	var sFeatures = '' ;
379
	var aChkFeatures = document.getElementsByName('chkFeature') ;
581
	var aChkFeatures = document.getElementsByName( 'chkFeature' ) ;
380
	for ( var i = 0 ; i < aChkFeatures.length ; i++ )
582
	for ( var i = 0 ; i < aChkFeatures.length ; i++ )
381
	{
583
	{
382
		if ( i > 0 ) sFeatures += ',' ;
584
		if ( i > 0 ) sFeatures += ',' ;
383
		sFeatures += aChkFeatures[i].value + '=' + ( aChkFeatures[i].checked ? 'yes' : 'no' ) ;
585
		sFeatures += aChkFeatures[i].value + '=' + ( aChkFeatures[i].checked ? 'yes' : 'no' ) ;
384
	}
586
	}
385
 
587
 
386
	if ( GetE('txtPopupWidth').value.length > 0 )	sFeatures += ',width=' + GetE('txtPopupWidth').value ;
588
	if ( GetE('txtPopupWidth').value.length > 0 )	sFeatures += ',width=' + GetE('txtPopupWidth').value ;
387
	if ( GetE('txtPopupHeight').value.length > 0 )	sFeatures += ',height=' + GetE('txtPopupHeight').value ;
589
	if ( GetE('txtPopupHeight').value.length > 0 )	sFeatures += ',height=' + GetE('txtPopupHeight').value ;
388
	if ( GetE('txtPopupLeft').value.length > 0 )	sFeatures += ',left=' + GetE('txtPopupLeft').value ;
590
	if ( GetE('txtPopupLeft').value.length > 0 )	sFeatures += ',left=' + GetE('txtPopupLeft').value ;
389
	if ( GetE('txtPopupTop').value.length > 0 )		sFeatures += ',top=' + GetE('txtPopupTop').value ;
591
	if ( GetE('txtPopupTop').value.length > 0 )		sFeatures += ',top=' + GetE('txtPopupTop').value ;
-
 
592
 
-
 
593
	if ( sFeatures != '' )
-
 
594
		sFeatures = sFeatures + ",status" ;
390
 
595
 
391
	return ( "javascript:void(window.open('" + uri + "'," + sWindowName + ",'" + sFeatures + "'))" ) ;
596
	return ( "window.open(this.href," + sWindowName + ",'" + sFeatures + "'); return false" ) ;
392
}
597
}
393
 
598
 
394
//#### Fills all Popup related fields.
599
//#### Fills all Popup related fields.
395
function FillPopupFields( windowName, features )
600
function FillPopupFields( windowName, features )
396
{
601
{
397
	if ( windowName )
602
	if ( windowName )
398
		GetE('txtPopupName').value = windowName ;
603
		GetE('txtPopupName').value = windowName ;
399
 
604
 
400
	var oFeatures = new Object() ;
605
	var oFeatures = new Object() ;
401
	var oFeaturesMatch ;
606
	var oFeaturesMatch ;
402
	while( ( oFeaturesMatch = oRegex.PopupFeatures.exec( features ) ) != null )
607
	while( ( oFeaturesMatch = oRegex.PopupFeatures.exec( features ) ) != null )
403
	{
608
	{
404
		var sValue = oFeaturesMatch[2] ;
609
		var sValue = oFeaturesMatch[2] ;
405
		if ( sValue == ( 'yes' || '1' ) )
610
		if ( sValue == ( 'yes' || '1' ) )
406
			oFeatures[ oFeaturesMatch[1] ] = true ;
611
			oFeatures[ oFeaturesMatch[1] ] = true ;
407
		else if ( ! isNaN( sValue ) && sValue != 0 )
612
		else if ( ! isNaN( sValue ) && sValue != 0 )
408
			oFeatures[ oFeaturesMatch[1] ] = sValue ;
613
			oFeatures[ oFeaturesMatch[1] ] = sValue ;
409
	}
614
	}
410
 
615
 
411
	// Update all features check boxes.
616
	// Update all features check boxes.
412
	var aChkFeatures = document.getElementsByName('chkFeature') ;
617
	var aChkFeatures = document.getElementsByName('chkFeature') ;
413
	for ( var i = 0 ; i < aChkFeatures.length ; i++ )
618
	for ( var i = 0 ; i < aChkFeatures.length ; i++ )
414
	{
619
	{
415
		if ( oFeatures[ aChkFeatures[i].value ] )
620
		if ( oFeatures[ aChkFeatures[i].value ] )
416
			aChkFeatures[i].checked = true ;
621
			aChkFeatures[i].checked = true ;
417
	}
622
	}
418
 
623
 
419
	// Update position and size text boxes.
624
	// Update position and size text boxes.
420
	if ( oFeatures['width'] )	GetE('txtPopupWidth').value		= oFeatures['width'] ;
625
	if ( oFeatures['width'] )	GetE('txtPopupWidth').value		= oFeatures['width'] ;
421
	if ( oFeatures['height'] )	GetE('txtPopupHeight').value	= oFeatures['height'] ;
626
	if ( oFeatures['height'] )	GetE('txtPopupHeight').value	= oFeatures['height'] ;
422
	if ( oFeatures['left'] )	GetE('txtPopupLeft').value		= oFeatures['left'] ;
627
	if ( oFeatures['left'] )	GetE('txtPopupLeft').value		= oFeatures['left'] ;
423
	if ( oFeatures['top'] )		GetE('txtPopupTop').value		= oFeatures['top'] ;
628
	if ( oFeatures['top'] )		GetE('txtPopupTop').value		= oFeatures['top'] ;
424
}
629
}
425
 
630
 
426
//#### The OK button was hit.
631
//#### The OK button was hit.
427
function Ok()
632
function Ok()
428
{
633
{
429
	var sUri, sInnerHtml ;
634
	var sUri, sInnerHtml ;
-
 
635
	oEditor.FCKUndo.SaveUndoStep() ;
430
 
636
 
431
	switch ( GetE('cmbLinkType').value )
637
	switch ( GetE('cmbLinkType').value )
432
	{
638
	{
433
		case 'url' :
639
		case 'url' :
434
			sUri = GetE('txtUrl').value ;
640
			sUri = GetE('txtUrl').value ;
435
 
641
 
436
			if ( sUri.length == 0 )
642
			if ( sUri.length == 0 )
437
			{
643
			{
438
				alert( FCKLang.DlnLnkMsgNoUrl ) ;
644
				alert( FCKLang.DlnLnkMsgNoUrl ) ;
439
				return false ;
645
				return false ;
440
			}
646
			}
441
 
647
 
442
			sUri = GetE('cmbLinkProtocol').value + sUri ;
648
			sUri = GetE('cmbLinkProtocol').value + sUri ;
443
 
-
 
444
			if( GetE('cmbTarget').value == 'popup' )
-
 
445
			{
-
 
446
				// Check the window name, according to http://www.w3.org/TR/html4/types.html#type-frame-target (IE throw erros with spaces).
-
 
447
				if ( /(^[^a-zA-Z])|(\s)/.test( GetE('txtPopupName').value ) )
-
 
448
				{
-
 
449
					alert( FCKLang.DlnLnkMsgInvPopName ) ;
-
 
450
					return false ;
-
 
451
				}
-
 
452
				
-
 
453
				sUri = BuildPopupUri( sUri ) ;
-
 
454
			}
-
 
455
 
649
 
456
			break ;
650
			break ;
457
 
651
 
458
		case 'email' :
652
		case 'email' :
459
			sUri = GetE('txtEMailAddress').value ;
653
			sUri = GetE('txtEMailAddress').value ;
460
 
654
 
461
			if ( sUri.length == 0 )
655
			if ( sUri.length == 0 )
462
			{
656
			{
463
				alert( FCKLang.DlnLnkMsgNoEMail ) ;
657
				alert( FCKLang.DlnLnkMsgNoEMail ) ;
464
				return false ;
658
				return false ;
465
			}
659
			}
466
 
660
 
467
			sUri = oParser.CreateEMailUri(
661
			sUri = oParser.CreateEMailUri(
468
				sUri,
662
				sUri,
469
				GetE('txtEMailSubject').value,
663
				GetE('txtEMailSubject').value,
470
				GetE('txtEMailBody').value ) ;
664
				GetE('txtEMailBody').value ) ;
471
			break ;
665
			break ;
472
 
666
 
473
		case 'anchor' :
667
		case 'anchor' :
474
			var sAnchor = GetE('cmbAnchorName').value ;
668
			var sAnchor = GetE('cmbAnchorName').value ;
475
			if ( sAnchor.length == 0 ) sAnchor = GetE('cmbAnchorId').value ;
669
			if ( sAnchor.length == 0 ) sAnchor = GetE('cmbAnchorId').value ;
476
 
670
 
477
			if ( sAnchor.length == 0 )
671
			if ( sAnchor.length == 0 )
478
			{
672
			{
479
				alert( FCKLang.DlnLnkMsgNoAnchor ) ;
673
				alert( FCKLang.DlnLnkMsgNoAnchor ) ;
480
				return false ;
674
				return false ;
481
			}
675
			}
482
 
676
 
483
			sUri = '#' + sAnchor ;
677
			sUri = '#' + sAnchor ;
484
			break ;
678
			break ;
485
	}
679
	}
486
 
680
 
487
	// No link selected, so try to create one.
-
 
488
	if ( !oLink )
681
	// If no link is selected, create a new one (it may result in more than one link creation - #220).
489
		oLink = oEditor.FCK.CreateLink( sUri ) ;
-
 
490
	
-
 
491
	if ( oLink )
-
 
492
		sInnerHtml = oLink.innerHTML ;		// Save the innerHTML (IE changes it if it is like an URL).
-
 
493
	else
-
 
494
	{
-
 
-
 
682
	var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ;
-
 
683
 
-
 
684
	// If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)
-
 
685
	var aHasSelection = ( aLinks.length > 0 ) ;
495
		// If no selection, use the uri as the link text (by dom, 2006-05-26)
686
	if ( !aHasSelection )
496
 
687
	{
497
		sInnerHtml = sUri;
688
		sInnerHtml = sUri;
498
 
689
 
499
		// Built a better text for empty links.
690
		// Built a better text for empty links.
500
		switch ( GetE('cmbLinkType').value )
691
		switch ( GetE('cmbLinkType').value )
501
		{
692
		{
502
			// anchor: use old behavior --> return true
693
			// anchor: use old behavior --> return true
503
			case 'anchor':
694
			case 'anchor':
504
				sInnerHtml = sInnerHtml.replace( /^#/, '' ) ;
695
				sInnerHtml = sInnerHtml.replace( /^#/, '' ) ;
505
				break ;
696
				break ;
506
 
697
 
507
			// url: try to get path
698
			// url: try to get path
508
			case 'url':
699
			case 'url':
509
				var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ;
700
				var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ;
510
				var asLinkPath = oLinkPathRegEx.exec( sUri ) ;
701
				var asLinkPath = oLinkPathRegEx.exec( sUri ) ;
511
				if (asLinkPath != null)
702
				if (asLinkPath != null)
512
					sInnerHtml = asLinkPath[1];  // use matched path
703
					sInnerHtml = asLinkPath[1];  // use matched path
513
				break ;
704
				break ;
514
 
705
 
515
			// mailto: try to get email address
706
			// mailto: try to get email address
516
			case 'email':
707
			case 'email':
517
				sInnerHtml = GetE('txtEMailAddress').value ;
708
				sInnerHtml = GetE('txtEMailAddress').value ;
518
				break ;
709
				break ;
519
		}
710
		}
520
 
711
 
521
		// Create a new (empty) anchor.
712
		// Create a new (empty) anchor.
522
		oLink = oEditor.FCK.CreateElement( 'a' ) ;
713
		aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ;
523
	}
714
	}
-
 
715
 
-
 
716
	for ( var i = 0 ; i < aLinks.length ; i++ )
524
 
717
	{
525
	oEditor.FCKUndo.SaveUndoStep() ;
718
		oLink = aLinks[i] ;
526
 
719
 
-
 
720
		if ( aHasSelection )
527
	oLink.href = sUri ;
721
			sInnerHtml = oLink.innerHTML ;		// Save the innerHTML (IE changes it if it is like an URL).
528
	SetAttribute( oLink, '_fcksavedurl', sUri ) ;
722
 
-
 
723
		oLink.href = sUri ;
529
 
724
		SetAttribute( oLink, '_fcksavedurl', sUri ) ;
-
 
725
 
-
 
726
		var onclick;
-
 
727
		// Accessible popups
-
 
728
		if( GetE('cmbTarget').value == 'popup' )
530
	oLink.innerHTML = sInnerHtml ;		// Set (or restore) the innerHTML
729
		{
-
 
730
			onclick = BuildOnClickPopup() ;
531
 
731
			// Encode the attribute
-
 
732
			onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" )  ;
-
 
733
			SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ;
-
 
734
		}
532
	// Target
735
		else
-
 
736
		{
-
 
737
			// Check if the previous onclick was for a popup:
-
 
738
			// In that case remove the onclick handler.
-
 
739
			onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;
533
	if( GetE('cmbTarget').value != 'popup' )
-
 
534
		SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ;
740
			if ( onclick )
535
	else
-
 
536
		SetAttribute( oLink, 'target', null ) ;
-
 
537
 
-
 
538
	// Advances Attributes
-
 
539
	SetAttribute( oLink, 'id'		, GetE('txtAttId').value ) ;
-
 
540
	SetAttribute( oLink, 'name'		, GetE('txtAttName').value ) ;		// No IE. Set but doesnt't update the outerHTML.
741
			{
541
	SetAttribute( oLink, 'dir'		, GetE('cmbAttLangDir').value ) ;
-
 
542
	SetAttribute( oLink, 'lang'		, GetE('txtAttLangCode').value ) ;
-
 
-
 
742
				// Decode the protected string
-
 
743
				onclick = decodeURIComponent( onclick ) ;
-
 
744
 
-
 
745
				if( oRegex.OnClickPopup.test( onclick ) )
-
 
746
					SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ;
-
 
747
			}
-
 
748
		}
-
 
749
 
-
 
750
		oLink.innerHTML = sInnerHtml ;		// Set (or restore) the innerHTML
-
 
751
 
-
 
752
		// Target
-
 
753
		if( GetE('cmbTarget').value != 'popup' )
-
 
754
			SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ;
-
 
755
		else
-
 
756
			SetAttribute( oLink, 'target', null ) ;
-
 
757
 
-
 
758
		// Let's set the "id" only for the first link to avoid duplication.
-
 
759
		if ( i == 0 )
-
 
760
			SetAttribute( oLink, 'id', GetE('txtAttId').value ) ;
-
 
761
 
-
 
762
		// Advances Attributes
-
 
763
		SetAttribute( oLink, 'name'		, GetE('txtAttName').value ) ;
-
 
764
		SetAttribute( oLink, 'dir'		, GetE('cmbAttLangDir').value ) ;
-
 
765
		SetAttribute( oLink, 'lang'		, GetE('txtAttLangCode').value ) ;
543
	SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ;
766
		SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ;
544
	SetAttribute( oLink, 'tabindex'	, ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ;
767
		SetAttribute( oLink, 'tabindex'	, ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ;
-
 
768
		SetAttribute( oLink, 'title'	, GetE('txtAttTitle').value ) ;
-
 
769
		SetAttribute( oLink, 'type'		, GetE('txtAttContentType').value ) ;
-
 
770
		SetAttribute( oLink, 'charset'	, GetE('txtAttCharSet').value ) ;
-
 
771
 
545
	SetAttribute( oLink, 'title'	, GetE('txtAttTitle').value ) ;
772
		if ( oEditor.FCKBrowserInfo.IsIE )
-
 
773
		{
546
	SetAttribute( oLink, 'type'		, GetE('txtAttContentType').value ) ;
774
			var sClass = GetE('txtAttClasses').value ;
547
	SetAttribute( oLink, 'charset'	, GetE('txtAttCharSet').value ) ;
775
			// If it's also an anchor add an internal class
548
 
776
			if ( GetE('txtAttName').value.length != 0 )
549
	if ( oEditor.FCKBrowserInfo.IsIE )
777
				sClass += ' FCK__AnchorC' ;
550
	{
778
			SetAttribute( oLink, 'className', sClass ) ;
551
		SetAttribute( oLink, 'className', GetE('txtAttClasses').value ) ;
779
 
-
 
780
			oLink.style.cssText = GetE('txtAttStyle').value ;
552
		oLink.style.cssText = GetE('txtAttStyle').value ;
781
		}
553
	}
782
		else
554
	else
783
		{
555
	{
784
			SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ;
556
		SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ;
785
			SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ;
557
		SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ;
786
		}
558
	}
787
	}
559
 
788
 
560
	// Select the link.
789
	// Select the (first) link.
561
	oEditor.FCKSelection.SelectNode(oLink);
790
	oEditor.FCKSelection.SelectNode( aLinks[0] );
562
	
791
 
563
	return true ;
792
	return true ;
564
}
793
}
565
 
794
 
566
function BrowseServer()
795
function BrowseServer()
567
{
796
{
568
	OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ;
797
	OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ;
569
}
798
}
570
 
799
 
571
function SetUrl( url )
800
function SetUrl( url )
572
{
801
{
573
	document.getElementById('txtUrl').value = url ;
802
	GetE('txtUrl').value = url ;
574
	OnUrlChange() ;
803
	OnUrlChange() ;
575
	window.parent.SetSelectedTab( 'Info' ) ;
804
	dialog.SetSelectedTab( 'Info' ) ;
576
}
805
}
577
 
806
 
578
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
807
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
579
{
808
{
-
 
809
	// Remove animation
-
 
810
	window.parent.Throbber.Hide() ;
-
 
811
	GetE( 'divUpload' ).style.display  = '' ;
-
 
812
 
580
	switch ( errorNumber )
813
	switch ( errorNumber )
581
	{
814
	{
582
		case 0 :	// No errors
815
		case 0 :	// No errors
583
			alert( 'Your file has been successfully uploaded' ) ;
816
			alert( 'Your file has been successfully uploaded' ) ;
584
			break ;
817
			break ;
585
		case 1 :	// Custom error
818
		case 1 :	// Custom error
586
			alert( customMsg ) ;
819
			alert( customMsg ) ;
587
			return ;
820
			return ;
588
		case 101 :	// Custom warning
821
		case 101 :	// Custom warning
589
			alert( customMsg ) ;
822
			alert( customMsg ) ;
590
			break ;
823
			break ;
591
		case 201 :
824
		case 201 :
592
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
825
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
593
			break ;
826
			break ;
594
		case 202 :
827
		case 202 :
595
			alert( 'Invalid file type' ) ;
828
			alert( 'Invalid file type' ) ;
596
			return ;
829
			return ;
597
		case 203 :
830
		case 203 :
598
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
831
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
599
			return ;
832
			return ;
-
 
833
		case 500 :
-
 
834
			alert( 'The connector is disabled' ) ;
-
 
835
			break ;
600
		default :
836
		default :
601
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
837
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
602
			return ;
838
			return ;
603
	}
839
	}
604
 
840
 
605
	SetUrl( fileUrl ) ;
841
	SetUrl( fileUrl ) ;
606
	GetE('frmUpload').reset() ;
842
	GetE('frmUpload').reset() ;
607
}
843
}
608
 
844
 
609
var oUploadAllowedExtRegex	= new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ;
845
var oUploadAllowedExtRegex	= new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ;
610
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ;
846
var oUploadDeniedExtRegex	= new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ;
611
 
847
 
612
function CheckUpload()
848
function CheckUpload()
613
{
849
{
614
	var sFile = GetE('txtUploadFile').value ;
850
	var sFile = GetE('txtUploadFile').value ;
615
	
851
 
616
	if ( sFile.length == 0 )
852
	if ( sFile.length == 0 )
617
	{
853
	{
618
		alert( 'Please select a file to upload' ) ;
854
		alert( 'Please select a file to upload' ) ;
619
		return false ;
855
		return false ;
620
	}
856
	}
621
	
857
 
622
	if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
858
	if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) ||
623
		( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
859
		( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) )
624
	{
860
	{
625
		OnUploadCompleted( 202 ) ;
861
		OnUploadCompleted( 202 ) ;
626
		return false ;
862
		return false ;
627
	}
863
	}
628
	
864
 
-
 
865
	// Show animation
-
 
866
	window.parent.Throbber.Show( 100 ) ;
-
 
867
	GetE( 'divUpload' ).style.display  = 'none' ;
-
 
868
 
629
	return true ;
869
	return true ;
630
}
-
 
631
870
}
-
 
871
 
-
 
872
function SetDefaultTarget()
-
 
873
{
-
 
874
	var target = FCKConfig.DefaultLinkTarget || '' ;
-
 
875
 
-
 
876
	if ( oLink || target.length == 0 )
-
 
877
		return ;
-
 
878
 
-
 
879
	switch ( target )
-
 
880
	{
-
 
881
		case '_blank' :
-
 
882
		case '_self' :
-
 
883
		case '_parent' :
-
 
884
		case '_top' :
-
 
885
			GetE('cmbTarget').value = target ;
-
 
886
			break ;
-
 
887
		default :
-
 
888
			GetE('cmbTarget').value = 'frame' ;
-
 
889
			break ;
-
 
890
	}
-
 
891
 
-
 
892
	GetE('txtTargetFrame').value = target ;
-
 
893
}
-
 
894