PageSourceSearch

https://torresdelpaine.com/wp-content/plugins/greatchile-core/js/attribution.js?ver=0.1

js torresdelpaine.com collected 2026-10-01 11:58:20 UTC 1,900 bytes, 60 lines download raw bytes

1/**
2 * Image attribution — © badge toggle. Dependency-free.
3 *
4 * The badge is a role=button <span> (valid inside a linked image's <a>,
5 * unlike a <button>). Clicking it toggles the credit popover and
6 * stopPropagation()s so a surrounding link / lightbox doesn't fire.
7 * Outside-click and Escape close any open credit; Enter/Space toggle.
8 *
9 * See gc_plan('image-attribution').
10 */
11(function () {
12	'use strict';
13
14	function closeAll(except) {
15		var open = document.querySelectorAll('.gc-attr-credit:not([hidden])');
16		for (var i = 0; i < open.length; i++) {
17			if (open[i] === except) continue;
18			open[i].hidden = true;
19			var badge = open[i].parentNode && open[i].parentNode.querySelector('.gc-attr-badge');
20			if (badge) badge.setAttribute('aria-expanded', 'false');
21		}
22	}
23
24	function toggle(badge) {
25		var wrap = badge.closest('.gc-attributed');
26		if (!wrap) return;
27		var credit = wrap.querySelector('.gc-attr-credit');
28		if (!credit) return;
29		var willShow = credit.hidden;
30		closeAll(willShow ? credit : null);
31		credit.hidden = !willShow;
32		badge.setAttribute('aria-expanded', willShow ? 'true' : 'false');
33	}
34
35	document.addEventListener('click', function (e) {
36		var t = e.target;
37		if (!t || !t.closest) return;
38		var badge = t.closest('.gc-attr-badge');
39		if (badge) {
40			e.preventDefault();
41			e.stopPropagation(); // keep a wrapping link / lightbox from firing
42			toggle(badge);
43			return;
44		}
45		// A click anywhere outside an open popover closes it.
46		if (!t.closest('.gc-attr-credit')) closeAll(null);
47	});
48
49	document.addEventListener('keydown', function (e) {
50		var t = e.target;
51		var badge = t && t.closest ? t.closest('.gc-attr-badge') : null;
52		if (badge && (e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar')) {
53			e.preventDefault();
54			e.stopPropagation();
55			toggle(badge);
56			return;
57		}
58		if (e.key === 'Escape' || e.key === 'Esc') closeAll(null);
59	});
60})();

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.