From 77496864d43dc9f959249c44f3382dcdbc71cc2e Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 9 Mar 2015 11:31:32 +0900 Subject: [PATCH 1/3] Unify comment view between comments and show, hide all comment input elements when user clicks on new reply button --- views/stories/comments.jade | 24 +++++++++++++----------- views/stories/show.jade | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/views/stories/comments.jade b/views/stories/comments.jade index bbf84b6322..a0d8cc32f1 100644 --- a/views/stories/comments.jade +++ b/views/stories/comments.jade @@ -57,29 +57,31 @@ $('.comment-a-comment').on('click', 'a', function () { $(this).unbind('click'); $('.comment-to-comment-formgroup').empty(); + $('#initial-comment-submit').addClass('hidden-element'); var div = document.createElement('div'); var commentId = $(this).attr('id'); $(div).html( - "
" + - "
" + + '
' + "
" + - "" + + "" + + "" + + "" + + "" + "
" + "
" + - "" + - "" + - "" + - "" + + "
" + "
" ) .addClass('row') .appendTo($(this).closest('.media-body-wrapper')); var text_max = 140; - $('#textarea_feedback').html(text_max + ' characters remaining'); - $('#comment-to-comment-textarea').keyup(function () { - var text_length = $('#comment-to-comment-textarea').val().length; + $('#textarea-comment-feedback').html(text_max + ' characters remaining'); + $('#comment-to-comment-textinput').keyup(function () { + console.log('I should be showing characters remaining'); + var text_length = $('#comment-to-comment-textinput').val().length; var text_remaining = text_max - text_length; - $('#textarea_feedback').html(text_remaining + ' characters remaining'); + $('#textarea-comment-feedback').html(text_remaining + ' characters remaining'); }); var submitCommentToCommentHandler = function submitCommentToCommentHandler() { $('#submit-comment-to-comment').unbind('click'); diff --git a/views/stories/show.jade b/views/stories/show.jade index fe36f3c7f7..2a9acb8421 100644 --- a/views/stories/show.jade +++ b/views/stories/show.jade @@ -41,7 +41,8 @@ input#comment-box.big-text-field.field-responsive.form-control(type='text', placeholder='Enter your reply', autofocus) span.input-group-btn button#comment-button.btn.btn-big.btn-primary.btn-responsive(type='button') Send - span.pull-left#textarea_feedback + span.spacer.pull-left#textarea_feedback + script. $('#reply-to-main-post').on('click', function() { $('#initial-comment-submit').removeClass('hidden-element'); From ca440c53f8a3332d6332e87c29693bb27d59b6e4 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 9 Mar 2015 11:55:33 +0900 Subject: [PATCH 2/3] Enter button now triggers comment submission --- views/stories/comments.jade | 8 +++++--- views/stories/show.jade | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/views/stories/comments.jade b/views/stories/comments.jade index a0d8cc32f1..dde7337b95 100644 --- a/views/stories/comments.jade +++ b/views/stories/comments.jade @@ -77,8 +77,10 @@ .appendTo($(this).closest('.media-body-wrapper')); var text_max = 140; $('#textarea-comment-feedback').html(text_max + ' characters remaining'); - $('#comment-to-comment-textinput').keyup(function () { - console.log('I should be showing characters remaining'); + $('#comment-to-comment-textinput').keyup(function (e) { + if (e.which === 13 || e === 13) { + $('#submit-comment-to-comment').click(); + } var text_length = $('#comment-to-comment-textinput').val().length; var text_remaining = text_max - text_length; $('#textarea-comment-feedback').html(text_remaining + ' characters remaining'); @@ -89,7 +91,7 @@ { data: { associatedPost: commentId, - body: $('#comment-to-comment-textarea').val(), + body: $('#comment-to-comment-textinput').val(), author: { picture: user.profile.picture, userId: user._id, diff --git a/views/stories/show.jade b/views/stories/show.jade index 2a9acb8421..985b9d4f2a 100644 --- a/views/stories/show.jade +++ b/views/stories/show.jade @@ -51,7 +51,10 @@ }); var text_max = 140; $('#textarea_feedback').html(text_max + ' characters remaining'); - $('#comment-box').keyup(function () { + $('#comment-box').keyup(function (e) { + if (e.which === 13 || e === 13) { + $('#comment-button').click(); + } var text_length = $('#comment-box').val().length; var text_remaining = text_max - text_length; $('#textarea_feedback').html(text_remaining + ' characters remaining'); From 3b3de541b39ea3971d90cd6efe23084ed430d868 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 9 Mar 2015 11:59:50 +0900 Subject: [PATCH 3/3] Update username for stories and comments on username change in profile --- controllers/resources.js | 4 +++- controllers/user.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/resources.js b/controllers/resources.js index 49e87a0d31..71bf06e4b6 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -298,7 +298,7 @@ module.exports = { }); })(); }, - updateUserStoryPictures: function(userId, picture) { + updateUserStoryPictures: function(userId, picture, username) { var counter = 0, foundStories, @@ -327,12 +327,14 @@ module.exports = { } R.forEach(function(comment) { comment.author.picture = picture; + comment.author.username = username; comment.markModified('author'); comment.save(); }, foundComments); R.forEach(function(story) { story.author.picture = picture; + story.author.username = username; story.markModified('author'); story.save(); }, foundStories); diff --git a/controllers/user.js b/controllers/user.js index cbdcc03d0b..d7e383a251 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -350,7 +350,7 @@ exports.postUpdateProfile = function(req, res, next) { } req.flash('success', {msg: 'Profile information updated.'}); res.redirect('/account'); - resources.updateUserStoryPictures(user._id.toString(), user.profile.picture); + resources.updateUserStoryPictures(user._id.toString(), user.profile.picture, user.profile.username); }); }); });