Ticket #8050: 8050_7.patch
File 8050_7.patch, 3.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/autogrow/plugin.js
7 7 * @file AutoGrow plugin 8 8 */ 9 9 (function(){ 10 11 // Actual content height, figured out by appending check the last element's document position. 12 function contentHeight( doc ) 13 { 14 // Create a temporary marker element. 15 var marker = CKEDITOR.dom.element.createFromHtml( '<span style="margin:0;padding:0;border:0;clear:both;width:1px;height:1px;display:block;">' + ( CKEDITOR.env.webkit ? ' ' : '' ) + '</span>', doc ); 16 var body = doc.getBody(); 17 body.append( marker ); 18 19 var height = marker.getDocumentPosition( doc ).y + marker.$.offsetHeight; 20 marker.remove(); 21 return height; 22 } 23 10 24 var resizeEditor = function( editor ) 11 25 { 12 26 if ( !editor.window ) 13 27 return; 28 14 29 var doc = editor.document, 30 body = doc.getBody(), 31 htmlElement = doc.getDocumentElement(), 15 32 currentHeight = editor.window.getViewPaneSize().height, 16 newHeight; 33 newHeight = contentHeight( doc ), 34 // Quirks mode overflows body, standards overflows document element 35 scrollable = doc.$.compatMode == 'BackCompat' ? body : htmlElement; 17 36 18 // We can not use documentElement to calculate the height for IE (#6061). 19 // It is not good for IE Quirks, yet using offsetHeight would also not work as expected (#6408). 20 // We do the same for FF because of the html height workaround (#6341). 21 if ( CKEDITOR.env.ie || CKEDITOR.env.gecko ) 22 newHeight = doc.getBody().$.scrollHeight + ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 0 : 24 ); 23 else 24 newHeight = doc.getDocumentElement().$.offsetHeight; 37 // Minor adjustment for each browser, or specified by user. 38 newHeight += ( editor.config.autoGrow_bottomSpace !== undefined || ( CKEDITOR.env.ie9Compat ? 0 : CKEDITOR.env.ie || CKEDITOR.env.opera ? -20 : 20 ) ); 25 39 26 var min = editor.config.autoGrow_minHeight, 27 max = editor.config.autoGrow_maxHeight; 28 ( min == undefined ) && ( editor.config.autoGrow_minHeight = min = 200 ); 29 if ( min ) 30 newHeight = Math.max( newHeight, min ); 31 if ( max ) 32 newHeight = Math.min( newHeight, max ); 40 var min = editor.config.autoGrow_minHeight || 200, 41 max = editor.config.autoGrow_maxHeight || Infinity; 42 43 newHeight = Math.max( newHeight, min ); 44 newHeight = Math.min( newHeight, max ); 33 45 34 46 if ( newHeight != currentHeight ) 35 47 { 36 48 newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight; 37 49 editor.resize( editor.container.getStyle( 'width' ), newHeight, true ); 50 51 if ( newHeight < max ) 52 scrollable.setStyle( 'overflow-y', 'hidden' ); 53 else 54 scrollable.removeStyle( 'overflow-y' ); 38 55 } 39 56 }; 40 57 CKEDITOR.plugins.add( 'autogrow', … … 86 103 * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed 87 104 * to determine another height to be used instead. 88 105 */ 106 107 108 /** 109 * Extra height in pixel to leave between the bottom boundary of content with document size when auto resizing. 110 * @name CKEDITOR.config.autoGrow_bottomSpace 111 * @type Number 112 * @default 20px 113 * @since 3.6.2 114 */