Skip to content
Snippets Groups Projects
Commit 99d5d3d6 authored by Angie Byron's avatar Angie Byron
Browse files

#184143 by redndahead: Fix #anchor tags conflicting with tableheader.js.

parent dbafad09
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -35,6 +35,9 @@ Drupal.behaviors.tableHeader = function (context) { ...@@ -35,6 +35,9 @@ Drupal.behaviors.tableHeader = function (context) {
$(this).addClass('tableHeader-processed'); $(this).addClass('tableHeader-processed');
}); });
// Define the anchor holding var.
var prevAnchor = '';
// Track positioning and visibility. // Track positioning and visibility.
function tracker(e) { function tracker(e) {
// Save positioning data. // Save positioning data.
...@@ -62,6 +65,16 @@ Drupal.behaviors.tableHeader = function (context) { ...@@ -62,6 +65,16 @@ Drupal.behaviors.tableHeader = function (context) {
var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition; var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition;
var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden'; var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden';
$(e).css({left: -hScroll + e.hPosition +'px', visibility: visState}); $(e).css({left: -hScroll + e.hPosition +'px', visibility: visState});
// Check the previous anchor to see if we need to scroll to make room for the header.
// Get the height of the header table and scroll up that amount.
if (prevAnchor != location.hash) {
if (location.hash != '') {
var scrollLocation = $('td' + location.hash).offset().top - $(e).height();
$('body, html').scrollTop(scrollLocation);
}
prevAnchor = location.hash;
}
} }
// Only attach to scrollbars once, even if Drupal.attachBehaviors is called // Only attach to scrollbars once, even if Drupal.attachBehaviors is called
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment