Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 431 → Rev 875

/trunk/api/fckeditor/fckeditor.js
1,6 → 1,6
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
* Copyright (C) 2003-2006 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
8,6 → 8,8
* For further information visit:
* http://www.fckeditor.net/
*
* "Support Open Source software. What about a donation today?"
*
* File Name: fckeditor.js
* This is the integration file for JavaScript.
*
32,6 → 34,7
this.CheckBrowser = true ;
this.DisplayErrors = true ;
this.EnableSafari = false ; // This is a temporary property, while Safari support is under development.
this.EnableOpera = false ; // This is a temporary property, while Opera support is under development.
 
this.Config = new Object() ;
 
39,12 → 42,15
this.OnError = null ; // function( source, errorNumber, errorDescription )
}
 
FCKeditor.prototype.Version = '2.3' ;
FCKeditor.prototype.VersionBuild = '1054' ;
 
FCKeditor.prototype.Create = function()
{
// Check for errors
if ( !this.InstanceName || this.InstanceName.length == 0 )
{
this._ThrowError( 701, 'You must specify a instance name.' ) ;
this._ThrowError( 701, 'You must specify an instance name.' ) ;
return ;
}
 
52,7 → 58,7
 
if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
{
document.write( '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" />' ) ;
document.write( '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ) ;
document.write( this._GetConfigHtml() ) ;
document.write( this._GetIFrameHtml() ) ;
}
60,7 → 66,7
{
var sWidth = this.Width.toString().indexOf('%') > 0 ? this.Width : this.Width + 'px' ;
var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
document.write('<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="WIDTH: ' + sWidth + '; HEIGHT: ' + sHeight + '" wrap="virtual">' + this._HTMLEncode( this.Value ) + '<\/textarea>') ;
document.write('<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="WIDTH: ' + sWidth + '; HEIGHT: ' + sHeight + '">' + this._HTMLEncode( this.Value ) + '<\/textarea>') ;
}
 
document.write( '</div>' ) ;
70,14 → 76,20
{
if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
{
// We must check the elements firstly using the Id and then the name.
var oTextarea = document.getElementById( this.InstanceName ) ;
var colElementsByName = document.getElementsByName( this.InstanceName ) ;
var i = 0;
while ( oTextarea || i == 0 )
{
if ( oTextarea && oTextarea.tagName == 'TEXTAREA' )
break ;
oTextarea = colElementsByName[i++] ;
}
if ( !oTextarea )
oTextarea = document.getElementsByName( this.InstanceName )[0] ;
if ( !oTextarea || oTextarea.tagName != 'TEXTAREA' )
{
alert( 'Error: The TEXTAREA id "' + this.InstanceName + '" was not found' ) ;
alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
return ;
}
 
109,21 → 121,23
sConfig += escape(o) + '=' + escape( this.Config[o] ) ;
}
 
return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" />' ;
return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
}
 
FCKeditor.prototype._GetIFrameHtml = function()
{
var sLink = this.BasePath + 'editor/fckeditor.html?InstanceName=' + this.InstanceName ;
var sFile = (/fcksource=true/i).test( window.top.location.search ) ? 'fckeditor.original.html' : 'fckeditor.html' ;
 
var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + this.InstanceName ;
if (this.ToolbarSet) sLink += '&Toolbar=' + this.ToolbarSet ;
 
return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="no" scrolling="no"></iframe>' ;
return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="0" scrolling="no"></iframe>' ;
}
 
FCKeditor.prototype._IsCompatibleBrowser = function()
{
var sAgent = navigator.userAgent.toLowerCase() ;
 
// Internet Explorer
if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
{
130,14 → 144,24
var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
return ( sBrowserVersion >= 5.5 ) ;
}
// Gecko
else if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 )
if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 )
return true ;
// Opera
if ( this.EnableOpera )
{
var aMatch = sAgent.match( /^opera\/(\d+\.\d+)/ ) ;
if ( aMatch && aMatch[1] >= 9.0 )
return true ;
}
// Safari
else if ( this.EnableSafari && sAgent.indexOf( 'safari' ) != -1 )
if ( this.EnableSafari && sAgent.indexOf( 'safari' ) != -1 )
return ( sAgent.match( /safari\/(\d+)/ )[1] >= 312 ) ; // Build must be at least 312 (1.3)
else
return false ;
return false ;
}
 
FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription )