|
|
|
@ -6,7 +6,6 @@ $(document).ready(function() {
|
|
|
|
|
setupNProgress();
|
|
|
|
|
setupTaskbar();
|
|
|
|
|
setupEditedByIcon();
|
|
|
|
|
setupPaginator();
|
|
|
|
|
setupMobileMenu();
|
|
|
|
|
|
|
|
|
|
var env = utils.findBootstrapEnvironment();
|
|
|
|
@ -88,81 +87,13 @@ $(document).ready(function() {
|
|
|
|
|
$(window).on('action:posts.loaded', activateEditedTooltips);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupPaginator() {
|
|
|
|
|
function appendPageNumber(ev, data) {
|
|
|
|
|
var el = data.after ? data.after : data.before;
|
|
|
|
|
if (!el) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage),
|
|
|
|
|
handle = $('<div class="page-number pointer">' + page + '</div>'),
|
|
|
|
|
shadow = $('<div class="shadow"></div>');
|
|
|
|
|
|
|
|
|
|
el.append(handle);
|
|
|
|
|
el.append(shadow);
|
|
|
|
|
|
|
|
|
|
handle.tooltip({
|
|
|
|
|
title: 'Slide to paginate',
|
|
|
|
|
placement: 'auto left'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var dragging = false, originalX = 0, toPage = page;
|
|
|
|
|
handle.on('touchstart', function(ev) {
|
|
|
|
|
dragging = true;
|
|
|
|
|
originalX = ev.originalEvent.touches[0].clientX;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#content').on('touchend', function() {
|
|
|
|
|
if (dragging === true) {
|
|
|
|
|
dragging = false;
|
|
|
|
|
if (page !== toPage) {
|
|
|
|
|
ajaxify.go('topic/' + ajaxify.data.slug + '/' + (toPage * config.postsPerPage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shadow.removeClass('active');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#content').on('touchmove', function(ev) {
|
|
|
|
|
if (!dragging) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var distance = ev.originalEvent.touches[0].clientX - originalX,
|
|
|
|
|
handlePos = parseInt(handle.css('left'), 10),
|
|
|
|
|
postWidth = handle.parents('[component="post"]').width();
|
|
|
|
|
|
|
|
|
|
toPage = Math.ceil((handlePos + distance) / postWidth * ajaxify.data.pageCount);
|
|
|
|
|
|
|
|
|
|
if (toPage >= ajaxify.data.pageCount) {
|
|
|
|
|
toPage = (ajaxify.data.pageCount - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (toPage < 0) {
|
|
|
|
|
toPage = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parseInt(handle.html(), 10) !== toPage) {
|
|
|
|
|
handle.html(toPage);
|
|
|
|
|
handle.removeClass('animated');
|
|
|
|
|
setTimeout(function() { handle.addClass('animated');}, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shadow.addClass('active');
|
|
|
|
|
shadow.css('left', toPage / ajaxify.data.pageCount * postWidth + 'px');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
handle.css('left', page / ajaxify.data.pageCount * handle.parents('[component="post"]').width() + 'px');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(window).on('action:posts.loading', appendPageNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupMobileMenu() {
|
|
|
|
|
if (!window.addEventListener) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#menu').removeClass('hidden');
|
|
|
|
|
|
|
|
|
|
var slideout = new Slideout({
|
|
|
|
|
'panel': document.getElementById('panel'),
|
|
|
|
|
'menu': document.getElementById('menu'),
|
|
|
|
@ -172,7 +103,6 @@ $(document).ready(function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#mobile-menu').on('click', function() {
|
|
|
|
|
$('#menu').show();
|
|
|
|
|
slideout.toggle();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -180,11 +110,7 @@ $(document).ready(function() {
|
|
|
|
|
slideout.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(window).on('resize', function() {
|
|
|
|
|
slideout.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(window).on('action:ajaxify.start', function() {
|
|
|
|
|
$(window).on('resize action:ajaxify.start', function() {
|
|
|
|
|
slideout.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -194,8 +120,6 @@ $(document).ready(function() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openingMenu() {
|
|
|
|
|
$('#menu').show();
|
|
|
|
|
|
|
|
|
|
$('#header-menu').css({
|
|
|
|
|
'top': $(window).scrollTop() + 'px',
|
|
|
|
|
'position': 'absolute'
|
|
|
|
@ -211,9 +135,13 @@ $(document).ready(function() {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
slideout.on('beforeopen', openingMenuAndLoad);
|
|
|
|
|
slideout.on('open', openingMenuAndLoad);
|
|
|
|
|
slideout.on('translate', openingMenu);
|
|
|
|
|
slideout.on('touchmove', function(target) {
|
|
|
|
|
var $target = $(target);
|
|
|
|
|
if ($target.length && ($target.is('code') || $target.parents('code').length)) {
|
|
|
|
|
slideout._preventOpen = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
slideout.on('close', function() {
|
|
|
|
|
$('#header-menu').css({
|
|
|
|
@ -221,7 +149,6 @@ $(document).ready(function() {
|
|
|
|
|
'position': 'fixed'
|
|
|
|
|
});
|
|
|
|
|
$('.slideout-open').removeClass('slideout-open');
|
|
|
|
|
$('#menu').hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#menu [data-section="navigation"] ul').html($('#main-nav').html() + ($('#logged-out-menu').html() || ''));
|
|
|
|
|