diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index 32aca16e..f3cb574f 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -25,7 +25,7 @@ Module.register("alert", { }, getStyles() { - return ["notificationFx.css", "font-awesome.css"]; + return ["notificationFx.css", "font-awesome.css", this.file(`./styles/${this.config.position}.css`)]; }, getTranslations() { @@ -136,21 +136,6 @@ Module.register("alert", { } }, - setPosition(pos) { - //Add css to body depending on the set position for notifications - const sheet = document.createElement("style"); - if (pos === "center") { - sheet.innerHTML = ".ns-box {margin-left: auto; margin-right: auto;text-align: center;}"; - } - if (pos === "right") { - sheet.innerHTML = ".ns-box {margin-left: auto;text-align: right;}"; - } - if (pos === "left") { - sheet.innerHTML = ".ns-box {margin-right: auto;text-align: left;}"; - } - document.body.appendChild(sheet); - }, - notificationReceived(notification, payload, sender) { if (notification === "SHOW_ALERT") { if (typeof payload.type === "undefined") { @@ -168,7 +153,6 @@ Module.register("alert", { start() { this.alerts = {}; - this.setPosition(this.config.position); if (this.config.welcome_message) { if (this.config.welcome_message === true) { this.showNotification({ title: this.translate("sysTitle"), message: this.translate("welcome") }); diff --git a/modules/default/alert/styles/center.css b/modules/default/alert/styles/center.css new file mode 100644 index 00000000..4e8f5e1d --- /dev/null +++ b/modules/default/alert/styles/center.css @@ -0,0 +1,5 @@ +.ns-box { + margin-left: auto; + margin-right: auto; + text-align: center; +} diff --git a/modules/default/alert/styles/left.css b/modules/default/alert/styles/left.css new file mode 100644 index 00000000..86d2746c --- /dev/null +++ b/modules/default/alert/styles/left.css @@ -0,0 +1,4 @@ +.ns-box { + margin-right: auto; + text-align: left; +} diff --git a/modules/default/alert/styles/right.css b/modules/default/alert/styles/right.css new file mode 100644 index 00000000..add9b6f1 --- /dev/null +++ b/modules/default/alert/styles/right.css @@ -0,0 +1,4 @@ +.ns-box { + margin-left: auto; + text-align: right; +}