\ No newline at end of file
diff --git a/src/components/infinite-loading/infinite-loading.ts b/src/components/infinite-loading/infinite-loading.ts
new file mode 100644
index 000000000..7c7b3b4d6
--- /dev/null
+++ b/src/components/infinite-loading/infinite-loading.ts
@@ -0,0 +1,68 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, Input, Output, EventEmitter } from '@angular/core';
+import { InfiniteScroll } from 'ionic-angular';
+
+/**
+ * Component to show a infinite loading trigger and spinner while more data is being loaded.
+ *
+ * Usage:
+ *
+ */
+@Component({
+ selector: 'core-infinite-loading',
+ templateUrl: 'core-infinite-loading.html',
+})
+export class CoreInfiniteLoadingComponent {
+ @Input() enabled: boolean;
+ @Input() position = 'bottom';
+ @Output() action: EventEmitter<() => void>; // Will emit an event when triggered.
+
+ loadingMore = false; // Hide button and avoid loading more.
+
+ protected infiniteScroll: InfiniteScroll;
+
+ constructor() {
+ this.action = new EventEmitter();
+ }
+
+ /**
+ * Load More items calling the action provided.
+ *
+ * @param {InfiniteScroll} [infiniteScroll] Infinite scroll object only if triggered from the scroll.
+ */
+ loadMore(infiniteScroll?: InfiniteScroll): void {
+ if (this.loadingMore) {
+ return;
+ }
+
+ if (infiniteScroll) {
+ this.infiniteScroll = infiniteScroll;
+ }
+ this.loadingMore = true;
+
+ this.action.emit(this.complete.bind(this));
+ }
+
+ /**
+ * Complete loading.
+ */
+ complete(): void {
+ this.loadingMore = false;
+ this.infiniteScroll && this.infiniteScroll.complete();
+ this.infiniteScroll = undefined;
+ }
+
+}
diff --git a/src/core/course/components/format/core-course-format.html b/src/core/course/components/format/core-course-format.html
index 621fc9f1e..4b244729d 100644
--- a/src/core/course/components/format/core-course-format.html
+++ b/src/core/course/components/format/core-course-format.html
@@ -51,12 +51,7 @@
-
-
-
-
-
-
+
diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts
index 65d5133c8..37b239a6e 100644
--- a/src/core/course/components/format/format.ts
+++ b/src/core/course/components/format/format.ts
@@ -373,9 +373,9 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
/**
* Show more activities (only used when showing all the sections at the same time).
*
- * @return {Promise} Resolved when done to change infinite loading status.
+ * @param {any} [infiniteComplete] Infinite scroll complete function. Only used from core-infinite-loading.
*/
- showMoreActivities(): Promise {
+ showMoreActivities(infiniteComplete?: any): void {
this.canLoadMore = false;
let modulesLoaded = 0,
@@ -399,7 +399,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
// 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) {
+ if (this.sections[i].hasContent && this.sections[i].modules && this.sections[i].modules.length > 0) {
thereAreMore = true;
break;
}
@@ -407,7 +407,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
this.canLoadMore = thereAreMore;
}
- return Promise.resolve();
+ infiniteComplete && infiniteComplete();
}
/**
diff --git a/src/core/course/providers/default-format.ts b/src/core/course/providers/default-format.ts
index 146f44232..50ae2701c 100644
--- a/src/core/course/providers/default-format.ts
+++ b/src/core/course/providers/default-format.ts
@@ -16,7 +16,6 @@ import { Injectable } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CoreCoursesProvider } from '@core/courses/providers/courses';
import { CoreCourseFormatHandler } from './format-delegate';
-import { CoreCourseProvider } from './course';
/**
* Default handler used when the course format doesn't have a specific implementation.
diff --git a/src/core/courses/pages/search/search.html b/src/core/courses/pages/search/search.html
index d9018b556..0174eb683 100644
--- a/src/core/courses/pages/search/search.html
+++ b/src/core/courses/pages/search/search.html
@@ -10,12 +10,7 @@
{{ 'core.courses.totalcoursesearchresults' | translate:{$a: total} }}
-