diff options
Diffstat (limited to 'httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js')
-rw-r--r-- | httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js | 119 |
1 files changed, 69 insertions, 50 deletions
diff --git a/httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js b/httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js index 7ce1c1cc2..1df2d0ffd 100644 --- a/httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js +++ b/httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js @@ -1,6 +1,6 @@ /*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
- * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ * Copyright (C) 2003-2010 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
@@ -22,71 +22,90 @@ * height (FCKConfig.AutoGrowMax), based on its contents.
*/
-var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
+var FCKAutoGrow = {
+ MIN_HEIGHT : window.frameElement.offsetHeight,
-function FCKAutoGrow_Check()
-{
- var oInnerDoc = FCK.EditorDocument ;
+ Check : function()
+ {
+ var delta = FCKAutoGrow.GetHeightDelta() ;
+ if ( delta != 0 )
+ {
+ var newHeight = window.frameElement.offsetHeight + delta ;
+
+ newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
- var iFrameHeight, iInnerHeight ;
+ if ( newHeight != window.frameElement.height )
+ {
+ window.frameElement.style.height = newHeight + "px" ;
+
+ // Gecko browsers use an onresize handler to update the innermost
+ // IFRAME's height. If the document is modified before the onresize
+ // is triggered, the plugin will miscalculate the new height. Thus,
+ // forcibly trigger onresize. #1336
+ if ( typeof window.onresize == 'function' )
+ {
+ window.onresize() ;
+ }
+ }
+ }
+ },
- if ( FCKBrowserInfo.IsIE )
+ CheckEditorStatus : function( sender, status )
{
- iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
- iInnerHeight = oInnerDoc.body.scrollHeight ;
- }
- else
+ if ( status == FCK_STATUS_COMPLETE )
+ FCKAutoGrow.Check() ;
+ },
+
+ GetEffectiveHeight : function( height )
{
- iFrameHeight = FCK.EditorWindow.innerHeight ;
- iInnerHeight = oInnerDoc.body.offsetHeight ;
- }
+ if ( height < FCKAutoGrow.MIN_HEIGHT )
+ height = FCKAutoGrow.MIN_HEIGHT;
+ else
+ {
+ var max = FCKConfig.AutoGrowMax;
+ if ( max && max > 0 && height > max )
+ height = max;
+ }
- var iDiff = iInnerHeight - iFrameHeight ;
+ return height;
+ },
- if ( iDiff != 0 )
+ GetHeightDelta : function()
{
- var iMainFrameSize = window.frameElement.offsetHeight ;
+ var oInnerDoc = FCK.EditorDocument ;
+
+ var iFrameHeight ;
+ var iInnerHeight ;
- if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
+ if ( FCKBrowserInfo.IsIE )
{
- iMainFrameSize += iDiff ;
- if ( iMainFrameSize > FCKConfig.AutoGrowMax )
- iMainFrameSize = FCKConfig.AutoGrowMax ;
+ iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
+ iInnerHeight = oInnerDoc.body.scrollHeight ;
}
- else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
+ else
{
- iMainFrameSize += iDiff ;
- if ( iMainFrameSize < FCKAutoGrow_Min )
- iMainFrameSize = FCKAutoGrow_Min ;
+ iFrameHeight = FCK.EditorWindow.innerHeight ;
+ iInnerHeight = oInnerDoc.body.offsetHeight +
+ ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ), 10 ) || 0 ) +
+ ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ), 10 ) || 0 ) ;
}
- else
- return ;
- window.frameElement.height = iMainFrameSize ;
- }
-}
+ return iInnerHeight - iFrameHeight ;
+ },
-FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
+ SetListeners : function()
+ {
+ if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
+ return ;
-function FCKAutoGrow_SetListeners()
-{
- if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
- return ;
+ FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ;
+ FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ;
+ }
+};
- FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
- FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
-}
+FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ;
if ( FCKBrowserInfo.IsIE )
-{
-// FCKAutoGrow_SetListeners() ;
- FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
-}
-
-function FCKAutoGrow_CheckEditorStatus( sender, status )
-{
- if ( status == FCK_STATUS_COMPLETE )
- FCKAutoGrow_Check() ;
-}
-
-FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;
\ No newline at end of file + FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow.SetListeners ) ;
+
+FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;
|