SPR-980: close meta box after click on TOC anchor
This commit is contained in:
parent
c5e825b2e3
commit
c6a2583846
2 changed files with 100 additions and 29 deletions
|
@ -16,12 +16,44 @@
|
|||
*/
|
||||
var registerClickForTabsInMetaBox = function($metaBox) {
|
||||
|
||||
$metaBox.on('click', '.meta-tabs a', function (e) {
|
||||
e.preventDefault();
|
||||
var $tab = $(this),
|
||||
isopen = $tab.attr('aria-expanded') === 'true';
|
||||
$metaBox.on('click', '.meta-tabs a', function (e) {
|
||||
e.preventDefault();
|
||||
var $tab = $(this),
|
||||
isopen = $tab.attr('aria-expanded') === 'true';
|
||||
|
||||
// disable all existing tabs
|
||||
// disable all existing tabs
|
||||
disableExistingTabs($metaBox);
|
||||
|
||||
|
||||
if (isopen) return; // tab was open, we closed it. we're done
|
||||
|
||||
// enable current tab
|
||||
$tab
|
||||
.attr('aria-expanded', 'true')
|
||||
.closest('li')
|
||||
.addClass('active');
|
||||
$metaBox.find($tab.attr('href'))
|
||||
.addClass('active')
|
||||
.attr('aria-hidden', 'false');
|
||||
|
||||
}).find('.meta-content').on('click', 'a[href*="#"]', function (e) {
|
||||
disableExistingTabs($metaBox);
|
||||
/* uses custome event handler hide see spc.js */
|
||||
}).find('#tagging__edit').on('hide', function(e){
|
||||
disableExistingTabs($metaBox);
|
||||
});
|
||||
|
||||
/**
|
||||
* in admin templates show toc tab, if available
|
||||
*/
|
||||
if($('body').hasClass('do-admin')) {
|
||||
var $tocLink = $metaBox.find('a[href="#spr__tab-toc"]');
|
||||
if($tocLink.length === 1) {
|
||||
$tocLink.trigger('click');
|
||||
}
|
||||
}
|
||||
},
|
||||
disableExistingTabs = function($metaBox) {
|
||||
$metaBox.find('.meta-tabs li')
|
||||
.removeClass('active')
|
||||
.find('a')
|
||||
|
@ -29,30 +61,7 @@
|
|||
$metaBox.find('.meta-content .tab-pane')
|
||||
.removeClass('active')
|
||||
.attr('aria-hidden', 'false');
|
||||
|
||||
if (isopen) return; // tab was open, we closed it. we're done
|
||||
|
||||
// enable current tab
|
||||
$tab
|
||||
.attr('aria-expanded', 'true')
|
||||
.closest('li')
|
||||
.addClass('active');
|
||||
$metaBox.find($tab.attr('href'))
|
||||
.addClass('active')
|
||||
.attr('aria-hidden', 'false');
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* in admin templates show toc tab, if available
|
||||
*/
|
||||
if($('body').hasClass('do-admin')) {
|
||||
var $tocLink = $metaBox.find('a[href="#spr__tab-toc"]');
|
||||
if($tocLink.length === 1) {
|
||||
$tocLink.trigger('click');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
$(function(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue