aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/site/assets/js/partials
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/site/assets/js/partials')
-rw-r--r--vendor/twbs/bootstrap/site/assets/js/partials/code-examples.js95
-rw-r--r--vendor/twbs/bootstrap/site/assets/js/partials/sidebar.js30
-rw-r--r--vendor/twbs/bootstrap/site/assets/js/partials/snippets.js168
3 files changed, 293 insertions, 0 deletions
diff --git a/vendor/twbs/bootstrap/site/assets/js/partials/code-examples.js b/vendor/twbs/bootstrap/site/assets/js/partials/code-examples.js
new file mode 100644
index 000000000..1e86df9f9
--- /dev/null
+++ b/vendor/twbs/bootstrap/site/assets/js/partials/code-examples.js
@@ -0,0 +1,95 @@
+// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
+// IT'S ALL JUST JUNK FOR OUR DOCS!
+// ++++++++++++++++++++++++++++++++++++++++++
+
+/*
+ * JavaScript for Bootstrap's docs (https://getbootstrap.com/)
+ * Copyright 2011-2025 The Bootstrap Authors
+ * Licensed under the Creative Commons Attribution 3.0 Unported License.
+ * For details, see https://creativecommons.org/licenses/by/3.0/.
+ */
+
+/* global bootstrap: false */
+
+import ClipboardJS from 'clipboard'
+
+export default () => {
+ // Insert copy to clipboard button before .highlight
+ const btnTitle = 'Copy to clipboard'
+ const btnEdit = 'Edit on StackBlitz'
+
+ const btnHtml = [
+ '<div class="bd-code-snippet">',
+ ' <div class="bd-clipboard">',
+ ' <button type="button" class="btn-clipboard">',
+ ' <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>',
+ ' </button>',
+ ' </div>',
+ '</div>'
+ ].join('')
+
+ // Wrap programmatically code blocks and add copy btn.
+ document.querySelectorAll('.highlight')
+ .forEach(element => {
+ // Ignore examples made by shortcode
+ if (!element.closest('.bd-example-snippet')) {
+ element.insertAdjacentHTML('beforebegin', btnHtml)
+ element.previousElementSibling.append(element)
+ }
+ })
+
+ /**
+ *
+ * @param {string} selector
+ * @param {string} title
+ */
+ function snippetButtonTooltip(selector, title) {
+ document.querySelectorAll(selector).forEach(btn => {
+ bootstrap.Tooltip.getOrCreateInstance(btn, { title })
+ })
+ }
+
+ snippetButtonTooltip('.btn-clipboard', btnTitle)
+ snippetButtonTooltip('.btn-edit', btnEdit)
+
+ const clipboard = new ClipboardJS('.btn-clipboard', {
+ target: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight'),
+ text: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight').textContent.trimEnd()
+ })
+
+ clipboard.on('success', event => {
+ const iconFirstChild = event.trigger.querySelector('.bi').firstElementChild
+ const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
+ const namespace = 'http://www.w3.org/1999/xlink'
+ const originalXhref = iconFirstChild.getAttributeNS(namespace, 'href')
+ const originalTitle = event.trigger.title
+ const isCheckIconVisible = originalXhref === '#check2'
+
+ if (isCheckIconVisible) {
+ return
+ }
+
+ tooltipBtn.setContent({ '.tooltip-inner': 'Copied!' })
+ event.trigger.addEventListener('hidden.bs.tooltip', () => {
+ tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
+ }, { once: true })
+ event.clearSelection()
+ iconFirstChild.setAttributeNS(namespace, 'href', originalXhref.replace('clipboard', 'check2'))
+
+ setTimeout(() => {
+ iconFirstChild.setAttributeNS(namespace, 'href', originalXhref)
+ event.trigger.title = originalTitle
+ }, 2000)
+ })
+
+ clipboard.on('error', event => {
+ const modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
+ const fallbackMsg = `Press ${modifierKey}C to copy`
+ const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
+
+ tooltipBtn.setContent({ '.tooltip-inner': fallbackMsg })
+ event.trigger.addEventListener('hidden.bs.tooltip', () => {
+ tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
+ }, { once: true })
+ })
+}
diff --git a/vendor/twbs/bootstrap/site/assets/js/partials/sidebar.js b/vendor/twbs/bootstrap/site/assets/js/partials/sidebar.js
new file mode 100644
index 000000000..bf42e7b5e
--- /dev/null
+++ b/vendor/twbs/bootstrap/site/assets/js/partials/sidebar.js
@@ -0,0 +1,30 @@
+// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
+// IT'S ALL JUST JUNK FOR OUR DOCS!
+// ++++++++++++++++++++++++++++++++++++++++++
+
+/*
+ * JavaScript for Bootstrap's docs (https://getbootstrap.com/)
+ * Copyright 2011-2025 The Bootstrap Authors
+ * Licensed under the Creative Commons Attribution 3.0 Unported License.
+ * For details, see https://creativecommons.org/licenses/by/3.0/.
+ */
+
+export default () => {
+ // Scroll the active sidebar link into view
+ const sidenav = document.querySelector('.bd-sidebar')
+ const sidenavActiveLink = document.querySelector('.bd-links-nav .active')
+
+ if (!sidenav || !sidenavActiveLink) {
+ return
+ }
+
+ const sidenavHeight = sidenav.clientHeight
+ const sidenavActiveLinkTop = sidenavActiveLink.offsetTop
+ const sidenavActiveLinkHeight = sidenavActiveLink.clientHeight
+ const viewportTop = sidenavActiveLinkTop
+ const viewportBottom = viewportTop - sidenavHeight + sidenavActiveLinkHeight
+
+ if (sidenav.scrollTop > viewportTop || sidenav.scrollTop < viewportBottom) {
+ sidenav.scrollTop = viewportTop - (sidenavHeight / 2) + (sidenavActiveLinkHeight / 2)
+ }
+}
diff --git a/vendor/twbs/bootstrap/site/assets/js/partials/snippets.js b/vendor/twbs/bootstrap/site/assets/js/partials/snippets.js
new file mode 100644
index 000000000..498071b41
--- /dev/null
+++ b/vendor/twbs/bootstrap/site/assets/js/partials/snippets.js
@@ -0,0 +1,168 @@
+// NOTICE!!! Initially embedded in our docs this JavaScript
+// file contains elements that can help you create reproducible
+// use cases in StackBlitz for instance.
+// In a real project please adapt this content to your needs.
+// ++++++++++++++++++++++++++++++++++++++++++
+
+/*
+ * JavaScript for Bootstrap's docs (https://getbootstrap.com/)
+ * Copyright 2011-2025 The Bootstrap Authors
+ * Licensed under the Creative Commons Attribution 3.0 Unported License.
+ * For details, see https://creativecommons.org/licenses/by/3.0/.
+ */
+
+/* global bootstrap: false */
+
+export default () => {
+ // --------
+ // Tooltips
+ // --------
+ // Instantiate all tooltips in a docs or StackBlitz
+ document.querySelectorAll('[data-bs-toggle="tooltip"]')
+ .forEach(tooltip => {
+ new bootstrap.Tooltip(tooltip)
+ })
+
+ // --------
+ // Popovers
+ // --------
+ // Instantiate all popovers in docs or StackBlitz
+ document.querySelectorAll('[data-bs-toggle="popover"]')
+ .forEach(popover => {
+ new bootstrap.Popover(popover)
+ })
+
+ // -------------------------------
+ // Toasts
+ // -------------------------------
+ // Used by 'Placement' example in docs or StackBlitz
+ const toastPlacement = document.getElementById('toastPlacement')
+ if (toastPlacement) {
+ document.getElementById('selectToastPlacement').addEventListener('change', function () {
+ if (!toastPlacement.dataset.originalClass) {
+ toastPlacement.dataset.originalClass = toastPlacement.className
+ }
+
+ toastPlacement.className = `${toastPlacement.dataset.originalClass} ${this.value}`
+ })
+ }
+
+ // Instantiate all toasts in docs pages only
+ document.querySelectorAll('.bd-example .toast')
+ .forEach(toastNode => {
+ const toast = new bootstrap.Toast(toastNode, {
+ autohide: false
+ })
+
+ toast.show()
+ })
+
+ // Instantiate all toasts in docs pages only
+ // js-docs-start live-toast
+ const toastTrigger = document.getElementById('liveToastBtn')
+ const toastLiveExample = document.getElementById('liveToast')
+
+ if (toastTrigger) {
+ const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
+ toastTrigger.addEventListener('click', () => {
+ toastBootstrap.show()
+ })
+ }
+ // js-docs-end live-toast
+
+ // -------------------------------
+ // Alerts
+ // -------------------------------
+ // Used in 'Show live alert' example in docs or StackBlitz
+
+ // js-docs-start live-alert
+ const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
+ const appendAlert = (message, type) => {
+ const wrapper = document.createElement('div')
+ wrapper.innerHTML = [
+ `<div class="alert alert-${type} alert-dismissible" role="alert">`,
+ ` <div>${message}</div>`,
+ ' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
+ '</div>'
+ ].join('')
+
+ alertPlaceholder.append(wrapper)
+ }
+
+ const alertTrigger = document.getElementById('liveAlertBtn')
+ if (alertTrigger) {
+ alertTrigger.addEventListener('click', () => {
+ appendAlert('Nice, you triggered this alert message!', 'success')
+ })
+ }
+ // js-docs-end live-alert
+
+ // --------
+ // Carousels
+ // --------
+ // Instantiate all non-autoplaying carousels in docs or StackBlitz
+ document.querySelectorAll('.carousel:not([data-bs-ride="carousel"])')
+ .forEach(carousel => {
+ bootstrap.Carousel.getOrCreateInstance(carousel)
+ })
+
+ // -------------------------------
+ // Checks & Radios
+ // -------------------------------
+ // Indeterminate checkbox example in docs and StackBlitz
+ document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]')
+ .forEach(checkbox => {
+ if (checkbox.id.includes('Indeterminate')) {
+ checkbox.indeterminate = true
+ }
+ })
+
+ // -------------------------------
+ // Links
+ // -------------------------------
+ // Disable empty links in docs examples only
+ document.querySelectorAll('.bd-content [href="#"]')
+ .forEach(link => {
+ link.addEventListener('click', event => {
+ event.preventDefault()
+ })
+ })
+
+ // -------------------------------
+ // Modal
+ // -------------------------------
+ // Modal 'Varying modal content' example in docs and StackBlitz
+ // js-docs-start varying-modal-content
+ const exampleModal = document.getElementById('exampleModal')
+ if (exampleModal) {
+ exampleModal.addEventListener('show.bs.modal', event => {
+ // Button that triggered the modal
+ const button = event.relatedTarget
+ // Extract info from data-bs-* attributes
+ const recipient = button.getAttribute('data-bs-whatever')
+ // If necessary, you could initiate an Ajax request here
+ // and then do the updating in a callback.
+
+ // Update the modal's content.
+ const modalTitle = exampleModal.querySelector('.modal-title')
+ const modalBodyInput = exampleModal.querySelector('.modal-body input')
+
+ modalTitle.textContent = `New message to ${recipient}`
+ modalBodyInput.value = recipient
+ })
+ }
+ // js-docs-end varying-modal-content
+
+ // -------------------------------
+ // Offcanvas
+ // -------------------------------
+ // 'Offcanvas components' example in docs only
+ const myOffcanvas = document.querySelectorAll('.bd-example-offcanvas .offcanvas')
+ if (myOffcanvas) {
+ myOffcanvas.forEach(offcanvas => {
+ offcanvas.addEventListener('show.bs.offcanvas', event => {
+ event.preventDefault()
+ }, false)
+ })
+ }
+}