moodle/lib/templates/paged_content_paging_bar.mustache
2018-04-18 11:45:00 +08:00

98 lines
3.5 KiB
Plaintext

{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/paged_content_paging_bar
This template renders the bootstrap style paging bar to control a paged
content section.
Example context (json):
{
"itemsperpage": 2,
"previous": true,
"next": true,
"first": true,
"last": true,
"pages": [
{
"url": "#",
"page": "1",
"active": true
},
{
"url": "#",
"page": "2"
}
]
}
}}
<nav aria-label="{{label}}"
id="{{$pagingbarid}}paging-bar-{{uniqid}}{{/pagingbarid}}"
data-region="paging-bar"
data-items-per-page="{{itemsperpage}}">
<ul class="pagination">
{{#previous}}
{{< core/paged_content_paging_bar_item }}
{{$item-content}}
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">{{#str}}previous{{/str}}</span>
{{/item-content}}
{{$attributes}}data-control="previous"{{/attributes}}
{{/ core/paged_content_paging_bar_item }}
{{/previous}}
{{#first}}
{{< core/paged_content_paging_bar_item }}
{{$item-content}}
<span aria-hidden="true">{{#str}}first{{/str}}</span>
<span class="sr-only">{{#str}}first{{/str}}</span>
{{/item-content}}
{{$attributes}}data-control="first"{{/attributes}}
{{/ core/paged_content_paging_bar_item }}
{{/first}}
{{#pages}}
{{< core/paged_content_paging_bar_item }}
{{$attributes}}data-page="true"{{/attributes}}
{{/ core/paged_content_paging_bar_item }}
{{/pages}}
{{#last}}
{{< core/paged_content_paging_bar_item }}
{{$item-content}}
<span aria-hidden="true">{{#str}}last{{/str}}</span>
<span class="sr-only">{{#str}}last{{/str}}</span>
{{/item-content}}
{{$attributes}}data-control="last"{{/attributes}}
{{/ core/paged_content_paging_bar_item }}
{{/last}}
{{#next}}
{{< core/paged_content_paging_bar_item }}
{{$item-content}}
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">{{#str}}next{{/str}}</span>
{{/item-content}}
{{$attributes}}data-control="next"{{/attributes}}
{{/ core/paged_content_paging_bar_item }}
{{/next}}
</ul>
</nav>
{{#js}}
require(['jquery', 'core/paged_content_paging_bar'], function($, PagingControl) {
var root = $('#{{$pagingbarid}}paging-bar-{{uniqid}}{{/pagingbarid}}');
PagingControl.init(root);
});
{{/js}}