A jQuery wrapper around window
.
Use fullscreenSupported instead
When embedded, the communicator helps talk to the parent page.
Copyrights for an H5P Content Library
H5P.ContentType is a base class for all content types. Used by newRunnable().
Functions here may be overridable by the libraries. In special cases, it is also possible to override H5P.ContentType on a global level.
NOTE that this doesn't actually 'extend' the event dispatcher but instead it creates a single instance which all content types shares as their base prototype. (in some cases this may be the root of strange event behavior)
Maps copyright license codes to their human readable counterpart.
Optional
externalIndicates if H5P is embedded on an external page using iframe.
Simple data structure class for storing a single field
True if the current browser supports fullscreen mode.
A list over H5P instances on the current page.
True if H5P content is rendered inside an iframe.
True if H5P content is in fullscreen mode.
Use H5P.fullscreen()
or H5P.semiFullScreen()
to enter fullscreen mode.
Use H5P.exitFullScreen()
to exit fullscreen mode.
An ordered list of copyright fields for media
Keeps track of when each H5P content instance was initiated.
Optional
preventPrevent H5P Core from initializing. Must be overriden before document ready.
Optional
safariIs set to the Safari version number if the current browser is Safari (but only if it does not support fullscreen mode).
A simple and elegant class for creating thumbnails of images
Create an accessible tooltip
Helper for adding a query parameter to an existing path that may already contain one or a hash.
URL to add query parameter to.
Query parameter to add on the format key1=value1&key2=value2
.
const path = "https://example.com";
const parameter = "foo=bar";
const result = H5P.addQueryParameter(path, parameter);
// result === "https://example.com?foo=bar"
const path = "https://example.com?foo=bar";
const parameter = "baz=qux";
const result = H5P.addQueryParameter(path, parameter);
// result === "https://example.com?foo=bar&baz=qux"
Show a toast message.
The reference element could be DOM elements the toast should be attached to, or e.g. the document body for general toast messages.
Reference element to show toast message for.
Message to show.
Optional
config: {Configuration.
Optional
duration?: numberToast message length in ms. Default: 3000
Relative positioning of the toast.
Optional
horizontal?: "left" | "right" | "before" | "centered" | "after"Default: centered
Optional
noOverflowBottom?: booleanTrue to prevent overflow bottom. Default: false
Optional
noOverflowLeft?: booleanTrue to prevent overflow left. Default: false
Optional
noOverflowRight?: booleanTrue to prevent overflow right. Default: false
Optional
noOverflowTop?: booleanTrue to prevent overflow top. Default: false
Optional
noOverflowX?: booleanTrue to prevent overflow left and right. Default: false
Optional
noOverflowY?: booleanTrue to prevent overflow top and bottom. Default: false
Optional
offsetHorizontal?: numberExtra horizontal offset. Default: 0
Optional
offsetVertical?: numberExtra vertical offset. Default: 0
Optional
overflowReference?: HTMLElementDOM reference for overflow. Default: document.body
Optional
vertical?: "top" | "bottom" | "centered" | "above" | "below"Default: below
Optional
style?: stringId for the tooltip. Default: h5p-toast
Store item in the H5P Clipboard
Gather a flat list of copyright information from the given parameters.
Used to collect all information in.
To search for file objects in.
Used to insert thumbnails for images.
Optional
extras: { machineName: string; metadata: H5PMetadata }Extras.
Library name of some kind. Metadata of the content instance.
Metadata
Optional
exitCallback: () => voidOptional
body: JQueryOptional
forceSemiFullScreen: booleanFunction for getting content for a certain ID
Optional
contentId: H5PContentIdUse getPath instead
Gather copyright information for the given content.
H5P instance to get copyright information for.
Parameters of the content instance.
Identifies the H5P content
Metadata of the content instance.
Copyright information.
Get the crossOrigin policy to use for img, video and audio tags on the current site.
URL to the source
crossOrigin attribute value required by the source
Use getCrossOrigin with the source as a H5PMedia instead
Get the crossOrigin policy to use for img, video and audio tags on the current site.
If the source points to external media, or H5PIntegration.crossorigin
has a falsy value,
undefined
will be returned.
File object from parameters/json_content
crossOrigin attribute value required by the source
Find the path to the content files based on the id of the content. Also identifies and returns absolute paths
Relative to content folder or absolute
ID of the content requesting the path
Complete URL to path
Initialize H5P content. Scans for ".h5p-content" in the document and initializes H5P instances where found.
DOM Element
next version after 1.24.4 (not released as of 2023-12-26)
Recursive function that detects deep empty structures.
Will return true if the value is null
, undefined
, an empty string, an empty array or an empty object.
Will also return true if the value is an array or object that contains only empty values.
Parse library string into values.
library in the format "machineName majorVersion.minorVersion"
library as an object with machineName, majorVersion and minorVersion properties, or false if the library parameter is invalid
A safe way of creating a new instance of a runnable H5P.
Library/action object form params.
Identifies the content.
Optional
$attachTo: JQueryElement to attach the instance to.
Optional
skipResize: booleanSkip triggering of the resize event after attaching.
Optional
extras: H5PExtrasWithState<TState>Extra parameters for the H5P content constructor
Instance
Display a dialog containing the embed code
Element to insert dialog after
The embed code
The advanced resize code
The content's size
Display a dialog containing the download button and copy button
Enter semi fullscreen for the given H5P instance
Content container.
Callback function called when user exits fullscreen.
For internal use. Gives the body of the iframe.
Set item in the H5P Clipboard
Data to be set
Post finished results for user
Identifies the content
Achieved score/points
The maximum score/points that can be achieved
Optional
time: numberReported time consumption/usage
Helper for setting the crossOrigin attribute + the complete correct source. Note: This will start loading the resource.
Runs getPath internally.
DOM element, typically img, video or audio
Uploaded file object from parameters/json_content (created by H5PEditor)
Needed to determine the complete correct file path
Translate text strings.
Translation identifier, may only contain a-zA-Z0-9. No spaces or special chars.
Optional
placeholderVars: Record<string, string>Data for placeholders.
Optional
namespace: stringTranslation namespace. Defaults to H5P.
Translated text
Trigger an event on an instance
Helper function that triggers an event if the instance supports event handling
Instance of H5P content
Type of event to trigger
Remove all empty spaces before and after the value
Use String#trim
instead
This is an interface which represents the
window.H5P
, or simplyH5P
, object in the H5P Core library. The object works as a namespace for a lot of utilities and classes that are used when creating both widgets and content types in H5P.