From a55a2bcca0763586eb0d8fb2d3313b71a0f806e2 Mon Sep 17 00:00:00 2001 From: Paul-Vincent Roll Date: Sun, 3 Apr 2016 20:28:51 +0200 Subject: [PATCH 1/3] Use SHOW_ALERT for all type of notifications --- modules/default/alert/README.md | 18 ++++++++++-------- modules/default/alert/alert.js | 23 ++++++++++------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/modules/default/alert/README.md b/modules/default/alert/README.md index 74df29a5..f76549ba 100644 --- a/modules/default/alert/README.md +++ b/modules/default/alert/README.md @@ -70,11 +70,18 @@ The following properties can be configured: ## Developer notes +For notifications use: -### Display notification ``` -self.sendNotification("SHOW_NOTIFICATION", {title: "Hello", message: "This is a test!"}); +self.sendNotification("SHOW_ALERT", {type: "notification"}); ``` +For alerts use: + +``` +self.sendNotification("SHOW_ALERT", {type: "alert"}); +``` + +### Notification params @@ -99,10 +106,7 @@ self.sendNotification("SHOW_NOTIFICATION", {title: "Hello", message: "This is a
-### Display alert -``` -self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!", imageUrl:"url", imageHeight: "30px", timer:2}); -``` +### Alert params @@ -149,8 +153,6 @@ self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!",
- - ## Open Source Licenses ###[NotificationStyles](https://github.com/codrops/NotificationStyles) See [ympanus.net](http://tympanus.net/codrops/licensing/) for license. \ No newline at end of file diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index 73ffcd27..03fcf1c2 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -14,7 +14,7 @@ Module.register('alert',{ // scale|slide|genie|jelly|flip|bouncyflip|exploader alert_effect:"jelly", //time a notification is displayed in seconds - display_time: 3.5, + display_time: 3500, //Position position: "center", //shown at startup @@ -32,18 +32,13 @@ Module.register('alert',{ message : message, layout : "growl", effect : this.config.effect, - ttl: this.config.display_time * 1000 + ttl: this.config.display_time }).show(); }, show_alert: function (params, sender) { var self = this //Set standard params if not provided by module - if (typeof params.timer === 'undefined') { - params.timer = null; - } - else { - params.timer = params.timer * 1000 - } + if (typeof params.timer === 'undefined') { params.timer = null; } if (typeof params.imageHeight === 'undefined') { params.imageHeight = "80px"; } if (typeof params.imageUrl === 'undefined') { params.imageUrl = null; @@ -99,11 +94,13 @@ Module.register('alert',{ }, notificationReceived: function(notification, payload, sender) { - if (notification === 'SHOW_NOTIFICATION') { - this.show_notification(payload) - } - else if (notification === 'SHOW_ALERT') { - this.show_alert(payload, sender) + if (notification === 'SHOW_ALERT') { + if (payload.type == "alert"){ + this.show_alert(payload, sender) + } + else if (payload.type = "notification"){ + this.show_notification(payload) + } } else if (notification === 'HIDE_ALERT') { this.hide_alert(sender) From e323a315e1e9c0e8b836f9134474cb633468d192 Mon Sep 17 00:00:00 2001 From: Paul-Vincent Roll Date: Sun, 3 Apr 2016 20:31:09 +0200 Subject: [PATCH 2/3] README ms not seconds --- modules/default/alert/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/alert/README.md b/modules/default/alert/README.md index f76549ba..81c133db 100644 --- a/modules/default/alert/README.md +++ b/modules/default/alert/README.md @@ -144,7 +144,7 @@ self.sendNotification("SHOW_ALERT", {type: "alert"}); timer (optional) - How long the alert should stay visible in seconds. + How long the alert should stay visible in ms.
Important: If you do not use the timer, it is your duty to hide the alert by using self.sendNotification("HIDE_ALERT");!

Possible values: int float
Default value: none From f931316dc8fc72501caf7122fd5deeffc3421930 Mon Sep 17 00:00:00 2001 From: Paul-Vincent Roll Date: Sun, 3 Apr 2016 20:34:47 +0200 Subject: [PATCH 3/3] No type = alert --- modules/default/alert/README.md | 2 +- modules/default/alert/alert.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/default/alert/README.md b/modules/default/alert/README.md index 81c133db..ced23b42 100644 --- a/modules/default/alert/README.md +++ b/modules/default/alert/README.md @@ -78,7 +78,7 @@ self.sendNotification("SHOW_ALERT", {type: "notification"}); For alerts use: ``` -self.sendNotification("SHOW_ALERT", {type: "alert"}); +self.sendNotification("SHOW_ALERT", {}); ``` ### Notification params diff --git a/modules/default/alert/alert.js b/modules/default/alert/alert.js index 03fcf1c2..dec635c1 100644 --- a/modules/default/alert/alert.js +++ b/modules/default/alert/alert.js @@ -94,6 +94,7 @@ Module.register('alert',{ }, notificationReceived: function(notification, payload, sender) { + if (typeof payload.type === 'undefined') { payload.type = "alert"; } if (notification === 'SHOW_ALERT') { if (payload.type == "alert"){ this.show_alert(payload, sender)