Sha256: 818fe851d1792e79693bc283a9efeaddd201a532191c657848229b54076935fc

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

;(function ($, window, document, undefined) {
  'use strict';

  var settings = {
        callback: $.noop,
        init: false
      }, 

      methods = {
        init : function (options) {
          settings = $.extend({}, options, settings);

          return this.each(function () {
            if (!settings.init) methods.events();
          });
        },

        events : function () {
          $(document).on('click.fndtn', '.tabs a', function (e) {
            methods.set_tab($(this).parent('dd, li'), e);
          });
          
          settings.init = true;
        },

        set_tab : function ($tab, e) {
          var $activeTab = $tab.closest('dl, ul').find('.active'),
              target = $tab.children('a').attr("href"),
              hasHash = /^#/.test(target),
              $content = $(target + 'Tab');

          if (hasHash && $content.length > 0) {
            // Show tab content
            e.preventDefault();
            $content.closest('.tabs-content').children('li').removeClass('active').hide();
            $content.css('display', 'block').addClass('active');
          }

          // Make active tab
          $activeTab.removeClass('active');
          $tab.addClass('active');

          settings.callback();
        }
      }

  $.fn.foundationTabs = function (method) {
    if (methods[method]) {
      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method) {
      return methods.init.apply(this, arguments);
    } else {
      $.error('Method ' +  method + ' does not exist on jQuery.foundationTooltips');
    }
  };
}(jQuery, this, this.document));

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zurb-foundation-3.2.2 vendor/assets/javascripts/foundation/jquery.foundation.tabs.js