twitter/bootstrap — pull request #7509 by davemurphysf (2013-04-08 20:17:36+00:00)
Title: Proposed fix for allowing Collapse events ('show'/'hide') to be cancelled

Proposed fix for issue #5973

Added tracking for if preventDefault has been called similar to how 'transitioning' is currently tracked. If that has occured, the elements are returned their previous states in show() and hide() respectively. The more complicated use case is for when a group of elements is being managed by a parent element, and calling show() triggers the other elements to be hidden. I changed the plugin definition to take an argument (a boolean) to pass to hide() in this (and only this) case so that reseting this.defaultPrevented to 0 only happens in the orginating show() function. The other way to go here so that the plugin definition is not changed is to call a different hide function (hideOpenSiblings()?) in show() to hide the other elements that never resets this.defaultPrevented to 0.