<commit_before>/**
 * Popups of the collapsable sidebar secondary menu.
 *
 * @mixin
 * @namespace Bolt.submenu
 *
 * @param {Object} bolt - The Bolt module.
 * @param {Object} $ - jQuery.
 */
(function (bolt, $) {
    /**
     * Bolt.submenu mixin container.
     *
     * @private
     * @type {Object}
     */
    var submenu = {};

    /**
     * Initializes the mixin.
     *
     * @static
     * @function init
     * @memberof Bolt.submenu
     */
    submenu.init = function () {
        initPopOvers();
        if ($('.navbar-toggle').is(':visible')) {
            // we're on mobile view - so do not trigger the popups,
            // console.log('mobile view');
            // only trigger the mobile open action
            $('#navpage-secondary a.menu-pop').on('click', function(e) {
                    e.preventDefault();
                    var submenu = $(this).nextAll('.submenu');

                    if (submenu.hasClass('show')) {
                        submenu.removeClass('show');
                    } else {
                        $('#navpage-secondary .submenu').removeClass('show');
                        submenu.addClass('show');
                    }
                }
            );
        } else {
            // Add hover focus and leave blur event handlers for popovers - on desktop
            $('#navpage-secondary')
                .on('mouseover focus', 'a.menu-pop', function () {
                        var item = this;
                        window.clearTimeout(timeout);
                        timeout = window.setTimeout(function () {
                            $('#navpage-secondary a.menu-pop').not(item).popover('hide');
                            $(item).popover('show');
                        }, 300);
                    }
                )
                .on('mouseenter focus', '.popover', function () {
                        window.clearTimeout(timeout);
                    }
                )
                .on('mouseleave blur', 'a.menu-pop, .popover', function () {
                        window.clearTimeout(timeout);
                        timeout = window.setTimeout(function () {
                            $('#navpage-secondary a.menu-pop').popover('hide');
                        }, 300);
                    }
                );
        }
    };

    /**
     * Timeout to open the submenu.
     *
     * @private
     * @constant {integer} Timeout resource number
     * @memberof Bolt.submenu
     */
    var timeout = 0;

    /**
     * Add the submenus to the data-content for bootstrap.popover.
     *
     * @private
     * @function initPopOvers
     * @memberof Bolt.submenu
     */
    function initPopOvers() {
        $('#navpage-secondary a.menu-pop').each(
            function () {
                var menu = '';

                $(this).nextAll('.submenu').children().each(function () {
                    if ($(this).hasClass('subdivider')) {
                        menu += '<hr>';
                    }
                    menu += $(this).html().trim().replace(/[ \n]+/g, ' ').replace(/(>) | (<)/g, '$1$2');
                });

                $(this).attr('data-html', true).attr('data-content', menu);
            }
        );
    }

    // Apply mixin container<commit_msg>Move initializing of opening/closing of mobile submenu to own function<commit_after>/**
 * Popups of the collapsable sidebar secondary menu.
 *
 * @mixin
 * @namespace Bolt.submenu
 *
 * @param {Object} bolt - The Bolt module.
 * @param {Object} $ - jQuery.
 */
(function (bolt, $) {
    /**
     * Bolt.submenu mixin container.
     *
     * @private
     * @type {Object}
     */
    var submenu = {};

    /**
     * Initializes the mixin.
     *
     * @static
     * @function init
     * @memberof Bolt.submenu
     */
    submenu.init = function () {
        initPopOvers();
        if ($('.navbar-toggle').is(':visible')) {
            initMobileAction();
        } else {
            // Add hover focus and leave blur event handlers for popovers - on desktop
            $('#navpage-secondary')
                .on('mouseover focus', 'a.menu-pop', function () {
                        var item = this;
                        window.clearTimeout(timeout);
                        timeout = window.setTimeout(function () {
                            $('#navpage-secondary a.menu-pop').not(item).popover('hide');
                            $(item).popover('show');
                        }, 300);
                    }
                )
                .on('mouseenter focus', '.popover', function () {
                        window.clearTimeout(timeout);
                    }
                )
                .on('mouseleave blur', 'a.menu-pop, .popover', function () {
                        window.clearTimeout(timeout);
                        timeout = window.setTimeout(function () {
                            $('#navpage-secondary a.menu-pop').popover('hide');
                        }, 300);
                    }
                );
        }
    };

    /**
     * Timeout to open the submenu.
     *
     * @private
     * @constant {integer} Timeout resource number
     * @memberof Bolt.submenu
     */
    var timeout = 0;

    /**
     * Add the submenus to the data-content for bootstrap.popover.
     *
     * @private
     * @function initPopOvers
     * @memberof Bolt.submenu
     */
    function initPopOvers() {
        $('#navpage-secondary a.menu-pop').each(
            function () {
                var menu = '';

                $(this).nextAll('.submenu').children().each(function () {
                    if ($(this).hasClass('subdivider')) {
                        menu += '<hr>';
                    }
                    menu += $(this).html().trim().replace(/[ \n]+/g, ' ').replace(/(>) | (<)/g, '$1$2');
                });

                $(this).attr('data-html', true).attr('data-content', menu);
            }
        );
    }

    /**
     * Initialize opening/closing of mobile submenu.
     *
     * @private
     * @function initMobileAction
     * @memberof Bolt.submenu
     */
    function initMobileAction() {
        $('#navpage-secondary a.menu-pop').on('click', function(e) {
                var submenu = $(this).nextAll('.submenu');

                e.preventDefault();

                if (submenu.hasClass('show')) {
                    submenu.removeClass('show');
                } else {
                    $('#navpage-secondary .submenu').removeClass('show');
                    submenu.addClass('show');
                }
            }
        );
    }

    // Apply mixin container
{'fraction_non_alphanumeric': 0.14586783079933766, 'fraction_numerical': 0.0027096191479753125, 'mean_word_length': 1.262942779291553, 'pattern_counts': {'":': 0, '<': 7, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4413552', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1703, 'n_words': 347}