PageSourceSearch

https://www.alnylam.com/themes/custom/alnylam/js/job-search-scroll.js?tlui2v

js alnylam.com collected 2026-09-24 17:18:52 UTC 2,070 bytes, 92 lines download raw bytes

1/* Smooth-scroll anchor links (e.g. "SEARCH JOBS") to the Job Search section. */
2(function () {
3	"use strict";
4
5	var TARGET_ID = "jsblk-search";
6
7	function getHeaderOffset() {
8		if (document.body.classList.contains("sticky-header")) {
9			return window.matchMedia("(max-width: 767px)").matches ? 149 : 156;
10		}
11
12		return window.matchMedia("(max-width: 767px)").matches ? 298 : 312;
13	}
14
15	function scrollToTarget() {
16		var target = document.getElementById(TARGET_ID);
17		if (!target) return;
18
19		var top =
20			target.getBoundingClientRect().top +
21			window.pageYOffset -
22			getHeaderOffset();
23
24		window.scrollTo({
25			top: top,
26			behavior: "smooth"
27		});
28	}
29
30	function handleClick(e) {
31		var link = e.target.closest("a");
32
33		if (!link) return;
34
35		var url;
36
37		try {
38			url = new URL(link.href, window.location.href);
39		} catch (err) {
40			return;
41		}
42
43		/*
44		 * Trigger smooth scroll when:
45		 * - Link points to this same page
46		 * - Hash is #jsblk-search
47		 *
48		 * Examples:
49		 * /careers#jsblk-search
50		 * https://example.com/careers#jsblk-search
51		 * #jsblk-search
52		 */
53		if (
54			url.origin === window.location.origin &&
55			url.pathname.replace(/\/$/, "") === window.location.pathname.replace(/\/$/, "") &&
56			url.hash === "#" + TARGET_ID
57		) {
58			e.preventDefault();
59
60			// Update URL without triggering the browser's default jump.
61			if (window.location.hash !== url.hash) {
62				history.pushState(null, "", url.hash);
63			}
64
65			scrollToTarget();
66		}
67	}
68
69	function init() {
70		if (document.body.dataset.jsblkScrollInit === "true") return;
71
72		document.body.dataset.jsblkScrollInit = "true";
73
74		// Handle clicks on links such as /careers#jsblk-search.
75		document.addEventListener("click", handleClick);
76
77		// Handle direct page load with #jsblk-search.
78		if (window.location.hash === "#" + TARGET_ID) {
79			setTimeout(scrollToTarget, 300);
80		}
81	}
82
83	if (window.Drupal && Drupal.behaviors) {
84		Drupal.behaviors.jsblkScroll = {
85			attach: init
86		};
87	} else if (document.readyState !== "loading") {
88		init();
89	} else {
90		document.addEventListener("DOMContentLoaded", init);
91	}
92})();

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.