|
46 | 46 | {{ super() }}
|
47 | 47 |
|
48 | 48 | {%- if not embedded %}
|
49 |
| -<meta name="readthedocs-addons-api-version" content="1"> |
50 |
| -<script type="text/javascript"> |
51 |
| - function onSwitch(event) { |
52 |
| - const option = event.target.selectedIndex; |
53 |
| - const item = event.target.options[option]; |
54 |
| - window.location.href = item.dataset.url; |
55 |
| - } |
56 |
| - |
57 |
| - document.addEventListener("readthedocs-addons-data-ready", function(event) { |
58 |
| - const config = event.detail.data() |
59 |
| - |
60 |
| - // Add some mocked hardcoded versions pointing to the official |
61 |
| - // documentation while migrating to Read the Docs. |
62 |
| - // These are only for testing purposes. |
63 |
| - // TODO: remove them when managing all the versions on Read the Docs, |
64 |
| - // since all the "active, built and not hidden" versions will be shown automatically. |
65 |
| - let versions = config.versions.active.concat([ |
66 |
| - { |
67 |
| - slug: "dev (3.13)", |
68 |
| - urls: { |
69 |
| - documentation: "https://docs.python.org/3.13/", |
70 |
| - } |
71 |
| - }, |
72 |
| - { |
73 |
| - slug: "3.12", |
74 |
| - urls: { |
75 |
| - documentation: "https://docs.python.org/3.12/", |
76 |
| - } |
77 |
| - }, |
78 |
| - { |
79 |
| - slug: "3.11", |
80 |
| - urls: { |
81 |
| - documentation: "https://docs.python.org/3.11/", |
82 |
| - } |
83 |
| - }, |
84 |
| - ]); |
85 |
| - |
86 |
| - const versionSelect = ` |
87 |
| - <select id="version_select"> |
88 |
| - ${ versions.map( |
89 |
| - (version) => ` |
90 |
| - <option |
91 |
| - value="${ version.slug }" |
92 |
| - ${ config.versions.current.slug === version.slug ? 'selected="selected"' : '' } |
93 |
| - data-url="${ version.urls.documentation }"> |
94 |
| - ${ version.slug } |
95 |
| - </option>` |
96 |
| - ).join("\n") } |
97 |
| - </select> |
98 |
| - `; |
99 |
| - |
100 |
| - // Prepend the current language to the options on the selector |
101 |
| - let languages = config.projects.translations.concat(config.projects.current); |
102 |
| - languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name)); |
103 |
| - |
104 |
| - const languageSelect = ` |
105 |
| - <select id="language_select"> |
106 |
| - ${ languages.map( |
107 |
| - (translation) => ` |
108 |
| - <option |
109 |
| - value="${ translation.slug }" |
110 |
| - ${ config.projects.current.slug === translation.slug ? 'selected="selected"' : '' } |
111 |
| - data-url="${ translation.urls.documentation }"> |
112 |
| - ${ translation.language.name } |
113 |
| - </option>` |
114 |
| - ).join("\n") } |
115 |
| - </select> |
116 |
| - `; |
117 |
| - |
118 |
| - // Query all the placeholders because there are different ones for Desktop/Mobile |
119 |
| - const versionPlaceholders = document.querySelectorAll(".version_switcher_placeholder"); |
120 |
| - for (placeholder of versionPlaceholders) { |
121 |
| - placeholder.innerHTML = versionSelect; |
122 |
| - let selectElement = placeholder.querySelector("select"); |
123 |
| - selectElement.addEventListener("change", onSwitch); |
124 |
| - } |
125 |
| - |
126 |
| - const languagePlaceholders = document.querySelectorAll(".language_switcher_placeholder"); |
127 |
| - for (placeholder of languagePlaceholders) { |
128 |
| - placeholder.innerHTML = languageSelect; |
129 |
| - let selectElement = placeholder.querySelector("select"); |
130 |
| - selectElement.addEventListener("change", onSwitch); |
131 |
| - } |
132 |
| - }); |
133 |
| -</script> |
| 49 | + <script type="text/javascript" src="{{ pathto('_static/rtd_switcher.js', 1) }}"></script> |
| 50 | + <meta name="readthedocs-addons-api-version" content="1"> |
134 | 51 | {%- endif %}
|
135 | 52 | {% endblock %}
|
0 commit comments