Commit ef043ca5 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#214329 by starbow: avoid attaching scroll behavior multiple times

parent ef1235cc
// $Id$
Drupal.tableHeaderDoScroll = function() {
if (typeof(Drupal.tableHeaderOnScroll)=='function') {
Drupal.tableHeaderOnScroll();
}
};
Drupal.behaviors.tableHeader = function (context) {
// This breaks in anything less than IE 7. Prevent it from running.
if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7) {
if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
return;
}
......@@ -16,7 +22,7 @@ Drupal.behaviors.tableHeader = function (context) {
top: '0px'
});
var headerClone = $(headerClone)[0];
headerClone = $(headerClone)[0];
headers.push(headerClone);
// Store parent table.
......@@ -44,7 +50,7 @@ Drupal.behaviors.tableHeader = function (context) {
var cellWidth = parentCell.eq(index).css('width');
// Exception for IE7.
if (cellWidth == 'auto') {
var cellWidth = parentCell.get(index).clientWidth +'px';
cellWidth = parentCell.get(index).clientWidth +'px';
}
$(this).css('width', cellWidth);
});
......@@ -56,16 +62,22 @@ Drupal.behaviors.tableHeader = function (context) {
var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition;
var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden';
$(e).css({left: -hScroll + e.hPosition +'px', visibility: visState});
};
}
// Only attach to scrollbars once, even if Drupal.attachBehaviors is called
// multiple times.
if (!$('body').hasClass('tableHeader-processed')) {
$('body').addClass('tableHeader-processed');
$(window).scroll(Drupal.tableHeaderDoScroll);
$(document.documentElement).scroll(Drupal.tableHeaderDoScroll);
}
// Track scrolling.
var scroll = function() {
Drupal.tableHeaderOnScroll = function() {
$(headers).each(function () {
tracker(this);
});
};
$(window).scroll(scroll);
$(document.documentElement).scroll(scroll);
// Track resizing.
var time = null;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment