2016-06-12 14:04:42 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const views = require('../util/views.js');
|
|
|
|
const CommentListControl = require('../controls/comment_list_control.js');
|
|
|
|
|
|
|
|
class CommentsPageView {
|
|
|
|
constructor() {
|
|
|
|
this._template = views.getTemplate('comments-page');
|
|
|
|
}
|
|
|
|
|
|
|
|
render(ctx) {
|
|
|
|
const target = ctx.target;
|
|
|
|
const source = this._template(ctx);
|
|
|
|
|
|
|
|
for (let post of ctx.results) {
|
2016-06-12 22:18:45 +02:00
|
|
|
post.comments.sort((a, b) => { return b.id - a.id; });
|
2016-06-12 14:04:42 +02:00
|
|
|
new CommentListControl(
|
|
|
|
source.querySelector(
|
|
|
|
`.comments-container[data-for="${post.id}"]`),
|
|
|
|
post.comments);
|
|
|
|
}
|
|
|
|
|
|
|
|
views.showView(target, source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = CommentsPageView;
|