pages/assets/js/common.js
George 1a7fddecf8
Fix code blocks not changing to plots and others (#2497)
For some unknown reason, all the `document.onreadystatechange = () => {`
checks stopped working. Thankfully, replacing them with
`document.addEventListener("readystatechange", () => {` fixed the
issues.

---------

Signed-off-by: George Araujo <george.gcac@gmail.com>
2024-06-11 14:06:38 -03:00

55 lines
1.9 KiB
JavaScript

$(document).ready(function () {
// add toggle functionality to abstract, award and bibtex buttons
$("a.abstract").click(function () {
$(this).parent().parent().find(".abstract.hidden").toggleClass("open");
$(this).parent().parent().find(".award.hidden.open").toggleClass("open");
$(this).parent().parent().find(".bibtex.hidden.open").toggleClass("open");
});
$("a.award").click(function () {
$(this).parent().parent().find(".abstract.hidden.open").toggleClass("open");
$(this).parent().parent().find(".award.hidden").toggleClass("open");
$(this).parent().parent().find(".bibtex.hidden.open").toggleClass("open");
});
$("a.bibtex").click(function () {
$(this).parent().parent().find(".abstract.hidden.open").toggleClass("open");
$(this).parent().parent().find(".award.hidden.open").toggleClass("open");
$(this).parent().parent().find(".bibtex.hidden").toggleClass("open");
});
$("a").removeClass("waves-effect waves-light");
// bootstrap-toc
if ($("#toc-sidebar").length) {
// remove related publications years from the TOC
$(".publications h2").each(function () {
$(this).attr("data-toc-skip", "");
});
var navSelector = "#toc-sidebar";
var $myNav = $(navSelector);
Toc.init($myNav);
$("body").scrollspy({
target: navSelector,
});
}
// add css to jupyter notebooks
const cssLink = document.createElement("link");
cssLink.href = "../css/jupyter.css";
cssLink.rel = "stylesheet";
cssLink.type = "text/css";
let jupyterTheme = determineComputedTheme();
$(".jupyter-notebook-iframe-container iframe").each(function () {
$(this).contents().find("head").append(cssLink);
if (jupyterTheme == "dark") {
$(this).bind("load", function () {
$(this).contents().find("body").attr({
"data-jp-theme-light": "false",
"data-jp-theme-name": "JupyterLab Dark",
});
});
}
});
});