MDL-64376 block_recentlyaccessedcourses: only centre courses on overflow
authorRyan Wyllie <ryan@ryanwyllie.com>
Thu, 28 Feb 2019 03:28:19 +0000 (11:28 +0800)
committerRyan Wyllie <ryan@ryanwyllie.com>
Thu, 28 Feb 2019 03:28:19 +0000 (11:28 +0800)
Only centre the courses in the div if they are overflowing the container
otherwise they should be left aligned.

blocks/recentlyaccessedcourses/amd/build/main.min.js
blocks/recentlyaccessedcourses/amd/src/main.js

index a5bf1e2..e76490a 100644 (file)
Binary files a/blocks/recentlyaccessedcourses/amd/build/main.min.js and b/blocks/recentlyaccessedcourses/amd/build/main.min.js differ
index 203b1a0..6a3ca16 100644 (file)
@@ -211,6 +211,15 @@ define(
                 return carry + course.attr('data-course-id');
             }, '');
 
+            // Centre the courses if we have an overflow of courses.
+            if (allCourses.length > coursesToShow.length) {
+                container.addClass('justify-content-center');
+                container.removeClass('justify-content-start');
+            } else {
+                container.removeClass('justify-content-center');
+                container.addClass('justify-content-start');
+            }
+
             // Don't bother updating the DOM unless the visible courses have changed.
             if (visibleCoursesId != newVisibleCoursesId) {
                 var pagingBar = root.find(PagedContentPagingBar.rootSelector);