Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 2047 → Rev 2048

/trunk/api/fckeditor/editor/plugins/autogrow/fckplugin.js
1,6 → 1,6
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
* Copyright (C) 2003-2009 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
22,78 → 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 ;
 
var iFrameHeight, iInnerHeight ;
newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
 
if ( FCKBrowserInfo.IsIE )
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() ;
}
}
}
},
 
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 ;
 
if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
var iFrameHeight ;
var iInnerHeight ;
 
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 iInnerHeight - iFrameHeight ;
},
 
SetListeners : function()
{
if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
return ;
 
window.frameElement.height = iMainFrameSize ;
 
// 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() ;
FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ;
FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ;
}
}
};
 
FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ;
 
function FCKAutoGrow_SetListeners()
{
if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
return ;
 
FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
}
 
if ( FCKBrowserInfo.IsIE )
{
// FCKAutoGrow_SetListeners() ;
FCK.Events.AttachEvent( 'OnAfterSetHTML', 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 ) ;
FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;