reduce initial js payload/requests

This commit is contained in:
Barış Soner Uşaklı
2018-11-17 20:50:07 -05:00
parent 0fd5210d37
commit c02d584b53
18 changed files with 505 additions and 479 deletions

View File

@@ -8,12 +8,11 @@ define('forum/topic', [
'forum/topic/events',
'forum/topic/posts',
'forum/topic/images',
'forum/topic/replies',
'navigator',
'sort',
'components',
'storage',
], function (infinitescroll, threadTools, postTools, events, posts, images, replies, navigator, sort, components, storage) {
], function (infinitescroll, threadTools, postTools, events, posts, images, navigator, sort, components, storage) {
var Topic = {};
var currentUrl = '';
@@ -49,7 +48,6 @@ define('forum/topic', [
postTools.init(tid);
threadTools.init(tid);
replies.init(tid);
events.init();
sort.handleSort('topicPostSort', 'user.setTopicSort', 'topic/' + ajaxify.data.slug);
@@ -61,6 +59,7 @@ define('forum/topic', [
addBlockQuoteHandler();
addParentHandler();
addDropupHandler();
addRepliesHandler();
navigator.init('[component="post"]', ajaxify.data.postcount, Topic.toTop, Topic.toBottom, Topic.navigatorCallback, Topic.calculateIndex);
@@ -177,6 +176,15 @@ define('forum/topic', [
});
}
function addRepliesHandler() {
$('[component="topic"]').on('click', '[component="post/reply-count"]', function () {
var btn = $(this);
require(['forum/topic/replies'], function (replies) {
replies.init(btn);
});
});
}
function updateTopicTitle() {
var span = components.get('navbar/title').find('span');
if ($(window).scrollTop() > 50 && span.hasClass('hidden')) {