[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 /* 2 * FCKeditor - The text editor for internet 3 * Copyright (C) 2003-2005 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 // Editor Base Path 23 if ( document.location.protocol == 'file:' ) 24 { 25 FCKConfig.BasePath = unescape( document.location.pathname.substr(1) ) ; 26 FCKConfig.BasePath = FCKConfig.BasePath.replace( /\\/gi, '/' ) ; 27 FCKConfig.BasePath = 'file://' + FCKConfig.BasePath.substring(0,FCKConfig.BasePath.lastIndexOf('/')+1) ; 28 } 29 else 30 { 31 FCKConfig.BasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1) ; 32 FCKConfig.FullBasePath = document.location.protocol + '//' + document.location.host + FCKConfig.BasePath ; 33 } 34 35 FCKConfig.EditorPath = FCKConfig.BasePath.replace( /editor\/$/, '' ) ; 36 37 // There is a bug in Gecko. If the editor is hidden on startup, an error is 38 // thrown when trying to get the screen dimentions. 39 try 40 { 41 FCKConfig.ScreenWidth = screen.width ; 42 FCKConfig.ScreenHeight = screen.height ; 43 } 44 catch (e) 45 { 46 FCKConfig.ScreenWidth = 800 ; 47 FCKConfig.ScreenHeight = 600 ; 48 } 49 50 // Override the actual configuration values with the values passed throw the 51 // hidden field "<InstanceName>___Config". 52 FCKConfig.ProcessHiddenField = function() 53 { 54 this.PageConfig = new Object() ; 55 56 // Get the hidden field. 57 var oConfigField = window.parent.document.getElementById( FCK.Name + '___Config' ) ; 58 59 // Do nothing if the config field was not defined. 60 if ( ! oConfigField ) return ; 61 62 var aCouples = oConfigField.value.split('&') ; 63 64 for ( var i = 0 ; i < aCouples.length ; i++ ) 65 { 66 if ( aCouples[i].length == 0 ) 67 continue ; 68 69 var aConfig = aCouples[i].split( '=' ) ; 70 var sKey = unescape( aConfig[0] ) ; 71 var sVal = unescape( aConfig[1] ) ; 72 73 if ( sKey == 'CustomConfigurationsPath' ) // The Custom Config File path must be loaded immediately. 74 FCKConfig[ sKey ] = sVal ; 75 76 else if ( sVal.toLowerCase() == "true" ) // If it is a boolean TRUE. 77 this.PageConfig[ sKey ] = true ; 78 79 else if ( sVal.toLowerCase() == "false" ) // If it is a boolean FALSE. 80 this.PageConfig[ sKey ] = false ; 81 82 else if ( ! isNaN( sVal ) ) // If it is a number. 83 this.PageConfig[ sKey ] = parseInt( sVal ) ; 84 85 else // In any other case it is a string. 86 this.PageConfig[ sKey ] = sVal ; 87 } 88 } 89 90 FCKConfig.LoadPageConfig = function() 91 { 92 for ( var sKey in this.PageConfig ) 93 FCKConfig[ sKey ] = this.PageConfig[ sKey ] ; 94 } 95 96 // Define toolbar sets collection. 97 FCKConfig.ToolbarSets = new Object() ; 98 99 // Defines the plugins collection. 100 FCKConfig.Plugins = new Object() ; 101 FCKConfig.Plugins.Items = new Array() ; 102 103 FCKConfig.Plugins.Add = function( name, langs, path ) 104 { 105 FCKConfig.Plugins.Items.addItem( [name, langs, path] ) ; 106 } 107 108 // FCKConfig.ProtectedSource: object that holds a collection of Regular 109 // Expressions that defined parts of the raw HTML that must remain untouched 110 // like custom tags, scripts, server side code, etc... 111 FCKConfig.ProtectedSource = new Object() ; 112 FCKConfig.ProtectedSource.RegexEntries = new Array() ; 113 114 FCKConfig.ProtectedSource.Add = function( regexPattern ) 115 { 116 this.RegexEntries.addItem( regexPattern ) ; 117 } 118 119 FCKConfig.ProtectedSource.Protect = function( html ) 120 { 121 function _Replace( protectedSource ) 122 { 123 var index = FCKTempBin.AddElement( protectedSource ) ; 124 return '<!--{PS..' + index + '}-->' ; 125 } 126 127 for ( var i = 0 ; i < this.RegexEntries.length ; i++ ) 128 { 129 html = html.replace( this.RegexEntries[i], _Replace ) ; 130 } 131 132 return html ; 133 } 134 135 136 FCKConfig.ProtectedSource.Revert = function( html, clearBin ) 137 { 138 function _Replace( m, opener, index ) 139 { 140 var protectedValue = clearBin ? FCKTempBin.RemoveElement( index ) : FCKTempBin.Elements[ index ] ; 141 // There could be protected source inside another one. 142 return FCKConfig.ProtectedSource.Revert( protectedValue, clearBin ) ; 143 } 144 145 return html.replace( /(<|<)!--\{PS..(\d+)\}--(>|>)/g, _Replace ) ; 146 } 147 148 // First of any other protection, we must protect all comments to avoid 149 // loosing them (of course, IE related). 150 FCKConfig.ProtectedSource.Add( /<!--[\s\S]*?-->/g ) ;
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |