MDL-57446 block_myoverview: add event list by course module
authorSimey Lameze <simey@moodle.com>
Tue, 14 Feb 2017 03:38:07 +0000 (11:38 +0800)
committerDamyon Wiese <damyon@moodle.com>
Mon, 3 Apr 2017 03:35:38 +0000 (11:35 +0800)
Part of MDL-55611 epic.

blocks/myoverview/amd/build/event_list_by_course.min.js [new file with mode: 0644]
blocks/myoverview/amd/src/event_list_by_course.js [new file with mode: 0644]

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 (file)
index 0000000..cf0f493
Binary files /dev/null and b/blocks/myoverview/amd/build/event_list_by_course.min.js differ
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 (file)
index 0000000..151e178
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+/**
+ * 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 <simey@moodle.com>
+ * @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);
+        }
+    };
+});