Add new comment from post edit screen, partial props: garyc40, see #15527

git-svn-id: http://svn.automattic.com/wordpress/trunk@20164 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2012-03-09 01:30:11 +00:00
parent 69447d2e89
commit 52f321913a
8 changed files with 120 additions and 91 deletions

View File

@ -287,8 +287,9 @@ div.error a {
border-color: #c00 !important; border-color: #c00 !important;
} }
.submit { .submit,
border-color: #DFDFDF; #commentsdiv #add-new-comment {
border-color: #dfdfdf;
} }
.highlight { .highlight {

View File

@ -295,8 +295,9 @@ div.error a {
border-color: #c00 !important; border-color: #c00 !important;
} }
.submit { .submit,
border-color: #DFDFDF; #commentsdiv #add-new-comment {
border-color: #dfdfdf;
} }
.highlight { .highlight {
@ -1533,11 +1534,7 @@ body.press-this ul.category-tabs li.tabs a {
} }
div.widgets-sortables, div.widgets-sortables,
#widgets-left .inactive { #widgets-left .inactive,
background-color: #fcfcfc;
border-color: #dfdfdf;
}
#available-widgets .widget-holder { #available-widgets .widget-holder {
background-color: #fcfcfc; background-color: #fcfcfc;
border-color: #dfdfdf; border-color: #dfdfdf;
@ -1664,10 +1661,7 @@ div.widgets-sortables,
color: #fff; color: #fff;
} }
.list-container { .list-container,
border-color: #DFDFDF;
}
.menu-item-handle { .menu-item-handle {
border-color: #dfdfdf; border-color: #dfdfdf;
} }

View File

@ -2400,7 +2400,6 @@ table.fixed {
width: 80px; width: 80px;
} }
#commentsdiv .fixed .column-author,
#comments-form .fixed .column-author { #comments-form .fixed .column-author {
width: 20%; width: 20%;
} }
@ -2410,28 +2409,49 @@ table.fixed {
padding: 0; padding: 0;
} }
#commentsdiv.postbox .inside .row-actions { #commentsdiv .inside .row-actions {
line-height:18px; line-height:18px;
} }
#commentsdiv.postbox .inside td { #commentsdiv .inside .column-author {
padding:1em 10px; width: 25%;
} }
#commentsdiv.postbox .inside .column-author { #commentsdiv .column-comment p {
width:33%; margin: 0.6em 0;
padding: 0;
} }
#commentsdiv.postbox .inside p { #commentsdiv #replyrow td {
margin:6px 10px 8px; padding: 0;
} }
#commentsdiv.postbox .column-comment p { #commentsdiv p {
margin:0.6em 0; padding: 8px 10px;
margin: 0;
} }
#commentsdiv.postbox #replyrow td { #commentsdiv #add-new-comment {
padding:0; border-width: 0 0 1px;
border-style: none none solid;
}
#commentsdiv .comments-box {
border: 0 none;
}
#commentsdiv .comments-box thead th {
background: transparent;
padding: 0 7px 4px;
font-style: italic;
}
#commentsdiv .comments-box tr:last-child td {
border-bottom: 0 none;
}
#commentsdiv img.waiting {
padding-left: 5px;
} }
.sorting-indicator { .sorting-indicator {
@ -3112,7 +3132,7 @@ div.tabs-panel-inactive {
#normal-sortables .postbox #replyrow .submit { #normal-sortables .postbox #replyrow .submit {
float: none; float: none;
margin: 0; margin: 0;
padding: 3px 7px; padding: 0 7px 5px;
} }
#side-sortables .submitbox .submit input, #side-sortables .submitbox .submit input,
@ -3126,24 +3146,12 @@ div.tabs-panel-inactive {
margin: 11px 0; margin: 11px 0;
} }
#side-sortables .comments-box,
#normal-sortables .comments-box {
border: 0 none;
}
ul.category-tabs, ul.category-tabs,
ul.add-menu-item-tabs, ul.add-menu-item-tabs,
ul.wp-tab-bar { ul.wp-tab-bar {
margin-top: 12px; margin-top: 12px;
} }
#side-sortables .comments-box thead th,
#normal-sortables .comments-box thead th {
background: transparent;
padding: 0 7px 4px;
font-style: italic;
}
ul.category-tabs li.tabs, ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs, ul.add-menu-item-tabs li.tabs,
.wp-tab-active { .wp-tab-active {
@ -3151,10 +3159,6 @@ ul.add-menu-item-tabs li.tabs,
border-width: 1px 1px 0; border-width: 1px 1px 0;
} }
#commentsdiv img.waiting {
padding-left: 5px;
}
#post-body .category-tabs li.tabs, #post-body .category-tabs li.tabs,
#post-body .add-menu-item-tabs li.tabs { #post-body .add-menu-item-tabs li.tabs {
border-style: solid none solid solid; border-style: solid none solid solid;

