foundation.accordion.js 1.1 KB

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