Hi there,
i've read, that the ui.tabs.js has a cookie functions build in. What is to do, the use this function? Add/Change something in the tabs.js?
Could someone give me a hint. I like to understand what happens between the .module and the js-files.
Cheers Kai

//getter
var cookie = $('.selector').tabs('option', 'cookie');
//setter
$('.selector').tabs('option', 'cookie', { expires: 30 });

Comments

Apfel007’s picture

HI there,

could someone help me to figure out that..

I add this to tabs.js

...
// Set cookie to remember active tab
Drupal.tabsClick = function(id) {
  $.cookie('activetab', id); 
};

and that to the tabs.module

...
$output .= '<li'. drupal_attributes($element[$key]['#attributes']) .'>
    
                  <a onClick="Drupal.tabsClick(this.id); return true;" 
                     id="tab-id-'. $element['#tabset_name'] .'-'. $element[$key]['#index'] .'"
                    href="#tabs-'. $element['#tabset_name'] .'-'. $element[$key]['#index'] .'">'. $element[$key]['#title'] .'</a></li>';

how can I now set the active-class to the id, the cookie saved? This this is the right function I think.. Thanks for helping me

...
Drupal.behaviors.tabs = function (context) {
  var fx = {duration: Drupal.settings.tabs.speed};
  if (Drupal.settings.tabs.fade) {
    fx.opacity = 'toggle';
  }
  if (Drupal.settings.tabs.slide) {
    fx.height = 'toggle';
  }
   // Process custom tabs.
  $('.drupal-tabs:not(.tabs-processed)', context)
    .addClass('tabs-processed')
    .each(function () {
      if ($(this).is('.tabs-navigation')) {
      Drupal.tabsNavigation(this);
      }
    })
    .find('> ul')
    .tabs({
     selectedClass: 'active',
     fx: fx
    })
    .addClass('tabs')
    .each(function () {
      // Assign secondary class to nested tabsets.
      var newClass = $(this).parents('.drupal-tabs').size() > 1 ? 'secondary' : 'primary';
      $(this).addClass(newClass);
    })
    .after('<span class="clear"></span>')
    .end()
    .show();
};
nedjo’s picture

I'd welcome a patch to add conditional cookie support.