Special:AllMessages: Remove al_title and allmessages-customised classes
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 16 Dec 2018 23:16:26 +0000 (23:16 +0000)
committerVolkerE <volker.e@wikimedia.org>
Mon, 17 Dec 2018 09:16:49 +0000 (09:16 +0000)
* The al_title class was unused, and thus removed.

* The allmessages-customised class was used in CSS to target
  elements with 'al_default' and 'al_actual' classses within it,
  which are in turn only used for that purpose.
  Change the HTML to match the needs of the CSS by only setting
  al_default/al_actual classes on customised messages and remove
  need for the parent element class.

On a plain install this reduced output by ~2K from 75.8K to 74.0K,
and allocate 100 (2x50) fewer attribute nodes.

Change-Id: If2dd4cf5c937935f03f30b8410a32b6821b0bf34

includes/specials/pagers/AllMessagesTablePager.php
resources/src/mediawiki.special/special.css

index a9479c4..18c1d70 100644 (file)
@@ -345,6 +345,7 @@ class AllMessagesTablePager extends TablePager {
                return '';
        }
 
+       /** @return string HTML */
        function formatRow( $row ) {
                // Do all the normal stuff
                $s = parent::formatRow( $row );
@@ -365,28 +366,28 @@ class AllMessagesTablePager extends TablePager {
                return $s;
        }
 
-       function getRowAttrs( $row, $isSecond = false ) {
-               $arr = [];
-
-               if ( $row->am_customised ) {
-                       $arr['class'] = 'allmessages-customised';
-               }
-
-               return $arr;
+       function getRowAttrs( $row ) {
+               return [];
        }
 
+       /** @return array HTML attributes */
        function getCellAttrs( $field, $value ) {
-               if ( $this->mCurrentRow->am_customised && $field === 'am_title' ) {
-                       return [ 'rowspan' => '2', 'class' => $field ];
-               } elseif ( $field === 'am_title' ) {
-                       return [ 'class' => $field ];
+               $attr = [];
+               if ( $field === 'am_title' ) {
+                       if ( $this->mCurrentRow->am_customised ) {
+                               $attr += [ 'rowspan' => '2' ];
+                       }
                } else {
-                       return [
+                       $attr += [
                                'lang' => $this->lang->getHtmlCode(),
                                'dir' => $this->lang->getDir(),
-                               'class' => $field
                        ];
+                       if ( $this->mCurrentRow->am_customised ) {
+                               // CSS class: am_default, am_actual
+                               $attr += [ 'class' => $field ];
+                       }
                }
+               return $attr;
        }
 
        // This is not actually used, as getStartBody is overridden above
index 35cdee7..cb05793 100644 (file)
@@ -1,9 +1,9 @@
 /* Special:AllMessages */
-#mw-allmessagestable .allmessages-customised .am_default {
+#mw-allmessagestable .am_default {
        background-color: #fcffc4;
 }
 
-#mw-allmessagestable .allmessages-customised:hover .am_default {
+#mw-allmessagestable tr:hover .am_default {
        background-color: #faff90;
 }
 
@@ -11,7 +11,7 @@
        background-color: #e2ffe2;
 }
 
-#mw-allmessagestable .allmessages-customised:hover + .allmessages-customised .am_actual {
+#mw-allmessagestable tr:hover + tr .am_actual {
        background-color: #b1ffb1;
 }