<commit_before>/**
 * Developer: <NAME>
 * Date: 7/6/2015
 * Copyright: 2009-2016 Comindware®
 *       All Rights Reserved
 * Published under the MIT license
 */

'use strict';

import { $ } from 'lib';
import PopupStackView from './window/views/PopupStackView';

const windowService = /** @lends module:core.services.WindowService */ {
    initialize() {
        this.__$popupStackRegionEl = $(document.createElement('div'));
        this.__$popupStackRegionEl.appendTo(document.body);

        const regionManager = new Marionette.RegionManager();
        regionManager.addRegion('popupStackRegion', { el: this.__$popupStackRegionEl });

        const popupStackRegion = regionManager.get('popupStackRegion');
        this.__popupStackView = new PopupStackView();
        popupStackRegion.show(this.__popupStackView);

        this.__popupStackView.on('popup:close', ...args => this.trigger('popup:close', ...args));
    },

    /**
     * Shows a marionette.view as a popup. If another popup is already shown, overlaps it.
     * The size of the view and it's location is totally the view's responsibility.
     * @param {Marionette.View} view A Marionette.View instance to show.
     * @returns {String} The popup id that you can use to close it.
     * */
    showPopup(view) {
        return this.__popupStackView.showPopup(view, {
            fadeBackground: true,
            transient: false,
            hostEl: null
        });
    },

    /**
     * Closes the top-level popup or does nothing if there is none.
     * @param {string} [popupId=null]
     * */
    closePopup(popupId = null) {
        this.__popupStackView.closePopup(popupId);
    },

    /**
     * Shows a marionette.view as a transient popup. If another popup is already shown, overlaps it.
     * The size of the view and it's location is totally the view's responsibility.
     * @param {Marionette.View} view A Marionette.View instance to show.
     * @param {Object} options Options object.
     * @param {Boolean} [options.fadeBackground=true] Whether to fade the background behind the popup.
     * */
    showTransientPopup(view, options = { fadeBackground: false, hostEl: null }) {
        return this.__popupStackView.showPopup(view, {
            fadeBackground: options.fadeBackground,
            anchorEl: options.anchorEl,
            transient: true,
            hostEl: options.hostEl
        });
    },

    get(popupId) {
        return this.__popupStackView.get(popupId);
    },

    fadeBackground(fade) {
        this.__popupStackView.fadeBackground(fade);
    }
};

_.extend(windowService, Backbone.Events);

export default windowService;
<commit_msg>WindowService: fix popout close event<commit_after>/**
 * Developer: <NAME>
 * Date: 7/6/2015
 * Copyright: 2009-2016 Comindware®
 *       All Rights Reserved
 * Published under the MIT license
 */

import { $ } from 'lib';
import PopupStackView from './window/views/PopupStackView';

const windowService = /** @lends module:core.services.WindowService */ {
    initialize() {
        this.__$popupStackRegionEl = $(document.createElement('div'));
        this.__$popupStackRegionEl.appendTo(document.body);

        const regionManager = new Marionette.RegionManager();
        regionManager.addRegion('popupStackRegion', { el: this.__$popupStackRegionEl });

        const popupStackRegion = regionManager.get('popupStackRegion');
        this.__popupStackView = new PopupStackView();
        popupStackRegion.show(this.__popupStackView);

        this.__popupStackView.on('popup:close', popupId => this.trigger('popup:close', popupId));
    },

    /**
     * Shows a marionette.view as a popup. If another popup is already shown, overlaps it.
     * The size of the view and it's location is totally the view's responsibility.
     * @param {Marionette.View} view A Marionette.View instance to show.
     * @returns {String} The popup id that you can use to close it.
     * */
    showPopup(view) {
        return this.__popupStackView.showPopup(view, {
            fadeBackground: true,
            transient: false,
            hostEl: null
        });
    },

    /**
     * Closes the top-level popup or does nothing if there is none.
     * @param {string} [popupId=null]
     * */
    closePopup(popupId = null) {
        this.__popupStackView.closePopup(popupId);
    },

    /**
     * Shows a marionette.view as a transient popup. If another popup is already shown, overlaps it.
     * The size of the view and it's location is totally the view's responsibility.
     * @param {Marionette.View} view A Marionette.View instance to show.
     * @param {Object} options Options object.
     * @param {Boolean} [options.fadeBackground=true] Whether to fade the background behind the popup.
     * */
    showTransientPopup(view, options = { fadeBackground: false, hostEl: null }) {
        return this.__popupStackView.showPopup(view, {
            fadeBackground: options.fadeBackground,
            anchorEl: options.anchorEl,
            transient: true,
            hostEl: options.hostEl
        });
    },

    get(popupId) {
        return this.__popupStackView.get(popupId);
    },

    fadeBackground(fade) {
        this.__popupStackView.fadeBackground(fade);
    }
};

_.extend(windowService, Backbone.Events);

export default windowService;

{'fraction_non_alphanumeric': 0.10711021751050996, 'fraction_numerical': 0.005117894352038019, 'mean_word_length': 2.5440414507772022, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6486244', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1468, 'n_words': 406}