Skip to content

Commit 3ab5b37

Browse files
committed
Merge pull request DerekRies#5 from deltaepsilon/master
A bit more flexibility for the custom notifications. Implementing custom... Conflicts: notification.js
2 parents fcecd1e + cfcc60f commit 3ab5b37

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

notification.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
angular.module('notifications', []).
44
factory('$notification', ['$timeout',function($timeout){
55

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

@@ -75,7 +75,7 @@ angular.module('notifications', []).
7575

7676
requestHtml5ModePermissions: function(){
7777
if (window.webkitNotifications){
78-
console.log('notifications are available');
78+
// console.log('notifications are available');
7979
if (window.webkitNotifications.checkPermission() === 0) {
8080
return true;
8181
}
@@ -97,6 +97,11 @@ angular.module('notifications', []).
9797
}
9898
},
9999

100+
setSetting: function (key, value) {
101+
settings[key] = value;
102+
return settings;
103+
},
104+
100105

101106
/* ============ QUERYING RELATED METHODS ============*/
102107

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

114119
info: function(title, content, userData, duration){
115-
console.log(title, content);
116120
return this.awesomeNotify('info','info', title, content, userData, duration);
117121
},
118122

@@ -142,13 +146,13 @@ angular.module('notifications', []).
142146
return this.makeNotification(type, false, icon, title, content, userData, duration);
143147
},
144148

145-
notify: function(image, title, content, userData, duration){
149+
notify: function(image, title, content, userData, duration, notificationClass){
146150
// Wraps the makeNotification method for displaying notifications with images
147151
// rather than icons
148-
return this.makeNotification('custom', image, true, title, content, userData);
152+
return this.makeNotification('custom', image, true, title, content, userData, notificationClass);
149153
},
150154

151-
makeNotification: function(type, image, icon, title, content, userData, duration){
155+
makeNotification: function(type, image, icon, title, content, userData, duration, notificationClass){
152156
var notification = {
153157
'type': type,
154158
'image': image,
@@ -157,17 +161,18 @@ angular.module('notifications', []).
157161
'content': content,
158162
'timestamp': +new Date(),
159163
'userData': userData,
160-
'duration': duration
164+
'duration': duration,
165+
'notificationClass': notificationClass
161166
};
162167
notifications.push(notification);
163168
if(duration == undefined) {
164169
duration = settings[type].duration;
165170
}
166171
if(settings.html5Mode){
167172
html5Notify(image, title, content, function(){
168-
console.log("inner on display function");
173+
// console.log("inner on display function");
169174
}, function(){
170-
console.log("inner on close function");
175+
// console.log("inner on close function");
171176
});
172177
}
173178
else{
@@ -216,9 +221,8 @@ angular.module('notifications', []).
216221
* Finally, the directive should have its own controller for
217222
* handling all of the notifications from the notification service
218223
*/
219-
console.log('this is a new directive');
220224
var html =
221-
'<div class="dr-notification-wrapper" ng-repeat="noti in queue">' +
225+
'<div class="dr-notification-wrapper {{ noti.notificationClass }}" ng-repeat="noti in queue">' +
222226
'<div class="dr-notification-close-btn" ng-click="removeNotification(noti)">' +
223227
'<i class="icon-remove"></i>' +
224228
'</div>' +

0 commit comments

Comments
 (0)