| 9 | | (function(){ |
| 10 | | var resizeEditor = function( editor ) |
| 11 | | { |
| 12 | | if ( !editor.window ) |
| 13 | | return; |
| 14 | | var doc = editor.document, |
| 15 | | currentHeight = editor.window.getViewPaneSize().height, |
| 16 | | newHeight; |
| | 9 | (function() |
| | 10 | { |
| | 11 | CKEDITOR.plugins.add( 'autogrow', |
| | 12 | { |
| | 13 | init : function( editor ) |
| | 14 | { |
| | 15 | function resizeEditor() |
| | 16 | { |
| | 17 | if ( !editor.window ) |
| | 18 | return; |
| | 19 | |
| | 20 | var doc = editor.document, |
| | 21 | iframe = new CKEDITOR.dom.element( doc.getWindow().$.frameElement ), |
| | 22 | resizeable = editor.getResizable( 1 ), |
| | 23 | body = doc.getBody(), |
| | 24 | htmlElement = doc.getDocumentElement(), |
| | 25 | currentHeight = resizeable.$.offsetHeight, |
| | 26 | newHeight; |
| 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; |
| | 28 | // Quirks mode overflows body except for IE9, standards overflows document element. |
| | 29 | var scrollable = !CKEDITOR.env.ie9Compat && doc.$.compatMode == 'BackCompat' ? body : htmlElement; |
| 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 ); |
| | 31 | // Content height |
| | 32 | iframe.setStyle( 'height', '1px' ); |
| | 33 | newHeight = scrollable.$.scrollHeight; |
| | 34 | |
| | 35 | // Count for the height of h-scrollbar. |
| | 36 | iframe.setStyle( 'height', newHeight + 'px' ); |
| | 37 | newHeight += scrollable.$.scrollWidth > scrollable.$.clientWidth ? scrollable.$.scrollHeight - scrollable.$.clientHeight : 0; |
| | 38 | |
| | 39 | // Now restore iframe height. |
| | 40 | iframe.setStyle( 'height', '100%' ); |
| | 41 | |
| | 42 | var min = editor.config.autoGrow_minHeight || 0, |
| | 43 | max = editor.config.autoGrow_maxHeight || Infinity; |
| | 44 | |
| | 45 | newHeight = Math.max( newHeight, min ); |
| | 46 | newHeight = Math.min( newHeight, max ); |
| 34 | | if ( newHeight != currentHeight ) |
| 35 | | { |
| 36 | | newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight; |
| 37 | | editor.resize( editor.container.getStyle( 'width' ), newHeight, true ); |
| 38 | | } |
| 39 | | }; |
| 40 | | CKEDITOR.plugins.add( 'autogrow', |
| 41 | | { |
| 42 | | init : function( editor ) |
| 43 | | { |
| | 48 | if ( newHeight != currentHeight ) |
| | 49 | { |
| | 50 | newHeight = editor.fire( 'autoGrow', { currentHeight : currentHeight, newHeight : newHeight } ).newHeight; |
| | 51 | resizeable.setStyle( 'height', newHeight + 'px' ); |
| | 52 | editor.fire( 'resize' ); |
| | 53 | |
| | 54 | // Make sure v-scrollbar isn't invisible after all. |
| | 55 | newHeight < max ? |
| | 56 | scrollable.setStyle( 'overflow-y', 'hidden' ) |
| | 57 | : scrollable.removeStyle( 'overflow-y' ); |
| | 58 | } |
| | 59 | } |
| | 60 | |