Add reload for some more links
This commit is contained in:
parent
813e7d92ce
commit
87ff346d7f
1 changed files with 20 additions and 4 deletions
|
@ -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 %}
|
||||
|
|
Loading…
Reference in a new issue