Main editor: maintain the height when switching Visual to Text and back, save the height when resizing as user state, output the height in the textarea tag when loading, (thanks @nacin for the help), fixes #21718

git-svn-id: https://develop.svn.wordpress.org/trunk@22007 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2012-09-26 03:30:21 +00:00
parent ff88489bdc
commit 5ad7fe8cd6
7 changed files with 169 additions and 27 deletions
+25 -3
View File
@@ -3107,7 +3107,7 @@ td.plugin-title p {
background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
width: 12px;
cursor: se-resize;
margin: 0 2px;
margin: 0 1px;
position: relative;
top: -2px;
}
@@ -3116,6 +3116,23 @@ td.plugin-title p {
top: 20px;
}
#content-resize-handle {
background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
width: 12px;
cursor: se-resize;
position: absolute;
right: 2px;
height: 19px;
}
.press-this #content-resize-handle {
bottom: 2px;
}
.tmce-active #content-resize-handle {
display: none;
}
#wp-word-count {
display: block;
padding: 2px 10px;
@@ -4309,6 +4326,10 @@ span.imgedit-scale-warn {
box-shadow: none;
}
.comment-php .wp-editor-area {
height: 200px;
}
.comment-ays {
margin-bottom: 0;
border-style: solid;
@@ -7320,6 +7341,7 @@ img {
/* Editor/Main Column */
.press-this #poststuff {
margin: 0 10px 10px;
padding: 0;
}
#poststuff #editor-toolbar {
@@ -7415,7 +7437,7 @@ h3.tb {
}
.press-this #extra-fields .actions {
margin: -25px -7px 0 0;
margin: -32px -7px 0 0;
}
.press-this .actions li {
@@ -7515,7 +7537,7 @@ h3.tb {
margin: 5px 0;
padding: 0 5px;
border: 0 none;
height: 357px;
height: 345px;
font-family: Consolas, Monaco, monospace;
font-size: 13px;
line-height: 19px;
+1 -1
View File
@@ -347,7 +347,7 @@ if ( post_type_supports($post_type, 'editor') ) {
?>
<div id="postdivrich" class="postarea">
<?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview') ); ?>
<?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview', 'editor_height' => 360) ); ?>
<table id="post-status-info" cellspacing="0"><tbody><tr>
<td id="wp-word-count"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
+1 -3
View File
@@ -49,10 +49,8 @@ var switchEditors = {
if ( ed && ed.isHidden() )
return false;
if ( ed ) {
txtarea_el.style.height = ed.getContentAreaContainer().offsetHeight + 20 + 'px';
if ( ed )
ed.hide();
}
dom.removeClass(wrap_id, 'tmce-active');
dom.addClass(wrap_id, 'html-active');
+79
View File
@@ -667,4 +667,83 @@ jQuery(document).ready( function($) {
}
wptitlehint();
// resizable textarea#content
(function() {
var textarea = $('textarea#content'), offset = null, el;
function dragging(e) {
textarea.height( Math.max(50, offset + e.pageY) + 'px' );
return false;
}
function endDrag(e) {
var height = $('#wp-content-editor-container').height();
textarea.focus();
$(document).unbind('mousemove', dragging).unbind('mouseup', endDrag);
if ( height > 83 ) {
height -= 33; // compensate for toolbars, padding...
setUserSetting( 'ed_size', height );
}
}
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;
});
})();
tinymce.onAddEditor.add(function(mce, ed){
if ( ed.id != 'content' )
return;
// 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 ),
tb_height = $('#content_tbl tr.mceFirst').height();
if ( height && !isNaN(height) && tb_height ) {
ifr_height = (height - tb_height) + 12; // compensate for padding in the textarea
$('#content_tbl').css('height', '' );
$('#content_ifr').css('height', ifr_height + 'px' );
setUserSetting( 'ed_size', height );
}
});
// resize the textarea to match TinyMCE's height when switching Visual -> Text
ed.onSaveContent.add( function(ed, o) {
var height = $('#content_tbl').height();
if ( height && height > 83 ) {
height -= 33;
$('#content').css( 'height', height + 'px' );
setUserSetting( 'ed_size', height );
}
});
// 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();
height -= 33;
if ( height > 50 && height != getUserSetting( 'ed_size' ) )
setUserSetting( 'ed_size', height );
$(document).off('mouseup.wp-mce-resize');
});
});
});
});
});
+1 -1
View File
@@ -288,7 +288,7 @@ if ( !empty($_REQUEST['ajax']) ) {
return false;
}
jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( 'Add Photos' ); ?> <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( 'Add Photos' ); ?> <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="button button-small"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
jQuery('#img_container').html(strtoappend);
<?php break;
}