<commit_before>/*
	overthrow responsive sidescroller extension
	(c) 2013: <NAME>, Filament Group, Inc.
	MIT License
*/

(function( w, o ){


	if( !o || !"querySelector" in w.document ){
		return;
	}

	function sendEvent( elem, evt, args, ieID ){
		// TODO needs IE8 support
		if( document.createEvent ){
			var event = document.createEvent( "Event" );
			event.initEvent( evt, true, true );
			event.overthrow = args;
			elem.dispatchEvent( event );
		}
		else {
			w.document.documentElement[ieID][ evt ] = {
				e: evt,
				args: args
			};
			w.document.documentElement[ evt ]++;
		}
	}

	o.sidescroller = function( elems, options ){

		var scrolls = elems,
			evtPrefix = "overthrow",
			evtNext = evtPrefix + "-next",
			evtPrev = evtPrefix + "-prev",
			slideNum = 0,
			ieID = "overthrow" + (new Date().getTime()),
			snapScroll = options && options.snapScroll,
			rewind = options && options.rewind;

		for( var i = 0; i < scrolls.length; i++ ){

			var thisSideScroll = scrolls[ i ],
				thisScroll = scrolls[ i ].querySelector( ".overthrow" ),
				nextPrev = w.document.createElement( "div" ),
				handled;

			thisSideScroll.setAttribute( "tabindex", "0" );

			// oldIE will need some expando event props
			if( w.document.attachEvent ){
				// these are iterators to trigger a property mutate event in IE8
				w.document.documentElement[ evtPrev ] = 0;
				w.document.documentElement[ evtNext ] = 0;
				// these for for the event data when that property iterates
				w.document.documentElement[ ieID ] = {};
				w.document.documentElement[ ieID ][ evtPrev ] = {};
				w.document.documentElement[ ieID ][ evtNext ] = {};
				thisSideScroll.ieID = ieID;
			}

			nextPrev.className = "sidescroll-nextprev-links";

			nextPrev.innerHTML = "<a href='#' class='sidescroll-prev'>Previous</a><a href='#' class='sidescroll-next'>Next</a>";

			function getActiveSlides( left ){
				var slides = thisScroll.querySelectorAll( "li" ),
					numSlides = slides.length,
					slidesWidth = thisScroll.offsetWidth,
					slideWidth = slides[ 0 ].offsetWidth,
					scrollLeft = left !== undefined ? left : thisScroll.scrollLeft,
					startSlide = Math.round( scrollLeft / slideWidth ),
					valid = true,
					ret = [];

				startSlide = Math.max( 0, startSlide );
				startSlide = Math.min( numSlides, startSlide );

				ret[ 0 ] = startSlide;
				for( var i = 1; i < numSlides; i++ ){
					if( startSlide + (i * slideWidth) < slidesWidth){
						ret.push( startSlide + i);
					}
					else{
						valid = false;
					}
				}
				slideNum = startSlide;
				return ret;
			}

			// expose the getactiveslides function on the overthrow element
			thisSideScroll.getActiveSlides = getActiveSlides;

			function handleClick( evt ){

				var e = evt || w.event;

				if( e.type === "keydown" || !handled ){
					handled = true;
					o.intercept();
					var slides = thisScroll.querySelectorAll( "li" ),
						target = e.target || e.srcElement,
						slidesWidth = thisScroll.offsetWidth,
						slideWidth = slides[ 0 ].offsetWidth,
						currScroll = thisScroll.scrollLeft,
						slideNum = Math.round( currScroll / slideWidth ),
						next = (e.type !== "keydown" && target.className.indexOf( "next" ) > -1) || e.keyCode === 39,
						newSlide = slideNum + ( next ? 1 : -1 ),
						newScroll = slideWidth * newSlide,
						scrollWidth = thisScroll.scrollWidth - slidesWidth;

					// if can't go left, go to end
					if( rewind ){
						
						if( newScroll < 0 ){
							newScroll = scrollWidth;
						}
						else if( newScroll > scrollWidth ){
							newScroll = 0;
						}
					}
					else {
						if( newScroll < 0 ){
							newScroll = 0;
						}
						else if( newScroll > scrollWidth ){
							newScroll = scrollWidth;
						}
					}

					var newActive = getActiveSlides( newScroll );

					if( newActive[ 0 ] !== slideNum ){

						o.toss( thisScroll, { left: newScroll } );

						sendEvent(
							thisSideScroll, // elem to receive event
							next ? evtNext : evtPrev, // evt name
							{
								active: newActive, // active slides
								originalEvent: e
							},
							ieID
						);
					}

					setTimeout( function(){ handled = false; }, 100 );
				}
				return false;
			}

			function handleSnap( e ){
				o.intercept();
				var slideWidth = thisScroll.querySelector( "li" ).offsetWidth,
					currScroll = thisScroll.scrollLeft,
					newSlide = Math.round( currScroll / slideWidth ),
					newScroll = slideWidth * newSlide;

				o.toss( thisScroll, { left: newScroll, duration: 20 } );

				if( slideNum !== newSlide ){
					sendEvent(
						thisSideScroll, // elem to receive event
						newSlide > slideNum ? evtNext : evtPrev, // evt name
						{
							active: getActiveSlides( newScroll ), // active slides
							originalEvent: e
						},
						ieID
					);
					slideNum = newSlide;
				}
			}

			var debounce;
			function handleResize( e ){
				clearTimeout(debounce);
				debounce = setTimeout(function(){
					handleSnap( e );<commit_msg>restored default prevention in the tap/click/arrow key handler. This fixes two issues: 1) touch browsers were advancing 2 slides on tap, and 2) the sidescroller was scrolling the page to top after a click on the arrows.<commit_after>/*
	overthrow responsive sidescroller extension
	(c) 2013: <NAME>, Filament Group, Inc.
	MIT License
*/

(function( w, o ){


	if( !o || !"querySelector" in w.document ){
		return;
	}

	function sendEvent( elem, evt, args, ieID ){
		// TODO needs IE8 support
		if( document.createEvent ){
			var event = document.createEvent( "Event" );
			event.initEvent( evt, true, true );
			event.overthrow = args;
			elem.dispatchEvent( event );
		}
		else {
			w.document.documentElement[ieID][ evt ] = {
				e: evt,
				args: args
			};
			w.document.documentElement[ evt ]++;
		}
	}

	o.sidescroller = function( elems, options ){

		var scrolls = elems,
			evtPrefix = "overthrow",
			evtNext = evtPrefix + "-next",
			evtPrev = evtPrefix + "-prev",
			slideNum = 0,
			ieID = "overthrow" + (new Date().getTime()),
			snapScroll = options && options.snapScroll,
			rewind = options && options.rewind;

		for( var i = 0; i < scrolls.length; i++ ){

			var thisSideScroll = scrolls[ i ],
				thisScroll = scrolls[ i ].querySelector( ".overthrow" ),
				nextPrev = w.document.createElement( "div" ),
				handled;

			thisSideScroll.setAttribute( "tabindex", "0" );

			// oldIE will need some expando event props
			if( w.document.attachEvent ){
				// these are iterators to trigger a property mutate event in IE8
				w.document.documentElement[ evtPrev ] = 0;
				w.document.documentElement[ evtNext ] = 0;
				// these for for the event data when that property iterates
				w.document.documentElement[ ieID ] = {};
				w.document.documentElement[ ieID ][ evtPrev ] = {};
				w.document.documentElement[ ieID ][ evtNext ] = {};
				thisSideScroll.ieID = ieID;
			}

			nextPrev.className = "sidescroll-nextprev-links";

			nextPrev.innerHTML = "<a href='#' class='sidescroll-prev'>Previous</a><a href='#' class='sidescroll-next'>Next</a>";

			function getActiveSlides( left ){
				var slides = thisScroll.querySelectorAll( "li" ),
					numSlides = slides.length,
					slidesWidth = thisScroll.offsetWidth,
					slideWidth = slides[ 0 ].offsetWidth,
					scrollLeft = left !== undefined ? left : thisScroll.scrollLeft,
					startSlide = Math.round( scrollLeft / slideWidth ),
					valid = true,
					ret = [];

				startSlide = Math.max( 0, startSlide );
				startSlide = Math.min( numSlides, startSlide );

				ret[ 0 ] = startSlide;
				for( var i = 1; i < numSlides; i++ ){
					if( startSlide + (i * slideWidth) < slidesWidth){
						ret.push( startSlide + i);
					}
					else{
						valid = false;
					}
				}
				slideNum = startSlide;
				return ret;
			}

			// expose the getactiveslides function on the overthrow element
			thisSideScroll.getActiveSlides = getActiveSlides;

			function handleClick( evt ){

				var e = evt || w.event;

				if( e.preventDefault ){
					e.preventDefault();
				}
				else{
					e.returnValue = false;
				}

				if( e.type === "keydown" || !handled ){
					handled = true;
					o.intercept();
					var slides = thisScroll.querySelectorAll( "li" ),
						target = e.target || e.srcElement,
						slidesWidth = thisScroll.offsetWidth,
						slideWidth = slides[ 0 ].offsetWidth,
						currScroll = thisScroll.scrollLeft,
						slideNum = Math.round( currScroll / slideWidth ),
						next = (e.type !== "keydown" && target.className.indexOf( "next" ) > -1) || e.keyCode === 39,
						newSlide = slideNum + ( next ? 1 : -1 ),
						newScroll = slideWidth * newSlide,
						scrollWidth = thisScroll.scrollWidth - slidesWidth;

					// if can't go left, go to end
					if( rewind ){
						
						if( newScroll < 0 ){
							newScroll = scrollWidth;
						}
						else if( newScroll > scrollWidth ){
							newScroll = 0;
						}
					}
					else {
						if( newScroll < 0 ){
							newScroll = 0;
						}
						else if( newScroll > scrollWidth ){
							newScroll = scrollWidth;
						}
					}

					var newActive = getActiveSlides( newScroll );

					if( newActive[ 0 ] !== slideNum ){

						o.toss( thisScroll, { left: newScroll } );

						sendEvent(
							thisSideScroll, // elem to receive event
							next ? evtNext : evtPrev, // evt name
							{
								active: newActive, // active slides
								originalEvent: e
							},
							ieID
						);
					}

					setTimeout( function(){ handled = false; }, 100 );
				}
			}

			function handleSnap( e ){
				o.intercept();
				var slideWidth = thisScroll.querySelector( "li" ).offsetWidth,
					currScroll = thisScroll.scrollLeft,
					newSlide = Math.round( currScroll / slideWidth ),
					newScroll = slideWidth * newSlide;

				o.toss( thisScroll, { left: newScroll, duration: 20 } );

				if( slideNum !== newSlide ){
					sendEvent(
						thisSideScroll, // elem to receive event
						newSlide > slideNum ? evtNext : evtPrev, // evt name
						{
							active: getActiveSlides( newScroll ), // active slides
							originalEvent: e
						},
						ieID
					);
					slideNum = newSlide;
				}
			}

			var debounce;
			function handleResize( e ){
				clearTimeout(debounce);
				debounce = setTimeout(function(){
					handleSnap( e );
{'fraction_non_alphanumeric': 0.12661321861556513, 'fraction_numerical': 0.006355103637074697, 'mean_word_length': 2.521170395869191, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '957153', 'n_tokens_mistral': 4325, 'n_tokens_neox': 3230, 'n_words': 858}