finish initial rework of profile page with meta pagination

This commit is contained in:
RaidMax
2019-03-29 21:56:56 -05:00
parent 7b8126d57e
commit 8521df85f5
16 changed files with 227 additions and 140 deletions

View File

@ -1,5 +1,6 @@
let loaderOffset = 10;
let loadCount = 10;
let startAt = null;
let isLoaderLoading = false;
let loadUri = '';
let loaderResponseId = '';
@ -19,13 +20,14 @@ function loadMoreItems() {
showLoader();
isLoaderLoading = true;
$.get(loadUri, { offset: loaderOffset, count : loadCount })
$.get(loadUri, { offset: loaderOffset, count: loadCount, startAt: startAt })
.done(function (response) {
$(loaderResponseId).append(response);
if (response.trim().length === 0) {
staleLoader();
}
$(document).trigger("loaderFinished", response);
startAt = $(response).filter('.loader-data-time').last().data('time');
hideLoader();
isLoaderLoading = false;
})
@ -37,47 +39,52 @@ function loadMoreItems() {
}
function setupListeners() {
if ($(loaderResponseId).length === 1) {
/*
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
*/
if ($(loaderResponseId).length === 1) {
/*
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
*/
$('html').bind('mousewheel DOMMouseScroll', function (e) {
var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
$('html').bind('mousewheel DOMMouseScroll', function (e) {
var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
if (delta < 0 && !hasScrollBar) {
loadMoreItems();
}
});
/*
https://stackoverflow.com/questions/3898130/check-if-a-user-has-scrolled-to-the-bottom
*/
var _throttleTimer = null;
var _throttleDelay = 100;
var $window = $(window);
var $document = $(document);
var hasScrollBar = false;
$document.ready(function () {
$window
.off('scroll', ScrollHandler)
.on('scroll', ScrollHandler);
});
function ScrollHandler(e) {
//throttle event:
hasScrollBar = true;
clearTimeout(_throttleTimer);
_throttleTimer = setTimeout(function () {
//do work
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
loadMoreItems();
if (delta < 0 && !hasScrollBar) {
loadMoreItems();
}
});
}, _throttleDelay);
/*
https://stackoverflow.com/questions/3898130/check-if-a-user-has-scrolled-to-the-bottom
*/
var _throttleTimer = null;
var _throttleDelay = 100;
var $window = $(window);
var $document = $(document);
var hasScrollBar = false;
$document.ready(function () {
$window
.off('scroll', ScrollHandler)
.on('scroll', ScrollHandler);
$('.loader-load-more').click(function (e) {
if (!isLoaderLoading) {
loadMoreItems();
}
})
});
function ScrollHandler(e) {
//throttle event:
hasScrollBar = true;
clearTimeout(_throttleTimer);
_throttleTimer = setTimeout(function () {
//do work
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
loadMoreItems();
}
}, _throttleDelay);
}
}
}
}

View File

@ -13,6 +13,7 @@
/*
* load context of chat
*/
$(document).off('click', '.client-message');
$(document).on('click', '.client-message', function (e) {
showLoader();
const location = $(this);
@ -33,6 +34,7 @@
/*
* load info on ban/flag
*/
$(document).off('click', '.automated-penalty-info-detailed');
$(document).on('click', '.automated-penalty-info-detailed', function (e) {
showLoader();
const location = $(this).parent();