PageSourceSearch

https://www.neighbors1st.com/files/theme/custom.js?1632503681

js neighbors1st.com collected 2026-10-08 21:26:36 UTC 6,032 bytes, 210 lines download raw bytes

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

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.