<commit_before>// require esphinx/support/array
// require esphinx/support/singleton

// require esphinx_ui
// require esphinx/support/ajax
// require esphinx/observer

"use strict";

var
    esPhinx,
    Singleton;

(function ($module) {

    var
        minimized = [],
        visible;

    $module.extend({

        windows: {

            modal: {

                hide: function (animation) {
                    visible.hide(animation);
                },

                close: function () {
                    visible.close();
                },

                // functions are objects in js
                new: function (options) {
                    var
                        self = $module.windows.modal.new,
                        mainReference = this,
                        args = Array.from(arguments),

                        $ = esPhinx,
                        body = $("body"),
                        imagesLoaded = [],

                        modal,
                        mask,
                        main,
                        container,
                        closeButton,
                        hideButton,
                        headers,
                        params,
                        asynchronousAnswer,
                        imgControl,
                        singleton,
                        index,
                        _windowController,

                        isMinimized = function () {
                            var
                                index;

                            if (index = minimized
                                .indexPerEquivalence(this)) {
                                return index;
                            }

                            return false;
                        },

                        addToMinimized = function () {
                            if (!isMinimized.call(this)) {
                                minimized.push(this);
                            }
                        },

                        removeFromMinimized = function () {
                            var
                                index;

                            if (index = isMinimized.call(this)) {
                                minimized.delete(index);
                            }
                        },

                        show = function (mainReference) {
                            modal.css("z-index", 0);
                            restartTransition(mask);
                            if (options.fadeIn) {
                                mask.css("transition", "opacity "
                                + options.fadeIn);
                            }
                            mask.removeClass("transparent");
                            main.show();

                            visible = mainReference;
                            // debugger

                            removeFromMinimized.call(this);
                        },

                        maskTransitionDuration = function (mask) {
                            return parseFloat(mask
                                .css("transition-duration")) * 1000;
                        },

                        restartTransition = function (mask) {
                            mask.css("transition", "opacity 0s");
                        },

                        resolveParams = function () {
                            options = options || {};

                            if (typeof options.windowController != "boolean") {
                                _windowController = false;
                            } else {
                                _windowController = options.windowController;
                            }

                            if (typeof options.closeButton != "boolean") {
                                options.closeButton = true;
                            }

                            if (options.content) {
                                options.url = false;
                            }
                        },

                        resolveHeaderActions = function (main, options) {
                            var
                                container = main.find(".container"),
                                childNodesCount = container.childNodes()
                                    .count(),
                                imgsCount = container.find("img").count(),
                                header,
                                actions;

                            if (childNodesCount == 1
                                && imgsCount == 1
                                && !_windowController) {
                                _windowController = false;
                            } else {
                                _windowController = true;
                            }

                            if (_windowController) {
                                header = $("<header></header>");
                                actions = $("<div></div>").addClass("actions");
                                hideButton = $('<a href="#"></a>')
                                    .addClass("hide-button");

                                header.append(actions);

                                if (options.closeButton) {
                                    closeButton = $('<a href="#"></a>')
                                        .addClass("close-button");
                                    actions.append(closeButton);
                                }

                                actions.append(hideButton);

                                main
                                    .prepend(header)
                                    .css({
                                        "max-height": $(document).height(),
                                        "max-width": $(document).width()
                                    });

                                bindHeaderEventListeners();
                            }
                        },

                        bindHeaderEventListeners = function () {
                            // $(document).off("keydown").on("keydown", function (e) {
                            //     if (e.keyCode == 27) {
                            //         self.hide();
                            //     }
                            // });

                            if (closeButton) {
                                closeButton.on("click", function () {
                                    mainReference.close();<commit_msg>refactor modal<commit_after>// require esphinx/support/array
// require esphinx/support/singleton

// require esphinx_ui
// require esphinx/support/ajax
// require esphinx/observer

"use strict";

var
    esPhinx,
    Singleton;

(function ($module) {

    var
        minimized = [],
        visible;

    $module.extend({

        windows: {

            modal: {

                hide: function (animation) {
                    visible.hide(animation);
                },

                close: function () {
                    visible.close();
                },

                // functions are objects in js
                new: function (options) {
                    var
                        self = $module.windows.modal.new,
                        mainReference = this,
                        args = Array.from(arguments),

                        $ = esPhinx,
                        body = $("body"),
                        imagesLoaded = [],

                        modal,
                        mask,
                        main,
                        container,
                        closeButton,
                        hideButton,
                        headers,
                        params,
                        asynchronousAnswer,
                        imgControl,
                        singleton,
                        index,
                        _windowController,

                        isMinimized = function () {
                            var
                                index;

                            if (index = minimized
                                .indexPerEquivalence(this)) {
                                return index;
                            }

                            return false;
                        },

                        addToMinimized = function () {
                            if (!isMinimized.call(this)) {
                                minimized.push(this);
                            }
                        },

                        removeFromMinimized = function () {
                            var
                                index;

                            if (index = isMinimized.call(this)) {
                                minimized.delete(index);
                            }
                        },

                        show = function (mainReference) {
                            modal.css("z-index", 0);
                            restartTransition(mask);
                            if (options.fadeIn) {
                                mask.css("transition", "opacity "
                                + options.fadeIn);
                            }
                            mask.removeClass("transparent");
                            main.show();

                            visible = mainReference;
                            // debugger

                            removeFromMinimized.call(this);
                        },

                        maskTransitionDuration = function (mask) {
                            return parseFloat(mask
                                .css("transition-duration")) * 1000;
                        },

                        restartTransition = function (mask) {
                            mask.css("transition", "opacity 0s");
                        },

                        resolveParams = function () {
                            options = options || {};

                            if (typeof options.windowController != "boolean") {
                                _windowController = false;
                            } else {
                                _windowController = options.windowController;
                            }

                            if (typeof options.closeButton != "boolean") {
                                options.closeButton = true;
                            }

                            if (options.content) {
                                options.url = false;
                            }
                        },

                        resolveHeaderActions = function (main, options) {
                            var
                                container = main.find(".container"),
                                childNodesCount = container.childNodes()
                                    .count(),
                                imgsCount = container.find("img").count(),
                                header,
                                actions;

                            if (childNodesCount > 1
                                || (childNodesCount == 1 && !imgsCount)
                                || _windowController) {
                                header = $("<header></header>");
                                actions = $("<div></div>").addClass("actions");
                                hideButton = $('<a href="#"></a>')
                                    .addClass("hide-button");

                                header.append(actions);

                                if (options.closeButton) {
                                    closeButton = $('<a href="#"></a>')
                                        .addClass("close-button");
                                    actions.append(closeButton);
                                }

                                actions.append(hideButton);

                                main
                                    .prepend(header)
                                    .css({
                                        "max-height": $(document).height(),
                                        "max-width": $(document).width()
                                    });

                                bindHeaderEventListeners();
                            }

                        },

                        bindHeaderEventListeners = function () {
                            // $(document).off("keydown").on("keydown", function (e) {
                            //     if (e.keyCode == 27) {
                            //         self.hide();
                            //     }
                            // });

                            if (closeButton) {
                                closeButton.on("click", function () {
                                    mainReference.close();
{'fraction_non_alphanumeric': 0.0819405756731662, 'fraction_numerical': 0.0015475085112968121, 'mean_word_length': 0.6081871345029239, 'pattern_counts': {'":': 4, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5005982', 'n_tokens_mistral': 2528, 'n_tokens_neox': 2275, 'n_words': 408}