mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
fix highlight on vanilla, dont replaceState if url didnt change
This commit is contained in:
@@ -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,14 +1030,17 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
localStorage.setItem("topic:" + templates.get('topic_id') + ":bookmark", el.attr('data-pid'));
|
||||
|
||||
if (!scrollingToPost) {
|
||||
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,
|
||||
window.location.protocol + '//' + window.location.host + window.location.pathname + '#' + el.attr('data-pid'));
|
||||
}, null, newUrl);
|
||||
} else {
|
||||
location.hash = '#' + el.attr('data-pid');
|
||||
}
|
||||
currentUrl = newUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user