mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Change how flashed messages are processed
This commit is contained in:
parent
4af7d8d4ba
commit
ca8d438e79
@ -22,7 +22,7 @@ nopaque.user.isAuthenticated = undefined;
|
|||||||
nopaque.user.settings = {}
|
nopaque.user.settings = {}
|
||||||
nopaque.user.settings.darkMode = undefined;
|
nopaque.user.settings.darkMode = undefined;
|
||||||
|
|
||||||
nopaque.flashedMessages = []
|
nopaque.flashedMessages = undefined;
|
||||||
|
|
||||||
// nopaque functions
|
// nopaque functions
|
||||||
nopaque.socket = {};
|
nopaque.socket = {};
|
||||||
@ -82,14 +82,6 @@ nopaque.socket.init = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
nopaque.Workarounds = {};
|
|
||||||
nopaque.Workarounds.apply = function() {
|
|
||||||
// Disable all option elements with no value
|
|
||||||
for (let optionElement of document.querySelectorAll('option[value=""]')) {
|
|
||||||
optionElement.disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nopaque.Forms = {};
|
nopaque.Forms = {};
|
||||||
nopaque.Forms.init = function() {
|
nopaque.Forms.init = function() {
|
||||||
var abortRequestElement, parentElement, progressElement, progressModal,
|
var abortRequestElement, parentElement, progressElement, progressModal,
|
||||||
@ -174,7 +166,7 @@ nopaque.Navigation.init = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nopaque.toast = function(message, color="") {
|
nopaque.flash = function(message, color="") {
|
||||||
var toast, toastActionElement;
|
var toast, toastActionElement;
|
||||||
|
|
||||||
toast = M.toast({classes: color,
|
toast = M.toast({classes: color,
|
||||||
@ -189,10 +181,14 @@ nopaque.toast = function(message, color="") {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nopaque.toast = nopaque.flash
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
nopaque.Workarounds.apply();
|
// Disable all option elements with no value
|
||||||
|
for (let optionElement of document.querySelectorAll('option[value=""]')) {
|
||||||
|
optionElement.disabled = true;
|
||||||
|
}
|
||||||
M.AutoInit();
|
M.AutoInit();
|
||||||
M.CharacterCounter.init(document.querySelectorAll('input[data-length][type="text"]'));
|
M.CharacterCounter.init(document.querySelectorAll('input[data-length][type="text"]'));
|
||||||
M.Dropdown.init(document.querySelectorAll("#nav-notifications, #nav-account"),
|
M.Dropdown.init(document.querySelectorAll("#nav-notifications, #nav-account"),
|
||||||
@ -200,7 +196,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
nopaque.Forms.init();
|
nopaque.Forms.init();
|
||||||
nopaque.Navigation.init();
|
nopaque.Navigation.init();
|
||||||
while (nopaque.flashedMessages.length) {
|
while (nopaque.flashedMessages.length) {
|
||||||
nopaque.toast(nopaque.flashedMessages.shift().message);
|
nopaque.flash(nopaque.flashedMessages.shift()[1]);
|
||||||
}
|
}
|
||||||
if (nopaque.user.isAuthenticated) {
|
if (nopaque.user.isAuthenticated) {
|
||||||
if (nopaque.user.settings.darkMode) {
|
if (nopaque.user.settings.darkMode) {
|
||||||
|
@ -51,9 +51,7 @@
|
|||||||
<script>
|
<script>
|
||||||
nopaque.user.isAuthenticated = {{ current_user.is_authenticated|tojson }};
|
nopaque.user.isAuthenticated = {{ current_user.is_authenticated|tojson }};
|
||||||
nopaque.user.settings.darkMode = {{ (current_user.is_authenticated and current_user.is_dark)|tojson }};
|
nopaque.user.settings.darkMode = {{ (current_user.is_authenticated and current_user.is_dark)|tojson }};
|
||||||
{% for category, message in get_flashed_messages(with_categories=true) %}
|
nopaque.flashedMessages = {{ get_flashed_messages(with_categories=true)|tojson }};
|
||||||
nopaque.flashedMessages.push({category: {{ category|tojson }}, message: {{ message|tojson }}});
|
|
||||||
{% endfor %}
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user