Index: wp-admin/js/post.js
===================================================================
--- wp-admin/js/post.js	(revision 23287)
+++ wp-admin/js/post.js	(working copy)
@@ -685,80 +685,103 @@
 
 	// resizable textarea#content
 	(function() {
-		var textarea = $('textarea#content'), offset = null, el;
+		var textarea = $('textarea#content'), handle;
 		// No point for touch devices
-		if ( 'ontouchstart' in window )
+		if ( !textarea.length || 'ontouchstart' in window )
 			return;
 
-		function dragging(e) {
-			textarea.height( Math.max(50, offset + e.pageY) + 'px' );
-			return false;
-		}
+		textarea.css('resize', 'none');
+		handle = $('<div id="content-resize-handle"><br></div>');
+		$('#wp-content-wrap').append(handle);
 
-		function endDrag(e) {
-			var height = $('#wp-content-editor-container').height();
+		handle.on('mousedown', function(e) {
+			var height, offset = textarea.height() - e.pageY;
 
-			textarea.focus();
-			$(document).unbind('mousemove', dragging).unbind('mouseup', endDrag);
+			textarea.blur();
 
-			height -= 33; // compensate for toolbars, padding...
-			// sanity check
-			if ( height > 50 && height < 5000 && height != getUserSetting( 'ed_size' ) )
-				setUserSetting( 'ed_size', height );
-		}
+			$(document).on( 'mousemove.wp-editor-resize', function(e) {
+				height = Math.max(50, offset + e.pageY)
+				textarea.height( height );
+				e.preventDefault();
+			}).on( 'mouseup.wp-editor-resize', function(e) {
+				textarea.focus();
+				$(document).off( '.wp-editor-resize' );
 
-		textarea.css('resize', 'none');
-		el = $('<div id="content-resize-handle"><br></div>');
-		$('#wp-content-wrap').append(el);
-		el.on('mousedown', function(e) {
-			offset = textarea.height() - e.pageY;
-			textarea.blur();
-			$(document).mousemove(dragging).mouseup(endDrag);
-			return false;
+				// compensate for textarea padding, 'height' has been set while dragging
+				height += 20;
+
+				// sanity check
+				if ( height > 50 && height < 5000 )
+					setUserSetting( 'ed_size', height );
+			});
+			e.preventDefault(); // stop the browser selecting/highlighting elements
 		});
 	})();
 
 	if ( typeof(tinymce) != 'undefined' ) {
 		tinymce.onAddEditor.add(function(mce, ed){
+			var get_textarea_height;
+
 			// iOS expands the iframe to full height and the user cannot adjust it.
 			if ( ed.id != 'content' || tinymce.isIOS5 )
 				return;
 
+			get_textarea_height = function() {
+				var height, ifr_height = $('#content_ifr').height(),
+					tb_height = $('#content_tbl tr.mceFirst').height();
+
+				if ( !ifr_height || !tb_height )
+					return false;
+
+				// total height including toolbar and statusbar
+				height = ifr_height + tb_height + 21;
+				// textarea height = total height - 33px Quicktags toolbar
+				height -= 33;
+
+				return height;
+			}
+
 			// resize TinyMCE to match the textarea height when switching Text -> Visual
 			ed.onLoadContent.add( function(ed, o) {
-				var ifr_height, height = parseInt( $('#content').css('height'), 10 ),
+				var ifr_height, node = document.getElementById('content'),
+					height = node ? parseInt( node.style.height, 10 ) : 360,
 					tb_height = $('#content_tbl tr.mceFirst').height();
 
-				if ( height && !isNaN(height) && tb_height ) {
+				if ( isNaN(height) || height < 50 || height > 5000 ) {
+					height = 360; // default height for the main editor
+					setUserSetting('ed_size', height);
+				}
+
+				if ( tb_height )
 					ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea
-					// sanity check
-					if ( ifr_height > 50 && ifr_height < 5000 ) {
-						$('#content_tbl').css('height', '' );
-						$('#content_ifr').css('height', ifr_height + 'px' );
-					}
+				else
+					ifr_height = 340;
+
+				// sanity check
+				if ( ifr_height > 50 && ifr_height < 5000 ) {
+					$('#content_tbl').css('height', '' );
+					$('#content_ifr').css('height', ifr_height + 'px' );
 				}
 			});
 
 			// resize the textarea to match TinyMCE's height when switching Visual -> Text
 			ed.onSaveContent.add( function(ed, o) {
-				var height = $('#content_tbl').height();
+				var height = get_textarea_height();
 
-				if ( height && height > 83 && height < 5000 ) {
-					height -= 33;
+				if ( !height || height < 50 || height > 5000 )
+					height = 360;
 
-					$('#content').css( 'height', height + 'px' );
-				}
+				$('textarea#content').css( 'height', height + 'px' );
 			});
 
 			// save on resizing TinyMCE
 			ed.onPostRender.add(function() {
 				$('#content_resize').on('mousedown.wp-mce-resize', function(e){
 					$(document).on('mouseup.wp-mce-resize', function(e){
-						var height = $('#wp-content-editor-container').height();
+						var height = get_textarea_height();
 
-						height -= 33;
 						// sanity check
-						if ( height > 50 && height < 5000 && height != getUserSetting( 'ed_size' ) )
+						if ( height && height > 50 && height < 5000 )
 							setUserSetting( 'ed_size', height );
 
 						$(document).off('mouseup.wp-mce-resize');
