<commit_before>/**
 * Block-Element-Modifier (BEM) builder.
 *
 * Created by <NAME> from Ubrainians for imCode
 * 24.07.17.
 */
Imcms.define("imcms-bem-builder", ["jquery"], function ($) {
    var MODIFIER_SEPARATOR = "--",
        BLOCK_SEPARATOR = "__"
    ;

    function getOriginClass(attributesObj) {
        return attributesObj["class"] ? " " + attributesObj["class"] : "";
    }

    function getElementClassWithModifiers(elementClass, modifiersArr) {
        return elementClass + getModifiersClass(elementClass, modifiersArr);
    }

    function getModifiersClass(baseClass, modifiersArr) {
        var modifiers = "";

        (modifiersArr || []).forEach(function (modifier) {
            modifiers += " " + baseClass + MODIFIER_SEPARATOR + modifier;
        });

        return modifiers;
    }

    function createBlocKElement(element, elementName) {
        var blockElement = {};
        this.elements[elementName] = element["class"] || "";

        if (element.modifiers) {
            blockElement.modifiers = element.modifiers;
        }

        blockElement[elementName] = (element.length) // means jquery, not simple array
            ? element
            : this.buildElement(elementName, element.tag, element.attributes, element.modifiers);

        return blockElement;
    }

    function createBlockElements(elements, elementName) {
        return elements.map(function (element) {
            return createBlocKElement.call(this, element, elementName);
        }.bind(this));
    }

    var BemBuilder = function (options) {
        this.elements = options.elements;
        this.block = options.block;
    };

    /**
     * Build BEM-styled class with needed separators
     *
     * Usage:
     * <pre><code>
     *     var bemClass = BEM.buildClass("one", "two", "three"); // = "one__two--three"
     * </code></pre>
     *
     * @param block {null|string}
     * @param element {null|string}
     * @param modifier {null|string}
     * @returns {string} BEM-styled class
     */
    BemBuilder.buildClass = function (block, element, modifier) {
        modifier = (modifier) ? MODIFIER_SEPARATOR + modifier : "";
        element = (block && element) ? BLOCK_SEPARATOR + element : (element) ? element : "";
        block = (block || "");
        return block + element + modifier;
    };

    /**
     * Build selector for BEM-styled class
     *
     * Usage:
     * <pre><code>
     *     var bemClassSelector = BEM.buildClassSelector("one", "two", "three"); // = ".one__two--three"
     * </code></pre>
     *
     * @param block {null|string}
     * @param element {null|string}
     * @param modifier {null|string}
     * @returns {string} selector for BEM-styled class
     */
    BemBuilder.buildClassSelector = function (block, element, modifier) {
        return "." + this.buildClass.apply(this, arguments);
    };

    BemBuilder.getBlockSeparator = function () {
        return BLOCK_SEPARATOR;
    };

    BemBuilder.getModifierSeparator = function () {
        return MODIFIER_SEPARATOR;
    };

    BemBuilder.prototype = {<commit_msg>IMCMS-233 - Apply new UI to the admin panel and editors: - Fixed js documentation.<commit_after>/**
 * Block-Element-Modifier (BEM) builder.
 *
 * Created by <NAME> from Ubrainians for imCode
 * 24.07.17.
 */
Imcms.define("imcms-bem-builder", ["jquery"], function ($) {
    var MODIFIER_SEPARATOR = "--",
        BLOCK_SEPARATOR = "__"
    ;

    function getOriginClass(attributesObj) {
        return attributesObj["class"] ? " " + attributesObj["class"] : "";
    }

    function getElementClassWithModifiers(elementClass, modifiersArr) {
        return elementClass + getModifiersClass(elementClass, modifiersArr);
    }

    function getModifiersClass(baseClass, modifiersArr) {
        var modifiers = "";

        (modifiersArr || []).forEach(function (modifier) {
            modifiers += " " + baseClass + MODIFIER_SEPARATOR + modifier;
        });

        return modifiers;
    }

    function createBlocKElement(element, elementName) {
        var blockElement = {};
        this.elements[elementName] = element["class"] || "";

        if (element.modifiers) {
            blockElement.modifiers = element.modifiers;
        }

        blockElement[elementName] = (element.length) // means jquery, not simple array
            ? element
            : this.buildElement(elementName, element.tag, element.attributes, element.modifiers);

        return blockElement;
    }

    function createBlockElements(elements, elementName) {
        return elements.map(function (element) {
            return createBlocKElement.call(this, element, elementName);
        }.bind(this));
    }

    var BemBuilder = function (options) {
        this.elements = options.elements;
        this.block = options.block;
    };

    /**
     * Build BEM-styled class with needed separators
     *
     * Usage:
     * <pre><code>
     *     var bemClass = BEM.buildClass("one", "two", "three"); // = "one__two--three"
     * </code></pre>
     *
     * @param block {null|string}
     * @param element {null|string?}
     * @param modifier {string?}
     * @returns {string} BEM-styled class
     */
    BemBuilder.buildClass = function (block, element, modifier) {
        modifier = (modifier) ? MODIFIER_SEPARATOR + modifier : "";
        element = (block && element) ? BLOCK_SEPARATOR + element : (element) ? element : "";
        block = (block || "");
        return block + element + modifier;
    };

    /**
     * Build selector for BEM-styled class
     *
     * Usage:
     * <pre><code>
     *     var bemClassSelector = BEM.buildClassSelector("one", "two", "three"); // = ".one__two--three"
     * </code></pre>
     *
     * @param block {null|string}
     * @param element {null|string?}
     * @param modifier {string?}
     * @returns {string} selector for BEM-styled class
     */
    BemBuilder.buildClassSelector = function (block, element, modifier) {
        return "." + this.buildClass.apply(this, arguments);
    };

    BemBuilder.getBlockSeparator = function () {
        return BLOCK_SEPARATOR;
    };

    BemBuilder.getModifierSeparator = function () {
        return MODIFIER_SEPARATOR;
    };

    BemBuilder.prototype = {
{'fraction_non_alphanumeric': 0.13268089202631156, 'fraction_numerical': 0.002406545804588481, 'mean_word_length': 2.5320113314447594, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '2556127', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1800, 'n_words': 380}