masoudmarandi commited on
Commit
27b477d
·
verified ·
1 Parent(s): 4abbf6a

top right of landing page get demo button missing modal

Browse files
Files changed (2) hide show
  1. components/modal.js +8 -9
  2. components/navbar.js +4 -5
components/modal.js CHANGED
@@ -190,8 +190,8 @@ class CustomModal extends HTMLElement {
190
  }
191
  customElements.define('custom-modal', CustomModal);
192
 
193
- // Global modal functions
194
- function openModal(modalId) {
195
  const modal = document.querySelector(`custom-modal[data-modal="${modalId}"]`);
196
  if (modal) {
197
  const overlay = modal.shadowRoot.getElementById(modalId);
@@ -200,9 +200,9 @@ function openModal(modalId) {
200
  document.body.style.overflow = 'hidden';
201
  }
202
  }
203
- }
204
 
205
- function closeModal(modalId) {
206
  const modal = document.querySelector(`custom-modal[data-modal="${modalId}"]`);
207
  if (modal) {
208
  const overlay = modal.shadowRoot.getElementById(modalId);
@@ -211,10 +211,10 @@ function closeModal(modalId) {
211
  document.body.style.overflow = '';
212
  }
213
  }
214
- }
215
 
216
- function handleFormSubmit(event, modalId) {
217
- event.preventDefault();
218
  const modal = document.querySelector(`custom-modal[data-modal="${modalId}"]`);
219
  if (modal) {
220
  const formContent = modal.shadowRoot.getElementById(`form-${modalId}`);
@@ -232,7 +232,6 @@ function handleFormSubmit(event, modalId) {
232
  }, 2000);
233
  }
234
  }
235
-
236
  // Close modals on Escape key (global handler for shadow DOM elements)
237
  document.addEventListener('keydown', (e) => {
238
  if (e.key === 'Escape') {
@@ -241,7 +240,7 @@ document.addEventListener('keydown', (e) => {
241
  const overlay = modal.shadowRoot.querySelector('.modal-overlay.open');
242
  if (overlay) {
243
  const modalId = modal.getAttribute('data-modal');
244
- closeModal(modalId);
245
  }
246
  });
247
  }
 
190
  }
191
  customElements.define('custom-modal', CustomModal);
192
 
193
+ // Global modal functions - explicitly attached to window for Shadow DOM access
194
+ window.openModal = function(modalId) {
195
  const modal = document.querySelector(`custom-modal[data-modal="${modalId}"]`);
196
  if (modal) {
197
  const overlay = modal.shadowRoot.getElementById(modalId);
 
200
  document.body.style.overflow = 'hidden';
201
  }
202
  }
203
+ };
204
 
205
+ window.closeModal = function(modalId) {
206
  const modal = document.querySelector(`custom-modal[data-modal="${modalId}"]`);
207
  if (modal) {
208
  const overlay = modal.shadowRoot.getElementById(modalId);
 
211
  document.body.style.overflow = '';
212
  }
213
  }
214
+ };
215
 
216
+ window.handleFormSubmit = function(event, modalId) {
217
+ event.preventDefault();
218
  const modal = document.querySelector(`custom-modal[data-modal="${modalId}"]`);
219
  if (modal) {
220
  const formContent = modal.shadowRoot.getElementById(`form-${modalId}`);
 
232
  }, 2000);
233
  }
234
  }
 
235
  // Close modals on Escape key (global handler for shadow DOM elements)
236
  document.addEventListener('keydown', (e) => {
237
  if (e.key === 'Escape') {
 
240
  const overlay = modal.shadowRoot.querySelector('.modal-overlay.open');
241
  if (overlay) {
242
  const modalId = modal.getAttribute('data-modal');
243
+ window.closeModal(modalId);
244
  }
245
  });
246
  }
components/navbar.js CHANGED
@@ -118,16 +118,15 @@ class CustomNavbar extends HTMLElement {
118
  menuToggle.addEventListener('click', () => {
119
  mobileMenu.classList.toggle('open');
120
  });
121
-
122
  // Demo button click handler
123
  const handleDemoClick = (e) => {
124
  e.preventDefault();
125
- if (typeof openModal === 'function') {
126
- openModal('demo-modal');
 
127
  }
128
  };
129
-
130
- navDemoBtn.addEventListener('click', handleDemoClick);
131
 
132
  // Also handle mobile demo button
133
  const mobileDemoBtn = this.shadowRoot.querySelector('.mobile-menu .nav-cta');
 
118
  menuToggle.addEventListener('click', () => {
119
  mobileMenu.classList.toggle('open');
120
  });
 
121
  // Demo button click handler
122
  const handleDemoClick = (e) => {
123
  e.preventDefault();
124
+ // Access via window to ensure visibility from Shadow DOM
125
+ if (window.openModal && typeof window.openModal === 'function') {
126
+ window.openModal('demo-modal');
127
  }
128
  };
129
+ navDemoBtn.addEventListener('click', handleDemoClick);
 
130
 
131
  // Also handle mobile demo button
132
  const mobileDemoBtn = this.shadowRoot.querySelector('.mobile-menu .nav-cta');