<commit_before>/*! jQuery Persistent Navigation 0.1.0
 *  Copyright (c) 2014 <NAME>
 *  Licensed under the MIT license.
 *  http://en.wikipedia.org/wiki/MIT_License
 */
(function($) {
	$.fn.persistentNavigation = function(method) {
		return this.each(function() {
			switch (method) {
				case 'destroy':
					destroy($(this));
					break;
				default:
					init($(this));
			}
		});
	}

	function init(element) {
		var $window = $(window),
			$menu = element,
			navId = 'nav_' + Math.floor( Math.random() * (new Date()).getTime() ),
			topOffset = $menu.offset().top,
			scrollHeight = $window.height() - topOffset;

		// wrap in fixed div, offset to starting position
		var $wrapper = $('<div id="' + navId + '"></div>').css({'position': 'fixed', 'top': topOffset});
		$menu.wrap($wrapper).css({'position': 'absolute', 'top': 0}).data('persistentNavigation', {navId: navId});

		var lastScroll = 0;
		// emulate natural scrolling until menu is fully revealed, then stop
		$window.on('scroll.' + navId, function() {
			if ($window.scrollTop() < lastScroll) { // going up
				if ( $menu.position().top < 0 ) {
					$menu.css('top', Math.min( $menu.position().top + lastScroll - $window.scrollTop(), 0) );
				}
			}
			else { // going down
				if ( $menu.height() + $menu.position().top > scrollHeight ) { // scroll
					$menu.css('top', Math.max( $menu.position().top + lastScroll - $window.scrollTop(), scrollHeight - $menu.height() ) );
				}
			}
			lastScroll = $window.scrollTop();
		}).trigger('scroll');

	}

	function destroy(element) {
		var settings = element.data('persistentNavigation');
		if (settings && settings.navId) {
			$(window).off('scroll.' + settings.navId);
			element.css({'position': '', 'top': ''});
			$('#' + settings.navId).replaceWith(element.remove());
		}<commit_msg>update method for resize<commit_after>/*! jQuery Persistent Navigation 0.1.0
 *  Copyright (c) 2014 <NAME>
 *  Licensed under the MIT license.
 *  http://en.wikipedia.org/wiki/MIT_License
 */
(function($) {
	$.fn.persistentNavigation = function(method) {
		return this.each(function() {
			switch (method) {
				case 'update':
					update($(this));
					break;
				case 'destroy':
					destroy($(this));
					break;
				default:
					init($(this));
			}
		});
	}

	function init(element) {
		var $window = $(window),
			$menu = element,
			settings = {
				navId: 'nav_' + Math.floor( Math.random() * (new Date()).getTime() ),
				topOffset: $menu.offset().top,
				scrollHeight: $window.height() - $menu.offset().top
			}

		// wrap in fixed div, offset to starting position
		var $wrapper = $('<div id="' + settings.navId + '"></div>').css({'position': 'fixed', 'top': settings.topOffset});
		$menu.wrap($wrapper).css({'position': 'absolute', 'top': 0}).data('persistentNavigation', settings);

		var lastScroll = 0;
		// emulate natural scrolling until menu is fully revealed, then stop
		$window.on('scroll.' + settings.navId, function() {
			if ($window.scrollTop() < lastScroll) { // going up
				if ( $menu.position().top < 0 ) {
					$menu.css('top', Math.min( $menu.position().top + lastScroll - $window.scrollTop(), 0) );
				}
			}
			else { // going down
				if ( $menu.height() + $menu.position().top > settings.scrollHeight ) { // scroll
					$menu.css('top', Math.max( $menu.position().top + lastScroll - $window.scrollTop(), settings.scrollHeight - $menu.height() ) );
				}
			}
			lastScroll = $window.scrollTop();
		}).trigger('scroll');

		$window.on('resize.' + settings.navId, function() { update(element) });
	}

	function update(element) {
		var settings = element.data('persistentNavigation');
		settings.scrollHeight = $(window).height() - settings.topOffset;
	}

	function destroy(element) {
		var settings = element.data('persistentNavigation');
		if (settings && settings.navId) {
			$(window).off('.' + settings.navId);
			element.css({'position': '', 'top': ''});
			$('#' + settings.navId).replaceWith(element.remove());
		}
{'fraction_non_alphanumeric': 0.19807983830217282, 'fraction_numerical': 0.0055583628094997475, 'mean_word_length': 3.514253135689852, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '6596008', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1253, 'n_words': 279}