PageSourceSearch

https://vision-forward.org/wp-content/themes/vision_forward_new/js/common.js?ver=999.6

js vision-forward.org collected 2026-10-01 14:41:40 UTC 5,488 bytes, 146 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3    /************* Toggle open search ********************/
4    $('#header-toggle-search, #header-search-modal').click(function () {
5        var search = $('#header-search');
6        if ($(search).hasClass('show')) {
7            $(search).removeClass('show');
8            $('#header-search-modal').removeClass('show');
9            $(document).off('keyup');
10            $("#aria-alert").remove();
11        } else {
12            $(search).addClass('show');
13            $(search).find('.search-field').focus();
14            $('#header-search-modal').addClass('show');
15            $( "<p id=\"aria-alert\" role=\"alert\" class=\"screen-reader-text\">Use Escape Key to hide Search Box and return to page.</p>" ).appendTo( document.body );
16
17            //add escape key to close header search
18            $(document).on('keyup', function(event) {
19                if(event.key == "Escape") {
20                    $(search).removeClass('show');
21                    $('#header-search-modal').removeClass('show');
22                    $(document).off('keyup');
23                    $("#aria-alert").remove();
24                }
25            });
26        }
27    });
28
29    $('#close-search').click(function () {
30        $('#header-search, #header-search-modal').removeClass('show');
31        $(document).off('keyup');
32        $("#aria-alert").remove();
33    });
34
35    //keep focus within search box
36    $('#header-search .search-field').on('keydown', function (event) {
37        if (event.key == "Tab") {
38            event.preventDefault();
39            if (event.shiftKey) {
40                $('#header-search #close-search').focus();
41            } else {
42                $('#header-search .search-submit').focus();
43            }
44        }
45    });
46    $('#header-search #close-search').on('keydown', function (event) {
47        if (event.key == "Tab") {
48            event.preventDefault();
49            if (event.shiftKey) {
50                $('#header-search .search-submit').focus();
51            } else {
52                $('#header-search .search-field').focus();
53            }
54        }
55    });
56    //END: keep focus within search box
57
58    /*** Catch empty searches -- works for any search forms, even if more than one on page ***/
59    $(".search-form").submit(function () {
60
61        var $input = $(this).find('.search-field');
62        if ($input.val() == "") {
63            $input.val(""); //in case a blank space is entered, this allows placeholder to be set.
64            $input.attr("placeholder", "* required");
65            $input.addClass("error");
66            $(this).blur();
67            $( "<p id=\"aria-alert-2\" role=\"alert\" class=\"screen-reader-text\">Please enter a term to search on.</p>" ).appendTo( document.body );
68            return false;
69        }
70    });
71    /*** END: Catch empty searches -- works for any search forms, even if more than one on page ***/
72
73    /**************** scrolling hide/show header for mobile *****************/
74    var didScroll;
75    var lastScrollTop = 0;
76    var delta = 10;
77    var navbarHeight = $('header#masthead').outerHeight();
78
79
80    // on scroll, let the interval function know the user has scrolled
81    $(window).scroll(function (event) {
82        didScroll = true;
83    });
84    // run hasScrolled() and reset didScroll status
85    setInterval(function () {
86        if (didScroll) {
87            hasScrolled();
88            didScroll = false;
89        }
90    }, 250);
91
92    function hasScrolled() {
93        var st = $(this).scrollTop(); //how far from top
94
95
96        if (Math.abs(lastScrollTop - st) <= delta) { //only change if scrolled more than delta of 5 px
97            return;
98        }
99
100        // If current position > last position AND scrolled past navbar...
101        if (st > lastScrollTop && st > navbarHeight) {
102            // Scroll Down
103            $('body').removeClass("scrolled-up").addClass("scrolled-down");
104        } else {
105            // Scroll Up
106            // If did not scroll past the document (possible on mac)...
107            if (st + $(window).height() < $(document).height()) {
108                $('body').removeClass("scrolled-down").addClass("scrolled-up");
109                if (st < navbarHeight) {
110                    $('body').removeClass('scrolled-up'); //at top so desktop header should expand.
111                }
112            }
113        }
114        lastScrollTop = st;
115    }
116
117    /**************** END: scrolling hide/show header for mobile *****************/
118
119    /******************* Forms - tiny labels inside fields when text is set ******************/
120	$('.gform_wrapper .inner-label input, .gform_wrapper .inner-label textarea').focus(function(){
121		$(this).parents('.gfield').addClass('focused');
122	}).focusout(function(){
123		if($(this).val().length == 0){
124			$(this).parents('.gfield').removeClass('focused');
125		}
126	});
127
128		/* after submit if error need to read the focus functions again */
129	jQuery(document).bind('gform_post_render', function(){
130
131		//add focused on all fields alerady set
132		$('.gform_wrapper .inner-label input, .gform_wrapper .inner-label textarea').each( function(){
133			if($(this).val().length > 0){
134				$(this).parents('.gfield').addClass('focused');
135			}
136		}).focus(function(){
137			$(this).parents('.gfield').addClass('focused');
138		}).focusout(function(){
139			if($(this).val().length == 0){
140				$(this).parents('.gfield').removeClass('focused');
141			}
142		});
143	});
144
145	/******************* END: Email Signup bottom - tiny labels inside fields when text is set ******************/
146});

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.