From d8cc67eab1f138d52196f2ff835a56e28db88a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 29 Sep 2021 09:14:48 +0200 Subject: [PATCH] MOBILE-3103 iframe: Add fullscreen button on iframes header toolbar --- scripts/langindex.json | 2 + src/addons/mod/scorm/pages/player/player.html | 4 +- src/addons/mod/scorm/pages/player/player.ts | 48 ++++++----------- src/core/components/iframe/core-iframe.html | 9 ++++ src/core/components/iframe/iframe.scss | 11 ++++ src/core/components/iframe/iframe.ts | 51 ++++++++++++++++--- src/core/lang.json | 2 + src/theme/theme.base.scss | 40 +++++++++++++++ src/theme/theme.light.scss | 5 ++ 9 files changed, 132 insertions(+), 40 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index 7c5324cd9..054a60d65 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1574,6 +1574,7 @@ "core.dftimedate": "local_moodlemobileapp", "core.digitalminor": "moodle", "core.digitalminor_desc": "moodle", + "core.disablefullscreen": "h5p", "core.discard": "local_moodlemobileapp", "core.dismiss": "local_moodlemobileapp", "core.displayoptions": "atto_media", @@ -1657,6 +1658,7 @@ "core.forcepasswordchangenotice": "moodle", "core.fulllistofcourses": "moodle", "core.fullnameandsitename": "local_moodlemobileapp", + "core.fullscreen": "h5p", "core.grades.aggregatemean": "grades", "core.grades.aggregatesum": "grades", "core.grades.average": "grades", diff --git a/src/addons/mod/scorm/pages/player/player.html b/src/addons/mod/scorm/pages/player/player.html index 5bf9e6959..a2074e95b 100644 --- a/src/addons/mod/scorm/pages/player/player.html +++ b/src/addons/mod/scorm/pages/player/player.html @@ -21,7 +21,9 @@ - + +

{{ errorMessage | translate }}

