From aecd3b46530287b29b48f61e5fb087f09fe57440 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 25 Jun 2014 16:21:33 -0400 Subject: [PATCH] handlebookmark func --- public/src/forum/topic.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 1c500ee526..005d904e58 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -56,11 +56,26 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT addBlockquoteEllipses($('.topic .post-content > blockquote')); + handleBookmark(tid); + + navigator.init('.posts > .post-row', postCount, Topic.navigatorCallback); + + socket.on('event:new_post', onNewPost); + + $(window).on('scroll', updateTopicTitle); + + $(window).trigger('action:topic.loaded'); + + socket.emit('topics.markAsRead', tid); + socket.emit('topics.increaseViewCount', tid); + }; + + function handleBookmark(tid) { var bookmark = localStorage.getItem('topic:' + tid + ':bookmark'); var postIndex = getPostIndex(); if (postIndex) { scrollTo.scrollToPost(postIndex - 1, true); - } else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1)) && postCount > 1) { + } else if (bookmark && (!config.usePagination || (config.usePagination && pagination.currentPage === 1)) && ajaxify.variables.get('postcount') > 1) { app.alert({ alert_id: 'bookmark', message: '[[topic:bookmark_instructions]]', @@ -74,18 +89,12 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT } }); } + } - navigator.init('.posts > .post-row', postCount, Topic.navigatorCallback); - - socket.on('event:new_post', onNewPost); - - $(window).on('scroll', updateTopicTitle); - - $(window).trigger('action:topic.loaded'); - - socket.emit('topics.markAsRead', tid); - socket.emit('topics.increaseViewCount', tid); - }; + function getPostIndex() { + var parts = window.location.pathname.split('/'); + return parts[4] ? parseInt(parts[4], 10) : 0; + } function handleSorting() { var threadSort = $('.thread-sort'); @@ -102,11 +111,6 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT }); } - function getPostIndex() { - var parts = window.location.pathname.split('/'); - return parts[4] ? parseInt(parts[4], 10) : 0; - } - function showBottomPostBar() { if($('#post-container .post-row').length > 1 || !$('#post-container li[data-index="0"]').length) { $('.bottom-post-bar').removeClass('hide');