Permalink
Browse files

Add 'Back to top button'

  • Loading branch information...
1 parent f073071 commit 43c5ba9d8f7e23bb7da661e815b1126938e995ea @den-plugins committed Dec 22, 2011
View
3 app/views/task_boards/show.html.erb
@@ -252,6 +252,7 @@
<% end %>
</tbody>
</table>
+<div id="back_to_top">Back to top</div>
<%= javascript_include_tag 'fixedtableheader', :plugin => 'scrum_task_board' %>
<%= javascript_include_tag 'jquery.colorbox-min.js', :plugin => 'scrum_task_board' %>
<%= javascript_include_tag 'jquery.jqplot.js', :plugin => 'redmine_burndown' %>
@@ -308,8 +309,6 @@
});
}
}
-</script>
-<script type='text/javascript'>
//===========TOOLTIP===========
var tip;
jQuery(".tooltip").hover(function(){
View
6 assets/javascripts/fixedtableheader.js
@@ -21,7 +21,7 @@ jQuery(function( $ ){
// 'Recreate' the table header since attributing a thead with position: fixed causes empty <td>s to lose their width
var jmark = jQuery( "#task_board thead" );
var jheader = jQuery( "#fixed_table_header" );
-
+ var jbtt = jQuery("#back_to_top");
var count = 0;
var leftInit = jheader.offset().left;
@@ -66,11 +66,13 @@ jQuery(function( $ ){
if (viewTop > markTop)
{
jheader.show();
+ jbtt.fadeIn();
}
// Check to see if the view has scroll back up above the message
else if (viewTop <= markTop)
{
jheader.hide();
+ jbtt.fadeOut();
}
// Allow the fixed header to scroll horizontally
jheader.offset({
@@ -101,6 +103,8 @@ jview.resize(function(){
jQuery("#task_board").bind('DOMNodeInserted DOMNodeRemoved', function(event) {
th_adjust();
});
+
+ jbtt.click(function(){ jQuery("body").animate({scrollTop: 0}, 100) });
});
// script modified from http://www.bennadel.com/blog/1810-Creating-A-Sometimes-Fixed-Position-Element-With-jQuery.htm
View
19 assets/stylesheets/task_board.css
@@ -392,3 +392,22 @@ ul.condensed li {display: inline-block; margin-right: 1px; }
.effortLabel { font-weight: normal;color: #666;font-size: 95%; }
+#back_to_top {
+ position: fixed;
+ right: 10px;
+ bottom: 4px;
+ text-align: center;
+ border: 1px solid #999
+ padding: 8px 10px;
+ background: white;
+ cursor: pointer;
+ font-weight: bold;
+ display:none;
+ box-shadow: 1px 1px 1px #CCC;
+}
+
+#back_to_top:hover {
+ border-color: #ccc;
+ color: #999;
+}
+

0 comments on commit 43c5ba9

Please sign in to comment.