Skip to content

Commit 65708b8

Browse files
Remove unnecessary jQuery dependency
1 parent f5835fc commit 65708b8

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

sphinx_material/sphinx_material/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block body %}
44
<h1 id="search-documentation">{{ _('Search') }}</h1>
55
<div id="fallback" class="admonition warning">
6-
<script type="text/javascript">$('#fallback').hide();</script>
6+
<script type="text/javascript">document.getElementById('fallback').style.display = 'none';</script>
77
<p>
88
{% trans %}Please activate JavaScript to enable the search
99
functionality.{% endtrans %}

sphinx_material/sphinx_material/static/javascripts/version_dropdown.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,35 @@ function add_version_dropdown(json_loc, target_loc, text) {
88
content.className = "dropdown-content md-hero";
99
dropdown.appendChild(button);
1010
dropdown.appendChild(content);
11-
$.getJSON(json_loc, function(versions) {
12-
for (var key in versions) {
13-
if (versions.hasOwnProperty(key)) {
11+
12+
fetch(json_loc)
13+
.then(response => {
14+
if (!response.ok) {
15+
throw new Error("Network response was not ok");
16+
}
17+
return response.json();
18+
})
19+
.then(versions => {
20+
for (const key in versions) {
21+
if (Object.prototype.hasOwnProperty.call(versions, key)) {
1422
console.log(key, versions[key]);
15-
var a = document.createElement("a");
23+
const a = document.createElement("a");
1624
a.innerHTML = key;
1725
a.title = key;
1826
a.href = target_loc + versions[key];
1927
content.appendChild(a);
2028
}
2129
}
22-
}).done(function() {
30+
31+
// Success equivalent of `.done()`
2332
button.innerHTML = text;
24-
}).fail(function() {
33+
})
34+
.catch(() => {
35+
// Equivalent of `.fail()`
2536
button.innerHTML = "Other Versions Not Found";
26-
}).always(function() {
27-
$(".navheader").append(dropdown);
37+
})
38+
.finally(() => {
39+
// Equivalent of `.always()`
40+
document.querySelector(".navheader").appendChild(dropdown);
2841
});
2942
};

sphinx_material/sphinx_material/static/jquery.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

sphinx_material/sphinx_material/static/jquery.min.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

sphinx_material/sphinx_material/version_dropdown.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
var json_loc = "{{ pathto(theme_version_json, 1) }}",
1515
target_loc = "{{ pathto('../', 1) }}",
1616
text = "{{ theme_version_dropdown_text }}";
17-
$( document ).ready( add_version_dropdown(json_loc, target_loc, text));
17+
document.addEventListener("DOMContentLoaded", () => {
18+
add_version_dropdown(json_loc, target_loc, text);
19+
});
1820
</script>
1921
{% endif %}
2022
{% endif %}

0 commit comments

Comments
 (0)