Skip to content

Commit

Permalink
much better logic handling for closing replies on suggestion contents
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcLear committed May 25, 2015
1 parent 6f7dd42 commit f31c86d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,19 @@ ep_comments.prototype.init = function(){
});

// Listen for include suggested change toggle
this.container.on("change", '#reply-suggestion-checkbox', function(){
this.container.on("change", '.reply-suggestion-checkbox', function(){
if($(this).is(':checked')){
// Get current text -- cake
var commentId = $(this).parent().parent().parent()[0].id;
var padOuter = $('iframe[name="ace_outer"]').contents();
var padInner = padOuter.find('iframe[name="ace_inner"]');

var currentString = padInner.contents().find("."+commentId).html();
$(this).parent().parent().find(".comment-suggest-from").html(currentString);
$(this).parent().parent().contents().find('.reply-suggestion').show();
console.log(self.comments[commentId].data);
$(this).parent().parent().find(".reply-comment-suggest-from").html(currentString);
$(this).parent().parent().find('.reply-suggestion').show();
}else{
$(this).parent().parent().contents().find('.reply-suggestion').hide();
$(this).parent().parent().find('.reply-suggestion').hide();
}
});

Expand Down Expand Up @@ -167,7 +168,9 @@ ep_comments.prototype.init = function(){
self.collectCommentReplies();
});
});

if($(this).parent().parent().find(".reply-suggestion-checkbox").is(':checked')){
$(this).parent().parent().find(".reply-suggestion-checkbox").click();
}
});

// Enable and handle cookies
Expand Down Expand Up @@ -539,7 +542,9 @@ ep_comments.prototype.addComment = function (callback){
// TODO This doesn't appear to get the Y right for the input field...

this.insertNewComment(data, function (comment, index){
if(comment.changeTo) data.comment.changeTo = comment.changeTo;
if(comment.changeTo){
data.comment.changeTo = comment.changeTo;
}
data.comment.text = comment.text;

// Save comment
Expand All @@ -558,7 +563,6 @@ ep_comments.prototype.addComment = function (callback){
});
});


var line = rep.lines.atIndex(rep.selStart[0]);
var selectedText = line.text.substring(rep.selStart[1], rep.selEnd[1]);
$('iframe[name="ace_outer"]').contents().find(".comment-suggest-from").val(selectedText);
Expand Down
2 changes: 1 addition & 1 deletion templates/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</p>
</span>
<p class="reply-comment-suggest">
<input type="checkbox" id="reply-suggestion-checkbox-${commentId}">
<input type="checkbox" id="reply-suggestion-checkbox-${commentId}" class="reply-suggestion-checkbox">
<label for="reply-suggestion-checkbox-${commentId}">Include suggested change</label>
</p>
</form>
Expand Down

0 comments on commit f31c86d

Please sign in to comment.