mirror of
https://github.com/placeholder-soft/prodigyapi.git
synced 2026-04-23 03:29:29 +08:00
Organizes javascript into libraries and application code
Signed-off-by: Christopher Rogers <chrissrogers@gmail.com>
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
//= require './jquery_ui'
|
||||
//= require_tree .
|
||||
//= require_tree ./lib
|
||||
//= 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
|
||||
setTimeout(function() {
|
||||
toc.setOption("showEffectSpeed", 180);
|
||||
},50);
|
||||
}, 50);
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
//= require ./jquery_ui
|
||||
/* jquery Tocify - v1.8.0 - 2013-09-16
|
||||
* http://www.gregfranko.com/jquery.tocify.js/
|
||||
* Copyright (c) 2013 Greg Franko; Licensed MIT
|
||||
@@ -1022,4 +1023,4 @@
|
||||
|
||||
});
|
||||
|
||||
})); //end of plugin
|
||||
})); //end of plugin
|
||||
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
Reference in New Issue
Block a user