2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @file AutoGrow plugin
\r
10 var resizeEditor = function( editor )
\r
12 var doc = editor.document,
\r
13 currentHeight = editor.window.getViewPaneSize().height,
\r
16 // We can not use documentElement to calculate the height for IE (#6061).
\r
17 if ( CKEDITOR.env.ie )
\r
18 newHeight = doc.getBody().$.scrollHeight + 24;
\r
20 newHeight = doc.getDocumentElement().$.offsetHeight;
\r
22 var min = editor.config.autoGrow_minHeight,
\r
23 max = editor.config.autoGrow_maxHeight;
\r
24 ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 );
\r
26 newHeight = Math.max( newHeight, min );
\r
28 newHeight = Math.min( newHeight, max );
\r
30 if ( newHeight != currentHeight )
\r
32 newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight;
\r
33 editor.resize( editor.container.getStyle( 'width' ), newHeight, true );
\r
36 CKEDITOR.plugins.add( 'autogrow',
\r
38 init : function( editor )
\r
40 for ( var eventName in { contentDom:1, key:1, selectionChange:1, insertElement:1 } )
\r
42 editor.on( eventName, function( evt )
\r
44 // Some time is required for insertHtml, and it gives other events better performance as well.
\r
45 if ( evt.editor.mode == 'wysiwyg' )
\r
46 setTimeout( function(){ resizeEditor( evt.editor ); }, 100 );
\r
53 * The minimum height to which the editor can reach using AutoGrow.
\r
54 * @name CKEDITOR.config.autoGrow_minHeight
\r
59 * config.autoGrow_minHeight = 300;
\r
63 * The maximum height to which the editor can reach using AutoGrow. Zero means unlimited.
\r
64 * @name CKEDITOR.config.autoGrow_maxHeight
\r
69 * config.autoGrow_maxHeight = 400;
\r
73 * Fired when the AutoGrow plugin is about to change the size of the editor.
\r
74 * @name CKEDITOR#autogrow
\r
76 * @param {Number} data.currentHeight The current height of the editor (before the resizing).
\r
77 * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed
\r
78 * to determine another height to be used instead.
\r