From 42cf09b5b4ff3afb4d38010849ab0e2dbc37abcf Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Wed, 10 Jun 2020 23:18:10 +0800 Subject: [PATCH] MDL-69008 core: Fix accessibility issues in paged content templates * Added menuitem role for the "Show x per page" menu. * Added appropriate aria-labels for the links in the paging bar. --- lang/en/moodle.php | 4 ++ lib/templates/paged_content.mustache | 48 ++++++++++++++++++- .../paged_content_paging_bar.mustache | 24 +++++++--- .../paged_content_paging_bar_item.mustache | 2 +- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/lang/en/moodle.php b/lang/en/moodle.php index ad8402c3cd0..9a5a8ef353b 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -841,6 +841,7 @@ $string['first'] = 'First'; $string['firstaccess'] = 'First access'; $string['firstname'] = 'First name'; $string['firstnamephonetic'] = 'First name - phonetic'; +$string['firstpage'] = 'First page'; $string['firstsiteaccess'] = 'First access to site'; $string['firsttime'] = 'Is this your first time here?'; $string['folder'] = 'Folder'; @@ -1114,6 +1115,7 @@ $string['lastlogin'] = 'Last login'; $string['lastmodified'] = 'Last modified'; $string['lastname'] = 'Surname'; $string['lastnamephonetic'] = 'Surname - phonetic'; +$string['lastpage'] = 'Last page'; $string['lastsiteaccess'] = 'Last access to site'; $string['lastyear'] = 'Last year'; $string['latestlanguagepack'] = 'Check for latest language pack on moodle.org'; @@ -1396,6 +1398,7 @@ Cheers from the \'{$a->sitename}\' administrator, $string['newusers'] = 'New users'; $string['newwindow'] = 'New window'; $string['next'] = 'Next'; +$string['nextpage'] = 'Next page'; $string['nextsection'] = 'Next section'; $string['no'] = 'No'; $string['noblockstoaddhere'] = 'There are no blocks that you can add to this page.'; @@ -1578,6 +1581,7 @@ $string['preview'] = 'Preview'; $string['previeworchoose'] = 'Preview or choose a theme'; $string['previous'] = 'Previous'; $string['previouslyselectedusers'] = 'Previously selected users not matching \'{$a}\''; +$string['previouspage'] = 'Previous page'; $string['previoussection'] = 'Previous section'; $string['primaryadminsetup'] = 'Setup administrator account'; $string['privacy:metadata:config_log'] = 'The log of configuration changes.'; diff --git a/lib/templates/paged_content.mustache b/lib/templates/paged_content.mustache index c1b7202744a..4111ea88fdb 100644 --- a/lib/templates/paged_content.mustache +++ b/lib/templates/paged_content.mustache @@ -23,11 +23,17 @@ Example context (json): { "pagingbar": { - "itemsperpage": 1, + "showitemsperpageselector": true, + "itemsperpage": [ + { "value": 5, "active": false }, + { "value": 10, "active": true }, + { "value": 15, "active": false } + ], "previous": true, "next": true, "first": true, "last": true, + "barsize": 5, "pages": [ { "page": "1", @@ -36,6 +42,26 @@ { "url": "#", "page": "2" + }, + { + "url": "#", + "page": "3" + }, + { + "url": "#", + "page": "4" + }, + { + "url": "#", + "page": "5" + }, + { + "url": "#", + "page": "6" + }, + { + "url": "#", + "page": "7" } ] }, @@ -48,6 +74,26 @@ { "page": 2, "content": "

Some page 2 content

" + }, + { + "page": 3, + "content": "

Some page 3 content

" + }, + { + "page": 4, + "content": "

Some page 4 content

" + }, + { + "page": 5, + "content": "

Some page 5 content

" + }, + { + "page": 6, + "content": "

Some page 6 content

" + }, + { + "page": 7, + "content": "

Some page 7 content

" } ] } diff --git a/lib/templates/paged_content_paging_bar.mustache b/lib/templates/paged_content_paging_bar.mustache index b0b84f1afcf..f8af3579499 100644 --- a/lib/templates/paged_content_paging_bar.mustache +++ b/lib/templates/paged_content_paging_bar.mustache @@ -22,7 +22,12 @@ Example context (json): { - "itemsperpage": 2, + "showitemsperpageselector": true, + "itemsperpage": [ + { "value": 5, "active": false }, + { "value": 10, "active": true }, + { "value": 15, "active": false } + ], "previous": true, "next": true, "first": true, @@ -89,7 +94,8 @@ {{#value}}{{.}}{{/value}} @@ -149,6 +155,7 @@