<commit_before>'use strict';

/**
 * @module ov.player
 */

(function(app) {

  /**
   * Manages oplSlider component.
   *
   * @param {Object} $scope The component isolated scope
   * @param {Object} $element The HTML element holding the component
   * @param {Object} $window The AngularJS $window service
   * @class OplSliderController
   * @constructor
   */
  function OplSliderController($scope, $element, $window) {
    var ctrl = this;
    var ngModelCtrl = $element.controller('ngModel');
    var step = 0;
    var sliderElementBoundingRectangle;
    var sliderElement;
    var thumbElement;
    var trackElement;
    var bodyElement;
    var preventFocus;
    var inTransition;

    /**
     * Updates model with actual value.
     */
    function updateModel() {
      ngModelCtrl.$setViewValue(ctrl.value);
      ngModelCtrl.$validate();
    }

    /**
     * Updates the user interface with current value.
     *
     * Thumb and track are updated to reflect the slider value.
     */
    function updateUI() {
      var percentage = ctrl.value / 100;

      if (inTransition) {
        var onTransitionEnd = function onTransitionEnd() {
          sliderElement.removeClass('opl-slider-in-transition');
          thumbElement.off('transitionend');
        };
        thumbElement.on('transitionend', onTransitionEnd);
      }

      requestAnimationFrame(function() {
        trackElement.attr('style', 'transform: scaleX(' + percentage + ')');
        thumbElement.attr(
          'style',
          'transform: translateX(' + percentage * sliderElementBoundingRectangle.width + 'px) translateX(-50%)'
        );
      });
    }

    /**
     * Sets slider value.
     *
     * It also updates the model and the user interface.
     *
     * @param {Number} value The value to apply to the slider between 0 and 100
     */
    function setValue(value) {
      if (value === ctrl.value) return;

      // If a step is defined, adjust value to be in a step
      if (step) value = Math.round(value / step) * step;

      ctrl.value = value;
      ctrl.valueTextParameters = {
        '%value%': ctrl.value
      };
      updateModel();
      updateUI();
    }

    /**
     * Computes the width of the slider HTML element.
     */
    function computeSliderElementBoundingRectangle() {
      sliderElementBoundingRectangle = sliderElement[0].getBoundingClientRect();
    }

    /**
     * Gets the slider value corresponding to a pressure event.
     *
     * @param {Event} pressureEvent Either a MouseEvent, PointerEvent or TouchEvent
     * @return {Number} The slider value corresponding to the pressure from 0 to 100
     */
    function getSliderPressureValue(pressureEvent) {
      var pressurePageXPosition;
      if (pressureEvent.targetTouches && pressureEvent.targetTouches.length > 0) {

        // This is a TouchEvent with one or several touch targets.
        // Get the x coordinate of the first touch point relative to the left
        // edge of the document
        pressurePageXPosition = pressureEvent.targetTouches[0].pageX;

      }

      // This is a MouseEvent or a PointerEvent
      pressurePageXPosition = pressureEvent.pageX;

      var pressureSliderXPosition = pressurePageXPosition - sliderElementBoundingRectangle.left;
      return Math.max(0, Math.min(100, pressureSliderXPosition / sliderElementBoundingRectangle.width * 100));
    }

    /**
     * Handles keywdown events.
     *<commit_msg>Fix typing error in opl-slider documentation<commit_after>'use strict';

/**
 * @module ov.player
 */

(function(app) {

  /**
   * Manages oplSlider component.
   *
   * @param {Object} $scope The component isolated scope
   * @param {Object} $element The HTML element holding the component
   * @param {Object} $window The AngularJS $window service
   * @class OplSliderController
   * @constructor
   */
  function OplSliderController($scope, $element, $window) {
    var ctrl = this;
    var ngModelCtrl = $element.controller('ngModel');
    var step = 0;
    var sliderElementBoundingRectangle;
    var sliderElement;
    var thumbElement;
    var trackElement;
    var bodyElement;
    var preventFocus;
    var inTransition;

    /**
     * Updates model with actual value.
     */
    function updateModel() {
      ngModelCtrl.$setViewValue(ctrl.value);
      ngModelCtrl.$validate();
    }

    /**
     * Updates the user interface with current value.
     *
     * Thumb and track are updated to reflect the slider value.
     */
    function updateUI() {
      var percentage = ctrl.value / 100;

      if (inTransition) {
        var onTransitionEnd = function onTransitionEnd() {
          sliderElement.removeClass('opl-slider-in-transition');
          thumbElement.off('transitionend');
        };
        thumbElement.on('transitionend', onTransitionEnd);
      }

      requestAnimationFrame(function() {
        trackElement.attr('style', 'transform: scaleX(' + percentage + ')');
        thumbElement.attr(
          'style',
          'transform: translateX(' + percentage * sliderElementBoundingRectangle.width + 'px) translateX(-50%)'
        );
      });
    }

    /**
     * Sets slider value.
     *
     * It also updates the model and the user interface.
     *
     * @param {Number} value The value to apply to the slider between 0 and 100
     */
    function setValue(value) {
      if (value === ctrl.value) return;

      // If a step is defined, adjust value to be in a step
      if (step) value = Math.round(value / step) * step;

      ctrl.value = value;
      ctrl.valueTextParameters = {
        '%value%': ctrl.value
      };
      updateModel();
      updateUI();
    }

    /**
     * Computes the width of the slider HTML element.
     */
    function computeSliderElementBoundingRectangle() {
      sliderElementBoundingRectangle = sliderElement[0].getBoundingClientRect();
    }

    /**
     * Gets the slider value corresponding to a pressure event.
     *
     * @param {Event} pressureEvent Either a MouseEvent, PointerEvent or TouchEvent
     * @return {Number} The slider value corresponding to the pressure from 0 to 100
     */
    function getSliderPressureValue(pressureEvent) {
      var pressurePageXPosition;
      if (pressureEvent.targetTouches && pressureEvent.targetTouches.length > 0) {

        // This is a TouchEvent with one or several touch targets.
        // Get the x coordinate of the first touch point relative to the left
        // edge of the document
        pressurePageXPosition = pressureEvent.targetTouches[0].pageX;

      }

      // This is a MouseEvent or a PointerEvent
      pressurePageXPosition = pressureEvent.pageX;

      var pressureSliderXPosition = pressurePageXPosition - sliderElementBoundingRectangle.left;
      return Math.max(0, Math.min(100, pressureSliderXPosition / sliderElementBoundingRectangle.width * 100));
    }

    /**
     * Handles keydown events.
     *
{'fraction_non_alphanumeric': 0.09788895315211105, 'fraction_numerical': 0.006940427993059572, 'mean_word_length': 2.585795749092794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7052796', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1863, 'n_words': 555}