Add reload for some more links

This commit is contained in:
cuom1999 2022-12-16 04:53:37 -06:00
parent 813e7d92ce
commit 87ff346d7f

View file

@ -46,12 +46,14 @@
});
}
function navigateTo($elem) {
function navigateTo($elem, update_sidebar=false) {
var url = $elem.attr('data-href') || $elem.attr('href');
if (url === '#') return;
if (update_sidebar) {
$('.left-sidebar-item').removeClass('active');
$elem.addClass('active');
}
$('.middle-right-content').html(loading_page);
$.get(url, function(data) {
var reload_content = $(data).find('.middle-right-content');
@ -59,10 +61,12 @@
if (reload_content.length) {
window.history.pushState("", "", url);
$('.middle-right-content').html(reload_content.first().html());
$(document).prop('title', $(data).filter('title').text());
MathJax.typeset($('.middle-right-content')[0]);
onWindowReady();
activateBlogBoxOnClick();
$('.xdsoft_datetimepicker').hide();
registerNavigation();
}
else {
window.location.href = url;
@ -70,6 +74,17 @@
});
}
function registerNavigation() {
$('.pagination a').on('click', function(e) {
e.preventDefault();
navigateTo($(this));
})
$('.tabs a').on('click', function(e) {
e.preventDefault();
navigateTo($(this));
})
}
$(function () {
window.addEventListener('popstate', (e) => {
window.location.href = e.currentTarget.location.href;
@ -77,8 +92,9 @@
activateBlogBoxOnClick();
$('.left-sidebar-item').on('click', function() {
navigateTo($(this));
navigateTo($(this), true);
});
registerNavigation();
});
</script>
{% endblock %}