<commit_before>// @flow
/*
*
* Marionette-based Backbone.Form editor. MUST NOT be used directly. Use EditorBase*View base views instead while implementing Marionette editors.
*
* */

import formRepository from '../../formRepository';
import { keyCode } from 'utils';

const classes = {
    disabled: 'editor_disabled',
    readonly: 'editor_readonly',
    hidden: 'editor_hidden',
    FOCUSED: 'editor_focused',
    EMPTY: 'editor_empty',
    ERROR: 'js-editor_error'
};

const onRender = function() {
    if (this.id) {
        this.el.setAttribute('id', this.id);
    }
    this.setPermissions(this.enabled, this.readonly);
    this.setHidden(this.hidden);
    this.setValue(this.value);
    if (this.focusElement) {
        this.$el.on('focus', this.focusElement, this.onFocus);
        this.$el.on('blur', this.focusElement, this.onBlur);
        this.$el.on('keyup', this.focusElement, this.onKeyup);
    } else if (this.focusElement !== null) {
        this.$el.on('focus', this.onFocus);
        this.$el.on('blur', this.onBlur);
        this.$el.on('keyup', this.onKeyup);
    }
    this.__updateEmpty();

    // revalidate if model isInvalid
    if (this.model && this.model.validationResult) {
        if (this.field) {
            e.validationResult = this.field.validate();
        } else {
            e.validationResult = this.validate();
        }
    }
};

const onChange = function() {
    if (this.model && this.schema.autocommit) {
        this.commit();
    }
    if (this.__validatedOnce) {
        if (this.form) {
            this.form.validate();
        } else if (this.field) {
            this.field.validate();
        }<commit_msg>Fix undefined in editor validate<commit_after>// @flow
/*
*
* Marionette-based Backbone.Form editor. MUST NOT be used directly. Use EditorBase*View base views instead while implementing Marionette editors.
*
* */

import formRepository from '../../formRepository';
import { keyCode } from 'utils';

const classes = {
    disabled: 'editor_disabled',
    readonly: 'editor_readonly',
    hidden: 'editor_hidden',
    FOCUSED: 'editor_focused',
    EMPTY: 'editor_empty',
    ERROR: 'js-editor_error'
};

const onRender = function() {
    if (this.id) {
        this.el.setAttribute('id', this.id);
    }
    this.setPermissions(this.enabled, this.readonly);
    this.setHidden(this.hidden);
    this.setValue(this.value);
    if (this.focusElement) {
        this.$el.on('focus', this.focusElement, this.onFocus);
        this.$el.on('blur', this.focusElement, this.onBlur);
        this.$el.on('keyup', this.focusElement, this.onKeyup);
    } else if (this.focusElement !== null) {
        this.$el.on('focus', this.onFocus);
        this.$el.on('blur', this.onBlur);
        this.$el.on('keyup', this.onKeyup);
    }
    this.__updateEmpty();

    // revalidate if model isInvalid
    if (this.model && this.model.validationResult) {
        if (this.field) {
            this.field.validate();
        } else {
            this.validate();
        }
    }
};

const onChange = function() {
    if (this.model && this.schema.autocommit) {
        this.commit();
    }
    if (this.__validatedOnce) {
        if (this.form) {
            this.form.validate();
        } else if (this.field) {
            this.field.validate();
        }
{'fraction_non_alphanumeric': 0.15286624203821655, 'fraction_numerical': 0.0, 'mean_word_length': 2.542427497314715, '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': '6954587', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1023, 'n_words': 210}