<commit_before>{% extends 'OroDashboardBundle:Dashboard:widget.html.twig' %}

{% block content %}
    <div class="tab-container">
        <ul class="nav nav-tabs">
            {% for tab in tabs %}
                <li{% if activeTab == tab.name %} class="active"{% endif %}><a
                    href="javascript:void(0);" class="no-hash tab-button"
                    data-name="{{ tab.name }}" data-url="{{ tab.url }}">{{ tab.label }}</a></li>
            {% endfor %}
        </ul>
        <div class="tab-content">
            <div class="content">
                {% block tab_content %}
                    {{ activeTabContent|raw }}
                {% endblock %}
            </div>
            <div class="loading-mask"></div>
        </div>
    </div>
    <script type="text/javascript">
        require(['jquery', 'underscore', 'oroui/js/mediator', 'oroui/js/error', 'oroui/js/loading-mask'],
        function($, _, mediator, error, LoadingMask){
            var loadingMask = null;
            $(document).on('click', '#{{ widgetContentId }} .tab-button', function (e) {
                var $el = $(this);
                var $prevTab = $el.closest('.nav-tabs').find('li.active');
                var $currentTab = $el.closest('li');
                $prevTab.removeClass('active');
                $currentTab.addClass('active');

                var $tabContent = $el.closest('.widget-content').find('.tab-content');
                if (_.isNull(loadingMask)) {
                    loadingMask = new LoadingMask();
                    $tabContent.find('.loading-mask').append(loadingMask.render().$el);
                }

                loadingMask.show();
                $.ajax({
                    url: $el.data('url'),
                    dataType: 'html',
                    error: function(jqXHR) {
                        loadingMask.hide();
                        $currentTab.removeClass('active');
                        $prevTab.addClass('active');
                        error.handle({}, jqXHR, {enforce: true});
                    },
                    success: function(data) {
                        var content = $tabContent.find('.content');
                        loadingMask.hide();
                        content.html(data);
                        mediator.execute('layout:init', content);
                    }
                });
            });
        });
    </script>
    {{ parent() }}
{% endblock %}
<commit_msg>BAP-7242 Migrate to new loading mask - dashboard tabbed widget<commit_after>{% extends 'OroDashboardBundle:Dashboard:widget.html.twig' %}

{% block content %}
    <div class="tab-container">
        <ul class="nav nav-tabs">
            {% for tab in tabs %}
                <li{% if activeTab == tab.name %} class="active"{% endif %}><a
                    href="javascript:void(0);" class="no-hash tab-button"
                    data-name="{{ tab.name }}" data-url="{{ tab.url }}">{{ tab.label }}</a></li>
            {% endfor %}
        </ul>
        <div class="tab-content">
            <div class="content">
                {% block tab_content %}
                    {{ activeTabContent|raw }}
                {% endblock %}
            </div>
        </div>
    </div>
    <script type="text/javascript">
        require(['jquery', 'underscore', 'oroui/js/mediator', 'oroui/js/error', 'oroui/js/app/views/loading-mask-view'],
        function($, _, mediator, error, LoadingMask){
            var loadingMask = null;
            $(document).on('click', '#{{ widgetContentId }} .tab-button', function (e) {
                var $el = $(this);
                var $prevTab = $el.closest('.nav-tabs').find('li.active');
                var $currentTab = $el.closest('li');
                $prevTab.removeClass('active');
                $currentTab.addClass('active');

                var $tabContent = $el.closest('.widget-content').find('.tab-content');
                if (!loadingMask) {
                    loadingMask = new LoadingMask({container: $tabContent});
                }

                loadingMask.show();
                $.ajax({
                    url: $el.data('url'),
                    dataType: 'html',
                    error: function(jqXHR) {
                        loadingMask.hide();
                        $currentTab.removeClass('active');
                        $prevTab.addClass('active');
                        error.handle({}, jqXHR, {enforce: true});
                    },
                    success: function(data) {
                        var content = $tabContent.find('.content');
                        loadingMask.hide();
                        content.html(data);
                        mediator.execute('layout:init', content);
                    }
                });
            });
        });
    </script>
    {{ parent() }}
{% endblock %}

{'fraction_non_alphanumeric': 0.16099261689909763, 'fraction_numerical': 0.0012305168170631665, 'mean_word_length': 1.402463054187192, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '682523', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1227, 'n_words': 228}