1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-28 15:50:01 +02:00

move util in a util folder with the sanitizer

This commit is contained in:
Johann-S
2019-02-23 00:37:55 +02:00
committed by XhmikosR
parent 8affe84c72
commit 8a37045b79
34 changed files with 559 additions and 589 deletions

View File

@@ -15,20 +15,24 @@
(function () {
'use strict'
function makeArray(list) {
return [].slice.call(list)
}
// Tooltip and popover demos
bootstrap.Util.makeArray(document.querySelectorAll('.tooltip-demo'))
makeArray(document.querySelectorAll('.tooltip-demo'))
.forEach(function (tooltip) {
new bootstrap.Tooltip(tooltip, {
selector: '[data-toggle="tooltip"]'
})
})
bootstrap.Util.makeArray(document.querySelectorAll('[data-toggle="popover"]'))
makeArray(document.querySelectorAll('[data-toggle="popover"]'))
.forEach(function (popover) {
new bootstrap.Popover(popover)
})
bootstrap.Util.makeArray(document.querySelectorAll('.toast'))
makeArray(document.querySelectorAll('.toast'))
.forEach(function (toastNode) {
var toast = new bootstrap.Toast(toastNode, {
autohide: false
@@ -38,24 +42,24 @@
})
// Demos within modals
bootstrap.Util.makeArray(document.querySelectorAll('.tooltip-test'))
makeArray(document.querySelectorAll('.tooltip-test'))
.forEach(function (tooltip) {
new bootstrap.Tooltip(tooltip)
})
bootstrap.Util.makeArray(document.querySelectorAll('.popover-test'))
makeArray(document.querySelectorAll('.popover-test'))
.forEach(function (popover) {
new bootstrap.Popover(popover)
})
// Indeterminate checkbox example
bootstrap.Util.makeArray(document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]'))
makeArray(document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]'))
.forEach(function (checkbox) {
checkbox.indeterminate = true
})
// Disable empty links in docs examples
bootstrap.Util.makeArray(document.querySelectorAll('.bd-content [href="#"]'))
makeArray(document.querySelectorAll('.bd-content [href="#"]'))
.forEach(function (link) {
link.addEventListener('click', function (e) {
e.preventDefault()
@@ -79,7 +83,7 @@
}
// Activate animated progress bar
bootstrap.Util.makeArray(document.querySelectorAll('.bd-toggle-animated-progress > .progress-bar-striped'))
makeArray(document.querySelectorAll('.bd-toggle-animated-progress > .progress-bar-striped'))
.forEach(function (progressBar) {
progressBar.addEventListener('click', function () {
if (progressBar.classList.contains('progress-bar-animated')) {
@@ -92,12 +96,12 @@
// Insert copy to clipboard button before .highlight
var btnHtml = '<div class="bd-clipboard"><button type="button" class="btn-clipboard" title="Copy to clipboard">Copy</button></div>'
bootstrap.Util.makeArray(document.querySelectorAll('figure.highlight, div.highlight'))
makeArray(document.querySelectorAll('figure.highlight, div.highlight'))
.forEach(function (element) {
element.insertAdjacentHTML('beforebegin', btnHtml)
})
bootstrap.Util.makeArray(document.querySelectorAll('.btn-clipboard'))
makeArray(document.querySelectorAll('.btn-clipboard'))
.forEach(function (btn) {
var tooltipBtn = new bootstrap.Tooltip(btn)
@@ -146,7 +150,7 @@
anchors.add('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5')
// Wrap inner
bootstrap.Util.makeArray(document.querySelectorAll('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5'))
makeArray(document.querySelectorAll('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5'))
.forEach(function (hEl) {
hEl.innerHTML = '<span class="bd-content-title">' + hEl.innerHTML + '</span>'
})

View File

@@ -134,12 +134,6 @@ Bootstrap's plugins don't fall back particularly gracefully when JavaScript is d
{% endcapture %}
{% include callout.html content=callout type="warning" %}
## Util
All Bootstrap's JavaScript files depend on `util.js` and it has to be included alongside the other JavaScript files. If you're using the compiled (or minified) `bootstrap.js`, there is no need to include this—it's already there.
`util.js` includes utility functions and a basic helper for `transitionEnd` events as well as a CSS transition emulator. It's used by the other plugins to check for CSS transition support and to catch hanging transitions.
## Sanitizer
Tooltips and Popovers use our built-in sanitizer to sanitize options which accept HTML.

View File

@@ -21,7 +21,6 @@ import 'bootstrap';
Alternatively, you may **import plugins individually** as needed:
{% highlight js %}
import 'bootstrap/js/dist/util';
import 'bootstrap/js/dist/alert';
...
{% endhighlight %}