diff --git a/assets/js/app.js b/assets/js/app.js index d53b02e452..ef6e2658ad 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -45,6 +45,8 @@ import { accordionInit } from "../ts/ui/accordion"; import initializeSentry from "../ts/sentry"; import Hooks from "../ts/phoenix-hooks/index.ts"; +import mobileAppBanner from "./mobile-app-banner.js"; + // Establish Phoenix Socket and LiveView configuration. import { Socket } from "phoenix"; import { LiveSocket } from "phoenix_live_view"; @@ -135,3 +137,5 @@ eventPageSetup(); previousEventsButton(); pslPageSetup(); accordionInit(); + +mobileAppBanner(); diff --git a/assets/js/mobile-app-banner.js b/assets/js/mobile-app-banner.js new file mode 100644 index 0000000000..72e702221d --- /dev/null +++ b/assets/js/mobile-app-banner.js @@ -0,0 +1,28 @@ +const isAlertsPage = () => { + const url = window.location.href; + + return /\/alerts\/[\w.-]+/.test(url); +}; + +const isIPhone = () => { + return /iPhone/.test(navigator.userAgent); +}; + +const isSchedulePage = () => { + const url = window.location.href; + + return /\/schedules\/[\w.-]+\/line/.test(url); +}; + +const isStopPage = () => { + const url = window.location.href; + + return /\/stops\/[\w.-]+/.test(url); +}; + +// Show the mobile app banner +export default function mobileAppBanner() { + if (isIPhone() && (isAlertsPage() || isSchedulePage() || isStopPage())) { + document.querySelector("#mobile-app-banner").style.display = "block"; + } +} diff --git a/lib/dotcom_web/templates/layout/root.html.eex b/lib/dotcom_web/templates/layout/root.html.eex index cbd1103ce8..0cbc49486c 100644 --- a/lib/dotcom_web/templates/layout/root.html.eex +++ b/lib/dotcom_web/templates/layout/root.html.eex @@ -75,6 +75,11 @@ <% end %> +
<%= if assigns[:search_header?] do %> <%= render "_searchbar.html", assigns %> <% end %>