Browse Source

feat: URL-hash deep-links to modals

_init.js: on load, open a Bootstrap modal named in the location hash. #zw is a
friendly alias (from the main site's Zeken Woozer Enterprises link) that scrolls
to the What section and opens the zw card modal; any other #modal-id just opens
that modal.
windhamdavid 2 weeks ago
parent
commit
40fcf2b004
1 changed files with 20 additions and 0 deletions
  1. 20 0
      js/_init.js

+ 20 - 0
js/_init.js

@@ -303,3 +303,23 @@ $(".nav-link").hover(function(){
 //    });
 //    });
 //  };
 //  };
 }
 }
+
+// Deep-link support for the URL hash on load.
+//  - #zw: friendly alias from the main site's "Zeken Woözer Enterprises" link —
+//    scroll to the What section and open the zw card modal.
+//  - otherwise: if the hash names a Bootstrap .modal, open it.
+document.addEventListener('DOMContentLoaded', function () {
+  var hash = window.location.hash;
+  if (!hash) return;
+  if (hash === '#zw') {
+    var what = document.getElementById('what');
+    if (what) what.scrollIntoView();
+    var zw = document.getElementById('zw-card-modal');
+    if (zw && window.bootstrap) bootstrap.Modal.getOrCreateInstance(zw).show();
+    return;
+  }
+  var target = document.querySelector(hash);
+  if (target && target.classList.contains('modal') && window.bootstrap) {
+    bootstrap.Modal.getOrCreateInstance(target).show();
+  }
+});