Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {%- javascript -%}
- $(document).ready(function()
- {
- var $panel = $('.search-target .panel-body'),
- $noMatches = $('<div class="no-matches alert alert-info">No matches found</div>');
- $noMatches.hide();
- $panel.prepend($noMatches);
- $('#pageSearch')
- // prevent the enter key from submitting the form
- .on('keydown', function(e)
- {
- if (e.keyCode == 13)
- {
- e.preventDefault();
- return false;
- }
- })
- // Filter page links when Search box is updated
- .on('keyup', function(e)
- {
- var value = $(this).val().toLowerCase();
- $matched = $('.panel-body > ul > li').filter(function()
- {
- var $setting = $(this),
- isShown = $setting.is(':visible'),
- isMatch = $setting.text().toLowerCase().indexOf(value) > -1;
- $setting.toggleClass('match', isMatch);
- if (isMatch && !isShown) $setting.stop(true,false).show(400);
- else if (!isMatch && isShown) $setting.stop(true,false).hide(400);
- return isMatch;
- }),
- matchCount = $matched.length;
- $noMatches.toggle(matchCount == 0);
- });
- });
- {%- endjavascript -%}
- {%- stylesheet -%}
- #pageSearch { margin-bottom:15px; }
- {% endstylesheet %}
- <div class="form-inline">
- <div class="form-group">
- <input id="pageSearch" type="text" class="form-control input-sm" placeholder="Search…">
- </div>
- </div>
- <div class="search-target">
- {%- include '~~/Assets/Lava/PageListAsBlocks.lava' -%}
- </div>
Add Comment
Please, Sign In to add comment