Debian Codegraph @

js/tests/visual/toast.html

raw symbols SCIP
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <link href="../../../dist/css/bootstrap.min.css" rel="stylesheet">
7 <title>Toast</title>
8 <style>
9 .notifications {
10 position: absolute;
11 top: 10px;
12 right: 10px;
13 }
14 </style>
15 </head>
16 <body>
17 <div class="container">
18 <h1>Toast <small>Bootstrap Visual Test</small></h1>
19
20 <div class="row mt-3">
21 <div class="col-md-12">
22 <button id="btnShowToast" class="btn btn-primary">Show toast</button>
23 <button id="btnHideToast" class="btn btn-primary">Hide toast</button>
24 </div>
25 </div>
26 </div>
27
28 <div class="notifications">
29 <div id="toastAutoHide" class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="2000">
30 <div class="toast-header">
31 <span class="d-block bg-primary rounded me-2" style="width: 20px; height: 20px;"></span>
32 <strong class="me-auto">Bootstrap</strong>
33 <small>11 mins ago</small>
34 </div>
35 <div class="toast-body">
36 Hello, world! This is a toast message with <strong>autohide</strong> in 2 seconds
37 </div>
38 </div>
39
40 <div class="toast" data-bs-autohide="false" role="alert" aria-live="assertive" aria-atomic="true">
41 <div class="toast-header">
42 <span class="d-block bg-primary rounded me-2" style="width: 20px; height: 20px;"></span>
43 <strong class="me-auto">Bootstrap</strong>
44 <small class="text-body-secondary">2 seconds ago</small>
45 <button type="button" class="ms-2 mb-1 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
46 </div>
47 <div class="toast-body">
48 Heads up, toasts will stack automatically
49 </div>
50 </div>
51 </div>
52
53 <script src="../../../dist/js/bootstrap.bundle.js"></script>
54 <script>
55 /* global bootstrap: false */
56
57 window.addEventListener('load', () => {
58 document.querySelectorAll('.toast').forEach(toastEl => new bootstrap.Toast(toastEl))
59
60 document.getElementById('btnShowToast').addEventListener('click', () => {
61 document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).show())
62 })
63
64 document.getElementById('btnHideToast').addEventListener('click', () => {
65 document.querySelectorAll('.toast').forEach(toastEl => bootstrap.Toast.getInstance(toastEl).hide())
66 })
67 })
68 </script>
69 </body>
70 </html>