SpecialTags: Add <thead> and <tbody> in the sortable table
authorFomafix <fomafix@googlemail.com>
Sun, 30 Dec 2018 13:42:40 +0000 (14:42 +0100)
committerJforrester <jforrester@wikimedia.org>
Tue, 1 Jan 2019 13:51:10 +0000 (13:51 +0000)
This avoids that module 'jquery.tablesorter' has to add the elements.

With change I0b446d18f47428d8c0c4aed78b75de16fe106218 this also avoids
a flash of missing sorting buttons while loading.

Change-Id: If6368af27606ebdb6f8d6e3bbe742706ec45e4e6

includes/specials/SpecialTags.php

index fd2d46a..fe8fa19 100644 (file)
@@ -136,7 +136,7 @@ class SpecialTags extends SpecialPage {
                }
 
                // Write the headers
-               $html = Xml::tags( 'tr', null, Xml::tags( 'th', null, $this->msg( 'tags-tag' )->parse() ) .
+               $thead = Xml::tags( 'tr', null, Xml::tags( 'th', null, $this->msg( 'tags-tag' )->parse() ) .
                        Xml::tags( 'th', null, $this->msg( 'tags-display-header' )->parse() ) .
                        Xml::tags( 'th', null, $this->msg( 'tags-description-header' )->parse() ) .
                        Xml::tags( 'th', null, $this->msg( 'tags-source-header' )->parse() ) .
@@ -148,26 +148,28 @@ class SpecialTags extends SpecialPage {
                                '' )
                );
 
+               $tbody = '';
                // Used in #doTagRow()
                $this->softwareActivatedTags = array_fill_keys(
                        ChangeTags::listSoftwareActivatedTags(), true );
 
                // Insert tags that have been applied at least once
                foreach ( $tagStats as $tag => $hitcount ) {
-                       $html .= $this->doTagRow( $tag, $hitcount, $userCanManage,
+                       $tbody .= $this->doTagRow( $tag, $hitcount, $userCanManage,
                                $userCanDelete, $userCanEditInterface );
                }
                // Insert tags defined somewhere but never applied
                foreach ( $definedTags as $tag ) {
                        if ( !isset( $tagStats[$tag] ) ) {
-                               $html .= $this->doTagRow( $tag, 0, $userCanManage, $userCanDelete, $userCanEditInterface );
+                               $tbody .= $this->doTagRow( $tag, 0, $userCanManage, $userCanDelete, $userCanEditInterface );
                        }
                }
 
                $out->addHTML( Xml::tags(
                        'table',
                        [ 'class' => 'mw-datatable sortable mw-tags-table' ],
-                       $html
+                       Xml::tags( 'thead', null, $thead ) .
+                       Xml::tags( 'tbody', null, $tbody )
                ) );
        }