PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/res/effects/vAccordion/vAccordion.js

https://bitbucket.org/aeris3/multicolumn
JavaScript | 50 lines | 36 code | 10 blank | 4 comment | 3 complexity | 27faa88ee83aad37101862531628bcac MD5 | raw file
  1. jQuery.noConflict();
  2. (function($) {
  3. // function accordion
  4. $.fn.accordion = function(customOptions) {
  5. var self = $(this)
  6. ,items = $(this).children()
  7. // defaults
  8. ,defaultOptions = {
  9. }
  10. // merge defaults with options in new settings object
  11. ,options = $.extend({}, defaultOptions, customOptions);
  12. self.find('.effectBoxItemContent').hide();
  13. if (options.showFirst == true) {
  14. self.find('li.effectBoxItemsFirst .effectBoxItemContent').show();
  15. self.find('li.effectBoxItemsFirst');
  16. }
  17. $(items).each(function() {
  18. $(this).children('.effectBoxItemTitle').click(function(event) {
  19. var $el = $(this),
  20. $parent = $el.parent();
  21. event.preventDefault();
  22. if (! $parent().hasClass('active')) {
  23. $parent().toggleClass('active');
  24. $parent().siblings().removeClass('active');
  25. $el.siblings('.effectBoxItemContent').slideDown();
  26. $parent().siblings().children('.effectBoxItemContent').slideUp();
  27. }
  28. });
  29. });
  30. };
  31. })(jQuery);
  32. jQuery(document).ready(function($) {
  33. var container = $('ul.vAccordion');
  34. container.each(function(index, element) {
  35. var id = element.id.split('_')[1];
  36. var customOptions = window['mullticolumnEffectBox_'+id] ? window['mullticolumnEffectBox_'+id] : {};
  37. // init accordion functions
  38. $(this).accordion(customOptions);
  39. });
  40. });