Ticket #8050: 8050_8.patch
File 8050_8.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, plus additional space specified by user. 38 newHeight += ( CKEDITOR.env.ie9Compat ? 0 : CKEDITOR.env.ie || CKEDITOR.env.opera ? -20 : 20 ) + 39 ( editor.config.autoGrow_bottomSpace || 0 ); 25 40 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 ); 41 var min = editor.config.autoGrow_minHeight || 200, 42 max = editor.config.autoGrow_maxHeight || Infinity; 43 44 newHeight = Math.max( newHeight, min ); 45 newHeight = Math.min( newHeight, max ); 33 46 34 47 if ( newHeight != currentHeight ) 35 48 { 36 49 newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight; 37 50 editor.resize( editor.container.getStyle( 'width' ), newHeight, true ); 51 52 if ( newHeight < max ) 53 scrollable.setStyle( 'overflow-y', 'hidden' ); 54 else 55 scrollable.removeStyle( 'overflow-y' ); 38 56 } 39 57 }; 40 58 CKEDITOR.plugins.add( 'autogrow', … … 86 104 * @param {Number} data.newHeight The new height of the editor (after the resizing). It can be changed 87 105 * to determine another height to be used instead. 88 106 */ 107 108 109 /** 110 * Extra height in pixel to leave between the bottom boundary of content with document size when auto resizing. 111 * @name CKEDITOR.config.autoGrow_bottomSpace 112 * @type Number 113 * @default 0 114 * @since 3.6.2 115 */