+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * This is the integration file for JavaScript.\r
- *\r
- * It defines the FCKeditor class that can be used to create editor\r
- * instances in a HTML page in the client side. For server side\r
- * operations, use the specific integration system.\r
- */\r
-\r
-// FCKeditor Class\r
-var FCKeditor = function( instanceName, width, height, toolbarSet, value )\r
-{\r
- // Properties\r
- this.InstanceName = instanceName ;\r
- this.Width = width || '100%' ;\r
- this.Height = height || '200' ;\r
- this.ToolbarSet = toolbarSet || 'Default' ;\r
- this.Value = value || '' ;\r
- this.BasePath = FCKeditor.BasePath ;\r
- this.CheckBrowser = true ;\r
- this.DisplayErrors = true ;\r
-\r
- this.Config = new Object() ;\r
-\r
- // Events\r
- this.OnError = null ; // function( source, errorNumber, errorDescription )\r
-}\r
-\r
-/**\r
- * This is the default BasePath used by all editor instances.\r
- */\r
-FCKeditor.BasePath = '/fckeditor/' ;\r
-\r
-/**\r
- * The minimum height used when replacing textareas.\r
- */\r
-FCKeditor.MinHeight = 200 ;\r
-\r
-/**\r
- * The minimum width used when replacing textareas.\r
- */\r
-FCKeditor.MinWidth = 750 ;\r
-\r
-FCKeditor.prototype.Version = '2.6.4' ;\r
-FCKeditor.prototype.VersionBuild = '21629' ;\r
-\r
-FCKeditor.prototype.Create = function()\r
-{\r
- document.write( this.CreateHtml() ) ;\r
-}\r
-\r
-FCKeditor.prototype.CreateHtml = function()\r
-{\r
- // Check for errors\r
- if ( !this.InstanceName || this.InstanceName.length == 0 )\r
- {\r
- this._ThrowError( 701, 'You must specify an instance name.' ) ;\r
- return '' ;\r
- }\r
-\r
- var sHtml = '' ;\r
-\r
- if ( !this.CheckBrowser || this._IsCompatibleBrowser() )\r
- {\r
- sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;\r
- sHtml += this._GetConfigHtml() ;\r
- sHtml += this._GetIFrameHtml() ;\r
- }\r
- else\r
- {\r
- var sWidth = this.Width.toString().indexOf('%') > 0 ? this.Width : this.Width + 'px' ;\r
- var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;\r
-\r
- sHtml += '<textarea name="' + this.InstanceName +\r
- '" rows="4" cols="40" style="width:' + sWidth +\r
- ';height:' + sHeight ;\r
-\r
- if ( this.TabIndex )\r
- sHtml += '" tabindex="' + this.TabIndex ;\r
-\r
- sHtml += '">' +\r
- this._HTMLEncode( this.Value ) +\r
- '<\/textarea>' ;\r
- }\r
-\r
- return sHtml ;\r
-}\r
-\r
-FCKeditor.prototype.ReplaceTextarea = function()\r
-{\r
- if ( document.getElementById( this.InstanceName + '___Frame' ) )\r
- return ;\r
- if ( !this.CheckBrowser || this._IsCompatibleBrowser() )\r
- {\r
- // We must check the elements firstly using the Id and then the name.\r
- var oTextarea = document.getElementById( this.InstanceName ) ;\r
- var colElementsByName = document.getElementsByName( this.InstanceName ) ;\r
- var i = 0;\r
- while ( oTextarea || i == 0 )\r
- {\r
- if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )\r
- break ;\r
- oTextarea = colElementsByName[i++] ;\r
- }\r
-\r
- if ( !oTextarea )\r
- {\r
- alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;\r
- return ;\r
- }\r
-\r
- oTextarea.style.display = 'none' ;\r
-\r
- if ( oTextarea.tabIndex )\r
- this.TabIndex = oTextarea.tabIndex ;\r
-\r
- this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;\r
- this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ;\r
- }\r
-}\r
-\r
-FCKeditor.prototype._InsertHtmlBefore = function( html, element )\r
-{\r
- if ( element.insertAdjacentHTML ) // IE\r
- element.insertAdjacentHTML( 'beforeBegin', html ) ;\r
- else // Gecko\r
- {\r
- var oRange = document.createRange() ;\r
- oRange.setStartBefore( element ) ;\r
- var oFragment = oRange.createContextualFragment( html );\r
- element.parentNode.insertBefore( oFragment, element ) ;\r
- }\r
-}\r
-\r
-FCKeditor.prototype._GetConfigHtml = function()\r
-{\r
- var sConfig = '' ;\r
- for ( var o in this.Config )\r
- {\r
- if ( sConfig.length > 0 ) sConfig += '&' ;\r
- sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ;\r
- }\r
-\r
- return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;\r
-}\r
-\r
-FCKeditor.prototype._GetIFrameHtml = function()\r
-{\r
- var sFile = 'fckeditor.html' ;\r
-\r
- try\r
- {\r
- if ( (/fcksource=true/i).test( window.top.location.search ) )\r
- sFile = 'fckeditor.original.html' ;\r
- }\r
- catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }\r
-\r
- var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ;\r
- if (this.ToolbarSet)\r
- sLink += '&Toolbar=' + this.ToolbarSet ;\r
-\r
- var html = '<iframe id="' + this.InstanceName +\r
- '___Frame" src="' + sLink +\r
- '" width="' + this.Width +\r
- '" height="' + this.Height ;\r
-\r
- if ( this.TabIndex )\r
- html += '" tabindex="' + this.TabIndex ;\r
-\r
- html += '" frameborder="0" scrolling="no"></iframe>' ;\r
-\r
- return html ;\r
-}\r
-\r
-FCKeditor.prototype._IsCompatibleBrowser = function()\r
-{\r
- return FCKeditor_IsCompatibleBrowser() ;\r
-}\r
-\r
-FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription )\r
-{\r
- this.ErrorNumber = errorNumber ;\r
- this.ErrorDescription = errorDescription ;\r
-\r
- if ( this.DisplayErrors )\r
- {\r
- document.write( '<div style="COLOR: #ff0000">' ) ;\r
- document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ;\r
- document.write( '</div>' ) ;\r
- }\r
-\r
- if ( typeof( this.OnError ) == 'function' )\r
- this.OnError( this, errorNumber, errorDescription ) ;\r
-}\r
-\r
-FCKeditor.prototype._HTMLEncode = function( text )\r
-{\r
- if ( typeof( text ) != "string" )\r
- text = text.toString() ;\r
-\r
- text = text.replace(\r
- /&/g, "&").replace(\r
- /"/g, """).replace(\r
- /</g, "<").replace(\r
- />/g, ">") ;\r
-\r
- return text ;\r
-}\r
-\r
-;(function()\r
-{\r
- var textareaToEditor = function( textarea )\r
- {\r
- var editor = new FCKeditor( textarea.name ) ;\r
-\r
- editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;\r
- editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;\r
-\r
- return editor ;\r
- }\r
-\r
- /**\r
- * Replace all <textarea> elements available in the document with FCKeditor\r
- * instances.\r
- *\r
- * // Replace all <textarea> elements in the page.\r
- * FCKeditor.ReplaceAllTextareas() ;\r
- *\r
- * // Replace all <textarea class="myClassName"> elements in the page.\r
- * FCKeditor.ReplaceAllTextareas( 'myClassName' ) ;\r
- *\r
- * // Selectively replace <textarea> elements, based on custom assertions.\r
- * FCKeditor.ReplaceAllTextareas( function( textarea, editor )\r
- * {\r
- * // Custom code to evaluate the replace, returning false if it\r
- * // must not be done.\r
- * // It also passes the "editor" parameter, so the developer can\r
- * // customize the instance.\r
- * } ) ;\r
- */\r
- FCKeditor.ReplaceAllTextareas = function()\r
- {\r
- var textareas = document.getElementsByTagName( 'textarea' ) ;\r
-\r
- for ( var i = 0 ; i < textareas.length ; i++ )\r
- {\r
- var editor = null ;\r
- var textarea = textareas[i] ;\r
- var name = textarea.name ;\r
-\r
- // The "name" attribute must exist.\r
- if ( !name || name.length == 0 )\r
- continue ;\r
-\r
- if ( typeof arguments[0] == 'string' )\r
- {\r
- // The textarea class name could be passed as the function\r
- // parameter.\r
-\r
- var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;\r
-\r
- if ( !classRegex.test( textarea.className ) )\r
- continue ;\r
- }\r
- else if ( typeof arguments[0] == 'function' )\r
- {\r
- // An assertion function could be passed as the function parameter.\r
- // It must explicitly return "false" to ignore a specific <textarea>.\r
- editor = textareaToEditor( textarea ) ;\r
- if ( arguments[0]( textarea, editor ) === false )\r
- continue ;\r
- }\r
-\r
- if ( !editor )\r
- editor = textareaToEditor( textarea ) ;\r
-\r
- editor.ReplaceTextarea() ;\r
- }\r
- }\r
-})() ;\r
-\r
-function FCKeditor_IsCompatibleBrowser()\r
-{\r
- var sAgent = navigator.userAgent.toLowerCase() ;\r
-\r
- // Internet Explorer 5.5+\r
- if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 )\r
- {\r
- var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;\r
- return ( sBrowserVersion >= 5.5 ) ;\r
- }\r
-\r
- // Gecko (Opera 9 tries to behave like Gecko at this point).\r
- if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )\r
- return true ;\r
-\r
- // Opera 9.50+\r
- if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 )\r
- return true ;\r
-\r
- // Adobe AIR\r
- // Checked before Safari because AIR have the WebKit rich text editor\r
- // features from Safari 3.0.4, but the version reported is 420.\r
- if ( sAgent.indexOf( ' adobeair/' ) != -1 )\r
- return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ; // Build must be at least v1\r
-\r
- // Safari 3+\r
- if ( sAgent.indexOf( ' applewebkit/' ) != -1 )\r
- return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ; // Build must be at least 522 (v3)\r
-\r
- return false ;\r
-}\r