Subversion Repositories Applications.papyrus

Rev

Rev 1925 | Show entire file | Regard 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
{
-
 
29
	var oInnerDoc = FCK.EditorDocument ;
28
	Check : function()
30
 
-
 
31
	var iFrameHeight, iInnerHeight ;
29
	{
32
 
-
 
33
	if ( FCKBrowserInfo.IsIE )
-
 
34
	{
-
 
35
		iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
-
 
36
		iInnerHeight = oInnerDoc.body.scrollHeight ;
-
 
37
	}
30
		var delta = FCKAutoGrow.GetHeightDelta() ;
38
	else
-
 
39
	{
31
		if ( delta != 0 )
40
		iFrameHeight = FCK.EditorWindow.innerHeight ;
-
 
41
		iInnerHeight = oInnerDoc.body.offsetHeight ;
-
 
42
	}
-
 
Line 43... Line -...
43
 
-
 
44
	var iDiff = iInnerHeight - iFrameHeight ;
-
 
45
 
32
		{
Line 46... Line -...
46
	if ( iDiff != 0 )
-
 
47
	{
-
 
48
		var iMainFrameSize = window.frameElement.offsetHeight ;
-
 
49
 
33
			var newHeight = window.frameElement.offsetHeight + delta ;
50
		if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
-
 
51
		{
-
 
52
			iMainFrameSize += iDiff ;
-
 
53
			if ( iMainFrameSize > FCKConfig.AutoGrowMax )
34
 
54
				iMainFrameSize = FCKConfig.AutoGrowMax ;
-
 
55
		}
-
 
56
		else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
-
 
57
		{
-
 
58
			iMainFrameSize += iDiff ;
-
 
59
			if ( iMainFrameSize < FCKAutoGrow_Min )
-
 
60
				iMainFrameSize = FCKAutoGrow_Min ;
-
 
61
		}
35
			newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ;
Line 62... Line 36...
62
		else
36
 
63
			return ;
37
			if ( newHeight != window.frameElement.height )
64
 
38
			{
65
		window.frameElement.height = iMainFrameSize ;
39
				window.frameElement.style.height = newHeight + "px" ;
66
 
40
 
-
 
41
				// Gecko browsers use an onresize handler to update the innermost
67
		// Gecko browsers use an onresize handler to update the innermost
42
				// IFRAME's height. If the document is modified before the onresize
68
		// IFRAME's height. If the document is modified before the onresize
43
				// is triggered, the plugin will miscalculate the new height. Thus,
69
		// is triggered, the plugin will miscalculate the new height. Thus,
44
				// forcibly trigger onresize. #1336
-
 
45
				if ( typeof window.onresize == 'function' )
-
 
46
				{
Line 70... Line -...
70
		// forcibly trigger onresize. #1336
-
 
71
		if ( typeof window.onresize == 'function' )
-
 
72
			window.onresize() ;
47
					window.onresize() ;
73
	}
48
				}
74
}
49
			}
75
 
50
		}
-
 
51
	},
Line -... Line 52...
-
 
52
 
-
 
53
	CheckEditorStatus : function( sender, status )
76
FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
54
	{
77
 
55
		if ( status == FCK_STATUS_COMPLETE )
-
 
56
			FCKAutoGrow.Check() ;
-
 
57
	},
-
 
58
 
-
 
59
	GetEffectiveHeight : function( height )
-
 
60
	{
78
function FCKAutoGrow_SetListeners()
61
		if ( height < FCKAutoGrow.MIN_HEIGHT )
Line -... Line 62...
-
 
62
			height = FCKAutoGrow.MIN_HEIGHT;
-
 
63
		else
-
 
64
		{
-
 
65
			var max = FCKConfig.AutoGrowMax;
-
 
66
			if ( max && max > 0 && height > max )
-
 
67
				height = max;
-
 
68
		}
-
 
69
 
-
 
70
		return height;
-
 
71
	},
79
{
72
 
80
	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
73
	GetHeightDelta : function()
-
 
74
	{
-
 
75
		var oInnerDoc = FCK.EditorDocument ;
-
 
76
 
-
 
77
		var iFrameHeight ;
-
 
78
		var iInnerHeight ;
81
		return ;
79
 
-
 
80
		if ( FCKBrowserInfo.IsIE )
-
 
81
		{
82
 
82
			iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
83
	FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
83
			iInnerHeight = oInnerDoc.body.scrollHeight ;
Line 84... Line 84...
84
	FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
84
		}
-
 
85
		else
-
 
86
		{
-
 
87
			iFrameHeight = FCK.EditorWindow.innerHeight ;
85
}
88
			iInnerHeight = oInnerDoc.body.offsetHeight +
86
 
89
				( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ), 10 ) || 0 ) +
87
if ( FCKBrowserInfo.IsIE )
90
				( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ), 10 ) || 0 ) ;
-
 
91
		}
-
 
92
 
-
 
93
		return iInnerHeight - iFrameHeight ;
88
{
94
	},
-
 
95
 
-
 
96
	SetListeners : function()
-
 
97
	{
-
 
98
		if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
-
 
99
			return ;
-
 
100
 
Line 89... Line 101...
89
//	FCKAutoGrow_SetListeners() ;
101
		FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ;