<commit_before>module jSlider {
	export class Effect {
		private initFunction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number) => void;
		private gotoFunction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) => void;
		private fraction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) => void;
		private canCycle:boolean;

		/**
		 * Create a new effect.
		 * Effects are built up of function that are ran
		 * on different types of switches
		 * @param init A method that is ran when the document is ready, and this effect was chosen
		 * this is used to set up the slides as whished.
		 * @param gotoFunction A function that is ran when going directly to a slide.
		 * The function receives three parameters
		 *    currentSlide : The slide we are going form
		 *    nextSlide : The slide we are going to
		 *    direction : The direction. -1 prev, +1 next.
		 * @param fraction Gets ran when trying to slide between slides.
		 *    currentSlide : The slide we are going form
		 *    nextSlide : The slide we are going to
		 *    fraction : A number between -1 and 1. How much should we slide.
		 * @param canCycle Whether or not this effect is able to go form the last to the first, or if it
		 *    does not.
		 */
		constructor(init:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number) => void, gotoFunction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) => void, fraction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) => void, canCycle:boolean = true) {
			this.initFunction = init;
			this.gotoFunction = gotoFunction;
			this.fraction = fraction;
			this.canCycle = canCycle;
		}

		public init(slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void {
			this.initFunction(slidesWrapper, slides, currentSlide);
		}

		public gotoSlide(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number):void {
			this.gotoFunction(slidesWrapper, slides, currentSlide, nextSlide, duration);
		}

		public fractionSlide(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number):void {
			this.fraction(slidesWrapper, slides, currentSlide, nextSlide, fraction);
		}

		/**
		 * Whether or not this effect can cycle form the last to the first slide, or the first to the last slide.
		 * @returns {boolean}
		 */
		public getCanCycle():boolean {
			return this.canCycle;
		}


		/*
		 * Effects
		 * */
		public static SLIDE:Effect = new Effect(
			/*INIT*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void {
			},
			/*GOTO SLIDE*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) {
				slidesWrapper.animate({
					right: ((100) * nextSlide) + "%"
				}, duration);
			},
			/*FRACTION SLIDING*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) {
				fraction = Math.abs(fraction);
				slidesWrapper.css({
					right: ((((nextSlide - currentSlide) * fraction) + currentSlide) * 100) + "%"
				})
			},
			/*CYCLES*/
			false
		);

		public static REWIND_SLIDE:Effect = new Effect(
			/*INIT*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void {
			},
			/*GOTO SLIDE*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) {
				slidesWrapper.animate({
					right: ((100) * nextSlide) + "%"
				}, duration);
			},
			/*FRACTION SLIDING*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) {
				fraction = Math.abs(fraction);
				slidesWrapper.css({
					right: ((((nextSlide - currentSlide) * fraction) + currentSlide) * 100) + "%"
				})
			},
			/*CYCLES*/
			true
		);
		
		public static FADE:Effect = new Effect(
			/*INIT*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void {
				slidesWrapper.css({
					"position": "relative"
				});
				slides.css({
					"position": "absolute",
					"top": 0,
					"bottom": 0,
					"right": 0,
					"left": 0
				});
				slides.css({opacity: 0});
				slides.eq(currentSlide).css({opacity: 1});
			},
			/*GOTO SLIDE*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) {
				slides.eq(currentSlide).animate({opacity: 0}, duration);
				slides.eq(nextSlide).animate({opacity: 1}, duration);
			},
			/*FRACTION SLIDING*/
			function (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) {
				slides.eq(nextSlide).css({opacity: Math.abs(fraction)});
				slides.eq(currentSlide).css({opacity: 1 - Math.abs(fraction)});
			},
			/*CYCLES*/
			true
		);
	}
}<commit_msg>Implement an IEffect interface for structur and readability<commit_after>module jSlider {
	export class Effect {
		private initFunction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number) => void;
		private gotoFunction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) => void;
		private fraction:(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) => void;
		private canCycle:boolean;

		/**
		 * Create a new effect.
		 * Effects are built up of function that are ran
		 * on different types of switches
		 */
		constructor(effect : jSlider.IEffect) {
			this.initFunction = effect.init;
			this.gotoFunction = effect.goto;
			this.fraction = effect.fraction;
			this.canCycle = effect.canCycle();
		}

		public init(slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void {
			this.initFunction(slidesWrapper, slides, currentSlide);
		}

		public gotoSlide(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number):void {
			this.gotoFunction(slidesWrapper, slides, currentSlide, nextSlide, duration);
		}

		public fractionSlide(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number):void {
			this.fraction(slidesWrapper, slides, currentSlide, nextSlide, fraction);
		}

		/**
		 * Whether or not this effect can cycle form the last to the first slide, or the first to the last slide.
		 * @returns {boolean}
		 */
		public getCanCycle():boolean {
			return this.canCycle;
		}


		/*
		 * Effects
		 * */
		public static SLIDE:Effect = new Effect({
			init : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void => {
			},
			goto : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) : void => {
				slidesWrapper.animate({
					right: ((100) * nextSlide) + "%"
				}, duration);
			},
			fraction : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) : void => {
				fraction = Math.abs(fraction);
				slidesWrapper.css({
					right: ((((nextSlide - currentSlide) * fraction) + currentSlide) * 100) + "%"
				})
			},
			canCycle : () : boolean => {
				return false;
			}
		});

		public static REWIND_SLIDE:Effect = new Effect({
			init : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number):void => {
			},
			goto : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) : void => {
				slidesWrapper.animate({
					right: ((100) * nextSlide) + "%"
				}, duration);
			},
			fraction : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) : void => {
				fraction = Math.abs(fraction);
				slidesWrapper.css({
					right: ((((nextSlide - currentSlide) * fraction) + currentSlide) * 100) + "%"
				})
			},
			canCycle : () : boolean => {
				return true;
			}
		});
		
		public static FADE:Effect = new Effect({
			init : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number) : void => {
				slidesWrapper.css({
					"position": "relative"
				});
				slides.css({
					"position": "absolute",
					"top": 0,
					"bottom": 0,
					"right": 0,
					"left": 0
				});
				slides.css({opacity: 0});
				slides.eq(currentSlide).css({opacity: 1});
			},
	
			goto : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) : void => {
				slides.eq(currentSlide).animate({opacity: 0}, duration);
				slides.eq(nextSlide).animate({opacity: 1}, duration);
			},
			
			fraction : (slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) : void => {
				slides.eq(nextSlide).css({opacity: Math.abs(fraction)});
				slides.eq(currentSlide).css({opacity: 1 - Math.abs(fraction)});
			},
			canCycle : () : boolean => {
				return true;
			}
		});
	}
	
	export interface IEffect {
		
		/**
		 * A method that is ran when the document is ready, and this effect was chosen
		 * this is used to set up the slides as whished.
		 * */
		init(slidesWrapper:JQuery, slides:JQuery, currentSlide:number) : void;
		
		/**
		 * gotoFunction A function that is ran when going directly to a slide.
		 * The function receives three parameters
		 * @param slidesWrapper The wrapper around the slides
		 * @param slides All the slides
		 * @param currentSlide the current slide in the slides jquery object. slides.eq(currentSlide) will get the current slide
		 * @param nextSlide same as curretn slide, only, its the next slide.
		 * @param duration How long the animation should take
		 * */
		goto(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, duration:number) : void;
		
		/**
		 * fraction Gets ran when trying to slide between slides.
		 * @param slidesWrapper The wrapper around the slides
		 * @param slides All the slides
		 * @param currentSlide the current slide in the slides jquery object. slides.eq(currentSlide) will get the current slide
		 * @param nextSlide same as curretn slide, only, its the next slide.
		 * @param fraction How much slide
		 * */
 		fraction(slidesWrapper:JQuery, slides:JQuery, currentSlide:number, nextSlide:number, fraction:number) : void;
		
		/*
		 * canCycle Whether or not this effect is able to go form the last to the first, or if it
		 * does not.
		 * */
		canCycle() : boolean;
		
	}
}
{'fraction_non_alphanumeric': 0.12479298587433024, 'fraction_numerical': 0.004481246955674622, 'mean_word_length': 3.961817303044949, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 24, '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': '574864', 'n_tokens_mistral': 3785, 'n_tokens_neox': 3147, 'n_words': 833}