Use seconds instead of ms

This commit is contained in:
Paul-Vincent Roll 2016-04-03 04:03:57 +02:00
parent f8ce8ece1e
commit 67bd6eac99
2 changed files with 15 additions and 10 deletions

View File

@ -45,9 +45,9 @@ The following properties can be configured:
</tr> </tr>
<tr> <tr>
<td><code>display_time</code></td> <td><code>display_time</code></td>
<td>Time a notification is displayed.<br> <td>Time a notification is displayed in seconds.<br>
<br><b>Possible values:</b> <code>int</code> <br><b>Possible values:</b> <code>float</code> <code>int</code>
<br><b>Default value:</b> <code>3500</code> <br><b>Default value:</b> <code>3.5</code>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -140,8 +140,8 @@ self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!",
</tr> </tr>
<tr> <tr>
<td><code>timer</code> (optional)</td> <td><code>timer</code> (optional)</td>
<td>How long the alert should stay visible.<br> <td>How long the alert should stay visible in seconds.<br>
<br><b>Possible values:</b> <code>int</code> <br><b>Possible values:</b> <code>int</code> <code>float</code>
<br><b>Default value:</b> <code>none</code> <br><b>Default value:</b> <code>none</code>
<br><b>Important:</b> If you do not use the `timer`, it is your duty to hide the alert by using <code>self.sendNotification("HIDE_ALERT");</code>! <br><b>Important:</b> If you do not use the `timer`, it is your duty to hide the alert by using <code>self.sendNotification("HIDE_ALERT");</code>!
</td> </td>

View File

@ -13,8 +13,8 @@ Module.register('alert',{
effect: "slide", effect: "slide",
// scale|slide|genie|jelly|flip|bouncyflip|exploader // scale|slide|genie|jelly|flip|bouncyflip|exploader
alert_effect:"jelly", alert_effect:"jelly",
//time a notification is displayed //time a notification is displayed in seconds
display_time: 3500, display_time: 3.5,
//Position //Position
position: "center", position: "center",
//shown at startup //shown at startup
@ -32,13 +32,18 @@ Module.register('alert',{
message : message, message : message,
layout : "growl", layout : "growl",
effect : this.config.effect, effect : this.config.effect,
ttl: this.config.display_time ttl: this.config.display_time * 1000
}).show(); }).show();
}, },
show_alert: function (params, sender) { show_alert: function (params, sender) {
var self = this var self = this
//Set standard params if not provided by module //Set standard params if not provided by module
if (typeof params.timer === 'undefined') { params.timer = null; } if (typeof params.timer === 'undefined') {
params.timer = null;
}
else {
params.timer = params.timer * 1000
}
if (typeof params.imageHeight === 'undefined') { params.imageHeight = "80px"; } if (typeof params.imageHeight === 'undefined') { params.imageHeight = "80px"; }
if (typeof params.imageUrl === 'undefined') { if (typeof params.imageUrl === 'undefined') {
params.imageUrl = null; params.imageUrl = null;
@ -63,7 +68,7 @@ Module.register('alert',{
this.alerts[sender.name] = new NotificationFx({ this.alerts[sender.name] = new NotificationFx({
message : image + message, message : image + message,
effect : this.config.alert_effect, effect : this.config.alert_effect,
ttl: null, ttl: params.timer,
al_no: "ns-alert" al_no: "ns-alert"
}); });
//Show alert //Show alert