Skip to content

Commit

Permalink
Merge pull request #102 from tunapanda/fix/interactive_book_bug
Browse files Browse the repository at this point in the history
fix: interactive book not working as expected
  • Loading branch information
Murage authored Feb 11, 2022
2 parents 13d5451 + f592ef3 commit 14e6a79
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/js/h5p-standalone.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class H5PStandalone {
contentOptions.exportUrl = urlPath(options.downloadUrl);
}

if (options.metadata) {
if (options.metadata) { // exposing content['id'].metadata key to allow overrides
contentOptions.metadata = options.metadata;
}

Expand Down Expand Up @@ -173,6 +173,7 @@ export default class H5PStandalone {
scripts: scripts,
displayOptions: contentOptions.displayOptions,
contentUrl: this.contentUrl,
metadata: {}
};

for (const key in contentOptions) {
Expand All @@ -181,6 +182,13 @@ export default class H5PStandalone {
}
}

// add missing content metadata from h5p.json
for (const key in this.h5p) {
if (H5PIntegration.contents[`cid-${this.id}`]?.['metadata']?.[key] === undefined) {
H5PIntegration.contents[`cid-${this.id}`]['metadata'][key] = this.h5p[key]
}
}

if (!generalIntegrationOptions.preventH5PInit) {
H5P.init();
}
Expand Down Expand Up @@ -325,13 +333,6 @@ export default class H5PStandalone {
Array.prototype.push.apply(scripts, JSDependencies[dependencyName]);
});

if (this.mainLibrary.preloadedCss) {
Array.prototype.push.apply(styles, this.mainLibrary.preloadedCss.map(style => `${this.librariesPath}/${this.mainLibraryPath}/${style.path}`));
}
if (this.mainLibrary.preloadedJs) {
Array.prototype.push.apply(scripts, this.mainLibrary.preloadedJs.map(script => `${this.librariesPath}/${this.mainLibraryPath}/${script.path}`));
}

// Append custom styles and scripts at the end to override original values
styles = styles.concat(customOptions.customCss);
scripts = scripts.concat(customOptions.customJs);
Expand Down

0 comments on commit 14e6a79

Please sign in to comment.