szurubooru/client/js/views/comments_page_view.js
rr- 54e3099c56 client/general: refactor control flow
- Controller lifetime is bound to route lifetime
- View lifetime is bound to controller lifetime
- Control lifetime is bound to view lifetime
- Enhanced event dispatching
- Enhanced responsiveness in some places
- Views communicate user input to controllers via new event system
2016-06-18 10:35:20 +02:00

28 lines
795 B
JavaScript

'use strict';
const views = require('../util/views.js');
const CommentListControl = require('../controls/comment_list_control.js');
const template = views.getTemplate('comments-page');
class CommentsPageView {
constructor(ctx) {
this._hostNode = ctx.hostNode;
this._controls = [];
const sourceNode = template(ctx);
for (let post of ctx.results) {
post.comments.sort((a, b) => { return b.id - a.id; });
this._controls.push(
new CommentListControl(
sourceNode.querySelector(
`.comments-container[data-for="${post.id}"]`),
post.comments));
}
views.replaceContent(this._hostNode, sourceNode);
}
}
module.exports = CommentsPageView;