mirror of
https://github.com/danbulant/api_docs
synced 2026-06-20 14:51:22 +00:00
Organizes javascript into libraries and application code
Signed-off-by: Christopher Rogers <chrissrogers@gmail.com>
This commit is contained in:
parent
adf94ffbf6
commit
b171d3c48a
7 changed files with 1926 additions and 4 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
//= require './jquery_ui'
|
//= require_tree ./lib
|
||||||
//= require_tree .
|
//= require_tree ./app
|
||||||
|
|
|
||||||
41
source/javascripts/app/search.js
Normal file
41
source/javascripts/app/search.js
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
(function (global) {
|
||||||
|
|
||||||
|
window.topic = topic;
|
||||||
|
|
||||||
|
var index = lunr(function () {
|
||||||
|
this.field('title', { boost: 10 });
|
||||||
|
this.field('tags', { boost: 100 });
|
||||||
|
this.field('body');
|
||||||
|
this.ref('id');
|
||||||
|
});
|
||||||
|
|
||||||
|
$(bindSearch);
|
||||||
|
|
||||||
|
function bindSearch () {
|
||||||
|
$('#search').on('keyup', function () {
|
||||||
|
if (this.value) {
|
||||||
|
var items = index.search(this.value);
|
||||||
|
$('article, nav li').hide();
|
||||||
|
items.forEach(function (item) {
|
||||||
|
$('#' + item.ref + ', #' + item.ref + '-nav').show();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('article, nav li').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('form').on('submit', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function topic (title, tags, handle) {
|
||||||
|
index.add({
|
||||||
|
id: handle,
|
||||||
|
title: title,
|
||||||
|
tags: tags,
|
||||||
|
body: $('#' + handle + '-body').text()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
})(window);
|
||||||
|
|
@ -20,5 +20,5 @@ $(function() {
|
||||||
// instead of displaying an ugly animation
|
// instead of displaying an ugly animation
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
toc.setOption("showEffectSpeed", 180);
|
toc.setOption("showEffectSpeed", 180);
|
||||||
},50);
|
}, 50);
|
||||||
});
|
});
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//= require ./jquery_ui
|
||||||
/* jquery Tocify - v1.8.0 - 2013-09-16
|
/* jquery Tocify - v1.8.0 - 2013-09-16
|
||||||
* http://www.gregfranko.com/jquery.tocify.js/
|
* http://www.gregfranko.com/jquery.tocify.js/
|
||||||
* Copyright (c) 2013 Greg Franko; Licensed MIT
|
* Copyright (c) 2013 Greg Franko; Licensed MIT
|
||||||
1880
source/javascripts/lib/lunr.js
Normal file
1880
source/javascripts/lib/lunr.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue