comparison misc/tableheader.js @ 11:589fb7c02327 6.5

Drupal 6.5
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:32:19 +0100
parents c1f4ac30525a
children
comparison
equal deleted inserted replaced
10:6f15c9d74937 11:589fb7c02327
1 // $Id: tableheader.js,v 1.16 2008/01/30 10:17:39 goba Exp $ 1 // $Id: tableheader.js,v 1.16.2.1 2008/10/01 23:30:36 goba Exp $
2 2
3 Drupal.tableHeaderDoScroll = function() { 3 Drupal.tableHeaderDoScroll = function() {
4 if (typeof(Drupal.tableHeaderOnScroll)=='function') { 4 if (typeof(Drupal.tableHeaderOnScroll)=='function') {
5 Drupal.tableHeaderOnScroll(); 5 Drupal.tableHeaderOnScroll();
6 } 6 }
33 33
34 $(table).addClass('sticky-table'); 34 $(table).addClass('sticky-table');
35 $(this).addClass('tableHeader-processed'); 35 $(this).addClass('tableHeader-processed');
36 }); 36 });
37 37
38 // Define the anchor holding var.
39 var prevAnchor = '';
40
38 // Track positioning and visibility. 41 // Track positioning and visibility.
39 function tracker(e) { 42 function tracker(e) {
40 // Save positioning data. 43 // Save positioning data.
41 var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight; 44 var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
42 if (e.viewHeight != viewHeight) { 45 if (e.viewHeight != viewHeight) {
60 // Track horizontal positioning relative to the viewport and set visibility. 63 // Track horizontal positioning relative to the viewport and set visibility.
61 var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft; 64 var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
62 var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition; 65 var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition;
63 var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden'; 66 var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden';
64 $(e).css({left: -hScroll + e.hPosition +'px', visibility: visState}); 67 $(e).css({left: -hScroll + e.hPosition +'px', visibility: visState});
68
69 // Check the previous anchor to see if we need to scroll to make room for the header.
70 // Get the height of the header table and scroll up that amount.
71 if (prevAnchor != location.hash) {
72 if (location.hash != '') {
73 var scrollLocation = $('td'+ location.hash).offset().top - $(e).height();
74 $('body, html').scrollTop(scrollLocation);
75 }
76 prevAnchor = location.hash;
77 }
65 } 78 }
66 79
67 // Only attach to scrollbars once, even if Drupal.attachBehaviors is called 80 // Only attach to scrollbars once, even if Drupal.attachBehaviors is called
68 // multiple times. 81 // multiple times.
69 if (!$('body').hasClass('tableHeader-processed')) { 82 if (!$('body').hasClass('tableHeader-processed')) {