<commit_before>'use strict';

var TextlineView = require('./Textline');
var CheckboxView = require('./Checkbox');
var RadioButtonView = require('./RadioButton');

module.exports = function (element) {

  this.el = element;
  this.init();

};

module.exports.prototype = {

  init: function () {

    console.log('Init Form');

    this.setVariables();
    this.addEventListeners();

    this.initFormElements();

  },

  setVariables: function () {

    this.validated = true;
    this.submit = this.el.querySelector('.js-form-submit');
    this.elements = this.el.querySelectorAll('.js-form-component');

  },

  addEventListeners: function () {

    if (this.submit) {
      this.submit.addEventListener('click', function () {

        this.validateForm();

      }.bind(this));
    }

  },

  initFormElements: function () {

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

      if (this.elements[i].classList.contains('js-form-component-textline')) {
        new TextlineView(this.elements[i]);
      } else if (this.elements[i].classList.contains('js-form-component-checkbox')) {
        new CheckboxView(this.elements[i]);
      } else if (this.elements[i].classList.contains('js-form-component-radio-button')) {
        new RadioButtonView(this.elements[i]);
      }

    }

  },

  validateForm: function () {

    this.validated = true;
    this.validateElements();

    if (this.validated) {
      this.el.submit();
    }

  },

  validateElements: function () {

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

      var type = this.elements[i].querySelector('input').type;
<commit_msg>Added validated event<commit_after>'use strict';

var TextlineView = require('./Textline');
var CheckboxView = require('./Checkbox');
var RadioButtonView = require('./RadioButton');

module.exports = function (element) {

  this.el = element;
  this.init();

};

module.exports.prototype = {

  init: function () {

    console.log('Init Form');

    this.setVariables();
    this.addEventListeners();

    this.initFormElements();

  },

  setVariables: function () {

    this.validated = true;
    this.submit = this.el.querySelector('.js-form-submit');
    this.elements = this.el.querySelectorAll('.js-form-component');

  },

  addEventListeners: function () {

    if (this.submit)
      this.submit.addEventListener('click',this.validateForm.bind(this));

    this.el.addEventListener('validate', this.validateForm.bind(this));

  },

  initFormElements: function () {

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

      if (this.elements[i].classList.contains('js-form-component-textline')) {
        new TextlineView(this.elements[i]);
      } else if (this.elements[i].classList.contains('js-form-component-checkbox')) {
        new CheckboxView(this.elements[i]);
      } else if (this.elements[i].classList.contains('js-form-component-radio-button')) {
        new RadioButtonView(this.elements[i]);
      }

    }

  },

  validateForm: function () {

    this.validated = true;
    this.validateElements();

    if (this.validated)
      this.el.submit();


  },

  validateElements: function () {

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

      var type = this.elements[i].querySelector('input').type;

{'fraction_non_alphanumeric': 0.16584615384615384, 'fraction_numerical': 0.0012307692307692308, 'mean_word_length': 3.1466836734693877, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5562517', 'n_tokens_mistral': 1022, 'n_tokens_neox': 979, 'n_words': 169}