mirror of
https://github.com/ForkAwesome/Fork-Awesome.git
synced 2024-12-28 06:21:32 +08:00
Improved icon search.
This commit is contained in:
parent
c1768c1f8a
commit
f9cd96b667
@ -15,7 +15,7 @@
|
|||||||
<div class="row fontawesome-icon-list">
|
<div class="row fontawesome-icon-list">
|
||||||
{% for icon in icons %}
|
{% for icon in icons %}
|
||||||
<div class="fa-hover col-md-3 col-sm-4 filter-icon"
|
<div class="fa-hover col-md-3 col-sm-4 filter-icon"
|
||||||
data-filter=" {{ icon.class }}{% for alias in icon.aliases %} {{ alias }}{% endfor %}{% for filter in icon.filter %} {{ filter }}{% endfor %}">
|
data-filter="{{ icon.class }}{% for alias in icon.aliases %}|{{ alias }}{% endfor %}{% for filter in icon.filter %}|{{ filter }}{% endfor %}">
|
||||||
<a href="{{ page.relative_path }}icon/{{ icon.id }}"><i class="fa fa-{{ icon.class }}"></i> fa-{{ icon.class }}{% if icon.alias_of %} <span class="text-muted">(alias)</span>{% endif %}</a>
|
<a href="{{ page.relative_path }}icon/{{ icon.id }}"><i class="fa fa-{{ icon.class }}"></i> fa-{{ icon.class }}{% if icon.alias_of %} <span class="text-muted">(alias)</span>{% endif %}</a>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -32,12 +32,12 @@ $(function() {
|
|||||||
|
|
||||||
var resultsCount = 0;
|
var resultsCount = 0;
|
||||||
$icons.each(function() {
|
$icons.each(function() {
|
||||||
var filter = $(this).attr('data-filter')
|
var filter = $(this).attr('data-filter').split('|');
|
||||||
var show = filter.match(' '+val);
|
var show = inFilter(val, filter);
|
||||||
if (!show) {
|
if (!show) {
|
||||||
if (val.slice(-1) === 's') {
|
if (val.slice(-1) === 's') {
|
||||||
// Try to be smart. Make plural terms singular.
|
// Try to be smart. Make plural terms singular.
|
||||||
show = filter.match(' '+val.slice(0, -1));
|
show = inFilter(val.slice(0, -1), filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (show) resultsCount++;
|
if (show) resultsCount++;
|
||||||
@ -53,6 +53,17 @@ $(function() {
|
|||||||
}).trigger('keyup');
|
}).trigger('keyup');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function inFilter(val, filter) {
|
||||||
|
var found = false;
|
||||||
|
for (var i = 0; i < filter.length; i++) {
|
||||||
|
if (filter[i].match(val)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user