PageSourceSearch

https://www.naturalpursuitoutdoors.com/files/theme/custom.js?1556830990

js naturalpursuitoutdoors.com collected 2026-10-08 17:09:28 UTC 6,390 bytes, 222 lines download raw bytes

1jQuery(function($) {
2  // Mobile sidebars
3  $.fn.expandableSidebar = function(expandedClass) {
4    var $me = this;
5
6    $me.on('click', function() {
7      if(!$me.hasClass(expandedClass)) {
8        $me.addClass(expandedClass);
9      } else {
10        $me.removeClass(expandedClass);
11      }
12    });
13  }
14
15  // Interval loop
16  $.fn.intervalLoop = function(condition, action, duration, limit) {
17    var counter = 0;
18    var looper = setInterval(function(){
19      if (counter >= limit || $.fn.checkIfElementExists(condition)) {
20        clearInterval(looper);
21      } else {
22        action();
23        counter++;
24      }
25    }, duration);
26  }
27
28  // Check if element exists
29  $.fn.checkIfElementExists = function(selector) {
30    return $(selector).length;
31  }
32
33  var centoController = {
34    init: function(opts) {
35      var base = this;
36
37      base._addClasses();
38
39      // Move Flyout
40      $.fn.intervalLoop('.cento-header #wsite-menus', base._moveFlyout, 100, 15);
41
42      // Move Cart
43      $.fn.intervalLoop('.cento-header #wsite-mini-cart', base._moveCart, 300, 8);
44
45      // Check Cart
46      $.fn.intervalLoop('body.cart-full', base._checkCartItems, 300, 10);
47
48      // Fixed header
49      base._stickyHeader();
50
51      if(!$('body').hasClass('wsite-editor') && $('#wsite-nav-cart-a').length) {
52        $('#wsite-nav-cart-a').html($('#wsite-nav-cart-a').html().replace(/[()]/g, ''));
53      }
54
55      setTimeout(function(){
56        base._attachEvents();
57      }, 800);
58    },
59
60    _addClasses: function() {
61      var base = this;
62
63      // Add fade in class to nav + logo + banner
64      $('body').addClass('fade-in');
65
66      // Add class to nav items with subnav
67      $('.wsite-menu-default').find('li.wsite-menu-item-wrap').each(function(){
68        var $me = $(this);
69
70        if($me.children('.wsite-menu-wrap').length > 0) {
71          $me.addClass('has-submenu');
72          $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-item'));
73        }
74      });
75
76      // Add class to subnav items with subnav
77      $('.wsite-menu').find('li.wsite-menu-subitem-wrap').each(function(){
78        var $me = $(this);
79
80        if($me.children('.wsite-menu-wrap').length > 0) {
81          $me.addClass('has-submenu');
82          $('<span class="icon-caret"></span>').insertAfter($me.children('a.wsite-menu-subitem'));
83        }
84      });
85
86        // Keep subnav open if submenu item is active
87        if ($(window).width() < 1024) {
88          $('li.wsite-menu-subitem-wrap.wsite-nav-current').parents('.wsite-menu-wrap').addClass('open');
89        }
90
91      // Add placeholder text to inputs
92      $('.wsite-form-sublabel').each(function(){
93        var sublabel = $(this).text();
94        $(this).prev('.wsite-form-input').attr('placeholder', sublabel);
95      });
96    },
97
98    _checkCartItems: function() {
99      var base = this;
100      if($('#wsite-mini-cart').find('li.wsite-product-item').length > 0) {
101        $('body').addClass('cart-full');
102      } else {
103        $('body').removeClass('cart-full');
104      }
105    },
106
107    _moveLogin: function() {
108      var loginDetach = $('#member-login').detach();
109      $('.mobile-nav .wsite-menu-default > li:last-child').after(loginDetach);
110    },
111
112    _moveFlyout: function() {
113      var maxheight = $(window).height() - $('.cento-header').outerHeight();
114      var anchor = true;
115
116      $('#wsite-menus .wsite-menu-wrap').each(function() {
117        if ($(this).outerHeight() > maxheight) {
118          anchor = false;
119        }
120      });
121
122      if (anchor) {
123        var move = $("#wsite-menus").detach();
124        $(".desktop-nav .container").append(move);
125      }
126    },
127
128    _moveCart: function() {
129      if ($(window).width() > 1024) {
130        var move = $("#wsite-mini-cart").detach();
131        $(".desktop-nav .container").append(move);
132      }
133    },
134
135    _stickyHeader: function() {
136      if ($(window).width() <= 1024) {
137        $('body:not(.wsite-native-mobile-editor, .wsite-checkout-page) .cento-header').waypoint('sticky');
138      }
139      else {
140        $('body:not(.wsite-native-mobile-editor, .wsite-checkout-page) .desktop-nav').waypoint('sticky');
141      }
142    },
143
144    _attachEvents: function() {
145      var base = this;
146
147      $('.hamburger').on('click', function(e) {
148          e.preventDefault();
149          if (!$('body').hasClass('nav-open')) {
150              $('body').addClass('nav-open');
151          } else {
152              $('body').removeClass('nav-open');
153          }
154      });
155
156      base._checkCartItems();
157      if($('#wsite-nav-cart-a').length) {
158        $('#wsite-nav-cart-a').html($('#wsite-nav-cart-a').html().replace(/[()]/g, ''));
159      }
160
161      // Move cart + login
162      if ($(window).width() <= 1024) {
163        $.fn.intervalLoop('.mobile-nav #member-login', base._moveLogin, 800, 5);
164      }
165
166      var resize;
167
168      $(window).on('resize', function(e) {
169        clearTimeout(resize);
170        resize = setTimeout(function() {
171          $('.sticky-wrapper > div').waypoint('unsticky');
172          base._stickyHeader();
173        }, 800);
174      });
175
176      // Subnav toggle
177      $('li.has-submenu span.icon-caret').on('click', function() {
178          var $me = $(this);
179
180          if($me.siblings('.wsite-menu-wrap').hasClass('open')) {
181              $me.siblings('.wsite-menu-wrap').removeClass('open');
182          } else {
183              $me.siblings('.wsite-menu-wrap').addClass('open');
184          }
185      });
186
187      // Store category dropdown
188      $('.wsite-com-sidebar').expandableSidebar('sidebar-expanded');
189
190      // Search filters dropdown
191      $('#wsite-search-sidebar').expandableSidebar('sidebar-expanded');
192
193      // Init fancybox swipe on mobile
194      if ('ontouchstart' in window) {
195        $('body').on('click', 'a.w-fancybox', function() {
196          base._initSwipeGallery();
197        });
198      }
199    },
200
201    _initSwipeGallery: function() {
202      var base = this;
203
204      setTimeout(function(){
205        var touchGallery = document.getElementsByClassName('fancybox-wrap')[0];
206        var mc = new Hammer(touchGallery);
207        mc.on("panleft panright", function(ev) {
208          if (ev.type == "panleft") {
209            $("a.fancybox-next").trigger("click");
210          } else if (ev.type == "panright") {
211            $("a.fancybox-prev").trigger("click");
212          }
213          base._initSwipeGallery();
214        });
215      }, 500);
216    }
217  }
218
219  $(document).ready(function(){
220    centoController.init();
221  });
222});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.