-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9462c36
commit b7da07f
Showing
10 changed files
with
3,574 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
docs/docsets/.docset/Contents/Resources/Documents/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions
70
docs/docsets/.docset/Contents/Resources/Documents/js/jazzy.search.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
$(function(){ | ||
var $typeahead = $('[data-typeahead]'); | ||
var $form = $typeahead.parents('form'); | ||
var searchURL = $form.attr('action'); | ||
|
||
function displayTemplate(result) { | ||
return result.name; | ||
} | ||
|
||
function suggestionTemplate(result) { | ||
var t = '<div class="list-group-item clearfix">'; | ||
t += '<span class="doc-name">' + result.name + '</span>'; | ||
if (result.parent_name) { | ||
t += '<span class="doc-parent-name label">' + result.parent_name + '</span>'; | ||
} | ||
t += '</div>'; | ||
return t; | ||
} | ||
|
||
$typeahead.one('focus', function() { | ||
$form.addClass('loading'); | ||
|
||
$.getJSON(searchURL).then(function(searchData) { | ||
const searchIndex = lunr(function() { | ||
this.ref('url'); | ||
this.field('name'); | ||
this.field('abstract'); | ||
for (const [url, doc] of Object.entries(searchData)) { | ||
this.add({url: url, name: doc.name, abstract: doc.abstract}); | ||
} | ||
}); | ||
|
||
$typeahead.typeahead( | ||
{ | ||
highlight: true, | ||
minLength: 3, | ||
autoselect: true | ||
}, | ||
{ | ||
limit: 10, | ||
display: displayTemplate, | ||
templates: { suggestion: suggestionTemplate }, | ||
source: function(query, sync) { | ||
const lcSearch = query.toLowerCase(); | ||
const results = searchIndex.query(function(q) { | ||
q.term(lcSearch, { boost: 100 }); | ||
q.term(lcSearch, { | ||
boost: 10, | ||
wildcard: lunr.Query.wildcard.TRAILING | ||
}); | ||
}).map(function(result) { | ||
var doc = searchData[result.ref]; | ||
doc.url = result.ref; | ||
return doc; | ||
}); | ||
sync(results); | ||
} | ||
} | ||
); | ||
$form.removeClass('loading'); | ||
$typeahead.trigger('focus'); | ||
}); | ||
}); | ||
|
||
var baseURL = searchURL.slice(0, -"search.json".length); | ||
|
||
$typeahead.on('typeahead:select', function(e, result) { | ||
window.location = baseURL + result.url; | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
docs/docsets/.docset/Contents/Resources/Documents/js/lunr.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.