[ Index ]
 

Code source de FCKeditor 2.4

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

title

Body

[fermer]

/editor/plugins/autogrow/ -> fckplugin.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: fckplugin.js
  22   *     Plugin: automatically resizes the editor until a configurable maximun 
  23   *     height (FCKConfig.AutoGrowMax), based on its contents.
  24   * 
  25   * File Authors:
  26   *         Frederico Caldeira Knabben (www.fckeditor.net)
  27   */
  28  
  29  var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
  30  
  31  function FCKAutoGrow_Check()
  32  {
  33      var oInnerDoc = FCK.EditorDocument ;
  34  
  35      var iFrameHeight, iInnerHeight ;
  36      
  37      if ( FCKBrowserInfo.IsIE )
  38      {
  39          iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
  40          iInnerHeight = oInnerDoc.body.scrollHeight ;
  41      }
  42      else
  43      {
  44          iFrameHeight = FCK.EditorWindow.innerHeight ;
  45          iInnerHeight = oInnerDoc.body.offsetHeight ;
  46      }
  47  
  48      var iDiff = iInnerHeight - iFrameHeight ;
  49  
  50      if ( iDiff != 0 )
  51      {
  52          var iMainFrameSize = window.frameElement.offsetHeight ;
  53          
  54          if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
  55          {
  56              iMainFrameSize += iDiff ;
  57              if ( iMainFrameSize > FCKConfig.AutoGrowMax )
  58                  iMainFrameSize = FCKConfig.AutoGrowMax ;
  59          }
  60          else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
  61          {
  62              iMainFrameSize += iDiff ;
  63              if ( iMainFrameSize < FCKAutoGrow_Min )
  64                  iMainFrameSize = FCKAutoGrow_Min ;
  65          }
  66          else
  67              return ;
  68              
  69          window.frameElement.height = iMainFrameSize ;
  70      }
  71  }
  72  
  73  FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
  74  
  75  function FCKAutoGrow_SetListeners()
  76  {
  77      if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
  78          return ;
  79  
  80      FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
  81      FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
  82  }
  83  
  84  if ( FCKBrowserInfo.IsIE )
  85  {
  86  //    FCKAutoGrow_SetListeners() ;
  87      FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
  88  }
  89  
  90  function FCKAutoGrow_CheckEditorStatus( sender, status )
  91  {
  92      if ( status == FCK_STATUS_COMPLETE )
  93          FCKAutoGrow_Check() ;
  94  }
  95  
  96  FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;


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