Subversion Repositories Applications.papyrus

Rev

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

Rev 1688 Rev 1921
Line 1... Line 1...
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
-
 
8
 * choice:
-
 
9
 *
-
 
10
 *  - GNU General Public License Version 2 or later (the "GPL")
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
11
 *    http://www.gnu.org/licenses/gpl.html
7
 * 
12
 *
8
 * For further information visit:
13
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
9
 * 		http://www.fckeditor.net/
14
 *    http://www.gnu.org/licenses/lgpl.html
10
 * 
15
 *
11
 * "Support Open Source software. What about a donation today?"
16
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
-
 
17
 *    http://www.mozilla.org/MPL/MPL-1.1.html
12
 * 
18
 *
13
 * File Name: fckeditor.js
19
 * == END LICENSE ==
-
 
20
 *
14
 * 	This is the integration file for JavaScript.
21
 * This is the integration file for JavaScript.
15
 * 
22
 *
16
 * 	It defines the FCKeditor class that can be used to create editor
23
 * It defines the FCKeditor class that can be used to create editor
17
 * 	instances in a HTML page in the client side. For server side
24
 * instances in a HTML page in the client side. For server side
18
 * 	operations, use the specific integration system.
25
 * operations, use the specific integration system.
19
 * 
-
 
20
 * File Authors:
-
 
21
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
-
 
22
 */
26
 */
Line 23... Line 27...
23
 
27
 
24
// FCKeditor Class
28
// FCKeditor Class
25
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
29
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
Line 28... Line 32...
28
	this.InstanceName	= instanceName ;
32
	this.InstanceName	= instanceName ;
29
	this.Width			= width			|| '100%' ;
33
	this.Width			= width			|| '100%' ;
30
	this.Height			= height		|| '200' ;
34
	this.Height			= height		|| '200' ;
31
	this.ToolbarSet		= toolbarSet	|| 'Default' ;
35
	this.ToolbarSet		= toolbarSet	|| 'Default' ;
32
	this.Value			= value			|| '' ;
36
	this.Value			= value			|| '' ;
33
	this.BasePath		= '/fckeditor/' ;
37
	this.BasePath		= FCKeditor.BasePath ;
34
	this.CheckBrowser	= true ;
38
	this.CheckBrowser	= true ;
35
	this.DisplayErrors	= true ;
39
	this.DisplayErrors	= true ;
36
	this.EnableSafari	= false ;		// This is a temporary property, while Safari support is under development.
-
 
37
	this.EnableOpera	= false ;		// This is a temporary property, while Opera support is under development.
-
 
Line 38... Line 40...
38
 
40
 
Line 39... Line 41...
39
	this.Config			= new Object() ;
41
	this.Config			= new Object() ;
40
 
42
 
41
	// Events
43
	// Events
Line -... Line 44...
-
 
44
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
-
 
45
}
-
 
46
 
-
 
47
/**
-
 
48
 * This is the default BasePath used by all editor instances.
-
 
49
 */
-
 
50
FCKeditor.BasePath = '/fckeditor/' ;
-
 
51
 
-
 
52
/**
-
 
53
 * The minimum height used when replacing textareas.
-
 
54
 */
-
 
55
FCKeditor.MinHeight = 200 ;
-
 
56
 
-
 
57
/**
-
 
58
 * The minimum width used when replacing textareas.
42
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
59
 */
43
}
60
FCKeditor.MinWidth = 750 ;
Line 44... Line 61...
44
 
61
 
45
FCKeditor.prototype.Version			= '2.3.2' ;
62
FCKeditor.prototype.Version			= '2.6.3' ;
46
FCKeditor.prototype.VersionBuild	= '1082' ;
63
FCKeditor.prototype.VersionBuild	= '19836' ;
47
 
64
 
