Template:Circa/doc/sortable

From Nordic Larp Wiki
Jump to navigation Jump to search

If the parameter "sortable=yes" is specified, the template generates invisible text that will cause the output to work in sortable tables, at the cost of causing problems for visually-impaired readers. Compare "Col 1" and "Col 2" in the following table:

Title Col 1 Col 2
Foo 1066 1066
Bar c. 1510 1510 c. 1510
Baz 1956 1956
Jaz c. 410 0410 c. 410

"Col 1" uses {{Circa}} 1510, and does not sort correctly. "Col 2" uses {{Circa|1510|sortable=yes}}, and does sort correctly. This works because {{Circa|1510|sortable=yes}} inserts an invisible span element at the start of the cell: <span style="display:none;">1510</span>. Although it is not rendered, it is still seen by the sorting code and makes sorting work.

The downside of this approach is that the invisible text is still rendered by screen readers that are used by visually impaired readers, and by text browsers such as Lynx, so the table will become garbled for readers who are using assistive technology or text browsers.