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