diff --git a/scripts/langindex.json b/scripts/langindex.json
index 339c56c5a..195114a07 100644
--- a/scripts/langindex.json
+++ b/scripts/langindex.json
@@ -426,6 +426,8 @@
"addon.mod_assign_submission_onlinetext.wordlimitexceeded": "assignsubmission_onlinetext",
"addon.mod_book.errorchapter": "book",
"addon.mod_book.modulenameplural": "book",
+ "addon.mod_book.navnexttitle": "book",
+ "addon.mod_book.navprevtitle": "book",
"addon.mod_book.tagarea_book_chapters": "book",
"addon.mod_book.toc": "book",
"addon.mod_chat.beep": "chat",
diff --git a/src/addon/mod/book/components/index/addon-mod-book-index.html b/src/addon/mod/book/components/index/addon-mod-book-index.html
index 6bb6c36d1..6fcc9f70d 100644
--- a/src/addon/mod/book/components/index/addon-mod-book-index.html
+++ b/src/addon/mod/book/components/index/addon-mod-book-index.html
@@ -19,13 +19,13 @@
-
0 && previousChapter" [next]="nextChapter > 0 && nextChapter" (action)="changeChapter($event)">
+
0">
{{ 'core.tag.tags' | translate }}:
-
0 && previousChapter" [next]="nextChapter > 0 && nextChapter" (action)="changeChapter($event)">
+
diff --git a/src/addon/mod/book/components/index/index.ts b/src/addon/mod/book/components/index/index.ts
index ae5e4f83d..50c69e8bd 100644
--- a/src/addon/mod/book/components/index/index.ts
+++ b/src/addon/mod/book/components/index/index.ts
@@ -17,7 +17,9 @@ import { Content, ModalController } from 'ionic-angular';
import { CoreAppProvider } from '@providers/app';
import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
-import { AddonModBookProvider, AddonModBookContentsMap, AddonModBookTocChapter, AddonModBookBook } from '../../providers/book';
+import {
+ AddonModBookProvider, AddonModBookContentsMap, AddonModBookTocChapter, AddonModBookBook, AddonModBookNavStyle
+} from '../../providers/book';
import { AddonModBookPrefetchHandler } from '../../providers/prefetch-handler';
import { CoreTagProvider } from '@core/tag/providers/tag';
@@ -33,14 +35,18 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
component = AddonModBookProvider.COMPONENT;
chapterContent: string;
- previousChapter: string;
- nextChapter: string;
+ previousChapter: AddonModBookTocChapter;
+ nextChapter: AddonModBookTocChapter;
tagsEnabled: boolean;
+ displayNavBar = true;
+ previousNavBarTitle: string;
+ nextNavBarTitle: string;
protected chapters: AddonModBookTocChapter[];
protected currentChapter: string;
protected contentsMap: AddonModBookContentsMap;
protected book: AddonModBookBook;
+ protected displayTitlesInNavBar = false;
constructor(injector: Injector, private bookProvider: AddonModBookProvider, private courseProvider: CoreCourseProvider,
private appProvider: CoreAppProvider, private prefetchDelegate: AddonModBookPrefetchHandler,
@@ -128,6 +134,8 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
this.book = book;
this.dataRetrieved.emit(book);
this.description = book.intro;
+ this.displayNavBar = book.navstyle != AddonModBookNavStyle.TOC_ONLY;
+ this.displayTitlesInNavBar = book.navstyle == AddonModBookNavStyle.TEXT;
}).catch(() => {
// Ignore errors since this WS isn't available in some Moodle versions.
}));
@@ -194,10 +202,15 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp
this.previousChapter = this.bookProvider.getPreviousChapter(this.chapters, chapterId);
this.nextChapter = this.bookProvider.getNextChapter(this.chapters, chapterId);
+ this.previousNavBarTitle = this.previousChapter && this.displayTitlesInNavBar ?
+ this.translate.instant('addon.mod_book.navprevtitle', {$a: this.previousChapter.title}) : '';
+ this.nextNavBarTitle = this.nextChapter && this.displayTitlesInNavBar ?
+ this.translate.instant('addon.mod_book.navnexttitle', {$a: this.nextChapter.title}) : '';
+
// Chapter loaded, log view. We don't return the promise because we don't want to block the user for this.
this.bookProvider.logView(this.module.instance, logChapterId ? chapterId : undefined, this.module.name).then(() => {
// Module is completed when last chapter is viewed, so we only check completion if the last is reached.
- if (this.nextChapter == '0') {
+ if (!this.nextChapter) {
this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata);
}
}).catch(() => {
diff --git a/src/addon/mod/book/lang/en.json b/src/addon/mod/book/lang/en.json
index 4f8f32f54..200e96ce1 100644
--- a/src/addon/mod/book/lang/en.json
+++ b/src/addon/mod/book/lang/en.json
@@ -1,6 +1,8 @@
{
"errorchapter": "Error reading chapter of book.",
"modulenameplural": "Books",
+ "navnexttitle": "Next: {{$a}}",
+ "navprevtitle": "Previous: {{$a}}",
"tagarea_book_chapters": "Book chapters",
"toc": "Table of contents"
}
\ No newline at end of file
diff --git a/src/addon/mod/book/providers/book.ts b/src/addon/mod/book/providers/book.ts
index dde84439e..95d3264fd 100644
--- a/src/addon/mod/book/providers/book.ts
+++ b/src/addon/mod/book/providers/book.ts
@@ -36,6 +36,15 @@ export const enum AddonModBookNumbering {
INDENTED = 3,
}
+/**
+ * Constants to define the navigation style used within a book.
+ */
+export const enum AddonModBookNavStyle {
+ TOC_ONLY = 0,
+ IMAGE = 1,
+ TEXT = 2,
+}
+
/**
* Service that provides some features for books.
*/
@@ -225,15 +234,15 @@ export class AddonModBookProvider {
*
* @param chapters The chapters list.
* @param chapterId The current chapter.
- * @return The next chapter id.
+ * @return The next chapter.
*/
- getNextChapter(chapters: AddonModBookTocChapter[], chapterId: string): string {
- let next = '0';
+ getNextChapter(chapters: AddonModBookTocChapter[], chapterId: string): AddonModBookTocChapter {
+ let next: AddonModBookTocChapter;
for (let i = 0; i < chapters.length; i++) {
if (chapters[i].id == chapterId) {
if (typeof chapters[i + 1] != 'undefined') {
- next = chapters[i + 1].id;
+ next = chapters[i + 1];
break;
}
}
@@ -247,16 +256,16 @@ export class AddonModBookProvider {
*
* @param chapters The chapters list.
* @param chapterId The current chapter.
- * @return The next chapter id.
+ * @return The next chapter.
*/
- getPreviousChapter(chapters: AddonModBookTocChapter[], chapterId: string): string {
- let previous = '0';
+ getPreviousChapter(chapters: AddonModBookTocChapter[], chapterId: string): AddonModBookTocChapter {
+ let previous: AddonModBookTocChapter;
for (let i = 0; i < chapters.length; i++) {
if (chapters[i].id == chapterId) {
break;
}
- previous = chapters[i].id;
+ previous = chapters[i];
}
return previous;
diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json
index d3f4ff056..61bd7973e 100644
--- a/src/assets/lang/en.json
+++ b/src/assets/lang/en.json
@@ -426,6 +426,8 @@
"addon.mod_assign_submission_onlinetext.wordlimitexceeded": "The word limit for this assignment is {{$a.limit}} words and you are attempting to submit {{$a.count}} words. Please review your submission and try again.",
"addon.mod_book.errorchapter": "Error reading chapter of book.",
"addon.mod_book.modulenameplural": "Books",
+ "addon.mod_book.navnexttitle": "Next: {{$a}}",
+ "addon.mod_book.navprevtitle": "Previous: {{$a}}",
"addon.mod_book.tagarea_book_chapters": "Book chapters",
"addon.mod_book.toc": "Table of contents",
"addon.mod_chat.beep": "Beep",
diff --git a/src/components/navigation-bar/core-navigation-bar.html b/src/components/navigation-bar/core-navigation-bar.html
index 4a7c211d3..47bc813a0 100644
--- a/src/components/navigation-bar/core-navigation-bar.html
+++ b/src/components/navigation-bar/core-navigation-bar.html
@@ -1,17 +1,19 @@
-
+
-
-
+
+
+
-
+
-
-
+
+
+
diff --git a/src/components/navigation-bar/navigation-bar.scss b/src/components/navigation-bar/navigation-bar.scss
new file mode 100644
index 000000000..4a6590802
--- /dev/null
+++ b/src/components/navigation-bar/navigation-bar.scss
@@ -0,0 +1,11 @@
+ion-app.app-root core-navigation-bar {
+ .core-navigation-bar-arrow {
+ text-transform: none;
+ max-width: 100%;
+
+ core-format-text {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ }
+}
diff --git a/src/components/navigation-bar/navigation-bar.ts b/src/components/navigation-bar/navigation-bar.ts
index 2942e5c2d..c19aad5ac 100644
--- a/src/components/navigation-bar/navigation-bar.ts
+++ b/src/components/navigation-bar/navigation-bar.ts
@@ -30,7 +30,9 @@ import { CoreTextUtilsProvider } from '@providers/utils/text';
})
export class CoreNavigationBarComponent {
@Input() previous?: any; // Previous item. If not defined, the previous arrow won't be shown.
+ @Input() previousTitle?: string; // Previous item title. If not defined, only the arrow will be shown.
@Input() next?: any; // Next item. If not defined, the next arrow won't be shown.
+ @Input() nextTitle?: string; // Next item title. If not defined, only the arrow will be shown.
@Input() info?: string; // Info to show when clicking the info button. If not defined, the info button won't be shown.
@Input() title?: string; // Title to show when seeing the info (new page).
@Input() component?: string; // Component the bar belongs to.