1 // This file is part of Moodle - http://moodle.org/
3 // Moodle is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // Moodle is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 * Manage the timeline dates view for the timeline block.
19 * @package block_timeline
20 * @copyright 2018 Ryan Wyllie <ryan@moodle.com>
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 'block_timeline/event_list'
37 EVENT_LIST_CONTAINER: '[data-region="event-list-container"]',
41 * Initialise the event list and being loading the events.
43 * @param {object} root The root element for the timeline dates view.
45 var load = function(root) {
46 var eventListContainer = root.find(SELECTORS.EVENT_LIST_CONTAINER);
47 Str.get_string('ariaeventlistpaginationnavdates', 'block_timeline')
48 .then(function(string) {
49 EventList.init(eventListContainer, [5, 10, 25], {}, string);
53 // Ignore if we can't load the string. Still init the event list.
54 EventList.init(eventListContainer, [5, 10, 25]);
59 * Initialise the timeline dates view. Begin loading the events
60 * if this view is active.
62 * @param {object} root The root element for the timeline courses view.
64 var init = function(root) {
66 if (root.hasClass('active')) {
68 root.attr('data-seen', true);
73 * Reset the view back to it's initial state. If this view is active then
74 * beging loading the events.
76 * @param {object} root The root element for the timeline courses view.
78 var reset = function(root) {
79 root.removeAttr('data-seen');
80 if (root.hasClass('active')) {
82 root.attr('data-seen', true);
87 * Load the events if this is the first time the view is displayed.
89 * @param {object} root The root element for the timeline courses view.
91 var shown = function(root) {
92 if (!root.attr('data-seen')) {
94 root.attr('data-seen', true);