jquery.makeCollapsible: Special case of content inside <li>
authorVictor Porton <porton@narod.ru>
Sun, 26 Jun 2016 13:30:54 +0000 (16:30 +0300)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 30 Jun 2016 17:35:01 +0000 (19:35 +0200)
Bug: T137676
Change-Id: Ie4228e63a63157e3909e938a4086f46dcbbf6767

resources/src/jquery/jquery.makeCollapsible.js

index bdb5ce8..501e898 100644 (file)
                                // If this is not a custom case, do the default: wrap the
                                // contents and add the toggle link. Different elements are
                                // treated differently.
+
                                if ( $collapsible.is( 'table' ) ) {
 
                                        // If the table has a caption, collapse to the caption
                                                }
                                        }
 
+                               } else if ( $collapsible.parent().is( 'li' ) &&
+                                       $collapsible.parent().children( '.mw-collapsible' ).size() === 1
+                               ) {
+                                       // special case of one collapsible in <li> tag
+                                       $toggleLink = buildDefaultToggleLink();
+                                       $collapsible.before( $toggleLink );
                                } else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) {
                                        // The toggle-link will be in the first list-item
                                        $firstItem = $collapsible.find( 'li:first' );