allow closing tabs by clicking them again
also pass the proper type to attr() - it expects strings!
This commit is contained in:
parent
c93c93a805
commit
435c8032f2
1 changed files with 7 additions and 6 deletions
|
@ -11,28 +11,29 @@ jQuery(function () {
|
||||||
$metaBox.on('click', '.meta-tabs a', function (e) {
|
$metaBox.on('click', '.meta-tabs a', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const $tab = jQuery(this);
|
const $tab = jQuery(this);
|
||||||
|
const isopen = $tab.attr('aria-expanded') === 'true';
|
||||||
|
|
||||||
// disable all existing tabs
|
// disable all existing tabs
|
||||||
$metaBox.find('.meta-tabs li')
|
$metaBox.find('.meta-tabs li')
|
||||||
.removeClass('active')
|
.removeClass('active')
|
||||||
.find('a')
|
.find('a')
|
||||||
.attr('aria-expanded', false);
|
.attr('aria-expanded', 'false');
|
||||||
$metaBox.find('.meta-content .tab-pane')
|
$metaBox.find('.meta-content .tab-pane')
|
||||||
.removeClass('active')
|
.removeClass('active')
|
||||||
.attr('aria-hidden', false);
|
.attr('aria-hidden', 'false');
|
||||||
|
|
||||||
|
if (isopen) return; // tab was open, we closed it. we're done
|
||||||
|
|
||||||
// enable current tab
|
// enable current tab
|
||||||
$tab
|
$tab
|
||||||
.attr('aria-expanded', true)
|
.attr('aria-expanded', 'true')
|
||||||
.closest('li')
|
.closest('li')
|
||||||
.addClass('active');
|
.addClass('active');
|
||||||
$metaBox.find($tab.attr('href'))
|
$metaBox.find($tab.attr('href'))
|
||||||
.addClass('active')
|
.addClass('active')
|
||||||
.attr('aria-hidden', false);
|
.attr('aria-hidden', 'false');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue