Ticket #2696: 2696_2.patch
File 2696_2.patch, 5.2 KB (added by , 15 years ago) |
---|
-
_whatsnew.html
116 116 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2649">#2649</a>] Fixed a JavaScript error 117 117 in IE when user tries to search with the "Match whole word" option enabled and the matched word is 118 118 at exactly the end of document.</li> 119 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2696">#2696</a>] Fixed non-working 120 autogrow plugin.</li> 119 121 </ul> 120 122 <p> 121 123 <a href="_whatsnew_history.html">See previous versions history</a></p> -
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 var FCKAutoGrow = { 26 MIN_HEIGHT : window.frameElement.offsetHeight, 26 27 27 function FCKAutoGrow_Check() 28 { 29 var oInnerDoc = FCK.EditorDocument ; 28 Check : function() 29 { 30 var delta = FCKAutoGrow.GetHeightDelta() ; 31 if ( delta != 0 ) 32 { 33 var newHeight = window.frameElement.offsetHeight + delta ; 34 35 newHeight = FCKAutoGrow.GetEffectiveHeight( newHeight ) ; 36 37 if ( newHeight != window.frameElement.height ) 38 { 39 window.frameElement.style.height = newHeight + "px" ; 30 40 31 var iFrameHeight, iInnerHeight ; 41 // Gecko browsers use an onresize handler to update the innermost 42 // IFRAME's height. If the document is modified before the onresize 43 // is triggered, the plugin will miscalculate the new height. Thus, 44 // forcibly trigger onresize. #1336 45 if ( typeof window.onresize == 'function' ) 46 { 47 window.onresize() ; 48 } 49 } 50 } 51 }, 32 52 33 if ( FCKBrowserInfo.IsIE)53 CheckEditorStatus : function( sender, status ) 34 54 { 35 iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ; 36 iInnerHeight = oInnerDoc.body.scrollHeight ; 37 } 38 else 55 if ( status == FCK_STATUS_COMPLETE ) 56 FCKAutoGrow.Check() ; 57 }, 58 59 GetEffectiveHeight : function( height ) 39 60 { 40 iFrameHeight = FCK.EditorWindow.innerHeight ; 41 iInnerHeight = oInnerDoc.body.offsetHeight ; 42 } 61 if ( height < FCKAutoGrow.MIN_HEIGHT ) 62 height = FCKAutoGrow.MIN_HEIGHT; 63 else 64 { 65 var max = FCKConfig.AutoGrowMax; 66 if ( max && max > 0 && height > max ) 67 height = max; 68 } 69 70 return height; 71 }, 43 72 44 var iDiff = iInnerHeight - iFrameHeight ; 45 46 if ( iDiff != 0 ) 73 GetHeightDelta : function() 47 74 { 48 var iMainFrameSize = window.frameElement.offsetHeight ;75 var oInnerDoc = FCK.EditorDocument ; 49 76 50 if ( iDiff > 0 && iMainFrameSize < FCKConfig.AutoGrowMax ) 77 var iFrameHeight ; 78 var iInnerHeight ; 79 80 if ( FCKBrowserInfo.IsIE ) 51 81 { 52 iMainFrameSize += iDiff ; 53 if ( iMainFrameSize > FCKConfig.AutoGrowMax ) 54 iMainFrameSize = FCKConfig.AutoGrowMax ; 82 iFrameHeight = FCK.EditorWindow.frameElement.offsetHeight ; 83 iInnerHeight = oInnerDoc.body.scrollHeight ; 55 84 } 56 else if ( iDiff < 0 && iMainFrameSize > FCKAutoGrow_Min )85 else 57 86 { 58 iMainFrameSize += iDiff ; 59 if ( iMainFrameSize < FCKAutoGrow_Min ) 60 iMainFrameSize = FCKAutoGrow_Min ; 87 iFrameHeight = FCK.EditorWindow.innerHeight ; 88 iInnerHeight = oInnerDoc.body.offsetHeight + 89 ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-top' ) ) || 0 ) + 90 ( parseInt( FCKDomTools.GetCurrentElementStyle( oInnerDoc.body, 'margin-bottom' ) ) || 0 ) ; 61 91 } 62 else 92 93 return iInnerHeight - iFrameHeight ; 94 }, 95 96 SetListeners : function() 97 { 98 if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG ) 63 99 return ; 64 100 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() ; 101 FCK.EditorWindow.attachEvent( 'onscroll', FCKAutoGrow.Check ) ; 102 FCK.EditorDocument.attachEvent( 'onkeyup', FCKAutoGrow.Check ) ; 73 103 } 74 } 104 }; 75 105 76 FCK.AttachToOnSelectionChange( FCKAutoGrow _Check ) ;106 FCK.AttachToOnSelectionChange( FCKAutoGrow.Check ) ; 77 107 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 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 ) ;