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'
|
|
|
|
|
|
|
|
if (!window.docsearch) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var inputElement = document.getElementById('search-input')
|
|
|
|
var siteDocsVersion = inputElement.getAttribute('data-docs-version')
|
|
|
|
|
2018-10-19 18:43:12 +02:00
|
|
|
function getOrigin() {
|
|
|
|
var location = window.location
|
|
|
|
var origin = location.origin
|
|
|
|
|
|
|
|
if (!origin) {
|
|
|
|
var port = location.port ? ':' + location.port : ''
|
|
|
|
|
|
|
|
origin = location.protocol + '//' + location.hostname + port
|
|
|
|
}
|
|
|
|
|
|
|
|
return origin
|
|
|
|
}
|
|
|
|
|
2018-04-09 22:53:45 +02:00
|
|
|
window.docsearch({
|
|
|
|
apiKey: '5990ad008512000bba2cf951ccf0332f',
|
|
|
|
indexName: 'bootstrap',
|
|
|
|
inputSelector: '#search-input',
|
|
|
|
algoliaOptions: {
|
|
|
|
facetFilters: ['version:' + siteDocsVersion]
|
|
|
|
},
|
|
|
|
handleSelected: function (input, event, suggestion) {
|
|
|
|
var url = suggestion.url
|
|
|
|
url = suggestion.isLvl1 ? url.split('#')[0] : url
|
|
|
|
// If it's a title we remove the anchor so it does not jump.
|
|
|
|
window.location.href = url
|
|
|
|
},
|
|
|
|
transformData: function (hits) {
|
|
|
|
return hits.map(function (hit) {
|
2018-10-19 18:43:12 +02:00
|
|
|
var siteurl = getOrigin()
|
2018-04-09 22:53:45 +02:00
|
|
|
var urlRE = /^https?:\/\/getbootstrap\.com/
|
|
|
|
|
2018-10-19 18:43:12 +02:00
|
|
|
// When in production, return the result as is,
|
|
|
|
// otherwise remove our url from it.
|
2018-04-09 22:53:45 +02:00
|
|
|
hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
|
|
|
|
|
|
|
|
return hit
|
|
|
|
})
|
|
|
|
},
|
|
|
|
debug: false // Set debug to true if you want to inspect the dropdown
|
|
|
|
})
|
|
|
|
}())
|