diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js index 6136e6ba80..e718716355 100644 --- a/src/wp-admin/js/editor.js +++ b/src/wp-admin/js/editor.js @@ -13,7 +13,7 @@ window.switchEditors = { // mode can be 'html', 'tmce', or 'toggle'; 'html' is used for the 'Text' editor tab. go: function( id, mode ) { - var t = this, ed, wrap_id, txtarea_el, editorHeight, toolbarHeight, + var t = this, ed, wrap_id, txtarea_el, iframe, editorHeight, toolbarHeight, DOM = tinymce.DOM; //DOMUtils outside the editor iframe id = id || 'content'; @@ -32,17 +32,14 @@ window.switchEditors = { } function getToolbarHeight() { - var height; + var node = DOM.select( '.mce-toolbar-grp', ed.getContainer() )[0], + height = node && node.clientHeight; - try { - height = DOM.getSize( DOM.select( '.mce-toolbar-grp', ed.getContainer() )[0] ); - } catch(e){} - - if ( height && height.h && height.h > 10 && height.h < 100 ) { - return height.h; + if ( height && height > 10 && height < 200 ) { + return parseInt( height, 10 ); } - return 0; + return 30; } if ( 'tmce' === mode || 'tinymce' === mode ) { @@ -63,8 +60,9 @@ window.switchEditors = { if ( ed ) { ed.show(); - if ( editorHeight && ( toolbarHeight = getToolbarHeight() ) ) { - editorHeight = editorHeight - toolbarHeight + 11; + if ( editorHeight ) { + toolbarHeight = getToolbarHeight(); + editorHeight = editorHeight - toolbarHeight + 14; // height cannot be under 50 or over 5000 if ( editorHeight > 50 && editorHeight < 5000 ) { @@ -73,9 +71,6 @@ window.switchEditors = { } } else { tinymce.init( tinyMCEPreInit.mceInit[id] ); - - // ed = tinymce.createEditor( id, tinyMCEPreInit.mceInit[id] ); - // ed.render(); } DOM.removeClass( wrap_id, 'html-active' ); @@ -89,11 +84,12 @@ window.switchEditors = { } if ( ed ) { - editorHeight = DOM.get( id + '_ifr' ); - editorHeight = editorHeight ? parseInt( editorHeight.style.height, 10 ) : 0; + iframe = DOM.get( id + '_ifr' ); + editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0; - if ( editorHeight && ( toolbarHeight = getToolbarHeight() ) ) { - editorHeight = editorHeight + toolbarHeight - 11; + if ( editorHeight ) { + toolbarHeight = getToolbarHeight(); + editorHeight = editorHeight + toolbarHeight - 14; // height cannot be under 50 or over 5000 if ( editorHeight > 50 && editorHeight < 5000 ) { diff --git a/src/wp-admin/js/post.js b/src/wp-admin/js/post.js index 0811471ddf..0e3e824957 100644 --- a/src/wp-admin/js/post.js +++ b/src/wp-admin/js/post.js @@ -1014,13 +1014,18 @@ jQuery(document).ready( function($) { if ( mce ) { editor.focus(); toolbarHeight = $( '#wp-content-editor-container .mce-toolbar-grp' ).height(); + + if ( toolbarHeight < 10 || toolbarHeight > 200 ) { + toolbarHeight = 30; + } + height = parseInt( $('#content_ifr').css('height'), 10 ) + toolbarHeight - 28; } else { $textarea.focus(); height = parseInt( $textarea.css('height'), 10 ); } - $document.off( 'mousemove.wp-editor-resize mouseup.wp-editor-resize' ); + $document.off( '.wp-editor-resize' ); // sanity check if ( height && height > 50 && height < 5000 ) { @@ -1045,10 +1050,10 @@ jQuery(document).ready( function($) { } $document.on( 'mousemove.wp-editor-resize', dragging ) - .on( 'mouseup.wp-editor-resize', endDrag ); + .on( 'mouseup.wp-editor-resize mouseleave.wp-editor-resize', endDrag ); event.preventDefault(); - }); + }).on( 'mouseup.wp-editor-resize', endDrag ); })(); if ( typeof tinymce !== 'undefined' ) {