<commit_before>import Events from 'events-mixin';

import {show, toggle, toggleClass} from '../utils';


export default class Slider {
  constructor(element, isTouchEnabled=true) {
    this.element = element;

    this.isTouching = false;
    this.offset = 0;

    this.selectors = {
      next: element.getAttribute('data-next-button'),
      previous: element.getAttribute('data-previous-button'),
      container: element.getAttribute('data-container'),
      items: element.getAttribute('data-items'),
    }

    this.nextButton = element.querySelector(this.selectors.next);
    this.previousButton = element.querySelector(this.selectors.previous);
    this.container = element.querySelector(this.selectors.container);

    this.events = new Events(element, this);
    this.events.bind(`click ${this.selectors.next}`, 'onNextClicked');
    this.events.bind(`click ${this.selectors.previous}`, 'onPreviousClicked');

    if (isTouchEnabled) {
      this.events.bind('touchstart', 'onTouchStart');
      this.events.bind('touchend', 'onTouchEnd');
      this.events.bind('touchmove', 'onTouchMove');
    }

    element.querySelector(this.selectors.items).classList.add('active');
  }

  // event handlers

  onNextClicked(event) {
    event.preventDefault();
    this.toNext();
  }<commit_msg>Only add mark first item active if there isn't another<commit_after>import Events from 'events-mixin';

import {show, toggle, toggleClass} from '../utils';


export default class Slider {
  constructor(element, isTouchEnabled=true) {
    this.element = element;

    this.isTouching = false;
    this.offset = 0;

    this.selectors = {
      next: element.getAttribute('data-next-button'),
      previous: element.getAttribute('data-previous-button'),
      container: element.getAttribute('data-container'),
      items: element.getAttribute('data-items'),
    }

    this.nextButton = element.querySelector(this.selectors.next);
    this.previousButton = element.querySelector(this.selectors.previous);
    this.container = element.querySelector(this.selectors.container);

    this.events = new Events(element, this);
    this.events.bind(`click ${this.selectors.next}`, 'onNextClicked');
    this.events.bind(`click ${this.selectors.previous}`, 'onPreviousClicked');

    if (isTouchEnabled) {
      this.events.bind('touchstart', 'onTouchStart');
      this.events.bind('touchend', 'onTouchEnd');
      this.events.bind('touchmove', 'onTouchMove');
    }

    if (!this.getActiveItem()) {
      element.querySelector(this.selectors.items).classList.add('active');
    }
  }

  // event handlers

  onNextClicked(event) {
    event.preventDefault();
    this.toNext();
  }
{'fraction_non_alphanumeric': 0.1463323353293413, 'fraction_numerical': 0.0007485029940119761, 'mean_word_length': 3.9226519337016574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '800573', 'n_tokens_mistral': 790, 'n_tokens_neox': 787, 'n_words': 133}