diff -u b/core/misc/vertical-tabs.js b/core/misc/vertical-tabs.js --- b/core/misc/vertical-tabs.js +++ b/core/misc/vertical-tabs.js @@ -43,7 +43,7 @@ var $this = $(this).addClass('vertical-tabs__panes'); var focusID = $this.find(':hidden.vertical-tabs__active-tab').val(); var tab_focus; - var tab_pane_set = $(this); + var $tabPaneSet = $(this); // Check if there are some details that can be converted to // vertical-tabs. @@ -55,18 +55,18 @@ // Create the tab column. var tab_list = $('
'); - tab_pane_set + $tabPaneSet .wrap('') .before(tab_list) - // If there are no visible tabs panes, hide the whole vertical-tabs area. - .bind('updateTabPaneSet', function() { - var tab_set = tab_pane_set.parent(); + // If there are no visible tab panes, hide the whole vertical-tabs + // area. + .on('updateTabPaneSet', function() { + var tab_set = $tabPaneSet.parent(); tab_set.show(); - var $fieldsets = $('> fieldset:visible', this); - if ($fieldsets.length == 0) { + var $panes = $('> details:visible', this); + if ($panes.length == 0) { tab_set.hide(); } }); - // Transform each details into a tab. $details.each(function () { @@ -83,22 +83,27 @@ .attr('open', true) .addClass('vertical-tabs__pane') // Override the default state:visible handler. - .bind('state:visible', function(e) { + .on('state:visible.verticalTabs', function (e) { if (e.target == this && e.trigger) { - // Get the id of the fieldset. + // Get the id of the vertical tab. var id = $(e.target).closest('.form-item, .form-submit, .form-wrapper').attr('id'); if (id) { - // Hide or show that instead of the fieldset. if (!e.value) { - vertical_tab.tabHide().updateSummary(); + if ($(vertical_tab.details.context).is(':visible')) { + vertical_tab.tabHide().updateSummary(); + } + else { + vertical_tab.item.hide(); + vertical_tab.updateSummary(); + } } else if(e.value) { vertical_tab.item.show(); vertical_tab.updateSummary(); } - tab_pane_set.trigger('updateTabPaneSet'); + $tabPaneSet.trigger('updateTabPaneSet'); // Don't bubble this up to the default handler. - e.preventDefault(); + e.stopPropagation(); } } })