{{ ftl('firefox-all-choose-which-firefox') }}
-{{ self.page_desc() }}
- {% if product %} - {% if product.slug == "desktop-release" %} -diff --git a/media/js/firefox/all/all-init.es6.js b/media/js/firefox/all/all-init.es6.js
index 8f52040b5..55ed81993 100644
--- a/media/js/firefox/all/all-init.es6.js
+++ b/media/js/firefox/all/all-init.es6.js
@@ -8,7 +8,12 @@ import TrackProductDownload from '../../base/datalayer-productdownload.es6';
import MzpModal from '@mozilla-protocol/core/protocol/js/modal';
(function (Mozilla) {
- function onLoad() {
+ // Getter function since outerHTML replacement in fetchContent breaks existing references
+ function getPartialTargetElement() {
+ return document.getElementById('partial-target');
+ }
+
+ function setUpPartialContentListeners() {
const browserHelpContent = document.getElementById('browser-help');
const browserHelpIcon = document.getElementById('icon-browser-help');
const installerHelpContent = document.getElementById('installer-help');
@@ -16,7 +21,6 @@ import MzpModal from '@mozilla-protocol/core/protocol/js/modal';
'.icon-installer-help'
);
const downloadButtons = document.querySelectorAll('.download-link');
-
function showHelpModal(modalContent, modalTitle, eventLabel) {
MzpModal.createModal(this, modalContent, {
title: modalTitle,
@@ -67,7 +71,6 @@ import MzpModal from '@mozilla-protocol/core/protocol/js/modal';
);
}
}
-
// event tracking for GA4
if (downloadButtons) {
for (let i = 0; i < downloadButtons.length; ++i) {
@@ -81,6 +84,74 @@ import MzpModal from '@mozilla-protocol/core/protocol/js/modal';
);
}
}
+
+ // Override click events for drill-down links.
+ getPartialTargetElement().addEventListener('click', function (event) {
+ const anchor = event.target.closest('a');
+ if (anchor && anchor.matches('.load-content-partial')) {
+ event.preventDefault();
+ fetchContent(anchor.href, true);
+ }
+ });
+ }
+
+ // A fetch helper since we use this in both the on click and popstate.
+ // pushState is a boolean so we avoid pushing state if triggered from popstate.
+ function fetchContent(url, pushState = false) {
+ fetch(url, {
+ // Signifies to backend to return partial HTML.
+ headers: { 'X-Requested-With': 'XMLHttpRequest' },
+ // Ignore what's cached and also don't cache this response.
+ // This is so we don't get full html pages when we expect partial html, or vice versa.
+ cache: 'no-store'
+ })
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ return response.text();
+ })
+ .then((html) => {
+ const partialTarget = getPartialTargetElement();
+ partialTarget.outerHTML = html;
+
+ // Re-attach listeners as we just replaced partialTarget
+ setUpPartialContentListeners();
+
+ if (pushState) {
+ history.pushState({ path: url }, '', url);
+ }
+
+ const activeHeaders = document.querySelectorAll(
+ '.c-step-name:not(.t-step-disabled)'
+ );
+ const targetHeader = activeHeaders[activeHeaders.length - 1];
+ targetHeader.focus({ preventScroll: true });
+ })
+ .catch((error) => {
+ throw new Error(
+ 'There was a problem with the fetch operation:',
+ error
+ );
+ });
+ }
+
+ function onLoad() {
+ setUpPartialContentListeners();
+
+ // Add popstate listener so we return partial HTML with browser back button.
+ window.addEventListener('popstate', function (event) {
+ if (!event.state) {
+ return;
+ }
+ fetchContent(event.state.path, false);
+ });
+
+ // Ensure initial state is set up when the page loads so root page is in popstate.
+ window.addEventListener('DOMContentLoaded', () => {
+ const url = window.location.href;
+ history.replaceState({ path: url }, '', url);
+ });
}
Mozilla.run(onLoad);
diff --git a/springfield/firefox/templates/firefox/all/base.html b/springfield/firefox/templates/firefox/all/base.html
index b62659585..829268804 100644
--- a/springfield/firefox/templates/firefox/all/base.html
+++ b/springfield/firefox/templates/firefox/all/base.html
@@ -10,10 +10,6 @@
{{ ftl('firefox-all-download-the-firefox-v2') }}
{%- endblock -%}
-{%- block page_desc -%}
- {{ ftl('firefox-all-everyone-deserves-access-v2') }}
-{%- endblock -%}
-
{% block page_css %}
{{ css_bundle('firefox_all') }}
{% endblock %}
@@ -46,95 +42,7 @@
{% endif %}
{% block content %}
- {{ self.page_desc() }}{{ ftl('firefox-all-choose-which-firefox') }}
-
{{ ftl('firefox-all-everyone-deserves-access-v2') }}
+ {% if product %} + {% if product.slug == "desktop-release" %} +