2
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
* Copyright (C) 2003-2010 Frederico Caldeira Knabben
7
* Licensed under the terms of any of the following licenses at your
10
* - GNU General Public License Version 2 or later (the "GPL")
11
* http://www.gnu.org/licenses/gpl.html
13
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
* http://www.gnu.org/licenses/lgpl.html
16
* - Mozilla Public License Version 1.1 or later (the "MPL")
17
* http://www.mozilla.org/MPL/MPL-1.1.html
21
* Plugin: automatically resizes the editor until a configurable maximun
22
* height (FCKConfig.AutoGrowMax), based on its contents.
26
MIN_HEIGHT : window.frameElement.offsetHeight,
30
var delta = FCKAutoGrow.GetHeightDelta() ;
33
var newHeight = window.frameElement.offsetHeight + delta ;
35
newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
37
if ( newHeight != window.frameElement.height )
39
window.frameElement.style.height = newHeight + "px" ;
41
// Gecko browsers use an onresize handler to update the innermost
42
// IFRAME's height. If the document is modified before the onresize
43
// is triggered, the plugin will miscalculate the new height. Thus,
44
// forcibly trigger onresize. #1336
45
if ( typeof window.onresize == 'function' )
53
CheckEditorStatus : function( sender, status )
55
if ( status == FCK_STATUS_COMPLETE )
59
GetEffectiveHeight : function( height )
61
if ( height < FCKAutoGrow.MIN_HEIGHT )
62
height = FCKAutoGrow.MIN_HEIGHT;
65
var max = FCKConfig.AutoGrowMax;
66
if ( max && max > 0 && height > max )
73
GetHeightDelta : function()
75
var oInnerDoc = FCK.EditorDocument ;
80
if ( FCKBrowserInfo.IsIE )
82
iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
83
iInnerHeight = oInnerDoc.body.scrollHeight ;
87
iFrameHeight = FCK.EditorWindow.innerHeight ;
88
iInnerHeight = oInnerDoc.body.offsetHeight +
89
( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ), 10 ) || 0 ) +
90
( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ), 10 ) || 0 ) ;
93
return iInnerHeight - iFrameHeight ;
96
SetListeners : function()
98
if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
101
FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ;
102
FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ;
106
FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ;
108
if ( FCKBrowserInfo.IsIE )
109
FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow.SetListeners ) ;
111
FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;