Added app.preload module to be able to add preload methods for other UI modules

This commit is contained in:
Niko 2022-02-23 15:49:54 +01:00
parent 4e3501ce37
commit f273506d9d
3 changed files with 9 additions and 2 deletions

View File

@ -396,6 +396,13 @@ function scriptPageHandler(modname, cfg) {
app.hashHandlers.push(cfg);
}
app.preload = {
quiz: function() {
app.script('pages.quiz');
app.template.load('quiz.index');
},
}
window.onload = function(e) {
dayjs.extend(window.dayjs_plugin_relativeTime);
dayjs.extend(window.dayjs_plugin_updateLocale);

View File

@ -10,7 +10,7 @@ app.pages.home = {
await app.template.loadMany(['home.quiz_item']);
app.pages.home.data.quizs = json;
app.pages.home.paint('quizs', json);
app.template.load('quiz.index');
app.preload.quiz();
});
});
},

View File

@ -231,7 +231,7 @@ app.pages.meet = {
if (typeof current.quiz_id === 'string') {
document.getElementById('meet-action-crush').style.display = 'none';
document.getElementById('meet-action-quiz').style.removeProperty('display');
app.template.load('quiz.index');
app.preload.quiz();
} else {
document.getElementById('meet-action-crush').style.removeProperty('display');
document.getElementById('meet-action-quiz').style.display = 'none';