SHARE
TWEET

Untitled

a guest Aug 23rd, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){
  2.  
  3.   var menuClass = 'header-menu__wrap'; //container ul
  4.  
  5.   var mainmenu = document.getElementById('header-menu'); //container ul
  6.   var mainmenuHeight;
  7.   var button = document.getElementById('button-xs'); //button
  8.   var translateX = -110 + "%";
  9.   var active = true;
  10.   var headerTop = document.querySelectorAll('.header-top')[0];
  11.   var headerbottom = document.querySelectorAll('.header-bottom')[0];
  12.   var body = document.getElementsByTagName('body');
  13.  
  14.   var submenulvl2 = document.querySelectorAll('.header-menu__wrap > li > ul > li > ul');
  15.  
  16.   if (submenulvl2.length > 0) {
  17.     for (var i = 0; submenulvl2.length > i; i++) {
  18.       submenulvl2[i].classList.add("header-submenu__container-level");
  19.     }
  20.   }
  21.  
  22.   button.addEventListener("click", buttonClick);
  23.  
  24.   function buttonClick() {
  25.     if (active) {
  26.       button.classList.add("active");
  27.       active = false;
  28.       body[0].style.overflow = 'hidden';
  29.     } else {
  30.       button.classList.remove("active");
  31.       active = true;
  32.       body[0].removeAttribute('style');
  33.     }
  34.   }
  35.  
  36. /*
  37.   function addFixedMenu(){
  38.     if (pageYOffset > mainmenuHeight) {
  39.       headerTop.classList.add("header-top_fixed");
  40.     } else {
  41.       headerTop.classList.remove("header-top_fixed");
  42.     }
  43.   }
  44. */
  45.  
  46.   if(window.innerWidth >= 768) {
  47.     mainmenuHeight = document.getElementById('header-menu').offsetHeight;
  48.     headerbottom.style.marginTop = mainmenuHeight + "px";
  49.   } else {
  50.     headerbottom.style.marginTop = "0";
  51.   }
  52.  
  53.   window.onresize = function() {
  54.     if(window.innerWidth >= 768) {
  55.       button.classList.remove("active");
  56.       mainmenuHeight = document.getElementById('header-menu').offsetHeight;
  57.       headerbottom.style.marginTop = mainmenuHeight + "px";
  58.     } else {
  59.       headerbottom.style.marginTop = "0";
  60.     }
  61.   };
  62.  
  63. })();
RAW Paste Data
Pastebin PRO Summer Special!
Get 60% OFF on Pastebin PRO accounts!
Top