[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/libraries/ckeditor/_source/plugins/autogrow/ -> plugin.js (source)

   1  /*

   2  Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.

   3  For licensing, see LICENSE.html or http://ckeditor.com/license

   4  */
   5  
   6  /**

   7   * @file AutoGrow plugin

   8   */
   9  (function(){
  10      var resizeEditor = function( editor )
  11      {
  12          var doc = editor.document,
  13              currentHeight = editor.window.getViewPaneSize().height,
  14              newHeight;
  15  
  16          // We can not use documentElement to calculate the height for IE (#6061).

  17          if ( CKEDITOR.env.ie )
  18              newHeight = doc.getBody().$.scrollHeight + 24;
  19          else
  20              newHeight = doc.getDocumentElement().$.offsetHeight;
  21  
  22          var min = editor.config.autoGrow_minHeight,
  23              max = editor.config.autoGrow_maxHeight;
  24          ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );
  25          if ( min )
  26              newHeight = Math.max( newHeight, min );
  27          if ( max )
  28              newHeight = Math.min( newHeight, max );
  29  
  30          if ( newHeight != currentHeight )
  31          {
  32              newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;
  33              editor.resize( editor.container.getStyle( 'width' ), newHeight, true );
  34          }
  35      };
  36      CKEDITOR.plugins.add( 'autogrow',
  37      {
  38          init : function( editor )
  39          {
  40              for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } )
  41              {
  42                  editor.on( eventName, function( evt )
  43                  {
  44                      // Some time is required for insertHtml, and it gives other events better performance as well.

  45                      if ( evt.editor.mode == 'wysiwyg' )
  46                          setTimeout( function(){ resizeEditor( evt.editor ); }, 100 );
  47                  });
  48              }
  49          }
  50      });
  51  })();
  52  /**

  53   * The minimum height to which the editor can reach using AutoGrow.

  54   * @name CKEDITOR.config.autoGrow_minHeight

  55   * @type Number

  56   * @default 200

  57   * @since 3.4

  58   * @example

  59   * config.autoGrow_minHeight = 300;

  60   */
  61  
  62  /**

  63   * The maximum height to which the editor can reach using AutoGrow. Zero means unlimited.

  64   * @name CKEDITOR.config.autoGrow_maxHeight

  65   * @type Number

  66   * @default 0

  67   * @since 3.4

  68   * @example

  69   * config.autoGrow_maxHeight = 400;

  70   */
  71  
  72  /**

  73   * Fired when the AutoGrow plugin is about to change the size of the editor.

  74   * @name CKEDITOR#autogrow

  75   * @event

  76   * @param {Number} data.currentHeight The current height of the editor (before the resizing).

  77   * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed

  78   *                to determine another height to be used instead.

  79   */


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7