function showTab()

in ArticleTemplates/assets/js/bootstraps/common.js [571:631]


function showTab(tab, tabContainer, evt) {
    let showElem;
    let hideElem;
    let href;
    let activeTab;
    let tabId;

    initMpuPoller();
    evt.preventDefault();

    if (tab.getAttribute('aria-selected') !== 'true') {
        activeTab = tabContainer.querySelector('[aria-selected="true"]');
        tabId = tab.getAttribute('id');

        if (activeTab) {
            href = activeTab.getAttribute('href');
            if (href) {
                hideElem = document.querySelector(href);
                if (hideElem) {
                    hideElem.style.display = 'none';
                    activeTab.setAttribute('aria-selected', false);
                }
            }
        }

        href = tab.getAttribute('href');

        if (href) {
            showElem = document.querySelector(href);
            if (showElem) {
                showElem.style.display = 'block';
                tab.setAttribute('aria-selected', true);
            }
        }

        switch(tabId) {
            case 'football__tab--article':
                window.location.href = 'x-gu://football_tab_report';
                break;
            case 'football__tab--stats':
                setPieChartSize();
                window.location.href = 'x-gu://football_tab_stats';
                break;
            case 'football__tab--liveblog':
                window.location.href = 'x-gu://football_tab_liveblog';
                break;
            case 'cricket__tab--liveblog':
                if (GU.opts.platform === 'android') {
                    window.GuardianJSInterface.cricketTabChanged('overbyover');
                }
                break;
            case 'cricket__tab--stats':
                if (GU.opts.platform === 'android') {
                    window.GuardianJSInterface.cricketTabChanged('scorecard');
                }
                break;
            default:
                window.location.href = 'x-gu://football_tab_unknown';
        }
    }
}