2018-04-27 09:11:17 +02:00
|
|
|
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
|
|
|
|
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
2018-04-09 22:53:45 +02:00
|
|
|
(function () {
|
|
|
|
'use strict'
|
|
|
|
|
2020-11-09 19:47:02 +01:00
|
|
|
var inputElement = document.getElementById('search-input')
|
|
|
|
|
|
|
|
if (!window.docsearch || !inputElement) {
|
2018-04-09 22:53:45 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-11-02 09:09:32 +01:00
|
|
|
var siteDocsVersion = inputElement.getAttribute('data-bd-docs-version')
|
2018-04-09 22:53:45 +02:00
|
|
|
|
2020-11-05 17:56:02 +01:00
|
|
|
document.addEventListener('keydown', function (event) {
|
|
|
|
if (event.ctrlKey && event.key === '/') {
|
|
|
|
event.preventDefault()
|
|
|
|
inputElement.focus()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-04-09 22:53:45 +02:00
|
|
|
window.docsearch({
|
|
|
|
apiKey: '5990ad008512000bba2cf951ccf0332f',
|
|
|
|
indexName: 'bootstrap',
|
|
|
|
inputSelector: '#search-input',
|
|
|
|
algoliaOptions: {
|
|
|
|
facetFilters: ['version:' + siteDocsVersion]
|
|
|
|
},
|
|
|
|
transformData: function (hits) {
|
|
|
|
return hits.map(function (hit) {
|
2020-11-24 20:05:11 +01:00
|
|
|
var liveUrl = 'https://getbootstrap.com/'
|
2018-04-09 22:53:45 +02:00
|
|
|
|
2020-11-09 07:48:37 +01:00
|
|
|
hit.url = window.location.origin.startsWith(liveUrl) ?
|
2020-04-30 20:07:26 +02:00
|
|
|
// On production, return the result as is
|
2019-03-26 11:49:45 +01:00
|
|
|
hit.url :
|
2020-04-30 20:07:26 +02:00
|
|
|
// On development or Netlify, replace `hit.url` with a trailing slash,
|
|
|
|
// so that the result link is relative to the server root
|
|
|
|
hit.url.replace(liveUrl, '/')
|
2018-04-09 22:53:45 +02:00
|
|
|
|
2018-11-22 15:34:34 +01:00
|
|
|
// Prevent jumping to first header
|
|
|
|
if (hit.anchor === 'content') {
|
|
|
|
hit.url = hit.url.replace(/#content$/, '')
|
|
|
|
hit.anchor = null
|
|
|
|
}
|
|
|
|
|
2018-04-09 22:53:45 +02:00
|
|
|
return hit
|
|
|
|
})
|
|
|
|
},
|
2019-03-26 11:49:45 +01:00
|
|
|
// Set debug to `true` if you want to inspect the dropdown
|
|
|
|
debug: false
|
2018-04-09 22:53:45 +02:00
|
|
|
})
|
2019-02-26 12:20:34 +01:00
|
|
|
})()
|