Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ReplyTo/class.replyto.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public function postController_render_before($sender) {
$this->prepareController($sender);
}

/**
* Add View Mode before rendering comments
* @param $sender
* @param $args
*/
public function base_beforeCommentsRender_handler($sender, $args) {
$viewMode = self::getViewMode();
$sender->setData('ViewMode', $viewMode);
}

/**
* Render View options for a discussion
* @param $sender
Expand Down Expand Up @@ -264,11 +274,13 @@ public function base_inlineDiscussionOptions_handler($sender, $args) {

/**
* Insert the indentation classes into the comment.
* All rendering options should be set before displaying comments
* @param $sender
* @param $args
*/
public function base_beforeCommentDisplay_handler($sender, $args) {
if($sender->deliveryType() != DELIVERY_TYPE_ALL) {
// Ajax request to post new comments or update comments
if(isset($_SERVER['HTTP_REFERER'])) {
$previous = $_SERVER['HTTP_REFERER'];
$query = parse_url($previous, PHP_URL_QUERY);
Expand All @@ -277,7 +289,7 @@ public function base_beforeCommentDisplay_handler($sender, $args) {
if(!$viewMode) {
$viewMode = self::isPagingUrl($previous) ? self::VIEW_FLAT : self::VIEW_THREADED;
}

$sender->setData('ViewMode', $viewMode);
if($viewMode == self::VIEW_THREADED) {
$this->buildCommentReplyToCssClasses($sender);
}
Expand Down
16 changes: 13 additions & 3 deletions ReplyTo/js/replyto.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ jQuery(document).ready(function($) {
var parent = $(btn).parents('.MainContent');
var commentContainer = $(parent).find('div.CommentForm');
var header = $(commentContainer).find('h2.H');
$(header).text('Reply to a comment');
// Form
var form = $(commentContainer).find('form#Form_Comment');
var href = $(btn).attr('href');
var commentID = param(href,'ParentCommentID');
var hiddenField = $(form).find(':input[type="hidden"]#Form_ParentCommentID')

var author = '';
if(commentID == '') { // No Parent Comment, Reply to Discussion
commentID = 0;
author = $(btn).parents('.Discussion').find('.Item-Header.DiscussionHeader .Author .topcoderHandle').text();
} else {
author = $(btn).parents('.Comment').find('.Item-Header.CommentHeader .Author .topcoderHandle').text();
}

$(header).text('Replying to '+ author);

if($(hiddenField).length == 0) {
var el = '<input type="hidden" name="ParentCommentID" id="Form_ParentCommentID" value="' + commentID + '"></input>';
$(form).append(el);
Expand All @@ -30,11 +40,11 @@ jQuery(document).ready(function($) {
var formButtons = $(form).find('.Buttons');
var postCommentButton = $(form).find('.CommentButton');
postCommentButton.val('Post Reply');
var backButton = $(formButtons).find('span.Back');
var backButton = $(formButtons).find('.Button.PreviewButton');
var cancelReplyButton = $(formButtons).find('span.Reply');
if($(cancelReplyButton).length == 0) {
var cancelReplyButton = '<span class="Reply"><a href="/" class="Button CancelReplyComment">Cancel Reply</a></span>';
$(cancelReplyButton).insertAfter(backButton);
$(cancelReplyButton).insertBefore(backButton);
} else {
$(cancelReplyButton).show();
}
Expand Down