diff --git a/src/addons/mod/scorm/pages/player/player.ts b/src/addons/mod/scorm/pages/player/player.ts index 74bf853c9..ad6555c82 100644 --- a/src/addons/mod/scorm/pages/player/player.ts +++ b/src/addons/mod/scorm/pages/player/player.ts @@ -66,7 +66,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { protected moduleUrl!: string; // Module URL. protected newAttempt = false; // Whether to start a new attempt. protected organizationId?: string; // Organization ID to load. - protected attempt?: number; // The attempt number. + protected attempt = 0; // The attempt number. protected offline = false; // Whether it's offline mode. protected userData?: AddonModScormUserDataMap; // User data. protected initialScoId?: number; // Initial SCO ID to load. @@ -96,7 +96,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.newAttempt = !!CoreNavigator.getRouteBooleanParam('newAttempt'); this.organizationId = CoreNavigator.getRouteParam('organizationId'); this.initialScoId = CoreNavigator.getRouteNumberParam('scoId'); - this.siteId = CoreSites.getCurrentSiteId(); + this.siteId = CoreSites.getRequiredCurrentSite().getId(); } catch (error) { CoreDomUtils.showErrorModal(error); @@ -150,14 +150,12 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.showToc = AddonModScorm.displayTocInPlayer(this.scorm); if (this.scorm.popup) { - this.mainMenuPage.changeVisibility(false); - // If we receive a value > 100 we assume it's a fixed pixel size. - if (this.scorm.width! > 100) { + if (this.scorm.width && this.scorm.width > 100) { this.scormWidth = this.scorm.width; // Only get fixed size on height if width is also fixed. - if (this.scorm.height! > 100) { + if (this.scorm.height && this.scorm.height > 100) { this.scormHeight = this.scorm.height; } } @@ -198,7 +196,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { // Wait a bit to prevent collisions between this store and SCORM API's store. setTimeout(async () => { try { - AddonModScormHelper.convertAttemptToOffline(this.scorm, this.attempt!); + AddonModScormHelper.convertAttemptToOffline(this.scorm, this.attempt); } catch (error) { CoreDomUtils.instance.showErrorModalDefault(error, 'core.error', true); } @@ -292,7 +290,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { await this.determineAttemptAndMode(attemptsData); const [data, accessInfo] = await Promise.all([ - AddonModScorm.getScormUserData(this.scorm.id, this.attempt!, { + AddonModScorm.getScormUserData(this.scorm.id, this.attempt, { cmId: this.cmId, offline: this.offline, }), @@ -319,13 +317,13 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { try { // We need to check incomplete again: attempt number or status might have changed. - this.incomplete = await AddonModScorm.isAttemptIncomplete(this.scorm.id, this.attempt!, { + this.incomplete = await AddonModScorm.isAttemptIncomplete(this.scorm.id, this.attempt, { offline: this.offline, cmId: this.cmId, }); // Get TOC. - this.toc = await AddonModScormHelper.getToc(this.scorm.id, this.attempt!, this.incomplete, { + this.toc = await AddonModScormHelper.getToc(this.scorm.id, this.attempt, this.incomplete, { organization: this.organizationId, offline: this.offline, cmId: this.cmId, @@ -351,7 +349,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { } // No SCO defined. Get the first valid one. - const sco = await AddonModScormHelper.getFirstSco(this.scorm.id, this.attempt!, { + const sco = await AddonModScormHelper.getFirstSco(this.scorm.id, this.attempt, { toc: this.toc, organization: this.organizationId, mode: this.mode, @@ -383,7 +381,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.siteId, this.scorm, sco.id, - this.attempt!, + this.attempt, this.userData!, this.mode, this.offline, @@ -446,14 +444,14 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { }]; try { - AddonModScorm.saveTracks(sco.id, this.attempt!, tracks, this.scorm, this.offline); + AddonModScorm.saveTracks(sco.id, this.attempt, tracks, this.scorm, this.offline); } catch { // Error saving data. Go offline if needed. if (this.offline) { return; } - const data = await AddonModScorm.getScormUserData(this.scorm.id, this.attempt!, { + const data = await AddonModScorm.getScormUserData(this.scorm.id, this.attempt, { cmId: this.cmId, }); @@ -464,12 +462,12 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { try { // Go offline. - await AddonModScormHelper.convertAttemptToOffline(this.scorm, this.attempt!); + await AddonModScormHelper.convertAttemptToOffline(this.scorm, this.attempt); this.offline = true; this.dataModel?.setOffline(true); - await AddonModScorm.saveTracks(sco.id, this.attempt!, tracks, this.scorm, true); + await AddonModScorm.saveTracks(sco.id, this.attempt, tracks, this.scorm, true); } catch (error) { CoreDomUtils.instance.showErrorModalDefault(error, 'core.error', true); } @@ -528,7 +526,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { value: String(CoreTimeUtils.timestamp()), }]; - await AddonModScorm.saveTracks(scoId, this.attempt!, tracks, this.scorm, this.offline); + await AddonModScorm.saveTracks(scoId, this.attempt, tracks, this.scorm, this.offline); if (this.offline) { return; @@ -541,22 +539,6 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { })); } - /** - * @inheritdoc - */ - ionViewDidEnter(): void { - if (this.scorm && this.scorm.popup) { - this.mainMenuPage.changeVisibility(false); - } - } - - /** - * @inheritdoc - */ - ionViewWillLeave(): void { - this.mainMenuPage.changeVisibility(true); - } - /** * Component being destroyed. */ diff --git a/src/core/components/iframe/core-iframe.html b/src/core/components/iframe/core-iframe.html index ca6c2ecce..a3dbdfae0 100644 --- a/src/core/components/iframe/core-iframe.html +++ b/src/core/components/iframe/core-iframe.html @@ -1,4 +1,13 @@
+ + + + + + + +