pages/assets/js/common.js
CheariX 876d287cc8
Feature: added "award" for publications (#2324)
This PR adds an "award" button to publications.
It takes the `award` value from the bibtex entry and displays(incl.
Markdown rendering) the text in a box similarly to abstract and bibtex.

User can set the entry `award_name` to configure the value. See example
config with `award_name: Nobel Prize`.

The color of the award box can be configured in `_base.scss`.

Note, there is a similar PR #2175, it I saw to issues with:

1. There was no progress
2. The award button just prints the text directly in the button,
similarly to `award_name`. Long award names could clutter the webpage.
3. IMHO, it brokes the current al-folio design, since butons do have a
fixed size/text. However, variable prize names are also possible with
this PR.
***
Pictures:

Default. Text are hidden:

<img width="708" alt="grafik"
src="https://github.com/alshedivat/al-folio/assets/1998723/1221c82c-c384-4297-807e-39385e2ce4fd">

Additional info is shown when the button is clicked. Markdown supported.

<img width="684" alt="grafik"
src="https://github.com/alshedivat/al-folio/assets/1998723/2354aeee-12b0-4d32-b194-5d2ea80d8363">

Only one text box shown at the same time, like it is with "ABS" and
"BIB":
<img width="691" alt="grafik"
src="https://github.com/alshedivat/al-folio/assets/1998723/d3937bb9-d9c2-47ac-b819-b92aec3d916a">

***

Feedback welcome.

You can also check [my
website](https://christianmainka.de/publications/awarded), which was the
base for this PR.
2024-04-07 17:37:02 -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 theme = determineComputedTheme();
$(".jupyter-notebook-iframe-container iframe").each(function () {
$(this).contents().find("head").append(cssLink);
if (theme == "dark") {
$(this).bind("load", function () {
$(this).contents().find("body").attr({
"data-jp-theme-light": "false",
"data-jp-theme-name": "JupyterLab Dark",
});
});
}
});
});