From 50327a82168b08ac7fabfa607e7b24143f3c4b0b Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Wed, 7 Feb 2024 05:14:54 +0000 Subject: [PATCH] Move google maps setup js inside application bundle --- app/assets/javascripts/tailwind/application.js | 2 -- app/assets/javascripts/tailwind/application.js.erb | 10 ++++++++++ app/views/_tailwind/application/_end_matter.html.erb | 10 ---------- app/views/_tailwind/layouts/application.html.erb | 1 - 4 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 app/assets/javascripts/tailwind/application.js create mode 100644 app/assets/javascripts/tailwind/application.js.erb delete mode 100644 app/views/_tailwind/application/_end_matter.html.erb diff --git a/app/assets/javascripts/tailwind/application.js b/app/assets/javascripts/tailwind/application.js deleted file mode 100644 index 8478f07dc..000000000 --- a/app/assets/javascripts/tailwind/application.js +++ /dev/null @@ -1,2 +0,0 @@ -//= require tailwind/maps -//= require geolocation \ No newline at end of file diff --git a/app/assets/javascripts/tailwind/application.js.erb b/app/assets/javascripts/tailwind/application.js.erb new file mode 100644 index 000000000..05a6a3ca6 --- /dev/null +++ b/app/assets/javascripts/tailwind/application.js.erb @@ -0,0 +1,10 @@ +//= require tailwind/maps +//= require geolocation + +(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({ + key: "<%= Rails.application.credentials.dig(:google_maps, :api_key) %>", + v: "weekly", + // Use the 'v' parameter to indicate the version to use (weekly, beta, alpha, etc.). + // Add other bootstrap parameters as needed, using camel case. + region: "au" +}); diff --git a/app/views/_tailwind/application/_end_matter.html.erb b/app/views/_tailwind/application/_end_matter.html.erb deleted file mode 100644 index 94d03b283..000000000 --- a/app/views/_tailwind/application/_end_matter.html.erb +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/app/views/_tailwind/layouts/application.html.erb b/app/views/_tailwind/layouts/application.html.erb index 5d9e2678f..8ce785654 100644 --- a/app/views/_tailwind/layouts/application.html.erb +++ b/app/views/_tailwind/layouts/application.html.erb @@ -25,6 +25,5 @@ <% end %> <%= render "footer" %> - <%= render "end_matter" %>