(drunk) not even done yet
This commit is contained in:
barisusakli
2014-08-16 21:33:42 -04:00
parent 3011491863
commit ca90afd544
14 changed files with 178 additions and 108 deletions

View File

@@ -11,8 +11,8 @@ define('navigator', ['forum/pagination'], function(pagination) {
var count = 0;
navigator.scrollActive = false;
navigator.init = function(selector, count, callback, toTop, toBottom) {
navigator.init = function(selector, count, toTop, toBottom, callback, calculateIndex) {
index = 1;
navigator.selector = selector;
navigator.callback = callback;
toTop = toTop || function() {};
@@ -36,7 +36,13 @@ define('navigator', ['forum/pagination'], function(pagination) {
input.val('');
return;
}
var url = generateUrl(input.val());
var index = parseInt(input.val(), 10);
if (typeof calculateIndex === 'function') {
index = calculateIndex(index, count);
}
var url = generateUrl(index);
input.val('');
$('.pagination-block .dropdown-toggle').trigger('click');
ajaxify.go(url);
@@ -76,12 +82,9 @@ define('navigator', ['forum/pagination'], function(pagination) {
var el = $(this);
if (elementInView(el)) {
index = parseInt(el.attr('data-index'), 10) + 1;
navigator.updateTextAndProgressBar();
if (typeof navigator.callback === 'function') {
navigator.callback(el);
index = navigator.callback(el, count);
navigator.updateTextAndProgressBar();
}
return false;
@@ -147,7 +150,7 @@ define('navigator', ['forum/pagination'], function(pagination) {
return scrollToPid(postIndex, highlight, duration, offset);
}
if(config.usePagination) {
if (config.usePagination) {
if (window.location.search.indexOf('page') !== -1) {
navigator.update();
return;
@@ -162,12 +165,19 @@ define('navigator', ['forum/pagination'], function(pagination) {
} else {
scrollToPid(postIndex, highlight, duration, offset);
}
} else {
navigator.scrollActive = false;
}
};
function scrollToPid(postIndex, highlight, duration, offset) {
var scrollTo = $('#post_anchor_' + postIndex);
if (!scrollTo) {
navigator.scrollActive = false;
return;
}
var done = false;
function animateScroll() {
$('html, body').animate({
@@ -195,7 +205,7 @@ define('navigator', ['forum/pagination'], function(pagination) {
}
}
if ($('#post-container').length && scrollTo.length) {
if ($('#post-container').length) {
animateScroll();
}
}