PageSourceSearch

https://theofficeshop.ca/wp-content/themes/Office-Shop/js/main.js

js theofficeshop.ca collected 2026-10-08 20:39:20 UTC 6,163 bytes, 208 lines download raw bytes

1var siteMenuClone = function() {
2
3    $('.js-clone-nav').each(function() {
4        var $this = $(this);
5        $this.clone().attr('class', 'site-nav-wrap').appendTo('.site-mobile-menu-body');
6    });
7
8
9    setTimeout(function() {
10
11        var counter = 0;
12        $('.site-mobile-menu .has-children').each(function() {
13            var $this = $(this);
14
15            $this.prepend('<span class="arrow-collapse collapsed">');
16
17            $this.find('.arrow-collapse').attr({
18                'data-toggle': 'collapse',
19                'data-target': '#collapseItem' + counter,
20            });
21
22            $this.find('> ul').attr({
23                'class': 'collapse',
24                'id': 'collapseItem' + counter,
25            });
26
27            counter++;
28
29        });
30
31    }, 1000);
32
33    $('body').on('click', '.arrow-collapse', function(e) {
34        var $this = $(this);
35        if ($this.closest('li').find('.collapse').hasClass('show')) {
36            $this.removeClass('active');
37        } else {
38            $this.addClass('active');
39        }
40        e.preventDefault();
41
42    });
43
44    $(window).resize(function() {
45        var $this = $(this),
46            w = $this.width();
47
48        if (w > 768) {
49            if ($('body').hasClass('offcanvas-menu')) {
50                $('body').removeClass('offcanvas-menu');
51            }
52        }
53    })
54
55    $('body').on('click', '.js-menu-toggle', function(e) {
56        var $this = $(this);
57        e.preventDefault();
58
59        if ($('body').hasClass('offcanvas-menu')) {
60            $('body').removeClass('offcanvas-menu');
61            $this.removeClass('active');
62        } else {
63            $('body').addClass('offcanvas-menu');
64            $this.addClass('active');
65        }
66    })
67
68    // click outisde offcanvas
69    $(document).mouseup(function(e) {
70        var container = $(".site-mobile-menu");
71        if (!container.is(e.target) && container.has(e.target).length === 0) {
72            if ($('body').hasClass('offcanvas-menu')) {
73                $('body').removeClass('offcanvas-menu');
74            }
75        }
76    });
77};
78siteMenuClone();
79
80
81
82jQuery(document).ready(function( $ ) {
83
84  // Back to top button
85  $(window).scroll(function() {
86    if ($(this).scrollTop() > 100) {
87      $('.back-to-top').fadeIn('slow');
88    } else {
89      $('.back-to-top').fadeOut('slow');
90    }
91  });
92  $('.back-to-top').click(function(){
93    $('html, body').animate({scrollTop : 0},1500, 'easeInOutExpo');
94    return false;
95  });
96
97  // Header fixed on scroll
98  $(window).scroll(function() {
99    if ($(this).scrollTop() > 100) {
100      $('#header').addClass('header-scrolled');
101    } else {
102      $('#header').removeClass('header-scrolled');
103    }
104  });
105
106  if ($(window).scrollTop() > 100) {
107    $('#header').addClass('header-scrolled');
108  }
109
110  // Real view height for mobile devices
111  if (window.matchMedia("(max-width: 767px)").matches) {
112    $('#intro').css({ height: $(window).height() });
113  }
114
115 
116
117 
118
119  // Mobile Navigation
120  if ($('#nav-menu-container').length) {
121    var $mobile_nav = $('#nav-menu-container').clone().prop({
122      id: 'mobile-nav'
123    });
124    $mobile_nav.find('> ul').attr({
125      'class': '',
126      'id': ''
127    });
128    $('body').append($mobile_nav);
129    $('body').prepend('<button type="button" id="mobile-nav-toggle"><i class="fa fa-bars"></i></button>');
130    $('body').append('<div id="mobile-body-overly"></div>');
131    $('#mobile-nav').find('.menu-has-children').prepend('<i class="fa fa-chevron-down"></i>');
132
133    $(document).on('click', '.menu-has-children i', function(e) {
134      $(this).next().toggleClass('menu-item-active');
135      $(this).nextAll('ul').eq(0).slideToggle();
136      $(this).toggleClass("fa-chevron-up fa-chevron-down");
137    });
138
139    $(document).on('click', '#mobile-nav-toggle', function(e) {
140      $('body').toggleClass('mobile-nav-active');
141      $('#mobile-nav-toggle i').toggleClass('fa-times fa-bars');
142      $('#mobile-body-overly').toggle();
143    });
144
145    $(document).click(function(e) {
146      var container = $("#mobile-nav, #mobile-nav-toggle");
147      if (!container.is(e.target) && container.has(e.target).length === 0) {
148        if ($('body').hasClass('mobile-nav-active')) {
149          $('body').removeClass('mobile-nav-active');
150          $('#mobile-nav-toggle i').toggleClass('fa-times fa-bars');
151          $('#mobile-body-overly').fadeOut();
152        }
153      }
154    });
155  } else if ($("#mobile-nav, #mobile-nav-toggle").length) {
156    $("#mobile-nav, #mobile-nav-toggle").hide();
157  }
158
159  // Smooth scroll for the menu and links with .scrollto classes
160  $('.nav-menu a, #mobile-nav a, .scrollto').on('click', function() {
161    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
162      var target = $(this.hash);
163      if (target.length) {
164        var top_space = 0;
165
166        if ($('#header').length) {
167          top_space = $('#header').outerHeight();
168
169          if( ! $('#header').hasClass('header-fixed') ) {
170            top_space = top_space - 20;
171          }
172        }
173
174        $('html, body').animate({
175          scrollTop: target.offset().top - top_space
176        }, 1500, 'easeInOutExpo');
177
178        if ($(this).parents('.nav-menu').length) {
179          $('.nav-menu .menu-active').removeClass('menu-active');
180          $(this).closest('li').addClass('menu-active');
181        }
182
183        if ($('body').hasClass('mobile-nav-active')) {
184          $('body').removeClass('mobile-nav-active');
185          $('#mobile-nav-toggle i').toggleClass('fa-times fa-bars');
186          $('#mobile-body-overly').fadeOut();
187        }
188        return false;
189      }
190    }
191  });
192
193  
194
195// custom code
196
197var set_product_field = setInterval(() => {
198  if($('body').find('.tieit_form_wrap .product_field').length > 0){
199    var product_field_name = $('body').find('.product_name').text();
200    $('body').find('.tieit_form_wrap .product_field').val(product_field_name);
201    clearInterval(set_product_field);
202  }
203}, 100);
204
205
206});
207
208

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.