Skip to content

Commit 544cf76

Browse files
committed
Update: remove jquery in search
1 parent a283c5d commit 544cf76

File tree

2 files changed

+15
-49
lines changed

2 files changed

+15
-49
lines changed

tensorly_sphinx_theme/searchbox.html

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,14 @@
44
<!-- <label class="label" id="searchlabel">Quick search</label> -->
55
<div class="field has-addons">
66
<div class="control is-expanded">
7-
<input class="input" type="text" placeholder="{{theme_searchbar_text}}" name="q" aria-labelledby="searchlabel">
7+
<input class="input" type="text" placeholder="{{theme_searchbar_text}}" name="q" aria-labelledby="searchlabel autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
88
</div>
99
<div class="control">
10-
<input class="button is-info" type="submit" value="Go" />
10+
<input class="button is-info" type="submit" value="{{ _('Go') }}" />
1111
</div>
1212
</div>
1313
</form>
14-
<script>$('#searchbox').show(0);</script>
15-
<script>
16-
$(document).ready(function() {
17-
Document.highlightSearchWords = function() {
18-
var params = $.getQueryParameters();
19-
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
20-
if (terms.length) {
21-
var body = $('div.body');
22-
if (!body.length) {
23-
body = $('body');
24-
}
25-
window.setTimeout(function() {
26-
$.each(terms, function() {
27-
body.highlightText(this.toLowerCase(), 'highlighted');
28-
});
29-
}, 10);
30-
$('<p class="highlight-link"><a href="javascript:Documentation.' +
31-
'hideSearchWords()">' + _('Hide All')
32-
+ '<span class="tag is-delete"></span>'
33-
+ '</a></p>')
34-
.appendTo($('#searchbox'));
35-
}
36-
};
37-
});
38-
</script>
14+
<script>document.getElementById('searchbox').style.display = "block"</script>
15+
3916
</div>
4017
{%- endif %}
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
document.addEventListener('DOMContentLoaded', () => {
22

3-
// Get all "navbar-burger" elements
4-
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
5-
6-
// Check if there are any navbar burgers
7-
if ($navbarBurgers.length > 0) {
8-
9-
// Add a click event on each of them
10-
$navbarBurgers.forEach( el => {
11-
el.addEventListener('click', () => {
12-
13-
// Get the target from the "data-target" attribute
14-
const target = el.dataset.target;
15-
const $target = document.getElementById(target);
16-
17-
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
18-
el.classList.toggle('is-active');
19-
$target.classList.toggle('is-active');
20-
21-
});
3+
// Top bar burger
4+
(function() {
5+
var burger = document.querySelector('.navbar-burger');
6+
var menu = document.querySelector('.navbar-menu');
7+
8+
burger.addEventListener('click', function() {
9+
burger.classList.toggle('is-active');
10+
menu.classList.toggle('is-active');
2211
});
23-
}
24-
25-
});
12+
})();
13+
14+
});

0 commit comments

Comments
 (0)