PageSourceSearch

https://teder.org/wp-content/plugins/language-switcher-for-divi-po…/js/lsdp_module_frontend.js?ver=1.1.2

js teder.org collected 2026-10-01 12:25:40 UTC 1,679 bytes, 65 lines download raw bytes

1/**
2 * Divi language switcher frontend behaviour:
3 * - Raise parent row z-index for dropdown overflow.
4 * - Click-to-open when data-lsdp-open-on="click".
5 */
6(function () {
7	'use strict';
8
9	function shouldOpenOnClick(wrapper) {
10		return (
11			wrapper.classList.contains('lsdp-open-on-click') ||
12			wrapper.getAttribute('data-lsdp-open-on') === 'click'
13		);
14	}
15
16	function bindClickOpen(wrapper) {
17		if (!shouldOpenOnClick(wrapper) || wrapper.hasAttribute('data-lsdp-click-initialized')) {
18			return;
19		}
20
21		wrapper.setAttribute('data-lsdp-click-initialized', 'true');
22
23		// Bind on the whole wrapper so flag, name, code, and ::after arrow all toggle.
24		wrapper.addEventListener('click', function (e) {
25			// Let clicks on other languages navigate; do not toggle.
26			if (e.target.closest('.lsdp-language-list')) {
27				return;
28			}
29			e.preventDefault();
30			e.stopPropagation();
31			wrapper.classList.toggle('active');
32		});
33	}
34
35	function raiseRowZIndex(wrapper) {
36		var parentRow = wrapper.closest('.et_pb_row');
37		if (parentRow) {
38			parentRow.style.setProperty('z-index', '999');
39		}
40	}
41
42	function initAll() {
43		document.querySelectorAll('.lsdp-wrapper.dropdown').forEach(function (wrapper) {
44			raiseRowZIndex(wrapper);
45			bindClickOpen(wrapper);
46		});
47	}
48
49	if (document.readyState === 'loading') {
50		document.addEventListener('DOMContentLoaded', initAll);
51	} else {
52		initAll();
53	}
54
55	document.addEventListener('click', function (e) {
56		document.querySelectorAll('.lsdp-wrapper.dropdown.active').forEach(function (wrapper) {
57			if (!shouldOpenOnClick(wrapper)) {
58				return;
59			}
60			if (!wrapper.contains(e.target)) {
61				wrapper.classList.remove('active');
62			}
63		});
64	});
65})();

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.