PageSourceSearch

https://rgp.com/wp-content/themes/salient-child/js/mobile-filter-toggle.js?ver=1789589550

js rgp.com collected 2026-09-24 23:14:51 UTC 3,131 bytes, 119 lines download raw bytes

1/**
2 * Mobile filter toggle: show/hide .hide-on-mobile panels below tablet breakpoint.
3 */
4(function () {
5	'use strict';
6
7	var TABLET_MIN_PX = 1000;
8	var BTN_SELECTOR = '.rgp-mobile-filter-toggle__button';
9	var BOUND_ATTR = 'data-rgp-mobile-filter-bound';
10	var OPEN_CLASS = 'is-open';
11
12	function isTabletUp() {
13		return window.matchMedia('(min-width: ' + TABLET_MIN_PX + 'px)').matches;
14	}
15
16	function escapeClassToken(className) {
17		if (typeof CSS !== 'undefined' && typeof CSS.escape === 'function') {
18			return CSS.escape(className);
19		}
20		return String(className).replace(/[^a-zA-Z0-9_-]/g, '\\$&');
21	}
22
23	function getPanel(button) {
24		if (!button) {
25			return null;
26		}
27
28		var panelId = button.getAttribute('data-rgp-mobile-filter-panel');
29		if (panelId) {
30			return document.getElementById(panelId);
31		}
32
33		var panelClass = button.getAttribute('data-rgp-mobile-filter-panel-class');
34		if (panelClass) {
35			return document.querySelector('.' + escapeClassToken(panelClass));
36		}
37
38		var ariaControls = button.getAttribute('aria-controls');
39		return ariaControls ? document.getElementById(ariaControls) : null;
40	}
41
42	function ensurePanelId(button, panel) {
43		if (!panel || panel.id) {
44			return panel ? panel.id : '';
45		}
46		var seed = button.getAttribute('data-rgp-mobile-filter-panel-class')
47			|| button.getAttribute('data-rgp-mobile-filter-panel')
48			|| 'panel';
49		panel.id = 'rgp-mft-' + seed.replace(/[^a-zA-Z0-9_-]/g, '-') + '-' + Math.random().toString(36).slice(2, 8);
50		button.setAttribute('aria-controls', panel.id);
51		return panel.id;
52	}
53
54	function syncPanel(button, panel) {
55		if (!button || !panel) {
56			return;
57		}
58		if (isTabletUp()) {
59			panel.classList.remove(OPEN_CLASS);
60			button.setAttribute('aria-expanded', 'true');
61			return;
62		}
63		button.setAttribute('aria-expanded', panel.classList.contains(OPEN_CLASS) ? 'true' : 'false');
64	}
65
66	function bindButton(button) {
67		if (!button || button.getAttribute(BOUND_ATTR) === '1') {
68			return;
69		}
70		var panel = getPanel(button);
71		if (!panel) {
72			return;
73		}
74
75		ensurePanelId(button, panel);
76		button.setAttribute(BOUND_ATTR, '1');
77		syncPanel(button, panel);
78
79		button.addEventListener('click', function () {
80			if (isTabletUp()) {
81				return;
82			}
83			panel.classList.toggle(OPEN_CLASS);
84			syncPanel(button, panel);
85		});
86	}
87
88	function bindAll(scope) {
89		var root = scope && scope.querySelectorAll ? scope : document;
90		root.querySelectorAll(BTN_SELECTOR).forEach(bindButton);
91	}
92
93	function syncAll() {
94		document.querySelectorAll(BTN_SELECTOR).forEach(function (button) {
95			syncPanel(button, getPanel(button));
96		});
97	}
98
99	if (document.readyState === 'loading') {
100		document.addEventListener('DOMContentLoaded', function () {
101			bindAll(document);
102		});
103	} else {
104		bindAll(document);
105	}
106
107	window.addEventListener('resize', syncAll);
108
109	if (typeof MutationObserver !== 'undefined') {
110		var debounceTimer;
111		var observer = new MutationObserver(function () {
112			clearTimeout(debounceTimer);
113			debounceTimer = setTimeout(function () {
114				bindAll(document);
115			}, 100);
116		});
117		observer.observe(document.documentElement, { childList: true, subtree: true });
118	}
119})();

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.