diff --git a/blocks/myoverview/amd/build/event_list_by_course.min.js b/blocks/myoverview/amd/build/event_list_by_course.min.js new file mode 100644 index 00000000000..cf0f4933841 --- /dev/null +++ b/blocks/myoverview/amd/build/event_list_by_course.min.js @@ -0,0 +1 @@ +define(["jquery","block_myoverview/event_list"],function(a,b){var c={EVENTS_BY_COURSE_CONTAINER:'[data-region="course-events-container"]',EVENTS_LIST_CONTAINER:'[data-region="event-list-container"]'},d=function(d){d.find(c.EVENTS_BY_COURSE_CONTAINER).each(function(d,e){e=a(e);var f=e.find(c.EVENTS_LIST_CONTAINER);b.load(f)})};return{init:function(b){b=a(b),d(b)}}}); \ No newline at end of file diff --git a/blocks/myoverview/amd/src/event_list_by_course.js b/blocks/myoverview/amd/src/event_list_by_course.js new file mode 100644 index 00000000000..151e17896a3 --- /dev/null +++ b/blocks/myoverview/amd/src/event_list_by_course.js @@ -0,0 +1,52 @@ +// 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 . + +/** + * Javascript to load and render the list of calendar events grouping by course. + * + * @module block_myoverview/events_by_course_list + * @package block_myoverview + * @copyright 2016 Simey Lameze + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define(['jquery', 'block_myoverview/event_list'], function($, EventList) { + + var SELECTORS = { + EVENTS_BY_COURSE_CONTAINER: '[data-region="course-events-container"]', + EVENTS_LIST_CONTAINER: '[data-region="event-list-container"]' + }; + + /** + * Loop through course events containers and load calendar events for that course. + * + * @method load + * @param {Object} root The root element of sort by course list. + */ + var load = function(root) { + + root.find(SELECTORS.EVENTS_BY_COURSE_CONTAINER).each(function(index, container) { + container = $(container); + var eventListContainer = container.find(SELECTORS.EVENTS_LIST_CONTAINER); + EventList.load(eventListContainer); + }); + }; + + return { + init: function(root) { + root = $(root); + load(root); + } + }; +});