Ticket #2696: 2696.patch
File 2696.patch, 4.3 KB (added by , 15 years ago) |
---|
-
editor/plugins/autogrow/fckplugin.js
22 22 * height (FCKConfig.AutoGrowMax), based on its contents. 23 23 */ 24 24 25 var FCKAutoGrow_Min = window.frameElement.offsetHeight;25 FCKAutoGrow = new Object(); 26 26 27 function FCKAutoGrow_Check() 27 FCKAutoGrow.MIN_HEIGHT = window.frameElement.offsetHeight ; 28 29 FCKAutoGrow.Check = function() 28 30 { 31 var delta = FCKAutoGrow.GetHeightDelta() ; 32 if ( delta != 0 ) 33 { 34 var newHeight = window.frameElement.offsetHeight + delta ; 35 36 newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ; 37 38 if ( newHeight != window.frameElement.height ) 39 { 40 window.frameElement.style.height = newHeight + "px" ; 41 42 // Gecko browsers use an onresize handler to update the innermost 43 // IFRAME's height. If the document is modified before the onresize 44 // is triggered, the plugin will miscalculate the new height. Thus, 45 // forcibly trigger onresize. #1336 46 if ( typeof window.onresize == 'function' ) 47 { 48 window.onresize() ; 49 } 50 } 51 } 52 } 53 54 FCKAutoGrow.CheckEditorStatus = function( sender, status ) 55 { 56 if ( status == FCK_STATUS_COMPLETE ) 57 FCKAutoGrow.Check() ; 58 } 59 60 FCKAutoGrow.GetEffectiveHeight = function( height ) 61 { 62 if ( height < FCKAutoGrow.MIN_HEIGHT ) 63 height = FCKAutoGrow.MIN_HEIGHT; 64 else 65 { 66 var max = FCKConfig.AutoGrowMax; 67 if ( max && max > 0 && height > max ) 68 height = max; 69 } 70 71 return height; 72 } 73 74 FCKAutoGrow.GetHeightDelta = function() 75 { 29 76 var oInnerDoc = FCK.EditorDocument ; 30 77 31 var iFrameHeight, iInnerHeight ; 78 var iFrameHeight ; 79 var iInnerHeight ; 32 80 33 81 if ( FCKBrowserInfo.IsIE ) 34 82 { … … 38 86 else 39 87 { 40 88 iFrameHeight = FCK.EditorWindow.innerHeight ; 41 iInnerHeight = oInnerDoc.body.offsetHeight ; 89 iInnerHeight = oInnerDoc.body.offsetHeight + 90 ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ) ) || 0 ) + 91 ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ) ) || 0 ) ; 42 92 } 43 93 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 } 94 return iInnerHeight - iFrameHeight ; 74 95 } 75 96 76 FCK.AttachToOnSelectionChange( FCKAutoGrow_Check ) ; 77 78 function FCKAutoGrow_SetListeners() 97 FCKAutoGrow.SetListeners = function() 79 98 { 80 99 if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 81 100 return ; 82 101 83 FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow _Check ) ;84 FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow _Check ) ;102 FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ; 103 FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ; 85 104 } 86 105 106 FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ; 107 87 108 if ( FCKBrowserInfo.IsIE ) 88 { 89 // FCKAutoGrow_SetListeners() ; 90 FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow_SetListeners ) ; 91 } 109 FCK.Events.AttachEvent( 'OnAfterSetHTML', FCKAutoGrow.SetListeners ) ; 92 110 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 ) ; 111 FCK.Events.AttachEvent( 'OnStatusChange', FCKAutoGrow.CheckEditorStatus ) ;