From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Date: Sun, 16 Jun 2024 15:14:22 +0000 (-0600)
Subject: [3.12] Docs: remove temporary hardcoded links and move inline JS to own file (GH...
X-Git-Tag: v3.12.5~210
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2f0fb964441b6ae67af6a88cd15dcb0a0f2c89e;p=thirdparty%2FPython%2Fcpython.git
[3.12] Docs: remove temporary hardcoded links and move inline JS to own file (GH-120348) (#120589)
[3.12] Docs: remove temporary hardcoded links (GH-120348)
(cherry picked from commit b8484c6ad7fd14ca464e584b79821b4b906dd77a)
---
diff --git a/Doc/tools/static/rtd_switcher.js b/Doc/tools/static/rtd_switcher.js
new file mode 100644
index 000000000000..f5dc7045a0db
--- /dev/null
+++ b/Doc/tools/static/rtd_switcher.js
@@ -0,0 +1,55 @@
+ function onSwitch(event) {
+ const option = event.target.selectedIndex;
+ const item = event.target.options[option];
+ window.location.href = item.dataset.url;
+ }
+
+ document.addEventListener("readthedocs-addons-data-ready", function(event) {
+ const config = event.detail.data()
+ const versionSelect = `
+
+ `;
+
+ // Prepend the current language to the options on the selector
+ let languages = config.projects.translations.concat(config.projects.current);
+ languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name));
+
+ const languageSelect = `
+
+ `;
+
+ // Query all the placeholders because there are different ones for Desktop/Mobile
+ const versionPlaceholders = document.querySelectorAll(".version_switcher_placeholder");
+ for (placeholder of versionPlaceholders) {
+ placeholder.innerHTML = versionSelect;
+ let selectElement = placeholder.querySelector("select");
+ selectElement.addEventListener("change", onSwitch);
+ }
+
+ const languagePlaceholders = document.querySelectorAll(".language_switcher_placeholder");
+ for (placeholder of languagePlaceholders) {
+ placeholder.innerHTML = languageSelect;
+ let selectElement = placeholder.querySelector("select");
+ selectElement.addEventListener("change", onSwitch);
+ }
+ });
diff --git a/Doc/tools/templates/layout.html b/Doc/tools/templates/layout.html
index 394ebee5f9e1..b09fd21a8ddc 100644
--- a/Doc/tools/templates/layout.html
+++ b/Doc/tools/templates/layout.html
@@ -46,90 +46,7 @@
{{ super() }}
{%- if not embedded %}
-
-
+
+
{%- endif %}
{% endblock %}