fix crash on first post closes #100

main
barisusakli 10 years ago
parent ed04b6d3c1
commit 3cee680d9e

@ -70,7 +70,7 @@ $(document).ready(function() {
$(window).one('action:taskbar.pushed', function(ev, data) { $(window).one('action:taskbar.pushed', function(ev, data) {
updateChatCount(data.element); updateChatCount(data.element);
}); });
} else if (!data.element.hasClass('active')) { } else if (!data.element.hasClass('active')) {
updateChatCount(data.element); updateChatCount(data.element);
} }
@ -121,8 +121,11 @@ $(document).ready(function() {
function setupPaginator() { function setupPaginator() {
function appendPageNumber(ev, data) { function appendPageNumber(ev, data) {
var el = data.after ? data.after : data.before, var el = data.after ? data.after : data.before;
page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage), if (!el) {
return;
}
var page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage),
handle = $('<div class="page-number pointer">' + page + '</div>'), handle = $('<div class="page-number pointer">' + page + '</div>'),
shadow = $('<div class="shadow"></div>'); shadow = $('<div class="shadow"></div>');
@ -159,7 +162,7 @@ $(document).ready(function() {
var distance = ev.originalEvent.touches[0].clientX - originalX, var distance = ev.originalEvent.touches[0].clientX - originalX,
handlePos = parseInt(handle.css('left'), 10), handlePos = parseInt(handle.css('left'), 10),
postWidth = handle.parents('[component="post"]').width(); postWidth = handle.parents('[component="post"]').width();
toPage = Math.ceil((handlePos + distance) / postWidth * ajaxify.data.pageCount); toPage = Math.ceil((handlePos + distance) / postWidth * ajaxify.data.pageCount);
if (toPage >= ajaxify.data.pageCount) { if (toPage >= ajaxify.data.pageCount) {

Loading…
Cancel
Save