From 72b734e3e8eebba1aca043ac98e30a4c49cfd437 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Tue, 9 Aug 2011 01:04:54 -0700 Subject: [PATCH] scroll to top like a boss --- app/views/layouts/application.html.haml | 4 +++- public/javascripts/view.js | 11 +++++++++++ public/stylesheets/sass/application.sass | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 71812c0e0..22c7d90da 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -107,6 +107,9 @@ %br = link_to t('.have_a_problem'), 'http://diaspora.shapado.com/' + %a{:id=>"back-to-top", :title=>"Back to top", :href=>"#"} + ⇧ + -if !@landing_page && request.url.match(/joindiaspora.com/) :javascript var is_ssl = ("https:" == document.location.protocol); @@ -122,4 +125,3 @@ feedback_widget_options.color = "#222"; feedback_widget_options.style = "idea"; var feedback_widget = new GSFN.feedback_widget(feedback_widget_options); - diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 45085b50d..2c7cb087f 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -25,6 +25,17 @@ var View = { $('#main_stream label').inFieldLabels(); }); + /*scroll to top */ + jQuery(window).scroll(function(){ + if(jQuery(window).scrollTop() > 1000){ + // show back to top + jQuery('#back-to-top').stop().animate({opacity: 1}); + } + else{ + // hide back to top + jQuery('#back-to-top').stop().animate({opacity: 0}); + } + }); /* Showing debug messages */ $(this.debug.selector) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index d94ddf470..f59519843 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3367,3 +3367,14 @@ ul#getting_started .accept_invitation_text :font :weight lighter +#back-to-top + :display block + :color white + :position fixed + :right 20px + :top 50px + :opacity 0 + :font-size 3em + :padding 0 12px 0 12px + :border-radius 10px + :background-color #82D400