PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.83
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.83
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Cookie_Preferences_Button / script.js

script.js in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.83, at includes/widgets/Cookie_Preferences_Button/script.js

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Cookie Preferences Button behavior.
3 *
4 * Binds a delegated click handler to elements with [data-ka-cookie-manage].
5 * Uses Elementor frontend init hook when available.
6 */
7 (function () {
8 const FLAG = "kingAddonsCookiePreferencesBound";
9
10 /**
11 * Bind click handler once per page.
12 *
13 * @return void
14 */
15 const bindOnce = () => {
16 if (window[FLAG]) {
17 return;
18 }
19 window[FLAG] = true;
20
21 document.addEventListener("click", (event) => {
22 const target = event.target;
23 if (!(target instanceof Element)) {
24 return;
25 }
26
27 const trigger = target.closest("[data-ka-cookie-manage]");
28 if (!trigger) {
29 return;
30 }
31
32 event.preventDefault();
33
34 if (typeof window.kingAddonsOpenConsent === "function") {
35 window.kingAddonsOpenConsent();
36 return;
37 }
38
39 document.dispatchEvent(
40 new CustomEvent("king-addons-open-cookie-settings")
41 );
42 });
43 };
44
45 document.addEventListener("DOMContentLoaded", bindOnce);
46
47 // Elementor editor/frontend support.
48 if (typeof jQuery !== "undefined") {
49 jQuery(window).on("elementor/frontend/init", function () {
50 if (
51 typeof elementorFrontend !== "undefined" &&
52 elementorFrontend.hooks &&
53 typeof elementorFrontend.hooks.addAction === "function"
54 ) {
55 elementorFrontend.hooks.addAction(
56 "frontend/element_ready/king-addons-cookie-preferences-button.default",
57 function () {
58 bindOnce();
59 }
60 );
61 } else {
62 bindOnce();
63 }
64 });
65 }
66 })();
67
68
69
70