Advertisement
dhiforester

modifikasi.js

Mar 25th, 2021
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. "use strict";
  3. const d = document;
  4. d.addEventListener("DOMContentLoaded", function(event) {
  5.     // options
  6.     const breakpoints = {
  7.         sm: 540,
  8.         md: 720,
  9.         lg: 960,
  10.         xl: 1140
  11.     };
  12.  
  13.     var preloader = d.querySelector('.preloader');
  14.     if(preloader) {
  15.         setTimeout(function() {
  16.             preloader.classList.add('show');
  17.  
  18.             setTimeout(function() {
  19.                 d.querySelector('.loader-element').classList.add('hide');
  20.             }, 200);
  21.         }, 1000);
  22.     }
  23.  
  24.     var iconNotifications = d.querySelector('.icon-notifications');
  25.     if(iconNotifications) {
  26.         var unreadNotifications = d.querySelector('.unread-notifications');
  27.         var bellShake = d.querySelector('.bell-shake');
  28.    
  29.         if (iconNotifications.getAttribute('data-unread-notifications') === 'true') {
  30.             unreadNotifications.style.display = 'block';
  31.         } else {
  32.             unreadNotifications.style.display = 'none';
  33.         }
  34.    
  35.         // bell shake
  36.         var shakingInterval = setInterval(function() {
  37.             if (iconNotifications.getAttribute('data-unread-notifications') === 'true') {
  38.                 if (bellShake.classList.contains('shaking')) {
  39.                     bellShake.classList.remove('shaking');
  40.                 } else {
  41.                     bellShake.classList.add('shaking');
  42.                 }
  43.             }
  44.         }, 5000);
  45.    
  46.         iconNotifications.addEventListener('show.bs.dropdown', function () {
  47.             bellShake.setAttribute('data-unread-notifications', false);
  48.             clearInterval(shakingInterval);
  49.             bellShake.classList.remove('shaking');
  50.             unreadNotifications.style.display = 'none';
  51.         });
  52.     }
  53.  
  54.     [].slice.call(d.querySelectorAll('[data-background]')).map(function(el) {
  55.         el.style.background = 'url(' + el.getAttribute('data-background') + ')';
  56.     });
  57.  
  58.     [].slice.call(d.querySelectorAll('[data-background-lg]')).map(function(el) {
  59.         if(document.body.clientWidth > breakpoints.lg) {
  60.             el.style.background = 'url(' + el.getAttribute('data-background-lg') + ')';
  61.         }
  62.     });
  63.  
  64.     [].slice.call(d.querySelectorAll('[data-background-color]')).map(function(el) {
  65.         el.style.background = 'url(' + el.getAttribute('data-background-color') + ')';
  66.     });
  67.  
  68.     [].slice.call(d.querySelectorAll('[data-color]')).map(function(el) {
  69.         el.style.color = 'url(' + el.getAttribute('data-color') + ')';
  70.     });
  71.  
  72.     // Tooltips
  73.     var tooltipTriggerList = [].slice.call(d.querySelectorAll('[data-toggle="tooltip"]'))
  74.     var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
  75.         return new bootstrap.Tooltip(tooltipTriggerEl)
  76.     })
  77.  
  78.     // Popovers
  79.     var popoverTriggerList = [].slice.call(d.querySelectorAll('[data-toggle="popover"]'))
  80.     var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  81.     return new bootstrap.Popover(popoverTriggerEl)
  82.     })
  83.  
  84.    
  85.  
  86. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement