ComunicWeb/assets/js/common/notifications.js

47 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-02-24 09:48:21 +00:00
/**
* Notification system
*
* @author Pierre HUBERT
*/
ComunicWeb.common.notificationSystem = {
2017-05-26 07:02:44 +00:00
/**
* 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
* @return {Object} Informations about the notification
2017-05-26 07:02:44 +00:00
*/
showNotification: function(message, notifType, notifDuration, notifTitle){
//Check if a notification type was specified
if(!notifType){
notifType = "info";
}
2017-02-24 09:48:21 +00:00
2017-05-26 07:02:44 +00:00
//Check if a notification duration was specified
if(!notifDuration){
notifDuration = 4;
}
2017-02-24 09:48:21 +00:00
2017-05-26 07:02:44 +00:00
//Prepare options
var options = {
message: message,
};
2017-02-24 09:48:21 +00:00
2017-05-26 07:02:44 +00:00
//Check if any notification title was specified
if(notifTitle){
options.title = notifTitle;
}
return $.notify(options,{
2017-05-26 07:02:44 +00:00
// settings
type: notifType,
2017-05-26 07:05:14 +00:00
delay: notifDuration*1000,
2017-05-26 07:02:44 +00:00
});
}
2017-02-24 09:48:21 +00:00
}