<commit_before>;(function ($) {
    'use strict';

    /**
     * Store and retrieve active tab, for all nav-tabs, using web browser's local storage.
     *
     * @link https://www.tutorialrepublic.com/faq/how-to-keep-the-current-tab-active-on-page-reload-in-bootstrap.php
     */

    var storage = new QoboStorage({
        engine: 'local'
    });

    var prefix = 'activeTab_';
    // store active tab for each navtab
    $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
        var navId = $(e.target).parents('.nav-tabs').attr('id');

        if (! navId) {
            return;
        }

        storage.write(prefix + navId, $(e.target).closest('li').index());
    });

    // load active tab for each navtab
    $('.nav-tabs').each(function (key, value) {
        var navId = $(value).attr('id');

        if (! navId) {
            return;
        }

        if (! storage.read(prefix + navId)) {
            return;
        }

        $('#' + navId + ' li:eq(' + storage.read(prefix + navId) + ') a').tab('show');
    });

    /**
     * Dynamic tab loading for system info
     */
    $('.system-info li').each(function (key,element) {
        if ($(element).hasClass('active')) {
            var link = $(element).find('a');
            getSystemInfo(link);
        }
    });

    $('.system-info a').click(function () {
        getSystemInfo($(this));
    });

    function getSystemInfo(element)
    {
        var destination = $(element).data('tab');

        $.ajax({
            url: '/api/v1.0/system/info',
            method: 'POST',
            dataType: 'html',
            data: { tab: $(element).data('tab') },
            headers: {
                Authorization: 'Bearer ' + api_token
            },
            beforeSend: function (xhr) {
                $('#' + destination).empty();
                $('#spinner-system-info').show();
            }
        }).then(function (response) {
            $('#spinner-system-info').hide();
            $('#' + destination).empty();
            $('#' + destination).append(response);
        });
    }

    $(window).resize(function () {
        responsiveTabs()
    });

    responsiveTabs();

    /**
     * Get any responsive-tabs and check for overflow list-items in order to
     * a new dropdown menu with the ones that are overflowing the list
     */
    function responsiveTabs()
    {
        $('.responsive-tabs').each(function () {
            var parentUl = $(this)
            var ulWidth = parentUl.width() - 45;

            var hideTabs = hideListItems(parentUl, ulWidth)

            //Check if the hideTabs is false
            if (!hideTabs) {
                showHiddenListItems(parentUl, ulWidth)
            }

            // Check if the dropdown-menu has items else delete it
            if (!parentUl.find('.dropdown-menu li').length) {
                parentUl.find('.dropdown').remove();
            }
        })
    }

    /**
     * Hide list items froma a navigation menu that has too many
     *
     * @param {object} parentUl The parent ul
     * @param {float} ulWidth The width
     * @return {boolean}
     */
    function hideListItems(parentUl, ulWidth)
    {
        var hideTabs = false;
        //Get the total width of all list items
        var liTotalWidth = totalLiWidth(parentUl);

        //Get the list items in reverse order
        $(parentUl.find('li:not(.dropdown-li):not(.dropdown)').get().reverse()).each(function () {
            //list item width including the margins size
            var liWidth = $(this).width() + parseInt($(this).css("margin-left")) + parseInt($(this).css("margin-right"));

            //Checks if the list item total width is larger than the ul width
            if (liTotalWidth > ulWidth) {
                hideTabs = true;
                //Checks if the dropdown already exist else create it
                if (!parentUl.find('.dropdown').length) {
                    var dropdownString = '<li class="dropdown pull-right" style="width:45px">' +
                            '<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="true">' +
                                '<i class="fa fa-bars"></i>' +
                            '</a>' +
                            '<ul class="dropdown-menu pull-right"></ul>' +
                        '</li>';
                    parentUl.append(dropdownString)
                }
                //Move the item under the dropdown list
                parentUl.find('.dropdown-menu').prepend($(this).addClass('dropdown-li'));

                liTotalWidth = liTotalWidth - liWidth;
            } else {
                return false;
            }
        });

        return hideTabs;
    }

    /**
     * Show hidden list items
     *
     * @param {object} parentUl The parent ul
     * @param {float} ulWidth The width
     * @param {object} obj The object
     */
    function showHiddenListItems(parentUl, ulWidth)
    {
        //Get the liTotalWidth again
        var liTotalWidth = totalLiWidth(parentUl);

        //Get all the list items from the dropdown
        parentUl.find('.dropdown-menu li').each(function () {
            liTotalWidth = liTotalWidth + realListItemWidth($(this));
            if (liTotalWidth < ulWidth) {
                parentUl.find('.dropdown').before($(this).removeClass('dropdown-li'))<commit_msg>Fixed an issue with navigation links inside dropdowns (Task #10281)<commit_after>;(function ($) {
    'use strict';

    /**
     * Store and retrieve active tab, for all nav-tabs, using web browser's local storage.
     *
     * @link https://www.tutorialrepublic.com/faq/how-to-keep-the-current-tab-active-on-page-reload-in-bootstrap.php
     */

    var storage = new QoboStorage({
        engine: 'local'
    });

    var prefix = 'activeTab_';
    // store active tab for each navtab
    $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
        var navId = $(e.target).parents('.nav-tabs').attr('id');

        if (! navId) {
            return;
        }

        storage.write(prefix + navId, $(e.target).attr('href'));
    });

    // load active tab for each navtab
    $('.nav-tabs').each(function (key, value) {
        var navId = $(value).attr('id');

        if (! navId) {
            return;
        }

        if (! storage.read(prefix + navId)) {
            return;
        }

        $('#' + navId + ' li a[href="' + storage.read(prefix + navId) + '"]').trigger('click');
    });

    /**
     * Dynamic tab loading for system info
     */
    $('.system-info li').each(function (key,element) {
        if ($(element).hasClass('active')) {
            var link = $(element).find('a');
            getSystemInfo(link);
        }
    });

    $('.system-info a').click(function () {
        getSystemInfo($(this));
    });

    function getSystemInfo(element)
    {
        var destination = $(element).data('tab');

        $.ajax({
            url: '/api/v1.0/system/info',
            method: 'POST',
            dataType: 'html',
            data: { tab: $(element).data('tab') },
            headers: {
                Authorization: 'Bearer ' + api_token
            },
            beforeSend: function (xhr) {
                $('#' + destination).empty();
                $('#spinner-system-info').show();
            }
        }).then(function (response) {
            $('#spinner-system-info').hide();
            $('#' + destination).empty();
            $('#' + destination).append(response);
        });
    }

    $(window).resize(function () {
        responsiveTabs()
    });

    responsiveTabs();

    /**
     * Get any responsive-tabs and check for overflow list-items in order to
     * a new dropdown menu with the ones that are overflowing the list
     */
    function responsiveTabs()
    {
        $('.responsive-tabs').each(function () {
            var parentUl = $(this)
            var ulWidth = parentUl.width() - 45;

            var hideTabs = hideListItems(parentUl, ulWidth)

            //Check if the hideTabs is false
            if (!hideTabs) {
                showHiddenListItems(parentUl, ulWidth)
            }

            // Check if the dropdown-menu has items else delete it
            if (!parentUl.find('.dropdown-menu li').length) {
                parentUl.find('.dropdown').remove();
            }
        })
    }

    /**
     * Hide list items froma a navigation menu that has too many
     *
     * @param {object} parentUl The parent ul
     * @param {float} ulWidth The width
     * @return {boolean}
     */
    function hideListItems(parentUl, ulWidth)
    {
        var hideTabs = false;
        //Get the total width of all list items
        var liTotalWidth = totalLiWidth(parentUl);

        //Get the list items in reverse order
        $(parentUl.find('li:not(.dropdown-li):not(.dropdown)').get().reverse()).each(function () {
            //list item width including the margins size
            var liWidth = $(this).width() + parseInt($(this).css("margin-left")) + parseInt($(this).css("margin-right"));

            //Checks if the list item total width is larger than the ul width
            if (liTotalWidth > ulWidth) {
                hideTabs = true;
                //Checks if the dropdown already exist else create it
                if (!parentUl.find('.dropdown').length) {
                    var dropdownString = '<li class="dropdown pull-right" style="width:45px">' +
                            '<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="true">' +
                                '<i class="fa fa-bars"></i>' +
                            '</a>' +
                            '<ul class="dropdown-menu pull-right"></ul>' +
                        '</li>';
                    parentUl.append(dropdownString)
                }
                //Move the item under the dropdown list
                parentUl.find('.dropdown-menu').prepend($(this).addClass('dropdown-li'));
                if ($(this).hasClass('active')) {
                    parentUl.find('.dropdown').addClass('active')
                }

                liTotalWidth = liTotalWidth - liWidth;
            } else {
                return false;
            }
        });

        return hideTabs;
    }

    /**
     * Show hidden list items
     *
     * @param {object} parentUl The parent ul
     * @param {float} ulWidth The width
     * @param {object} obj The object
     */
    function showHiddenListItems(parentUl, ulWidth)
    {
        //Get the liTotalWidth again
        var liTotalWidth = totalLiWidth(parentUl);

        //Get all the list items from the dropdown
        parentUl.find('.dropdown-menu li').each(function () {
            liTotalWidth = liTotalWidth + realListItemWidth($(this));
            if (liTotalWidth < ulWidth) {
                parentUl.find('.dropdown').before($(this).removeClass('dropdown-li'))
{'fraction_non_alphanumeric': 0.14614256917720359, 'fraction_numerical': 0.001557632398753894, 'mean_word_length': 1.72875, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3999813', 'n_tokens_mistral': 3085, 'n_tokens_neox': 2929, 'n_words': 716}