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