1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-25 22:41:20 +02:00

Refactor util plugin and some tests

This commit is contained in:
Johann-S
2018-09-14 14:27:30 +02:00
committed by XhmikosR
parent 19b836c907
commit a2f1d79045
12 changed files with 458 additions and 448 deletions

View File

@@ -17,13 +17,14 @@
document.addEventListener('DOMContentLoaded', function () {
// Tooltip and popover demos
var tooltipDemoList = document.querySelectorAll('.tooltip-demo')
var tooltipDemoList = [].slice.call(document.querySelectorAll('.tooltip-demo'))
tooltipDemoList.forEach(function (tooltip) {
new bootstrap.Tooltip(tooltip, {
selector: '[data-toggle="tooltip"]'
})
})
var popoverList = document.querySelectorAll('[data-toggle="popover"]')
var popoverList = [].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
popoverList.forEach(function (popover) {
new bootstrap.Popover(popover)
})
@@ -35,24 +36,24 @@
.toast('show')
// Demos within modals
var tooltipTestList = document.querySelectorAll('.tooltip-test')
var tooltipTestList = [].slice.call(document.querySelectorAll('.tooltip-test'))
tooltipTestList.forEach(function (tooltip) {
new bootstrap.Tooltip(tooltip)
})
var popoverTestList = document.querySelectorAll('.popover-test')
var popoverTestList = [].slice.call(document.querySelectorAll('.popover-test'))
popoverTestList.forEach(function (popover) {
new bootstrap.Popover(popover)
})
// Indeterminate checkbox example
var indeterminateCheckboxList = document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]')
var indeterminateCheckboxList = [].slice.call(document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]'))
indeterminateCheckboxList.forEach(function (checkbox) {
checkbox.indeterminate = true
})
// Disable empty links in docs examples
var emptyLinkList = document.querySelectorAll('.bd-content [href="#"]')
var emptyLinkList = [].slice.call(document.querySelectorAll('.bd-content [href="#"]'))
emptyLinkList.forEach(function (link) {
link.addEventListener('click', function (e) {
e.preventDefault()
@@ -77,7 +78,7 @@
}
// Activate animated progress bar
var animatedProgressBarList = document.querySelectorAll('.bd-toggle-animated-progress > .progress-bar-striped')
var animatedProgressBarList = [].slice.call(document.querySelectorAll('.bd-toggle-animated-progress > .progress-bar-striped'))
animatedProgressBarList.forEach(function (progressBar) {
progressBar.addEventListener('click', function () {
if (progressBar.classList.contains('progress-bar-animated')) {
@@ -89,9 +90,9 @@
})
// Insert copy to clipboard button before .highlight
var hightList = [].slice.call(document.querySelectorAll('figure.highlight, div.highlight'))
var btnHtml = '<div class="bd-clipboard"><button type="button" class="btn-clipboard" title="Copy to clipboard">Copy</button></div>'
hightList.forEach(function (element) {
var highList = [].slice.call(document.querySelectorAll('figure.highlight, div.highlight'))
highList.forEach(function (element) {
element.insertAdjacentHTML('beforebegin', btnHtml)
})