$(document).ready(function () {

    let interVal = setInterval(function () {
        $('.email_success').slideUp();
        clearInterval(interVal);
    }, 2000);

    /**
     * set localstorage item for main tabs
     * when clicked to add active class for it
     */
    $('#site-settings-tab, #modules-settings-tab').click(function () {
        localStorage.setItem('settingTap', $(this).attr('id'));
        localStorage.setItem('settingTabPane', $(this).attr('href'));
    });

    /**
     * get localstorage item for clicked tabs
     * to add active class for it
     * depend on it's #ID
     * @type {string}
     */
    let settingTap = localStorage.getItem('settingTap'),
        settingTabPane = localStorage.getItem('settingTabPane');
    settingTap ? $("#"+settingTap).addClass('active') : $('#site-settings-tab').addClass('active');
    settingTabPane ? $(settingTabPane).addClass('active') : $('#site-settings').addClass('active');


    $('.module_nav_link').click(function () {
        localStorage.setItem('module_nav_link', $(this).attr('id'));
        localStorage.setItem('module_tap_pane', $(this).attr('href'));
        let module_tap_pane = $(this).attr('href');
        $(module_tap_pane).addClass('fade active show');
        $(module_tap_pane).siblings().removeClass('fade active show')
    });


    /**
     * Add active class for first child
     */
    let module_nav_link = localStorage.getItem('module_nav_link'),
        module_tap_pane = localStorage.getItem('module_tap_pane');

    module_nav_link
        ? $("#"+module_nav_link).addClass('active')
        : $('.module_nav_item:first-of-type .module_nav_link').addClass('active');

    module_tap_pane
        ? $(module_tap_pane).addClass('fade active show')
        : $('.module_tap_pane:first-of-type').addClass('fade active show');



    $('.language_link').click(function () {
        localStorage.setItem('langTapClicked', $(this).attr('id'));
        localStorage.setItem('langTabPane', $(this).attr('href'));
        let langTabPane = $(this).attr('href');
        $(langTabPane).addClass('fade active show');
        $(langTabPane).siblings().removeClass('fade active show')

    });

    let langTapClicked = localStorage.getItem('langTapClicked'),
        langTabPane = localStorage.getItem('langTabPane');
    langTapClicked ? $("#"+langTapClicked).addClass('active') : $('.lang_nav_item:first-of-type a').addClass('active');
    langTabPane ? $(langTabPane).addClass('fade active show') : $('.language_tab_content div.tab-pane:first-of-type').addClass('fade active show');



});
