Skip to content

Commit

Permalink
Add link to cancel comment (add/edit)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahularyan committed Sep 8, 2015
1 parent c7d6362 commit 935418e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
10 changes: 10 additions & 0 deletions assets/js/anspress_site.js
Expand Up @@ -50,6 +50,7 @@
this.hoverCard();
this.delete_notification();
this.mark_as_read();
this.cancel_comment();
},
doAjax: function(query, success, context, before, abort) {
/** Shorthand method for calling ajax */
Expand Down Expand Up @@ -644,6 +645,15 @@
});
},

cancel_comment: function(){
$('body').delegate('[data-action="cancel-comment"]', 'click', function(e) {
e.preventDefault();
var postID = $(this).data('id');
$('[href="#comments-'+postID+'"]').removeClass('loaded');
$(this).closest('.ap-comment-form').remove();
});
}

}
})(jQuery);

Expand Down
2 changes: 1 addition & 1 deletion assets/prod/anspress_site.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion includes/ajax.php
Expand Up @@ -123,11 +123,15 @@ public function load_comment_form() {
$nonce = wp_create_nonce( 'comment_'.(int) $_REQUEST['post'] );
}

ob_start();
include ap_get_theme_location('comment-form.php');
$html = ob_get_clean();

$comment_args = array(
'id_form' => 'ap-commentform',
'title_reply' => '',
'logged_in_as' => '',
'comment_field' => '<div class="ap-comment-submit"><input type="submit" value="'.__( 'Comment', 'ap' ).'" name="submit"></div><div class="ap-comment-textarea"><textarea name="comment" rows="3" aria-required="true" id="ap-comment-textarea" class="ap-form-control autogrow" placeholder="'.__( 'Respond to the post.', 'ap' ).'">'.$content.'</textarea></div><input type="hidden" name="ap_form_action" value="comment_form"/><input type="hidden" name="ap_ajax_action" value="comment_form"/><input type="hidden" name="__nonce" value="'.$nonce.'"/>'.$commentid,
'comment_field' => $html.'<input type="hidden" name="ap_form_action" value="comment_form"/><input type="hidden" name="ap_ajax_action" value="comment_form"/><input type="hidden" name="__nonce" value="'.$nonce.'"/>'.$commentid,
'comment_notes_after' => '',
);

Expand Down
3 changes: 2 additions & 1 deletion includes/user.php
Expand Up @@ -776,7 +776,8 @@ function ap_cover_upload_form() {
function ap_get_cover_src($user_id = false, $small = false) {

if ( $user_id === false ) {
$user_id = ap_get_displayed_user_id(); }
$user_id = ap_get_displayed_user_id();
}

$cover = get_user_meta( $user_id, '_ap_cover', true );

Expand Down
15 changes: 15 additions & 0 deletions theme/default/comment-form.php
@@ -0,0 +1,15 @@
<?php
/**
* This template is used for displaying comment form.
*
* @link http://anspress.io
* @since 2.4
*/
?>
<div class="ap-comment-submit">
<input type="submit" value="<?php _e( 'Comment', 'ap' ); ?>" name="submit">
<a href="#" data-action="cancel-comment" data-id="<?php echo $comment_post_ID; ?>"><?php _e( 'Cancel', 'ap' ); ?></a>
</div>
<div class="ap-comment-textarea">
<textarea name="comment" rows="3" aria-required="true" id="ap-comment-textarea" class="ap-form-control autogrow" placeholder="<?php _e( 'Respond to the post.', 'ap' ); ?>"><?php echo $content; ?></textarea>
</div>
1 change: 1 addition & 0 deletions theme/default/css/main.css
Expand Up @@ -2699,6 +2699,7 @@ body ul ul#ap-user-menu-link li > a .count {
padding: 4px 10px;
text-decoration: none;
vertical-align: middle;
margin-bottom: 5px;
}
#anspress .ap-comment-form input[type="submit"].ap-btn-view-all {
display: block;
Expand Down
3 changes: 2 additions & 1 deletion theme/default/less/comment.less
Expand Up @@ -64,7 +64,7 @@
i{
font-size: 10px;
}
}
}
}
.ap-comment-time {
color: #777;
Expand Down Expand Up @@ -100,6 +100,7 @@
}
input[type="submit"]{
#anspress .ap-btn;
margin-bottom: 5px;
}
.ap-comment-textarea {
overflow: hidden;
Expand Down

0 comments on commit 935418e

Please sign in to comment.