diff --git a/modules/default/alert/README.md b/modules/default/alert/README.md index 2afe63de..e2602acf 100644 --- a/modules/default/alert/README.md +++ b/modules/default/alert/README.md @@ -33,21 +33,29 @@ The following properties can be configured: effect The animation effect to use.
-
Possible values: scale, slide, genie, jelly, flip, exploader & bouncyflip +
Possible values: scale slide genie jelly flip exploader bouncyflip
Default value: slide display_time Time a notification is displayed.
-
Possible values: any int +
Possible values: int +
Default value: 3500 + + + + + position + Position where the notifications should be displayed.
+
Possible values: left center right
Default value: 3500 welcome_message Message shown at startup.
-
Possible values: any string & false +
Possible values: string false
Default value: Welcome, start was successfull! @@ -73,13 +81,13 @@ self.sendNotification("SHOW_NOTIFICATION", {title: "Hello", message: "This is a title The title of the notification.
-
Possible values: text or html as a string +
Possible values: text or html message The message of the notification.
-
Possible values: text or html as a string +
Possible values: text or html @@ -101,40 +109,40 @@ self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!", title The title of the alert.
-
Possible values: text or html as a string +
Possible values: text or html message The message of the alert.
-
Possible values: text or html as a string +
Possible values: text or html type (optional) The type of the alert.
-
Possible values: error, warning, info & success +
Possible values: error warning info success
Default value: none imageUrl (optional) Image to show in the alert
-
Possible values: url as string +
Possible values: url
Default value: none imageSize (optional even with imageUrl set) Size of the image
-
Possible values: "widthxheight" as string +
Possible values: "widthxheight"
Default value: none timer (optional) How long the alert should stay visible.
-
Possible values: any int +
Possible values: int
Default value: none
Important: If you do not use the `timer`, it is your duty to hide the alert by using self.sendNotification("HIDE_ALERT");! diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index 7a7da6fd..46df39d1 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -13,6 +13,8 @@ Module.register('alert',{ effect: "slide", //time a notification is displayed display_time: 3500, + //Position + position: "center", //shown at startup welcome_message: "Welcome, start was successfull!" }, @@ -23,7 +25,7 @@ Module.register('alert',{ return ['ns-default.css', 'sweetalert.css']; }, show_notification: function (message) { - message = "" + message.title + "
" + message.message + "" + message = "" + message.title + "
" + message.message + "" new NotificationFx({ message : message, layout : "growl", @@ -50,6 +52,14 @@ Module.register('alert',{ hide_alert: function () { swal.close() }, + setPosition: function (pos) { + var sheet = document.createElement('style') + if (pos == "center"){sheet.innerHTML = ".ns-box {margin-left: auto; margin-right: auto;}";} + if (pos == "right"){sheet.innerHTML = ".ns-box {margin-left: auto;}";} + if (pos == "left"){sheet.innerHTML = ".ns-box {margin-right: auto;}";} + document.body.appendChild(sheet); + + }, notificationReceived: function(notification, payload, sender) { if (notification === 'SHOW_NOTIFICATION') { this.show_notification(payload) @@ -65,6 +75,7 @@ Module.register('alert',{ if (this.config.welcome_message){ this.show_notification({title: "Welcome", message: this.config.welcome_message}) } + this.setPosition(this.config.position) Log.info('Starting module: ' + this.name); } diff --git a/modules/default/alert/ns-default.css b/modules/default/alert/ns-default.css index a5cb67f7..099d561f 100755 --- a/modules/default/alert/ns-default.css +++ b/modules/default/alert/ns-default.css @@ -5,17 +5,15 @@ background: #fff; padding: 22px; line-height: 1.4; - margin-top: 10px; + margin-bottom: 10px; z-index: 1000; color: black; font-size: 70%; position: relative; - float: left; - clear: both; + display: table; - top: auto; - left: 30px; - + + word-wrap:break-word; max-width: 100%; border-radius: 5px; }