PageSourceSearch

https://hamiltoncommercialcleaning.co.nz/theme/site.js

js hamiltoncommercialcleaning.co.nz collected 2026-10-04 01:37:14 UTC 4,786 bytes, 141 lines download raw bytes

1function toggleMenu() {
2    var item = document.getElementById("site-navigation");
3    item.classList.toggle("mobile-nav-open");
4    
5    var body = document.getElementById("site-body");
6    body.classList.toggle("page-scroll-locked");
7    
8    var navOpen = document.getElementById("site-navigation");
9    var navToggle = document.getElementById("nav-toggle");
10    
11    if (navOpen.classList.contains('mobile-nav-open') ) {
12        navToggle.setAttribute("aria-expanded", "true");
13    } else {
14        navToggle.setAttribute("aria-expanded", "false");
15    }
16    
17    // Add event listener to all links inside the menu
18    var menuLinks = document.querySelectorAll("#site-navigation a");
19    for (var i = 0; i < menuLinks.length; i++) {
20        menuLinks[i].addEventListener("click", function() {
21            // Remove the "page-scroll-locked" class from the body element
22            body.classList.remove("page-scroll-locked");
23            // Close the mobile navigation menu by removing the "mobile-nav-open" class
24            item.classList.remove("mobile-nav-open");
25            // Set the "aria-expanded" attribute to "false" to indicate that the menu is closed
26            navToggle.setAttribute("aria-expanded", "false");
27        });
28    }
29}
30
31
32document.getElementById("nav-toggle").addEventListener("click", toggleMenu); 
33
34
35// Gallery Lightbox JS
36
37
38var galleries = document.querySelectorAll('[id*="gallery-"]');
39
40if ( galleries.length !== 0 ) {
41
42    for (i = 0; i < galleries.length; ++i) {
43        var gallery_item = document.querySelectorAll('#' + galleries[i].id.toString() + ' .gallery-item a');
44        
45        for (a = 0; a < gallery_item.length; ++a) {
46            gallery_item[a].classList.add('glightbox');
47            gallery_item[a].setAttribute('data-gallery', 'gallery1');
48        }
49        
50        
51    }
52    document.onreadystatechange = () => {
53        if (document.readyState === 'complete') {
54            const lightbox = GLightbox({
55    			selector:  '.glightbox',
56    			touchNavigation: true,
57    			loop: true,
58    			autoplayVideos: true,
59    		});
60    		
61        }
62    };
63}
64
65
66// To stop the mobile nav getting stuck if the user leaves it open while increasing browser width we want to remove them once the view port exceeds our mobile nav limit.
67function removeMobileClasses(x) {
68  if (x.matches) { // If media query matches
69    
70    var item = document.getElementById("site-navigation");
71    item.classList.remove("mobile-nav-open");
72    
73    var body = document.getElementById("site-body");
74    body.classList.remove("page-scroll-locked");
75    
76    //var body = document.getElementById("site-body");
77    //var class_exists = body.classList.contains('body-sticky-header-height-unset');
78    if (body.classList.contains('body-sticky-header-height-unset')) {
79        var header_height = document.getElementById("masthead");
80        var body_margin = header_height.offsetHeight + "px";
81        body.style.marginTop=body_margin;
82    }
83    
84    
85  }
86
87}
88var x = window.matchMedia("(min-width: 960px)")
89removeMobileClasses(x) // Call listener function at run time
90x.addListener(removeMobileClasses) // Attach listener function on state changes
91
92
93// Check if the Web Share API is supported
94if (navigator.share) {
95  // Share button click event handler
96  const shareBtn = document.querySelector('.share-btn');
97  if (shareBtn) {
98    shareBtn.addEventListener('click', () => {
99      navigator.share({
100        title: document.title,
101        text: document.title,
102        url: window.location.href
103      })
104      .then(() => console.log('Shared successfully.'))
105      .catch((error) => console.log('Error sharing:', error));
106    });
107  }
108} else {
109  // Fallback for browsers that do not support the Web Share API
110  const shareBtn = document.querySelector('.share-btn');
111  if (shareBtn) {
112    shareBtn.addEventListener('click', () => {
113      const shareUrl = window.location.href;
114      const shareFallback = document.querySelector('.share-fallback');
115      let modal = shareFallback.querySelector('.modal');
116      if (!modal) {
117        modal = document.createElement('div');
118        modal.classList.add('modal');
119        modal.innerHTML = `
120          <div class="modal-content">
121            <h2>Share this page</h2>
122            <p>Copy the link below to share this page with your friends:</p>
123            <input type="text" value="${shareUrl}" readonly>
124            <button class="copy-btn">Copy</button>
125          </div>
126        `;
127        shareFallback.appendChild(modal);
128      }
129      const copyBtn = modal.querySelector('.copy-btn');
130      copyBtn.addEventListener('click', () => {
131        const input = modal.querySelector('input');
132        input.select();
133        document.execCommand('copy');
134        copyBtn.textContent = 'Copied!';
135      });
136    });
137  }
138}
139
140
141

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.