Line 54... Line 71...
54
{
71
{
55
	// Check for errors
72
	// Check for errors
56
	if ( !this.InstanceName || this.InstanceName.length == 0 )
73
	if ( !this.InstanceName || this.InstanceName.length == 0 )
57
	{
74
	{
58
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
75
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
59
		return ;
76
		return '' ;
60
	}
77
	}
Line 61... Line 78...
61
 
78
 
Line 62... Line 79...
62
	var sHtml = '<div>' ;
79
	var sHtml = '' ;
63
 
80
 
64
	if ( !this.CheckBrowser || FCKeditor_IsCompatibleBrowser() )
81
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
65
	{
82
	{
66
		sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;
83
		sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;
67
		sHtml += this._GetConfigHtml() ;
84
		sHtml += this._GetConfigHtml() ;
68
		sHtml += this._GetIFrameHtml() ;
85
		sHtml += this._GetIFrameHtml() ;
69
	}
86
	}
70
	else
87
	else
71
	{
88
	{
-
 
89
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
72
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
90
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
-
 
91
 
-
 
92
		sHtml += '<textarea name="' + this.InstanceName +
-
 
93
			'" rows="4" cols="40" style="width:' + sWidth +
-
 
94
			';height:' + sHeight ;
-
 
95
 
-
 
96
		if ( this.TabIndex )
-
 
97
			sHtml += '" tabindex="' + this.TabIndex ;
-
 
98
 
-
 
99
		sHtml += '">' +
73
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
100
			this._HTMLEncode( this.Value ) +
Line 74... Line -...
74
		sHtml += '<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="width:' + sWidth + ';height:' + sHeight + '">' + this._HTMLEncode( this.Value ) + '<\/textarea>' ;
-
 
75
	}
-
 
76
 
101
			'<\/textarea>' ;
77
	sHtml += '</div>' ;
102
	}
Line 78... Line 103...
78
	
103
 
79
	return sHtml ;
104
	return sHtml ;
80
}
105
}
81
 
106
 
82
FCKeditor.prototype.ReplaceTextarea = function()
107
FCKeditor.prototype.ReplaceTextarea = function()
83
{
108
{
84
	if ( !this.CheckBrowser || FCKeditor_IsCompatibleBrowser() )
109
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
85
	{
110
	{
Line 91... Line 116...
91
		{
116
		{
92
			if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )
117
			if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )
93
				break ;
118
				break ;
94
			oTextarea = colElementsByName[i++] ;
119
			oTextarea = colElementsByName[i++] ;
95
		}
120
		}
96
		
121
 
97
		if ( !oTextarea )
122
		if ( !oTextarea )
98
		{
123
		{
99
			alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
124
			alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
100
			return ;
125
			return ;
101
		}
126
		}
Line 102... Line 127...
102
 
127
 
-
 
128
		oTextarea.style.display = 'none' ;
-
 
129
 
-
 
130
		if ( oTextarea.tabIndex )
-
 
131
			this.TabIndex = oTextarea.tabIndex ;
103
		oTextarea.style.display = 'none' ;
132
 
104
		this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;
133
		this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;
105
		this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ;
134
		this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ;
106
	}
135
	}
Line 123... Line 152...
123
{
152
{
124
	var sConfig = '' ;
153
	var sConfig = '' ;
125
	for ( var o in this.Config )
154
	for ( var o in this.Config )
126
	{
155
	{
127
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
156
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
128
		sConfig += escape(o) + '=' + escape( this.Config[o] ) ;
157
		sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ;
129
	}
158
	}
Line 130... Line 159...
130
 
159
 
131
	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
160
	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
Line 132... Line 161...
132
}
161
}
133
 
162
 
134
FCKeditor.prototype._GetIFrameHtml = function()
163
FCKeditor.prototype._GetIFrameHtml = function()
135
{
164
{
136
	var sFile = 'fckeditor.html' ;
165
	var sFile = 'fckeditor.html' ;
137
	
166
 
138
	try
167
	try
139
	{
168
	{
140
		if ( (/fcksource=true/i).test( window.top.location.search ) )
169
		if ( (/fcksource=true/i).test( window.top.location.search ) )
141
			sFile = 'fckeditor.original.html' ;
170
			sFile = 'fckeditor.original.html' ;
Line 142... Line 171...
142
	}
171
	}
-
 
172
	catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
143
	catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
173
 
-
 
174
	var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ;
-
 
175
	if (this.ToolbarSet)
-
 
176
		sLink += '&amp;Toolbar=' + this.ToolbarSet ;
-
 
177
 
-
 
178
	html = '<iframe id="' + this.InstanceName +
Line -... Line 179...
-
 
179
		'___Frame" src="' + sLink +
-
 
180
		'" width="' + this.Width +
-
 
181
		'" height="' + this.Height ;
144
 
182
 
-
 
183
	if ( this.TabIndex )
-
 
184
		html += '" tabindex="' + this.TabIndex ;
145
	var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + this.InstanceName ;
185
 
Line 146... Line -...
146
	if (this.ToolbarSet) sLink += '&amp;Toolbar=' + this.ToolbarSet ;
-
 
147
 
186
	html += '" frameborder="0" scrolling="no"></iframe>' ;
148
	return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="0" scrolling="no"></iframe>' ;
187
 
149
}
188
	return html ;
150
 
189
}
Line 182... Line 221...
182
		/>/g, "&gt;") ;
221
		/>/g, "&gt;") ;
Line 183... Line 222...
183
 
222
 
184
	return text ;
223
	return text ;
Line -... Line 224...
-
 
224
}
-
 
225
 
-
 
