muzakkirhussain011 commited on
Commit
9a73c74
·
1 Parent(s): a1ca782

Add application files

Browse files
Files changed (1) hide show
  1. app.py +18 -36
app.py CHANGED
@@ -492,7 +492,12 @@ footer { display: none !important; }
492
 
493
  /* ============== NAVIGATION BUTTONS ROW ============== */
494
  .nav-buttons-row {
495
- display: none; /* Hidden on desktop - use sidebar */
 
 
 
 
 
496
  gap: 8px;
497
  padding: 12px 16px;
498
  background: var(--bg-primary);
@@ -532,6 +537,11 @@ footer { display: none !important; }
532
  /* Show nav buttons on mobile/tablet */
533
  @media (max-width: 768px) {
534
  .nav-buttons-row {
 
 
 
 
 
535
  display: flex;
536
  }
537
  .nav-buttons-row button:first-child {
@@ -3260,26 +3270,11 @@ This project is open source and available under the MIT License.
3260
  btn_chat.click(fn=lambda: show_page("chat"), outputs=all_pages)
3261
  btn_about.click(fn=lambda: show_page("about"), outputs=all_pages)
3262
 
3263
- # JavaScript to connect sidebar nav items to Gradio buttons (optimized)
3264
  gr.HTML("""
3265
  <script>
3266
- // Cache for navigation buttons - populated once on load
3267
- window._navButtonCache = null;
3268
  window._pageOrder = ['setup', 'dashboard', 'discovery', 'prospects', 'contacts', 'emails', 'chat', 'about'];
3269
 
3270
- // Initialize button cache
3271
- function initNavCache() {
3272
- if (window._navButtonCache) return window._navButtonCache;
3273
- const buttons = document.querySelectorAll('.nav-buttons-row button');
3274
- if (buttons.length >= 8) {
3275
- window._navButtonCache = {};
3276
- window._pageOrder.forEach((page, idx) => {
3277
- window._navButtonCache[page] = buttons[idx];
3278
- });
3279
- }
3280
- return window._navButtonCache;
3281
- }
3282
-
3283
  window.selectPage = function(pageName) {
3284
  // Close mobile sidebar immediately
3285
  if (window.closeMobileSidebar) {
@@ -3291,31 +3286,18 @@ This project is open source and available under the MIT License.
3291
  item.classList.toggle('active', item.dataset.page === pageName);
3292
  });
3293
 
3294
- // Use cached button reference for instant navigation
3295
- const cache = initNavCache();
3296
- if (cache && cache[pageName]) {
3297
- cache[pageName].click();
3298
-
3299
- // Update button row active state
3300
- Object.values(cache).forEach(b => b.classList.remove('active-nav-btn'));
3301
- cache[pageName].classList.add('active-nav-btn');
3302
- return;
3303
- }
3304
-
3305
- // Fallback: direct index access (no searching)
3306
  const buttons = document.querySelectorAll('.nav-buttons-row button');
3307
  const idx = window._pageOrder.indexOf(pageName);
 
 
 
 
 
3308
  if (idx >= 0 && buttons[idx]) {
3309
  buttons[idx].click();
3310
  }
3311
  };
3312
-
3313
- // Initialize cache after Gradio loads
3314
- if (document.readyState === 'loading') {
3315
- document.addEventListener('DOMContentLoaded', () => setTimeout(initNavCache, 100));
3316
- } else {
3317
- setTimeout(initNavCache, 100);
3318
- }
3319
  </script>
3320
  """)
3321
 
 
492
 
493
  /* ============== NAVIGATION BUTTONS ROW ============== */
494
  .nav-buttons-row {
495
+ /* Hidden visually but accessible to JS for click events */
496
+ position: absolute;
497
+ left: -9999px;
498
+ top: -9999px;
499
+ opacity: 0;
500
+ pointer-events: none;
501
  gap: 8px;
502
  padding: 12px 16px;
503
  background: var(--bg-primary);
 
537
  /* Show nav buttons on mobile/tablet */
538
  @media (max-width: 768px) {
539
  .nav-buttons-row {
540
+ position: static;
541
+ left: auto;
542
+ top: auto;
543
+ opacity: 1;
544
+ pointer-events: auto;
545
  display: flex;
546
  }
547
  .nav-buttons-row button:first-child {
 
3270
  btn_chat.click(fn=lambda: show_page("chat"), outputs=all_pages)
3271
  btn_about.click(fn=lambda: show_page("about"), outputs=all_pages)
3272
 
3273
+ # JavaScript to connect sidebar nav items to Gradio page selector
3274
  gr.HTML("""
3275
  <script>
 
 
3276
  window._pageOrder = ['setup', 'dashboard', 'discovery', 'prospects', 'contacts', 'emails', 'chat', 'about'];
3277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3278
  window.selectPage = function(pageName) {
3279
  // Close mobile sidebar immediately
3280
  if (window.closeMobileSidebar) {
 
3286
  item.classList.toggle('active', item.dataset.page === pageName);
3287
  });
3288
 
3289
+ // Find and click the corresponding navigation button
 
 
 
 
 
 
 
 
 
 
 
3290
  const buttons = document.querySelectorAll('.nav-buttons-row button');
3291
  const idx = window._pageOrder.indexOf(pageName);
3292
+
3293
+ // Update button row active state
3294
+ buttons.forEach((b, i) => b.classList.toggle('active-nav-btn', i === idx));
3295
+
3296
+ // Click the button to trigger Gradio's native event handler
3297
  if (idx >= 0 && buttons[idx]) {
3298
  buttons[idx].click();
3299
  }
3300
  };
 
 
 
 
 
 
 
3301
  </script>
3302
  """)
3303