assets/js/modules/navHighlight.js
function () {

			var headersLength = sourceHeaders.length;
			var minDistance = Number.MAX_VALUE;
			var closestHeader = -1;
			var fileNameInUrl = filename === '' ? '' : filename + '.' +  extension;

			if ((document.body.scrollTop || document.documentElement.scrollTop) < hashThreshold) {

				if (!!window.location.hash)	{
					currentHeader = -1;
					if (!!(window.history && history.pushState)) {
						window.history.replaceState({anchor: 0}, document.title, window.location.pathname);
					}
				}

				return;
			}

			// catch section which is closed for top window border
			for (var i=0; i < headersLength; i++) {

				if ((sourceHeaders[i].tagName === 'H3') && (!utils.hasClass(utils.closest(sourceHeaders[i], 'source_section'), 'source_section__open')) ) {
					continue;
				}

				var currentDist = Math.abs( utils.offsetTop(sourceHeaders[i]) - 60 - window.pageYOffset ); //60 = Header heights
				if (currentDist < minDistance) {
					closestHeader = i;
					minDistance = currentDist;
				}
			}

			if (closestHeader !== currentHeader) {
				utils.removeClass( document.querySelector('.source_main_nav_li.__active'), '__active');
				utils.removeClass( document.querySelector('.source_main_nav_a.__active'), '__active');

				utils.addClass(navHeaders[closestHeader], '__active');

				var parent = utils.closest(navHeaders[closestHeader], 'source_main_nav_li');
				var hashFromLink = navHeaders[closestHeader].getAttribute('href');

				if (!!parent && parent) {
					utils.addClass(parent, '__active');
				}

				if (_this.conf.updateHash) {
					// TODO: pause hash change when scrolling - append it only on stand-still

					// Modern browsers uses history API for correct back-button-browser functionality
					if (!!(window.history && history.pushState)) {
						window.history.replaceState({anchor: closestHeader+1}, document.title, fileNameInUrl + hashFromLink);
					} else { // ie9 fallback
						 window.location.hash = hashFromLink;
					}
				}

				currentHeader = closestHeader;
			}
		}
function () {

			var headersLength = sourceHeaders.length;
			var minDistance = Number.MAX_VALUE;
			var closestHeader = -1;
			var fileNameInUrl = filename === '' ? '' : filename + '.' +  extension;

			if ((document.body.scrollTop || document.documentElement.scrollTop) < hashThreshold) {

				if (!!window.location.hash)	{
					currentHeader = -1;
					if (!!(window.history && history.pushState)) {
						window.history.replaceState({anchor: 0}, document.title, window.location.pathname);
					}
				}

				return;
			}

			// catch section which is closed for top window border
			for (var i=0; i < headersLength; i++) {

				if ((sourceHeaders[i].tagName === 'H3') && (!utils.hasClass(utils.closest(sourceHeaders[i], 'source_section'), 'source_section__open')) ) {
					continue;
				}

				var currentDist = Math.abs( utils.offsetTop(sourceHeaders[i]) - 60 - window.pageYOffset ); //60 = Header heights
				if (currentDist < minDistance) {
					closestHeader = i;
					minDistance = currentDist;
				}
			}

			if (closestHeader !== currentHeader) {
				utils.removeClass( document.querySelector('.source_main_nav_li.__active'), '__active');
				utils.removeClass( document.querySelector('.source_main_nav_a.__active'), '__active');

				utils.addClass(navHeaders[closestHeader], '__active');

				var parent = utils.closest(navHeaders[closestHeader], 'source_main_nav_li');
				var hashFromLink = navHeaders[closestHeader].getAttribute('href');

				if (!!parent && parent) {
					utils.addClass(parent, '__active');
				}

				if (_this.conf.updateHash) {
					// TODO: pause hash change when scrolling - append it only on stand-still

					// Modern browsers uses history API for correct back-button-browser functionality
					if (!!(window.history && history.pushState)) {
						window.history.replaceState({anchor: closestHeader+1}, document.title, fileNameInUrl + hashFromLink);
					} else { // ie9 fallback
						 window.location.hash = hashFromLink;
					}
				}

				currentHeader = closestHeader;
			}
		}
function ( ) { var headersLength = sourceHeaders . length ; var minDistance = Number . MAX_VALUE ; var closestHeader = - 1 ; var fileNameInUrl = filename === '' ? '' : filename + '.' + extension ; if ( ( document . body . scrollTop || document . documentElement . scrollTop ) < hashThreshold ) { if ( ! ! window . location . hash ) { currentHeader = - 1 ; if ( ! ! ( window . history && history . pushState ) ) { window . history . replaceState ( { anchor : 0 } , document . title , window . location . pathname ) ; } } return ; } // catch section which is closed for top window border for ( var i = 0 ; i < headersLength ; i ++ ) { if ( ( sourceHeaders [ i ] . tagName === 'H3' ) && ( ! utils . hasClass ( utils . closest ( sourceHeaders [ i ] , 'source_section' ) , 'source_section__open' ) ) ) { continue ; } var currentDist = Math . abs ( utils . offsetTop ( sourceHeaders [ i ] ) - 60 - window . pageYOffset ) ; //60 = Header heights if ( currentDist < minDistance ) { closestHeader = i ; minDistance = currentDist ; } } if ( closestHeader !== currentHeader ) { utils . removeClass ( document . querySelector ( '.source_main_nav_li.__active' ) , '__active' ) ; utils . removeClass ( document . querySelector ( '.source_main_nav_a.__active' ) , '__active' ) ; utils . addClass ( navHeaders [ closestHeader ] , '__active' ) ; var parent = utils . closest ( navHeaders [ closestHeader ] , 'source_main_nav_li' ) ; var hashFromLink = navHeaders [ closestHeader ] . getAttribute ( 'href' ) ; if ( ! ! parent && parent ) { utils . addClass ( parent , '__active' ) ; } if ( _this . conf . updateHash ) { // TODO: pause hash change when scrolling - append it only on stand-still // Modern browsers uses history API for correct back-button-browser functionality if ( ! ! ( window . history && history . pushState ) ) { window . history . replaceState ( { anchor : closestHeader + 1 } , document . title , fileNameInUrl + hashFromLink ) ; } else { // ie9 fallback window . location . hash = hashFromLink ; } } currentHeader = closestHeader ; } }
watch headers position
watch headers position