Subversion Repositories Applications.papyrus

Rev

Rev 1925 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1925 Rev 2048
Line 1... Line 1...
1
/*
1
/*
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
3
 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
4
 *
4
 *
5
 * == BEGIN LICENSE ==
5
 * == BEGIN LICENSE ==
6
 *
6
 *
7
 * Licensed under the terms of any of the following licenses at your
7
 * Licensed under the terms of any of the following licenses at your
8
 * choice:
8
 * choice:
Line 20... Line 20...
20
 *
20
 *
21
 * Plugin: automatically resizes the editor until a configurable maximun
21
 * Plugin: automatically resizes the editor until a configurable maximun
22
 * height (FCKConfig.AutoGrowMax), based on its contents.
22
 * height (FCKConfig.AutoGrowMax), based on its contents.
23
 */
23
 */
Line -... Line 24...
-
 
24
 
24
 
25
var FCKAutoGrow = {
Line 25... Line 26...
25
var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
26
	MIN_HEIGHT : window.frameElement.offsetHeight,
26
 
27
 
27
function FCKAutoGrow_Check()
28
	Check : function()
-
 
29
	{
-
 
30
		var delta = FCKAutoGrow.GetHeightDelta() ;
-
 
31
		if ( delta != 0 )
Line 28... Line 32...
28
{
32
		{
Line -... Line 33...
-
 
33
			var newHeight = window.frameElement.offsetHeight + delta ;
-
 
34
 
-
 
35
			newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
-
 
36
 
-
 
37
			if ( newHeight != window.frameElement.height )
-
 
38
			{
-
 
39
				window.frameElement.style.height = newHeight + "px" ;
-
 
40
 
-
 
41
				// Gecko browsers use an onresize handler to update the innermost
-
 
42
				// IFRAME's height. If the document is modified before the onresize
29
	var oInnerDoc = FCK.EditorDocument ;
43
				// is triggered, the plugin will miscalculate the new height. Thus,
-
 
44
				// forcibly trigger onresize. #1336
-
 
45
				if ( typeof window.onresize == 'function' )
-
 
46
				{
-
 
47
					window.onresize() ;
-
 
48
				}
-
 
49
			}
30
 
50
		}
31
	var iFrameHeight, iInnerHeight ;
51
	},
32
 
52
 
33
	if ( FCKBrowserInfo.IsIE )
53
	CheckEditorStatus : function( sender, status )
34
	{
54
	{
-
 
55
		if ( status == FCK_STATUS_COMPLETE )
35
		iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
56
			FCKAutoGrow.Check() ;
36
		iInnerHeight = oInnerDoc.body.scrollHeight ;
57
	},
37
	}
58
 
-
 
59
	GetEffectiveHeight : function( height )
-
 
60
	{
-
 
61
		if ( height < FCKAutoGrow.MIN_HEIGHT )
-
 
62
			height = FCKAutoGrow.MIN_HEIGHT;
-
 
63
		else
38
	else
64
		{
Line 39... Line 65...
39
	{
65
			var max = FCKConfig.AutoGrowMax;
-
 
66
			if ( max && max > 0 && height > max )
Line 40... Line 67...
40
		iFrameHeight = FCK.EditorWindow.innerHeight ;
67
				height = max;
41
		iInnerHeight = oInnerDoc.body.offsetHeight ;
68
		}
42
	}
69
 
-
 
70
		return height;
-
 
71
	},
-
 
72
 
Line 43... Line 73...
43
 
73
	GetHeightDelta : function()
44
	var iDiff = iInnerHeight - iFrameHeight ;
74
	{
45
 
-
 
46
	if ( iDiff != 0 )
75
		var oInnerDoc = FCK.EditorDocument ;
47
	{
76
 
48
		var iMainFrameSize = window.frameElement.offsetHeight ;
77
		var iFrameHeight ;
49
 
78
		var iInnerHeight ;
50
		if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
79
 
51
		{
80
		if ( FCKBrowserInfo.IsIE )
52
			iMainFrameSize += iDiff ;
81
		{
53
			if ( iMainFrameSize > FCKConfig.AutoGrowMax )
82
			iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
-
 
83
			iInnerHeight = oInnerDoc.body.scrollHeight ;
54
				iMainFrameSize = FCKConfig.AutoGrowMax ;
84
		}
55
		}
-
 
56
		else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
-
 
Line 57... Line 85...
57
		{
85
		else
-
 
86
		{
Line 58... Line -...
58
			iMainFrameSize += iDiff ;
-
 
59
			if ( iMainFrameSize < FCKAutoGrow_Min )
-
 
60
				iMainFrameSize = FCKAutoGrow_Min ;
-
 
61
		}
-
 
62
		else
87
			iFrameHeight = FCK.EditorWindow.innerHeight ;
63
			return ;
-
 
64
 
88
			iInnerHeight = oInnerDoc.body.offsetHeight +
-
 
89
				( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ), 10 ) || 0 ) +
65
		window.frameElement.height = iMainFrameSize ;
90
				( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ), 10 ) || 0 ) ;
Line 66... Line 91...
66
 
91
		}
-
 
92
 
-
 
93
		return iInnerHeight - iFrameHeight ;
-
 
94
	},
Line 67... Line -...
67
		// Gecko browsers use an onresize handler to update the innermost
-
 
68
		// IFRAME's height. If the document is modified before the onresize
-
 
69
		// is triggered, the plugin will miscalculate the new height. Thus,
-
 
70
		// forcibly trigger onresize. #1336
-
 
71
		if ( typeof window.onresize == 'function' )
-
 
72
			window.onresize() ;
95
 
73
	}
-
 
74
}
-
 
Line 75... Line 96...
75
 
96
	SetListeners : function()
76
FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
-
 
77
 
-
 
78
function FCKAutoGrow_SetListeners()
97
	{
79
{
-
 
80
	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
-
 
81
		return ;
-
 
82
 
-
 
83
	FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
-
 
84
	FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
-
 
85
}
-
 
Line 86... Line 98...
86
 
98
		if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )