import rt 3.8.7
[freeside.git] / rt / share / html / NoAuth / RichText / FCKeditor / editor / _source / internals / fckconfig.js
diff --git a/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/internals/fckconfig.js b/rt/share/html/NoAuth/RichText/FCKeditor/editor/_source/internals/fckconfig.js
new file mode 100644 (file)
index 0000000..bf5f4c2
--- /dev/null
@@ -0,0 +1,237 @@
+/*\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
+ * Creates and initializes the FCKConfig object.\r
+ */\r
+\r
+var FCKConfig = FCK.Config = new Object() ;\r
+\r
+/*\r
+       For the next major version (probably 3.0) we should move all this stuff to\r
+       another dedicated object and leave FCKConfig as a holder object for settings only).\r
+*/\r
+\r
+// Editor Base Path\r
+if ( document.location.protocol == 'file:' )\r
+{\r
+       FCKConfig.BasePath = decodeURIComponent( document.location.pathname.substr(1) ) ;\r
+       FCKConfig.BasePath = FCKConfig.BasePath.replace( /\\/gi, '/' ) ;\r
+\r
+       // The way to address local files is different according to the OS.\r
+       // In Windows it is file:// but in MacOs it is file:/// so let's get it automatically\r
+       var sFullProtocol = document.location.href.match( /^(file\:\/{2,3})/ )[1] ;\r
+       // #945 Opera does strange things with files loaded from the disk, and it fails in Mac to load xml files\r
+       if ( FCKBrowserInfo.IsOpera )\r
+               sFullProtocol += 'localhost/' ;\r
+\r
+       FCKConfig.BasePath = sFullProtocol + FCKConfig.BasePath.substring( 0, FCKConfig.BasePath.lastIndexOf( '/' ) + 1) ;\r
+}\r
+else\r
+       FCKConfig.BasePath = document.location.protocol + '//' + document.location.host +\r
+               document.location.pathname.substring( 0, document.location.pathname.lastIndexOf( '/' ) + 1) ;\r
+\r
+FCKConfig.FullBasePath = FCKConfig.BasePath ;\r
+\r
+FCKConfig.EditorPath = FCKConfig.BasePath.replace( /editor\/$/, '' ) ;\r
+\r
+// There is a bug in Gecko. If the editor is hidden on startup, an error is\r
+// thrown when trying to get the screen dimensions.\r
+try\r
+{\r
+       FCKConfig.ScreenWidth   = screen.width ;\r
+       FCKConfig.ScreenHeight  = screen.height ;\r
+}\r
+catch (e)\r
+{\r
+       FCKConfig.ScreenWidth   = 800 ;\r
+       FCKConfig.ScreenHeight  = 600 ;\r
+}\r
+\r
+// Override the actual configuration values with the values passed throw the\r
+// hidden field "<InstanceName>___Config".\r
+FCKConfig.ProcessHiddenField = function()\r
+{\r
+       this.PageConfig = new Object() ;\r
+\r
+       // Get the hidden field.\r
+       var oConfigField = window.parent.document.getElementById( FCK.Name + '___Config' ) ;\r
+\r
+       // Do nothing if the config field was not defined.\r
+       if ( ! oConfigField ) return ;\r
+\r
+       var aCouples = oConfigField.value.split('&') ;\r
+\r
+       for ( var i = 0 ; i < aCouples.length ; i++ )\r
+       {\r
+               if ( aCouples[i].length == 0 )\r
+                       continue ;\r
+\r
+               var aConfig = aCouples[i].split( '=' ) ;\r
+               var sKey = decodeURIComponent( aConfig[0] ) ;\r
+               var sVal = decodeURIComponent( aConfig[1] ) ;\r
+\r
+               if ( sKey == 'CustomConfigurationsPath' )       // The Custom Config File path must be loaded immediately.\r
+                       FCKConfig[ sKey ] = sVal ;\r
+\r
+               else if ( sVal.toLowerCase() == "true" )        // If it is a boolean TRUE.\r
+                       this.PageConfig[ sKey ] = true ;\r
+\r
+               else if ( sVal.toLowerCase() == "false" )       // If it is a boolean FALSE.\r
+                       this.PageConfig[ sKey ] = false ;\r
+\r
+               else if ( sVal.length > 0 && !isNaN( sVal ) )   // If it is a number.\r
+                       this.PageConfig[ sKey ] = parseInt( sVal, 10 ) ;\r
+\r
+               else                                                                            // In any other case it is a string.\r
+                       this.PageConfig[ sKey ] = sVal ;\r
+       }\r
+}\r
+\r
+function FCKConfig_LoadPageConfig()\r
+{\r
+       var oPageConfig = FCKConfig.PageConfig ;\r
+       for ( var sKey in oPageConfig )\r
+               FCKConfig[ sKey ] = oPageConfig[ sKey ] ;\r
+}\r
+\r
+function FCKConfig_PreProcess()\r
+{\r
+       var oConfig = FCKConfig ;\r
+\r
+       // Force debug mode if fckdebug=true in the QueryString (main page).\r
+       if ( oConfig.AllowQueryStringDebug )\r
+       {\r
+               try\r
+               {\r
+                       if ( (/fckdebug=true/i).test( window.top.location.search ) )\r
+                               oConfig.Debug = true ;\r
+               }\r
+               catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }\r
+       }\r
+\r
+       // Certifies that the "PluginsPath" configuration ends with a slash.\r
+       if ( !oConfig.PluginsPath.EndsWith('/') )\r
+               oConfig.PluginsPath += '/' ;\r
+\r
+       // If no ToolbarComboPreviewCSS, point it to EditorAreaCSS.\r
+       var sComboPreviewCSS = oConfig.ToolbarComboPreviewCSS ;\r
+       if ( !sComboPreviewCSS || sComboPreviewCSS.length == 0 )\r
+               oConfig.ToolbarComboPreviewCSS = oConfig.EditorAreaCSS ;\r
+\r
+       // Turn the attributes that will be removed in the RemoveFormat from a string to an array\r
+       oConfig.RemoveAttributesArray = (oConfig.RemoveAttributes || '').split( ',' );\r
+\r
+       if ( !FCKConfig.SkinEditorCSS || FCKConfig.SkinEditorCSS.length == 0 )\r
+               FCKConfig.SkinEditorCSS = FCKConfig.SkinPath + 'fck_editor.css' ;\r
+\r
+       if ( !FCKConfig.SkinDialogCSS || FCKConfig.SkinDialogCSS.length == 0 )\r
+               FCKConfig.SkinDialogCSS = FCKConfig.SkinPath + 'fck_dialog.css' ;\r
+}\r
+\r
+// Define toolbar sets collection.\r
+FCKConfig.ToolbarSets = new Object() ;\r
+\r
+// Defines the plugins collection.\r
+FCKConfig.Plugins = new Object() ;\r
+FCKConfig.Plugins.Items = new Array() ;\r
+\r
+FCKConfig.Plugins.Add = function( name, langs, path )\r
+{\r
+       FCKConfig.Plugins.Items.push( [name, langs, path] ) ;\r
+}\r
+\r
+// FCKConfig.ProtectedSource: object that holds a collection of Regular\r
+// Expressions that defined parts of the raw HTML that must remain untouched\r
+// like custom tags, scripts, server side code, etc...\r
+FCKConfig.ProtectedSource = new Object() ;\r
+\r
+// Generates a string used to identify and locate the Protected Tags comments.\r
+FCKConfig.ProtectedSource._CodeTag = (new Date()).valueOf() ;\r
+\r
+// Initialize the regex array with the default ones.\r
+FCKConfig.ProtectedSource.RegexEntries = [\r
+       // First of any other protection, we must protect all comments to avoid\r
+       // loosing them (of course, IE related).\r
+       /<!--[\s\S]*?-->/g ,\r
+\r
+       // Script tags will also be forced to be protected, otherwise IE will execute them.\r
+       /<script[\s\S]*?<\/script>/gi,\r
+\r
+       // <noscript> tags (get lost in IE and messed up in FF).\r
+       /<noscript[\s\S]*?<\/noscript>/gi\r
+] ;\r
+\r
+FCKConfig.ProtectedSource.Add = function( regexPattern )\r
+{\r
+       this.RegexEntries.push( regexPattern ) ;\r
+}\r
+\r
+FCKConfig.ProtectedSource.Protect = function( html )\r
+{\r
+       var codeTag = this._CodeTag ;\r
+       function _Replace( protectedSource )\r
+       {\r
+               var index = FCKTempBin.AddElement( protectedSource ) ;\r
+               return '<!--{' + codeTag + index + '}-->' ;\r
+       }\r
+\r
+       for ( var i = 0 ; i < this.RegexEntries.length ; i++ )\r
+       {\r
+               html = html.replace( this.RegexEntries[i], _Replace ) ;\r
+       }\r
+\r
+       return html ;\r
+}\r
+\r
+FCKConfig.ProtectedSource.Revert = function( html, clearBin )\r
+{\r
+       function _Replace( m, opener, index )\r
+       {\r
+               var protectedValue = clearBin ? FCKTempBin.RemoveElement( index ) : FCKTempBin.Elements[ index ] ;\r
+               // There could be protected source inside another one.\r
+               return FCKConfig.ProtectedSource.Revert( protectedValue, clearBin ) ;\r
+       }\r
+\r
+       var regex = new RegExp( "(<|&lt;)!--\\{" + this._CodeTag + "(\\d+)\\}--(>|&gt;)", "g" ) ;\r
+       return html.replace( regex, _Replace ) ;\r
+}\r
+\r
+// Returns a string with the attributes that must be appended to the body\r
+FCKConfig.GetBodyAttributes = function()\r
+{\r
+       var bodyAttributes = '' ;\r
+       // Add id and class to the body.\r
+       if ( this.BodyId && this.BodyId.length > 0 )\r
+               bodyAttributes += ' id="' + this.BodyId + '"' ;\r
+       if ( this.BodyClass && this.BodyClass.length > 0 )\r
+               bodyAttributes += ' class="' + this.BodyClass + '"' ;\r
+\r
+       return bodyAttributes ;\r
+}\r
+\r
+// Sets the body attributes directly on the node\r
+FCKConfig.ApplyBodyAttributes = function( oBody )\r
+{\r
+       // Add ID and Class to the body\r
+       if ( this.BodyId && this.BodyId.length > 0 )\r
+               oBody.id = FCKConfig.BodyId ;\r
+       if ( this.BodyClass && this.BodyClass.length > 0 )\r
+               oBody.className += ' ' + FCKConfig.BodyClass ;\r
+}\r