Subversion Repositories Applications.papyrus

Rev

Rev 431 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 431 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:
9
 * 		http://www.fckeditor.net/
9
 * 		http://www.fckeditor.net/
10
 * 
10
 * 
-
 
11
 * "Support Open Source software. What about a donation today?"
-
 
12
 * 
11
 * File Name: fckeditor.js
13
 * File Name: fckeditor.js
12
 * 	This is the integration file for JavaScript.
14
 * 	This is the integration file for JavaScript.
13
 * 
15
 * 
14
 * 	It defines the FCKeditor class that can be used to create editor
16
 * 	It defines the FCKeditor class that can be used to create editor
15
 * 	instances in a HTML page in the client side. For server side
17
 * 	instances in a HTML page in the client side. For server side
Line 30... Line 32...
30
	this.Value			= value			|| '' ;
32
	this.Value			= value			|| '' ;
31
	this.BasePath		= '/fckeditor/' ;
33
	this.BasePath		= '/fckeditor/' ;
32
	this.CheckBrowser	= true ;
34
	this.CheckBrowser	= true ;
33
	this.DisplayErrors	= true ;
35
	this.DisplayErrors	= true ;
34
	this.EnableSafari	= false ;		// This is a temporary property, while Safari support is under development.
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 35... Line 38...
35
 
38
 
Line 36... Line 39...
36
	this.Config			= new Object() ;
39
	this.Config			= new Object() ;
37
 
40
 
38
	// Events
41
	// Events
Line -... Line 42...
-
 
42
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
-
 
43
}
-
 
44
 
39
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
45
FCKeditor.prototype.Version			= '2.3' ;
40
}
46
FCKeditor.prototype.VersionBuild	= '1054' ;
41
 
47
 
42
FCKeditor.prototype.Create = function()
48
FCKeditor.prototype.Create = function()
43
{
49
{
44
	// Check for errors
50
	// Check for errors
45
	if ( !this.InstanceName || this.InstanceName.length == 0 )
51
	if ( !this.InstanceName || this.InstanceName.length == 0 )
46
	{
52
	{
Line 47... Line 53...
47
		this._ThrowError( 701, 'You must specify a instance name.' ) ;
53
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
Line 48... Line 54...
48
		return ;
54
		return ;
49
	}
55
	}
50
 
56
 
51
	document.write( '<div>' ) ;
57
	document.write( '<div>' ) ;
52
 
58
 
53
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
59
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
54
	{
60
	{
55
		document.write( '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" />' ) ;
61
		document.write( '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ) ;
56
		document.write( this._GetConfigHtml() ) ;
62
		document.write( this._GetConfigHtml() ) ;
57
		document.write( this._GetIFrameHtml() ) ;
63
		document.write( this._GetIFrameHtml() ) ;
58
	}
64
	}
59
	else
65
	else
Line 60... Line 66...
60
	{
66
	{
61
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
67
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
Line 62... Line 68...
62
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
68
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
63
		document.write('<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="WIDTH: ' + sWidth + '; HEIGHT: ' + sHeight + '" wrap="virtual">' + this._HTMLEncode( this.Value ) + '<\/textarea>') ;
69
		document.write('<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="WIDTH: ' + sWidth + '; HEIGHT: ' + sHeight + '">' + this._HTMLEncode( this.Value ) + '<\/textarea>') ;
64
	}
70
	}
65
 
71
 
-
 
72
	document.write( '</div>' ) ;
66
	document.write( '</div>' ) ;
73
}
-
 
74
 
-
 
75
FCKeditor.prototype.ReplaceTextarea = function()
-
 
76
{
-
 
77
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
-
 
78
	{
-
 
79
		// We must check the elements firstly using the Id and then the name.
-
 
80
		var oTextarea = document.getElementById( this.InstanceName ) ;
-
 
81
		var colElementsByName = document.getElementsByName( this.InstanceName ) ;
Line 67... Line 82...
67
}
82
		var i = 0;
68
 
-
 
69
FCKeditor.prototype.ReplaceTextarea = function()
-
 
70
{
-
 
71
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
83
		while ( oTextarea || i == 0 )
72
	{
84
		{
73
		var oTextarea = document.getElementById( this.InstanceName ) ;
85
			if ( oTextarea && oTextarea.tagName == 'TEXTAREA' )
74
		
86
				break ;
Line 75... Line 87...
75
		if ( !oTextarea )
87
			oTextarea = colElementsByName[i++] ;
76
			oTextarea = document.getElementsByName( this.InstanceName )[0] ;
88
		}
Line 107... Line 119...
107
	{
119
	{
108
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
120
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
109
		sConfig += escape(o) + '=' + escape( this.Config[o] ) ;
121
		sConfig += escape(o) + '=' + escape( this.Config[o] ) ;
110
	}
122
	}
Line 111... Line 123...
111
 
123
 
112
	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" />' ;
124
	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
Line 113... Line 125...
113
}
125
}
114
 
126
 
-
 
127
FCKeditor.prototype._GetIFrameHtml = function()
-
 
128
{
115
FCKeditor.prototype._GetIFrameHtml = function()
129
	var sFile = (/fcksource=true/i).test( window.top.location.search ) ? 'fckeditor.original.html' : 'fckeditor.html' ;
116
{
130
 
Line 117... Line 131...
117
	var sLink = this.BasePath + 'editor/fckeditor.html?InstanceName=' + this.InstanceName ;
131
	var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + this.InstanceName ;
118
	if (this.ToolbarSet) sLink += '&Toolbar=' + this.ToolbarSet ;
132
	if (this.ToolbarSet) sLink += '&Toolbar=' + this.ToolbarSet ;
Line 119... Line 133...
119
 
133
 
120
	return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="no" scrolling="no"></iframe>' ;
134
	return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="0" scrolling="no"></iframe>' ;
121
}
135
}
122
 
136
 
123
FCKeditor.prototype._IsCompatibleBrowser = function()
137
FCKeditor.prototype._IsCompatibleBrowser = function()
124
{
138
{
125
	var sAgent = navigator.userAgent.toLowerCase() ;
139
	var sAgent = navigator.userAgent.toLowerCase() ;
126
 
140
	
127
	// Internet Explorer
141
	// Internet Explorer
128
	if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
142
	if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
-
 
143
	{
129
	{
144
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
130
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
145
		return ( sBrowserVersion >= 5.5 ) ;
131
		return ( sBrowserVersion >= 5.5 ) ;
146
	}
-
 
147
	
-
 
148
	// Gecko
-
 
149
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 )
-
 
150
		return true ;
-
 
151
	
-
 
152
	// Opera
-
 
153
	if ( this.EnableOpera )
-
 
154
	{
-
 
155
		var aMatch = sAgent.match( /^opera\/(\d+\.\d+)/ ) ;
132
	}
156
		if ( aMatch && aMatch[1] >= 9.0 )
133
	// Gecko
157
			return true ;
134
	else if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 )
158
	}
135
		return true ;
159
	
136
	// Safari
160
	// Safari
137
	else if ( this.EnableSafari && sAgent.indexOf( 'safari' ) != -1 )
161
	if ( this.EnableSafari && sAgent.indexOf( 'safari' ) != -1 )
Line 138... Line 162...
138
		return ( sAgent.match( /safari\/(\d+)/ )[1] >= 312 ) ;	// Build must be at least 312 (1.3)
162
		return ( sAgent.match( /safari\/(\d+)/ )[1] >= 312 ) ;	// Build must be at least 312 (1.3)
139
	else
163
	
140
		return false ;
164
	return false ;