Commit | Line | Data |
---|---|---|
0fc7dbce SL |
1 | {{! |
2 | This file is part of Moodle - http://moodle.org/ | |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
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/>. | |
16 | }} | |
17 | {{! | |
18 | @template block_myoverview/courses-view | |
19 | ||
20 | This template renders the courses view for the myoverview block. | |
21 | ||
22 | Example context (json): | |
23 | {} | |
24 | }} | |
e8f4d954 RW |
25 | <div id data-limit="{{$limit}}6{{/limit}}" data-status="{{$status}}{{/status}}"> |
26 | {{< block_myoverview/course-paging-content }} | |
27 | {{$id}}paging-content-{{uniqid}}{{/id}} | |
28 | {{/ block_myoverview/course-paging-content }} | |
29 | <div class="text-xs-center text-center"> | |
30 | {{< block_myoverview/paging-bar }} | |
31 | {{$id}}paging-bar-{{uniqid}}{{/id}} | |
32 | {{/ block_myoverview/paging-bar }} | |
0fc7dbce | 33 | </div> |
e8f4d954 | 34 | </div> |
0fc7dbce | 35 | {{#js}} |
e8f4d954 RW |
36 | require( |
37 | [ | |
38 | 'jquery', | |
39 | 'core/templates', | |
40 | 'block_myoverview/paging_bar', | |
41 | 'block_myoverview/paging_content', | |
42 | 'block_myoverview/courses_view_repository' | |
43 | ], | |
44 | function($, Templates, PagingBar, PagingContent, CoursesRepository) { | |
0fc7dbce | 45 | |
e8f4d954 RW |
46 | var root = $(); |
47 | var pagingBarElement = $('paging-bar-{{uniqid}}'); | |
48 | var pagingContentElement = $('paging-content-{{uniqid}}'); | |
49 | var loadContentCallback = function(pageNumber) { | |
50 | var limit = root.attr('data-limit'); | |
51 | var offset = (pageNumber - 1) * limit; | |
52 | var status = root.attr('data-status'); | |
53 | ||
54 | return CoursesRepository.queryFromStatus(status, limit, offset) | |
55 | .then(function(courses) { | |
56 | return Templates.render('block_myoverview/course-paging-content-item', courses); | |
57 | }) | |
58 | }; | |
59 | ||
60 | PagingBar.registerEventListeners(pagingBarElement); | |
61 | var content = new PagingContent(pagingContentElement, pagingBarElement, loadContentCallback); | |
62 | ||
63 | content.registerEventListeners(); | |
0fc7dbce SL |
64 | }); |
65 | {{/js}} |