Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import $ from 'jquery'
  2.  
  3. /* jQuery scripts */
  4. $(document).ready(function() {
  5.     /* Mobile dropdown menu */
  6.     $('.dropdown').on('click tap', function() {
  7.         if ($(this).next().hasClass('opened')) {
  8.             $(this).next().removeClass('opened')
  9.         } else {
  10.             $(this).next().addClass('opened')
  11.         }
  12.     })
  13.  
  14.     /* Mobile animate menu */
  15.     $('.header__main-mobile-btn').on('click tap', function() {
  16.         if ($('.header__mobile').hasClass('opened')) {
  17.             $('.header__mobile').removeClass('opened')
  18.         } else {
  19.             $('.header__mobile').addClass('opened')
  20.         }
  21.     })
  22.  
  23.     function toggleSearchBar() {
  24.         if ($('.header__search-bar').hasClass('opened')) {
  25.             $('.header__search-bar').removeClass('opened')
  26.         } else {
  27.             $('.header__search-bar').addClass('opened')
  28.         }
  29.     }
  30.  
  31.     /* Search button */
  32.     $('.header__main-search-toggle').on('click touched', function(e) {
  33.         e.preventDefault()
  34.         toggleSearchBar()
  35.     })
  36.  
  37.     $('.header__cancel-search').on('click touched', function(e) {
  38.         e.preventDefault()
  39.         toggleSearchBar()
  40.     })
  41.  
  42.     /* Mega menu , menu 1   $('.header__main-menu-item a').hover(function () {
  43.         $(this).parent().find('.header__main-submenu').show()
  44.     },
  45.     function() {
  46.         $(this).parent().find('.header__main-submenu').hide()
  47.     })
  48.  
  49.  
  50.     /* Mega menu, menu 2
  51.     $('.header__main-submenu-item a').hover(function () {
  52.         $(this).parent().find('.header__main-submenu-in').show()
  53.         },
  54.         function() {
  55.         $(this).parent().find('.header__main-submenu-in').hide()
  56.     })
  57. */
  58.  
  59. /*
  60.     $('.menu-collection').hover(function () {
  61.         $(this).parent().find('#collection.header__main-submenu-in').show()
  62.         $(this).parent().find('#age.header__main-submenu-in').hide()
  63.         $(this).parent().find('#brand.header__main-submenu-in').hide()
  64.         $(this).parent().find('#holiday.header__main-submenu-in').hide()       
  65.     },
  66.     function() {
  67.         $(this).parent().find('.header__main-submenu').hide()
  68.     })
  69.  
  70.     $('.menu-age').hover(function () {
  71.         $(this).parent().find('#age.header__main-submenu-in').show()
  72.         $(this).parent().find('#collection.header__main-submenu-in').hide()
  73.         $(this).parent().find('#brand.header__main-submenu-in').hide()
  74.         $(this).parent().find('#holiday.header__main-submenu-in').hide()       
  75.     },
  76.     function() {
  77.         $(this).parent().find('.header__main-submenu').hide()
  78.     })
  79.  
  80.     $('.menu-brand').hover(function () {
  81.         $(this).parent().find('#brand.header__main-submenu-in').show()
  82.         $(this).parent().find('#collection.header__main-submenu-in').hide()
  83.         $(this).parent().find('#age.header__main-submenu-in').hide()
  84.         $(this).parent().find('#holiday.header__main-submenu-in').hide()           
  85.     },
  86.     function() {
  87.         $(this).parent().find('.header__main-submenu').hide()
  88.     })
  89.  
  90.     $('.menu-holiday').hover(function () {
  91.         $(this).parent().find('#holiday.header__main-submenu-in').show()
  92.         $(this).parent().find('#collection.header__main-submenu-in').hide()
  93.         $(this).parent().find('#brand.header__main-submenu-in').hide()
  94.         $(this).parent().find('#age.header__main-submenu-in').hide()           
  95.     },
  96.     function() {
  97.         $(this).parent().find('.header__main-submenu').hide()
  98.     })
  99.  
  100.  
  101. */
  102.  
  103.  
  104.  
  105.  
  106.     $('.header__main-submenu').hover(function () {
  107.         $('.header__main-submenu').show()
  108.     },
  109.     function() {
  110.         $(this).hide()
  111.     })
  112.  
  113.     $('.header__main-submenu-in-item').hover(function () {
  114.         $('.header__main-submenu-products--'+$(this).find('a').attr("data-collection-handle")).css("display", "inline-block")
  115.     },
  116.     function () {
  117.         $('.header__main-submenu-products--'+$(this).find('a').attr("data-collection-handle")).hide()
  118.     })
  119.  
  120.     $('.header__main-submenu-products').hover(function () {
  121.         $(this).css("display", "inline-block")
  122.     },
  123.     function () {
  124.         $(this).hide()
  125.     })
  126.  
  127.     /* Modal's script */
  128.     var modal = $('.header__modal')[0]
  129.  
  130.     $('.headaer__modal-trigger').on('click touched', function(e) {
  131.         e.preventDefault()
  132.  
  133.         $('.header__modal').css('display', 'block')
  134.         $('.header__mobile').removeClass('opened')
  135.     })
  136.  
  137.     $('.header__modal-close').on('click touched', function(e) {
  138.         e.preventDefault()
  139.  
  140.         $('.header__modal').css('display', 'none')
  141.     })
  142.  
  143.     $('.header__modal-exit').on('click touched', function(e) {
  144.         e.preventDefault()
  145.  
  146.         $('.header__modal').css('display', 'none')
  147.     })
  148.  
  149.     window.onclick = function(event) {
  150.         if (event.target === modal) {
  151.             $('.header__modal').css('display', 'none')
  152.         }
  153.     }
  154. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement