From 3a54136769cf5ddb15067b7c415c7f73ddc74fcd Mon Sep 17 00:00:00 2001 From: Math-ias Date: Fri, 22 Nov 2024 17:37:40 -0500 Subject: [PATCH] [DISC-18903] Remove jquery and hanging javascript assets. Some notes on files I changed. * `scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala` This adds jquery to list of resources to load in a scaladoc page. I could remove it after fixing `ux.js`. If you search for jquery now it appears in `dagre-d3.min.js`. But this is only in doc comment examples. * `scaladoc/resources/dotty_res/scripts/ux.js` jQuery powered things like sidebar link behaviour (issuing GET) and item expansion (from mini blurb to full description). * `docs/_spec/public/scripts/toc.js` I tried to do a 1 to 1 port, included bugs like scroll listener being unhooked after clicking a link in the TOC. This table of contents ISN'T the same as what appears in normal docs. This is specific to the language spec. There might be an opportunity here to share code, see IntersectionObserver in `ux.js`. * `docs/_spec/public/scripts/main.js` Nothing exciting here. * `docs/_spec/_layouts/toc.yml` Loads jQuery for previously mentioned language spec TOC. * `docs/_spec/_layouts/default.yml` I think duplicate to above. * `docs/_assets/js/toolbar.js` Lots of unused jquery code. This is hanging source code, with references to code that was removed with commit ... ``` 0f78f739dd31ba095f19d32707315d94469ae9f9 ``` * `docs/_assets/css/toolbar.css` Same as above. * `docs/_assets/js/sidebar.js` `togglePath` call path removed in same commit above. --- docs/_assets/css/toolbar.css | 98 -------------- docs/_assets/js/sidebar.js | 6 - docs/_assets/js/toolbar.js | 26 ---- docs/_spec/_layouts/default.yml | 1 - docs/_spec/_layouts/toc.yml | 1 - docs/_spec/public/scripts/main.js | 18 ++- docs/_spec/public/scripts/toc.js | 128 +++++++++--------- scaladoc/resources/dotty_res/scripts/ux.js | 11 +- .../tools/scaladoc/renderers/Resources.scala | 1 - 9 files changed, 81 insertions(+), 209 deletions(-) delete mode 100644 docs/_assets/css/toolbar.css delete mode 100644 docs/_assets/js/sidebar.js delete mode 100644 docs/_assets/js/toolbar.js diff --git a/docs/_assets/css/toolbar.css b/docs/_assets/css/toolbar.css deleted file mode 100644 index faf051e5dde8..000000000000 --- a/docs/_assets/css/toolbar.css +++ /dev/null @@ -1,98 +0,0 @@ -body { - margin-top: 50px; -} - -nav.navbar { - height: 50px; - line-height: 1; - font-size: 24px; - font-family: var(--font-family-toolbar-details); - background-color: var(--toolbar); - box-shadow: 0 0 6px; -} -nav.navbar-dark * { - color: var(--toolbar-entry); - transition: color .2s ease-out; -} - -nav.navbar-dark a:hover *, nav.navbar-dark a:focus * { - color: var(--toolbar-active); -} -nav.navbar a:hover { - text-decoration: none; -} -nav.navbar a { - cursor: pointer; -} - -.navbar-brand { - margin-right: auto; - margin-left: auto; - font-size: inherit; - display: flex; - align-items: center; -} - -.navbar-brand .project-logo { - display: none; - height: 40px; - margin-right: 7px; -} - -.navbar-brand .project-details * { - margin: 0; - line-height: inherit; -} -.navbar-brand .project-details h1 { - font-size: 1em; - font-family: var(--font-family-toolbar-main); - font-weight: var(--font-weight-toolbar-main); -} -.navbar-brand .project-details h2 { - font-size: 0.5em; - margin-top: 2px; - font-weight: var(--font-weight-toolbar-details); -} - -#search-api-input { - color: initial; - width: 10em; -} -#searchbar { - display: none; -} -#searchbar.shown { - display: initial; - margin-left: auto; - margin-right: auto; -} -#searchbar.shown + .navbar-brand { - display: none; -} - -#search-icon { - margin-left: .5em; -} - -@media (min-width: 420px) { - .navbar-brand .project-logo { - display: inline; - } -} - -@media (min-width: 768px) { - #search-icon, #searchbar.shown { - margin-left: 1em; - margin-right: initial; - } - #searchbar.shown + .navbar-brand { - display: flex; - } -} - -@media (min-width: 1200px) { - #searchbar.shown { - position: absolute; - margin-left: 4em; - } -} diff --git a/docs/_assets/js/sidebar.js b/docs/_assets/js/sidebar.js deleted file mode 100644 index 2832486c1d6a..000000000000 --- a/docs/_assets/js/sidebar.js +++ /dev/null @@ -1,6 +0,0 @@ -// Toggles a sidebar section -function toggleSection(titleElement) { - const title = $(titleElement); - title.siblings("ul").toggleClass("toggled"); - title.children("i.fas").toggleClass("fa-angle-right fa-angle-down"); -} diff --git a/docs/_assets/js/toolbar.js b/docs/_assets/js/toolbar.js deleted file mode 100644 index a799ca661dd9..000000000000 --- a/docs/_assets/js/toolbar.js +++ /dev/null @@ -1,26 +0,0 @@ -$(function() { - const menuIcon = $("#menu-icon"); - const sidebar = $(".sidebar"); - menuIcon.on("click", () => { - sidebar.toggleClass("toggled"); - }); - - const searchIcon = $("#search-icon"); - const searchbar = $("#searchbar"); - const searchApiInput = $("#search-api-input"); - searchIcon.on("click", () => { - searchbar.toggleClass("shown"); - searchApiInput.focus(); - }); - - const baseurlInput = $("#baseurl-input"); - searchApiInput.keydown(evt => { - if (evt.which === 13) { // Enter - const baseUrl = baseurlInput.val(); - const searchTerm = searchApiInput.val(); - const previousUrl = encodeURI(window.location); - const searchUrl = `${baseUrl}/api/search.html?searchTerm=${searchTerm}&previousUrl=${previousUrl}`; - window.location = searchUrl; - } - }); -}); diff --git a/docs/_spec/_layouts/default.yml b/docs/_spec/_layouts/default.yml index 0f7fb24d7ce2..88e13a1668ce 100644 --- a/docs/_spec/_layouts/default.yml +++ b/docs/_spec/_layouts/default.yml @@ -10,7 +10,6 @@ -