From de91be44dace653329b336e419d4d37d4e15e6b2 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Sun, 8 Mar 2015 18:48:20 +0900 Subject: [PATCH] comment submit time bug fixed --- controllers/story.js | 6 +++-- models/Comment.js | 6 ++--- public/css/main.less | 19 ++++++++++---- views/stories/comments.jade | 49 +++++++++++++++++-------------------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/controllers/story.js b/controllers/story.js index b3eab98834..c88df28fdb 100644 --- a/controllers/story.js +++ b/controllers/story.js @@ -269,7 +269,8 @@ exports.commentSubmit = function(req, res, next) { upvotes: 0, author: data.author, comments: [], - topLevel: true + topLevel: true, + commentOn: Date.now() }); commentSave(comment, Story, res); }; @@ -285,7 +286,8 @@ exports.commentOnCommentSubmit = function(req, res, next) { upvotes: 0, author: data.author, comments: [], - topLevel: false + topLevel: false, + commentOn: Date.now() }); commentSave(comment, Comment, res); }; diff --git a/models/Comment.js b/models/Comment.js index 89d1804654..a3a35fe6fd 100644 --- a/models/Comment.js +++ b/models/Comment.js @@ -23,9 +23,9 @@ var commentSchema = new mongoose.Schema({ type: Array, default: [] }, - toplevel: { - type: Boolean, - default: false + commentOn: { + type: Number, + default: Date.now() } }); diff --git a/public/css/main.less b/public/css/main.less index c12a897789..f65df91a75 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -175,6 +175,14 @@ ul { margin-top: 5px; } +.positive-10 { + margin-top: 10px; +} + +.positive-15 { + margin-top: 15px; +} + .negative-45 { margin-top: -45px; margin-bottom: -45px; @@ -815,13 +823,14 @@ iframe.iphone { height: 50px; } -.comment-wrapper { - position: relative; +//.media ~ .media .media-body-wrapper:nth-child(odd) { +// background-color: #e5e5e5; +//} + +.media-body-wrapper:nth-child(odd){ + background-color: #e5e5e5; } -.comment + .comment-wrapper { - left: 3%; -} //uncomment this to see the dimensions of all elements outlined in red //* { diff --git a/views/stories/comments.jade b/views/stories/comments.jade index b85cd7e7e0..1ca087a539 100644 --- a/views/stories/comments.jade +++ b/views/stories/comments.jade @@ -1,5 +1,5 @@ .text-left - div#comment-list.comment-list + div#comment-list script(src="https://cdn.jsdelivr.net/ramda/0.10.0/ramda.min.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js") @@ -7,9 +7,9 @@ var sentinel = 0; var renderComments = function renderComments(comments, containerSelector, level) { var commentDetails; - var offSetClass = level ? 'col-xs-offset-' + level : ''; - var rowClass = level ? 'col-xs-' + (12 - level) : 'col-xs-12'; + var backgroundColorForCommentNestingLevel = level % 2 !== 0 ? '#e5e5e5' : '#e7e7e7imit T'; R.forEach(function displayComments(comment) { + $.ajax({ type: 'GET', url: '/stories/comments/' + comment, @@ -22,32 +22,27 @@ }, success: function (data, textStatus, xhr) { commentDetails = data; + console.log(commentDetails.commentOn); var div = document.createElement('div'); $(div) .html( - "
" + - "
" + - "" + - "
" + - "
" + - "
" + - "
" + - commentDetails.body + - "
" + - "
" + - "
" + - "
" + - "
" + - "commented " + moment(commentDetails.commentedOn).fromNow() + " by " + - "@" + commentDetails.author.username + " · " + - "Reply" + - "
" + - "
" + - "
" + - "
" + - "
" + '
' + + '
' + + '' + commentDetails.author.username + '' + + '
' + + '
' + + '
' + + '

' + commentDetails.body + '

' + + '
' + + "commented " + moment(commentDetails.commentOn).fromNow() + " by " + + "@" + commentDetails.author.username + " · " + + "Reply" + + '
' + + '
' + + '
' + + '
' ) - .addClass('comment-wrapper comment_' + commentDetails._id) + .addClass('comment-wrapper positive-10') .appendTo($(containerSelector)); sentinel += commentDetails.comments.length; @@ -68,8 +63,8 @@ "" + "" ) - .addClass('col-xs-6 col-xs-offset-3') - .appendTo($(this).closest('.comment')); + .addClass('row') + .appendTo($(this).closest('.media-body-wrapper')); var submitCommentToCommentHandler = function submitCommentToCommentHandler() { $('#submit-comment-to-comment').unbind('click'); $.post('/stories/comment/' + commentId + '/comment',