| 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>Tooltip</title> |
| 8 | <style> |
| 9 | #target { |
| 10 | border: 1px solid; |
| 11 | width: 100px; |
| 12 | height: 50px; |
| 13 | margin-left: 50px; |
| 14 | transform: rotate(270deg); |
| 15 | margin-top: 100px; |
| 16 | } |
| 17 | </style> |
| 18 | </head> |
| 19 | <body> |
| 20 | <div class="container"> |
| 21 | <h1>Tooltip <small>Bootstrap Visual Test</small></h1> |
| 22 | |
| 23 | <p class="text-body-secondary">Tight pants next level keffiyeh <a href="#" data-bs-toggle="tooltip" title="Default tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel <a href="#" data-bs-toggle="tooltip" title="Another tooltip">have a</a> terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan <a href="#" data-bs-toggle="tooltip" title="Another one here too">whatever keytar</a>, scenester farm-to-table banksy Austin <a href="#" data-bs-toggle="tooltip" title="The last tip!">freegan cred</a> raw denim single-origin coffee viral.</p> |
| 24 | |
| 25 | <hr> |
| 26 | |
| 27 | <div class="row"> |
| 28 | <p> |
| 29 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="auto" title="Tooltip on auto"> |
| 30 | Tooltip on auto |
| 31 | </button> |
| 32 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top"> |
| 33 | Tooltip on top |
| 34 | </button> |
| 35 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" title="Tooltip on right"> |
| 36 | Tooltip on end |
| 37 | </button> |
| 38 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Tooltip on bottom"> |
| 39 | Tooltip on bottom |
| 40 | </button> |
| 41 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip on left"> |
| 42 | Tooltip on start |
| 43 | </button> |
| 44 | </p> |
| 45 | </div> |
| 46 | <div class="row"> |
| 47 | <p> |
| 48 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip with container (selector)" data-bs-container="#customContainer"> |
| 49 | Tooltip with container (selector) |
| 50 | </button> |
| 51 | <button id="tooltipElement" type="button" class="btn btn-secondary" data-bs-placement="left" title="Tooltip with container (element)"> |
| 52 | Tooltip with container (element) |
| 53 | </button> |
| 54 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>"> |
| 55 | Tooltip with HTML |
| 56 | </button> |
| 57 | <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip with XSS" data-bs-container="<img src=1 onerror=alert(123)>"> |
| 58 | Tooltip with XSS |
| 59 | </button> |
| 60 | </p> |
| 61 | </div> |
| 62 | <div class="row"> |
| 63 | <div class="col-sm-3"> |
| 64 | <div id="target" title="Test tooltip on transformed element"></div> |
| 65 | </div> |
| 66 | <div id="shadow" class="pt-5"></div> |
| 67 | </div> |
| 68 | <div id="customContainer"></div> |
| 69 | |
| 70 | <div class="row mt-4 border-top"> |
| 71 | <hr> |
| 72 | <div class="h4">Test Selector triggered tooltips</div> |
| 73 | <div id="wrapperTriggeredBySelector"> |
| 74 | <div class="py-2 selectorButtonsBlock"> |
| 75 | <button type="button" class="btn btn-secondary bs-dynamic-tooltip" title="random title">Using title</button> |
| 76 | <button type="button" class="btn btn-secondary bs-dynamic-tooltip" data-bs-title="random title">Using bs-title</button> |
| 77 | </div> |
| 78 | |
| 79 | </div> |
| 80 | <div class="mt-3"> |
| 81 | <button type="button" class="btn btn-primary" onclick="duplicateButtons()">Duplicate above two buttons</button> |
| 82 | </div> |
| 83 | </div> |
| 84 | </div> |
| 85 | |
| 86 | <script src="../../../dist/js/bootstrap.bundle.js"></script> |
| 87 | <script> |
| 88 | /* global bootstrap: false */ |
| 89 | |
| 90 | if (typeof document.body.attachShadow === 'function') { |
| 91 | const shadowRoot = document.getElementById('shadow').attachShadow({ mode: 'open' }) |
| 92 | shadowRoot.innerHTML = |
| 93 | '<button id="firstShadowTooltip" type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top in a shadow dom">' + |
| 94 | ' Tooltip on top in a shadow dom' + |
| 95 | '</button>' + |
| 96 | '<button id="secondShadowTooltip" type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top in a shadow dom with container option">' + |
| 97 | ' Tooltip on top in a shadow dom' + |
| 98 | '</button>' |
| 99 | |
| 100 | new bootstrap.Tooltip(shadowRoot.firstChild) |
| 101 | new bootstrap.Tooltip(shadowRoot.getElementById('secondShadowTooltip'), { |
| 102 | container: shadowRoot |
| 103 | }) |
| 104 | } |
| 105 | |
| 106 | new bootstrap.Tooltip('#tooltipElement', { |
| 107 | container: '#customContainer' |
| 108 | }) |
| 109 | |
| 110 | const targetTooltip = new bootstrap.Tooltip('#target', { |
| 111 | placement: 'top', |
| 112 | trigger: 'manual' |
| 113 | }) |
| 114 | targetTooltip.show() |
| 115 | |
| 116 | document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(tooltipEl => new bootstrap.Tooltip(tooltipEl)) |
| 117 | </script> |
| 118 | |
| 119 | <script> |
| 120 | /* global bootstrap: false */ |
| 121 | |
| 122 | new bootstrap.Tooltip('#wrapperTriggeredBySelector', { |
| 123 | animation: false, |
| 124 | selector: '.bs-dynamic-tooltip' |
| 125 | }) |
| 126 | |
| 127 | /* eslint-disable no-unused-vars */ |
| 128 | function duplicateButtons() { |
| 129 | const buttonsBlock = document.querySelector('.selectorButtonsBlock')// get first |
| 130 | const buttonsBlockClone = buttonsBlock.cloneNode(true) |
| 131 | buttonsBlockClone.innerHTML += new Date().toLocaleString() |
| 132 | document.querySelector('#wrapperTriggeredBySelector').append(buttonsBlockClone) |
| 133 | } |
| 134 | /* eslint-enable no-unused-vars */ |
| 135 | </script> |
| 136 | |
| 137 | </body> |
| 138 | </html> |