views:

19

answers:

0

I'm using wordpress as cms and mystique theme for my site and use it's tab feature in my code but this tab code is not able to get active tab by url (ex: http://www.animcentral.com/anime/death-note#section-forums it should activate first tab from left but it doesn't) I wanna Extend this javascript to be able to active selected tab by url.

// optimized minitabs
(function (jQuery) {
  jQuery.fn.minitabs = function (options) {
    jQuery.fn.minitabs.defaults = {
      content: '.sections',
      nav: 'ul:first',
      effect: 'top',
      speed: 333,
      cookies: true
    };
    var o = jQuery.extend({},
    jQuery.fn.minitabs.defaults, options);
    return this.each(function () {
      var $tabs = jQuery(this);
      var $instance = $tabs.attr('id');
      var $nav = jQuery('#' + $instance + ' ' + o.nav);
      if (o.cookies) { // check for the active tab cookie
        var cookieID = $instance;
        var cookieState = jQuery.cookie(cookieID);
      } // hide all sections
      $tabs.find(o.content + " >div:gt(0)").hide();
      if (o.cookies && (cookieState != null)) { // if we have a cookie then show the section according to its value
        $nav.find('li.' + cookieState).addClass("active");
        var link = $nav.find('li.' + cookieState + ' a');
        var section = link.attr('href');
        $tabs.find(o.content + ' div' + section).show();
      } else { // if not, show the 1st section
        $nav.find('li:first').addClass("active");
        $tabs.find(o.content + ' div:first').show();
      }
      $nav.find("li>a").click(function () {
        if (!jQuery(this).parent('li').hasClass("active")) {
          $nav.find('li').removeClass("active");
          if (o.cookies) {
            var cookieValue = jQuery(this).parent('li').attr("class");
            jQuery.cookie(cookieID, cookieValue, {
              path: '/'
            });
          }
          jQuery(this).parent('li').addClass("active");
          jQuery(this).blur();
          var re = /([_\-\w]+$)/i;
          var target = jQuery('#' + $instance + ' #' + re.exec(this.href)[1]);
          if (o.effect == 'slide') $tabs.find(o.content + " >div").slideUp(o.effect);
          else $tabs.find(o.content + " >div").hide();
          switch (o.effect) {
          case 'top':
            if (isIE) target.css({
              top: -300
            }).show().animate({
              top: 0
            },
            o.speed, 'easeOutQuart');
            else target.css({
              opacity: 0,
              top: -300
            }).show().animate({
              opacity: 1,
              top: 0
            },
            o.speed, 'easeOutQuart');
            break;
          case 'slide':
            target.slideDown(o.speed);
            break;
          case 'height':
            originalHeight = target.height();
            target.css({
              opacity: 0,
              height: 0
            }).show().animate({
              opacity: 1,
              height: originalHeight
            },
            o.speed, 'easeOutQuart');
            break;
          }
          return false;
        }
      })
    });
  };
})(jQuery);