Make it easy to disable generic content features.
parent
cc8bfa4b98
commit
2636ddc393
50
js/h5p.js
50
js/h5p.js
|
@ -30,7 +30,29 @@ else if (document.documentElement.msRequestFullscreen) {
|
||||||
H5P.fullScreenBrowserPrefix = 'ms';
|
H5P.fullScreenBrowserPrefix = 'ms';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of when the H5Ps where started
|
/** @const {Number} */
|
||||||
|
H5P.DISABLE_NONE = 0;
|
||||||
|
|
||||||
|
/** @const {Number} */
|
||||||
|
H5P.DISABLE_FRAME = 1;
|
||||||
|
|
||||||
|
/** @const {Number} */
|
||||||
|
H5P.DISABLE_DOWNLOAD = 2;
|
||||||
|
|
||||||
|
/** @const {Number} */
|
||||||
|
H5P.DISABLE_EMBED = 4;
|
||||||
|
|
||||||
|
/** @const {Number} */
|
||||||
|
H5P.DISABLE_COPYRIGHT = 8;
|
||||||
|
|
||||||
|
/** @const {Number} */
|
||||||
|
H5P.DISABLE_ABOUT = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep track of when the H5Ps where started.
|
||||||
|
*
|
||||||
|
* @type {Array}
|
||||||
|
*/
|
||||||
H5P.opened = {};
|
H5P.opened = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,29 +90,41 @@ H5P.init = function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contentData.disable & H5P.DISABLE_FRAME) {
|
||||||
|
$element.addClass('h5p-no-frame');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Create action bar
|
||||||
var $actions = H5P.jQuery('<ul class="h5p-actions"></ul>');
|
var $actions = H5P.jQuery('<ul class="h5p-actions"></ul>');
|
||||||
if (contentData.exportUrl !== '') {
|
|
||||||
// Display export button
|
if (!(contentData.disable & H5P.DISABLE_DOWNLOAD)) {
|
||||||
|
// Add export button
|
||||||
H5P.jQuery('<li class="h5p-button h5p-export" role="button" tabindex="1" title="' + H5P.t('downloadDescription') + '">' + H5P.t('download') + '</li>').appendTo($actions).click(function () {
|
H5P.jQuery('<li class="h5p-button h5p-export" role="button" tabindex="1" title="' + H5P.t('downloadDescription') + '">' + H5P.t('download') + '</li>').appendTo($actions).click(function () {
|
||||||
window.location.href = contentData.exportUrl;
|
window.location.href = contentData.exportUrl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (instance.getCopyrights !== undefined) {
|
if (!(contentData.disable & H5P.DISABLE_COPYRIGHT) && instance.getCopyrights !== undefined) {
|
||||||
// Display copyrights button
|
// Add 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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (contentData.embedCode !== undefined) {
|
if (!(contentData.disable & H5P.DISABLE_EMBED)) {
|
||||||
// Display embed button
|
// Add 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 () {
|
||||||
H5P.openEmbedDialog($actions, contentData.embedCode);
|
H5P.openEmbedDialog($actions, contentData.embedCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (H5PIntegration.showH5PIconInActionBar()) {
|
if (!(contentData.disable & H5P.DISABLE_ABOUT)) {
|
||||||
|
// Add about H5P button icon
|
||||||
H5P.jQuery('<li><a class="h5p-link" href="http://h5p.org" target="_blank" title="' + H5P.t('h5pDescription') + '"></a></li>').appendTo($actions);
|
H5P.jQuery('<li><a class="h5p-link" href="http://h5p.org" target="_blank" title="' + H5P.t('h5pDescription') + '"></a></li>').appendTo($actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert action bar if it has any content
|
||||||
|
if ($actions.children().length) {
|
||||||
$actions.insertAfter($container);
|
$actions.insertAfter($container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Keep track of when we started
|
// Keep track of when we started
|
||||||
H5P.opened[contentId] = new Date();
|
H5P.opened[contentId] = new Date();
|
||||||
|
|
|
@ -36,6 +36,9 @@ html.h5p-iframe .h5p-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
.h5p-content.h5p-no-frame {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
.h5p-container {
|
.h5p-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
Loading…
Reference in New Issue