summaryrefslogtreecommitdiffstats
path: root/site/assets/js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-24 12:33:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-24 12:33:51 +0000
commit3ea39841c8049525e31e9f4d6300f0c60cdb42de (patch)
tree855de60a8872eafb5911acd303aedcdbfe713a73 /site/assets/js
parentInital commit. (diff)
downloadbootstrap-html-3ea39841c8049525e31e9f4d6300f0c60cdb42de.tar.xz
bootstrap-html-3ea39841c8049525e31e9f4d6300f0c60cdb42de.zip
Adding upstream version 5.2.3+dfsg.upstream/5.2.3+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'site/assets/js')
-rw-r--r--site/assets/js/application.js30
-rw-r--r--site/assets/js/code-examples.js88
-rw-r--r--site/assets/js/search.js47
-rw-r--r--site/assets/js/snippets.js154
4 files changed, 319 insertions, 0 deletions
diff --git a/site/assets/js/application.js b/site/assets/js/application.js
new file mode 100644
index 0000000..dec2363
--- /dev/null
+++ b/site/assets/js/application.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-2022 The Bootstrap Authors
+ * Copyright 2011-2022 Twitter, Inc.
+ * Licensed under the Creative Commons Attribution 3.0 Unported License.
+ * For details, see https://creativecommons.org/licenses/by/3.0/.
+ */
+
+(() => {
+ 'use strict'
+
+ // Scroll the active sidebar link into view
+ const sidenav = document.querySelector('.bd-sidebar')
+ if (sidenav) {
+ const sidenavHeight = sidenav.clientHeight
+ const sidenavActiveLink = document.querySelector('.bd-links-nav .active')
+ 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/site/assets/js/code-examples.js b/site/assets/js/code-examples.js
new file mode 100644
index 0000000..25486c2
--- /dev/null
+++ b/site/assets/js/code-examples.js
@@ -0,0 +1,88 @@
+// 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-2022 The Bootstrap Authors
+ * Copyright 2011-2022 Twitter, Inc.
+ * Licensed under the Creative Commons Attribution 3.0 Unported License.
+ * For details, see https://creativecommons.org/licenses/by/3.0/.
+ */
+
+/* global ClipboardJS: false, bootstrap: false */
+
+(() => {
+ 'use strict'
+ // 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 => {
+ if (!element.closest('.bd-example-snippet')) { // Ignore examples made be shortcode
+ 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')
+ })
+
+ clipboard.on('success', event => {
+ const iconFirstChild = event.trigger.querySelector('.bi').firstChild
+ 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
+
+ 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/site/assets/js/search.js b/site/assets/js/search.js
new file mode 100644
index 0000000..9bad274
--- /dev/null
+++ b/site/assets/js/search.js
@@ -0,0 +1,47 @@
+// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
+// IT'S ALL JUST JUNK FOR OUR DOCS!
+// ++++++++++++++++++++++++++++++++++++++++++
+
+(() => {
+ 'use strict'
+
+ const searchElement = document.getElementById('docsearch')
+
+ if (!window.docsearch || !searchElement) {
+ return
+ }
+
+ const siteDocsVersion = searchElement.getAttribute('data-bd-docs-version')
+
+ window.docsearch({
+ apiKey: '3151f502c7b9e9dafd5e6372b691a24e',
+ indexName: 'bootstrap',
+ appId: 'AK7KMZKZHQ',
+ container: searchElement,
+ searchParameters: {
+ facetFilters: [`version:${siteDocsVersion}`]
+ },
+ transformItems(items) {
+ return items.map(item => {
+ const liveUrl = 'https://getbootstrap.com/'
+
+ item.url = window.location.origin.startsWith(liveUrl) ?
+ // On production, return the result as is
+ item.url :
+ // On development or Netlify, replace `item.url` with a trailing slash,
+ // so that the result link is relative to the server root
+ item.url.replace(liveUrl, '/')
+
+ // Prevent jumping to first header
+ if (item.anchor === 'content') {
+ item.url = item.url.replace(/#content$/, '')
+ item.anchor = null
+ }
+
+ return item
+ })
+ },
+ // Set debug to `true` if you want to inspect the dropdown
+ debug: false
+ })
+})()
diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js
new file mode 100644
index 0000000..53f8a78
--- /dev/null
+++ b/site/assets/js/snippets.js
@@ -0,0 +1,154 @@
+// 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-2022 The Bootstrap Authors
+ * Copyright 2011-2022 Twitter, Inc.
+ * Licensed under the Creative Commons Attribution 3.0 Unported License.
+ * For details, see https://creativecommons.org/licenses/by/3.0/.
+ */
+
+/* global bootstrap: false */
+
+(() => {
+ 'use strict'
+
+ // --------
+ // Tooltips
+ // --------
+ // Instantiate all tooltips in a docs or StackBlitz page
+ document.querySelectorAll('[data-bs-toggle="tooltip"]')
+ .forEach(tooltip => {
+ new bootstrap.Tooltip(tooltip)
+ })
+
+ // --------
+ // Popovers
+ // --------
+ // Instantiate all popovers in a docs or StackBlitz page
+ 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 a docs page only
+ document.querySelectorAll('.bd-example .toast')
+ .forEach(toastNode => {
+ const toast = new bootstrap.Toast(toastNode, {
+ autohide: false
+ })
+
+ toast.show()
+ })
+
+ // Instantiate all toasts in a docs page only
+ const toastTrigger = document.getElementById('liveToastBtn')
+ const toastLiveExample = document.getElementById('liveToast')
+ if (toastTrigger) {
+ toastTrigger.addEventListener('click', () => {
+ const toast = new bootstrap.Toast(toastLiveExample)
+
+ toast.show()
+ })
+ }
+
+ // -------------------------------
+ // Alerts
+ // -------------------------------
+ // Used in 'Show live toast' example in docs or StackBlitz
+ const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
+ const alertTrigger = document.getElementById('liveAlertBtn')
+
+ 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)
+ }
+
+ if (alertTrigger) {
+ alertTrigger.addEventListener('click', () => {
+ appendAlert('Nice, you triggered this alert message!', 'success')
+ })
+ }
+
+ // -------------------------------
+ // 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
+ 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')
+
+ // 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
+ })
+ }
+
+ // -------------------------------
+ // 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)
+ })
+ }
+})()