Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
angular.module('notifications', []).
factory('$notification', ['$timeout',function($timeout){

console.log('notification service online');
// console.log('notification service online');
var notifications = JSON.parse(localStorage.getItem('$notifications')) || [],
queue = [];

Expand Down Expand Up @@ -75,7 +75,7 @@ angular.module('notifications', []).

requestHtml5ModePermissions: function(){
if (window.webkitNotifications){
console.log('notifications are available');
// console.log('notifications are available');
if (window.webkitNotifications.checkPermission() === 0) {
return true;
}
Expand All @@ -97,6 +97,11 @@ angular.module('notifications', []).
}
},

setSetting: function (key, value) {
settings[key] = value;
return settings;
},


/* ============ QUERYING RELATED METHODS ============*/

Expand All @@ -112,7 +117,7 @@ angular.module('notifications', []).
/* ============== NOTIFICATION METHODS ==============*/

info: function(title, content, userData){
console.log(title, content);
// console.log(title, content);
return this.awesomeNotify('info','info', title, content, userData);
},

Expand Down Expand Up @@ -142,29 +147,30 @@ angular.module('notifications', []).
return this.makeNotification(type, false, icon, title, content, userData);
},

notify: function(image, title, content, userData){
notify: function(image, title, content, userData, notificationClass){
// Wraps the makeNotification method for displaying notifications with images
// rather than icons
return this.makeNotification('custom', image, true, title, content, userData);
return this.makeNotification('custom', image, true, title, content, userData, notificationClass);
},

makeNotification: function(type, image, icon, title, content, userData){
makeNotification: function(type, image, icon, title, content, userData, notificationClass){
var notification = {
'type': type,
'image': image,
'icon': icon,
'title': title,
'content': content,
'timestamp': +new Date(),
'userData': userData
'userData': userData,
'notificationClass': notificationClass
};
notifications.push(notification);

if(settings.html5Mode){
html5Notify(image, title, content, function(){
console.log("inner on display function");
// console.log("inner on display function");
}, function(){
console.log("inner on close function");
// console.log("inner on close function");
});
}
else{
Expand Down Expand Up @@ -212,9 +218,8 @@ angular.module('notifications', []).
* Finally, the directive should have its own controller for
* handling all of the notifications from the notification service
*/
console.log('this is a new directive');
var html =
'<div class="dr-notification-wrapper" ng-repeat="noti in queue">' +
'<div class="dr-notification-wrapper {{ noti.notificationClass }}" ng-repeat="noti in queue">' +
'<div class="dr-notification-close-btn" ng-click="removeNotification(noti)">' +
'<i class="icon-remove"></i>' +
'</div>' +
Expand Down