[795] | 1 | /* |
---|
| 2 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net |
---|
| 3 | * Copyright (C) 2003-2007 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 | } |
---|
| 68 | |
---|
| 69 | FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ; |
---|
| 70 | |
---|
| 71 | function FCKAutoGrow_SetListeners() |
---|
| 72 | { |
---|
| 73 | if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) |
---|
| 74 | return ; |
---|
| 75 | |
---|
| 76 | FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow_Check ) ; |
---|
| 77 | FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow_Check ) ; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | if ( FCKBrowserInfo.IsIE ) |
---|
| 81 | { |
---|
| 82 | // FCKAutoGrow_SetListeners() ; |
---|
| 83 | FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | function FCKAutoGrow_CheckEditorStatus( sender, status ) |
---|
| 87 | { |
---|
| 88 | if ( status == FCK_STATUS_COMPLETE ) |
---|
| 89 | FCKAutoGrow_Check() ; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow_CheckEditorStatus ) ; |
---|