PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.86
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.86
51.1.86 51.1.84 51.1.85 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 All 40 releases
← All changes | includes/extensions/Theme_Builder/script.js +77 -13 51.1.44 → 51.1.86 View file →
@@ -1,20 +1,23 @@
1 1 document.addEventListener('DOMContentLoaded', () => {
2 2 const addNewButton = document.getElementById('ka-theme-builder-add-new');
3 + const addNewEmptyButton = document.getElementById('ka-theme-builder-add-new-empty');
3 4 const addNewModal = document.getElementById('ka-theme-builder-modal');
4 5 const quickModal = document.getElementById('ka-theme-builder-quick-modal');
5 - const closeButtons = document.querySelectorAll('.ka-theme-builder-modal__close');
6 + const closeButtons = document.querySelectorAll('.ka-tb-modal-close');
6 7
8 + const isOpenClass = 'is-open';
9 +
7 10 const openModal = (modal) => {
8 - if (modal) {
9 - modal.style.display = 'flex';
10 - }
11 + if (!modal) return;
12 + modal.classList.add(isOpenClass);
13 + modal.setAttribute('aria-hidden', 'false');
11 14 };
12 15
13 16 const closeModal = (modal) => {
14 - if (modal) {
15 - modal.style.display = 'none';
16 - }
17 + if (!modal) return;
18 + modal.classList.remove(isOpenClass);
19 + modal.setAttribute('aria-hidden', 'true');
17 20 };
18 21
19 22 if (addNewButton) {
20 23 addNewButton.addEventListener('click', (event) => {
@@ -22,8 +25,35 @@
22 25 openModal(addNewModal);
23 26 });
24 27 }
25 28
29 + if (addNewEmptyButton) {
30 + addNewEmptyButton.addEventListener('click', (event) => {
31 + event.preventDefault();
32 + openModal(addNewModal);
33 + });
34 + }
35 +
36 + // Type cards: preselect type/location and open create modal
37 + const typeButtons = document.querySelectorAll('.ka-tb-type');
38 + const typeSelect = document.getElementById('ka-tb-type');
39 + const locationSelect = document.getElementById('ka-tb-location');
40 + typeButtons.forEach((btn) => {
41 + btn.addEventListener('click', (event) => {
42 + event.preventDefault();
43 + const type = btn.getAttribute('data-ka-tb-type');
44 + const location = btn.getAttribute('data-ka-tb-location');
45 +
46 + if (typeSelect && type) {
47 + typeSelect.value = type;
48 + }
49 + if (locationSelect && location) {
50 + locationSelect.value = location;
51 + }
52 + openModal(addNewModal);
53 + });
54 + });
55 +
26 56 closeButtons.forEach((button) => {
27 57 button.addEventListener('click', () => {
28 58 closeModal(addNewModal);
29 59 closeModal(quickModal);
@@ -48,9 +78,9 @@
48 78 if (quickPriority) {
49 79 quickPriority.value = priority || '10';
50 80 }
51 81 if (quickEnabled) {
52 - quickEnabled.checked = enabled;
82 + quickEnabled.value = enabled ? '1' : '0';
53 83 }
54 84
55 85 openModal(quickModal);
56 86 });
@@ -55,14 +85,48 @@
55 85 openModal(quickModal);
56 86 });
57 87 });
58 88
59 - const backdrops = document.querySelectorAll('.ka-theme-builder-modal__backdrop');
60 - backdrops.forEach((backdrop) => {
61 - backdrop.addEventListener('click', () => {
62 - closeModal(addNewModal);
63 - closeModal(quickModal);
89 + // Backdrop click closes (clicking inside modal does not)
90 + [addNewModal, quickModal].forEach((modal) => {
91 + if (!modal) return;
92 + modal.addEventListener('click', (event) => {
93 + if (event.target === modal) {
94 + closeModal(modal);
95 + }
64 96 });
97 + });
98 +
99 + // ESC closes any open modal
100 + document.addEventListener('keydown', (event) => {
101 + if (event.key !== 'Escape') return;
102 + closeModal(addNewModal);
103 + closeModal(quickModal);
104 + });
105 +
106 + // Dropdown actions
107 + const closeAllDropdowns = () => {
108 + document.querySelectorAll('[data-ka-dropdown].is-open').forEach((dd) => dd.classList.remove('is-open'));
109 + };
110 +
111 + document.addEventListener('click', (event) => {
112 + const trigger = event.target.closest('.ka-tb-dropdown-trigger');
113 + if (trigger) {
114 + const dropdown = trigger.closest('[data-ka-dropdown]');
115 + if (!dropdown) return;
116 +
117 + const isOpen = dropdown.classList.contains('is-open');
118 + closeAllDropdowns();
119 + dropdown.classList.toggle('is-open', !isOpen);
120 + return;
121 + }
122 +
123 + // Click inside menu should not close immediately (links will navigate)
124 + if (event.target.closest('.ka-tb-dropdown-menu')) {
125 + return;
126 + }
127 +
128 + closeAllDropdowns();
65 129 });
66 130 });
67 131
68 132