`;
}
if ($(".search-modal-card-body").hasClass("is-justify-content-center")) {
$(".search-modal-card-body").removeClass("is-justify-content-center");
}
$(".search-modal-card-body").html(search_result_container);
} else {
filter_results = [];
modal_filters = make_modal_body_filters(filters, filter_results);
if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) {
$(".search-modal-card-body").addClass("is-justify-content-center");
}
$(".search-modal-card-body").html(initial_search_body);
}
}
/**
* Make the modal filter html
*
* @param {string[]} filters
* @param {string[]} selected_filters
* @returns string
*/
function make_modal_body_filters(filters, selected_filters = []) {
let str = ``;
filters.forEach((val) => {
if (selected_filters.includes(val)) {
str += `${val}`;
} else {
str += `${val}`;
}
});
let filter_html = `
Filters:
${str}
`;
return filter_html;
}
/**
* Make the result component given a minisearch result data object and the value of the search input as queryString.
* To view the result object structure, refer: https://lucaong.github.io/minisearch/modules/_minisearch_.html#searchresult
*
* @param {object} result
* @param {string} querystring
* @returns string
*/
function make_search_result(result, querystring) {
let search_divider = ``;
let display_link =
result.location.slice(Math.max(0), Math.min(50, result.location.length)) +
(result.location.length > 30 ? "..." : ""); // To cut-off the link because it messes with the overflow of the whole div
if (result.page !== "") {
display_link += ` (${result.page})`;
}
let textindex = new RegExp(`\\b${querystring}\\b`, "i").exec(result.text);
let text =
textindex !== null
? result.text.slice(
Math.max(textindex.index - 100, 0),
Math.min(
textindex.index + querystring.length + 100,
result.text.length
)
)
: ""; // cut-off text before and after from the match
let display_result = text.length
? "..." +
text.replace(
new RegExp(`\\b${querystring}\\b`, "i"), // For first occurrence
'$&'
) +
"..."
: ""; // highlights the match
let in_code = false;
if (!["page", "section"].includes(result.category.toLowerCase())) {
in_code = true;
}
// We encode the full url to escape some special characters which can lead to broken links
let result_div = `
`
);
document.querySelector(".docs-search-query").addEventListener("click", () => {
openModal();
});
document.querySelector(".close-search-modal").addEventListener("click", () => {
closeModal();
});
$(document).on("click", ".search-result-link", function () {
closeModal();
});
document.addEventListener("keydown", (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === "/") {
openModal();
} else if (event.key === "Escape") {
closeModal();
}
return false;
});
// Functions to open and close a modal
function openModal() {
let searchModal = document.querySelector("#search-modal");
searchModal.classList.add("is-active");
document.querySelector(".documenter-search-input").focus();
}
function closeModal() {
let searchModal = document.querySelector("#search-modal");
let initial_search_body = `
Type something to get started!
`;
searchModal.classList.remove("is-active");
document.querySelector(".documenter-search-input").blur();
if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) {
$(".search-modal-card-body").addClass("is-justify-content-center");
}
$(".documenter-search-input").val("");
$(".search-modal-card-body").html(initial_search_body);
}
document
.querySelector("#search-modal .modal-background")
.addEventListener("click", () => {
closeModal();
});
})
////////////////////////////////////////////////////////////////////////////////
require(['jquery'], function($) {
// Manages the showing and hiding of the sidebar.
$(document).ready(function () {
var sidebar = $("#documenter > .docs-sidebar");
var sidebar_button = $("#documenter-sidebar-button");
sidebar_button.click(function (ev) {
ev.preventDefault();
sidebar.toggleClass("visible");
if (sidebar.hasClass("visible")) {
// Makes sure that the current menu item is visible in the sidebar.
$("#documenter .docs-menu a.is-active").focus();
}
});
$("#documenter > .docs-main").bind("click", function (ev) {
if ($(ev.target).is(sidebar_button)) {
return;
}
if (sidebar.hasClass("visible")) {
sidebar.removeClass("visible");
}
});
});
// Resizes the package name / sitename in the sidebar if it is too wide.
// Inspired by: https://github.com/davatron5000/FitText.js
$(document).ready(function () {
e = $("#documenter .docs-autofit");
function resize() {
var L = parseInt(e.css("max-width"), 10);
var L0 = e.width();
if (L0 > L) {
var h0 = parseInt(e.css("font-size"), 10);
e.css("font-size", (L * h0) / L0);
// TODO: make sure it survives resizes?
}
}
// call once and then register events
resize();
$(window).resize(resize);
$(window).on("orientationchange", resize);
});
// Scroll the navigation bar to the currently selected menu item
$(document).ready(function () {
var sidebar = $("#documenter .docs-menu").get(0);
var active = $("#documenter .docs-menu .is-active").get(0);
if (typeof active !== "undefined") {
sidebar.scrollTop = active.offsetTop - sidebar.offsetTop - 15;
}
});
})
////////////////////////////////////////////////////////////////////////////////
require(['jquery'], function($) {
// Theme picker setup
$(document).ready(function () {
// onchange callback
$("#documenter-themepicker").change(function themepick_callback(ev) {
var themename = $("#documenter-themepicker option:selected").attr("value");
if (themename === "auto") {
// set_theme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
window.localStorage.removeItem("documenter-theme");
} else {
// set_theme(themename);
window.localStorage.setItem("documenter-theme", themename);
}
// We re-use the global function from themeswap.js to actually do the swapping.
set_theme_from_local_storage();
});
// Make sure that the themepicker displays the correct theme when the theme is retrieved
// from localStorage
if (typeof window.localStorage !== "undefined") {
var theme = window.localStorage.getItem("documenter-theme");
if (theme !== null) {
$("#documenter-themepicker option").each(function (i, e) {
e.selected = e.value === theme;
});
}
}
});
})
////////////////////////////////////////////////////////////////////////////////
require(['jquery'], function($) {
// update the version selector with info from the siteinfo.js and ../versions.js files
$(document).ready(function () {
// If the version selector is disabled with DOCUMENTER_VERSION_SELECTOR_DISABLED in the
// siteinfo.js file, we just return immediately and not display the version selector.
if (
typeof DOCUMENTER_VERSION_SELECTOR_DISABLED === "boolean" &&
DOCUMENTER_VERSION_SELECTOR_DISABLED
) {
return;
}
var version_selector = $("#documenter .docs-version-selector");
var version_selector_select = $("#documenter .docs-version-selector select");
version_selector_select.change(function (x) {
target_href = version_selector_select
.children("option:selected")
.get(0).value;
window.location.href = target_href;
});
// add the current version to the selector based on siteinfo.js, but only if the selector is empty
if (
typeof DOCUMENTER_CURRENT_VERSION !== "undefined" &&
$("#version-selector > option").length == 0
) {
var option = $(
""
);
version_selector_select.append(option);
}
if (typeof DOC_VERSIONS !== "undefined") {
var existing_versions = version_selector_select.children("option");
var existing_versions_texts = existing_versions.map(function (i, x) {
return x.text;
});
DOC_VERSIONS.forEach(function (each) {
var version_url = documenterBaseURL + "/../" + each + "/";
var existing_id = $.inArray(each, existing_versions_texts);
// if not already in the version selector, add it as a new option,
// otherwise update the old option with the URL and enable it
if (existing_id == -1) {
var option = $(
""
);
version_selector_select.append(option);
} else {
var option = existing_versions[existing_id];
option.value = version_url;
option.disabled = false;
}
});
}
// only show the version selector if the selector has been populated
if (version_selector_select.children("option").length > 0) {
version_selector.toggleClass("visible");
}
});
})