[ Index ] |
|
Code source de GeekLog 1.4.1 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2006 Frederico Caldeira Knabben 4 * 5 * Licensed under the terms of the GNU Lesser General Public License: 6 * http://www.opensource.org/licenses/lgpl-license.php 7 * 8 * For further information visit: 9 * http://www.fckeditor.net/ 10 * 11 * "Support Open Source software. What about a donation today?" 12 * 13 * File Name: fckconfig.js 14 * Creates and initializes the FCKConfig object. 15 * 16 * File Authors: 17 * Frederico Caldeira Knabben (fredck@fckeditor.net) 18 */ 19 20 var FCKConfig = FCK.Config = new Object() ; 21 22 /* 23 For the next major version (probably 3.0) we should move all this stuff to 24 another dedicated object and leave FCKConfig as a holder object for settings only). 25 */ 26 27 // Editor Base Path 28 if ( document.location.protocol == 'file:' ) 29 { 30 FCKConfig.BasePath = unescape( document.location.pathname.substr(1) ) ; 31 FCKConfig.BasePath = FCKConfig.BasePath.replace( /\\/gi, '/' ) ; 32 FCKConfig.BasePath = 'file://' + FCKConfig.BasePath.substring(0,FCKConfig.BasePath.lastIndexOf('/')+1) ; 33 FCKConfig.FullBasePath = FCKConfig.BasePath ; 34 } 35 else 36 { 37 FCKConfig.BasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1) ; 38 FCKConfig.FullBasePath = document.location.protocol + '//' + document.location.host + FCKConfig.BasePath ; 39 } 40 41 FCKConfig.EditorPath = FCKConfig.BasePath.replace( /editor\/$/, '' ) ; 42 43 // There is a bug in Gecko. If the editor is hidden on startup, an error is 44 // thrown when trying to get the screen dimentions. 45 try 46 { 47 FCKConfig.ScreenWidth = screen.width ; 48 FCKConfig.ScreenHeight = screen.height ; 49 } 50 catch (e) 51 { 52 FCKConfig.ScreenWidth = 800 ; 53 FCKConfig.ScreenHeight = 600 ; 54 } 55 56 // Override the actual configuration values with the values passed throw the 57 // hidden field "<InstanceName>___Config". 58 FCKConfig.ProcessHiddenField = function() 59 { 60 this.PageConfig = new Object() ; 61 62 // Get the hidden field. 63 var oConfigField = window.parent.document.getElementById( FCK.Name + '___Config' ) ; 64 65 // Do nothing if the config field was not defined. 66 if ( ! oConfigField ) return ; 67 68 var aCouples = oConfigField.value.split('&') ; 69 70 for ( var i = 0 ; i < aCouples.length ; i++ ) 71 { 72 if ( aCouples[i].length == 0 ) 73 continue ; 74 75 var aConfig = aCouples[i].split( '=' ) ; 76 var sKey = unescape( aConfig[0] ) ; 77 var sVal = unescape( aConfig[1] ) ; 78 79 if ( sKey == 'CustomConfigurationsPath' ) // The Custom Config File path must be loaded immediately. 80 FCKConfig[ sKey ] = sVal ; 81 82 else if ( sVal.toLowerCase() == "true" ) // If it is a boolean TRUE. 83 this.PageConfig[ sKey ] = true ; 84 85 else if ( sVal.toLowerCase() == "false" ) // If it is a boolean FALSE. 86 this.PageConfig[ sKey ] = false ; 87 88 else if ( ! isNaN( sVal ) ) // If it is a number. 89 this.PageConfig[ sKey ] = parseInt( sVal ) ; 90 91 else // In any other case it is a string. 92 this.PageConfig[ sKey ] = sVal ; 93 } 94 } 95 96 function FCKConfig_LoadPageConfig() 97 { 98 var oPageConfig = FCKConfig.PageConfig ; 99 for ( var sKey in oPageConfig ) 100 FCKConfig[ sKey ] = oPageConfig[ sKey ] ; 101 } 102 103 function FCKConfig_PreProcess() 104 { 105 var oConfig = FCKConfig ; 106 107 // Force debug mode if fckdebug=true in the QueryString (main page). 108 if ( oConfig.AllowQueryStringDebug && (/fckdebug=true/i).test( window.top.location.search ) ) 109 oConfig.Debug = true ; 110 111 // Certifies that the "PluginsPath" configuration ends with a slash. 112 if ( !oConfig.PluginsPath.endsWith('/') ) 113 oConfig.PluginsPath += '/' ; 114 115 // EditorAreaCSS accepts an array of paths or a single path (as string). 116 // In the last case, transform it in an array. 117 if ( typeof( oConfig.EditorAreaCSS ) == 'string' ) 118 oConfig.EditorAreaCSS = [ oConfig.EditorAreaCSS ] ; 119 } 120 121 // Define toolbar sets collection. 122 FCKConfig.ToolbarSets = new Object() ; 123 124 // Defines the plugins collection. 125 FCKConfig.Plugins = new Object() ; 126 FCKConfig.Plugins.Items = new Array() ; 127 128 FCKConfig.Plugins.Add = function( name, langs, path ) 129 { 130 FCKConfig.Plugins.Items.AddItem( [name, langs, path] ) ; 131 } 132 133 // FCKConfig.ProtectedSource: object that holds a collection of Regular 134 // Expressions that defined parts of the raw HTML that must remain untouched 135 // like custom tags, scripts, server side code, etc... 136 FCKConfig.ProtectedSource = new Object() ; 137 FCKConfig.ProtectedSource.RegexEntries = new Array() ; 138 139 FCKConfig.ProtectedSource.Add = function( regexPattern ) 140 { 141 this.RegexEntries.AddItem( regexPattern ) ; 142 } 143 144 FCKConfig.ProtectedSource.Protect = function( html ) 145 { 146 function _Replace( protectedSource ) 147 { 148 var index = FCKTempBin.AddElement( protectedSource ) ; 149 return '<!--{PS..' + index + '}-->' ; 150 } 151 152 for ( var i = 0 ; i < this.RegexEntries.length ; i++ ) 153 { 154 html = html.replace( this.RegexEntries[i], _Replace ) ; 155 } 156 157 return html ; 158 } 159 160 161 FCKConfig.ProtectedSource.Revert = function( html, clearBin ) 162 { 163 function _Replace( m, opener, index ) 164 { 165 var protectedValue = clearBin ? FCKTempBin.RemoveElement( index ) : FCKTempBin.Elements[ index ] ; 166 // There could be protected source inside another one. 167 return FCKConfig.ProtectedSource.Revert( protectedValue, clearBin ) ; 168 } 169 170 return html.replace( /(<|<)!--\{PS..(\d+)\}--(>|>)/g, _Replace ) ; 171 } 172 173 // First of any other protection, we must protect all comments to avoid 174 // loosing them (of course, IE related). 175 FCKConfig.ProtectedSource.Add( /<!--[\s\S]*?-->/g ) ;
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |