]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Backport search.js changes from v4-dev.
authorXhmikosR <xhmikosr@gmail.com>
Thu, 22 Nov 2018 19:13:15 +0000 (21:13 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 10 Dec 2018 09:08:34 +0000 (11:08 +0200)
docs/assets/js/src/search.js

index 53fec2a7021b07e79526abaccbaa157c14824b69..72b1ec71a4ebd4a594dfa7bce3fce9bcb1f7a974 100644 (file)
     apiKey: 'c8948afa20e6437a6e829f7e87b9ac11',
     indexName: 'bootstrap-v3',
     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) {
       return hits.map(function (hit) {
         var siteurl = getOrigin()
         // 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
       })
     },