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 15 // disable all existing tabs 16 $metaBox.find('.meta-tabs li') 17 .removeClass('active') 18 .find('a') 19 .attr('aria-expanded', false); 20 $metaBox.find('.meta-content .tab-pane') 21 .removeClass('active') 22 .attr('aria-hidden', false); 23 24 // enable current tab 25 $tab 26 .attr('aria-expanded', true) 27 .closest('li') 28 .addClass('active'); 29 $metaBox.find($tab.attr('href')) 30 .addClass('active') 31 .attr('aria-hidden', false); 32 33 }); 34 35 36 37 38}); 39