PageSourceSearch

https://hia.com.au//VisualAssets/Global/Scripts/global.js

js hia.com.au collected 2026-10-02 05:20:01 UTC 12,396 bytes, 300 lines download raw bytes

1/*
2 * ---------------------------------------- *
3 * HIA Global JavaScripts                   *
4 * ---------------------------------------- *
5 */
6
7// project namespace
8window.hia || (window.hia = {}); //  hia namespace
9
10(function ($) {
11
12    hia.toggleHeaderVisibility = function toggleHeaderComponentsVisibility() {
13        var $targets = hia.cache.$header.find('#header-main').add(hia.cache.$header.find('.shop-opts'));
14
15        if (hia.cache.$body.find('#TB_window').length || hia.cache.$setLocation.find('section').hasClass('active') || hia.cache.$body.find('.overlayer-window.active').length) {
16            $targets.addClass('hidden');
17
18        } else {
19            $targets.removeClass('hidden');
20        }
21    }
22
23    function mainHeader() {
24        var $searchButton = hia.cache.$header.find('.search-button');
25
26        function showSetLocation() {
27            if (hia.cache.$window.width() < hia.config.breakpoints.GLOBAL_TABLET_WIDTH) {
28                hia.cache.$header.find('.set-location').addClass('active');
29                hia.cache.$body.addClass('set-location-open');
30            }
31
32            hia.cache.$setLocation.find('section, .close').addClass('active');
33            hia.cache.$header.add(hia.cache.$header.find('.search, #top')).removeClass('active');
34            $searchButton.find('button').removeClass('hidden');
35            $searchButton.find('button.close').addClass('hidden');
36
37            setTimeout(function () {
38                hia.cache.$body.add(hia.cache.$html).animate({ scrollTop: 0 });
39            }, 200);
40        }
41
42        // open set location section on load to show error (if present)
43        if (hia.cache.$setLocation.find('.error').css('display') === 'block') {
44            showSetLocation();
45        }
46
47        // show/hide search bar
48        $searchButton.on('click', function (e) {
49            e.preventDefault();
50            hia.cache.$header.find('.search, #top').add(hia.cache.$overlay).add(hia.cache.$header).toggleClass('active');
51            $searchButton.find('button').toggleClass('hidden');
52        });
53
54        // show/hide set location
55        hia.cache.$setLocation.add(hia.cache.$setLocation.children('p')).add(hia.cache.$setLocation.children('p').children('span')).add(hia.cache.$header.find('button.location')).on('click', function (e) {
56            if (e.target !== e.currentTarget) {
57                return;
58            }
59
60            e.preventDefault();
61            showSetLocation();
62        });
63
64        // show/hide login
65        hia.cache.$header.find('.acct button').on('click', function (e) {
66            e.preventDefault();
67
68            if (hia.cache.$header.find('.mobile-menu').hasClass('open')) {
69                hia.cache.$header.find('.mobile-menu').click();
70            }
71
72            hia.cache.$header.find('.acct section').stop().slideToggle('fast');
73            hia.cache.$overlay.toggleClass('active');
74
75            if (hia.cache.$window.width() > hia.config.breakpoints.GLOBAL_TABLET_WIDTH) {
76                hia.cache.$header.toggleClass('active');
77                hia.cache.$header.find('#top').toggleClass('active');
78            } else if (hia.cache.$window.width() <= hia.config.breakpoints.GLOBAL_MOBILE_WIDTH) {
79                hia.cache.$body.toggleClass('no-scroll');
80                $(this).closest('.shop-opts').add(hia.cache.$header).toggleClass('nav-open');
81                hia.cache.$overlay.removeClass('active');
82            }
83        });
84
85        hia.cache.$setLocation.find('.change-location').on('click', function () {
86            hia.cache.$setLocation.find('.location-fieldset').removeClass('hide');
87            hia.cache.$setLocation.find('.form-headers').add($(this)).addClass('hide');
88        });
89
90        hia.cache.$setLocation.find('.close-button, .close').on('click', function () {
91            hia.cache.$body.removeClass('set-location-open');
92            hia.cache.$setLocation.find('.location-container').removeClass('active');
93        });
94    }
95
96    function megaMenu() {
97        var $primaryNav = $(this),
98            $navLinks = $primaryNav.find('.top-level > li'),
99            $backButton = $navLinks.filter('.back-button'),
100            $currentNavLink = $primaryNav.find('.top-level li.current'),
101            $mobileMenu = hia.cache.$header.find('.mobile-menu'),
102            $mainHeader = $primaryNav.closest('#header-main'),
103            $searchButton = hia.cache.$header.find('.search-button'),
104            windowHeight = hia.cache.$window.height(),
105            windowWidth = hia.cache.$window.width();
106
107        function lockScroll() {
108            document.addEventListener('touchmove', stopDefault, { passive: false });
109            hia.cache.$body.on({
110                touchstart: touchstartHandler,
111                touchmove: touchmoveHandler
112            }, '#header-main');
113        }
114
115        function unlockScroll() {
116            document.removeEventListener('touchmove', stopDefault);
117            hia.cache.$body.off({
118                touchstart: touchstartHandler,
119                touchmove: touchmoveHandler
120            });
121        }
122
123        function hideNav() {
124            var $lastLink = $currentNavLink.last();
125
126            if ($currentNavLink.length && $lastLink.find('ul').length) {
127                $navLinks.add($currentNavLink.siblings()).add($currentNavLink).addClass('hidden');
128                $backButton.add($lastLink).removeClass('hidden');
129            } else if ($currentNavLink.length) {
130                $currentNavLink.eq(2).length ? $navLinks.addClass('hidden') : $navLinks.not('.current').addClass('hidden');
131                $lastLink.removeClass('current').closest('li').removeClass('hidden');
132                $lastLink.add($lastLink.find('a')).addClass('active');
133                $lastLink.closest('.current').siblings().addClass('hidden');
134                $backButton.removeClass('hidden');
135            }
136
137            $primaryNav.addClass('hidden');
138            hia.cache.$header.add(hia.cache.$header.closest('section')).removeClass('nav-open');
139            hia.cache.$header.find('.search').removeClass('active');
140            $searchButton.find('button').removeClass('hidden');
141            $searchButton.find('button.close').addClass('hidden');
142
143            $mobileMenu.add($mainHeader).removeClass('open');
144            hia.cache.$body.removeClass('no-scroll');
145            unlockScroll();
146        }
147
148        function stopDefault(e) {
149            e.preventDefault();
150        }
151
152        function touchstartHandler(e) {
153            if (e.currentTarget.scrollTop === 0) {
154                e.currentTarget.scrollTop = 1;
155            } else if (e.currentTarget.scrollHeight === e.currentTarget.scrollTop + e.currentTarget.offsetHeight) {
156                e.currentTarget.scrollTop -= 1;
157            }
158        }
159
160        function touchmoveHandler(e) {
161            if ($(this)[0].scrollHeight > $(this).innerHeight()) {
162                e.stopPropagation();
163            }
164        }
165
166        function displayHeaderElements() {
167
168            // only hide nav on horizontal resize (to account for vertical window height change on mobile devices when scrolling) & reveal on desktop
169            if ((hia.cache.$window.width() <= hia.config.breakpoints.GLOBAL_TABLET_WIDTH && hia.cache.$window.height() === windowHeight && hia.cache.$window.width() !== windowWidth) || (hia.cache.$window.width() <= hia.config.breakpoints.GLOBAL_TABLET_WIDTH && hia.cache.$window.height() !== windowHeight && hia.cache.$window.width() !== windowWidth)) {
170                hideNav();
171            } else if (hia.cache.$window.width() > hia.config.breakpoints.GLOBAL_TABLET_WIDTH) {
172                $navLinks.add($primaryNav).removeClass('hidden').filter('.back-button').addClass('hidden');
173                hia.cache.$header.find('.search').removeClass('active');
174                $searchButton.find('button').removeClass('hidden');
175                $searchButton.find('button.close').addClass('hidden');
176
177                $mobileMenu.add($mainHeader).removeClass('open');
178                hia.cache.$header.add(hia.cache.$header.closest('section')).removeClass('nav-open');
179            }
180
181            windowHeight = hia.cache.$window.height();
182            windowWidth = hia.cache.$window.width();
183        }
184
185        if (hia.cache.$window.width() <= hia.config.breakpoints.GLOBAL_TABLET_WIDTH) {
186            hideNav();
187        }
188
189        hia.cache.$window.on('scroll', function () {
190            if ($('.set-location').outerHeight(true) <= hia.cache.$window.scrollTop() && !$mainHeader.hasClass('hidden')) {
191                hia.cache.$header.addClass('fixed');
192
193            } else {
194                hia.cache.$header.removeClass('fixed');
195            }
196
197            hia.toggleHeaderVisibility();
198        });
199
200        // mobile
201        window.toolkit.resizeTimer.push(displayHeaderElements);
202
203        $mobileMenu.on('click', function (e) {
204            e.preventDefault();
205
206            if ($('#BeforeLogin').is(':visible')) {
207                hia.cache.$header.find('.acct button').click();
208            }
209
210            $mobileMenu.add($mainHeader).toggleClass('open');
211            hia.cache.$header.add(hia.cache.$header.closest('section')).toggleClass('nav-open');
212            hia.cache.$header.find('.search').toggleClass('active');
213            hia.cache.$overlay.removeClass('active');
214            if (hia.cache.$window.width() <= hia.config.breakpoints.GLOBAL_MOBILE_WIDTH) {
215                hia.cache.$body.toggleClass('no-scroll');
216
217                if (hia.cache.$body.hasClass('no-scroll')) {
218                    lockScroll();
219                } else {
220                    unlockScroll();
221                }
222            }
223            $primaryNav.toggleClass('hidden');
224            if (hia.cache.$header.find('.search').find('.error').is(':visible')) {
225                $primaryNav.addClass('search-error');
226            }
227        });
228
229        $primaryNav.find('.back-button').on('click', function (e) {
230            e.preventDefault();
231            window.history.back();
232        });
233    }
234
235    // toggle footer links & back to top
236    function footer() {
237        if (hia.cache.$window.width() <= hia.config.breakpoints.GLOBAL_TABLET_WIDTH) {
238            hia.cache.$footer.find('h4').on('click', function () {
239                $(this).siblings('.second-level').stop().slideToggle('fast');
240            });
241        }
242
243        hia.cache.$footer.find('button.back-to-top').on('click', function (e) {
244            e.preventDefault();
245            hia.cache.$body.add(hia.cache.$html).animate({ scrollTop: '0' });
246        });
247    }
248
249    function paginationEvents() {
250        var $pagination = $(this),
251            $lastPaginationItem = $pagination.find('li').last(),
252            $prevDisabled = $pagination.find('.prev-disabled');
253
254        if ($pagination.find('.prev').length === 0) {
255            $('<li class="prev-disabled"><span></span></li>').insertAfter($pagination.find('li').eq(0));
256
257        } else if ($prevDisabled.length) {
258            $prevDisabled.remove();
259
260        } else if ($lastPaginationItem.hasClass('active')) {
261            $('<li class="next-disabled"><span></span></li>').insertAfter($lastPaginationItem);
262        }
263    }
264
265    $(document).ready(function () {
266
267        $.extend(true, hia, {
268            cache: toolkit.cache,
269            config: toolkit.config
270        });
271
272        // custom config
273        hia.config.breakpoints.GLOBAL_MOBILE_WIDTH = 737;
274        hia.config.breakpoints.GLOBAL_TABLET_WIDTH = 880;
275        hia.config.breakpoints.GLOBAL_WINDOW_HEIGHT = 680;
276
277        // custom cache
278        hia.cache.$header = $('#site-header');
279        hia.cache.$footer = $('#site-footer');
280        hia.cache.$main = $('#main');
281        hia.cache.$overlay = $('#overlay');
282        hia.cache.$setLocation = hia.cache.$header.find('#location');
283
284        hia.cache.$html.removeClass('no-js').addClass('js');
285
286        if (hia.cache.$footer.length) {
287            footer();
288        }
289
290        if (hia.cache.$header.length) {
291            mainHeader();
292        }
293
294        $('#primary-navigation').each(megaMenu);
295
296        $('.pagination').each(paginationEvents);
297
298    });
299
300})(jQuery);

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.