szurubooru/public_html/js/Presenters/PostContentPresenter.js

51 lines
991 B
JavaScript
Raw Normal View History

2014-10-22 10:42:15 +02:00
var App = App || {};
App.Presenters = App.Presenters || {};
App.Presenters.PostContentPresenter = function(
util,
2014-10-25 15:02:46 +02:00
promise,
presenterManager,
postNotesPresenter) {
2014-10-22 10:42:15 +02:00
var post;
var templates = {};
var $target;
function init(params, loaded) {
$target = params.$target;
post = params.post;
promise.wait(util.promiseTemplate('post-content'))
.then(function(postContentTemplate) {
templates.postContent = postContentTemplate;
render();
loaded();
2014-10-25 15:02:46 +02:00
presenterManager.initPresenters([
[postNotesPresenter, {post: post, notes: post.notes, $target: $target.find('.post-notes-target')}]],
function() {});
2014-10-22 10:42:15 +02:00
}).fail(function() {
console.log(arguments);
loaded();
});
}
function render() {
$target.html(templates.postContent({post: post}));
}
return {
init: init,
render: render,
};
};
App.DI.register('postContentPresenter', [
'util',
2014-10-25 15:02:46 +02:00
'promise',
'presenterManager',
'postNotesPresenter'],
2014-10-22 10:42:15 +02:00
App.Presenters.PostContentPresenter);