mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-02 01:42:36 +02:00
use Util.makeArray in our docs
This commit is contained in:
@@ -17,48 +17,51 @@
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
// Tooltip and popover demos
|
// Tooltip and popover demos
|
||||||
var tooltipDemoList = [].slice.call(document.querySelectorAll('.tooltip-demo'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.tooltip-demo'))
|
||||||
tooltipDemoList.forEach(function (tooltip) {
|
.forEach(function (tooltip) {
|
||||||
new bootstrap.Tooltip(tooltip, {
|
new bootstrap.Tooltip(tooltip, {
|
||||||
selector: '[data-toggle="tooltip"]'
|
selector: '[data-toggle="tooltip"]'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
var popoverList = [].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
|
bootstrap.Util.makeArray(document.querySelectorAll('[data-toggle="popover"]'))
|
||||||
popoverList.forEach(function (popover) {
|
.forEach(function (popover) {
|
||||||
new bootstrap.Popover(popover)
|
new bootstrap.Popover(popover)
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.toast')
|
bootstrap.Util.makeArray(document.querySelectorAll('.toast'))
|
||||||
.toast({
|
.forEach(function (toastNode) {
|
||||||
autohide: false
|
var toast = new bootstrap.Toast(toastNode, {
|
||||||
|
autohide: false
|
||||||
|
})
|
||||||
|
|
||||||
|
toast.show()
|
||||||
})
|
})
|
||||||
.toast('show')
|
|
||||||
|
|
||||||
// Demos within modals
|
// Demos within modals
|
||||||
var tooltipTestList = [].slice.call(document.querySelectorAll('.tooltip-test'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.tooltip-test'))
|
||||||
tooltipTestList.forEach(function (tooltip) {
|
.forEach(function (tooltip) {
|
||||||
new bootstrap.Tooltip(tooltip)
|
new bootstrap.Tooltip(tooltip)
|
||||||
})
|
})
|
||||||
|
|
||||||
var popoverTestList = [].slice.call(document.querySelectorAll('.popover-test'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.popover-test'))
|
||||||
popoverTestList.forEach(function (popover) {
|
.forEach(function (popover) {
|
||||||
new bootstrap.Popover(popover)
|
new bootstrap.Popover(popover)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Indeterminate checkbox example
|
// Indeterminate checkbox example
|
||||||
var indeterminateCheckboxList = [].slice.call(document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]'))
|
||||||
indeterminateCheckboxList.forEach(function (checkbox) {
|
.forEach(function (checkbox) {
|
||||||
checkbox.indeterminate = true
|
checkbox.indeterminate = true
|
||||||
})
|
})
|
||||||
|
|
||||||
// Disable empty links in docs examples
|
// Disable empty links in docs examples
|
||||||
var emptyLinkList = [].slice.call(document.querySelectorAll('.bd-content [href="#"]'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.bd-content [href="#"]'))
|
||||||
emptyLinkList.forEach(function (link) {
|
.forEach(function (link) {
|
||||||
link.addEventListener('click', function (e) {
|
link.addEventListener('click', function (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// Modal relatedTarget demo
|
// Modal relatedTarget demo
|
||||||
var exampleModal = document.getElementById('exampleModal')
|
var exampleModal = document.getElementById('exampleModal')
|
||||||
@@ -78,35 +81,35 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Activate animated progress bar
|
// Activate animated progress bar
|
||||||
var animatedProgressBarList = [].slice.call(document.querySelectorAll('.bd-toggle-animated-progress > .progress-bar-striped'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.bd-toggle-animated-progress > .progress-bar-striped'))
|
||||||
animatedProgressBarList.forEach(function (progressBar) {
|
.forEach(function (progressBar) {
|
||||||
progressBar.addEventListener('click', function () {
|
progressBar.addEventListener('click', function () {
|
||||||
if (progressBar.classList.contains('progress-bar-animated')) {
|
if (progressBar.classList.contains('progress-bar-animated')) {
|
||||||
progressBar.classList.remove('progress-bar-animated')
|
progressBar.classList.remove('progress-bar-animated')
|
||||||
} else {
|
} else {
|
||||||
progressBar.classList.add('progress-bar-animated')
|
progressBar.classList.add('progress-bar-animated')
|
||||||
}
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// Insert copy to clipboard button before .highlight
|
// 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>'
|
var btnHtml = '<div class="bd-clipboard"><button type="button" class="btn-clipboard" title="Copy to clipboard">Copy</button></div>'
|
||||||
var highList = [].slice.call(document.querySelectorAll('figure.highlight, div.highlight'))
|
bootstrap.Util.makeArray(document.querySelectorAll('figure.highlight, div.highlight'))
|
||||||
highList.forEach(function (element) {
|
.forEach(function (element) {
|
||||||
element.insertAdjacentHTML('beforebegin', btnHtml)
|
element.insertAdjacentHTML('beforebegin', btnHtml)
|
||||||
})
|
})
|
||||||
|
|
||||||
var copyBtnList = [].slice.call(document.querySelectorAll('.btn-clipboard'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.btn-clipboard'))
|
||||||
copyBtnList.forEach(function (btn) {
|
.forEach(function (btn) {
|
||||||
var tooltipBtn = new bootstrap.Tooltip(btn)
|
var tooltipBtn = new bootstrap.Tooltip(btn)
|
||||||
|
|
||||||
btn.addEventListener('mouseleave', function () {
|
btn.addEventListener('mouseleave', function () {
|
||||||
// Explicitly hide tooltip, since after clicking it remains
|
// Explicitly hide tooltip, since after clicking it remains
|
||||||
// focused (as it's a button), so tooltip would otherwise
|
// focused (as it's a button), so tooltip would otherwise
|
||||||
// remain visible until focus is moved away
|
// remain visible until focus is moved away
|
||||||
tooltipBtn.hide()
|
tooltipBtn.hide()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
var clipboard = new ClipboardJS('.btn-clipboard', {
|
var clipboard = new ClipboardJS('.btn-clipboard', {
|
||||||
target: function (trigger) {
|
target: function (trigger) {
|
||||||
@@ -145,13 +148,13 @@
|
|||||||
anchors.add('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5')
|
anchors.add('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5')
|
||||||
|
|
||||||
// Wrap inner
|
// Wrap inner
|
||||||
var hList = [].slice.call(document.querySelectorAll('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5'))
|
bootstrap.Util.makeArray(document.querySelectorAll('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5'))
|
||||||
hList.forEach(function (hEl) {
|
.forEach(function (hEl) {
|
||||||
var span = document.createElement('span')
|
var span = document.createElement('span')
|
||||||
span.classList.add('bd-content-title')
|
span.classList.add('bd-content-title')
|
||||||
hEl.parentElement.insertBefore(span, hEl)
|
hEl.parentElement.insertBefore(span, hEl)
|
||||||
span.appendChild(hEl)
|
span.appendChild(hEl)
|
||||||
})
|
})
|
||||||
|
|
||||||
bsCustomFileInput.init()
|
bsCustomFileInput.init()
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user