From 4c9de6b5c1e2bdfa54a65ce30bd4584db607d464 Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 26 May 2017 09:02:44 +0200 Subject: [PATCH] Implemented notification system --- assets/js/common/notifications.js | 58 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/assets/js/common/notifications.js b/assets/js/common/notifications.js index 01e77536..c4906bb9 100644 --- a/assets/js/common/notifications.js +++ b/assets/js/common/notifications.js @@ -6,33 +6,41 @@ ComunicWeb.common.notificationSystem = { - /** - * Display a notification - * - * @param {String} message The message to show on the screen - * @param {String} notifType Specify the notification type (info, error, success) - * @param {Integer} notifDuration Optionnal, specify how much time the message will appear in seconds - * @param {String} notifTitle The title of the notification - */ - showNotification: function(message, notifType, notifDuration, notifTitle){ - - //Check if a notification type was specified - if(!notifType){ - notifType = "info"; - } + /** + * Display a notification + * + * @param {String} message The message to show on the screen + * @param {String} notifType Specify the notification type (info, danger, success, warning) + * @param {Integer} notifDuration Optionnal, specify how much time the message will appear in seconds + * @param {String} notifTitle The title of the notification + */ + showNotification: function(message, notifType, notifDuration, notifTitle){ + + //Check if a notification type was specified + if(!notifType){ + notifType = "info"; + } - //Check if a notification duration was specified - if(!notifDuration){ - notifDuration = 4; - } + //Check if a notification duration was specified + if(!notifDuration){ + notifDuration = 4; + } - //Check if a notification title was specified - if(!notifTitle){ - notifTitle = ""; - } + //Prepare options + var options = { + message: message, + }; - //DEV - show an alert while no notif system is implemented - alert("notif " + notifType + ": " + message); - } + //Check if any notification title was specified + if(notifTitle){ + options.title = notifTitle; + } + + $.notify(options,{ + // settings + type: notifType, + timer: notifDuration*1000, + }); + } } \ No newline at end of file