https://bugzilla.wikimedia.org/show_bug.cgi?id=40618

--- Comment #12 from Bartosz DziewoƄski <matma....@gmail.com> ---
I've created a proof-of-concept implementation using the sortEnd.tablesorter
event $.tablesorter fires upon finishing sorting.

The code is essentially five lines:

$('table.sortable th.unsortable.ordinal').each(function(i, th) {
  var $th = $(th), $table = $th.closest('table');
  $table.on('sortEnd.tablesorter', function() {
    $table.find('tr td:nth-child('+ (th.column+1) +')').each(function(j, td) {
      $(td).text( (j+1) );
    });
  })
});

This means that for every column with class="unsortable ordinal" on the header
cell inside a table with class="sortable", the code will re-fill it with
consecutive numbers, starting at 1, when the table is sorted. This allows for
columns which contain ordinal numbers (the original use case).

The solution was discussed on pl.wikipedia's technical village pump[1][2] and
is currently live in its common.js[3]. It's used on a few pages already,
including the aforementioned [[pl:Miasta w Polsce (statystyki)]] and our help
page with a list of interwiki codes, [[pl:Pomoc:Interwiki]].

[1] [[pl:Wikipedia:Kawiarenka/Kwestie techniczne#Poprawa tabeli w Miasta w
Polsce (statystyki)]]
[2] [[pl:Wikipedia:Kawiarenka/Kwestie techniczne#Sortowanie tabeli]]
[3] [[pl:MediaWiki:Common.js]], at the very bottom

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to