View File

@ -471,25 +471,30 @@ function post_comment_meta_box_thead($result) {
function post_comment_meta_box($post) { function post_comment_meta_box($post) {
global $wpdb, $post_ID; global $wpdb, $post_ID;
$total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
if ( 1 > $total ) {
echo '<p>' . __('No comments yet.') . '</p>';
return;
}
wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
?>
<p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post_ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
<?php
$total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
$wp_list_table->display( true ); $wp_list_table->display( true );
?>
<p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /></p> if ( 1 > $total ) {
<?php echo '<p id="no-comments">' . __('No comments yet.') . '</p>';
$hidden = get_hidden_meta_boxes('post'); } else {
if ( ! in_array('commentsdiv', $hidden) ) { ?> $hidden = get_hidden_meta_boxes('post');
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script> if ( ! in_array('commentsdiv', $hidden) ) {
<?php ?>
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
<?php
}
} }
?>
<p class="hide-if-no-js hidden" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /></p>
<?php
wp_comment_trashnotice(); wp_comment_trashnotice();
} }

View File

@ -314,7 +314,7 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
<?php endif; ?> <?php endif; ?>
<div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div> <div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div>
<div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div>
<div id="edithead" style="display:none;"> <div id="edithead" style="display:none;">
<div class="inside"> <div class="inside">
<label for="author"><?php _e('Name') ?></label> <label for="author"><?php _e('Name') ?></label>
@ -343,6 +343,7 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
<p id="replysubmit" class="submit"> <p id="replysubmit" class="submit">
<a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a> <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
<a href="#comments-form" class="save button-primary alignright" tabindex="104"> <a href="#comments-form" class="save button-primary alignright" tabindex="104">
<span id="addbtn" style="display:none;"><?php _e('Add Comment'); ?></span>
<span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
<span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />

View File

@ -345,61 +345,72 @@ commentReply = {
}, },
close : function() { close : function() {
var c; var c, replyrow = $('#replyrow');
if ( this.cid ) { // replyrow is not showing?
if ( replyrow.parent().is('#com-reply') )
return;
if ( this.cid && this.act == 'edit-comment' ) {
c = $('#comment-' + this.cid); c = $('#comment-' + this.cid);
c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
if ( typeof QTags != 'undefined' )
QTags.closeAllTags('replycontent');
if ( this.act == 'edit-comment' )
c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
$('#replyrow').hide();
$('#com-reply').append( $('#replyrow') );
$('#replycontent').val('');
$('input', '#edithead').val('');
$('.error', '#replysubmit').html('').hide();
$('.waiting', '#replysubmit').hide();
$('#replycontent').css('height', '');
this.cid = '';
} }
// reset the Quicktags buttons
if ( typeof QTags != 'undefined' )
QTags.closeAllTags('replycontent');
$('#add-new-comment').css('display', '');
replyrow.hide();
$('#com-reply').append( replyrow );
$('#replycontent').css('height', '').val('');
$('#edithead input').val('');
$('.error', replyrow).html('').hide();
$('.waiting', replyrow).hide();
this.cid = '';
}, },
open : function(id, p, a) { open : function(comment_id, post_id, action) {
var t = this, editRow, rowData, act, c = $('#comment-' + id), h = c.height(), replyButton; var t = this, editRow, rowData, act, c = $('#comment-' + comment_id), h = c.height(), replyButton;
t.close(); t.close();
t.cid = id; t.cid = comment_id;
editRow = $('#replyrow'); editRow = $('#replyrow');
rowData = $('#inline-'+id); rowData = $('#inline-'+comment_id);
act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment'; action = action || 'replyto';
act = 'edit' == action ? 'edit' : 'replyto';
act = t.act = act + '-comment';
$('#action', editRow).val(act); $('#action', editRow).val(act);
$('#comment_post_ID', editRow).val(p); $('#comment_post_ID', editRow).val(post_id);
$('#comment_ID', editRow).val(id); $('#comment_ID', editRow).val(comment_id);
if ( h > 120 ) if ( h > 120 )
$('#replycontent', editRow).css('height', (35+h) + 'px'); $('#replycontent', editRow).css('height', (35+h) + 'px');
if ( a == 'edit' ) { if ( action == 'edit' ) {
$('#author', editRow).val( $('div.author', rowData).text() ); $('#author', editRow).val( $('div.author', rowData).text() );
$('#author-email', editRow).val( $('div.author-email', rowData).text() ); $('#author-email', editRow).val( $('div.author-email', rowData).text() );
$('#author-url', editRow).val( $('div.author-url', rowData).text() ); $('#author-url', editRow).val( $('div.author-url', rowData).text() );
$('#status', editRow).val( $('div.comment_status', rowData).text() ); $('#status', editRow).val( $('div.comment_status', rowData).text() );
$('#replycontent', editRow).val( $('textarea.comment', rowData).val() ); $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
$('#edithead, #savebtn', editRow).show(); $('#edithead, #savebtn', editRow).show();
$('#replyhead, #replybtn', editRow).hide(); $('#replyhead, #replybtn, #addhead, #addbtn', editRow).hide();
c.after( editRow ).fadeOut('fast', function(){ c.after( editRow ).fadeOut('fast', function(){
$('#replyrow').fadeIn(300, function(){ $(this).show() }); $('#replyrow').fadeIn(300, function(){ $(this).show() });
}); });
} else { } else if ( action == 'add' ) {
replyButton = $('#replybtn', editRow); $('#addhead, #addbtn', editRow).show();
$('#edithead, #savebtn', editRow).hide(); $('#replyhead, #replybtn, #edithead, #editbtn', editRow).hide();
$('#the-comment-list').prepend(editRow);
$('#replyrow').fadeIn(300);
} else {
replyButton = $('#replybtn', editRow);
$('#edithead, #savebtn, #addhead, #addbtn', editRow).hide();
$('#replyhead, #replybtn', editRow).show(); $('#replyhead, #replybtn', editRow).show();
c.after(editRow); c.after(editRow);
@ -442,7 +453,8 @@ commentReply = {
$('#replysubmit .waiting').show(); $('#replysubmit .waiting').show();
$('#replyrow input').not(':button').each(function() { $('#replyrow input').not(':button').each(function() {
post[ $(this).attr('name') ] = $(this).val(); var t = $(this);
post[ t.attr('name') ] = t.val();
}); });
post.content = $('#replycontent').val(); post.content = $('#replycontent').val();
@ -483,6 +495,7 @@ commentReply = {
r = r.responses[0]; r = r.responses[0];
c = r.data; c = r.data;
id = '#comment-' + r.id; id = '#comment-' + r.id;
if ( 'edit-comment' == t.act ) if ( 'edit-comment' == t.act )
$(id).remove(); $(id).remove();
@ -527,6 +540,16 @@ commentReply = {
if ( er ) if ( er )
$('#replysubmit .error').html(er).show(); $('#replysubmit .error').html(er).show();
},
addcomment: function(post_id) {
var t = this;
$('#add-new-comment').fadeOut(200, function(){
t.open(0, post_id, 'add');
$('table.comments-box').css('display', '');
$('#no-comments').remove();
});
} }
}; };

View File

@ -211,10 +211,11 @@ commentsBox = {
if ( commentsBox.st > commentsBox.total ) if ( commentsBox.st > commentsBox.total )
$('#show-comments').hide(); $('#show-comments').hide();
else else
$('#show-comments').html(postL10n.showcomm); $('#show-comments').show().children('a').html(postL10n.showcomm);
return; return;
} else if ( 1 == r ) { } else if ( 1 == r ) {
$('#show-comments').parent().html(postL10n.endcomm); $('#show-comments').html(postL10n.endcomm);
return; return;
} }

View File

@ -1082,7 +1082,7 @@ html[dir="rtl"] .wp-switch-editor {
border-top-right-radius: 3px; border-top-right-radius: 3px;
border-top-left-radius: 3px; border-top-left-radius: 3px;
padding: 2px 8px 0; padding: 2px 8px 0;
min-height: 30px; min-height: 29px;
} }
.quicktags-toolbar > div { .quicktags-toolbar > div {