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/>.
18 @template block_myoverview/courses-view
20 This template renders the courses view for the myoverview block.
22 Example context (json):
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 }}
40 'block_myoverview/paging_bar',
41 'block_myoverview/paging_content',
42 'block_myoverview/courses_view_repository'
44 function($, Templates, PagingBar, PagingContent, CoursesRepository) {
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');
54 return CoursesRepository.queryFromStatus(status, limit, offset)
55 .then(function(courses) {
56 return Templates.render('block_myoverview/course-paging-content-item', courses);
60 PagingBar.registerEventListeners(pagingBarElement);
61 var content = new PagingContent(pagingContentElement, pagingBarElement, loadContentCallback);
63 content.registerEventListeners();