From b2b9390cf22a86c11001a64d1b6d5d65e7b5538a Mon Sep 17 00:00:00 2001 From: Naman Gupta <01namangupta@gmail.com> Date: Sat, 17 Feb 2018 06:37:11 +0530 Subject: [PATCH] Added scroll to top in footer (#2251) --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/header_footer.js | 11 +++++++++++ app/assets/stylesheets/style.css | 12 ++++++++++++ app/views/layouts/_footer.html.erb | 5 +++++ 4 files changed, 29 insertions(+) create mode 100644 app/assets/javascripts/header_footer.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1246650d62..c29f1006aa 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -50,4 +50,5 @@ //= require chart.js/dist/Chart.js // require turbolinks // Temporarily removed while fixing //= require google_analytics.js +//= require header_footer.js diff --git a/app/assets/javascripts/header_footer.js b/app/assets/javascripts/header_footer.js new file mode 100644 index 0000000000..3a7c0dc191 --- /dev/null +++ b/app/assets/javascripts/header_footer.js @@ -0,0 +1,11 @@ +jQuery(document).ready(function() { + var duration = 300; + + $(".back-to-top").click(function(event) { + event.preventDefault(); + jQuery("html, body").animate({scrollTop: 0}, duration); + return false; + }) + +}); + \ No newline at end of file diff --git a/app/assets/stylesheets/style.css b/app/assets/stylesheets/style.css index 9cec4337ae..cffc232267 100644 --- a/app/assets/stylesheets/style.css +++ b/app/assets/stylesheets/style.css @@ -417,3 +417,15 @@ div.note.moderated h4 { font-size: 80%; } } + +.back-to-top { + + float: right; + +} + +.back-to-top i { + + font-size: 60px; + +} diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index c214a6ab42..41a42a2821 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -39,6 +39,11 @@ <% end %> + + + + +