Merge branch 'MDL-75910-311' of https://github.com/andrewnicols/moodle into MOODLE_31...
[moodle.git] / lib / templates / paging_bar.mustache
blob622285e7c10c91f363b6d9e4aac72b371a283751
1 {{!
2     This file is part of Moodle - http://moodle.org/
4     Moodle is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
9     Moodle is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
14     You should have received a copy of the GNU General Public License
15     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17 {{!
18     @template core/paging_bar
20     This template renders the horizontal bar with page links, e.g.
21         | « | 1 | 2 | 3 | » |
23     Example context (json):
24     {
25         "previous": null,
26         "next": {
27             "page": 2,
28             "url": "./page.php?p=1"
29         },
30         "first": null,
31         "last": {
32             "page": 100,
33             "url": "./page.php?p=99"
34         },
35         "label": "Page",
36         "pages": [
37             {
38                 "page": 1,
39                 "active": true,
40                 "url": null
41             },
42             {
43                 "page": 2,
44                 "active": false,
45                 "url": "./page.php?p=1"
46             }
47         ],
48         "haspages": true,
49         "pagesize": 10
50     }
52 {{#haspages}}
53     <nav aria-label="{{label}}" class="pagination pagination-centered justify-content-center">
54         <ul class="mt-1 pagination " data-page-size="{{pagesize}}">
55             {{#previous}}
56                 <li class="page-item" data-page-number="{{page}}">
57                     <a href="{{url}}" class="page-link" aria-label="{{# str }} previouspage, moodle {{/ str }}">
58                         <span aria-hidden="true">&laquo;</span>
59                         <span class="sr-only">{{#str}}previouspage, moodle{{/str}}</span>
60                     </a>
61                 </li>
62             {{/previous}}
63             {{#first}}
64                 <li class="page-item" data-page-number="{{page}}">
65                     <a href="{{url}}" class="page-link">{{page}}</a>
66                 </li>
67                 <li class="page-item disabled" data-page-number="{{page}}">
68                     <span class="page-link">&hellip;</span>
69                 </li>
70             {{/first}}
71             {{#pages}}
72                 <li class="page-item {{#active}}active{{/active}}" data-page-number="{{page}}">
73                     <a href="{{#url}}{{.}}{{/url}}{{^url}}#{{/url}}" class="page-link">
74                         {{page}}
75                         {{#active}}
76                             <span class="sr-only">{{#str}}currentinparentheses, theme_boost{{/str}}</span>
77                         {{/active}}
78                     </a>
79                 </li>
80             {{/pages}}
81             {{#last}}
82                 <li class="page-item disabled" data-page-number="{{page}}">
83                     <span class="page-link">&hellip;</span>
84                 </li>
85                 <li class="page-item" data-page-number="{{page}}">
86                     <a href="{{url}}" class="page-link">{{page}}</a>
87                 </li>
88             {{/last}}
89             {{#next}}
90                 <li class="page-item" data-page-number="{{page}}">
91                     <a href="{{url}}" class="page-link" aria-label="{{# str }} nextpage, moodle {{/ str }}">
92                         <span aria-hidden="true">&raquo;</span>
93                         <span class="sr-only">{{#str}}nextpage, moodle{{/str}}</span>
94                     </a>
95                 </li>
96             {{/next}}
97         </ul>
98     </nav>
99 {{/haspages}}