Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1062334 - Update ambient indicator colour
Browse files Browse the repository at this point in the history
  • Loading branch information
albertopq authored and rvandermeulen committed Sep 17, 2014
1 parent 646aaaa commit ea64187
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
12 changes: 9 additions & 3 deletions apps/system/js/notifications.js
Expand Up @@ -401,7 +401,10 @@ var NotificationScreen = {
this.container.querySelector('.priority-notifications') :
this.container.querySelector('.other-notifications');

this.addUnreadNotification();

// We need to animate the ambient indicator when the toast
// timesout, so we skip updating it here, by passing a skip bool
this.addUnreadNotification(true);

var notificationNode = document.createElement('div');
notificationNode.classList.add('notification');
Expand Down Expand Up @@ -648,13 +651,15 @@ var NotificationScreen = {
notification.style.transform = '';
},

addUnreadNotification: function ns_addUnreadNotification() {
addUnreadNotification: function ns_addUnreadNotification(skipUpdate) {
if (UtilityTray.shown) {
return;
}

this.unreadNotifications++;
this.updateNotificationIndicator();
if (!skipUpdate) {
this.updateNotificationIndicator();
}
},

removeUnreadNotification: function ns_removeUnreadNotification() {
Expand All @@ -680,6 +685,7 @@ var NotificationScreen = {

closeToast: function ns_closeToast() {
this.toaster.classList.remove('displayed');
this.updateNotificationIndicator();
},

closeNotification: function ns_closeNotification(notificationNode) {
Expand Down
7 changes: 4 additions & 3 deletions apps/system/style/notifications/notifications.css
Expand Up @@ -119,7 +119,7 @@
opacity: 0;
background-color: #00BCE2;
transform: translateY(-.2rem);
transition: opacity .5s ease .5s, transform 0s ease 1s;
transition: opacity .5s ease .5s, transform 0s ease 1s, background-color 0s ease 1s;
}

#notification-toaster.displayed:after,
Expand All @@ -130,7 +130,7 @@
margin: auto;
border-left: 0.2rem solid transparent;
border-right: 0.2rem solid transparent;
border-top: 0.2rem solid #B3F3FF;
border-top: 0.2rem solid #00d3ff;
bottom: 0;
content: '';
}
Expand All @@ -149,8 +149,9 @@
}

#ambient-indicator.unread {
transition: none;
background-color: #006e86;
transform: translateY(0);
transition: background-color .3s ease .3s;
opacity: 1;
}

Expand Down
29 changes: 29 additions & 0 deletions apps/system/test/unit/notifications_test.js
Expand Up @@ -266,6 +266,26 @@ suite('system/NotificationScreen >', function() {
});
});

suite('addUnreadNotification', function() {
setup(function() {
sinon.spy(NotificationScreen, 'updateNotificationIndicator');
});

teardown(function() {
NotificationScreen.updateNotificationIndicator.restore();
});

test('should update the notifications indicator', function() {
NotificationScreen.addUnreadNotification();
assert.isTrue(NotificationScreen.updateNotificationIndicator.called);
});

test('shouldnt update the notif indicator when skipping', function() {
NotificationScreen.addUnreadNotification(true);
assert.isFalse(NotificationScreen.updateNotificationIndicator.called);
});
});

suite('addNotification >', function() {
test('calling addNotification without icon', function() {
var toasterIcon = NotificationScreen.toasterIcon;
Expand All @@ -279,6 +299,15 @@ suite('system/NotificationScreen >', function() {
assert.isTrue(toasterIcon.hidden);
});

test('doesnt update the ambient indicator', function() {
sinon.spy(NotificationScreen, 'updateNotificationIndicator');
var imgpath = 'http://example.com/test.png';
var detail = {icon: imgpath, title: 'title', detail: 'detail'};
NotificationScreen.addNotification(detail);
assert.isFalse(NotificationScreen.updateNotificationIndicator.called);
NotificationScreen.updateNotificationIndicator.restore();
});

function testNotificationWithDirection(dir) {
var toasterTitle = NotificationScreen.toasterTitle;
var imgpath = 'http://example.com/test.png';
Expand Down

0 comments on commit ea64187

Please sign in to comment.