Index: misc/vertical-tabs.js =================================================================== RCS file: /cvs/drupal/drupal/misc/vertical-tabs.js,v retrieving revision 1.7 diff -u -p -r1.7 vertical-tabs.js --- misc/vertical-tabs.js 31 Aug 2009 05:51:08 -0000 1.7 +++ misc/vertical-tabs.js 5 Sep 2009 09:12:59 -0000 @@ -37,11 +37,13 @@ Drupal.behaviors.verticalTabs = { $('> li:first', list).addClass('first'); $('> li:last', list).addClass('last'); + $('> li a', list).attr('tabindex', 999); if (!focus) { focus = $('> .vertical-tabs-pane:first', this); } focus.data('verticalTab').focus(); + Drupal_verticalTabs_addKeyboardSupport(); }); } }; @@ -117,4 +119,75 @@ Drupal.theme.prototype.verticalTab = fun return tab; }; +/** + * Function to add support for tabbing through all the tabs. + * What with empty tabs? or tabs with all inputs disabled? it breaks + */ + +Drupal_verticalTabs_addKeyboardSupport = function () { + +$('div.vertical-tabs-panes > fieldset').not(':last').each( + function() { + // All but radio + $(':input:enabled:last', this).not('[type=radio]').bind ('keydown', + function(e) { + if (!e.shiftKey && e.keyCode == 9) { + var t = $(this); + var fs = t.closest('fieldset'); + var n = fs.next(); + var c1 = $(':input:enabled:first', n); + n.data('verticalTab').focus(); + c1.focus(); + return false; + } + }); + // Radios + var radioname = $(':input:enabled:last[type=radio]', this).attr('name'); + $('[name='+radioname+']').bind ('keydown', + function(e) { + if (!e.shiftKey && e.keyCode == 9) { + var t = $(this); + var fs = t.closest('fieldset'); + var n = fs.next(); + var c1 = $(':input:enabled:first', n); + n.data('verticalTab').focus(); + c1.focus(); + return false; + } + }); + + }); + +$('div.vertical-tabs-panes > fieldset').not(':first').each( + function() { + // All but radio + $(':input:enabled:first', this).not('[type=radio]').bind ('keydown', + function(e) { + if (e.shiftKey && e.keyCode == 9) { + var t = $(this); + var fs = t.closest('fieldset'); + var n = fs.prev(); + var c1 = $(':input:enabled:last', n); + n.data('verticalTab').focus(); + c1.focus(); + return false; + } + }); + // Radios + var radioname = $(':input:enabled:first[type=radio]', this).attr('name'); + $('[name='+radioname+']').bind ('keydown', + function(e) { + if (e.shiftKey && e.keyCode == 9) { + var t = $(this); + var fs = t.closest('fieldset'); + var n = fs.prev(); + var c1 = $(':input:enabled:last', n); + n.data('verticalTab').focus(); + c1.focus(); + return false; + } + }); + }); +} + })(jQuery);