RCFilters: Minimize vertical spacing; get rid of legend and <br>s
authorMoriel Schottlender <moriel@gmail.com>
Thu, 24 Aug 2017 23:52:29 +0000 (16:52 -0700)
committerMoriel Schottlender <moriel@gmail.com>
Fri, 1 Sep 2017 16:54:59 +0000 (09:54 -0700)
Bug: T174121
Change-Id: I2249bf3d313232fe2f0dff6e34c5140885a13735

resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js

index ad99e22..cfcdf35 100644 (file)
                        this.$element.find( 'hr' ).detach();
                }
 
+               // Get rid of all <br>s, which are inside rcshowhide
+               // If we still have content in rcshowhide, the <br>s are
+               // gone. Instead, the CSS now has a rule to mark all <span>s
+               // inside .rcshowhide with display:block; to simulate newlines
+               // where they're actually needed.
+               this.$element.find( 'br' ).detach();
                if ( !this.$element.find( '.rcshowhide' ).contents().length ) {
                        this.$element.find( '.rcshowhide' ).detach();
-                       // If we're hiding rcshowhide, the '<br>'s are around it,
-                       // there's no need for them either.
-                       this.$element.find( 'br' ).detach();
                }
 
                if ( this.$element.find( '.cloption' ).text().trim() === '' ) {
                        '.rclistfrom, .rcnotefrom, .rcoptions-listfromreset'
                ).detach();
 
-               if ( this.$element.text().trim() === this.$element.find( 'legend' ).text() ) {
+               // Get rid of the legend
+               this.$element.find( 'legend' ).detach();
+
+               // Check if the element is essentially empty, and detach it if it is
+               if ( !this.$element.text().trim().length ) {
                        this.$element.detach();
                }
        };