From 643e65af5b604ac0b33cfdfcd823b484236589ba Mon Sep 17 00:00:00 2001 From: Splines Date: Mon, 17 Apr 2023 10:33:36 +0200 Subject: [PATCH 1/9] Use a modal to show sponsors --- app/assets/javascripts/footer_modal.js | 5 ++ app/views/main/_sponsors.html.erb | 112 +++++++++++++++++++++++++ app/views/main/sponsors.html.erb | 107 ----------------------- app/views/shared/_footer.html.erb | 20 ++++- 4 files changed, 134 insertions(+), 110 deletions(-) create mode 100644 app/assets/javascripts/footer_modal.js create mode 100644 app/views/main/_sponsors.html.erb delete mode 100644 app/views/main/sponsors.html.erb diff --git a/app/assets/javascripts/footer_modal.js b/app/assets/javascripts/footer_modal.js new file mode 100644 index 000000000..302d1649a --- /dev/null +++ b/app/assets/javascripts/footer_modal.js @@ -0,0 +1,5 @@ +$(document).ready(function () { + if (window.location.hash == "#sponsors") { + $('#sponsors').modal('show'); + } +}); \ No newline at end of file diff --git a/app/views/main/_sponsors.html.erb b/app/views/main/_sponsors.html.erb new file mode 100644 index 000000000..5f931df4c --- /dev/null +++ b/app/views/main/_sponsors.html.erb @@ -0,0 +1,112 @@ +

+ <%= t('sponsors.sponsorships') %> +

+
+ <%= t('sponsors.uni_hd') %> +
+ +
+ <%= t('sponsors.hse') %> +
+ + + \ No newline at end of file diff --git a/app/views/main/sponsors.html.erb b/app/views/main/sponsors.html.erb deleted file mode 100644 index 6302bba28..000000000 --- a/app/views/main/sponsors.html.erb +++ /dev/null @@ -1,107 +0,0 @@ -
-

- <%= t('sponsors.sponsorships') %> -

-
- <%= t('sponsors.uni_hd') %> -
- -
- <%= t('sponsors.hse') %> -
- -
\ No newline at end of file diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb index c0666d56f..004d438f6 100644 --- a/app/views/shared/_footer.html.erb +++ b/app/views/shared/_footer.html.erb @@ -1,4 +1,17 @@ +<%= javascript_include_tag :footer_modal %> + <% I18n.with_locale(current_user.try(:locale)) do %> + +<%# Sponsors modal %> + + +<%# Footbar %>
@@ -39,9 +52,10 @@ target: :_blank)) %>
- <%= t('footer.sponsors_html', - sponsors: link_to(t('basics.sponsors'), - sponsors_path)) %> + + <%= t('basics.sponsors') %> + Date: Mon, 17 Apr 2023 10:44:32 +0200 Subject: [PATCH 2/9] Redirect old sponsors route --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 964976b33..860927591 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -884,7 +884,7 @@ as: 'comments' get 'main/sponsors', - to: 'main#sponsors', + to: redirect('#sponsors'), as: 'sponsors' get 'main/start', From 4f35b95b7b12270fdd6c97fefa5a0ceae110fdcb Mon Sep 17 00:00:00 2001 From: Splines Date: Mon, 17 Apr 2023 10:49:17 +0200 Subject: [PATCH 3/9] Remove "#sponsors" slug when closing modal --- app/assets/javascripts/footer_modal.js | 8 ++++++-- app/views/main/_sponsors.html.erb | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/footer_modal.js b/app/assets/javascripts/footer_modal.js index 302d1649a..0a3e82009 100644 --- a/app/assets/javascripts/footer_modal.js +++ b/app/assets/javascripts/footer_modal.js @@ -1,5 +1,9 @@ -$(document).ready(function () { +$(document).ready(() => { if (window.location.hash == "#sponsors") { $('#sponsors').modal('show'); } -}); \ No newline at end of file + + $('#sponsors').on('hide.bs.modal', () => { + window.history.pushState(null, null, location.pathname); + }); +}); diff --git a/app/views/main/_sponsors.html.erb b/app/views/main/_sponsors.html.erb index 5f931df4c..298612e94 100644 --- a/app/views/main/_sponsors.html.erb +++ b/app/views/main/_sponsors.html.erb @@ -104,8 +104,7 @@ -
- + <%= t('basics.sponsors') %> From a93132388ad11260ab13a8865dd5306c6fafadde Mon Sep 17 00:00:00 2001 From: Splines Date: Mon, 17 Apr 2023 21:09:10 +0200 Subject: [PATCH 7/9] Remove whitespaces around link --- app/views/shared/_footer.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb index 3263bdc88..a6a98fe9c 100644 --- a/app/views/shared/_footer.html.erb +++ b/app/views/shared/_footer.html.erb @@ -52,9 +52,9 @@ target: :_blank)) %>
- - <%= t('basics.sponsors') %> - + <%= t('basics.sponsors') %> Date: Tue, 18 Apr 2023 22:10:52 +0200 Subject: [PATCH 8/9] Get rid of old sponsors route --- config/routes.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 860927591..3702cfc13 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -883,10 +883,6 @@ to: 'main#comments', as: 'comments' - get 'main/sponsors', - to: redirect('#sponsors'), - as: 'sponsors' - get 'main/start', to: 'main#start', as: 'start' From 3b6109af90aeaf147722b5b3aabaaef321fd303a Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 18 Apr 2023 22:13:59 +0200 Subject: [PATCH 9/9] Don't use browser history for modal --- app/assets/javascripts/footer_modal.js | 8 -------- app/views/shared/_footer.html.erb | 5 ++--- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/footer_modal.js b/app/assets/javascripts/footer_modal.js index c5271780c..28d02804f 100644 --- a/app/assets/javascripts/footer_modal.js +++ b/app/assets/javascripts/footer_modal.js @@ -2,12 +2,4 @@ document.addEventListener("turbolinks:load", () => { if (window.location.hash == "#sponsors") { $('#sponsors').modal('show'); } - - $('#sponsorsLink').click(function (event) { - window.history.pushState(null, null, '#sponsors'); - }); - - $('#sponsors').on('hide.bs.modal', () => { - window.history.pushState(null, null, location.pathname); - }); }); diff --git a/app/views/shared/_footer.html.erb b/app/views/shared/_footer.html.erb index a6a98fe9c..ed42a2b91 100644 --- a/app/views/shared/_footer.html.erb +++ b/app/views/shared/_footer.html.erb @@ -52,9 +52,8 @@ target: :_blank)) %>