diff --git a/js/h5p.js b/js/h5p.js
index d95dfe4..d53f8e2 100644
--- a/js/h5p.js
+++ b/js/h5p.js
@@ -73,12 +73,12 @@ H5P.init = function () {
window.location.href = contentData.exportUrl;
});
}
- if (instance.getCopyrights !== undefined) {
- // Display copyrights button
- H5P.jQuery('
' + H5P.t('copyrights') + '').appendTo($actions).click(function () {
- H5P.openCopyrightsDialog($actions, instance);
- });
- }
+
+ // Display copyrights button
+ H5P.jQuery('' + H5P.t('copyrights') + '').appendTo($actions).click(function () {
+ H5P.openCopyrightsDialog($actions, instance, library.params, contentId);
+ });
+
if (contentData.embedCode !== undefined) {
// Display embed button
H5P.jQuery('' + H5P.t('embed') + '').appendTo($actions).click(function () {
@@ -495,19 +495,77 @@ H5P.Dialog = function (name, title, content, $element) {
* @param {object} instance to get copyright information from.
* @returns {undefined}
*/
-H5P.openCopyrightsDialog = function ($element, instance) {
- var copyrights = instance.getCopyrights();
+H5P.openCopyrightsDialog = function ($element, instance, parameters, contentId) {
+ var copyrights;
+ if (instance.getCopyrights !== undefined) {
+ // Use the instance's own copyright generator
+ copyrights = instance.getCopyrights();
+ }
+ else {
+ // Create a generic flat copyright list
+ copyrights = new H5P.ContentCopyrights();
+ H5P.findCopyrights(copyrights, parameters, contentId);
+ }
+
if (copyrights !== undefined) {
+ // Convert to string
copyrights = copyrights.toString();
}
if (copyrights === undefined || copyrights === '') {
+ // Use no copyrights default text
copyrights = H5P.t('noCopyrights');
}
+ // Open dialog with copyright information
var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $element);
dialog.open();
};
+/**
+ * Gather a flat list of copyright information from the given parameters.
+ *
+ * @param {H5P.ContentCopyrights} info Used to collect all information in.
+ * @param {(Object|Arrray)} parameters To search for file objects in.
+ * @param {Number} contentId Used to insert thumbnails for images.
+ * @returns {undefined}
+ */
+H5P.findCopyrights = function (info, parameters, contentId) {
+ // Cycle through parameters
+ for (var field in parameters) {
+ if (!parameters.hasOwnProperty(field)) {
+ continue; // Do not check
+ }
+ var value = parameters[field];
+
+ if (value instanceof Array) {
+ // Cycle through array
+ H5P.findCopyrights(info, value, contentId);
+ }
+ else if (value instanceof Object) {
+ // Check if object is a file with copyrights
+ if (value.copyright === undefined ||
+ value.copyright.license === undefined ||
+ value.path === undefined ||
+ value.mime === undefined) {
+
+ // Nope, cycle throught object
+ H5P.findCopyrights(info, value, contentId);
+ }
+ else {
+ // Found file, add copyrights
+ var copyrights = new H5P.MediaCopyright(value.copyright);
+ if (value.width !== undefined && value.height !== undefined) {
+ copyrights.setThumbnail(new H5P.Thumbnail(H5P.getPath(value.path, contentId), value.width, value.height));
+ }
+ info.addMedia(copyrights);
+ }
+ }
+ else {
+ }
+ }
+};
+
+
/**
* Display a dialog containing the embed code.
*
diff --git a/styles/h5p.css b/styles/h5p.css
index c9099c6..3ceb8e8 100644
--- a/styles/h5p.css
+++ b/styles/h5p.css
@@ -234,6 +234,8 @@ div.h5p-fullscreen {
font-size: 1.5em;
margin: 0.25em 0;
position: absolute;
+ line-height: 1.25em;
+ padding: 0;
}
.h5p-embed-dialog .h5p-inner {
width: 50%;
@@ -322,4 +324,4 @@ div.h5p-fullscreen {
padding-left: 38px;
min-height: 30px;
line-height: 30px;
-}
\ No newline at end of file
+}