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