v1.18.x
Baris Soner Usakli 11 years ago
parent f68b692ce4
commit 5759b1b1a2

@ -28,27 +28,14 @@ var ajaxify = {};
} }
}; };
var pagination, paginator_bar;
ajaxify.currentPage = null; ajaxify.currentPage = null;
ajaxify.initialLoad = false; ajaxify.initialLoad = false;
ajaxify.go = function (url, callback, quiet) { ajaxify.go = function (url, callback, quiet) {
// "quiet": If set to true, will not call pushState // "quiet": If set to true, will not call pushState
// start: the following should be set like so: ajaxify.onchange(function(){}); where the code actually belongs
$(window).off('scroll');
app.enterRoom('global'); app.enterRoom('global');
pagination = pagination || document.getElementById('pagination'); $('body').trigger('action:ajaxifying', {url: url});
paginator_bar = pagination ? document.body.querySelector('.progress-container') : undefined;
if (pagination) {
pagination.parentNode.style.display = 'none';
paginator_bar.style.display = 'none';
}
window.onscroll = null;
// end
if ($('#content').hasClass('ajaxifying')) { if ($('#content').hasClass('ajaxifying')) {
templates.cancelRequest(); templates.cancelRequest();

@ -1,7 +1,6 @@
define(['composer', 'forum/pagination'], function(composer, pagination) { define(['composer', 'forum/pagination'], function(composer, pagination) {
var Topic = {}, var Topic = {},
infiniteLoaderActive = false, infiniteLoaderActive = false;
pagination;
function showBottomPostBar() { function showBottomPostBar() {
if($('#post-container .post-row').length > 1 || !$('#post-container li[data-index="0"]').length) { if($('#post-container .post-row').length > 1 || !$('#post-container li[data-index="0"]').length) {
@ -9,6 +8,27 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
} }
} }
$('body').on('action:ajaxifying', function(ev, data) {
if(data.url.indexOf('topic') === 0) {
$('.pagination-block a').on('click', function() {
return false;
});
$('.pagination-block i:first').on('click', function() {
app.scrollToTop();
});
$('.pagination-block i:last').on('click', function() {
app.scrollToBottom();
});
} else {
$(window).off('scroll');
$('.pagination-block').addClass('hide');
}
});
Topic.init = function() { Topic.init = function() {
var expose_tools = templates.get('expose_tools'), var expose_tools = templates.get('expose_tools'),
tid = templates.get('topic_id'), tid = templates.get('topic_id'),
@ -346,6 +366,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
function enableInfiniteLoading() { function enableInfiniteLoading() {
if(!config.usePagination) { if(!config.usePagination) {
$('.pagination-block').removeClass('hide');
app.enableInfiniteLoading(function() { app.enableInfiniteLoading(function() {
if (!infiniteLoaderActive && $('#post-container').children().length) { if (!infiniteLoaderActive && $('#post-container').children().length) {
loadMorePosts(tid, function(posts) { loadMorePosts(tid, function(posts) {
@ -927,39 +948,21 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
} }
} }
window.onscroll = updateHeader; $(window).on('scroll', updateHeader);
}; };
function updateHeader() { function updateHeader() {
if (pagination == null) { var paginationEl = $('#pagination');
$('.pagination-block a').on('click', function() {
return false;
});
jQuery('.pagination-block i:first').on('click', function() {
app.scrollToTop();
});
jQuery('.pagination-block i:last').on('click', function() {
app.scrollToBottom();
});
}
pagination = pagination || document.getElementById('pagination');
var windowHeight = jQuery(window).height(); var windowHeight = jQuery(window).height();
var scrollTop = jQuery(window).scrollTop(); var scrollTop = jQuery(window).scrollTop();
var scrollBottom = scrollTop + windowHeight; var scrollBottom = scrollTop + windowHeight;
var progressBar = $('.progress-bar'); var progressBar = $('.progress-bar');
var progressBarContainer = $('.progress-container');
var tid = templates.get('topic_id'); var tid = templates.get('topic_id');
if(pagination.parentNode)
pagination.parentNode.style.display = 'block';
progressBarContainer.css('display', '');
if (scrollTop < jQuery('.posts > .post-row:first-child').height() && Topic.postCount > 1) { if (scrollTop < jQuery('.posts > .post-row:first-child').height() && Topic.postCount > 1) {
localStorage.removeItem("topic:" + tid + ":bookmark"); localStorage.removeItem("topic:" + tid + ":bookmark");
pagination.innerHTML = '1 out of ' + Topic.postCount; paginationEl.html('1 out of ' + Topic.postCount);
progressBar.width(0); progressBar.width(0);
return; return;
} }
@ -986,14 +989,14 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
smallestNonNegative = Number.MAX_VALUE; smallestNonNegative = Number.MAX_VALUE;
} }
pagination.innerHTML = (this.postnumber-1) + ' out of ' + Topic.postCount; paginationEl.html((this.postnumber-1) + ' out of ' + Topic.postCount);
progressBar.width(((this.postnumber-1) / Topic.postCount * 100) + '%'); progressBar.width(((this.postnumber-1) / Topic.postCount * 100) + '%');
} }
}); });
setTimeout(function() { setTimeout(function() {
if (scrollTop + windowHeight == jQuery(document).height() && !infiniteLoaderActive) { if (scrollTop + windowHeight == jQuery(document).height() && !infiniteLoaderActive) {
pagination.innerHTML = Topic.postCount + ' out of ' + Topic.postCount; paginationEl.html(Topic.postCount + ' out of ' + Topic.postCount);
progressBar.width('100%'); progressBar.width('100%');
} }
}, 100); }, 100);

@ -156,7 +156,7 @@
</li> </li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right pagination-block"> <ul class="nav navbar-nav navbar-right pagination-block hide">
<li class="active"> <li class="active">
<a href="#"> <a href="#">
<i class="fa fa-chevron-up pointer"></i> <i class="fa fa-chevron-up pointer"></i>

Loading…
Cancel
Save