diff options
author | XhmikosR <xhmikosr@gmail.com> | 2019-01-08 19:33:28 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2019-03-13 20:22:59 +0300 |
commit | d95d30029f8d63190eb242c9914cee16b6b90627 (patch) | |
tree | 06fbab510fa94ac092606eb04b37d061e64d8fbc /site/static/docs/4.3/assets/js/src/search.js | |
parent | 6aa475c82e69a02882e87da7067e522806d6579c (diff) |
Switch to Hugo.
No more Ruby dependency and most important more than 10 times less build time (at least on Windows)!
Diffstat (limited to 'site/static/docs/4.3/assets/js/src/search.js')
-rw-r--r-- | site/static/docs/4.3/assets/js/src/search.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/site/static/docs/4.3/assets/js/src/search.js b/site/static/docs/4.3/assets/js/src/search.js new file mode 100644 index 0000000000..dc222508d6 --- /dev/null +++ b/site/static/docs/4.3/assets/js/src/search.js @@ -0,0 +1,55 @@ +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT +// IT'S ALL JUST JUNK FOR OUR DOCS! +// ++++++++++++++++++++++++++++++++++++++++++ + +(function () { + 'use strict' + + if (!window.docsearch) { + return + } + + var inputElement = document.getElementById('search-input') + var siteDocsVersion = inputElement.getAttribute('data-docs-version') + + 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 + } + + window.docsearch({ + apiKey: '5990ad008512000bba2cf951ccf0332f', + indexName: 'bootstrap', + inputSelector: '#search-input', + algoliaOptions: { + facetFilters: ['version:' + siteDocsVersion] + }, + transformData: function (hits) { + return hits.map(function (hit) { + var siteurl = getOrigin() + var urlRE = /^https?:\/\/getbootstrap\.com/ + + // When in production, return the result as is, + // otherwise remove our url from it. + hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '') + + // Prevent jumping to first header + if (hit.anchor === 'content') { + hit.url = hit.url.replace(/#content$/, '') + hit.anchor = null + } + + return hit + }) + }, + debug: false // Set debug to true if you want to inspect the dropdown + }) +})() |