Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <meta charset='utf-8'> |
| 4 | <head> |
| 5 | <script src="../dist/dialog-polyfill.js"></script> |
| 6 | <link rel="stylesheet" type="text/css" href="../dist/dialog-polyfill.css"> |
| 7 | </head> |
| 8 | <body> |
| 9 | |
| 10 | <p> |
| 11 | Enter a value and submit the form. The close event will be fired and the <code>returnValue</code> of the dialog will be alerted. |
| 12 | </p> |
| 13 | |
| 14 | <input type="text" placeholder="Focusable pre" /> |
| 15 | |
| 16 | <dialog> |
| 17 | <form method="dialog"> |
| 18 | <input type="text" placeholder="Enter value" /> |
| 19 | <input type="reset" value="Reset" /> |
| 20 | <input type="submit" value="Stuff" /> |
| 21 | <input type="submit" value="Done" /> |
| 22 | <button type="submit" value="Button Value Is Different Than Text">Button Submit</button> |
| 23 | <button value="Regular Button Value">Button</button> |
| 24 | </form> |
| 25 | </dialog> |
| 26 | |
| 27 | <button id="show">Show Dialog</button> |
| 28 | |
| 29 | <input type="text" placeholder="Focusable post" /> |
| 30 | |
| 31 | |
| 32 | <script> |
| 33 | var dialog = document.querySelector('dialog'); |
| 34 | dialogPolyfill.registerDialog(dialog); |
| 35 | dialog.showModal(); |
| 36 | |
| 37 | dialog.addEventListener('close', function() { |
| 38 | var valueEl = dialog.querySelector('input[type="text"]'); |
| 39 | alert(dialog.returnValue); |
| 40 | }); |
| 41 | |
| 42 | show.addEventListener('click', function() { |
| 43 | dialog.showModal(); |
| 44 | }); |
| 45 | |
| 46 | </script> |
| 47 | </body> |
| 48 | </html> |