foundation.tab.js 986 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*jslint unparam: true, browser: true, indent: 2 */
  2. ;(function ($, window, document, undefined) {
  3. 'use strict';
  4. Foundation.libs.tab = {
  5. name : 'tab',
  6. version : '5.0.1',
  7. settings : {
  8. active_class: 'active'
  9. },
  10. init : function (scope, method, options) {
  11. this.bindings(method, options);
  12. },
  13. events : function () {
  14. $(this.scope).off('.tab').on('click.fndtn.tab', '[data-tab] > dd > a', function (e) {
  15. e.preventDefault();
  16. var tab = $(this).parent(),
  17. target = $('#' + this.href.split('#')[1]),
  18. siblings = tab.siblings(),
  19. settings = tab.closest('[data-tab]').data('tab-init');
  20. tab.addClass(settings.active_class);
  21. siblings.removeClass(settings.active_class);
  22. target.siblings().removeClass(settings.active_class).end().addClass(settings.active_class);
  23. });
  24. },
  25. off : function () {},
  26. reflow : function () {}
  27. };
  28. }(jQuery, this, this.document));