Skip to content

Commit

Permalink
Add search support in Content types and parts definitions
Browse files Browse the repository at this point in the history
Fixes #1070
  • Loading branch information
agriffard committed Oct 7, 2017
1 parent a9bc573 commit 1d084df
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,33 @@
<ul class="list-group">
@foreach (var type in Model.Types)
{
<li class="list-group-item">
<li class="list-group-item" data-filter-value="@type.DisplayName">
@Html.DisplayFor(m => type)
</li>
}
</ul>
</ul>
<script at="Foot" type="text/javascript">
//<![CDATA[
$(function() {
var searchBox = $('#search-box');
// On each keypress filter the list of features
searchBox.keyup(function(e) {
var search = $(this).val().toLowerCase();
var elementsToFilter = $("[data-filter-value]");
// On ESC, clear the search box and display all features
if (e.keyCode == 27 || search == '') {
searchBox.val('');
elementsToFilter.toggle(true);
} else {
elementsToFilter.each(function() {
var text = $(this).data('filter-value').toLowerCase();
var found = text.indexOf(search) > -1;
$(this).toggle(found);
});
}
});
});
//]]>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,33 @@
<ul class="list-group">
@foreach (var type in Model.Parts)
{
<li class="list-group-item">
<li class="list-group-item" data-filter-value="@type.DisplayName">
@Html.DisplayFor(m => type)
</li>
}
</ul>
<script at="Foot" type="text/javascript">
//<![CDATA[
$(function() {
var searchBox = $('#search-box');
// On each keypress filter the list of features
searchBox.keyup(function(e) {
var search = $(this).val().toLowerCase();
var elementsToFilter = $("[data-filter-value]");
// On ESC, clear the search box and display all features
if (e.keyCode == 27 || search == '') {
searchBox.val('');
elementsToFilter.toggle(true);
} else {
elementsToFilter.each(function() {
var text = $(this).data('filter-value').toLowerCase();
var found = text.indexOf(search) > -1;
$(this).toggle(found);
});
}
});
});
//]]>
</script>

0 comments on commit 1d084df

Please sign in to comment.