<div class="notifications">
<button class="btn btn-notifications js-btn-modal js-notifications" data-total="" data-modal="notifications">
<div class="svg-wrap">
<svg class="svg" viewBox="0 0 25 25">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-bell"></use>
</svg>
</div>
</button>
<div class="notifications-modal js-modal" data-modal="notifications" data-index="0">
<div class="notifications-modal-inner modal-panel">
<div class="notifications-header">
<div class="tab">
<div class="text">Approvals</div>
</div>
</div>
<div class="approvals-container"></div>
</div>
</div>
</div>
<div class="notifications">
<button class="btn btn-notifications js-btn-modal js-notifications" data-total="" data-modal="notifications">
<div class="svg-wrap">
<svg class="svg" viewBox="0 0 25 25">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-bell"></use>
</svg>
</div>
</button>
<div class="notifications-modal js-modal" data-modal="notifications" data-index="0">
<div class="notifications-modal-inner modal-panel">
<div class="notifications-header">
{{!-- <button class="btn tab tab-notifications js-tab -active" data-tab="notifications"> --}}
<div class="tab">
<div class="text">Approvals</div>
</div>
</div>
<div class="approvals-container"></div>
</div>
</div>
</div>
/* No context defined for this component. */
.notifications {
.btn-notifications {
position: absolute;
top: 0;
right: 0;
width: 20rem;
height: 20rem;
background: $color-irma-slate;
color: white;
transition: background $transition;
&:hover, &:focus {
background: $color-irma-navy;
}
&.-active {
background: $color-irma-navy;
}
&::after {
content: attr(data-total);
position: absolute;
top: 3rem;
right: 3rem;
display: block;
width: 5rem;
height: 5rem;
background: $color-irma-danger;
border-radius: 5rem;
@include font-primary-semibold;
text-align: center;
@include font-size-small;
line-height: 5.6rem;
}
.svg-wrap {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 6rem;
height: 6rem;
.svg {
* {
fill: currentColor;
}
}
}
}
.notifications-modal {
$component-width: 80rem;
$header-height: calc(10rem + 5px);
$border-color: $color-irma-silver;
$background-color: #FAFBFB;
$tab-count: 1;
position: absolute;
top: 20rem;
right: 0;
width: $component-width;
overflow: hidden;
background: $background-color;
visibility: hidden;
opacity: 0;
transition: all $transition;
&.-active {
visibility: visible;
opacity: 1;
}
&.-active {
.notifications-header {
background: $color-irma-navy;
}
}
@for $i from 0 through ($tab-count - 1) {
&[data-index="#{$i}"] {
.notifications-header {
&::after {
transform: translateX(#{$i * $component-width / $tab-count});
}
}
}
}
.notifications-header {
position: relative;
display: flex;
height: $header-height;
background: $color-irma-slate;
color: white;
filter: drop-shadow(0 0 10px rgba(black, 0.14));
&::after {
content: '';
position: absolute;
bottom: 0;
display: block;
height: 5px;
width: (100% / $tab-count);
background: $color-irma-danger;
transition: all 0.3s $ease-out-quad;
}
.tab {
position: relative;
width: (100% / $tab-count);
height: 100%;
text-align: left;
font-size: 0;
&.-active {
.text {
opacity: 1;
}
}
}
.text {
padding: 0 5rem;
opacity: 1;
color: white;
@include font-primary-bold;
text-transform: uppercase;
@include font-size-small;
line-height: $header-height;
transition: opacity 0.3s;
}
}
.tab-panel {
display: none;
max-height: 75rem;
padding: 0;
margin: 0;
overflow-y: auto;
color: $color-irma-slate;
@include font-size-small;
&.-active {
display: block;
}
.list-heading {
padding-bottom: 3rem;
border-bottom: 1px solid $border-color;
.text {
opacity: 0.7;
}
}
ul {
padding: 0;
margin: 0;
list-style-type: none;
}
.list-item {
position: relative;
margin: 0;
border-bottom: 1px solid $border-color;
a {
display: block;
padding: 4rem;
color: inherit;
text-decoration: none;
transition: all $transition;
&.-new {
background: rgba($color-irma-fog, 0.15);
}
&:hover, &:focus {
background: rgba($color-irma-fog, 0.35);
}
}
}
.item-title {
@include font-primary-bold;
@include font-size;
}
.item-description {
margin-top: 1rem;
.text {
opacity: 0.7;
}
}
.item-date {
.text {
opacity: 0.5;
}
}
.load-previous {
padding: 6rem 0;
color: $color-irma-link;
text-decoration: underline;
text-align: center;
}
}
}
.no-results {
padding: 4rem;
}
}
/*
* _notifications.js
*/
irma.notifications = (function () {
'use strict';
var newCount = 0,
approvals = [],
page = 1,
pageLength = 4;
var checkApprovals = function () {
var url = irma.baseURL + "getMyNewApprovalsCount.asp?" + irma.urlParams + "&irmaWebServiceLookupID=" + irma.userId;
$.ajax({
url: url
}).done(function (results) {
if (results.recCount > 0) {
newCount = results.recCount;
getApprovals();
}
else if ($('.approvals-container *').length === 0) {
newCount = 0;
getApprovals();
}
}).fail(function (jqXHR, textStatus) {
irma.logger.postLog(textStatus, url);
});
};
var getApprovals = function () {
var url = irma.baseURL + "getMyApprovals.asp?" + irma.urlParams + "&SearchValue=all&irmaWebServiceLookupID=" + irma.userId;
$.ajax({
url: url
}).done(function (results) {
sortApprovals(results);
}).fail(function (jqXHR, textStatus) {
irma.logger.postLog(textStatus, url);
});
};
var sortApprovals = function (res) {
approvals = [];
var i = 0;
_.forEach(res.data, function (app, i) {
var approval = {
title: app.chrTitle,
source: app.chrSource,
type: app.chrType,
url: app.chrRedirectURL
};
if (i < newCount + 1) {
approval.new = true;
}
approvals.push(approval);
});
var recCount = parseInt(res.recCount);
var context = {
approvals: approvals.slice(0, pageLength),
count: recCount,
noResults: recCount === 0
};
showApprovals(context);
};
var showApprovals = function (context) {
if (approvals.length > page * pageLength) {
context.showButton = true;
}
$.get(irma.assetPath + '/templates/notifications/approvals-list.hbs?v=' + irma.templateVersion, function (template) {
var templateScript = Handlebars.compile(template);
var html = templateScript(context);
$('.notifications .approvals-container').html(html);
$('.js-notifications').attr('data-total', context.count);
});
};
var init = function () {
checkApprovals(irma.userId);
$(document).on('click', '.js-tab', function () {
var name = $(this).data().tab,
$modal = $(this).closest('.notifications-modal'),
$tabs = $modal.find('[data-tab]');
$modal.attr('data-index', $(this).index());
$tabs.removeClass('-active');
$tabs.filter('[data-tab=\'' + name + '\']').addClass('-active');
}).on('click', '.js-notifications', function (e) {
$(this).toggleClass('-active');
if ($(this).is('.-active')) {
checkApprovals();
}
}).on('click', function (e) {
var $target = $(e.target);
if (!($target.is('.js-notifications') || $target.is('.notifications-modal'))) {
$('.js-notifications').removeClass('-active');
}
}).on('click', '.js-more-approvals', function () {
page++;
showApprovals({ approvals: approvals.slice(0, page * pageLength)});
});
};
return {
init: init
};
}());
There are no notes for this item.