mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-28 04:11:18 +01:00
add Jazzy docs
This commit is contained in:
43
docs/js/jazzy.js
Executable file
43
docs/js/jazzy.js
Executable file
@@ -0,0 +1,43 @@
|
||||
window.jazzy = {'docset': false}
|
||||
if (typeof window.dash != 'undefined') {
|
||||
document.documentElement.className += ' dash'
|
||||
window.jazzy.docset = true
|
||||
}
|
||||
if (navigator.userAgent.match(/xcode/i)) {
|
||||
document.documentElement.className += ' xcode'
|
||||
window.jazzy.docset = true
|
||||
}
|
||||
|
||||
// On doc load, toggle the URL hash discussion if present
|
||||
$(document).ready(function() {
|
||||
if (!window.jazzy.docset) {
|
||||
var linkToHash = $('a[href="' + window.location.hash +'"]');
|
||||
linkToHash.trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
// On token click, toggle its discussion and animate token.marginLeft
|
||||
$(".token").click(function(event) {
|
||||
if (window.jazzy.docset) {
|
||||
return;
|
||||
}
|
||||
var link = $(this);
|
||||
var animationDuration = 300;
|
||||
$content = link.parent().parent().next();
|
||||
$content.slideToggle(animationDuration);
|
||||
|
||||
// Keeps the document from jumping to the hash.
|
||||
var href = $(this).attr('href');
|
||||
if (history.pushState) {
|
||||
history.pushState({}, '', href);
|
||||
} else {
|
||||
location.hash = href;
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Dumb down quotes within code blocks that delimit strings instead of quotations
|
||||
// https://github.com/realm/jazzy/issues/714
|
||||
$("code q").replaceWith(function () {
|
||||
return ["\"", $(this).contents(), "\""];
|
||||
});
|
||||
62
docs/js/jazzy.search.js
Normal file
62
docs/js/jazzy.search.js
Normal file
@@ -0,0 +1,62 @@
|
||||
$(function(){
|
||||
var searchIndex = lunr(function() {
|
||||
this.ref('url');
|
||||
this.field('name');
|
||||
});
|
||||
|
||||
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) {
|
||||
$.each(searchData, function (url, doc) {
|
||||
searchIndex.add({url: url, name: doc.name});
|
||||
});
|
||||
|
||||
$typeahead.typeahead(
|
||||
{
|
||||
highlight: true,
|
||||
minLength: 3
|
||||
},
|
||||
{
|
||||
limit: 10,
|
||||
display: displayTemplate,
|
||||
templates: { suggestion: suggestionTemplate },
|
||||
source: function(query, sync) {
|
||||
var results = searchIndex.search(query).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;
|
||||
});
|
||||
});
|
||||
4
docs/js/jquery.min.js
vendored
Executable file
4
docs/js/jquery.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
6
docs/js/lunr.min.js
vendored
Executable file
6
docs/js/lunr.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1538
docs/js/typeahead.jquery.js
Normal file
1538
docs/js/typeahead.jquery.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user