Node.js based forum software built for the modern web
fix highlight on vanilla, dont replaceState if url didnt change
Baris Soner Usakli36bc2967c27c
diff --git a/public/src/forum/topic.js b/public/src/forum/topic.jsindex 68c6a12471..f10839ec0e 100644--- a/public/src/forum/topic.js+++ b/public/src/forum/topic.js@@ -1,7 +1,8 @@define(['composer', 'forum/pagination'], function(composer, pagination) {var Topic = {},infiniteLoaderActive = false,- scrollingToPost = false;+ scrollingToPost = false,+ currentUrl = '';function showBottomPostBar() {if($('#post-container .post-row').length > 1 || !$('#post-container li[data-index="0"]').length) {@@ -1020,6 +1021,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {$('.posts > .post-row').each(function() {var el = $(this);+if (elementInView(el)) {var index = parseInt(el.attr('data-index'), 10) + 1;if(index === 0) {@@ -1028,13 +1030,16 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {localStorage.setItem("topic:" + templates.get('topic_id') + ":bookmark", el.attr('data-pid'));if (!scrollingToPost) {- if (history.replaceState) {- history.replaceState({- url: window.location.pathname.slice(1) + '#' + el.attr('data-pid')- }, null,- window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid'));- } else {- location.hash = '#' + el.attr('data-pid');+ var newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid')+ if (newUrl !== currentUrl) {+ if (history.replaceState) {+ history.replaceState({+ url: window.location.pathname.slice(1) + '#' + el.attr('data-pid')+ }, null, newUrl);+ } else {+ location.hash = '#' + el.attr('data-pid');+ }+ currentUrl = newUrl;}}}@@ -1105,9 +1110,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {}, duration !== undefined ? duration : 400, function() {scrollingToPost = false;if (highlight) {- scrollTo.parent().addClass('highlight');+ scrollTo.parent().find('.topic-item').addClass('highlight');setTimeout(function() {- scrollTo.parent().removeClass('highlight');+ scrollTo.parent().find('.topic-item').removeClass('highlight');}, 5000);}});diff --git a/public/templates/topic.tpl b/public/templates/topic.tplindex 9dcc7c8b3f..ef0d794d88 100644--- a/public/templates/topic.tpl+++ b/public/templates/topic.tpl@@ -38,7 +38,7 @@</a></div>- <div class="col-md-11 panel panel-default post-block">+ <div class="col-md-11 panel panel-default post-block topic-item"><a class="main-post avatar" href="{relative_path}/user/{posts.userslug}"><img itemprop="image" src="{posts.picture}" align="left" class="img-thumbnail" width=150 height=150 />