Debian Codegraph @

js/tests/visual/modal.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>Modal</title>
8 <style>
9 #tall {
10 height: 1500px;
11 width: 100px;
12 }
13 </style>
14 </head>
15 <body>
16 <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
17 <div class="container-fluid">
18 <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
19 <span class="navbar-toggler-icon"></span>
20 </button>
21 <div class="collapse navbar-collapse" id="navbarResponsive">
22 <a class="navbar-brand" href="#">This shouldn't jump!</a>
23 <ul class="navbar-nav">
24 <li class="nav-item">
25 <a class="nav-link active" href="#" aria-current="page">Home</a>
26 </li>
27 <li class="nav-item">
28 <a class="nav-link" href="#">Link</a>
29 </li>
30 <li class="nav-item">
31 <a class="nav-link" href="#">Link</a>
32 </li>
33 </ul>
34 </div>
35 </div>
36 </nav>
37
38 <div class="container mt-3">
39 <h1>Modal <small>Bootstrap Visual Test</small></h1>
40
41 <div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
42 <div class="modal-dialog">
43 <div class="modal-content">
44 <div class="modal-header">
45 <h1 class="modal-title fs-4" id="myModalLabel">Modal title</h1>
46 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
47 </div>
48 <div class="modal-body">
49 <h4>Text in a modal</h4>
50 <p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p>
51
52 <h4>Popover in a modal</h4>
53 <p>This <button type="button" class="btn btn-primary" data-bs-toggle="popover" data-bs-placement="left" title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">button</button> should trigger a popover on click.</p>
54
55
56 <h4>Tooltips in a modal</h4>
57 <p><a href="#" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top">This link</a> and <a href="#" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Tooltip on bottom">that link</a> should have tooltips on hover.</p>
58
59 <div id="accordion" role="tablist">
60 <div class="card" role="presentation">
61 <div class="card-header" role="tab" id="headingOne">
62 <h5 class="mb-0">
63 <a data-bs-toggle="collapse" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
64 Collapsible Group Item #1
65 </a>
66 </h5>
67 </div>
68
69 <div id="collapseOne" class="collapse show" data-bs-parent="#accordion" role="tabpanel" aria-labelledby="headingOne">
70 <div class="card-body">
71 Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
72 </div>
73 </div>
74 </div>
75 <div class="card" role="presentation">
76 <div class="card-header" role="tab" id="headingTwo">
77 <h5 class="mb-0">
78 <a class="collapsed" data-bs-toggle="collapse" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
79 Collapsible Group Item #2
80 </a>
81 </h5>
82 </div>
83 <div id="collapseTwo" class="collapse" data-bs-parent="#accordion" role="tabpanel" aria-labelledby="headingTwo">
84 <div class="card-body">
85 Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
86 </div>
87 </div>
88 </div>
89 <div class="card" role="presentation">
90 <div class="card-header" role="tab" id="headingThree">
91 <h5 class="mb-0">
92 <a class="collapsed" data-bs-toggle="collapse" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
93 Collapsible Group Item #3
94 </a>
95 </h5>
96 </div>
97 <div id="collapseThree" class="collapse" data-bs-parent="#accordion" role="tabpanel" aria-labelledby="headingThree">
98 <div class="card-body">
99 Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
100 </div>
101 </div>
102 </div>
103 </div>
104
105 <hr>
106
107 <h4>Overflowing text to show scroll behavior</h4>
108 <p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
109 <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
110 <p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
111 <p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
112 <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
113 <p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
114 <p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
115 <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
116 <p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
117 </div>
118 <div class="modal-footer">
119 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
120 <button type="button" class="btn btn-primary">Save changes</button>
121 </div>
122 </div>
123 </div>
124 </div>
125
126 <div class="modal fade" id="firefoxModal" tabindex="-1" aria-labelledby="firefoxModalLabel" aria-hidden="true">
127 <div class="modal-dialog">
128 <div class="modal-content">
129 <div class="modal-header">
130 <h1 class="modal-title fs-4" id="firefoxModalLabel">Firefox Bug Test</h1>
131 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
132 </div>
133 <div class="modal-body">
134 <ol>
135 <li>Ensure you're using Firefox.</li>
136 <li>Open a new tab and then switch back to this tab.</li>
137 <li>Click into this input: <input type="text" id="ff-bug-input"></li>
138 <li>Switch to the other tab and then back to this tab.</li>
139 </ol>
140 <p>Test result: <strong id="ff-bug-test-result"></strong></p>
141 </div>
142 <div class="modal-footer">
143 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
144 <button type="button" class="btn btn-primary">Save changes</button>
145 </div>
146 </div>
147 </div>
148 </div>
149
150 <div class="modal fade" id="slowModal" tabindex="-1" aria-labelledby="slowModalLabel" aria-hidden="true" style="transition-duration: 5s;">
151 <div class="modal-dialog" style="transition-duration: inherit;">
152 <div class="modal-content">
153 <div class="modal-header">
154 <h1 class="modal-title fs-4" id="slowModalLabel">Lorem slowly</h1>
155 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
156 </div>
157 <div class="modal-body">
158 <p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Nulla vitae elit libero, a pharetra augue.</p>
159 </div>
160 <div class="modal-footer">
161 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
162 <button type="button" class="btn btn-primary">Save changes</button>
163 </div>
164 </div>
165 </div>
166 </div>
167
168 <button type="button" class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#myModal">
169 Launch demo modal
170 </button>
171
172 <button type="button" class="btn btn-primary btn-lg" id="tall-toggle">
173 Toggle tall &lt;body&gt; content
174 </button>
175
176 <br><br>
177
178 <button type="button" class="btn btn-secondary btn-lg" data-bs-toggle="modal" data-bs-target="#firefoxModal">
179 Launch Firefox bug test modal
180 </button>
181 (<a href="https://github.com/twbs/bootstrap/issues/18365">See Issue #18365</a>)
182
183 <br><br>
184
185 <button type="button" class="btn btn-secondary btn-lg" data-bs-toggle="modal" data-bs-target="#slowModal">
186 Launch modal with slow transition
187 </button>
188
189 <br><br>
190
191 <div class="text-bg-dark p-2" id="tall" style="display: none;">
192 Tall body content to force the page to have a scrollbar.
193 </div>
194
195 <button type="button" class="btn btn-secondary btn-lg" data-bs-toggle="modal" data-bs-target="&#x3C;div class=&#x22;modal fade the-bad&#x22; tabindex=&#x22;-1&#x22;&#x3E;&#x3C;div class=&#x22;modal-dialog&#x22;&#x3E;&#x3C;div class=&#x22;modal-content&#x22;&#x3E;&#x3C;div class=&#x22;modal-header&#x22;&#x3E;&#x3C;button type=&#x22;button&#x22; class=&#x22;btn-close&#x22; data-bs-dismiss=&#x22;modal&#x22; aria-label=&#x22;Close&#x22;&#x3E;&#x3C;span aria-hidden=&#x22;true&#x22;&#x3E;&#x26;times;&#x3C;/span&#x3E;&#x3C;/button&#x3E;&#x3C;h1 class=&#x22;modal-title fs-4&#x22;&#x3E;The Bad Modal&#x3C;/h1&#x3E;&#x3C;/div&#x3E;&#x3C;div class=&#x22;modal-body&#x22;&#x3E;This modal&#x27;s HTTML source code is declared inline, inside the data-bs-target attribute of it&#x27;s show-button&#x3C;/div&#x3E;&#x3C;/div&#x3E;&#x3C;/div&#x3E;&#x3C;/div&#x3E;">
196 Modal with an XSS inside the data-bs-target
197 </button>
198
199 <br><br>
200
201 <button type="button" class="btn btn-secondary btn-lg" id="btnPreventModal">
202 Launch prevented modal on hide (to see the result open your console)
203 </button>
204 </div>
205
206 <script src="../../../dist/js/bootstrap.bundle.js"></script>
207 <script>
208 /* global bootstrap: false */
209
210 const ffBugTestResult = document.getElementById('ff-bug-test-result')
211 const firefoxTestDone = false
212
213 function reportFirefoxTestResult(result) {
214 if (!firefoxTestDone) {
215 ffBugTestResult.classList.add(result ? 'text-success' : 'text-danger')
216 ffBugTestResult.textContent = result ? 'PASS' : 'FAIL'
217 }
218 }
219
220 document.querySelectorAll('[data-bs-toggle="popover"]').forEach(popoverEl => new bootstrap.Popover(popoverEl))
221
222 document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipEl => new bootstrap.Tooltip(tooltipEl))
223
224 const tall = document.getElementById('tall')
225 document.getElementById('tall-toggle').addEventListener('click', () => {
226 tall.style.display = tall.style.display === 'none' ? 'block' : 'none'
227 })
228
229 const ffBugInput = document.getElementById('ff-bug-input')
230 const firefoxModal = document.getElementById('firefoxModal')
231 function handlerClickFfBugInput() {
232 firefoxModal.addEventListener('focus', reportFirefoxTestResult.bind(false))
233 ffBugInput.addEventListener('focus', reportFirefoxTestResult.bind(true))
234 ffBugInput.removeEventListener('focus', handlerClickFfBugInput)
235 }
236
237 ffBugInput.addEventListener('focus', handlerClickFfBugInput)
238
239 const modalFf = new bootstrap.Modal(firefoxModal)
240
241 document.getElementById('btnPreventModal').addEventListener('click', () => {
242 const shownFirefoxModal = () => {
243 modalFf.hide()
244 firefoxModal.removeEventListener('shown.bs.modal', hideFirefoxModal)
245 }
246
247 const hideFirefoxModal = event => {
248 event.preventDefault()
249 firefoxModal.removeEventListener('hide.bs.modal', hideFirefoxModal)
250
251 if (modalFf._isTransitioning) {
252 console.error('Modal plugin should not set _isTransitioning when hide event is prevented')
253 } else {
254 console.log('Test passed')
255 modalFf.hide() // work as expected
256 }
257 }
258
259 firefoxModal.addEventListener('shown.bs.modal', shownFirefoxModal)
260 firefoxModal.addEventListener('hide.bs.modal', hideFirefoxModal)
261 modalFf.show()
262 })
263
264 // Test transition duration
265 let t0
266 let t1
267 const slowModal = document.getElementById('slowModal')
268
269 slowModal.addEventListener('shown.bs.modal', () => {
270 t1 = performance.now()
271 console.log(`transition-duration took ${t1 - t0}ms.`)
272 })
273
274 slowModal.addEventListener('show.bs.modal', () => {
275 t0 = performance.now()
276 })
277 </script>
278 </body>
279 </html>