mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-04-30 08:06:43 +03:00
Normalize search terms
This commit is contained in:
parent
f55b0f08d6
commit
388f1f9741
@ -497,7 +497,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function(document) {
|
(function(document) {
|
||||||
var icons = [{{ allIconNames }}],
|
var icons = [{{ allIconNames }}].map(normalizeSearchTerm),
|
||||||
$grid = document.querySelector('.grid'),
|
$grid = document.querySelector('.grid'),
|
||||||
$icons = $grid.querySelectorAll('.grid-item:not(.grid-item--ad)'),
|
$icons = $grid.querySelectorAll('.grid-item:not(.grid-item--ad)'),
|
||||||
$search = document.querySelector('.search'),
|
$search = document.querySelector('.search'),
|
||||||
@ -542,7 +542,7 @@
|
|||||||
|
|
||||||
function search(value) {
|
function search(value) {
|
||||||
var hiddenCounter = 0,
|
var hiddenCounter = 0,
|
||||||
value = value.toLowerCase().trim();
|
value = normalizeSearchTerm(value);
|
||||||
|
|
||||||
icons.forEach(function(e, i) {
|
icons.forEach(function(e, i) {
|
||||||
if (e.indexOf(value) > -1) {
|
if (e.indexOf(value) > -1) {
|
||||||
@ -556,6 +556,10 @@
|
|||||||
$grid.classList.toggle('search__empty', hiddenCounter == icons.length);
|
$grid.classList.toggle('search__empty', hiddenCounter == icons.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeSearchTerm(value) {
|
||||||
|
return value.toLowerCase().replace(/ /g, '');
|
||||||
|
}
|
||||||
|
|
||||||
$search.addEventListener('input', debounce(function(e) {
|
$search.addEventListener('input', debounce(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user