<commit_before>/*global define*/
define(['jquery', 'underscore', 'backbone'
    ], function ($, _, Backbone) {
    'use strict';

    /**
     * Loading mask widget
     *
     * @export  oroui/js/loading-mask
     * @class   oroui.LoadingMask
     * @extends Backbone.View
     */
    return Backbone.View.extend({

        /** @property {Boolean} */
        displayed: false,

        /** @property {Boolean} */
        liveUpdate: true,

        /** @property {String} */
        className: 'loading-mask',

        /** @property {String} */
        loadingHint: 'Loading...',

        /** @property */
        template:_.template(
            '<div class="loading-wrapper"></div>' +
            '<div class="loading-frame">' +
                '<div class="box well">' +
                    '<div class="loading-content">' +
                        '<%= loadingHint %>' +
                    '</div>' +
                '</div>' +
            '</div>'
        ),

        /**
         * Initialize
         *
         * @param {Object} options
         * @param {Boolean} [options.liveUpdate] Update position of loading animation on window scroll and resize
         */
        initialize: function (options) {
            var updateProxy,
                opts = options || {};

            if (_.has(opts, 'liveUpdate')) {
                this.liveUpdate = opts.liveUpdate;
            }

            if (this.liveUpdate) {
                updateProxy = $.proxy(this.updatePos, this);
                $(window).resize(updateProxy).scroll(updateProxy);
            }
            Backbone.View.prototype.initialize.apply(this, arguments);
        },

        /**
         * Show loading mask
         *
         * @return {*}
         */
        show: function () {
            this.$el.show();
            this.displayed = true;
            this.resetPos().updatePos();
            return this;
        },

        /**
         * Update position of loading animation
         *
         * @return {*}
         * @protected
         */
        updatePos: function () {
            if (!this.displayed) {
                return this;
            }
            var $containerEl = this.$('.loading-wrapper');
            var $loadingEl = this.$('.loading-frame');

            var loadingHeight = $loadingEl.height();
            var loadingWidth = $loadingEl.width();
            var containerWidth = $containerEl.outerWidth();
            var containerHeight = $containerEl.outerHeight();
            if (loadingHeight > containerHeight) {
                $containerEl.css('height', loadingHeight + 'px');
            }

            var halfLoadingHeight = loadingHeight / 2;
            var loadingTop = containerHeight / 2  - halfLoadingHeight;
            var loadingLeft = (containerWidth - loadingWidth) / 2;

            // Move loading message to visible center of container if container is visible
            var windowHeight = $(window).outerHeight();
            var containerTop = $containerEl.offset().top;
            if (containerTop < windowHeight && (containerTop + loadingTop + loadingHeight) > windowHeight) {
                loadingTop = (windowHeight - containerTop) / 2 - halfLoadingHeight;
            }

            loadingTop = loadingTop < containerHeight - loadingHeight ? loadingTop : containerHeight - loadingHeight;
            loadingLeft = loadingLeft > 0 ? Math.round(loadingLeft) : 0;
            loadingTop = loadingTop > 0 ? Math.round(loadingTop) : 0;
<commit_msg>BAP-3566: Apply design for Tasks Sidebar-widget - CR changes<commit_after>/*global define*/
define(['jquery', 'underscore', 'backbone'
    ], function ($, _, Backbone) {
    'use strict';

    /**
     * Loading mask widget
     *
     * @export  oroui/js/loading-mask
     * @class   oroui.LoadingMask
     * @extends Backbone.View
     */
    return Backbone.View.extend({

        /** @property {Boolean} */
        displayed: false,

        /** @property {Boolean} */
        liveUpdate: true,

        /** @property {String} */
        className: 'loading-mask',

        /** @property {String} */
        loadingHint: 'Loading...',

        /** @property */
        template:_.template(
            '<div class="loading-wrapper"></div>' +
            '<div class="loading-frame">' +
                '<div class="box well">' +
                    '<div class="loading-content">' +
                        '<%= loadingHint %>' +
                    '</div>' +
                '</div>' +
            '</div>'
        ),

        /**
         * Initialize
         *
         * @param {Object} options
         * @param {Boolean} [options.liveUpdate] Update position of loading animation on window scroll and resize
         */
        initialize: function (options) {
            var updateProxy,
                opts = options || {};

            if (_.has(opts, 'liveUpdate')) {
                this.liveUpdate = opts.liveUpdate;
            }

            if (this.liveUpdate) {
                updateProxy = $.proxy(this.updatePos, this);
                $(window).resize(updateProxy).scroll(updateProxy);
            }
            Backbone.View.prototype.initialize.apply(this, arguments);
        },

        /**
         * Show loading mask
         *
         * @return {*}
         */
        show: function () {
            this.$el.show();
            this.displayed = true;
            this.resetPos().updatePos();
            return this;
        },

        /**
         * Update position of loading animation
         *
         * @return {*}
         * @protected
         */
        updatePos: function () {
            if (!this.displayed) {
                return this;
            }
            var $containerEl = this.$('.loading-wrapper');
            var $loadingEl = this.$('.loading-frame');

            var loadingHeight = $loadingEl.height();
            var loadingWidth = $loadingEl.width();
            var containerWidth = $containerEl.outerWidth();
            var containerHeight = $containerEl.outerHeight();
            if (loadingHeight > containerHeight) {
                $containerEl.css('height', loadingHeight + 'px');
            }

            var halfLoadingHeight = loadingHeight / 2;
            var loadingTop = containerHeight / 2  - halfLoadingHeight;
            var loadingLeft = (containerWidth - loadingWidth) / 2;

            // Move loading message to visible center of container if container is visible
            var windowHeight = $(window).outerHeight();
            var containerTop = $containerEl.offset().top;
            if (containerTop < windowHeight && (containerTop + loadingTop + loadingHeight) > windowHeight) {
                loadingTop = (windowHeight - containerTop) / 2 - halfLoadingHeight;
            }

            loadingTop = loadingHeight > 0 ? loadingTop : 0;
            loadingTop = loadingTop < containerHeight - loadingHeight ? loadingTop : containerHeight - loadingHeight;
            loadingLeft = loadingLeft > 0 ? Math.round(loadingLeft) : 0;
            loadingTop = loadingTop > 0 ? Math.round(loadingTop) : 0;

{'fraction_non_alphanumeric': 0.12559774964838255, 'fraction_numerical': 0.0030942334739803095, 'mean_word_length': 1.5867588213895962, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 30, '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': '5215197', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1738, 'n_words': 408}