Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit d49b972

Browse files
committed
Added search.
Updated fixtures.
1 parent fef0a58 commit d49b972

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

template.hbs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
padding: 2rem 1rem;
4545
}
4646
47+
.search {
48+
margin: 0 0 1rem 0;
49+
width: 90%;
50+
}
51+
4752
.menu {
4853
padding: 0;
4954
}
@@ -177,6 +182,8 @@
177182

178183
<div class="col-md-3 hidden-sm hidden-xs">
179184

185+
<input type="text" class="form-control search" id="search-methods" placeholder="Search..." autocomplete="off">
186+
180187
<ul class="menu">
181188

182189
{{#each files}}
@@ -187,7 +194,7 @@
187194

188195
{{#each methods}}
189196

190-
<li class="scope-{{#if isPrivate}}private{{else}}public{{/if}}">
197+
<li class="method-link scope-{{#if isPrivate}}private{{else}}public{{/if}}">
191198
<a href="#{{uid}}" title="{{name}}">{{name}}</a>
192199
</li>
193200

@@ -410,6 +417,30 @@
410417
hljs.highlightBlock(this);
411418
});
412419
420+
var $methodLinks = $('.method-link');
421+
422+
$('#search-methods').on('keyup', function (e) {
423+
424+
var query = new RegExp(e.target.value.replace(' ', '|'), 'ig');
425+
426+
$methodLinks.each(function () {
427+
428+
var $this = $(this);
429+
430+
if (!$this.text().match(query)) {
431+
432+
$this.hide();
433+
434+
} else {
435+
436+
$this.show();
437+
438+
}
439+
440+
});
441+
442+
});
443+
413444
$(window).on('scroll', handleScrollEvent);
414445
415446
handleScrollEvent();

test/fixtures/documentation.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
padding: 2rem 1rem;
4343
}
4444

45+
.search {
46+
margin: 0 0 1rem 0;
47+
width: 90%;
48+
}
49+
4550
.menu {
4651
padding: 0;
4752
}
@@ -171,6 +176,8 @@ <h1>
171176

172177
<div class="col-md-3 hidden-sm hidden-xs">
173178

179+
<input type="text" class="form-control search" id="search-methods" placeholder="Search..." autocomplete="off">
180+
174181
<ul class="menu">
175182

176183

@@ -179,7 +186,7 @@ <h1>
179186
<ul>
180187

181188

182-
<li class="scope-public">
189+
<li class="method-link scope-public">
183190
<a href="#index.js-plugin" title="plugin">plugin</a>
184191
</li>
185192

@@ -330,6 +337,30 @@ <h3>Returns</h3>
330337
hljs.highlightBlock(this);
331338
});
332339

340+
var $methodLinks = $('.method-link');
341+
342+
$('#search-methods').on('keyup', function (e) {
343+
344+
var query = new RegExp(e.target.value.replace(' ', '|'), 'ig');
345+
346+
$methodLinks.each(function () {
347+
348+
var $this = $(this);
349+
350+
if (!$this.text().match(query)) {
351+
352+
$this.hide();
353+
354+
} else {
355+
356+
$this.show();
357+
358+
}
359+
360+
});
361+
362+
});
363+
333364
$(window).on('scroll', handleScrollEvent);
334365

335366
handleScrollEvent();

0 commit comments

Comments
 (0)