From 3cee680d9ed4c09cd30838ffd86d3e8467588255 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 26 Jul 2015 13:59:02 -0400 Subject: [PATCH] fix crash on first post closes #100 --- lib/persona.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/persona.js b/lib/persona.js index 6107f7e..11c2c03 100644 --- a/lib/persona.js +++ b/lib/persona.js @@ -70,7 +70,7 @@ $(document).ready(function() { $(window).one('action:taskbar.pushed', function(ev, data) { updateChatCount(data.element); }); - + } else if (!data.element.hasClass('active')) { updateChatCount(data.element); } @@ -121,8 +121,11 @@ $(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), + var el = data.after ? data.after : data.before; + if (!el) { + return; + } + var page = Math.ceil((el.attr('data-index') - 1) / config.postsPerPage), handle = $('
' + page + '
'), shadow = $('
'); @@ -159,7 +162,7 @@ $(document).ready(function() { 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) {