Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
feat(notifications): begin implementing multiple notifications support
Browse files Browse the repository at this point in the history
  • Loading branch information
paglias committed Sep 29, 2014
1 parent fb550cb commit 6fb8bc3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions scripts/controllers/tasksCtrl.js
Expand Up @@ -57,6 +57,11 @@ habitrpg
.controller('TasksCtrl',
['$scope', '$rootScope', 'filterFilter', 'User', 'Notification', '$state', '$ionicActionSheet',
function($scope, $rootScope, filterFilter, User, Notification, $state, $ionicActionSheet) {
Notification.push({type: 'text', text: 'Notification at ' + Date.now()});
Notification.push({type: 'text', text: 'Notification at ' + Date.now()});
Notification.push({type: 'text', text: 'Notification at ' + Date.now()});
Notification.push({type: 'text', text: 'Notification at ' + Date.now()});
Notification.push({type: 'text', text: 'Notification at ' + Date.now()});

$scope.newTask = {};

Expand Down
14 changes: 9 additions & 5 deletions scripts/services/notificationServices.js
@@ -1,7 +1,7 @@
angular.module('notificationServices', []).
factory('Notification', ['$filter','$rootScope', '$timeout', function ($filter,$rootScope, $timeout) {

$rootScope.notification = {type:null,data:null};
$rootScope.notifications = [];
var active = false;
var timer = null;
var goldFilter = $filter('gold');
Expand All @@ -27,8 +27,8 @@ angular.module('notificationServices', []).
},

push: function (message) {
var notif = $rootScope.notification.data = {};
$rootScope.notification.type = message.type;
var notif = {};
notif.type = message.type;
switch(message.type) {
case 'stats':
if (message.stats.gp) {
Expand All @@ -41,11 +41,15 @@ angular.module('notificationServices', []).
notif.hp = message.stats.hp.toFixed(2)
break;
case 'text':
$rootScope.notification.data = message.text;
notif.data = message.text;
break;
}

this.animate()
$rootScope.notifications.push(notif);

$timeout(function(){
$rootScope.notifications.pop();
}, 2000);
},

get: function () {
Expand Down
3 changes: 2 additions & 1 deletion views/notifications.jade
@@ -1,5 +1,6 @@
// Notifications
.bar.bar-header.bar-energized.notif-bar(ng-show='notification.type')
.bar.bar-header.bar-energized.notif-bar(ng-repeat="notification in notifications",
style='margin-top: {{($index * 44) +"px"}}')
h1.title
span(ng-if='notification.type=="text"', ng-bind-html='notification.data')
span(ng-if='notification.type=="stats"')
Expand Down

0 comments on commit 6fb8bc3

Please sign in to comment.