<commit_before>// Dependencies:
// 
// window.breakpoint

(function(window) {
	"use strict";

	var Sparky     = window.Sparky;
	var dom        = window.dom;
	var breakpoint = window.breakpoint;

	Sparky.fn['sticky'] = function stickToTop(node, scopes) {
		var value = node.getAttribute('data-sticky');

		scopes.tap(function() {
			var top = jQuery(node).offset().top;
			var gap = dom.valueToPx(value);
			var fixed;

			breakpoint({
				minScrollTop: top - gap
			}, function enter() {
				fixed = node.cloneNode(true);
				var fixedThs  = dom.query('th', fixed);

				jQuery('th', node).each(function(i, th) {
					fixedThs[i].style.width = dom.style('width', th);
				});

				dom.classes(fixed).add('fixed');
				dom.append(node.parentNode, fixed);

			}, function exit() {
				if (fixed) { dom.remove(fixed); }
			});
		});
	};
})(this);<commit_msg>Converts fn.sticky to dom. Sticky element is inserted directly following current element.<commit_after>// Dependencies:
// 
// window.breakpoint

(function(window) {
	"use strict";

	var Sparky     = window.Sparky;
	var dom        = window.dom;
	var breakpoint = window.breakpoint;

	Sparky.fn['sticky'] = function stickToTop(node, scopes) {
		var value = dom.attribute('data-sticky', node);

		scopes.tap(function() {
			var top = dom.offset(node)[1];
			var gap = dom.valueToPx(value);
			var fixed;

			breakpoint({
				minScrollTop: top - gap
			}, function enter() {
				fixed = node.cloneNode(true);
				var fixedThs  = dom.query('th', fixed);

				// Make sure table header cells retain their correct width
				dom.query('th', node).forEach(function(th, i) {
					fixedThs[i].style.width = dom.style('width', th) + 'px';
				});

				dom.classes(fixed).add('fixed');
				dom.after(node, fixed);
			}, function exit() {
				if (fixed) { dom.remove(fixed); }
			});
		});
	};
})(this);
{'fraction_non_alphanumeric': 0.17018970189701896, 'fraction_numerical': 0.0005420054200542005, 'mean_word_length': 3.1954545454545453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1654572', 'n_tokens_mistral': 738, 'n_tokens_neox': 625, 'n_words': 137}