HummingBirdAnimeClient/public/js/anime_collection.js

31 lines
770 B
JavaScript
Raw Normal View History

2016-02-01 09:49:18 -05:00
(($, AnimeClient) => {
'use strict';
2016-02-02 11:34:03 -05:00
const search = (tempHtml, query) => {
$('.cssload-loader').removeAttr('hidden');
$.get(AnimeClient.url('/collection/search'), {'query':query}, (searchResults, status) => {
$('.cssload-loader').attr('hidden', 'hidden');
2016-02-02 11:34:03 -05:00
// Give mustache a key to iterate over
searchResults = {
anime: searchResults
};
Mustache.parse(tempHtml);
$('#series_list').html(Mustache.render(tempHtml, searchResults));
});
};
2016-02-01 09:49:18 -05:00
2016-02-02 11:34:03 -05:00
$.get('/public/templates/anime-ajax-search-results.html', tempHtml => {
$('#search').on('keypress', AnimeClient.throttle(250, function(e) {
let query = encodeURIComponent($(this).val());
if (query === '') {
return;
}
2016-02-01 09:49:18 -05:00
2016-02-02 11:34:03 -05:00
search(tempHtml, query);
2016-02-01 09:49:18 -05:00
}));
});
2016-02-02 11:34:03 -05:00
})(Zepto, AnimeClient);