mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-15 18:04:12 +03:00
Normalize search terms
This commit is contained in:
parent
f55b0f08d6
commit
388f1f9741
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user