Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @file Ações da página 'inicio.html', como abrir e esconder o menu e etc.
- * @author Anderson Feitosa
- */
- window.onload = function() {
- displayQuantityOfNotReadedNotifications();
- };
- const navOpen = document.getElementById('nav_toggle_open');
- const navClose = document.getElementById('nav_toggle_close');
- const sidebar = document.getElementById('navbar_left');
- const overlay = document.getElementsByClassName('overlay');
- /**
- * Responsável por esconder o menu lateral e a opacidade no fundo e chamar as animações dos mesmos.
- */
- function hideSideMenu() {
- sidebar.classList.add('animate-hide');
- overlay[0].style.display = 'none';
- setTimeout(function() {
- sidebar.classList.remove('animate-hide');
- sidebar.style.display = 'none';
- }, 400);
- }
- /**
- * Responsável por chamar a função que exibe o menu lateral e a opacidade no fundo.
- */
- navOpen.addEventListener('click', function() {
- sidebar.style.display = 'block';
- overlay[0].style.display = 'block';
- });
- /**
- * Click EventListener que chama a função 'hideSideMenu'.
- */
- navClose.addEventListener('click', function() {
- hideSideMenu();
- });
- /**
- * Click EventListener que chama a função 'hideSideMenu'.
- */
- overlay[0].addEventListener('click', function() {
- hideSideMenu();
- });
- /**
- * Responsável por verificar no localStorage a quantidade de notificações não lidas.
- */
- function getQuantityOfNotReadedNotifications() {
- const notifications = JSON.parse(localStorage.getItem('notifications')) || [];
- if (notifications.length !== 0) {
- const val = notifications.filter(function(el) {
- return el['readed'] === false;
- });
- return val.length;
- }
- return 0;
- }
- /**
- * Responsável por chamar a função que exibe o número de notificações não lidas para o usuário.
- */
- function displayQuantityOfNotReadedNotifications() {
- const quantityOfNotifications = getQuantityOfNotReadedNotifications();
- if (quantityOfNotifications !== 0) {
- changeHtmlCounter(quantityOfNotifications);
- }
- }
- /**
- * Responsável por mudar o HTML do ícone de notificação, mostrando ao usuário que existem notificações não lidas.
- * @param {number} quantity - Quantidade das noitificação não lidas que vai se exibida no ícone de notificação.
- */
- function changeHtmlCounter(quantity) {
- const span = document.getElementById('cont-notify');
- if (span) {
- span.innerHTML = quantity;
- span.classList.remove('dis-none');
- }
- }
Add Comment
Please, Sign In to add comment