All files / web/bundles/pimui/js pim-async-tab.js

38.89% Statements 7/18
66.67% Branches 8/12
66.67% Functions 2/3
38.89% Lines 7/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 341183x         1183x 17x 17x 17x     17x   17x                                        
define(
    ['jquery', 'oro/loading-mask'],
    function ($, LoadingMask) {
        'use strict';
 
        return function (tab) {
            var $tab = $(tab);
            var target = $tab.attr('href');
            Iif (!target || target === '#' || target.indexOf('javascript') === 0) {
                return;
            }
            var $target = $(target);
 
            Iif (!$target.attr('data-loaded') && !$target.attr('data-loading') && $target.attr('data-url')) {
                $target.attr('data-loading', 1);
                if (!$target.hasClass('active')) {
                    $target.addClass('active');
                }
                var loadingMask = new LoadingMask();
                loadingMask.render().$el.appendTo($target)
                    .css({ 'position': 'absolute', 'width': '100%', 'height': '80%' });
                loadingMask.show();
 
                $.get($target.attr('data-url'), function (data) {
                    $target.html(data).attr('data-loaded', 1).removeAttr('data-loading');
                    loadingMask.hide().$el.remove();
                    $target.closest('form').trigger('tab.loaded', $target);
                });
            }
        };
    }
);