fix highlight on vanilla, dont replaceState if url didnt change

v1.18.x
Baris Soner Usakli 11 years ago
parent 1ba3acfd03
commit 36bc2967c2

@ -1,7 +1,8 @@
define(['composer', 'forum/pagination'], function(composer, pagination) { define(['composer', 'forum/pagination'], function(composer, pagination) {
var Topic = {}, var Topic = {},
infiniteLoaderActive = false, infiniteLoaderActive = false,
scrollingToPost = false; scrollingToPost = false,
currentUrl = '';
function showBottomPostBar() { function showBottomPostBar() {
if($('#post-container .post-row').length > 1 || !$('#post-container li[data-index="0"]').length) { 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() { $('.posts > .post-row').each(function() {
var el = $(this); var el = $(this);
if (elementInView(el)) { if (elementInView(el)) {
var index = parseInt(el.attr('data-index'), 10) + 1; var index = parseInt(el.attr('data-index'), 10) + 1;
if(index === 0) { if(index === 0) {
@ -1028,14 +1030,17 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
localStorage.setItem("topic:" + templates.get('topic_id') + ":bookmark", el.attr('data-pid')); localStorage.setItem("topic:" + templates.get('topic_id') + ":bookmark", el.attr('data-pid'));
if (!scrollingToPost) { if (!scrollingToPost) {
var newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid')
if (newUrl !== currentUrl) {
if (history.replaceState) { if (history.replaceState) {
history.replaceState({ history.replaceState({
url: window.location.pathname.slice(1) + '#' + el.attr('data-pid') url: window.location.pathname.slice(1) + '#' + el.attr('data-pid')
}, null, }, null, newUrl);
window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid'));
} else { } else {
location.hash = '#' + el.attr('data-pid'); location.hash = '#' + el.attr('data-pid');
} }
currentUrl = newUrl;
}
} }
} }
return false; return false;
@ -1105,9 +1110,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
}, duration !== undefined ? duration : 400, function() { }, duration !== undefined ? duration : 400, function() {
scrollingToPost = false; scrollingToPost = false;
if (highlight) { if (highlight) {
scrollTo.parent().addClass('highlight'); scrollTo.parent().find('.topic-item').addClass('highlight');
setTimeout(function() { setTimeout(function() {
scrollTo.parent().removeClass('highlight'); scrollTo.parent().find('.topic-item').removeClass('highlight');
}, 5000); }, 5000);
} }
}); });

@ -38,7 +38,7 @@
</a> </a>
</div> </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}"> <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 /> <img itemprop="image" src="{posts.picture}" align="left" class="img-thumbnail" width=150 height=150 />

Loading…
Cancel
Save