mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Switched to spaces
This commit is contained in:
@ -2,103 +2,103 @@ var App = App || {};
|
||||
App.Presenters = App.Presenters || {};
|
||||
|
||||
App.Presenters.GlobalCommentListPresenter = function(
|
||||
_,
|
||||
jQuery,
|
||||
util,
|
||||
auth,
|
||||
promise,
|
||||
pagerPresenter,
|
||||
topNavigationPresenter) {
|
||||
_,
|
||||
jQuery,
|
||||
util,
|
||||
auth,
|
||||
promise,
|
||||
pagerPresenter,
|
||||
topNavigationPresenter) {
|
||||
|
||||
var $el;
|
||||
var privileges;
|
||||
var templates = {};
|
||||
var $el;
|
||||
var privileges;
|
||||
var templates = {};
|
||||
|
||||
function init(params, loaded) {
|
||||
$el = jQuery('#content');
|
||||
topNavigationPresenter.select('comments');
|
||||
function init(params, loaded) {
|
||||
$el = jQuery('#content');
|
||||
topNavigationPresenter.select('comments');
|
||||
|
||||
privileges = {
|
||||
canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts),
|
||||
};
|
||||
privileges = {
|
||||
canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts),
|
||||
};
|
||||
|
||||
promise.wait(
|
||||
util.promiseTemplate('global-comment-list'),
|
||||
util.promiseTemplate('global-comment-list-item'),
|
||||
util.promiseTemplate('post-list-item'))
|
||||
.then(function(listTemplate, listItemTemplate, postTemplate) {
|
||||
templates.list = listTemplate;
|
||||
templates.listItem = listItemTemplate;
|
||||
templates.post = postTemplate;
|
||||
promise.wait(
|
||||
util.promiseTemplate('global-comment-list'),
|
||||
util.promiseTemplate('global-comment-list-item'),
|
||||
util.promiseTemplate('post-list-item'))
|
||||
.then(function(listTemplate, listItemTemplate, postTemplate) {
|
||||
templates.list = listTemplate;
|
||||
templates.listItem = listItemTemplate;
|
||||
templates.post = postTemplate;
|
||||
|
||||
render();
|
||||
loaded();
|
||||
render();
|
||||
loaded();
|
||||
|
||||
pagerPresenter.init({
|
||||
baseUri: '#/comments',
|
||||
backendUri: '/comments',
|
||||
$target: $el.find('.pagination-target'),
|
||||
updateCallback: function($page, data) {
|
||||
renderComments($page, data.entities);
|
||||
},
|
||||
},
|
||||
function() {
|
||||
reinit(params, function() {});
|
||||
});
|
||||
}).fail(function() {
|
||||
console.log(arguments);
|
||||
loaded();
|
||||
});
|
||||
}
|
||||
pagerPresenter.init({
|
||||
baseUri: '#/comments',
|
||||
backendUri: '/comments',
|
||||
$target: $el.find('.pagination-target'),
|
||||
updateCallback: function($page, data) {
|
||||
renderComments($page, data.entities);
|
||||
},
|
||||
},
|
||||
function() {
|
||||
reinit(params, function() {});
|
||||
});
|
||||
}).fail(function() {
|
||||
console.log(arguments);
|
||||
loaded();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function reinit(params, loaded) {
|
||||
pagerPresenter.reinit({query: params.query || {}});
|
||||
loaded();
|
||||
}
|
||||
function reinit(params, loaded) {
|
||||
pagerPresenter.reinit({query: params.query || {}});
|
||||
loaded();
|
||||
}
|
||||
|
||||
function deinit() {
|
||||
pagerPresenter.deinit();
|
||||
}
|
||||
function deinit() {
|
||||
pagerPresenter.deinit();
|
||||
}
|
||||
|
||||
function render() {
|
||||
$el.html(templates.list());
|
||||
}
|
||||
function render() {
|
||||
$el.html(templates.list());
|
||||
}
|
||||
|
||||
function renderComments($page, data) {
|
||||
var $target = $page.find('.posts');
|
||||
_.each(data, function(data) {
|
||||
var post = data.post;
|
||||
var comments = data.comments;
|
||||
function renderComments($page, data) {
|
||||
var $target = $page.find('.posts');
|
||||
_.each(data, function(data) {
|
||||
var post = data.post;
|
||||
var comments = data.comments;
|
||||
|
||||
var $post = jQuery('<li>' + templates.listItem({
|
||||
util: util,
|
||||
post: post,
|
||||
postTemplate: templates.post,
|
||||
canViewPosts: privileges.canViewPosts,
|
||||
}) + '</li>');
|
||||
var $post = jQuery('<li>' + templates.listItem({
|
||||
util: util,
|
||||
post: post,
|
||||
postTemplate: templates.post,
|
||||
canViewPosts: privileges.canViewPosts,
|
||||
}) + '</li>');
|
||||
|
||||
util.loadImagesNicely($post.find('img'));
|
||||
var presenter = App.DI.get('commentListPresenter');
|
||||
util.loadImagesNicely($post.find('img'));
|
||||
var presenter = App.DI.get('commentListPresenter');
|
||||
|
||||
presenter.init({
|
||||
post: post,
|
||||
comments: comments,
|
||||
$target: $post.find('.post-comments-target'),
|
||||
}, function() {
|
||||
presenter.render();
|
||||
});
|
||||
presenter.init({
|
||||
post: post,
|
||||
comments: comments,
|
||||
$target: $post.find('.post-comments-target'),
|
||||
}, function() {
|
||||
presenter.render();
|
||||
});
|
||||
|
||||
$target.append($post);
|
||||
});
|
||||
}
|
||||
$target.append($post);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
reinit: reinit,
|
||||
deinit: deinit,
|
||||
render: render,
|
||||
};
|
||||
return {
|
||||
init: init,
|
||||
reinit: reinit,
|
||||
deinit: deinit,
|
||||
render: render,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user