This commit is contained in:
Michael Q Larson
2015-03-09 00:27:23 -07:00
4 changed files with 26 additions and 16 deletions

View File

@ -298,7 +298,7 @@ module.exports = {
}); });
})(); })();
}, },
updateUserStoryPictures: function(userId, picture) { updateUserStoryPictures: function(userId, picture, username) {
var counter = 0, var counter = 0,
foundStories, foundStories,
@ -327,12 +327,14 @@ module.exports = {
} }
R.forEach(function(comment) { R.forEach(function(comment) {
comment.author.picture = picture; comment.author.picture = picture;
comment.author.username = username;
comment.markModified('author'); comment.markModified('author');
comment.save(); comment.save();
}, foundComments); }, foundComments);
R.forEach(function(story) { R.forEach(function(story) {
story.author.picture = picture; story.author.picture = picture;
story.author.username = username;
story.markModified('author'); story.markModified('author');
story.save(); story.save();
}, foundStories); }, foundStories);

View File

@ -350,7 +350,7 @@ exports.postUpdateProfile = function(req, res, next) {
} }
req.flash('success', {msg: 'Profile information updated.'}); req.flash('success', {msg: 'Profile information updated.'});
res.redirect('/account'); res.redirect('/account');
resources.updateUserStoryPictures(user._id.toString(), user.profile.picture); resources.updateUserStoryPictures(user._id.toString(), user.profile.picture, user.profile.username);
}); });
}); });
}); });

View File

@ -57,29 +57,33 @@
$('.comment-a-comment').on('click', 'a', function () { $('.comment-a-comment').on('click', 'a', function () {
$(this).unbind('click'); $(this).unbind('click');
$('.comment-to-comment-formgroup').empty(); $('.comment-to-comment-formgroup').empty();
$('#initial-comment-submit').addClass('hidden-element');
var div = document.createElement('div'); var div = document.createElement('div');
var commentId = $(this).attr('id'); var commentId = $(this).attr('id');
$(div).html( $(div).html(
"<div class='formgroup comment-to-comment-formgroup'>" + "<div class='formgroup comment-to-comment-formgroup control-label-story-submission'>" +
"<div class=col-xs-12" + '<div class="col-xs-12">' +
"<div class='input-group'>" + "<div class='input-group'>" +
"<input class='form-control' id='comment-to-comment-textarea' type='text' maxlength='140' autofocus />" + "<input class='form-control big-text-field field-responsive' id='comment-to-comment-textinput' type='text' maxlength='140' autofocus />" +
"<span class='input-group-btn'>" +
"<button id='submit-comment-to-comment' class='btn btn-big btn-primary btn-responsive'>Send</button>" +
"</span>" +
"</div>" + "</div>" +
"</div>" + "</div>" +
"<span class='input-group-btn'>" + "<div id='textarea-comment-feedback'></div>" +
"<button id='submit-comment-to-comment' class='btn btn-big btn-primary btn-responsive' type='button'>Send</button>" +
"</span>" +
"<span class='pull-left' id='textarea_feedback'></span>" +
"</div>" "</div>"
) )
.addClass('row') .addClass('row')
.appendTo($(this).closest('.media-body-wrapper')); .appendTo($(this).closest('.media-body-wrapper'));
var text_max = 140; var text_max = 140;
$('#textarea_feedback').html(text_max + ' characters remaining'); $('#textarea-comment-feedback').html(text_max + ' characters remaining');
$('#comment-to-comment-textarea').keyup(function () { $('#comment-to-comment-textinput').keyup(function (e) {
var text_length = $('#comment-to-comment-textarea').val().length; 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; 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() { var submitCommentToCommentHandler = function submitCommentToCommentHandler() {
$('#submit-comment-to-comment').unbind('click'); $('#submit-comment-to-comment').unbind('click');
@ -87,7 +91,7 @@
{ {
data: { data: {
associatedPost: commentId, associatedPost: commentId,
body: $('#comment-to-comment-textarea').val(), body: $('#comment-to-comment-textinput').val(),
author: { author: {
picture: user.profile.picture, picture: user.profile.picture,
userId: user._id, userId: user._id,

View File

@ -41,7 +41,8 @@
input#comment-box.big-text-field.field-responsive.form-control(type='text', placeholder='Enter your reply', autofocus) input#comment-box.big-text-field.field-responsive.form-control(type='text', placeholder='Enter your reply', autofocus)
span.input-group-btn span.input-group-btn
button#comment-button.btn.btn-big.btn-primary.btn-responsive(type='button') Send 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. script.
$('#reply-to-main-post').on('click', function() { $('#reply-to-main-post').on('click', function() {
$('#initial-comment-submit').removeClass('hidden-element'); $('#initial-comment-submit').removeClass('hidden-element');
@ -50,7 +51,10 @@
}); });
var text_max = 140; var text_max = 140;
$('#textarea_feedback').html(text_max + ' characters remaining'); $('#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_length = $('#comment-box').val().length;
var text_remaining = text_max - text_length; var text_remaining = text_max - text_length;
$('#textarea_feedback').html(text_remaining + ' characters remaining'); $('#textarea_feedback').html(text_remaining + ' characters remaining');