Project

General

Profile

Patch #36742 » 36742.patch

Dmitry Makurin , 2022-03-09 13:34

View differences:

app/views/layouts/base.html.erb
<%= call_hook :view_layouts_base_body_top %>
<div id="wrapper">
<div id="us-btn-up"><span class="chevron-up"></span></div>
<div class="flyout-menu js-flyout-menu">
<% if User.current.logged? || !Setting.login_required? %>
public/javascripts/application.js
tribute.attach(element);
}
function setupUpButton() {
$(window).scroll(function() {
if ($(this).scrollTop() > 30) {
$('#us-btn-up').addClass('showed');
} else {
$('#us-btn-up').removeClass('showed');
}
});
$('#us-btn-up').click(function () {
$('html, body').animate({ scrollTop: 0 }, 300);
});
}
$(document).ready(setupAjaxIndicator);
$(document).ready(hideOnLoad);
......
$(document).on('focus', '[data-auto-complete=true]', function(event) {
inlineAutoComplete(event.target);
});
$(document).ready(setupUpButton);
public/stylesheets/application.css
display: inline;
opacity: 1;
}
#us-btn-up {
display: none;
}
@media all and (min-width: 900px) {
#us-btn-up {
display: block;
height: 0;
padding: 0;
overflow: hidden;
position: fixed;
bottom: 35px;
right: 35px;
z-index: 99;
border: none;
outline: none;
color: #888;
cursor: pointer;
border-radius: 4px;
transition: opacity .3s, background-color .3s;
opacity: 0;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 0 30px 0 rgba(0, 0, 0, 0.15) inset;
background: #fff;
}
#us-btn-up.showed {
height: auto;
opacity: 0.7;
padding: 15px 20px;
}
#us-btn-up:hover {
background-color: #f5f5f5;
}
.chevron-up {
position: relative;
height: 16px;
width: 16px;
top: 1px;
display: inline-block;
background-image: url(../images/chevron-up.png);
background-size: cover;
margin: 0;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
test/system/scroll_to_top_button_test.rb
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2022 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../application_system_test_case', __FILE__)
class ScrollToTopButtonTest < ApplicationSystemTestCase
fixtures :issues, :users, :projects, :trackers, :projects_trackers, :issue_statuses, :enumerations, :projects_trackers,
:roles, :members, :member_roles, :enabled_modules
def setup
super
100.times { Issue.generate! }
end
def test_scroll_button
log_user('admin', 'admin')
visit '/issues?per_page=100'
# scroll to the page bottom
page.execute_script "window.scrollBy(0,10000)"
# button appears
assert has_css? '#us-btn-up.showed'
# scroll back to the top
find('div#us-btn-up').click
# no button
assert has_no_css? '#us-btn-up.showed'
end
end
(2-2/2)