123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- (function ($) {
- Drupal.behaviors.verticalTabs = {
- attach: function (context) {
- $('.vertical-tabs-panes', context).once('vertical-tabs', function () {
- var focusID = $(':hidden.vertical-tabs-active-tab', this).val();
- var tab_focus;
-
- var $fieldsets = $('> fieldset', this);
- if ($fieldsets.length == 0) {
- return;
- }
-
- var tab_list = $('<ul class="vertical-tabs-list"></ul>');
- $(this).wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list);
-
- $fieldsets.each(function () {
- var vertical_tab = new Drupal.verticalTab({
- title: $('> legend', this).text(),
- fieldset: $(this)
- });
- tab_list.append(vertical_tab.item);
- $(this)
- .removeClass('collapsible collapsed')
- .addClass('vertical-tabs-pane')
- .data('verticalTab', vertical_tab);
- if (this.id == focusID) {
- tab_focus = $(this);
- }
- });
- $('> li:first', tab_list).addClass('first');
- $('> li:last', tab_list).addClass('last');
- if (!tab_focus) {
-
-
- if (window.location.hash && $(this).find(window.location.hash).length) {
- tab_focus = $(this).find(window.location.hash).closest('.vertical-tabs-pane');
- }
- else {
- tab_focus = $('> .vertical-tabs-pane:first', this);
- }
- }
- if (tab_focus.length) {
- tab_focus.data('verticalTab').focus();
- }
- });
- }
- };
- Drupal.verticalTab = function (settings) {
- var self = this;
- $.extend(this, settings, Drupal.theme('verticalTab', settings));
- this.link.click(function () {
- self.focus();
- return false;
- });
-
-
- this.link.keydown(function(event) {
- if (event.keyCode == 13) {
- self.focus();
-
- $("fieldset.vertical-tabs-pane :input:visible:enabled:first").focus();
- return false;
- }
- });
- this.fieldset
- .bind('summaryUpdated', function () {
- self.updateSummary();
- })
- .trigger('summaryUpdated');
- };
- Drupal.verticalTab.prototype = {
-
- focus: function () {
- this.fieldset
- .siblings('fieldset.vertical-tabs-pane')
- .each(function () {
- var tab = $(this).data('verticalTab');
- tab.fieldset.hide();
- tab.item.removeClass('selected');
- })
- .end()
- .show()
- .siblings(':hidden.vertical-tabs-active-tab')
- .val(this.fieldset.attr('id'));
- this.item.addClass('selected');
-
- $('#active-vertical-tab').remove();
- this.link.append('<span id="active-vertical-tab" class="element-invisible">' + Drupal.t('(active tab)') + '</span>');
- },
-
- updateSummary: function () {
- this.summary.html(this.fieldset.drupalGetSummary());
- },
-
- tabShow: function () {
-
- this.item.show();
-
- this.item.closest('.vertical-tabs').show();
-
-
-
- this.item.parent().children('.vertical-tab-button').removeClass('first')
- .filter(':visible:first').addClass('first');
-
- this.fieldset.removeClass('vertical-tab-hidden').show();
-
- this.focus();
- return this;
- },
-
- tabHide: function () {
-
- this.item.hide();
-
-
-
- this.item.parent().children('.vertical-tab-button').removeClass('first')
- .filter(':visible:first').addClass('first');
-
- this.fieldset.addClass('vertical-tab-hidden').hide();
-
- var $firstTab = this.fieldset.siblings('.vertical-tabs-pane:not(.vertical-tab-hidden):first');
- if ($firstTab.length) {
- $firstTab.data('verticalTab').focus();
- }
-
- else {
- this.item.closest('.vertical-tabs').hide();
- }
- return this;
- }
- };
- Drupal.theme.prototype.verticalTab = function (settings) {
- var tab = {};
- tab.item = $('<li class="vertical-tab-button" tabindex="-1"></li>')
- .append(tab.link = $('<a href="#"></a>')
- .append(tab.title = $('<strong></strong>').text(settings.title))
- .append(tab.summary = $('<span class="summary"></span>')
- )
- );
- return tab;
- };
- })(jQuery);
|