diff --git a/js/h5p.js b/js/h5p.js
index 9b38d5e..b8a09e0 100644
--- a/js/h5p.js
+++ b/js/h5p.js
@@ -130,7 +130,8 @@ H5P.init = function (target) {
window.location.href = contentData.exportUrl;
});
}
- if (!(contentData.disable & H5P.DISABLE_COPYRIGHT) && instance.getCopyrights !== undefined) {
+ if (!(contentData.disable & H5P.DISABLE_COPYRIGHT) &&
+ ((instance.getCopyrights !== undefined) || H5P.hasCopyrights(library.params, contentId))) {
// Add copyrights button
H5P.jQuery('
' + H5P.t('copyrights') + '').appendTo($actions).click(function () {
H5P.openCopyrightsDialog($actions, instance, library.params, contentId);
@@ -883,6 +884,47 @@ H5P.findCopyrights = function (info, parameters, contentId) {
}
};
+/**
+ * Recursive function for checking if content has copyrights
+ *
+ * @param {(Object|Arrray)} parameters To search for file objects in.
+ * @param {Number} contentId Used to insert thumbnails for images.
+ * @returns {boolean} Returns true if complete copyright information was found.
+ */
+H5P.hasCopyrights = function (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
+ if (H5P.hasCopyrights(value, contentId)) {
+ return true;
+ }
+ }
+ 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
+ if (H5P.hasCopyrights(value, contentId)) {
+ return true;
+ }
+ }
+ else {
+ // Found file, return true
+ return true;
+ }
+ }
+ }
+ return false;
+};
/**
* Display a dialog containing the embed code.