Skip to content

Node.js based forum software built for the modern web

closes #2027

barisusakli63a7766ac1a8
diff --git a/public/src/forum/category.js b/public/src/forum/category.js
index 646582abaf..30bcf629f1 100644
--- a/public/src/forum/category.js
+++ b/public/src/forum/category.js
@@ -42,8 +42,8 @@ define('forum/category', ['composer', 'forum/pagination', 'forum/infinitescroll'
var clickedTid = $(this).parents('li.category-item[data-tid]').attr('data-tid');
$('#topics-container li.category-item').each(function(index, el) {
if($(el).offset().top - $(window).scrollTop() > 0) {
- localStorage.setItem('category:bookmark', $(el).attr('data-tid'));
- localStorage.setItem('category:bookmark:clicked', clickedTid);
+ localStorage.setItem('category:' + cid + ':bookmark', $(el).attr('data-tid'));
+ localStorage.setItem('category:' + cid + ':bookmark:clicked', clickedTid);
return false;
}
});
@@ -84,45 +84,53 @@ define('forum/category', ['composer', 'forum/pagination', 'forum/infinitescroll'
$(window).on('action:popstate', function(ev, data) {
if(data.url.indexOf('category/') === 0) {
- var bookmark = localStorage.getItem('category:bookmark');
- var clicked = localStorage.getItem('category:bookmark:clicked');
+ var cid = data.url.match(/^category\/(\d+)/);
+ if (cid && cid[1]) {
+ cid = cid[1];
+ }
+ if (!cid) {
+ return;
+ }
- if (bookmark) {
+ var bookmark = localStorage.getItem('category:' + cid + ':bookmark');
+ var clicked = localStorage.getItem('category:' + cid + ':bookmark:clicked');
- if(config.usePagination) {
- socket.emit('topics.getTidPage', bookmark, function(err, page) {
- if(err) {
- return;
- }
- if(parseInt(page, 10) !== pagination.currentPage) {
- pagination.loadPage(page);
- } else {
- Category.scrollToTopic(bookmark, clicked, 400);
- }
- });
- } else {
+ if (!bookmark) {
+ return;
+ }
- socket.emit('topics.getTidIndex', bookmark, function(err, index) {
- if(err) {
- return;
- }
+ if(config.usePagination) {
+ socket.emit('topics.getTidPage', bookmark, function(err, page) {
+ if (err) {
+ return;
+ }
+ if(parseInt(page, 10) !== pagination.currentPage) {
+ pagination.loadPage(page);
+ } else {
+ Category.scrollToTopic(bookmark, clicked, 400);
+ }
+ });
+ } else {
+ socket.emit('topics.getTidIndex', bookmark, function(err, index) {
+ if (err) {
+ return;
+ }
- if(index === 0) {
- Category.highlightTopic(clicked);
- return;
- }
+ if (index === 0) {
+ Category.highlightTopic(clicked);
+ return;
+ }
- if (index < 0) {
- index = 0;
- }
+ if (index < 0) {
+ index = 0;
+ }
- $('#topics-container').empty();
+ $('#topics-container').empty();
- loadTopicsAfter(index, function() {
- Category.scrollToTopic(bookmark, clicked, 0);
- });
+ loadTopicsAfter(index, function() {
+ Category.scrollToTopic(bookmark, clicked, 0);
});
- }
+ });
}
}
});
diff --git a/public/src/modules/alerts.js b/public/src/modules/alerts.js
index bdf55ae917..60128e848f 100644
--- a/public/src/modules/alerts.js
+++ b/public/src/modules/alerts.js
@@ -6,7 +6,7 @@ define('alerts', function() {
module.alert = function (params) {
params.alert_id = 'alert_button_' + (params.alert_id ? params.alert_id : new Date().getTime());
- params.title = params.title.trim() || '';
+ params.title = params.title ? params.title.trim() || '' : '';
params.message = params.message.trim();
params.location = params.location || 'right-top';