<commit_before>// @require ModernizrNetworkXhr2
// @require KwfLoading

var $ = require('jQuery');
var onReady = require('kwf/on-ready');
var responsiveEl = require('kwf/responsive-el');
var fieldRegistry = require('kwf/frontend-form/field-registry');
var errorStyleRegistry = require('kwf/frontend-form/error-style-registry');
var formRegistry = require('kwf/frontend-form/form-registry');

require('kwf/frontend-form/error-style/above');
require('kwf/frontend-form/error-style/below-field');
require('kwf/frontend-form/error-style/bubble');
require('kwf/frontend-form/error-style/icon-bubble');

require('kwf/frontend-form/field/field');
require('kwf/frontend-form/field/cards');
require('kwf/frontend-form/field/checkbox');
require('kwf/frontend-form/field/date-select');
require('kwf/frontend-form/field/field-set');
require('kwf/frontend-form/field/file');
require('kwf/frontend-form/field/multi-checkbox');
require('kwf/frontend-form/field/radio');
require('kwf/frontend-form/field/select');
require('kwf/frontend-form/field/static');
require('kwf/frontend-form/field/text-area');
require('kwf/frontend-form/field/text-field');

responsiveEl('.kwcClass.default', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 500, cls: 'gt500'}, {minWidth: 350, cls: 'gt350'}]);
responsiveEl('.kwcClass.centerDefault', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 500, cls: 'gt500'}, {minWidth: 350, cls: 'gt350'}]);
responsiveEl('.kwcClass.smallBox', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 350, cls: 'gt350'}]);
responsiveEl('.kwcClass.center', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 350, cls: 'gt350'}]);

var FormComponent = function(form)
{
    this.el = form;
    var config = form.parent().find('.config', true);
    if (!config) return;
    config = $.parseJSON(config.val());
    if (!config) return;
    this.config = config;
    this._submitDisabled = 0;

    formRegistry.formsByComponentId[this.config.componentId] = this;


    if (this.el.find('form').get(0).enctype == 'multipart/form-data' && this.config.useAjaxRequest) {
        if (Modernizr.xhr2) {
            this.el.find('form').get(0).enctype = 'application/x-www-form-urlencoded';
        }
        this.config.useAjaxRequest = Modernizr.xhr2;
    }

    this.fields = [];
    var fieldEls = form.find('.kwfField');
    for (var fieldElIndex=0; fieldElIndex<fieldEls.length; fieldElIndex++) {
        var fieldEl = fieldEls[fieldElIndex];
        var classes = fieldEl.className.split(' ');
        var fieldConstructor = false;
        $.each(classes, function (indx, c) {
            if (fieldRegistry.fields[c]) {
                fieldConstructor = fieldRegistry.fields[c];
            }
        });
        if (fieldConstructor) {
            var field = new fieldConstructor($(fieldEl), this);
            this.fields.push(field);
        }
    }

    this.errorStyle = new Kwf.FrontendForm.errorStyles[this.config.errorStyle](this);

    $.each(this.fields, function(i, f) {
        f.initField();
    });

    if (this.config.hideForValue) {
        $.each(this.config.hideForValue, (function(indx, hideForValue) {
            var field = this.findField(hideForValue.field);
            field.on('change', function(v, f) {
                if (v == hideForValue.value) {
                    this.findField(hideForValue.hide).hide();
                } else {
                    this.findField(hideForValue.hide).show();
                }
            }, this);

            //initialize on startup
            if (field.getValue() == hideForValue.value) {
                this.findField(hideForValue.hide).hide();<commit_msg>Creating a errorSyle Object error fix<commit_after>// @require ModernizrNetworkXhr2
// @require KwfLoading

var $ = require('jQuery');
var onReady = require('kwf/on-ready');
var responsiveEl = require('kwf/responsive-el');
var fieldRegistry = require('kwf/frontend-form/field-registry');
var errorStyleRegistry = require('kwf/frontend-form/error-style-registry');
var formRegistry = require('kwf/frontend-form/form-registry');

require('kwf/frontend-form/error-style/above');
require('kwf/frontend-form/error-style/below-field');
require('kwf/frontend-form/error-style/bubble');
require('kwf/frontend-form/error-style/icon-bubble');

require('kwf/frontend-form/field/field');
require('kwf/frontend-form/field/cards');
require('kwf/frontend-form/field/checkbox');
require('kwf/frontend-form/field/date-select');
require('kwf/frontend-form/field/field-set');
require('kwf/frontend-form/field/file');
require('kwf/frontend-form/field/multi-checkbox');
require('kwf/frontend-form/field/radio');
require('kwf/frontend-form/field/select');
require('kwf/frontend-form/field/static');
require('kwf/frontend-form/field/text-area');
require('kwf/frontend-form/field/text-field');

responsiveEl('.kwcClass.default', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 500, cls: 'gt500'}, {minWidth: 350, cls: 'gt350'}]);
responsiveEl('.kwcClass.centerDefault', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 500, cls: 'gt500'}, {minWidth: 350, cls: 'gt350'}]);
responsiveEl('.kwcClass.smallBox', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 350, cls: 'gt350'}]);
responsiveEl('.kwcClass.center', [{maxWidth: 500, cls: 'veryNarrow'}, {minWidth: 350, cls: 'gt350'}]);

var FormComponent = function(form)
{
    this.el = form;
    var config = form.parent().find('.config', true);
    if (!config) return;
    config = $.parseJSON(config.val());
    if (!config) return;
    this.config = config;
    this._submitDisabled = 0;

    formRegistry.formsByComponentId[this.config.componentId] = this;


    if (this.el.find('form').get(0).enctype == 'multipart/form-data' && this.config.useAjaxRequest) {
        if (Modernizr.xhr2) {
            this.el.find('form').get(0).enctype = 'application/x-www-form-urlencoded';
        }
        this.config.useAjaxRequest = Modernizr.xhr2;
    }

    this.fields = [];
    var fieldEls = form.find('.kwfField');
    for (var fieldElIndex=0; fieldElIndex<fieldEls.length; fieldElIndex++) {
        var fieldEl = fieldEls[fieldElIndex];
        var classes = fieldEl.className.split(' ');
        var fieldConstructor = false;
        $.each(classes, function (indx, c) {
            if (fieldRegistry.fields[c]) {
                fieldConstructor = fieldRegistry.fields[c];
            }
        });
        if (fieldConstructor) {
            var field = new fieldConstructor($(fieldEl), this);
            this.fields.push(field);
        }
    }

    this.errorStyle = new errorStyleRegistry.errorStyles[this.config.errorStyle](this);

    $.each(this.fields, function(i, f) {
        f.initField();
    });

    if (this.config.hideForValue) {
        $.each(this.config.hideForValue, (function(indx, hideForValue) {
            var field = this.findField(hideForValue.field);
            field.on('change', function(v, f) {
                if (v == hideForValue.value) {
                    this.findField(hideForValue.hide).hide();
                } else {
                    this.findField(hideForValue.hide).show();
                }
            }, this);

            //initialize on startup
            if (field.getValue() == hideForValue.value) {
                this.findField(hideForValue.hide).hide();
{'fraction_non_alphanumeric': 0.17038567493112947, 'fraction_numerical': 0.015151515151515152, 'mean_word_length': 3.3453022142429685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '938938', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2318, 'n_words': 366}