<commit_before>// ------------------------------ //
//             Slider             //
// ------------------------------ //

var $ = require('jquery');
var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;
var focusable = require('focusable');

function Slider(obj, config) {
    this.slider = obj;
    this.classes = window.PROJECT_NAME.Settings.Classes;

    this.config = $.extend({
        displayedSlides: 4,
        slidesMargin: 20,
        createNavigation: true,
        navigationType: 'both',
        sliderWrapperClass: 'slider-wrapper',
        sliderContainerClass: 'slider-container',
        slideClass: 'slide',
        sliderActiveContentClass: 'slider-activecontent',
        sliderTriggerClass: 'slide-trigger',
        sliderTriggerContentClass: 'slide-trigger-content',
        sliderNavigationClass: 'slider-navigation',
        navigationPrevClass: 'slider-navigation-prev',
        navigationNextClass: 'slider-navigation-next',
        navigationArrowClass: 'slider-navigation-arrows',
        navigationDotClass: 'slider-navigation-dots',
        navigationPrevText: 'Précédent',
        navigationNextText: 'Suivant',
        navigationDotText: 'Afficher la diapositive ',
        navigationDotActiveText: 'Diapositive présentement affichée',
        ariaTextClass: 'aria-text',
        ariaTextActiveClass: 'aria-text-active',
        ariaHiddenBoxClass: 'aria-hidden-box',
        displayDotsNumber: true,
        autoCenterActiveSlide: true,
        swipe: false,
        autoplay: false,
        autoplayDelay: 3000,
        autoplayButtonClass: 'slider-autoplay',
        autoplayButtonText: 'Mettre le carrousel en marche',
        autoplayButtonPauseText: 'Mettre le carrousel en pause',
        changeSlideLoop: true,
        animationSpeed: 300,
        beforeClone: $.noop,
        afterClone: $.noop,
        beforeChangeSlide: $.noop,
        afterChangeSlide: $.noop,
        beforeUpdateLayout: $.noop,
        afterUpdateLayout: $.noop,
        breakpoints: []
    }, config);

    // Get the sliders wrapper
    this.sliderWrapper = this.slider.find('.' + this.config.sliderWrapperClass);

    // Get the sliders container
    this.sliderContainer = this.slider.find('.' + this.config.sliderContainerClass);

    // Get the slides
    this.slides = this.slider.find('.' + this.config.slideClass);

    // Initialize activeSlideIndex
    this.activeSlideIndex = 0;

    // Get displayed slides number
    this.displayedSlides = this.config.displayedSlides;

    // Initialize current breakpoint
    this.currentBreakpoint = undefined;

    // Initialize mouse hover state
    this.mouseHover = false;

    // Initialize animated state
    this.animated = false;

    // Bind events
    this.bindEvents();

    // Navigation initialization
    if (this.config.createNavigation) {
        this.createNavigation(this.config.navigationType);
    }

    // Autoplay initialization
    if (this.config.autoplay) {
        this.autoplay();
    }

    if (this.config.swipe) {
        this.swipe();
    }

    this.init();
}

inherits(Slider, EventEmitter);

