app/assets/javascripts/materialize/collapsible.js in materialize-sass-0.95.3.3 vs app/assets/javascripts/materialize/collapsible.js in materialize-sass-0.95.3.4

- old
+ new

@@ -9,11 +9,11 @@ return this.each(function() { var $this = $(this); - var $panel_headers = $(this).find('.collapsible-header'); + var $panel_headers = $(this).find('> li > .collapsible-header'); var collapsible_type = $this.data("collapsible"); // Turn off any existing event handlers $this.off('click.collapse', '.collapsible-header'); @@ -24,23 +24,24 @@ Helper Functions ****************/ // Accordion Open function accordionOpen(object) { - $panel_headers = $this.find('.collapsible-header'); + $panel_headers = $this.find('> li > .collapsible-header'); object.parent().toggleClass('active'); if (object.parent().hasClass('active')){ object.siblings('.collapsible-body').stop(true,false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false}); } else{ object.siblings('.collapsible-body').stop(true,false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false}); } $panel_headers.not(object).parent().removeClass('active'); $panel_headers.not(object).parent().children('.collapsible-body').stop(true,false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false}); } - // Collapsible Open - function collapsibleOpen(object) { + + // Expandable Open + function expandableOpen(object) { object.parent().toggleClass('active'); if (object.parent().hasClass('active')){ object.siblings('.collapsible-body').stop(true,false).slideDown({ duration: 350, easing: "easeOutQuart", queue: false}); } else{ @@ -51,29 +52,25 @@ /***** End Helper Functions *****/ if (options.accordion || collapsible_type == "accordion" || collapsible_type == undefined) { // Handle Accordion - - // Event delegation to all collapsible section - $this.on('click.collapse', '.collapsible-header', function (e) { - accordionOpen($(e.currentTarget)); + // Add click handler to only direct collapsible header children + $this.find('> li > .collapsible-header').on('click.collapse', function (e) { + accordionOpen($(e.target)); }); - // Open first active accordionOpen($panel_headers.filter('.active').first()); } else { // Handle Expandables $panel_headers.each(function () { - - // Event delegation to open collapsible section + // Add click handler to only direct collapsible header children $(this).on('click.collapse', function (e) { - collapsibleOpen($(e.currentTarget)); + expandableOpen($(e.target)); }); - // Open any bodies that have the active class if ($(this).hasClass('active')) { - collapsibleOpen($(this)); + expandableOpen($(this)); } }); } \ No newline at end of file