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

Commit e7df6ea

Browse files
committed
Updated template.
1 parent 5165e8b commit e7df6ea

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

template.hbs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.10.0/styles/github.min.css">
1212
<style>
1313
14+
input[type="search"]::-webkit-search-cancel-button {
15+
-webkit-appearance: searchfield-cancel-button;
16+
}
17+
1418
.jumbotron {
1519
margin-bottom: 0;
1620
border-radius: 0;
@@ -182,7 +186,7 @@
182186

183187
<div class="col-md-3 hidden-sm hidden-xs">
184188

185-
<input type="text" class="form-control search" id="search-methods" placeholder="Search..." autocomplete="off">
189+
<input type="search" class="form-control search" id="search-methods" placeholder="Search..." autocomplete="off">
186190

187191
<ul class="menu">
188192

@@ -417,9 +421,13 @@
417421
hljs.highlightBlock(this);
418422
});
419423
424+
var $searchInput = $('#search-methods');
420425
var $methodLinks = $('.method-link');
426+
var $methodNames = $('.method .method-name');
421427
422-
$('#search-methods').on('keyup', function (e) {
428+
var urlQuery = window.location.search.match(/q=([^&]+)/);
429+
430+
$searchInput.on('keyup', function (e) {
423431
424432
var query = new RegExp(e.target.value.replace(' ', '|'), 'ig');
425433
@@ -439,8 +447,38 @@
439447
440448
});
441449
450+
$methodNames.each(function () {
451+
452+
var $this = $(this);
453+
454+
if (!$this.text().match(query)) {
455+
456+
$this.closest('.method').hide();
457+
458+
} else {
459+
460+
$this.closest('.method').show();
461+
462+
}
463+
464+
});
465+
466+
window.history.replaceState({}, '', window.location.pathname + '?q=' + e.target.value);
467+
468+
});
469+
470+
$searchInput.on('search', function () {
471+
472+
$searchInput.trigger('keyup');
473+
442474
});
443475
476+
if (urlQuery && urlQuery.length > 1) {
477+
478+
$searchInput.val(urlQuery[1]).trigger('keyup');
479+
480+
}
481+
444482
$(window).on('scroll', handleScrollEvent);
445483
446484
handleScrollEvent();

0 commit comments

Comments
 (0)