[freeside-commits] freeside/httemplate/elements/fckeditor/editor/plugins/autogrow fckplugin.js, 1.1, 1.2

Mark Wells mark at wavetail.420.am
Tue Mar 16 00:49:36 PDT 2010


Update of /home/cvs/cvsroot/freeside/httemplate/elements/fckeditor/editor/plugins/autogrow
In directory wavetail.420.am:/tmp/cvs-serv19732/fckeditor/editor/plugins/autogrow

Modified Files:
	fckplugin.js 
Log Message:
FCKeditor 2.6.6

Index: fckplugin.js
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/fckeditor/editor/plugins/autogrow/fckplugin.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- fckplugin.js	1 Aug 2007 22:26:34 -0000	1.1
+++ fckplugin.js	16 Mar 2010 07:49:33 -0000	1.2
@@ -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()
+	Check : function()
 {
-	var oInnerDoc = FCK.EditorDocument ;
+		var delta = FCKAutoGrow.GetHeightDelta() ;
+		if ( delta != 0 )
+		{
+			var newHeight = window.frameElement.offsetHeight + delta ;
 
-	var iFrameHeight, iInnerHeight ;
+			newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
 
-	if ( FCKBrowserInfo.IsIE )
+			if ( newHeight != window.frameElement.height )
 	{
-		iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
-		iInnerHeight = oInnerDoc.body.scrollHeight ;
+				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() ;
+				}
 	}
+		}
+	},
+
+	CheckEditorStatus : function( sender, status )
+	{
+		if ( status == FCK_STATUS_COMPLETE )
+			FCKAutoGrow.Check() ;
+	},
+
+	GetEffectiveHeight : function( height )
+	{
+		if ( height < FCKAutoGrow.MIN_HEIGHT )
+			height = FCKAutoGrow.MIN_HEIGHT;
 	else
 	{
-		iFrameHeight = FCK.EditorWindow.innerHeight ;
-		iInnerHeight = oInnerDoc.body.offsetHeight ;
+			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 ;
 
-		if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
-		{
-			iMainFrameSize += iDiff ;
-			if ( iMainFrameSize > FCKConfig.AutoGrowMax )
-				iMainFrameSize = FCKConfig.AutoGrowMax ;
-		}
-		else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
+		var iFrameHeight ;
+		var iInnerHeight ;
+
+		if ( FCKBrowserInfo.IsIE )
 		{
-			iMainFrameSize += iDiff ;
-			if ( iMainFrameSize < FCKAutoGrow_Min )
-				iMainFrameSize = FCKAutoGrow_Min ;
+			iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
+			iInnerHeight = oInnerDoc.body.scrollHeight ;
 		}
 		else
-			return ;
-
-		window.frameElement.height = iMainFrameSize ;
-	}
+		{
+			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 ) ;
 }
 
-FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
+		return iInnerHeight - iFrameHeight ;
+	},
 
-function FCKAutoGrow_SetListeners()
+	SetListeners : function()
 {
 	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 ) ;
 }
+};
 
-if ( FCKBrowserInfo.IsIE )
-{
-//	FCKAutoGrow_SetListeners() ;
-	FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
-}
+FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ;
 
-function FCKAutoGrow_CheckEditorStatus( sender, status )
-{
-	if ( status == FCK_STATUS_COMPLETE )
-		FCKAutoGrow_Check() ;
-}
+if ( FCKBrowserInfo.IsIE )
+	FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow.SetListeners ) ;
 
-FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;
\ No newline at end of file
+FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;



More information about the freeside-commits mailing list