Normalize search terms

This commit is contained in:
birjolaxew 2017-07-10 12:56:28 +02:00
parent f55b0f08d6
commit 388f1f9741
No known key found for this signature in database
GPG Key ID: 548A6D4C439CC3DD

View File

@ -497,7 +497,7 @@
{% endfor %}
<script type="text/javascript">
(function(document) {
var icons = [{{ allIconNames }}],
var icons = [{{ allIconNames }}].map(normalizeSearchTerm),
$grid = document.querySelector('.grid'),
$icons = $grid.querySelectorAll('.grid-item:not(.grid-item--ad)'),
$search = document.querySelector('.search'),
@ -542,7 +542,7 @@
function search(value) {
var hiddenCounter = 0,
value = value.toLowerCase().trim();
value = normalizeSearchTerm(value);
icons.forEach(function(e, i) {
if (e.indexOf(value) > -1) {
@ -556,6 +556,10 @@
$grid.classList.toggle('search__empty', hiddenCounter == icons.length);
}
function normalizeSearchTerm(value) {
return value.toLowerCase().replace(/ /g, '');
}
$search.addEventListener('input', debounce(function(e) {
e.preventDefault();