Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1921
1
/*
1
/*
2
 * FCKeditor - The text editor for internet
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
3
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
-
 
4
 *
-
 
5
 * == BEGIN LICENSE ==
4
 * 
6
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
7
 * Licensed under the terms of any of the following licenses at your
-
 
8
 * choice:
-
 
9
 *
-
 
10
 *  - GNU General Public License Version 2 or later (the "GPL")
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
11
 *    http://www.gnu.org/licenses/gpl.html
7
 * 
12
 *
8
 * For further information visit:
13
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
9
 * 		http://www.fckeditor.net/
14
 *    http://www.gnu.org/licenses/lgpl.html
10
 * 
15
 *
11
 * "Support Open Source software. What about a donation today?"
16
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
-
 
17
 *    http://www.mozilla.org/MPL/MPL-1.1.html
12
 * 
18
 *
13
 * File Name: fckplugin.js
19
 * == END LICENSE ==
-
 
20
 *
14
 * 	Plugin: automatically resizes the editor until a configurable maximun 
21
 * Plugin: automatically resizes the editor until a configurable maximun
15
 * 	height (FCKConfig.AutoGrowMax), based on its contents.
22
 * height (FCKConfig.AutoGrowMax), based on its contents.
16
 * 
-
 
17
 * File Authors:
-
 
18
 * 		Frederico Caldeira Knabben (fredck@fckeditor.net)
-
 
19
 */
23
 */
20
 
24
 
21
var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
25
var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
22
 
26
 
23
function FCKAutoGrow_Check()
27
function FCKAutoGrow_Check()
24
{
28
{
25
	var oInnerDoc = FCK.EditorDocument ;
29
	var oInnerDoc = FCK.EditorDocument ;
26
 
30
 
27
	var iFrameHeight, iInnerHeight ;
31
	var iFrameHeight, iInnerHeight ;
28
	
32
 
29
	if ( FCKBrowserInfo.IsIE )
33
	if ( FCKBrowserInfo.IsIE )
30
	{
34
	{
31
		iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
35
		iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
32
		iInnerHeight = oInnerDoc.body.scrollHeight ;
36
		iInnerHeight = oInnerDoc.body.scrollHeight ;
33
	}
37
	}
34
	else
38
	else
35
	{
39
	{
36
		iFrameHeight = FCK.EditorWindow.innerHeight ;
40
		iFrameHeight = FCK.EditorWindow.innerHeight ;
37
		iInnerHeight = oInnerDoc.body.offsetHeight ;
41
		iInnerHeight = oInnerDoc.body.offsetHeight ;
38
	}
42
	}
39
 
43
 
40
	var iDiff = iInnerHeight - iFrameHeight ;
44
	var iDiff = iInnerHeight - iFrameHeight ;
41
 
45
 
42
	if ( iDiff != 0 )
46
	if ( iDiff != 0 )
43
	{
47
	{
44
		var iMainFrameSize = window.frameElement.offsetHeight ;
48
		var iMainFrameSize = window.frameElement.offsetHeight ;
45
		
49
 
46
		if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
50
		if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
47
		{
51
		{
48
			iMainFrameSize += iDiff ;
52
			iMainFrameSize += iDiff ;
49
			if ( iMainFrameSize > FCKConfig.AutoGrowMax )
53
			if ( iMainFrameSize > FCKConfig.AutoGrowMax )
50
				iMainFrameSize = FCKConfig.AutoGrowMax ;
54
				iMainFrameSize = FCKConfig.AutoGrowMax ;
51
		}
55
		}
52
		else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
56
		else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )
53
		{
57
		{
54
			iMainFrameSize += iDiff ;
58
			iMainFrameSize += iDiff ;
55
			if ( iMainFrameSize < FCKAutoGrow_Min )
59
			if ( iMainFrameSize < FCKAutoGrow_Min )
56
				iMainFrameSize = FCKAutoGrow_Min ;
60
				iMainFrameSize = FCKAutoGrow_Min ;
57
		}
61
		}
58
		else
62
		else
59
			return ;
63
			return ;
60
			
64
 
61
		window.frameElement.height = iMainFrameSize ;
65
		window.frameElement.height = iMainFrameSize ;
-
 
66
 
-
 
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() ;
62
	}
73
	}
63
}
74
}
64
 
75
 
65
FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
76
FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
66
 
77
 
67
function FCKAutoGrow_SetListeners()
78
function FCKAutoGrow_SetListeners()
68
{
79
{
-
 
80
	if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG )
-
 
81
		return ;
-
 
82
 
69
	FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
83
	FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ;
70
	FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
84
	FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ;
71
}
85
}
72
 
86
 
73
if ( FCKBrowserInfo.IsIE )
87
if ( FCKBrowserInfo.IsIE )
74
{
88
{
75
//	FCKAutoGrow_SetListeners() ;
89
//	FCKAutoGrow_SetListeners() ;
76
	FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
90
	FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
77
}
91
}
78
 
92
 
79
function FCKAutoGrow_CheckEditorStatus( sender, status )
93
function FCKAutoGrow_CheckEditorStatus( sender, status )
80
{
94
{
81
	if ( status == FCK_STATUS_COMPLETE )
95
	if ( status == FCK_STATUS_COMPLETE )
82
		FCKAutoGrow_Check() ;
96
		FCKAutoGrow_Check() ;
83
}
97
}
84
 
-
 
85
FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;
98
 
-
 
99
FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;