<commit_before>"use strict";

define(['jquery',
        'logManager'], function ( _jquery,
                                  logManager) {

    var WidgetBase;

    WidgetBase = function (options) {
        //this.logger --- logger instance for the Widget
        var loggerName = "WidgetBase",
            msg = "";

        if (options && options[WidgetBase.OPTIONS.LOGGER_INSTANCE_NAME]) {
            loggerName = options[WidgetBase.OPTIONS.LOGGER_INSTANCE_NAME];
        }

        this.logger = logManager.create(loggerName);

        //this.$el --- jQuery reference to the DOM container of Widget
        if (options && options[WidgetBase.OPTIONS.CONTAINER_ELEMENT]) {
            this.$el = $(options[WidgetBase.OPTIONS.CONTAINER_ELEMENT]);
            if (this.$el.length === 0) {
                msg = "Widget's container element can not be found";
                this.logger.error(msg);
                throw (msg);
            }
        } else {
            msg = "Widget's container element is not specified in constructor's 'options' parameter";
            this.logger.error(msg);
            throw (msg);
        }

        //by default Widget is in EDIT mode
        this._isReadOnly = false;
    };

    WidgetBase.OPTIONS = { "CONTAINER_ELEMENT" : "containerElement",
        "LOGGER_INSTANCE_NAME": "LOGGER_INSTANCE_NAME" };

    WidgetBase.READ_ONLY_CLASS = 'read-only';


    /************ SET READ-ONLY MODE *************/
    WidgetBase.prototype.setReadOnly = function (isReadOnly) {
        if (this._isReadOnly !== isReadOnly) {
            this._isReadOnly = isReadOnly;
            this.logger.debug("ReadOnly mode changed to '" + isReadOnly + "'");
            this.onReadOnlyChanged(this._isReadOnly);
        }
    };

    WidgetBase.prototype.isReadOnly = function () {
        return this._isReadOnly;
    };

    /* METHOD CALLED WHEN THE WIDGET'S READ-ONLY PROPERTY CHANGES */
    WidgetBase.prototype.onReadOnlyChanged = function (isReadOnly) {
        if (isReadOnly === true) {
            this.$el.addClass(READ_ONLY_CLASS);
        } else {
            this.$el.removeClass(READ_ONLY_CLASS);
        }
    };
    /***** END OF --- SET READ-ONLY MODE *********/

    /************** WIDGET-BASE INTERFACE *******************/
<commit_msg>bugfix in onReadOnlyChanged style change<commit_after>"use strict";

define(['jquery',
        'logManager'], function ( _jquery,
                                  logManager) {

    var WidgetBase;

    WidgetBase = function (options) {
        //this.logger --- logger instance for the Widget
        var loggerName = "WidgetBase",
            msg = "";

        if (options && options[WidgetBase.OPTIONS.LOGGER_INSTANCE_NAME]) {
            loggerName = options[WidgetBase.OPTIONS.LOGGER_INSTANCE_NAME];
        }

        this.logger = logManager.create(loggerName);

        //this.$el --- jQuery reference to the DOM container of Widget
        if (options && options[WidgetBase.OPTIONS.CONTAINER_ELEMENT]) {
            this.$el = $(options[WidgetBase.OPTIONS.CONTAINER_ELEMENT]);
            if (this.$el.length === 0) {
                msg = "Widget's container element can not be found";
                this.logger.error(msg);
                throw (msg);
            }
        } else {
            msg = "Widget's container element is not specified in constructor's 'options' parameter";
            this.logger.error(msg);
            throw (msg);
        }

        //by default Widget is in EDIT mode
        this._isReadOnly = false;
    };

    WidgetBase.OPTIONS = { "CONTAINER_ELEMENT" : "containerElement",
        "LOGGER_INSTANCE_NAME": "LOGGER_INSTANCE_NAME" };

    WidgetBase.READ_ONLY_CLASS = 'read-only';


    /************ SET READ-ONLY MODE *************/
    WidgetBase.prototype.setReadOnly = function (isReadOnly) {
        if (this._isReadOnly !== isReadOnly) {
            this._isReadOnly = isReadOnly;
            this.logger.debug("ReadOnly mode changed to '" + isReadOnly + "'");
            this.onReadOnlyChanged(this._isReadOnly);
        }
    };

    WidgetBase.prototype.isReadOnly = function () {
        return this._isReadOnly;
    };

    /* METHOD CALLED WHEN THE WIDGET'S READ-ONLY PROPERTY CHANGES */
    WidgetBase.prototype.onReadOnlyChanged = function (isReadOnly) {
        if (isReadOnly === true) {
            this.$el.addClass(WidgetBase.READ_ONLY_CLASS);
        } else {
            this.$el.removeClass(WidgetBase.READ_ONLY_CLASS);
        }
    };
    /***** END OF --- SET READ-ONLY MODE *********/

    /************** WIDGET-BASE INTERFACE *******************/

{'fraction_non_alphanumeric': 0.14108964619057957, 'fraction_numerical': 0.0004341219882787063, 'mean_word_length': 2.1496924128503077, 'pattern_counts': {'":': 2, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6980418', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1276, 'n_words': 270}