comment submit time bug fixed
This commit is contained in:
@ -269,7 +269,8 @@ exports.commentSubmit = function(req, res, next) {
|
|||||||
upvotes: 0,
|
upvotes: 0,
|
||||||
author: data.author,
|
author: data.author,
|
||||||
comments: [],
|
comments: [],
|
||||||
topLevel: true
|
topLevel: true,
|
||||||
|
commentOn: Date.now()
|
||||||
});
|
});
|
||||||
commentSave(comment, Story, res);
|
commentSave(comment, Story, res);
|
||||||
};
|
};
|
||||||
@ -285,7 +286,8 @@ exports.commentOnCommentSubmit = function(req, res, next) {
|
|||||||
upvotes: 0,
|
upvotes: 0,
|
||||||
author: data.author,
|
author: data.author,
|
||||||
comments: [],
|
comments: [],
|
||||||
topLevel: false
|
topLevel: false,
|
||||||
|
commentOn: Date.now()
|
||||||
});
|
});
|
||||||
commentSave(comment, Comment, res);
|
commentSave(comment, Comment, res);
|
||||||
};
|
};
|
||||||
|
@ -23,9 +23,9 @@ var commentSchema = new mongoose.Schema({
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: []
|
default: []
|
||||||
},
|
},
|
||||||
toplevel: {
|
commentOn: {
|
||||||
type: Boolean,
|
type: Number,
|
||||||
default: false
|
default: Date.now()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -175,6 +175,14 @@ ul {
|
|||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.positive-10 {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.positive-15 {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.negative-45 {
|
.negative-45 {
|
||||||
margin-top: -45px;
|
margin-top: -45px;
|
||||||
margin-bottom: -45px;
|
margin-bottom: -45px;
|
||||||
@ -815,13 +823,14 @@ iframe.iphone {
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-wrapper {
|
//.media ~ .media .media-body-wrapper:nth-child(odd) {
|
||||||
position: relative;
|
// 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
|
//uncomment this to see the dimensions of all elements outlined in red
|
||||||
//* {
|
//* {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.text-left
|
.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://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")
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js")
|
||||||
@ -7,9 +7,9 @@
|
|||||||
var sentinel = 0;
|
var sentinel = 0;
|
||||||
var renderComments = function renderComments(comments, containerSelector, level) {
|
var renderComments = function renderComments(comments, containerSelector, level) {
|
||||||
var commentDetails;
|
var commentDetails;
|
||||||
var offSetClass = level ? 'col-xs-offset-' + level : '';
|
var backgroundColorForCommentNestingLevel = level % 2 !== 0 ? '#e5e5e5' : '#e7e7e7imit T';
|
||||||
var rowClass = level ? 'col-xs-' + (12 - level) : 'col-xs-12';
|
|
||||||
R.forEach(function displayComments(comment) {
|
R.forEach(function displayComments(comment) {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: '/stories/comments/' + comment,
|
url: '/stories/comments/' + comment,
|
||||||
@ -22,32 +22,27 @@
|
|||||||
},
|
},
|
||||||
success: function (data, textStatus, xhr) {
|
success: function (data, textStatus, xhr) {
|
||||||
commentDetails = data;
|
commentDetails = data;
|
||||||
|
console.log(commentDetails.commentOn);
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
$(div)
|
$(div)
|
||||||
.html(
|
.html(
|
||||||
"<div class='comment row col-xs-12'>" +
|
'<div class="media">' +
|
||||||
"<div class='col-xs-1'>" +
|
'<div class="media-left">' +
|
||||||
"<img class='img-news' src=" + commentDetails.author.picture + "></img>" +
|
'<img class="media-object img-news" src="' + commentDetails.author.picture +'" alt="' + commentDetails.author.username + '">' +
|
||||||
"</div>" +
|
'</div>' +
|
||||||
"<div class='col-xs-10'>" +
|
'<div class="media-body comment_' + commentDetails._id + '">' +
|
||||||
"<div class='row'>" +
|
'<div class="media-body-wrapper">' +
|
||||||
"<div class='col-xs-12'>" +
|
'<p>' + commentDetails.body + '</p>' +
|
||||||
commentDetails.body +
|
'<div class="clearfix comment-a-comment negative-15">' +
|
||||||
"</div>" +
|
"commented " + moment(commentDetails.commentOn).fromNow() + " by " +
|
||||||
"</div>" +
|
"<a href='/" + commentDetails.author.username + "'>@" + commentDetails.author.username + "</a> · " +
|
||||||
"<div>" +
|
"<a id='" + commentDetails._id + "'>Reply</a>" +
|
||||||
"<h6>" +
|
'</div>' +
|
||||||
"<div class='col-xs-12 negative-15 comment-a-comment'>" +
|
'</div>' +
|
||||||
"commented " + moment(commentDetails.commentedOn).fromNow() + " by " +
|
'</div>' +
|
||||||
"<a href='/" + commentDetails.author.username + "'>@" + commentDetails.author.username + "</a> · " +
|
'</div>'
|
||||||
"<a id='" + commentDetails._id + "'>Reply</a>" +
|
|
||||||
"</div>" +
|
|
||||||
"</h6>" +
|
|
||||||
"</div>" +
|
|
||||||
"</div>" +
|
|
||||||
"</div>"
|
|
||||||
)
|
)
|
||||||
.addClass('comment-wrapper comment_' + commentDetails._id)
|
.addClass('comment-wrapper positive-10')
|
||||||
.appendTo($(containerSelector));
|
.appendTo($(containerSelector));
|
||||||
|
|
||||||
sentinel += commentDetails.comments.length;
|
sentinel += commentDetails.comments.length;
|
||||||
@ -68,8 +63,8 @@
|
|||||||
"<button class='btn btn-small btn-primary' id='submit-comment-to-comment'>Submit</button>" +
|
"<button class='btn btn-small btn-primary' id='submit-comment-to-comment'>Submit</button>" +
|
||||||
"</div>"
|
"</div>"
|
||||||
)
|
)
|
||||||
.addClass('col-xs-6 col-xs-offset-3')
|
.addClass('row')
|
||||||
.appendTo($(this).closest('.comment'));
|
.appendTo($(this).closest('.media-body-wrapper'));
|
||||||
var submitCommentToCommentHandler = function submitCommentToCommentHandler() {
|
var submitCommentToCommentHandler = function submitCommentToCommentHandler() {
|
||||||
$('#submit-comment-to-comment').unbind('click');
|
$('#submit-comment-to-comment').unbind('click');
|
||||||
$.post('/stories/comment/' + commentId + '/comment',
|
$.post('/stories/comment/' + commentId + '/comment',
|
||||||
|
Reference in New Issue
Block a user