app/assets/javascripts/materialize/collapsible.js in materialize-sass-0.98.1 vs app/assets/javascripts/materialize/collapsible.js in materialize-sass-0.98.2

- old
+ new

@@ -72,12 +72,14 @@ object.siblings('.collapsible-body').stop(true,false).slideUp({ duration: 350, easing: "easeOutQuart", queue: false, complete: function() {$(this).css('height', '');}}); } } // Open collapsible. object: .collapsible-header - function collapsibleOpen(object) { - object.toggleClass('active'); + function collapsibleOpen(object, noToggle) { + if (!noToggle) { + object.toggleClass('active'); + } if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { // Handle Accordion accordionOpen(object); } else { // Handle Expandables expandableOpen(object); @@ -119,15 +121,24 @@ function getPanelHeader(object) { return object.closest('li > .collapsible-header'); } + + // Turn off any existing event handlers + function removeEventHandlers() { + $this.off('click.collapse', '> li > .collapsible-header'); + } + /***** End Helper Functions *****/ // Methods - if (methodParam >= 0 && + if (methodName === 'destroy') { + removeEventHandlers(); + return; + } else if (methodParam >= 0 && methodParam < $panel_headers.length) { var $curr_header = $panel_headers.eq(methodParam); if ($curr_header.length && (methodName === 'open' || (methodName === 'close' && @@ -136,13 +147,11 @@ } return; } - // Turn off any existing event handlers - $this.off('click.collapse', '> li > .collapsible-header'); - $panel_headers.off('click.collapse'); + removeEventHandlers(); // Add click handler to only direct collapsible header children $this.on('click.collapse', '> li > .collapsible-header', function(e) { var element = $(e.target); @@ -155,14 +164,14 @@ }); // Open first active if (options.accordion || collapsible_type === "accordion" || collapsible_type === undefined) { // Handle Accordion - collapsibleOpen($panel_headers.filter('.active').first()); + collapsibleOpen($panel_headers.filter('.active').first(), true); } else { // Handle Expandables $panel_headers.filter('.active').each(function() { - collapsibleOpen($(this)); + collapsibleOpen($(this), true); }); } }); };