PageSourceSearch

https://www.openpolytechnic.ac.nz/_resources/themes/openpolytechnic/javascript/global-search.js?m=1790186485

js openpolytechnic.ac.nz collected 2026-09-24 20:00:30 UTC 1,900 bytes, 64 lines download raw bytes

1$(document).ready(function() {
2    // Selector for all search toggles
3    var $searchToggles = $('.search-toggle-desktop, .search-toggle-mobile');
4    var $searchIcon = $('#searchSubmit');
5    var $section = $('.mobile-header');
6
7    // Toggle search display on search toggle button click
8    $searchToggles.click(function(event) {
9        var $searchBanner = $(this).closest('header, .mobile-header').find('.global-search');
10        var $searchInput = $(this).closest('header, .mobile-header').find('#siteSearchField');
11        // Toggle display and padding
12        if ($searchBanner.css('display') === 'flex') {
13            $searchBanner.hide();
14            $section.removeClass('padding-when-active');
15            $searchInput.blur();
16        } else {
17            $searchBanner.css('display', 'flex');
18            $section.addClass('padding-when-active');
19            $searchInput.focus();
20        }
21        event.stopPropagation();
22    });
23
24    // Close the banner when clicking outside of it
25    $(document).click(function(event) {
26        $('.global-search').each(function() {
27            if (!$(this).is(event.target) && !$(this).has(event.target).length && $(this).css('display') === 'flex') {
28                $(this).hide();
29                $section.removeClass('padding-when-active');
30            }
31        });
32    });
33
34    // Submit the search form on search icon click
35    $searchIcon.click(function() {
36        $(this).closest('.global-search-form').submit();
37    });
38
39    // Close the search banner when pressing the Escape key
40    $(document).keydown(function(event) {
41        if (event.key === "Escape") {
42            $('.global-search').each(function() {
43                if ($(this).css('display') === 'flex') {
44                    $(this).hide();
45                    $section.removeClass('padding-when-active');
46                }
47            });
48        }
49    });
50});
51
52
53
54
55
56
57
58
59
60
61
62
63
64

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.