Add ajax reload to org home

This commit is contained in:
cuom1999 2022-11-25 00:27:39 -06:00
parent 392a39c43e
commit e35f91ca2d
5 changed files with 32 additions and 22 deletions

View file

@ -97,6 +97,7 @@
$(function () {
$('img.unveil').unveil(200);
});
const loading_page = `{% include "loading-page.html" %}`;
</script>
{% endcompress %}

File diff suppressed because one or more lines are too long

View file

@ -14,5 +14,10 @@
$(this).parent().submit();
}
});
$('#control-panel a').on('click', function(e) {
e.preventDefault();
navigateTo($(this));
})
});
</script>

View file

@ -129,32 +129,36 @@
})
$('#logout').on('click', () => $('#logout-form').submit());
}
function navigateTo($elem) {
var url = $elem.attr('data-href') || $elem.attr('href');
if (url === '#') return;
$('.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');
if (reload_content.length) {
window.history.pushState("", "", url);
$('.middle-right-content').html(reload_content.first().html());
MathJax.typeset($('.middle-right-content')[0]);
onWindowReady();
}
else {
window.location.href = url;
}
});
}
$(function () {
const loading_page = `{% include "loading-page.html" %}`;
window.addEventListener('popstate', (e) => {
window.location.href = e.currentTarget.location.href;
});
$('.left-sidebar-item').on('click', function() {
var url = $(this).attr('data-href');
if (url === '#') return;
$('.left-sidebar-item').removeClass('active');
$(this).addClass('active');
$('.middle-right-content').html(loading_page);
$.get(url, function(data) {
var reload_content = $(data).find('.middle-right-content');
if (reload_content.length) {
window.history.pushState("", "", url);
$('.middle-right-content').html(reload_content.first().html());
MathJax.typeset($('.middle-right-content')[0]);
onWindowReady();
}
else {
window.location.href = url;
}
});
navigateTo($(this));
});
$('.blog-box').on('click', function() {
var $description = $(this).children('.blog-description');