$(document).ready(function() { RESPONSIVEUI.responsiveTabs(); }); /* ---------------- ResponsiveTabs.js Author: Pete Love | www.petelove.com Version: 1.5 ------------------- */ var RESPONSIVEUI = {}; RESPONSIVEUI.responsiveTabs = function () { if (!$('.tabs').hasClass('enabled')) { // if we haven't already enabled tabs $('.tabs').addClass('enabled'); // used to style tabs if JS is present //loop through all sets of tabs on the page var tablistcount = 1; $('.tabs').each(function() { var $tabs = $(this); // add tab heading and tab panel classes $tabs.children('h1,h2,h3,h4,h5,h6').addClass('tab-heading'); $tabs.children('div').addClass('tab-panel'); // determine if markup already identifies the active tab panel for this set of tabs // if not then set first heading and tab to be the active one var $activePanel = $tabs.find('.active-panel'); if(!$activePanel.length) { var $activePanel = $tabs.find('.tab-panel').first().addClass('active-panel'); } $tabs.find('.tab-panel').not('.active-panel').hide().attr('aria-hidden','true'); //hide all except active panel $activePanel.attr('aria-hidden', 'false'); /* make active tab panel hidden for mobile */ $activePanel.addClass('hidden-mobile'); // wrap tabs in container - to be dynamically resized to help prevent page jump var $tabsWrapper = $('
', { class: 'tabs-wrapper' }); $tabs.wrap($tabsWrapper); var highestHeight = 0; // determine height of tallest tab panel. Used later to prevent page jump when tabs are clicked $tabs.find('.tab-panel').each(function() { var tabHeight = $(this).height(); if (tabHeight > highestHeight) { highestHeight = tabHeight; } }) //create the tab list var $tabList = $('