MOBILE-4265 h5p: Update h5p to 1.23

main
Dani Palou 2023-03-02 10:14:41 +01:00
parent bd6fb138e1
commit 173acfb954
39 changed files with 1120 additions and 78 deletions

View File

@ -1877,6 +1877,7 @@
"core.h5p.fullscreen": "h5p",
"core.h5p.gpl": "h5p",
"core.h5p.h5ptitle": "h5p",
"core.h5p.height": "h5p",
"core.h5p.helpChoosingLicense": "h5p",
"core.h5p.hideadvanced": "h5p",
"core.h5p.icon": "h5p",
@ -1970,6 +1971,7 @@
"core.h5p.thumbnail": "h5p",
"core.h5p.title": "h5p",
"core.h5p.undisclosed": "h5p",
"core.h5p.width": "h5p",
"core.h5p.year": "h5p",
"core.h5p.years": "h5p",
"core.h5p.yearsfrom": "h5p",

View File

@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid meet">
<metadata>
<json>
<![CDATA[

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid meet">
<metadata>
<json>
<![CDATA[

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -35,11 +35,15 @@ H5P.ActionBar = (function ($, EventDispatcher) {
var handler = function () {
self.trigger(type);
};
H5P.jQuery('<li/>', {
const $actionList = H5P.jQuery('<li/>', {
'class': 'h5p-button h5p-noselect h5p-' + (customClass ? customClass : type),
role: 'button',
appendTo: $actions
});
const $actionButton = H5P.jQuery('<button/>', {
tabindex: 0,
title: H5P.t(type + 'Description'),
'aria-label': H5P.t(type + 'Description'),
html: H5P.t(type),
on: {
click: handler,
@ -50,9 +54,11 @@ H5P.ActionBar = (function ($, EventDispatcher) {
}
}
},
appendTo: $actions
appendTo: $actionList
});
H5P.Tooltip($actionButton.get(0));
hasActions = true;
};
@ -69,14 +75,15 @@ H5P.ActionBar = (function ($, EventDispatcher) {
}
if (displayOptions.icon) {
// 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);
const $h5pLogo = H5P.jQuery('<li><a class="h5p-link" href="http://h5p.org" target="_blank" aria-label="' + H5P.t('h5pDescription') + '"></a></li>').appendTo($actions);
H5P.Tooltip($h5pLogo.find('.h5p-link').get(0));
hasActions = true;
}
/**
* Returns a reference to the dom element
*
* @returns {H5P.jQuery}
* @return {H5P.jQuery}
*/
self.getDOMElement = function () {
return $actions;
@ -85,7 +92,7 @@ H5P.ActionBar = (function ($, EventDispatcher) {
/**
* Does the actionbar contain actions?
*
* @returns {Boolean}
* @return {Boolean}
*/
self.hasActions = function () {
return hasActions;

View File

@ -87,7 +87,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
popup.setAttribute('aria-labelledby', 'h5p-confirmation-dialog-dialog-text-' + uniqueId);
popupBackground.appendChild(popup);
popup.addEventListener('keydown', function (e) {
if (e.which === 27) {// Esc key
if (e.key === 'Escape') {// Esc key
// Exit dialog
dialogCanceled(e);
}
@ -135,18 +135,18 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
// Exit button
var exitButton = document.createElement('button');
exitButton.classList.add('h5p-confirmation-dialog-exit');
exitButton.setAttribute('aria-hidden', 'true');
exitButton.tabIndex = -1;
exitButton.title = options.cancelText;
exitButton.setAttribute('aria-label', options.cancelText);
// Cancel handler
cancelButton.addEventListener('click', dialogCanceled);
cancelButton.addEventListener('keydown', function (e) {
if (e.which === 32) { // Space
if (e.key === ' ') { // Space
dialogCanceled(e);
}
else if (e.which === 9 && e.shiftKey) { // Shift-tab
flowTo(confirmButton, e);
else if (e.key === 'Tab' && e.shiftKey) { // Shift-tab
const nextbutton = options.hideExit ? confirmButton : exitButton;
flowTo(nextbutton, e);
}
});
@ -161,11 +161,17 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
// Confirm handler
confirmButton.addEventListener('click', dialogConfirmed);
confirmButton.addEventListener('keydown', function (e) {
if (e.which === 32) { // Space
if (e.key === ' ') { // Space
dialogConfirmed(e);
}
else if (e.which === 9 && !e.shiftKey) { // Tab
const nextButton = !options.hideCancel ? cancelButton : confirmButton;
else if (e.key === 'Tab' && !e.shiftKey) { // Tab
let nextButton = confirmButton;
if (!options.hideExit) {
nextButton = exitButton;
}
else if (!options.hideCancel) {
nextButton = cancelButton;
}
flowTo(nextButton, e);
}
});
@ -174,9 +180,13 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
// Exit handler
exitButton.addEventListener('click', dialogCanceled);
exitButton.addEventListener('keydown', function (e) {
if (e.which === 32) { // Space
if (e.key === ' ') { // Space
dialogCanceled(e);
}
else if (e.key === 'Tab' && !e.shiftKey) { // Tab
const nextButton = options.hideCancel ? confirmButton : cancelButton;
flowTo(nextButton, e);
}
});
if (!options.hideExit) {
popup.appendChild(exitButton);
@ -375,7 +385,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
/**
* Retrieve element
*
* @returns {HTMLElement}
* @return {HTMLElement}
*/
this.getElement = function () {
return popup;
@ -383,7 +393,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
/**
* Get previously focused element
* @returns {HTMLElement}
* @return {HTMLElement}
*/
this.getPreviouslyFocused = function () {
return previouslyFocused;

View File

@ -22,7 +22,7 @@ H5P.ContentType = function (isRootLibrary) {
* Is library standalone or not? Not beeing standalone, means it is
* included in another library
*
* @returns {Boolean}
* @return {Boolean}
*/
ContentType.prototype.isRoot = function () {
return isRootLibrary;
@ -31,7 +31,7 @@ H5P.ContentType = function (isRootLibrary) {
/**
* Returns the file path of a file in the current library
* @param {string} filePath The path to the file relative to the library folder
* @returns {string} The full path to the file
* @return {string} The full path to the file
*/
ContentType.prototype.getLibraryFilePath = function (filePath) {
return H5P.getLibraryPath(this.libraryInfo.versionedNameNoSpaces) + '/' + filePath;

View File

@ -160,7 +160,7 @@ H5P.ContentUpgradeProcess = (function (Version) {
ContentUpgradeProcess.prototype.processField = function (field, params, done) {
var self = this;
if (params === undefined) {
if (params === undefined || params === null) {
return done();
}

View File

@ -0,0 +1,217 @@
/*global H5P*/
H5P.Tooltip = (function () {
'use strict';
/**
* Create an accessible tooltip
*
* @param {HTMLElement} triggeringElement The element that should trigger the tooltip
* @param {Object} options Options for tooltip
* @param {String} options.text The text to be displayed in the tooltip
* If not set, will attempt to set text = aria-label of triggeringElement
* @param {String[]} options.classes Extra css classes for the tooltip
* @param {Boolean} options.ariaHidden Whether the hover should be read by screen readers or not (default: true)
* @param {String} options.position Where the tooltip should appear in relation to the
* triggeringElement. Accepted positions are "top" (default), "left", "right" and "bottom"
*
* @constructor
*/
function Tooltip(triggeringElement, options) {
// Make sure tooltips have unique id
H5P.Tooltip.uniqueId += 1;
const tooltipId = 'h5p-tooltip-' + H5P.Tooltip.uniqueId;
// Default options
options = options || {};
options.classes = options.classes || [];
options.ariaHidden = options.ariaHidden || true;
// Initiate state
let hover = false;
let focus = false;
// Function used by the escape listener
const escapeFunction = function (e) {
if (e.key === 'Escape') {
tooltip.classList.remove('h5p-tooltip-visible');
}
}
// Create element
const tooltip = document.createElement('div');
tooltip.classList.add('h5p-tooltip');
tooltip.id = tooltipId;
tooltip.role = 'tooltip';
tooltip.innerHTML = options.text || triggeringElement.getAttribute('aria-label') || '';
tooltip.setAttribute('aria-hidden', options.ariaHidden);
tooltip.classList.add(...options.classes);
triggeringElement.appendChild(tooltip);
// Set the initial position based on options.position
switch (options.position) {
case 'left':
tooltip.classList.add('h5p-tooltip-left');
break;
case 'right':
tooltip.classList.add('h5p-tooltip-right');
break;
case 'bottom':
tooltip.classList.add('h5p-tooltip-bottom');
break;
default:
options.position = 'top';
}
// Aria-describedby will override aria-hidden
if (!options.ariaHidden) {
triggeringElement.setAttribute('aria-describedby', tooltipId);
}
// Add event listeners to triggeringElement
triggeringElement.addEventListener('mouseenter', function () {
showTooltip(true);
});
triggeringElement.addEventListener('mouseleave', function () {
hideTooltip(true);
});
triggeringElement.addEventListener('focusin', function () {
showTooltip(false);
});
triggeringElement.addEventListener('focusout', function () {
hideTooltip(false);
});
// Prevent clicks on the tooltip from triggering onClick listeners on the triggeringElement
tooltip.addEventListener('click', function (event) {
event.stopPropagation();
});
// Use a mutation observer to listen for aria-label being
// changed for the triggering element. If so, update the tooltip.
// Mutation observer will be used even if the original elements
// doesn't have any aria-label.
new MutationObserver(function (mutations) {
const ariaLabel = mutations[0].target.getAttribute('aria-label');
if (ariaLabel) {
tooltip.innerHTML = options.text || ariaLabel;
}
}).observe(triggeringElement, {
attributes: true,
attributeFilter: ['aria-label'],
});
// Use intersection observer to adjust the tooltip if it is not completely visible
new IntersectionObserver(function (entries) {
entries.forEach((entry) => {
const target = entry.target;
const positionClass = 'h5p-tooltip-' + options.position;
// Stop adjusting when hidden (to prevent a false positive next time)
if (entry.intersectionRatio === 0) {
['h5p-tooltip-down', 'h5p-tooltip-left', 'h5p-tooltip-right']
.forEach(function (adjustmentClass) {
if (adjustmentClass !== positionClass) {
target.classList.remove(adjustmentClass);
}
});
}
// Adjust if not completely visible when meant to be
else if (entry.intersectionRatio < 1 && (hover || focus)) {
const targetRect = entry.boundingClientRect;
const intersectionRect = entry.intersectionRect;
// Going out of screen on left side
if (intersectionRect.left > targetRect.left) {
target.classList.add('h5p-tooltip-right');
target.classList.remove(positionClass);
}
// Going out of screen on right side
else if (intersectionRect.right < targetRect.right) {
target.classList.add('h5p-tooltip-left');
target.classList.remove(positionClass);
}
// going out of top of screen
if (intersectionRect.top > targetRect.top) {
target.classList.add('h5p-tooltip-down');
target.classList.remove(positionClass);
}
// going out of bottom of screen
else if (intersectionRect.bottom < targetRect.bottom) {
target.classList.add('h5p-tooltip-up');
target.classList.remove(positionClass);
}
}
});
}).observe(tooltip);
/**
* Makes the tooltip visible and activates it's functionality
*
* @param {Boolean} triggeredByHover True if triggered by mouse, false if triggered by focus
*/
const showTooltip = function (triggeredByHover) {
if (triggeredByHover) {
hover = true;
}
else {
focus = true;
}
tooltip.classList.add('h5p-tooltip-visible');
// Add listener to iframe body, as esc keypress would not be detected otherwise
document.body.addEventListener('keydown', escapeFunction, true);
}
/**
* Hides the tooltip and removes listeners
*
* @param {Boolean} triggeredByHover True if triggered by mouse, false if triggered by focus
*/
const hideTooltip = function (triggeredByHover) {
if (triggeredByHover) {
hover = false;
}
else {
focus = false;
}
// Only hide tooltip if neither hovered nor focused
if (!hover && !focus) {
tooltip.classList.remove('h5p-tooltip-visible');
// Remove iframe body listener
document.body.removeEventListener('keydown', escapeFunction, true);
}
}
/**
* Change the text displayed by the tooltip
*
* @param {String} text The new text to be displayed
* Set to null to use aria-label of triggeringElement instead
*/
this.setText = function (text) {
options.text = text;
tooltip.innerHTML = options.text || triggeringElement.getAttribute('aria-label') || '';
};
/**
* Retrieve tooltip
*
* @return {HTMLElement}
*/
this.getElement = function () {
return tooltip;
};
}
return Tooltip;
})();
H5P.Tooltip.uniqueId = -1;

View File

@ -263,7 +263,7 @@ H5P.XAPIEvent.prototype.getContentXAPIId = function (instance) {
/**
* Check if this event is sent from a child (i.e not from grandchild)
*
* @returns {Boolean}
* @return {Boolean}
*/
H5P.XAPIEvent.prototype.isFromChild = function () {
var parentId = this.getVerifiedStatementValue(['context', 'contextActivities', 'parent', 0, 'id']);

View File

@ -209,7 +209,7 @@ H5P.init = function (target) {
instance.triggerXAPI('accessed-reuse');
});
actionBar.on('copyrights', function () {
var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $container);
var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $container, $actions.find('.h5p-copyrights')[0]);
dialog.open(true);
instance.triggerXAPI('accessed-copyright');
});
@ -372,13 +372,7 @@ H5P.init = function (target) {
if (!H5P.isFramed || H5P.externalEmbed === false) {
// Resize everything when window is resized.
H5P.jQuery(window.parent).resize(function () {
if (window.parent.H5P.isFullscreen) {
// Use timeout to avoid bug in certain browsers when exiting fullscreen. Some browser will trigger resize before the fullscreenchange event.
H5P.trigger(instance, 'resize');
}
else {
H5P.trigger(instance, 'resize');
}
H5P.trigger(instance, 'resize');
});
}
@ -685,7 +679,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
before('h5p-fullscreen');
var first, eventName = (H5P.fullScreenBrowserPrefix === 'ms' ? 'MSFullscreenChange' : H5P.fullScreenBrowserPrefix + 'fullscreenchange');
document.addEventListener(eventName, function () {
document.addEventListener(eventName, function fullscreenCallback() {
if (first === undefined) {
// We are entering fullscreen mode
first = false;
@ -695,7 +689,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
// We are exiting fullscreen
done('h5p-fullscreen');
document.removeEventListener(eventName, arguments.callee, false);
document.removeEventListener(eventName, fullscreenCallback, false);
});
if (H5P.fullScreenBrowserPrefix === '') {
@ -1090,13 +1084,15 @@ H5P.t = function (key, vars, ns) {
* Displayed inside the dialog.
* @param {H5P.jQuery} $element
* Which DOM element the dialog should be inserted after.
* @param {H5P.jQuery} $returnElement
* Which DOM element the focus should be moved to on close
*/
H5P.Dialog = function (name, title, content, $element) {
H5P.Dialog = function (name, title, content, $element, $returnElement) {
/** @alias H5P.Dialog# */
var self = this;
var $dialog = H5P.jQuery('<div class="h5p-popup-dialog h5p-' + name + '-dialog" role="dialog" tabindex="-1">\
var $dialog = H5P.jQuery('<div class="h5p-popup-dialog h5p-' + name + '-dialog" aria-labelledby="' + name + '-dialog-header" aria-modal="true" role="dialog" tabindex="-1">\
<div class="h5p-inner">\
<h2>' + title + '</h2>\
<h2 id="' + name + '-dialog-header">' + title + '</h2>\
<div class="h5p-scroll-content">' + content + '</div>\
<div class="h5p-close" role="button" tabindex="0" aria-label="' + H5P.t('close') + '" title="' + H5P.t('close') + '"></div>\
</div>\
@ -1155,7 +1151,12 @@ H5P.Dialog = function (name, title, content, $element) {
$dialog.remove();
H5P.jQuery(self).trigger('dialog-closed', [$dialog]);
$element.attr('tabindex', '-1');
$element.focus();
if ($returnElement) {
$returnElement.focus();
}
else {
$element.focus();
}
}, 200);
};
};
@ -1288,7 +1289,7 @@ H5P.findCopyrights = function (info, parameters, contentId, extras) {
const path = data.params.file.path;
const width = data.params.file.width;
const height = data.params.file.height;
metadataCopyrights.setThumbnail(new H5P.Thumbnail(H5P.getPath(path, contentId), width, height));
metadataCopyrights.setThumbnail(new H5P.Thumbnail(H5P.getPath(path, contentId), width, height, data.params.alt));
}
info.addMedia(metadataCopyrights);
}
@ -1393,7 +1394,7 @@ H5P.openReuseDialog = function ($element, contentData, library, instance, conten
*/
H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size, instance) {
var fullEmbedCode = embedCode + resizeCode;
var dialog = new H5P.Dialog('embed', H5P.t('embed'), '<textarea class="h5p-embed-code-container" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>' + H5P.t('size') + ': <input type="text" value="' + Math.ceil(size.width) + '" class="h5p-embed-size"/> × <input type="text" value="' + Math.ceil(size.height) + '" class="h5p-embed-size"/> px<br/><div role="button" tabindex="0" class="h5p-expander">' + H5P.t('showAdvanced') + '</div><div class="h5p-expander-content"><p>' + H5P.t('advancedHelp') + '</p><textarea class="h5p-embed-code-container" autocorrect="off" autocapitalize="off" spellcheck="false">' + resizeCode + '</textarea></div>', $element);
var dialog = new H5P.Dialog('embed', H5P.t('embed'), '<textarea class="h5p-embed-code-container" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>' + H5P.t('size') + ': <input aria-label="'+ H5P.t('width') +'" type="text" value="' + Math.ceil(size.width) + '" class="h5p-embed-size"/> × <input aria-label="'+ H5P.t('width') +'" type="text" value="' + Math.ceil(size.height) + '" class="h5p-embed-size"/> px<br/><div role="button" tabindex="0" class="h5p-expander">' + H5P.t('showAdvanced') + '</div><div class="h5p-expander-content"><p>' + H5P.t('advancedHelp') + '</p><textarea class="h5p-embed-code-container" autocorrect="off" autocapitalize="off" spellcheck="false">' + resizeCode + '</textarea></div>', $element);
// Selecting embed code when dialog is opened
H5P.jQuery(dialog).on('dialog-opened', function (event, $dialog) {
@ -1938,8 +1939,10 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
* @param {string} source
* @param {number} width
* @param {number} height
* @param {string} alt
* alternative text for the thumbnail
*/
H5P.Thumbnail = function (source, width, height) {
H5P.Thumbnail = function (source, width, height, alt) {
var thumbWidth, thumbHeight = 100;
if (width !== undefined) {
thumbWidth = Math.round(thumbHeight * (width / height));
@ -1951,7 +1954,7 @@ H5P.Thumbnail = function (source, width, height) {
* @returns {string} HTML.
*/
this.toString = function () {
return '<img src="' + source + '" alt="' + H5P.t('thumbnail') + '" class="h5p-thumbnail" height="' + thumbHeight + '"' + (thumbWidth === undefined ? '' : ' width="' + thumbWidth + '"') + '/>';
return '<img src="' + source + '" alt="' + (alt ? alt : '') + '" class="h5p-thumbnail" height="' + thumbHeight + '"' + (thumbWidth === undefined ? '' : ' width="' + thumbWidth + '"') + '/>';
};
};
@ -2718,15 +2721,18 @@ H5P.createTitle = function (rawTitle, maxLength) {
if (!isTmpFile && clipboardData.contentId && !path.match(/^https?:\/\//i)) {
// Comes from existing content
let prefix;
if (H5PEditor.contentId) {
// .. to existing content
return '../' + clipboardData.contentId + '/' + path;
prefix = '../' + clipboardData.contentId + '/';
}
else {
// .. to new content
return (H5PEditor.contentRelUrl ? H5PEditor.contentRelUrl : '../content/') + clipboardData.contentId + '/' + path;
prefix = (H5PEditor.contentRelUrl ? H5PEditor.contentRelUrl : '../content/') + clipboardData.contentId + '/';
}
return path.substr(0, prefix.length) === prefix ? path : prefix + path;
}
return path; // Will automatically be looked for in tmp folder
});

View File

@ -85,7 +85,7 @@ H5P.RequestQueue = (function ($, EventDispatcher) {
/**
* Start processing of requests queue
*
* @returns {boolean} Returns false if it was not possible to resume processing queue
* @return {boolean} Returns false if it was not possible to resume processing queue
*/
RequestQueue.prototype.resumeQueue = function () {
// Not supported

View File

@ -94,14 +94,14 @@ H5PEmbedCommunicator = (function() {
var getH5PObject = async (iFrame) => {
var H5P = iFrame.contentWindow.H5P;
if (H5P?.instances?.[0]) {
if (H5P && H5P.instances && H5P.instances[0]) {
return H5P;
}
// In some cases, the H5P takes a while to be initialized (which causes some random behat failures).
const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay));
let remainingAttemps = 10;
while (!H5P?.instances?.[0] && remainingAttemps > 0) {
while ((!H5P || !H5P.instances || !H5P.instances[0]) && remainingAttemps > 0) {
await sleep(100);
H5P = iFrame.contentWindow.H5P;
remainingAttemps--;
@ -121,7 +121,7 @@ document.onreadystatechange = async() => {
return;
}
var H5P = await getH5PObject(iFrame);
if (!H5P?.instances?.[0]) {
if (!H5P || !H5P.instances || !H5P.instances[0]) {
return;
}

View File

@ -5,3 +5,4 @@ Changes:
1. The h5p.js file has been modified to make fullscreen work in the Moodle app. In line 34, the code inside the condition document.documentElement.webkitRequestFullScreen has changed, the original code has been commented.
2. The h5p.js file has been modified to simulate a fake full screen in iOS. The H5P file now sends post messages to the app, and also listens to messages sent by the app to enter/exit full screen.
3. The embed.js file has been modified to remove optional chaining because it isn't supported in some old devices.

View File

@ -0,0 +1,494 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-cyrillic-ext.woff2') format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-cyrillic.woff2') format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-greek-ext.woff2') format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-greek.woff2') format('woff2');
unicode-range: U+0370-03FF;
}
/* hebrew */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-hebrew.woff2') format('woff2');
unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-latin-ext.woff2') format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-latin.woff2') format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-cyrillic-ext.woff2') format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-cyrillic.woff2') format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-greek-ext.woff2') format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-greek.woff2') format('woff2');
unicode-range: U+0370-03FF;
}
/* hebrew */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-hebrew.woff2') format('woff2');
unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-latin-ext.woff2') format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-latin.woff2') format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-cyrillic-ext.woff2') format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-cyrillic.woff2') format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-greek-ext.woff2') format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-greek.woff2') format('woff2');
unicode-range: U+0370-03FF;
}
/* hebrew */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-hebrew.woff2') format('woff2');
unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-latin-ext.woff2') format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-italic-400-600-700-v28-latin.woff2') format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-cyrillic-ext.woff2') format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-cyrillic.woff2') format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-greek-ext.woff2') format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-greek.woff2') format('woff2');
unicode-range: U+0370-03FF;
}
/* hebrew */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-hebrew.woff2') format('woff2');
unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-latin-ext.woff2') format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-latin.woff2') format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-cyrillic-ext.woff2') format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-cyrillic.woff2') format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-greek-ext.woff2') format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-greek.woff2') format('woff2');
unicode-range: U+0370-03FF;
}
/* hebrew */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-hebrew.woff2') format('woff2');
unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-latin-ext.woff2') format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-latin.woff2') format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-cyrillic-ext.woff2') format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-cyrillic.woff2') format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-greek-ext.woff2') format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-greek.woff2') format('woff2');
unicode-range: U+0370-03FF;
}
/* hebrew */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-hebrew.woff2') format('woff2');
unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-vietnamese.woff2') format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-latin-ext.woff2') format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url('../fonts/open-sans/opensans-400-600-700-v28-latin.woff2') format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

View File

@ -1,4 +1,3 @@
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
.h5p-hub-publish button,.h5p-hub-registration button{font-family:"Open Sans", sans-serif;font-size:0.75em;background:transparent;padding:0.75em 2em;color:#757575;border-radius:3em;border:1px solid #d6d6d6;cursor:pointer;font-weight:bold}.h5p-hub-publish button:before,.h5p-hub-registration button:before{font-weight:normal}.h5p-hub-publish button:hover,.h5p-hub-registration button:hover{color:#5f5f5f;border-color:#5f5f5f}.h5p-hub-publish button.h5p-hub-contained.h5p-hub-green,.h5p-hub-registration button.h5p-hub-contained.h5p-hub-green{background-color:#186df7;color:#fff;border-color:#186df7}.h5p-hub-publish button.h5p-hub-contained.h5p-hub-green:hover,.h5p-hub-registration button.h5p-hub-contained.h5p-hub-green:hover{background-color:#2e46a4;border-color:#2e46a4}.h5p-hub-publish button.h5p-hub-outlined.h5p-hub-green,.h5p-hub-registration button.h5p-hub-outlined.h5p-hub-green{border-width:0.125em;background-color:white;border-color:#186df7;color:#186df7}.h5p-hub-publish button.h5p-hub-outlined.h5p-hub-green:hover,.h5p-hub-registration button.h5p-hub-outlined.h5p-hub-green:hover{background-color:#186df7;border-color:#186df7;color:#ffffff}.h5p-hub-publish button.h5p-hub-outlined.h5p-hub-green[disabled],.h5p-hub-registration button.h5p-hub-outlined.h5p-hub-green[disabled]{color:#aac3ec;border-color:#aac3ec;background-color:white;pointer-events:none}.h5p-hub-publish .h5p-hub-navigation button{padding:0.833em;max-width:10.5em}
.h5p-hub-publish .h5p-hub-form-element,.h5p-hub-registration .h5p-hub-form-element{font-family:Nunito, sans-serif;font-size:16px;padding:1em 0}.h5p-hub-publish .h5p-hub-form-element label,.h5p-hub-registration .h5p-hub-form-element label{display:block;margin-bottom:0.4em;font-weight:bold}.h5p-hub-publish .h5p-hub-form-element.h5p-hub-mandatory label:after,.h5p-hub-registration .h5p-hub-form-element.h5p-hub-mandatory label:after{content:'*';color:#d11e15;position:relative;top:-0.2em}.h5p-hub-publish .h5p-hub-form-element input,.h5p-hub-registration .h5p-hub-form-element input{border-radius:0.208em;width:100%;box-sizing:border-box;line-height:normal}.h5p-hub-publish .h5p-hub-form-element input::placeholder,.h5p-hub-registration .h5p-hub-form-element input::placeholder{font-style:italic}.h5p-hub-publish .h5p-hub-form-element .h5p-hub-description,.h5p-hub-registration .h5p-hub-form-element .h5p-hub-description{font-size:0.833em;color:#707475;margin:0 0 1em 0}.h5p-hub-publish .h5p-hub-form-element textarea,.h5p-hub-registration .h5p-hub-form-element textarea{resize:none;width:100%;border-radius:0.208em;box-sizing:border-box;line-height:1.25em}.h5p-hub-publish .h5p-hub-form-element textarea::-webkit-scrollbar,.h5p-hub-registration .h5p-hub-form-element textarea::-webkit-scrollbar{background-color:rgba(105,117,133,0.25);width:0.333em;border-radius:5.45256em}.h5p-hub-publish .h5p-hub-form-element textarea::-webkit-scrollbar-thumb,.h5p-hub-registration .h5p-hub-form-element textarea::-webkit-scrollbar-thumb{background-color:#697585;background-size:24px 100%;border-radius:5.45256em}.h5p-hub-publish .h5p-hub-form-element textarea::placeholder,.h5p-hub-registration .h5p-hub-form-element textarea::placeholder{font-style:italic}.h5p-hub-publish .h5p-hub-form-element .h5p-hub-link-button,.h5p-hub-registration .h5p-hub-form-element .h5p-hub-link-button{border:none;text-decoration:underline;text-align:right;align-self:flex-start;color:#186df7;font-size:.917em;font-weight:normal;padding:0}.h5p-hub-publish .h5p-hub-form-element .h5p-hub-details-row,.h5p-hub-registration .h5p-hub-form-element .h5p-hub-details-row{display:flex;align-content:center;align-items:center;justify-content:space-between}.h5p-hub-publish .h5p-hub-form-element textarea,.h5p-hub-publish .h5p-hub-form-element input,.h5p-hub-publish .h5p-hub-form-element select,.h5p-hub-registration .h5p-hub-form-element textarea,.h5p-hub-registration .h5p-hub-form-element input,.h5p-hub-registration .h5p-hub-form-element select{padding:.958em;border:2px solid #e2e5ee;box-shadow:none;color:#3c4859;font-family:Nunito, sans-serif}.h5p-hub-publish .h5p-hub-form-element textarea:focus,.h5p-hub-publish .h5p-hub-form-element input:focus,.h5p-hub-publish .h5p-hub-form-element select:focus,.h5p-hub-registration .h5p-hub-form-element textarea:focus,.h5p-hub-registration .h5p-hub-form-element input:focus,.h5p-hub-registration .h5p-hub-form-element select:focus{border-color:#98cbe8;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(152,203,232,0.6);outline:none}.h5p-hub-publish .h5p-hub-step-content>.h5p-hub-form-element:first-child,.h5p-hub-registration .h5p-hub-step-content>.h5p-hub-form-element:first-child{padding-top:0}.h5p-hub-publish .h5p-hub-step-content>.h5p-hub-form-element:last-child,.h5p-hub-registration .h5p-hub-step-content>.h5p-hub-form-element:last-child{padding-bottom:0}

View File

@ -1,4 +1,3 @@
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
.h5p-hub-publish button,.h5p-hub-registration button{font-family:"Open Sans", sans-serif;font-size:0.75em;background:transparent;padding:0.75em 2em;color:#757575;border-radius:3em;border:1px solid #d6d6d6;cursor:pointer;font-weight:bold}.h5p-hub-publish button:before,.h5p-hub-registration button:before{font-weight:normal}.h5p-hub-publish button:hover,.h5p-hub-registration button:hover{color:#5f5f5f;border-color:#5f5f5f}.h5p-hub-publish button.h5p-hub-contained.h5p-hub-green,.h5p-hub-registration button.h5p-hub-contained.h5p-hub-green{background-color:#186df7;color:#fff;border-color:#186df7}.h5p-hub-publish button.h5p-hub-contained.h5p-hub-green:hover,.h5p-hub-registration button.h5p-hub-contained.h5p-hub-green:hover{background-color:#2e46a4;border-color:#2e46a4}.h5p-hub-publish button.h5p-hub-outlined.h5p-hub-green,.h5p-hub-registration button.h5p-hub-outlined.h5p-hub-green{border-width:0.125em;background-color:white;border-color:#186df7;color:#186df7}.h5p-hub-publish button.h5p-hub-outlined.h5p-hub-green:hover,.h5p-hub-registration button.h5p-hub-outlined.h5p-hub-green:hover{background-color:#186df7;border-color:#186df7;color:#ffffff}.h5p-hub-publish button.h5p-hub-outlined.h5p-hub-green[disabled],.h5p-hub-registration button.h5p-hub-outlined.h5p-hub-green[disabled]{color:#aac3ec;border-color:#aac3ec;background-color:white;pointer-events:none}.h5p-hub-publish .h5p-hub-navigation button{padding:0.833em;max-width:10.5em}
.h5p-hub-publish .h5p-hub-stepper{display:flex;width:100%;max-width:40em;align-items:center;flex-direction:row;margin:2em auto;padding:0 2em;box-sizing:border-box}.h5p-hub-publish .h5p-hub-step-connector{flex-grow:1;margin-left:-2em;margin-right:-2em;position:relative;top:-0.6em}.h5p-hub-publish .h5p-hub-step-connector-line{display:block;border-top-style:solid;border-top-width:1px;border-color:#d5d5d7}

View File

@ -0,0 +1,67 @@
.h5p-tooltip {
--translateX: -50%;
--translateY: 0;
display: none;
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(var(--translateX)) translateY(var(--translateY));
z-index: 4;
font-size: 0.9rem;
line-height: 1.5rem;
padding: 0 0.5rem;
white-space: nowrap;
background: #000;
color: #FFF;
cursor: default;
/* To hide the position adjustments and to get a bit more
pleasent popup effect */
-webkit-animation: 800ms ease 0s normal forwards 1 fadein;
animation: 800ms ease 0s normal forwards 1 fadein;
}
@keyframes fadein{
0% { opacity: 0; }
80% { opacity: 0; }
100% { opacity: 1; }
}
@-webkit-keyframes fadein{
0% { opacity: 0; }
80% { opacity: 0; }
100% { opacity: 1; }
}
.h5p-tooltip-bottom {
top: 100%;
bottom: auto;
}
.h5p-tooltip-left {
--translateY: -50%;
--translateX: 0;
top: 50%;
bottom: auto;
left: auto;
right: 100%;
}
.h5p-tooltip-right {
--translateY: -50%;
--translateX: 0;
top: 50%;
bottom: auto;
left: 100%;
right: auto;
}
.h5p-tooltip-visible {
display: block;
}

View File

@ -1,5 +1,6 @@
/* Import common fonts */
@import 'font-open-sans.css';
/* General CSS for H5P. Licensed under the MIT License.*/
/* Custom H5P font to use for icons. */
@font-face {
font-family: 'h5p';
@ -55,6 +56,8 @@ html.h5p-iframe .h5p-content {
line-height: 1.5em;
width: 100%;
height: auto;
-webkit-text-size-adjust: none;
text-size-adjust: none;
}
html.h5p-iframe .h5p-fullscreen .h5p-content,
html.h5p-iframe .h5p-semi-fullscreen .h5p-content {
@ -189,7 +192,6 @@ div.h5p-fullscreen {
.h5p-content ul.h5p-actions {
box-sizing: border-box;
-moz-box-sizing: border-box;
overflow: hidden;
list-style: none;
padding: 0px 10px;
margin: 0;
@ -216,36 +218,51 @@ div.h5p-fullscreen {
outline: none;
line-height: 22px;
}
.h5p-actions > .h5p-button:hover {
.h5p-actions button:hover {
color: #333;
}
.h5p-actions > .h5p-button:active,
.h5p-actions > .h5p-button:focus,
.h5p-actions button:active,
.h5p-actions button:focus,
.h5p-actions .h5p-link:active,
.h5p-actions .h5p-link:focus {
color: #666;
}
.h5p-actions > .h5p-button:focus,
.h5p-actions button {
display: inline-flex;
padding: 0;
margin: 0;
color: #6A6A6A;
position: relative;
/* Disable default button style */
background: none;
border: none;
font: inherit;
cursor: pointer;
line-height: 2;
}
.h5p-actions button:focus,
.h5p-actions .h5p-link:focus {
outline-style: solid;
outline-width: thin;
outline-offset: -2px;
outline-color: #9ecaed;
outline-color: #5981A1;
}
.h5p-actions > .h5p-button:before {
.h5p-actions button:before {
font-family: 'H5P';
font-size: 20px;
line-height: 23px;
vertical-align: bottom;
padding-right: 0;
}
.h5p-actions > .h5p-button.h5p-export:before {
.h5p-actions > .h5p-button.h5p-export > button:before {
content: "\e90b";
}
.h5p-actions > .h5p-button.h5p-copyrights:before {
.h5p-actions > .h5p-button.h5p-copyrights > button:before {
content: "\e88f";
}
.h5p-actions > .h5p-button.h5p-embed:before {
.h5p-actions > .h5p-button.h5p-embed > button:before {
content: "\e892";
}
.h5p-actions .h5p-link {
@ -253,8 +270,8 @@ div.h5p-fullscreen {
margin-right: 0;
font-size: 2.0em;
line-height: 23px;
overflow: hidden;
color: #999;
position: relative;
color: #6a6a6a;
text-decoration: none;
outline: none;
}

View File

@ -35,6 +35,7 @@ export class CoreH5PCore {
'styles/h5p.css',
'styles/h5p-confirmation-dialog.css',
'styles/h5p-core-button.css',
'styles/h5p-tooltip.css',
];
static readonly SCRIPTS = [
@ -47,6 +48,7 @@ export class CoreH5PCore {
'js/h5p-confirmation-dialog.js',
'js/h5p-action-bar.js',
'js/request-queue.js',
'js/h5p-tooltip.js',
];
static readonly ADMIN_SCRIPTS = [
@ -178,13 +180,28 @@ export class CoreH5PCore {
/**
* Writes library data as string on the form {machineName} {majorVersion}.{minorVersion}.
*
* @param libraryData Library data.
* @param folderName Use hyphen instead of space in returned string.
* @param library Library data.
* @returns String on the form {machineName} {majorVersion}.{minorVersion}.
*/
static libraryToString(libraryData: CoreH5PLibraryBasicData | CoreH5PContentMainLibraryData, folderName?: boolean): string {
return ('machineName' in libraryData ? libraryData.machineName : libraryData.name) + (folderName ? '-' : ' ') +
libraryData.majorVersion + '.' + libraryData.minorVersion;
static libraryToString(library: CoreH5PLibraryBasicData | CoreH5PContentMainLibraryData): string {
const name = 'machineName' in library ? library.machineName : library.name;
return `${name} ${library.majorVersion}.${library.minorVersion}`;
}
/**
* Get the name of a library's folder name
*
* @param library Library data.
* @returns Folder name.
*/
static libraryToFolderName(library: CoreH5PLibraryBasicData | CoreH5PContentMainLibraryData): string {
const name = 'machineName' in library ? library.machineName : library.name;
// In LMS, a property named patchVersionInFolderName is checked here. This property is only used to retrieve some icons when
// using the editor, and it isn't stored in DB. The check wasn't included here because the app will never have that prop.
return `${name}-${library.majorVersion}.${library.minorVersion}`;
}
/**
@ -562,7 +579,7 @@ export class CoreH5PCore {
for (const machineName in dependencies) {
const dependency = dependencies[machineName];
const folderName = CoreH5PCore.libraryToString(dependency, true);
const folderName = CoreH5PCore.libraryToFolderName(dependency);
roots[folderName] = this.h5pFS.getLibraryFolderPath(dependency, siteId, folderName);
}
@ -793,6 +810,8 @@ export class CoreH5PCore {
invalidAge: Translate.instant('core.h5p.invalidAge'),
keywordsExits: Translate.instant('core.h5p.keywordsExits'),
someKeywordsExits: Translate.instant('core.h5p.someKeywordsExits'),
width: Translate.instant('core.h5p.width'),
height: Translate.instant('core.h5p.height'),
};
}

View File

@ -363,7 +363,7 @@ export class CoreH5PFileStorage {
* @returns The path to the dependency library
*/
getDependencyPath(dependency: CoreH5PContentDependencyData): string {
return 'libraries/' + dependency.machineName + '-' + dependency.majorVersion + '.' + dependency.minorVersion;
return 'libraries/' + CoreH5PCore.libraryToFolderName(dependency);
}
/**
@ -400,7 +400,7 @@ export class CoreH5PFileStorage {
folderName?: string,
): string {
if (!folderName) {
folderName = CoreH5PCore.libraryToString(libraryData, true);
folderName = CoreH5PCore.libraryToFolderName(libraryData);
}
return CorePath.concatenatePaths(this.getLibrariesFolderPath(siteId), folderName);

View File

@ -56,16 +56,16 @@ export class CoreH5PStorage {
await Promise.all(Object.keys(librariesJsonData).map(async (libString) => {
const libraryData: CoreH5PLibraryBeingSaved = librariesJsonData[libString];
// Find local library identifier.
const dbData = await CoreUtils.ignoreErrors(this.h5pFramework.getLibraryByData(libraryData));
// Find local library with same major + minor.
const existingLibrary = await CoreUtils.ignoreErrors(this.h5pFramework.getLibraryByData(libraryData));
if (dbData) {
if (existingLibrary) {
// Library already installed.
libraryData.libraryId = dbData.id;
libraryData.libraryId = existingLibrary.id;
const isNewPatch = await this.h5pFramework.isPatchedLibrary(libraryData, dbData);
const newerPatchVersion = existingLibrary.patchversion < libraryData.patchVersion;
if (!isNewPatch) {
if (!newerPatchVersion) {
// Same or older version, no need to save.
libraryData.saveDependencies = false;

View File

@ -72,6 +72,7 @@
"fullscreen": "Fullscreen",
"gpl": "General Public License v3",
"h5ptitle": "Visit h5p.org to check out more content.",
"height": "height",
"helpChoosingLicense": "Help me choose a license",
"hideadvanced": "Hide advanced",
"icon": "Icon",
@ -165,6 +166,7 @@
"thumbnail": "Thumbnail",
"title": "Title",
"undisclosed": "Undisclosed",
"width": "width",
"year": "Year",
"years": "Year(s)",
"yearsfrom": "Years (from)",