|
|
|
@ -122,9 +122,49 @@ $(document).ready(function() {
|
|
|
|
|
function setupPaginator() {
|
|
|
|
|
function appendPageNumber(ev, data) {
|
|
|
|
|
var el = data.after ? data.after : data.before,
|
|
|
|
|
page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage);
|
|
|
|
|
|
|
|
|
|
el.append('<div class="page-number">' + page + '</div>');
|
|
|
|
|
page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage),
|
|
|
|
|
handle = $('<div class="page-number pointer">' + page + '</div>');
|
|
|
|
|
|
|
|
|
|
el.append(handle);
|
|
|
|
|
|
|
|
|
|
handle.tooltip({
|
|
|
|
|
title: 'Slide to paginate',
|
|
|
|
|
placement: 'left'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var dragging = false, originalY = 0;
|
|
|
|
|
handle.on('mousedown', function(ev) {
|
|
|
|
|
dragging = true;
|
|
|
|
|
originalY = ev.screenY;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('body').on('mouseup', function() {
|
|
|
|
|
dragging = false;
|
|
|
|
|
//handle.css('margin-top', '0px');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('body').on('mousemove', function(ev) {
|
|
|
|
|
if (!dragging) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//handle.css('margin-top', (originalY - ev.screenY) + 'px');
|
|
|
|
|
var distance = originalY - ev.screenY,
|
|
|
|
|
toPage = page - parseInt(distance / 50, 10);
|
|
|
|
|
|
|
|
|
|
if (toPage > ajaxify.data.pageCount) {
|
|
|
|
|
toPage = ajaxify.data.pageCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (toPage < 0) {
|
|
|
|
|
toPage = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handle.html(toPage);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(window).on('action:posts.loading', appendPageNumber);
|
|
|
|
|