1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-11 23:55:16 +01:00

more function split up

This commit is contained in:
Matthias Kretschmann 2015-11-20 22:30:58 +01:00
parent e6aa768235
commit 27b329218e

View File

@ -11,34 +11,27 @@ var Search = (function(w, d) {
_private = { _private = {
searchShow: function() { searchShow: function() {
var body = $('body');
searchlink.on('click', function(e) { searchlink.on('click', function(e) {
e.preventDefault(); e.preventDefault();
SimpleJekyllSearch({
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('search-results'),
json: '/search.json',
searchResultTemplate: '<li class="grid__col"><a class="search-link" href="{url}">{title}</a></li>',
fuzzy: false
});
// show search field // show search field
searcharea searcharea
.removeClass('ready bounceOutUp') .removeClass('ready bounceOutUp')
.addClass('ready slideDown') .addClass('ready slideDown')
.on('animationend webkitAnimationEnd oAnimationEnd', function(){ .on('animationend webkitAnimationEnd oAnimationEnd', function(){
$('body').addClass('search-open'); body.addClass('search-open');
}); });
searchfield.focus(); searchfield.focus();
// hide menu too just in case _private.searchSimpleJekyllSearch();
if ($('body').hasClass('menu-open')) {
$('body').removeClass('menu-open');
}
// show search results upon typing // hide menu too just in case
if (searchfield.val().length) { if (body.hasClass('menu-open')) {
searchpop.removeClass('hide'); body.removeClass('menu-open');
} }
// bind the hide controls // bind the hide controls
@ -61,13 +54,25 @@ var Search = (function(w, d) {
// and dont close thepop now // and dont close thepop now
e.stopPropagation(); e.stopPropagation();
}); });
},
// finally show popup upon first keypress searchResultsShow: function() {
// show popup upon first keypress
searchfield.on('keyup', function() { searchfield.on('keyup', function() {
searchpop.removeClass('hide'); searchpop.removeClass('hide');
}); });
}, },
searchSimpleJekyllSearch: function() {
SimpleJekyllSearch({
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('search-results'),
json: '/search.json',
searchResultTemplate: '<li class="grid__col"><a class="search-link" href="{url}">{title}</a></li>',
fuzzy: false
});
},
searchHide: function() { searchHide: function() {
$('.search-close').on('click', function(e) { $('.search-close').on('click', function(e) {
e.preventDefault(); e.preventDefault();
@ -94,6 +99,7 @@ var Search = (function(w, d) {
app = { app = {
init: function() { init: function() {
_private.searchShow(); _private.searchShow();
_private.searchResultsShow();
_private.searchHide(); _private.searchHide();
} }
}; };