Merge branch 'flat-copyrights'
commit
fa402916d5
68
js/h5p.js
68
js/h5p.js
|
@ -73,12 +73,12 @@ H5P.init = function () {
|
||||||
window.location.href = contentData.exportUrl;
|
window.location.href = contentData.exportUrl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (instance.getCopyrights !== undefined) {
|
|
||||||
// Display copyrights button
|
// Display copyrights button
|
||||||
H5P.jQuery('<li class="h5p-button h5p-copyrights" role="button" tabindex="1" title="' + H5P.t('copyrightsDescription') + '">' + H5P.t('copyrights') + '</li>').appendTo($actions).click(function () {
|
H5P.jQuery('<li class="h5p-button h5p-copyrights" role="button" tabindex="1" title="' + H5P.t('copyrightsDescription') + '">' + H5P.t('copyrights') + '</li>').appendTo($actions).click(function () {
|
||||||
H5P.openCopyrightsDialog($actions, instance);
|
H5P.openCopyrightsDialog($actions, instance, library.params, contentId);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (contentData.embedCode !== undefined) {
|
if (contentData.embedCode !== undefined) {
|
||||||
// Display embed button
|
// Display embed button
|
||||||
H5P.jQuery('<li class="h5p-button h5p-embed" role="button" tabindex="1" title="' + H5P.t('embedDescription') + '">' + H5P.t('embed') + '</li>').appendTo($actions).click(function () {
|
H5P.jQuery('<li class="h5p-button h5p-embed" role="button" tabindex="1" title="' + H5P.t('embedDescription') + '">' + H5P.t('embed') + '</li>').appendTo($actions).click(function () {
|
||||||
|
@ -495,19 +495,77 @@ H5P.Dialog = function (name, title, content, $element) {
|
||||||
* @param {object} instance to get copyright information from.
|
* @param {object} instance to get copyright information from.
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
H5P.openCopyrightsDialog = function ($element, instance) {
|
H5P.openCopyrightsDialog = function ($element, instance, parameters, contentId) {
|
||||||
var copyrights = instance.getCopyrights();
|
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) {
|
if (copyrights !== undefined) {
|
||||||
|
// Convert to string
|
||||||
copyrights = copyrights.toString();
|
copyrights = copyrights.toString();
|
||||||
}
|
}
|
||||||
if (copyrights === undefined || copyrights === '') {
|
if (copyrights === undefined || copyrights === '') {
|
||||||
|
// Use no copyrights default text
|
||||||
copyrights = H5P.t('noCopyrights');
|
copyrights = H5P.t('noCopyrights');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open dialog with copyright information
|
||||||
var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $element);
|
var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $element);
|
||||||
dialog.open();
|
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.
|
* Display a dialog containing the embed code.
|
||||||
*
|
*
|
||||||
|
|
|
@ -234,6 +234,8 @@ div.h5p-fullscreen {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
margin: 0.25em 0;
|
margin: 0.25em 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
line-height: 1.25em;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
.h5p-embed-dialog .h5p-inner {
|
.h5p-embed-dialog .h5p-inner {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
|
Loading…
Reference in New Issue