- var settings = editor.settings,
- oldSize = 0;
-
- function resize( e ) {
- var deltaSize, myHeight,
- d = editor.getDoc(),
- body = d.body,
- DOM = tinymce.DOM,
- resizeHeight = 250;
-
- if ( ( e && e.type === 'setcontent' && e.initial ) || editor.settings.inline ) {
- return;
- }
-
- // Get height differently depending on the browser used
- myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight );
-
- // Don't make it smaller than 250px
- if ( myHeight > 250 ) {
- resizeHeight = myHeight;
- }
-
- body.scrollTop = 0;
-
- // Resize content element
- if ( resizeHeight !== oldSize ) {
- deltaSize = resizeHeight - oldSize;
- DOM.setStyle( DOM.get( editor.id + '_ifr' ), 'height', resizeHeight + 'px' );
- oldSize = resizeHeight;
-
- // WebKit doesn't decrease the size of the body element until the iframe gets resized
- // So we need to continue to resize the iframe down until the size gets fixed
- if ( tinymce.isWebKit && deltaSize < 0 ) {
- resize( e );
- }
- }
- }
-
- // Register the command
- editor.addCommand( 'wpAutoResize', resize );