RCFilters UI: Unify li bullets with and without highlights
authorMoriel Schottlender <moriel@gmail.com>
Wed, 19 Apr 2017 21:47:43 +0000 (14:47 -0700)
committerMooeypoo <moriel@gmail.com>
Wed, 19 Apr 2017 22:00:36 +0000 (22:00 +0000)
Make sure that the placement of the texts under the bullets is
the same whether the highlight is on or off. Otherwise, the list
is shifting a bit to the right to make room for highlight 'bullets'
when we press the highlight key.

Bonus: Make sure the highlight container is only appended to each
bullet once, even if the process is called for more than once on
the same content.

Bug: T163275
Bug: T163387
Change-Id: I4c2cf6176d5129dd2bc37d2f58ed84e85aca8560

resources/src/mediawiki.rcfilters/styles/mw.rcfilters.ui.ChangesListWrapperWidget.less
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js

index 402f0ad..3337a03 100644 (file)
                }
        }
 
+       ul {
+               // Each li's margin-left should be the width of the highlights
+               // element + the margin
+               margin-left: ~'calc( ( @{result-circle-diameter} + @{result-circle-margin} ) * 5 + @{result-circle-general-margin} )';
+       }
+
        &-highlighted {
                ul {
                        list-style: none;
-                       // Each li's margin-left should be the width of the highlights
-                       // element + the margin
-                       margin-left: ~'calc( ( @{result-circle-diameter} + @{result-circle-margin} ) * 5 + @{result-circle-general-margin} )';
 
                        li {
                                list-style: none;
index c7e6961..f4a1807 100644 (file)
                                                .prop( 'data-color', 'none' )
                                );
 
+               if ( $( '.mw-rcfilters-ui-changesListWrapperWidget-highlights' ).length ) {
+                       // Already set up
+                       return;
+               }
+
                mw.rcfilters.HighlightColors.forEach( function ( color ) {
                        $highlights.append(
                                $( '<div>' )