226
;(function()
-
 
227
{
-
 
228
	var textareaToEditor = function( textarea )
-
 
229
	{
-
 
230
		var editor = new FCKeditor( textarea.name ) ;
-
 
231
 
-
 
232
		editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;
-
 
233
		editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;
-
 
234
 
-
 
235
		return editor ;
-
 
236
	}
-
 
237
 
-
 
238
	/**
-
 
239
	 * Replace all <textarea> elements available in the document with FCKeditor
-
 
240
	 * instances.
-
 
241
	 *
-
 
242
	 *	// Replace all <textarea> elements in the page.
-
 
243
	 *	FCKeditor.ReplaceAllTextareas() ;
-
 
244
	 *
-
 
245
	 *	// Replace all <textarea class="myClassName"> elements in the page.
-
 
246
	 *	FCKeditor.ReplaceAllTextareas( 'myClassName' ) ;
-
 
247
	 *
-
 
248
	 *	// Selectively replace <textarea> elements, based on custom assertions.
-
 
249
	 *	FCKeditor.ReplaceAllTextareas( function( textarea, editor )
-
 
250
	 *		{
-
 
251
	 *			// Custom code to evaluate the replace, returning false if it
-
 
252
	 *			// must not be done.
-
 
253
	 *			// It also passes the "editor" parameter, so the developer can
-
 
254
	 *			// customize the instance.
-
 
255
	 *		} ) ;
-
 
256
	 */
-
 
257
	FCKeditor.ReplaceAllTextareas = function()
-
 
258
	{
-
 
259
		var textareas = document.getElementsByTagName( 'textarea' ) ;
-
 
260
 
-
 
261
		for ( var i = 0 ; i < textareas.length ; i++ )
-
 
262
		{
-
 
263
			var editor = null ;
-
 
264
			var textarea = textareas[i] ;
-
 
265
			var name = textarea.name ;
-
 
266
 
-
 
267
			// The "name" attribute must exist.
-
 
268
			if ( !name || name.length == 0 )
-
 
269
				continue ;
-
 
270
 
-
 
271
			if ( typeof arguments[0] == 'string' )
-
 
272
			{
-
 
273
				// The textarea class name could be passed as the function
-
 
274
				// parameter.
-
 
275
 
-
 
276
				var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;
-
 
277
 
-
 
278
				if ( !classRegex.test( textarea.className ) )
-
 
279
					continue ;
-
 
280
			}
-
 
281
			else if ( typeof arguments[0] == 'function' )
-
 
282
			{
-
 
283
				// An assertion function could be passed as the function parameter.
-
 
284
				// It must explicitly return "false" to ignore a specific <textarea>.
-
 
285
				editor = textareaToEditor( textarea ) ;
-
 
286
				if ( arguments[0]( textarea, editor ) === false )
-
 
287
					continue ;
-
 
288
			}
-
 
289
 
-
 
290
			if ( !editor )
-
 
291
				editor = textareaToEditor( textarea ) ;
-
 
292
 
-
 
293
			editor.ReplaceTextarea() ;
-
 
294
		}
-
 
295
	}
185
}
296
})() ;
186
 
297
 
187
function FCKeditor_IsCompatibleBrowser()
298
function FCKeditor_IsCompatibleBrowser()
Line 188... Line 299...
188
{
299
{
189
	var sAgent = navigator.userAgent.toLowerCase() ;
300
	var sAgent = navigator.userAgent.toLowerCase() ;
190
 
301
 
191
	// Internet Explorer
302
	// Internet Explorer 5.5+
192
	if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
303
	if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 )
193
	{
304
	{
Line 194... Line 305...
194
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
305
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
195
		return ( sBrowserVersion >= 5.5 ) ;
306
		return ( sBrowserVersion >= 5.5 ) ;
196
	}
307
	}
Line 197... Line 308...
197
 
308
 
198
	// Gecko (Opera 9 tries to behave like Gecko at this point).
309
	// Gecko (Opera 9 tries to behave like Gecko at this point).
199
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
310
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
-
 
311
		return true ;
-
 
312
 
-
 
313
	// Opera 9.50+
-
 
314
	if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 )
-
 
315
		return true ;
-
 
316
 
200
		return true ;
317
	// Adobe AIR
201
 
318
	// Checked before Safari because AIR have the WebKit rich text editor
202
	// Opera
319
	// features from Safari 3.0.4, but the version reported is 420.
203
	if ( this.EnableOpera && navigator.appName == 'Opera' && parseInt( navigator.appVersion ) >= 9 )
320
	if ( sAgent.indexOf( ' adobeair/' ) != -1 )
Line 204... Line 321...
204
			return true ;
321
		return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ;	// Build must be at least v1
205
 
-
 
206
	// Safari
322
 
-
 
323
	// Safari 3+