feat(client): Add notification badge

fixes #4365
closes #7755
This commit is contained in:
Luan
2016-07-02 21:38:38 -03:00
committed by Blade Barringer
parent 28ebc92aa9
commit bac1405a20
3 changed files with 36 additions and 0 deletions

View File

@@ -139,6 +139,15 @@
hrpg-button-color-mixin($color-toolbar) hrpg-button-color-mixin($color-toolbar)
> a span.inactive > a span.inactive
opacity: 0.236 !important opacity: 0.236 !important
> a span.notification-counter
background: #428bca
color: #fff
position: absolute
top: -5px
right: -7px
font: bold 12px/12px "Lato", sans-serif
border-radius: 50px
padding: 3px 6px
div div
padding-bottom: 1em padding-bottom: 1em
width: 300px width: 300px

View File

@@ -29,6 +29,32 @@ angular.module('habitrpg')
$scope.clearMessages = Chat.markChatSeen; $scope.clearMessages = Chat.markChatSeen;
$scope.clearCards = Chat.clearCards; $scope.clearCards = Chat.clearCards;
$scope.getNotificationsCount = function() {
var count = 0;
if($scope.user.invitations.party && $scope.user.invitations.party.id){
count++;
}
if($scope.user.purchased.plan && $scope.user.purchased.plan.mysteryItems.length){
count++;
}
if($scope.user.invitations.guilds){
count += $scope.user.invitations.guilds.length;
}
if($scope.user.flags.classSelected && !$scope.user.preferences.disableClasses && $scope.user.stats.points){
count += $scope.user.stats.points > 0 ? 1 : 0;
}
if($scope.user.newMessages) {
count += Object.keys($scope.user.newMessages).length;
}
return count;
};
$scope.iconClasses = function() { $scope.iconClasses = function() {
return selectNotificationValue( return selectNotificationValue(
'glyphicon-gift', 'glyphicon-gift',

View File

@@ -177,6 +177,7 @@ nav.toolbar(ng-controller='MenuCtrl')
li.toolbar-notifs li.toolbar-notifs
a(data-expand-menu, menu='notifs') a(data-expand-menu, menu='notifs')
span.glyphicon(ng-class='iconClasses()') span.glyphicon(ng-class='iconClasses()')
span.notification-counter(ng-if='getNotificationsCount()') {{getNotificationsCount()}}
div(ng-show='_expandedMenu.menu === "notifs"') div(ng-show='_expandedMenu.menu === "notifs"')
h4=env.t('notifications') h4=env.t('notifications')
div div