diff --git a/src/addon/calendar/pages/list/list.html b/src/addon/calendar/pages/list/list.html index 5b8dfd808..bba5d8fa7 100644 --- a/src/addon/calendar/pages/list/list.html +++ b/src/addon/calendar/pages/list/list.html @@ -29,9 +29,12 @@ - - - +
+ + + + +
\ No newline at end of file diff --git a/src/addon/messages/pages/discussion/discussion.html b/src/addon/messages/pages/discussion/discussion.html index 89bd5a6be..9d33ba0fd 100644 --- a/src/addon/messages/pages/discussion/discussion.html +++ b/src/addon/messages/pages/discussion/discussion.html @@ -15,9 +15,12 @@ - - - +
+ + + + +
diff --git a/src/addon/mod/forum/components/index/addon-mod-forum-index.html b/src/addon/mod/forum/components/index/addon-mod-forum-index.html index 8d88b2378..a9fde4ef3 100644 --- a/src/addon/mod/forum/components/index/addon-mod-forum-index.html +++ b/src/addon/mod/forum/components/index/addon-mod-forum-index.html @@ -88,9 +88,12 @@ - - - +
+ + + + +
diff --git a/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html b/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html index 4ad1add14..266a22449 100644 --- a/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html +++ b/src/addon/mod/glossary/components/index/addon-mod-glossary-index.html @@ -56,9 +56,12 @@ - - - +
+ + + + +
diff --git a/src/addon/notifications/pages/list/list.html b/src/addon/notifications/pages/list/list.html index 05d17c75d..e1cd62ea5 100644 --- a/src/addon/notifications/pages/list/list.html +++ b/src/addon/notifications/pages/list/list.html @@ -32,8 +32,11 @@ - - - +
+ + + + +
diff --git a/src/core/course/components/format/core-course-format.html b/src/core/course/components/format/core-course-format.html index 56eedc8d8..621fc9f1e 100644 --- a/src/core/course/components/format/core-course-format.html +++ b/src/core/course/components/format/core-course-format.html @@ -44,10 +44,19 @@
- - + + + + + +
+ + + + +
diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index cd9a0bd00..65d5133c8 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -41,6 +41,8 @@ import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-comp templateUrl: 'core-course-format.html' }) export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { + static LOAD_MORE_ACTIVITIES = 20; // How many activities should load each time showMoreActivities is called. + @Input() course: any; // The course to render. @Input() sections: any[]; // List of course sections. @Input() downloadEnabled?: boolean; // Whether the download of sections and modules is enabled. @@ -57,6 +59,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { sectionSelectorComponent: any; singleSectionComponent: any; allSectionsComponent: any; + canLoadMore = false; + showSectionId = 0; // Data to pass to the components. data: any = {}; @@ -273,6 +277,9 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { } else { this.previousSection = null; this.nextSection = null; + this.canLoadMore = false; + this.showSectionId = 0; + this.showMoreActivities(); } if (this.moduleId && typeof previousValue == 'undefined') { @@ -363,6 +370,46 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { return Promise.all(promises); } + /** + * Show more activities (only used when showing all the sections at the same time). + * + * @return {Promise} Resolved when done to change infinite loading status. + */ + showMoreActivities(): Promise { + this.canLoadMore = false; + + let modulesLoaded = 0, + i; + for (i = this.showSectionId + 1; i < this.sections.length; i++) { + if (this.sections[i].hasContent && this.sections[i].modules) { + modulesLoaded += this.sections[i].modules.reduce((total, module) => { + return module.visibleoncoursepage !== 0 ? total + 1 : total; + }, 0); + + if (modulesLoaded >= CoreCourseFormatComponent.LOAD_MORE_ACTIVITIES) { + this.showSectionId = i; + break; + } + } + } + + this.canLoadMore = i < this.sections.length; + + if (this.canLoadMore) { + // Check if any of the following sections have any content. + let thereAreMore = false; + for (i++; i < this.sections.length; i++) { + if (this.sections[i].hasContent && this.sections[i].modules) { + thereAreMore = true; + break; + } + } + this.canLoadMore = thereAreMore; + } + + return Promise.resolve(); + } + /** * Component destroyed. */ diff --git a/src/core/courses/pages/search/search.html b/src/core/courses/pages/search/search.html index 875eb16fb..d9018b556 100644 --- a/src/core/courses/pages/search/search.html +++ b/src/core/courses/pages/search/search.html @@ -10,9 +10,12 @@ {{ 'core.courses.totalcoursesearchresults' | translate:{$a: total} }} - - - +
+ + + + +
diff --git a/src/core/user/components/participants/core-user-participants.html b/src/core/user/components/participants/core-user-participants.html index 266a79210..8000e1abe 100644 --- a/src/core/user/components/participants/core-user-participants.html +++ b/src/core/user/components/participants/core-user-participants.html @@ -17,9 +17,12 @@ - - - +
+ + + + +
\ No newline at end of file