1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-29 14:59:16 +02:00

Use Babel and ES6 in docs JS files (#31607)

* Pass docs js through Babel

* Use ES6 in docs js

* Only run babel on src files

* Allow babel in Hugo

* Update scripts.html

* Inherit from the root .eslintrc.json

* Use `Array.from`

* Drop Babel from docs

* Prefer template

* replace IIFE with arrow functions

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Co-authored-by: GeoSot <geo.sotis@gmail.com>
This commit is contained in:
Tiger Oakes
2022-04-12 08:07:25 -07:00
committed by GitHub
parent f6cb4b64b5
commit fe257823ec
11 changed files with 122 additions and 167 deletions

View File

@@ -1,24 +1,24 @@
/* global bootstrap: false */
(function () {
(() => {
'use strict'
// Tooltip and popover demos
document.querySelectorAll('.tooltip-demo')
.forEach(function (tooltip) {
.forEach(tooltip => {
new bootstrap.Tooltip(tooltip, {
selector: '[data-bs-toggle="tooltip"]'
})
})
document.querySelectorAll('[data-bs-toggle="popover"]')
.forEach(function (popover) {
.forEach(popover => {
new bootstrap.Popover(popover)
})
document.querySelectorAll('.toast')
.forEach(function (toastNode) {
var toast = new bootstrap.Toast(toastNode, {
.forEach(toastNode => {
const toast = new bootstrap.Toast(toastNode, {
autohide: false
})
@@ -27,27 +27,27 @@
// Disable empty links and submit buttons
document.querySelectorAll('[href="#"], [type="submit"]')
.forEach(function (link) {
link.addEventListener('click', function (event) {
.forEach(link => {
link.addEventListener('click', event => {
event.preventDefault()
})
})
function setActiveItem() {
var hash = window.location.hash
const { hash } = window.location
if (hash === '') {
return
}
var link = document.querySelector('.bd-aside a[href="' + hash + '"]')
const link = document.querySelector(`.bd-aside a[href="${hash}"]`)
if (!link) {
return
}
var active = document.querySelector('.bd-aside .active')
var parent = link.parentNode.parentNode.previousElementSibling
const active = document.querySelector('.bd-aside .active')
const parent = link.parentNode.parentNode.previousElementSibling
link.classList.add('active')
@@ -59,7 +59,7 @@
return
}
var expanded = active.parentNode.parentNode.previousElementSibling
const expanded = active.parentNode.parentNode.previousElementSibling
active.classList.remove('active')