<commit_before>/*! Copyright (c) 2011 by <NAME> - https://github.com/jmosbech/StickyTableHeaders 
    MIT license info: https://github.com/jmosbech/StickyTableHeaders/blob/master/license.txt */

(function ($) {
	$.StickyTableHeaders = function (el, options) {
		// To avoid scope issues, use 'base' instead of 'this'
		// to reference this class from internal events and functions.
		var base = this;

		// Access to jQuery and DOM versions of element
		base.$el = $(el);
		base.el = el;

		// Add a reverse reference to the DOM object
		base.$el.data('StickyTableHeaders', base);

		base.init = function () {
			base.options = $.extend({}, $.StickyTableHeaders.defaultOptions, options);

			base.$el.each(function () {
				var $this = $(this);
				$this.wrap('<div class="divTableWithFloatingHeader" style="position:relative"></div>');

				var originalHeader = $('thead:first', this);
				originalHeader.before(originalHeader.clone());
				var clonedHeader = $('thead:first', this);

				clonedHeader.addClass('tableFloatingHeader');
				clonedHeader.css('position', 'fixed');
				clonedHeader.css('top', '0px');
				clonedHeader.css('left', $this.css('margin-left'));
				clonedHeader.css('display', 'none');

				originalHeader.addClass('tableFloatingHeaderOriginal');

				// enabling support for jquery.tablesorter plugin
				$this.bind('sortEnd', function (e) { base.updateCloneFromOriginal(originalHeader, clonedHeader); });
			});

			base.updateTableHeaders();
			$(window).scroll(base.updateTableHeaders);
			$(window).resize(base.updateTableHeaders);
		};

		base.updateTableHeaders = function () {
			base.$el.each(function () {
				var $this = $(this);
				var $window = $(window);

				var fixedHeaderHeight = isNaN(base.options.fixedOffset) ? base.options.fixedOffset.height() : base.options.fixedOffset;

				var originalHeader = $('.tableFloatingHeaderOriginal', this);
				var floatingHeader = $('.tableFloatingHeader', this);
				var offset = $this.offset();
				var scrollTop = $window.scrollTop() + fixedHeaderHeight;
				var scrollLeft = $window.scrollLeft();

				if ((scrollTop > offset.top) && (scrollTop < offset.top + $this.height())) {
					floatingHeader.css('top', fixedHeaderHeight + 'px');
					floatingHeader.css('margin-top', 0);
					floatingHeader.css('left', (offset.left - scrollLeft) + 'px');
					floatingHeader.css('display', 'block');

					base.updateCloneFromOriginal(originalHeader, floatingHeader);
				}
				else {
					floatingHeader.css('display', 'none');
				}
			});
		};

		base.updateCloneFromOriginal = function (originalHeader, floatingHeader) {
			// Copy cell widths and classes from original header
			$('th', floatingHeader).each(function (index) {
				$this = $(this);
				var origCell = $('th', originalHeader).eq(index);
				$this.removeClass().addClass(origCell.attr('class'));
				$this.css('width', origCell.width());
			});

			// Copy row width from whole table
			floatingHeader.css('width', originalHeader.width());
		};

		// Run initializer
		base.init();
	};

	$.StickyTableHeaders.defaultOptions = {
		fixedOffset: 0
	};

	$.fn.stickyTableHeaders = function (options) {
		return this.each(function () {
			(new $.StickyTableHeaders(this, options));
		});
	};

})(jQuery);
<commit_msg>Combine CSS changes to single call to avoid unneeded redraws<commit_after>/*! Copyright (c) 2011 by <NAME> - https://github.com/jmosbech/StickyTableHeaders 
    MIT license info: https://github.com/jmosbech/StickyTableHeaders/blob/master/license.txt */

(function ($) {
	$.StickyTableHeaders = function (el, options) {
		// To avoid scope issues, use 'base' instead of 'this'
		// to reference this class from internal events and functions.
		var base = this;

		// Access to jQuery and DOM versions of element
		base.$el = $(el);
		base.el = el;

		// Add a reverse reference to the DOM object
		base.$el.data('StickyTableHeaders', base);

		base.init = function () {
			base.options = $.extend({}, $.StickyTableHeaders.defaultOptions, options);

			base.$el.each(function () {
				var $this = $(this);
				$this.wrap('<div class="divTableWithFloatingHeader" style="position:relative"></div>');

				var originalHeader = $('thead:first', this);
				originalHeader.before(originalHeader.clone());
				var clonedHeader = $('thead:first', this);

				clonedHeader.addClass('tableFloatingHeader');
				clonedHeader.css({
					'position': 'fixed',
					'top': 0,
					'left': $this.css('margin-left'),
					'display': 'none'
				});

				originalHeader.addClass('tableFloatingHeaderOriginal');

				// enabling support for jquery.tablesorter plugin
				$this.bind('sortEnd', function (e) { base.updateCloneFromOriginal(originalHeader, clonedHeader); });
			});

			base.updateTableHeaders();
			$(window).scroll(base.updateTableHeaders);
			$(window).resize(base.updateTableHeaders);
		};

		base.updateTableHeaders = function () {
			base.$el.each(function () {
				var $this = $(this);
				var $window = $(window);

				var fixedHeaderHeight = isNaN(base.options.fixedOffset) ? base.options.fixedOffset.height() : base.options.fixedOffset;

				var originalHeader = $('.tableFloatingHeaderOriginal', this);
				var floatingHeader = $('.tableFloatingHeader', this);
				var offset = $this.offset();
				var scrollTop = $window.scrollTop() + fixedHeaderHeight;
				var scrollLeft = $window.scrollLeft();

				if ((scrollTop > offset.top) && (scrollTop < offset.top + $this.height())) {
					floatingHeader.css({
						'top': fixedHeaderHeight,
						'margin-top': 0,
						'left': offset.left - scrollLeft,
						'display': 'block'
					});

					base.updateCloneFromOriginal(originalHeader, floatingHeader);
				}
				else {
					floatingHeader.css('display', 'none');
				}
			});
		};

		base.updateCloneFromOriginal = function (originalHeader, floatingHeader) {
			// Copy cell widths and classes from original header
			$('th', floatingHeader).each(function (index) {
				$this = $(this);
				var origCell = $('th', originalHeader).eq(index);
				$this.removeClass().addClass(origCell.attr('class'));
				$this.css('width', origCell.width());
			});

			// Copy row width from whole table
			floatingHeader.css('width', originalHeader.width());
		};

		// Run initializer
		base.init();
	};

	$.StickyTableHeaders.defaultOptions = {
		fixedOffset: 0
	};

	$.fn.stickyTableHeaders = function (options) {
		return this.each(function () {
			(new $.StickyTableHeaders(this, options));
		});
	};

})(jQuery);

{'fraction_non_alphanumeric': 0.15569221538923053, 'fraction_numerical': 0.0020998950052497373, 'mean_word_length': 3.358169934640523, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5978437', 'n_tokens_mistral': 2385, 'n_tokens_neox': 1932, 'n_words': 419}