jquery.makeCollapsible: minor fixes to togglingHandler()
authorMatmaRex <matma.rex@gmail.com>
Thu, 11 Apr 2013 12:01:07 +0000 (14:01 +0200)
committerMatmaRex <matma.rex@gmail.com>
Thu, 11 Apr 2013 12:01:07 +0000 (14:01 +0200)
Documentation was not consistent with the code.

Followup to Id3f457a8, per post-merge code review.

Change-Id: If64b685cf697620e3b6fef797767c947f2c1f512

resources/jquery/jquery.makeCollapsible.js

index f07f1b7..09fe06e 100644 (file)
         * @param {jQuery.Event|null} e either the event or null if unavailable
         * @param {Object|undefined} options
         */
-       function togglingHandler( $toggle, $collapsible, event, options ) {
+       function togglingHandler( $toggle, $collapsible, e, options ) {
                var wasCollapsed, $textContainer, collapseText, expandText;
 
-               if ( event ) {
+               if ( options === undefined ) {
+                       options = {};
+               }
+
+               if ( e ) {
                        // Don't fire if a link was clicked, if requested  (for premade togglers by default)
-                       if ( options.linksPassthru && $.nodeName( event.target, 'a' ) ) {
-                               return true;
+                       if ( options.linksPassthru && $.nodeName( e.target, 'a' ) ) {
+                               return;
                        } else {
-                               event.preventDefault();
-                               event.stopPropagation();
+                               e.preventDefault();
+                               e.stopPropagation();
                        }
                }