mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-20 20:00:36 +03:00
Backport search.js changes from v4-dev.
This commit is contained in:
@@ -28,12 +28,6 @@
|
|||||||
apiKey: 'c8948afa20e6437a6e829f7e87b9ac11',
|
apiKey: 'c8948afa20e6437a6e829f7e87b9ac11',
|
||||||
indexName: 'bootstrap-v3',
|
indexName: 'bootstrap-v3',
|
||||||
inputSelector: '#search-input',
|
inputSelector: '#search-input',
|
||||||
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) {
|
transformData: function (hits) {
|
||||||
return hits.map(function (hit) {
|
return hits.map(function (hit) {
|
||||||
var siteurl = getOrigin()
|
var siteurl = getOrigin()
|
||||||
@@ -43,6 +37,12 @@
|
|||||||
// otherwise remove our url from it.
|
// otherwise remove our url from it.
|
||||||
hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
|
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
|
return hit
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user