Advertisement
artemsemkin

Untitled

Feb 8th, 2022
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Init Template Components
  3.  * only once after the initial
  4.  * page load
  5.  */
  6.  function initComponentsOnce({
  7.   scope = window.$document,
  8.   container = window.$pageWrapper
  9. }) {
  10.  
  11.   const $sliderMenu = scope.find('.js-slider-menu');
  12.  
  13.   // Run cursor follower on non-touch devices
  14.   if (window.kinsey.theme.cursorFollower.enabled && !window.Modernizr.touchevents && window.$cursor.length) {
  15.     window.$html.addClass('cursorfollower');
  16.     window.$cursor.artsCursor({
  17.       target: {
  18.         cursor: '[data-arts-cursor]',
  19.         magnetic: '[data-arts-cursor-magnetic]',
  20.         highlight: 'a:not(a[data-arts-cursor]):not(.social__item a):not(a.page-numbers):not(.js-arts-cursor-no-highlight), .js-arts-cursor-highlight, button:not(button[data-arts-cursor])',
  21.         hideNative: '[data-arts-cursor-hide-native]',
  22.         hideScaleMagnetic: '.slider__dot, .social__item, a.page-numbers',
  23.       },
  24.       elements: {
  25.         follower: '.js-arts-cursor__follower',
  26.         stroke: {
  27.           inner: '.js-arts-cursor__stroke-inner',
  28.           outer: '.js-arts-cursor__stroke-outer',
  29.         },
  30.         arrow: {
  31.           up: '.js-arts-cursor__arrow-up',
  32.           down: '.js-arts-cursor__arrow-down',
  33.           left: '.js-arts-cursor__arrow-left',
  34.           right: '.js-arts-cursor__arrow-right',
  35.         },
  36.         container: {
  37.           label: '.js-arts-cursor__label',
  38.           icon: '.js-arts-cursor__icon'
  39.         }
  40.       },
  41.       effect: window.kinsey.theme.cursorFollower || {}
  42.     });
  43.   } else {
  44.     window.$html.addClass('no-cursorfollower');
  45.   }
  46.  
  47.   // Run AJAX navigation
  48.   if (window.kinsey.theme.ajax.enabled && window.$barbaWrapper.length) {
  49.     new PJAX({
  50.       target: window.$barbaWrapper,
  51.     });
  52.   }
  53.  
  54.   // Run page header
  55.   window.kinsey.theme.header = new Header({
  56.     target: window.$pageHeader,
  57.     scope
  58.   });
  59.  
  60.   if ($sliderMenu.length) {
  61.     $sliderMenu.each(function () {
  62.       new SliderMenu({
  63.         target: $(this),
  64.         scope
  65.       });
  66.     });
  67.   }
  68.  
  69.   // Reset (close) overlay menu when switching
  70.   // from mobile to desktop screen size
  71.   const mqHeader = window.matchMedia('(min-width: 992px');
  72.  
  73.   mqHeader.onchange = (e) => {
  74.     if (e.matches) {
  75.       window.kinsey.theme.header.closeMenu();
  76.     }
  77.   };
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement