mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
Rename nopaque.toast to nopaque.flash which offers styling by categories
This commit is contained in:
parent
b0c2415f55
commit
3ea1f4bd9f
@ -132,7 +132,7 @@ function recieveResults(response) {
|
|||||||
} else if (response["code"] === 1) {
|
} else if (response["code"] === 1) {
|
||||||
queryResultsTableElement.classList.add("hide");
|
queryResultsTableElement.classList.add("hide");
|
||||||
queryLoadingElement.classList.add("hide");
|
queryLoadingElement.classList.add("hide");
|
||||||
nopaque.toast("Invalid query entered!", "red");
|
nopaque.toast("error", "Invalid query entered!");
|
||||||
console.log("[ERROR] corpus_analysis_init");
|
console.log("[ERROR] corpus_analysis_init");
|
||||||
console.log("Code:" + response["code"]);
|
console.log("Code:" + response["code"]);
|
||||||
return; // no further code execution of this code block
|
return; // no further code execution of this code block
|
||||||
|
@ -166,10 +166,31 @@ nopaque.Navigation.init = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nopaque.flash = function(message, color="") {
|
nopaque.flash = function() {
|
||||||
var toast, toastActionElement;
|
var classes, toast, toastActionElement;
|
||||||
|
|
||||||
toast = M.toast({classes: color,
|
switch (arguments.length) {
|
||||||
|
case 1:
|
||||||
|
category = "message";
|
||||||
|
message = arguments[0];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
category = arguments[0];
|
||||||
|
message = arguments[1];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error("Usage: nopaque.flash(message) or nopaque.flash(category, message)")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (category) {
|
||||||
|
case "error":
|
||||||
|
classes = "red";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
classes = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
toast = M.toast({classes: classes,
|
||||||
html: `<span>${message}</span>
|
html: `<span>${message}</span>
|
||||||
<button data-action="close" class="btn-flat toast-action white-text">
|
<button data-action="close" class="btn-flat toast-action white-text">
|
||||||
<i class="material-icons">close</i>
|
<i class="material-icons">close</i>
|
||||||
@ -196,7 +217,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.flash(nopaque.flashedMessages.shift()[1]);
|
nopaque.flash(...nopaque.flashedMessages.shift());
|
||||||
}
|
}
|
||||||
if (nopaque.user.isAuthenticated) {
|
if (nopaque.user.isAuthenticated) {
|
||||||
if (nopaque.user.settings.darkMode) {
|
if (nopaque.user.settings.darkMode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user