Skip to content

Commit

Permalink
Merge branch 'master' into feat/full_experience_opts
Browse files Browse the repository at this point in the history
  • Loading branch information
Murage authored Feb 11, 2022
2 parents 2741f95 + 14e6a79 commit e0988f6
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 @@ -200,6 +200,7 @@ export default class H5PStandalone {
scripts: scripts,
displayOptions: contentOptions.displayOptions,
contentUrl: this.contentUrl,
metadata: {}
};

for (const key in contentOptions) {
Expand All @@ -208,6 +209,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 @@ -352,13 +360,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 e0988f6

Please sign in to comment.