diff --git a/misc/vertical-tabs.js b/misc/vertical-tabs.js
index 3aa0f6f..ab1664d 100644
--- a/misc/vertical-tabs.js
+++ b/misc/vertical-tabs.js
@@ -17,6 +17,7 @@ Drupal.behaviors.verticalTabs = {
$('.vertical-tabs-panes', context).once('vertical-tabs', function () {
var focusID = $(':hidden.vertical-tabs-active-tab', this).val();
var tab_focus;
+ var tab_pane_set = $(this);
// Check if there are some fieldsets that can be converted to vertical-tabs
var $fieldsets = $('> fieldset', this);
@@ -26,7 +27,16 @@ Drupal.behaviors.verticalTabs = {
// Create the tab column.
var tab_list = $('
');
- $(this).wrap('').before(tab_list);
+ tab_pane_set.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();
+ tab_set.show();
+ var $fieldsets = $('> fieldset:visible', this);
+ if ($fieldsets.length == 0) {
+ tab_set.hide();
+ }
+ });
// Transform each fieldset into a tab.
$fieldsets.each(function () {
@@ -38,6 +48,27 @@ Drupal.behaviors.verticalTabs = {
$(this)
.removeClass('collapsible collapsed')
.addClass('vertical-tabs-pane')
+ // Override the default state:visible handler.
+ .bind('state:visible', function(e) {
+ if (e.target == this && e.trigger) {
+ // Get the id of the fieldset.
+ var id = $(e.target).closest('.form-item, .form-submit, .form-wrapper').attr('id');
+ if (id) {
+ // Get the corresponding vertical_tab button.
+ // Hide or show that instead of the fieldset.
+ if (!e.value) {
+ vertical_tab.tabHide().updateSummary();
+ }
+ else if(e.value) {
+ vertical_tab.item.show();
+ vertical_tab.updateSummary();
+ }
+ tab_pane_set.trigger('updateTabPaneSet');
+ // Don't bubble this up to the default handler.
+ return false;
+ }
+ }
+ })
.data('verticalTab', vertical_tab);
if (this.id == focusID) {
tab_focus = $(this);