[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/editor/_source/internals/ -> fckconfig.js (source)

   1  /*
   2   * FCKeditor - The text editor for Internet - http://www.fckeditor.net
   3   * Copyright (C) 2003-2007 Frederico Caldeira Knabben
   4   * 
   5   * == BEGIN LICENSE ==
   6   * 
   7   * Licensed under the terms of any of the following licenses at your
   8   * choice:
   9   * 
  10   *  - GNU General Public License Version 2 or later (the "GPL")
  11   *    http://www.gnu.org/licenses/gpl.html
  12   * 
  13   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  14   *    http://www.gnu.org/licenses/lgpl.html
  15   * 
  16   *  - Mozilla Public License Version 1.1 or later (the "MPL")
  17   *    http://www.mozilla.org/MPL/MPL-1.1.html
  18   * 
  19   * == END LICENSE ==
  20   * 
  21   * File Name: fckconfig.js
  22   *     Creates and initializes the FCKConfig object.
  23   * 
  24   * File Authors:
  25   *         Frederico Caldeira Knabben (www.fckeditor.net)
  26   */
  27  
  28  var FCKConfig = FCK.Config = new Object() ;
  29  
  30  /*
  31      For the next major version (probably 3.0) we should move all this stuff to
  32      another dedicated object and leave FCKConfig as a holder object for settings only).
  33  */
  34  
  35  // Editor Base Path
  36  if ( document.location.protocol == 'file:' )
  37  {
  38      FCKConfig.BasePath = decodeURIComponent( document.location.pathname.substr(1) ) ;
  39      FCKConfig.BasePath = FCKConfig.BasePath.replace( /\\/gi, '/' ) ;
  40      FCKConfig.BasePath = 'file://' + FCKConfig.BasePath.substring(0,FCKConfig.BasePath.lastIndexOf('/')+1) ;
  41      FCKConfig.FullBasePath = FCKConfig.BasePath ;
  42  }
  43  else
  44  {
  45      FCKConfig.BasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/')+1) ;
  46      FCKConfig.FullBasePath = document.location.protocol + '//' + document.location.host + FCKConfig.BasePath ;
  47  }
  48  
  49  FCKConfig.EditorPath = FCKConfig.BasePath.replace( /editor\/$/, '' ) ;
  50  
  51  // There is a bug in Gecko. If the editor is hidden on startup, an error is 
  52  // thrown when trying to get the screen dimentions.
  53  try
  54  {
  55      FCKConfig.ScreenWidth    = screen.width ;
  56      FCKConfig.ScreenHeight    = screen.height ;
  57  }
  58  catch (e) 
  59  {
  60      FCKConfig.ScreenWidth    = 800 ;
  61      FCKConfig.ScreenHeight    = 600 ;
  62  }
  63  
  64  // Override the actual configuration values with the values passed throw the 
  65  // hidden field "<InstanceName>___Config".
  66  FCKConfig.ProcessHiddenField = function()
  67  {
  68      this.PageConfig = new Object() ;
  69  
  70      // Get the hidden field.
  71      var oConfigField = window.parent.document.getElementById( FCK.Name + '___Config' ) ;
  72      
  73      // Do nothing if the config field was not defined.
  74      if ( ! oConfigField ) return ;
  75  
  76      var aCouples = oConfigField.value.split('&') ;
  77  
  78      for ( var i = 0 ; i < aCouples.length ; i++ )
  79      {
  80          if ( aCouples[i].length == 0 )
  81              continue ;
  82  
  83          var aConfig = aCouples[i].split( '=' ) ;
  84          var sKey = decodeURIComponent( aConfig[0] ) ;
  85          var sVal = decodeURIComponent( aConfig[1] ) ;
  86  
  87          if ( sKey == 'CustomConfigurationsPath' )    // The Custom Config File path must be loaded immediately.
  88              FCKConfig[ sKey ] = sVal ;
  89  
  90          else if ( sVal.toLowerCase() == "true" )    // If it is a boolean TRUE.
  91              this.PageConfig[ sKey ] = true ;
  92  
  93          else if ( sVal.toLowerCase() == "false" )    // If it is a boolean FALSE.
  94              this.PageConfig[ sKey ] = false ;
  95  
  96          else if ( sVal.length > 0 && !isNaN( sVal ) )    // If it is a number.
  97              this.PageConfig[ sKey ] = parseInt( sVal, 10 ) ;
  98  
  99          else                                        // In any other case it is a string.
 100              this.PageConfig[ sKey ] = sVal ;
 101      }
 102  }
 103  
 104  function FCKConfig_LoadPageConfig()
 105  {
 106      var oPageConfig = FCKConfig.PageConfig ;
 107      for ( var sKey in oPageConfig )
 108          FCKConfig[ sKey ] = oPageConfig[ sKey ] ;
 109  }
 110  
 111  function FCKConfig_PreProcess()
 112  {
 113      var oConfig = FCKConfig ;
 114      
 115      // Force debug mode if fckdebug=true in the QueryString (main page).
 116      if ( oConfig.AllowQueryStringDebug )
 117      {
 118          try
 119          {
 120              if ( (/fckdebug=true/i).test( window.top.location.search ) )
 121                  oConfig.Debug = true ;
 122          }
 123          catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
 124      }
 125  
 126      // Certifies that the "PluginsPath" configuration ends with a slash.
 127      if ( !oConfig.PluginsPath.EndsWith('/') )
 128          oConfig.PluginsPath += '/' ;
 129  
 130      // EditorAreaCSS accepts an array of paths or a single path (as string).
 131      // In the last case, transform it in an array.
 132      if ( typeof( oConfig.EditorAreaCSS ) == 'string' )
 133          oConfig.EditorAreaCSS = [ oConfig.EditorAreaCSS ] ;
 134  
 135      var sComboPreviewCSS = oConfig.ToolbarComboPreviewCSS ;
 136      if ( !sComboPreviewCSS || sComboPreviewCSS.length == 0 )
 137          oConfig.ToolbarComboPreviewCSS = oConfig.EditorAreaCSS ;
 138      else if ( typeof( sComboPreviewCSS ) == 'string' )
 139          oConfig.ToolbarComboPreviewCSS = [ sComboPreviewCSS ] ;
 140  }
 141  
 142  // Define toolbar sets collection.
 143  FCKConfig.ToolbarSets = new Object() ;
 144  
 145  // Defines the plugins collection.
 146  FCKConfig.Plugins = new Object() ;
 147  FCKConfig.Plugins.Items = new Array() ;
 148  
 149  FCKConfig.Plugins.Add = function( name, langs, path )
 150  {
 151      FCKConfig.Plugins.Items.AddItem( [name, langs, path] ) ;
 152  }
 153  
 154  // FCKConfig.ProtectedSource: object that holds a collection of Regular 
 155  // Expressions that defined parts of the raw HTML that must remain untouched
 156  // like custom tags, scripts, server side code, etc...
 157  FCKConfig.ProtectedSource = new Object() ;
 158  
 159  // Initialize the regex array with the default ones.
 160  FCKConfig.ProtectedSource.RegexEntries = [
 161      // First of any other protection, we must protect all comments to avoid 
 162      // loosing them (of course, IE related).
 163      /<!--[\s\S]*?-->/g ,
 164  
 165      // Script tags will also be forced to be protected, otherwise IE will execute them.
 166      /<script[\s\S]*?<\/script>/gi,
 167      
 168      // <noscript> tags (get lost in IE and messed up in FF).
 169      /<noscript[\s\S]*?<\/noscript>/gi
 170  ] ;
 171  
 172  FCKConfig.ProtectedSource.Add = function( regexPattern )
 173  {
 174      this.RegexEntries.AddItem( regexPattern ) ;
 175  }
 176  
 177  FCKConfig.ProtectedSource.Protect = function( html )
 178  {
 179  	function _Replace( protectedSource )
 180      {
 181          var index = FCKTempBin.AddElement( protectedSource ) ;
 182          return '<!--{PS..' + index + '}-->' ;
 183      }
 184      
 185      for ( var i = 0 ; i < this.RegexEntries.length ; i++ )
 186      {
 187          html = html.replace( this.RegexEntries[i], _Replace ) ;
 188      }
 189      
 190      return html ;
 191  }
 192  
 193  FCKConfig.ProtectedSource.Revert = function( html, clearBin )
 194  {
 195  	function _Replace( m, opener, index )
 196      {
 197          var protectedValue = clearBin ? FCKTempBin.RemoveElement( index ) : FCKTempBin.Elements[ index ] ;
 198          // There could be protected source inside another one.
 199          return FCKConfig.ProtectedSource.Revert( protectedValue, clearBin ) ;
 200      }
 201  
 202      return html.replace( /(<|&lt;)!--\{PS..(\d+)\}--(>|&gt;)/g, _Replace ) ;
 203  }


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7