1jQuery(function () { 2 const $metaBox = jQuery('#spr__meta-box'); 3 if (!$metaBox.length) return; 4 5 /** 6 * Register the click handler for the tabs 7 * 8 * Tabs can be added dynamically later on and this handler will still 9 * provide the open/close functionality 10 */ 11 $metaBox.on('click', '.meta-tabs a', function (e) { 12 e.preventDefault(); 13 const $tab = jQuery(this); 14 const isopen = $tab.attr('aria-expanded') === 'true'; 15 16 // disable all existing tabs 17 $metaBox.find('.meta-tabs li') 18 .removeClass('active') 19 .find('a') 20 .attr('aria-expanded', 'false'); 21 $metaBox.find('.meta-content .tab-pane') 22 .removeClass('active') 23 .attr('aria-hidden', 'false'); 24 25 if (isopen) return; // tab was open, we closed it. we're done 26 27 // enable current tab 28 $tab 29 .attr('aria-expanded', 'true') 30 .closest('li') 31 .addClass('active'); 32 $metaBox.find($tab.attr('href')) 33 .addClass('active') 34 .attr('aria-hidden', 'false'); 35 36 }); 37 38 39}); 40