PageSourceSearch

https://www.trincoll.edu/wp-content/themes/trinity/primary/js/custom.js?ver=20210910

js trincoll.edu collected 2026-10-01 08:28:03 UTC 5,903 bytes, 214 lines download raw bytes

1// JQS: javascript Query Search
2const JQS = (function(a) {
3    if (a == "") return {};
4    var b = {};
5    for (var i = 0; i < a.length; ++i)
6    {
7        var p=a[i].split('=', 2);
8        if (p.length == 1)
9            b[p[0]] = "";
10        else
11            b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
12    }
13    return b;
14})(window.location.search.substr(1).split('&'));
15
16function resetSearchFooter() {
17   jQuery("#tric_nav_bar_search .site_search_input").val('');
18}
19/*-------------------------------------------
20	search page functionality
21-------------------------------------------*/
22/* if it is default search page or the custom search page on information-services blog */
23
24if (
25		(
26			window.location.pathname == '/' ||
27			window.location.pathname == '/lits' ||
28			window.location.pathname == '/lits/' ||
29			window.location.pathname == '/information-services/')
30
31	&& typeof JQS['s'] != 'undefined') {
32	// console.log('debug: search-page');
33	(function() {
34		var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
35		var element = document.querySelector('.trinity-google-custom-search');
36		if (element) {
37			var observer = new MutationObserver(function (mutations) {
38				mutations.forEach(function (mutation) {
39					if (mutation.addedNodes.length) {
40						var input = document.querySelector('input.gsc-input');
41						if (input) {
42							var value = typeof JQS['s'] != 'undefined' ? JQS['s'] : '';
43							google.search.cse.element.getElement('storesearch').prefillQuery(value);
44							google.search.cse.element.getElement('storesearch').execute();
45						}
46					}
47				});
48			});
49		}
50
51		observer.observe(element, {
52			attributes: true,
53			childList: true
54		});
55	})();
56}
57/*-------------------------------------------
58	new filter function
59-------------------------------------------*/
60if ((window.location.pathname.indexOf('news') > -1) || (window.location.pathname.indexOf('blog') > -1)) {
61	// console.log('debug: news-page');
62	(function($) {
63
64		var fragment = "";
65		if (window.location.pathname.indexOf('news') > -1) {
66			fragment = "/news/";
67		} else {
68			//blogs are on each site, so need to preserve the blog in path
69			// e.g. /engineering/blog/ and not just /blog/
70			fragment = window.location.pathname;
71		}
72
73		var query = {
74		    // fcat: JQS['fcat'] ? JQS['fcat'] : '',
75		    // fsearch: JQS['fsearch'] ? JQS['fsearch'] : ''
76		    fcat: '',
77		    fsearch: ''
78		};
79		var settingQuery = function(queryName, value) {
80			query[queryName] = typeof value === 'undefined' ? '' : value;
81			return query;
82		}
83
84		var input 		= document.getElementById('search_by_keyword');
85		if (input) {
86			input.addEventListener('keypress', function(e) {
87			    if (e.key === 'Enter') {
88					e.preventDefault();
89					e.stopPropagation();
90			      	window.location.href = location.protocol + '//' + window.location.hostname + fragment + '?' + $.param(settingQuery('fsearch', input.value));
91			    }
92			});
93		}
94
95		var input_click = document.getElementsByClassName('filter_search_input_submit')[0];
96		if (input_click) {
97			input_click.addEventListener('click', function(e) {
98				e.preventDefault();
99				e.stopPropagation();
100		      	window.location.href = location.protocol + '//' + window.location.hostname + fragment + '?' + $.param(settingQuery('fsearch', input.value));
101			});
102		}
103
104		var categs = document.getElementsByClassName('news-filter-option');
105		if (categs) {
106			for (var i = categs.length - 1; i >= 0; i--) {
107				categs[i].addEventListener('click', function(e) {
108					e.preventDefault();
109					e.stopPropagation();
110					window.location.href = location.protocol + '//' + window.location.hostname + fragment + '?' + $.param(settingQuery('fcat', e.target.dataset.filterOptionValue));
111				});
112			}
113		}
114	})(jQuery);
115}
116Site.modules.CustomAlert = (function($, Site) {
117
118	var $alert;
119	var $alertClose;
120	var $alertTime;
121	var cookieName;
122
123	function init() {
124		$alert = $(".alert");
125		$alertClose = $(".alert_close");
126		$alertTime = $alert.data("time");
127		cookieName = "alert-cookie";
128		var alert = sessionStorage.getItem("tric-alert");
129
130		if (alert == 'close') {
131			hideAlert();
132		} else {
133			showAlert();
134		}
135
136		resizeAlert();
137		bindUI();
138	}
139
140	function bindUI() {
141		$alertClose.on("click", function() {
142			setCookie();
143			sessionStorage.setItem("tric-alert", "close");
144			hideAlert();
145		});
146
147		Site.onResize.push(resizeAlert);
148	}
149
150	function resizeAlert() {
151		if($alert.hasClass("show_alert")) {
152			alertResizeTest();
153		} else {
154			alertResetSize();
155		}
156	}
157
158	function alertResizeTest() {
159		if ($alert.hasClass("admin_alert")) {
160			adminAlertResize();
161		} else {
162			standardAlertResize();
163		}
164	}
165
166	function setCookie() {
167		$.cookie(cookieName, $alertTime);
168	}
169
170	function showAlert() {
171		$alert.addClass("show_alert");
172
173		alertResizeTest();
174	}
175
176	function hideAlert() {
177		$alert.removeClass("show_alert");
178
179		alertResetSize();
180	}
181
182	function adminAlertResize() {
183		$(".mobile_sidebar").css({
184			"height": 'calc(100% - ' + $(".header_ribbon").innerHeight() + 'px - ' + $(".alert").innerHeight() + 'px' + '32px)',
185			"top": $(".header_ribbon").innerHeight() + $(".alert").innerHeight() + 32 +  'px'
186		});
187
188		$(".header").css("top", $(".alert").innerHeight() + 32 + 'px');
189		$(".page_feature").css("padding-top", $(".alert").innerHeight());
190	}
191
192	function standardAlertResize() {
193		$(".mobile_sidebar").css({
194			"height": 'calc(100% - ' + $(".header_ribbon").innerHeight() + 'px - ' + $(".alert").innerHeight() + 'px)',
195			"top": $(".header_ribbon").innerHeight() + $(".alert").innerHeight() + 'px'
196		});
197
198		$(".header").css("top", $(".alert").innerHeight());
199		$(".page_feature").css("padding-top", $(".alert").innerHeight());
200	}
201
202	function alertResetSize() {
203		$(".header").css("top", "");
204		$(".mobile_sidebar").css({
205			"height": "",
206			"top": ""
207		});
208		$(".page_feature").css("padding-top", "");
209	}
210
211	Site.onInit.push(init);
212
213	return {};
214})(jQuery, Site);

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.