$.extend(Slider.prototype, {

    // Component initialization
    init: function() {
        // Layout initialization
        this.initLayout(this.config.displayedSlides);
        this.onResize();

        this.createAriabox();

        // Create active content wrapper
        if (this.isActiveContent()) {
            var content = this.slides.first().find('.' + this.config.sliderTriggerContentClass).clone();
            this.slider.prepend('<div class="' + this.config.sliderActiveContentClass + '"></div>');
            this.updateActiveSlideContent(content);
            // Auto center active slide
            if (this.config.autoCenterActiveSlide === true) {
                this.slider.find('.' + this.config.sliderActiveContentClass).css('text-align', 'center');
            }
        }
    },

    // Layout initialization
    initLayout: function() {
        var slideWidth = 100 / this.slides.length,
            slideWidthCalc = this.config.slidesMargin / this.slides.length * (this.slides.length - 1),
            slidesCSS = 'float: left;' +
            'position: relative;' +
            'width: ' + slideWidth + '%;' +
            'width: calc(' + slideWidth + '% - ' + slideWidthCalc + 'px);';

        // Callback
        this.config.beforeUpdateLayout();

        // Add necessary css for the slider
        this.sliderWrapper.css({
            'position': 'relative',
            'overflow': 'hidden'
        });

        this.sliderContainer.css({
            'position': 'relative',
            'left': '0',
            'width': this.slides.length / this.displayedSlides * 100 + '%'
        });

        this.slides.attr('style', slidesCSS).find('> a').css('display', 'block');

        // Add margin to all slides except the first one
        this.slides.slice(1).css({
            'margin-left': this.config.slidesMargin + 'px'
        });

        // Disable focus on hidden slides
        this.slides.slice(this.displayedSlides).find(':focusable').attr('tabindex', '-1');

        // Callback
        this.config.afterUpdateLayout();
    },

    // Bind events with actions
    bindEvents: function() {
        // Function called each time the window is resized
        $(window).on('resize', $.proxy(function() {
            this.onResize();
        }, this));

        this.slider.hover($.proxy(function() {
            this.mouseHover = true;
        }, this), $.proxy(function() {
            this.mouseHover = false;
        }, this));
<commit_msg>Update slider.js - Remove left and right overflow<commit_after>// ------------------------------ //
//             Slider             //
// ------------------------------ //

var $ = require('jquery');
var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;
var focusable = require('focusable');

function Slider(obj, config) {
    this.slider = obj;
    this.classes = window.PROJECT_NAME.Settings.Classes;

    this.config = $.extend({
        displayedSlides: 4,
        slidesMargin: 20,
        createNavigation: true,
        navigationType: 'both',
        sliderOverflowClass: 'slider-overflow',
        sliderWrapperClass: 'slider-wrapper',
        sliderContainerClass: 'slider-container',
        slideClass: 'slide',
        sliderActiveContentClass: 'slider-activecontent',
        sliderTriggerClass: 'slide-trigger',
        sliderTriggerContentClass: 'slide-trigger-content',
        sliderNavigationClass: 'slider-navigation',
        navigationPrevClass: 'slider-navigation-prev',
        navigationNextClass: 'slider-navigation-next',
        navigationArrowClass: 'slider-navigation-arrows',
        navigationDotClass: 'slider-navigation-dots',
        navigationPrevText: 'Précédent',
        navigationNextText: 'Suivant',
        navigationDotText: 'Afficher la diapositive ',
        navigationDotActiveText: 'Diapositive présentement affichée',
        ariaTextClass: 'aria-text',
        ariaTextActiveClass: 'aria-text-active',
        ariaHiddenBoxClass: 'aria-hidden-box',
        displayDotsNumber: true,
        autoCenterActiveSlide: true,
        swipe: true,
        autoplay: false,
        autoplayDelay: 3000,
        autoplayButtonClass: 'slider-autoplay',
        autoplayButtonText: 'Mettre le carrousel en marche',
        autoplayButtonPauseText: 'Mettre le carrousel en pause',
        changeSlideLoop: true,
        animationSpeed: 300,
        beforeClone: $.noop,
        afterClone: $.noop,
        beforeChangeSlide: $.noop,
        afterChangeSlide: $.noop,
        beforeUpdateLayout: $.noop,
        afterUpdateLayout: $.noop,
        breakpoints: []
    }, config);

    // Get the sliders wrapper
    this.sliderWrapper = this.slider.find('.' + this.config.sliderWrapperClass);

    // Get the sliders container
    this.sliderContainer = this.slider.find('.' + this.config.sliderContainerClass);

    // Get the slides
    this.slides = this.slider.find('.' + this.config.slideClass);

    // Initialize activeSlideIndex
    this.activeSlideIndex = 0;

    // Get displayed slides number
    this.displayedSlides = this.config.displayedSlides;

    // Initialize current breakpoint
    this.currentBreakpoint = undefined;

    // Initialize mouse hover state
    this.mouseHover = false;

    // Initialize animated state
    this.animated = false;

    // Bind events
    this.bindEvents();

    // Navigation initialization
    if (this.config.createNavigation) {
        this.createNavigation(this.config.navigationType);
    }

    // Autoplay initialization
    if (this.config.autoplay) {
        this.autoplay();
    }

    if (this.config.swipe) {
        this.swipe();
    }

    this.init();
}

inherits(Slider, EventEmitter);

$.extend(Slider.prototype, {

    // Component initialization
    init: function() {
        // Layout initialization
        this.initLayout(this.config.displayedSlides);
        this.onResize();

        this.createAriabox();

        // Create active content wrapper
        if (this.isActiveContent()) {
            var content = this.slides.first().find('.' + this.config.sliderTriggerContentClass).clone();
            this.slider.prepend('<div class="' + this.config.sliderActiveContentClass + '"></div>');
            this.updateActiveSlideContent(content);
            // Auto center active slide
            if (this.config.autoCenterActiveSlide === true) {
                this.slider.find('.' + this.config.sliderActiveContentClass).css('text-align', 'center');
            }
        }
    },

    // Layout initialization
    initLayout: function() {
        var slideWidth = 100 / this.slides.length,
            slideWidthCalc = this.config.slidesMargin / this.slides.length * this.slides.length,
            slidesCSS = 'float: left;' +
            'position: relative;' +
            'width: ' + slideWidth + '%;' +
            'width: calc(' + slideWidth + '% - ' + slideWidthCalc + 'px);';

        // Callback
        this.config.beforeUpdateLayout();

        // Add necessary css for the slider
        this.sliderWrapper.css({
            'position': 'relative',
            'overflow': 'hidden',
            'margin-left': this.config.slidesMargin / 2 * -1 + 'px',
            'margin-right': this.config.slidesMargin / 2 * -1 + 'px'
        });

        // Create slider overflow wrapper
        this.sliderWrapper.wrap('<div class="' + this.config.sliderOverflowClass + '"></div>');
        this.slider.find('.' + this.config.sliderOverflowClass).css('overflow', 'hidden');

        this.sliderContainer.css({
            'position': 'relative',
            'left': '0',
            'width': this.slides.length / this.displayedSlides * 100 + '%'
        });

        this.slides.attr('style', slidesCSS).find('> a').css('display', 'block');

        // Add margin to all slides
        this.slides.css({
            'margin-left': this.config.slidesMargin / 2 + 'px',
            'margin-right': this.config.slidesMargin / 2 + 'px'
        });

        // Disable focus on hidden slides
        this.slides.slice(this.displayedSlides).find(':focusable').attr('tabindex', '-1');

        // Callback
        this.config.afterUpdateLayout();
    },

    // Bind events with actions
    bindEvents: function() {
        // Function called each time the window is resized
        $(window).on('resize', $.proxy(function() {
            this.onResize();
        }, this));

        this.slider.hover($.proxy(function() {
            this.mouseHover = true;
        }, this), $.proxy(function() {
            this.mouseHover = false;
        }, this));

{'fraction_non_alphanumeric': 0.13878213340165685, 'fraction_numerical': 0.003928601930139209, 'mean_word_length': 2.253681578216171, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3361832', 'n_tokens_mistral': 3278, 'n_tokens_neox': 3186, 'n_words': 651}