SHOW:
|
|
- or go back to the newest paste.
1 | - | {% javascript %} |
1 | + | {%- javascript -%} |
2 | - | $(document).ready(function(){ |
2 | + | $(document).ready(function() |
3 | - | $("#pageSearch").on("keyup", function() { |
3 | + | { |
4 | - | var value = $(this).val().toLowerCase(); |
4 | + | $('#pageSearch') |
5 | // prevent the enter key from submitting the form | |
6 | - | // Filter page links when Search box is updated |
6 | + | .on('keydown', function(e) |
7 | - | $(".panel-body ul li").filter(function() { |
7 | + | { |
8 | - | $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) |
8 | + | if (e.keyCode == 13) |
9 | { | |
10 | - | }); |
10 | + | e.preventDefault(); |
11 | return false; | |
12 | - | // hides/reveals panel based on the presence of search results |
12 | + | |
13 | - | $( ".panel-body ul").each(function( index ) { |
13 | + | }) |
14 | - | |
14 | + | // Filter page links when Search box is updated |
15 | - | $(this).parent().parent().show(); // reset visibilty of panels |
15 | + | .on('keyup', function(e) |
16 | - | if($(this).children(":visible").length == 0) |
16 | + | { |
17 | var $text = $(this), | |
18 | - | //if a panel has no visible children than hide it |
18 | + | $lists = $('.search-target .panel-body > ul') |
19 | - | $(this).parent().parent().hide(); |
19 | + | value = $text.val().toLowerCase(); |
20 | ||
21 | // hides/reveals panel based on the presence of search results | |
22 | $lists.each(function() | |
23 | - | }); |
23 | + | |
24 | var $list = $(this), | |
25 | - | {% endjavascript %} |
25 | + | $panel = $list.parents('.search-target'), |
26 | $children = $list.children('li'), | |
27 | - | {% stylesheet %} |
27 | + | isOpen = $panel.is(':visible'), |
28 | - | h2 { |
28 | + | |
29 | - | margin-left:10px |
29 | + | // Filter page links when Search box is updated |
30 | - | } |
30 | + | $matched = $children.filter(function() |
31 | - | #pageSearch { |
31 | + | { |
32 | - | margin-bottom:15px |
32 | + | var $setting = $(this), |
33 | - | } |
33 | + | isShown = $setting.is(':visible'), |
34 | - | {% endstylesheet %} |
34 | + | isMatch = $setting.text().toLowerCase().indexOf(value) > -1; |
35 | ||
36 | - | <input id="pageSearch" type="text" placeholder="Search.."> |
36 | + | $setting.toggleClass('match', isMatch); |
37 | ||
38 | - | {% if childPage.Title != 'All Settings' %} |
38 | + | if (isMatch && !isShown) $setting.stop(true,false).show(200); |
39 | - | <div class="panel panel-default list-as-blocks clearfix"> |
39 | + | else if (!isMatch && isShown) $setting.stop(true,false).hide(200); |
40 | - | <h2> {{ childPage.Title }}</h2> |
40 | + | |
41 | return isMatch; | |
42 | }), | |
43 | matchCount = $matched.length; | |
44 | ||
45 | //if a panel has no visible children then hide it | |
46 | if (isOpen && matchCount == 0) | |
47 | $panel.stop(true,false).slideUp(400); | |
48 | else if (!isOpen && matchCount > 0) | |
49 | $panel.stop(true,false).slideDown(400, function(){ $(this).css('height', 'auto'); }); | |
50 | }); | |
51 | }); | |
52 | }); | |
53 | {%- endjavascript -%} | |
54 | ||
55 | {%- stylesheet -%} | |
56 | - | {% endif %} |
56 | + | h2 { margin-left:10px; } |
57 | #pageSearch { margin-bottom:15px; } | |
58 | {%- endstylesheet -%} | |
59 | ||
60 | - | {% if IncludePageList != empty %} |
60 | + | <div class="form-inline"> |
61 | - | <div class="panel panel-default list-as-blocks clearfix"> |
61 | + | <div class="form-group"> |
62 | - | <h2> Additional Pages </h3> |
62 | + | <input id="pageSearch" type="text" class="form-control input-sm" placeholder="Search…"> |
63 | </div> | |
64 | </div> | |
65 | ||
66 | {%- for childPage in Page.Pages -%} | |
67 | {%- if childPage.Title != 'All Settings' -%} | |
68 | <div class="panel panel-default list-as-blocks search-target clearfix"> | |
69 | <div class="panel-heading"> | |
70 | <h2 class="panel-title"><i class="{{ childPage.IconCssClass }}"></i> {{ childPage.Title }}</h2> | |
71 | </div> | |
72 | <div class="panel-body"> | |
73 | <ul> | |
74 | - | {% endif %} |
74 | + | |
75 | <li> | |
76 | <a href="{{ grandChildPage.Url }}" {% if grandChildPage.DisplayDescription != 'true' %} title="{{ grandChildPage.Description }}"{% endif %}> | |
77 | {% if grandChildPage.IconCssClass != '' %} | |
78 | <i class="{{ grandChildPage.IconCssClass }}"></i> | |
79 | {% endif %} | |
80 | <h3>{{ grandChildPage.Title }}</h3> | |
81 | </a> | |
82 | </li> | |
83 | {%- endfor -%} | |
84 | </ul> | |
85 | </div> | |
86 | </div> | |
87 | {%- endif -%} | |
88 | {%- endfor -%} | |
89 | ||
90 | {%- if IncludePageList != empty -%} | |
91 | <div class="panel panel-default list-as-blocks search-target clearfix"> | |
92 | <div class="panel-heading"><h2 class="panel-title">Additional Pages</h2></div> | |
93 | <div class="panel-body"> | |
94 | <ul> | |
95 | {%- for includedPage in IncludePageList -%} | |
96 | {%- assign attributeParts = includedPage | PropertyToKeyValue -%} | |
97 | <li> | |
98 | <a href="{{ attributeParts.Value }}">{{ attributeParts.Key }}</a> | |
99 | </li> | |
100 | {%- endfor -%} | |
101 | </ul> | |
102 | </div> | |
103 | </div> | |
104 | {%- endif -%} | |
105 |