From c4ddc0118d4802a4a2c7c3bd7aaf5cfa8aa6d7f4 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 25 Dec 2014 18:29:43 +0500 Subject: [PATCH] [#369] add scroller --- app/assets/javascripts/extra/scroller.js.coffee | 13 +++++++++++++ app/assets/javascripts/new_application.js | 1 + app/assets/stylesheets/custom_bootstrap.css.sass | 7 +++++++ app/views/layouts/_scroller.html.slim | 1 + app/views/layouts/application.html.slim | 2 ++ 5 files changed, 24 insertions(+) create mode 100644 app/assets/javascripts/extra/scroller.js.coffee create mode 100644 app/views/layouts/_scroller.html.slim diff --git a/app/assets/javascripts/extra/scroller.js.coffee b/app/assets/javascripts/extra/scroller.js.coffee new file mode 100644 index 000000000..9e63006f1 --- /dev/null +++ b/app/assets/javascripts/extra/scroller.js.coffee @@ -0,0 +1,13 @@ +# http://sitear.ru/material/sozdaem-knopku-naverh-scroll-to-top-na-jquery +$(window).scroll -> + if $(this).scrollTop() > 0 + $("#scroller").fadeIn() + else + $("#scroller").fadeOut() + return + +$("#scroller").click -> + $("body,html").animate + scrollTop: 0 + , 400 + false diff --git a/app/assets/javascripts/new_application.js b/app/assets/javascripts/new_application.js index 99940e7ff..ebc3a11ec 100644 --- a/app/assets/javascripts/new_application.js +++ b/app/assets/javascripts/new_application.js @@ -41,6 +41,7 @@ //= require extra/highlight //= require extra/pull +//= require extra/scroller //= require_self diff --git a/app/assets/stylesheets/custom_bootstrap.css.sass b/app/assets/stylesheets/custom_bootstrap.css.sass index 9c0e7bf1c..372be917c 100644 --- a/app/assets/stylesheets/custom_bootstrap.css.sass +++ b/app/assets/stylesheets/custom_bootstrap.css.sass @@ -218,3 +218,10 @@ textarea.resize-vertical .update-label, .update-status, .pointer cursor: pointer + +#scroller + position: fixed + bottom: 30px + left: 20px + cursor: pointer + display: none diff --git a/app/views/layouts/_scroller.html.slim b/app/views/layouts/_scroller.html.slim new file mode 100644 index 000000000..97f2dbf4e --- /dev/null +++ b/app/views/layouts/_scroller.html.slim @@ -0,0 +1 @@ +#scroller.fa.fa-arrow-circle-up.fa-2x.text-primary \ No newline at end of file diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index c7cb01f72..5f5db5e4b 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -33,3 +33,5 @@ html == javascript_include_tag 'moment/ru.js', cache: 'moment' == javascript_include_tag 'angular-locale_ru-ru', cache: 'angular-locale' == yield :additional_scripts if content_for?(:additional_scripts) + + == render '/layouts/scroller'