// Only import what we need: // https://getbootstrap.com/docs/5.1/customize/optimize/ import "bootstrap/js/dist/alert"; import "bootstrap/js/dist/button"; // import "bootstrap/js/dist/carousel"; import "bootstrap/js/dist/collapse"; import "bootstrap/js/dist/dropdown"; import "bootstrap/js/dist/modal"; // import "bootstrap/js/dist/offcanvas"; import "bootstrap/js/dist/popover"; import "bootstrap/js/dist/scrollspy"; import "bootstrap/js/dist/tab"; // import "bootstrap/js/dist/toast"; import "bootstrap/js/dist/tooltip"; import jquery from "jquery"; window.$ = window.jQuery = jquery; if (!process.env.BUILD_DEPLOY) { // get warnings for using deprecated jquery features require("jquery-migrate"); } import Cookies from "js-cookie"; // setup CSRF protection using jQuery function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); } jQuery.ajaxSetup({ crossDomain: false, // obviates need for sameOrigin test beforeSend: function (xhr, settings) { if (!csrfSafeMethod(settings.type)) { xhr.setRequestHeader("X-CSRFToken", Cookies.get("csrftoken")); } } }); // Use the Bootstrap tooltip plugin for all elements with a title attribute $(document) .ready(function () { $('[title][title!=""]') .tooltip(); }); // Help browser to wrap long link texts (esp. email addresses) more sensibly. $(document) .ready(function () { $("#content a") .each(function () { // get the text of the element var text = $(this) .text(); // insert some at strategic places var newtext = text.replace(/([@._])/g, "$1"); if (newtext === text) { return; } // now replace only that text inside the element's HTML var newhtml = $(this) .html() .replace(text, newtext); $(this) .html(newhtml); }); // $("#content table.tablesorter") // .on("tablesorter:done", function () { // $("#content table.tablesorter .date") // .each(function () { // // get the text of the element // var text = $(this) // .text(); // // insert some at strategic places // var newtext = text.replace(/([-])/g, "$1"); // if (newtext === text) { // return; // } // // now replace only that text inside the element's HTML // var newhtml = $(this) // .html() // .replace(text, newtext); // $(this) // .html(newhtml); // }); // }); }); $(document) .ready(function () { function dropdown_hover() { var navbar = $(this) .closest(".navbar"); if (navbar.length === 0 || navbar.find(".navbar-toggler") .is(":hidden")) { $(this) .children(".dropdown-toggle") .dropdown("toggle"); } } // load data for the menu $.ajax({ url: $(document.body) .data("group-menu-data-url"), type: "GET", dataType: "json", success: function (data) { for (var parentId in data) { var attachTo = $(".group-menu.group-parent-" + parentId); if (attachTo.length == 0) { console.log("Could not find parent " + parentId); continue; } attachTo.find(".dropdown-menu") .remove(); var menu = ['"); for (i = 0; i < attachTo.length; i++) { attachTo.closest(".dropdown-menu"); } attachTo.append(menu.join("")); } if (!("ontouchstart" in document.documentElement)) { $("ul.nav li.dropdown, ul.nav li.dropend") .on("mouseenter mouseleave", dropdown_hover); } } }); }); // Automatically add a navigation pane to long pages if #content element has the ietf-auto-nav class. // The parent of #content must have the row class or the navigation pane will render incorrectly. $(function () { const contentElement = $('#content.ietf-auto-nav'); if (contentElement.length > 0) { const headings = contentElement .find("h1:visible, h2:visible, h3:visible, h4:visible, h5:visible, h6:visible, .nav-heading:visible") .not(".navskip"); const contents = (headings.length > 0) && ($(headings) .html() .split("<") .shift() .trim()); if ( contents && (contents.length > 0) && ($(headings) .last() .offset() .top > $(window) .height()) ) { // console.log("Enabling nav."); let n = 0; let last_level; let nav; contentElement .attr("data-bs-offset", 0) .attr("tabindex", 0) .after($(`
`)) .find("h1:visible, h2:visible, h3:visible, h4:visible, h5:visible, h6:visible, .nav-heading:visible") .not(".navskip") .each(function () { // Some headings have complex HTML in them - only use first part in that case. const text = $(this) .html() .split("<") .shift() .trim(); if (text === undefined || text === "") { // Nothing to do for empty headings. return; } let id = $(this) .attr("id"); if (id === undefined) { id = `autoid-${++n}`; $(this) .attr("id", id); } if (nav === undefined) { nav = $("#righthand-nav"); nav = $(nav) .append(`