-
Notifications
You must be signed in to change notification settings - Fork 0
/
question-answer.js
40 lines (31 loc) · 1.04 KB
/
question-answer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Version 2.0, May 2020 */
/*jslint browser: true */
(function ($) {
"use strict";
function highlight(selector) {
$(selector).effect("highlight", {}, 2000);
}
function initToggleAnswers() {
var answerTitles = $(".admonition-answer .admonition-title");
$(".admonition-title ~ *", ".admonition-answer").toggle();
answerTitles.toggleClass("expanded");
answerTitles.on("click", function (event) {
var title = $(event.target),
content = $(".admonition-title ~ *", title.parent());
title.toggleClass("expanded");
content.slideToggle();
});
}
function initHighlightAnchoredSection() {
if (document.location.hash !== "") {
highlight(document.location.hash);
}
$('.rst-content a[href*="#"]').click(function () {
highlight($(this).attr("href"));
});
}
$(document).ready(function () {
initToggleAnswers();
initHighlightAnchoredSection();
});
}(window.jQuery));