1925 |
jp_milcent |
1 |
/*
|
|
|
2 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
|
|
3 |
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
|
|
|
4 |
*
|
|
|
5 |
* == BEGIN LICENSE ==
|
|
|
6 |
*
|
|
|
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")
|
|
|
11 |
* http://www.gnu.org/licenses/gpl.html
|
|
|
12 |
*
|
|
|
13 |
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
|
|
14 |
* http://www.gnu.org/licenses/lgpl.html
|
|
|
15 |
*
|
|
|
16 |
* - Mozilla Public License Version 1.1 or later (the "MPL")
|
|
|
17 |
* http://www.mozilla.org/MPL/MPL-1.1.html
|
|
|
18 |
*
|
|
|
19 |
* == END LICENSE ==
|
|
|
20 |
*
|
|
|
21 |
* Plugin: automatically resizes the editor until a configurable maximun
|
|
|
22 |
* height (FCKConfig.AutoGrowMax), based on its contents.
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
var FCKAutoGrow_Min = window.frameElement.offsetHeight ;
|
|
|
26 |
|
|
|
27 |
function FCKAutoGrow_Check()
|
|
|
28 |
{
|
|
|
29 |
var oInnerDoc = FCK.EditorDocument ;
|
|
|
30 |
|
|
|
31 |
var iFrameHeight, iInnerHeight ;
|
|
|
32 |
|
|
|
33 |
if ( FCKBrowserInfo.IsIE )
|
|
|
34 |
{
|
|
|
35 |
iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ;
|
|
|
36 |
iInnerHeight = oInnerDoc.body.scrollHeight ;
|
|
|
37 |
}
|
|
|
38 |
else
|
|
|
39 |
{
|
|
|
40 |
iFrameHeight = FCK.EditorWindow.innerHeight ;
|
|
|
41 |
iInnerHeight = oInnerDoc.body.offsetHeight ;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
var iDiff = iInnerHeight - iFrameHeight ;
|
|
|
45 |
|
|
|
46 |
if ( iDiff != 0 )
|
|
|
47 |
{
|
|
|
48 |
var iMainFrameSize = window.frameElement.offsetHeight ;
|
|
|
49 |
|
|
|
50 |
if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax )
|
|
|
51 |
{
|
|
|
52 |
iMainFrameSize += iDiff ;
|
|
|
53 |
if ( iMainFrameSize > FCKConfig.AutoGrowMax )
|
|
|
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 |
}
|
|
|
62 |
else
|
|
|
63 |
return ;
|
|
|
64 |
|
|
|
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() ;
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ;
|
|
|
77 |
|
|
|
78 |
function FCKAutoGrow_SetListeners()
|
|
|
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 |
}
|
|
|
86 |
|
|
|
87 |
if ( FCKBrowserInfo.IsIE )
|
|
|
88 |
{
|
|
|
89 |
// FCKAutoGrow_SetListeners() ;
|
|
|
90 |
FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
function FCKAutoGrow_CheckEditorStatus( sender, status )
|
|
|
94 |
{
|
|
|
95 |
if ( status == FCK_STATUS_COMPLETE )
|
|
|
96 |
FCKAutoGrow_Check() ;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ;
|