| 1 | <!DOCTYPE html> |
| 2 | <html lang="en" xmlns:hx-boost="http://www.w3.org/1999/xhtml"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8"> |
| 5 | <meta name="htmx-config" content='{"extensions": "browser-indicator"}'> |
| 6 | <title>Browser Indicator Test</title> |
| 7 | <script src="../../src/htmx.js"></script> |
| 8 | <script src="../../src/ext/hx-browser-indicator.js"></script> |
| 9 | <script> |
| 10 | htmx.config.logAll = true; |
| 11 | htmx.config.boostBrowserIndicator = true; |
| 12 | |
| 13 | // Add a 2 second delay to all fetches so the indicator is visible |
| 14 | let originalFetch = window.fetch; |
| 15 | window.fetch = async (...args) => { |
| 16 | await new Promise(r => setTimeout(r, 2000)); |
| 17 | return originalFetch(...args); |
| 18 | }; |
| 19 | </script> |
| 20 | <style> |
| 21 | body { font-family: sans-serif; max-width: 600px; margin: 2em auto; } |
| 22 | button { padding: 0.5em 1em; margin: 0.5em; font-size: 1em; } |
| 23 | #output { margin-top: 1em; padding: 1em; border: 1px solid #ccc; min-height: 2em; } |
| 24 | </style> |
| 25 | </head> |
| 26 | <body> |
| 27 | |
| 28 | <h2>hx-browser-indicator test</h2> |
| 29 | |
| 30 | <p>Click a button and watch the browser tab spinner.</p> |
| 31 | |
| 32 | <h3>Per-element attribute</h3> |
| 33 | <button hx-get="/test/scratch/fragment.html" hx-target="#output" hx-browser-indicator="true"> |
| 34 | Load (with browser indicator) |
| 35 | </button> |
| 36 | <button hx-get="/test/scratch/fragment.html" hx-target="#output"> |
| 37 | Load (no browser indicator) |
| 38 | </button> |
| 39 | |
| 40 | <h3>Boosted link (enable via config)</h3> |
| 41 | <div hx-boost:inherited="true"> |
| 42 | <a href="">Boosted link</a> |
| 43 | </div> |
| 44 | |
| 45 | <div id="output">Response will appear here</div> |
| 46 | |
| 47 | |
| 48 | |
| 49 | </body> |
| 50 | </html> |