Merge branch 'master' of https://github.com/h5p/h5p-php-library
commit
aa96d726bd
|
@ -1643,6 +1643,7 @@ class H5PCore {
|
||||||
'js/h5p-event-dispatcher.js',
|
'js/h5p-event-dispatcher.js',
|
||||||
'js/h5p-x-api-event.js',
|
'js/h5p-x-api-event.js',
|
||||||
'js/h5p-x-api.js',
|
'js/h5p-x-api.js',
|
||||||
|
'js/h5p-content-type.js',
|
||||||
);
|
);
|
||||||
public static $adminScripts = array(
|
public static $adminScripts = array(
|
||||||
'js/jquery.js',
|
'js/jquery.js',
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
* */
|
||||||
|
H5P.ContentType = function (standalone, library) {
|
||||||
|
|
||||||
|
function ContentType() {};
|
||||||
|
|
||||||
|
// Inherit from EventDispatcher.
|
||||||
|
ContentType.prototype = new H5P.EventDispatcher();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is library standalone or not? Not beeing standalone, means it is
|
||||||
|
* included in another library
|
||||||
|
*
|
||||||
|
* @method isStandalone
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
|
ContentType.prototype.isStandalone = function () {
|
||||||
|
return standalone;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file path of a file in the current library
|
||||||
|
* @method getLibraryFilePath
|
||||||
|
* @param {string} filePath The path to the file relative to the library folder
|
||||||
|
* @return {string} The full path to the file
|
||||||
|
*/
|
||||||
|
ContentType.prototype.getLibraryFilePath = function (filePath) {
|
||||||
|
var libraryObject = H5P.libraryFromString(library.library);
|
||||||
|
return H5P.getLibraryPath(libraryObject.machineName + '-' + libraryObject.majorVersion + '.' + libraryObject.minorVersion) + '/' + filePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
return ContentType;
|
||||||
|
};
|
|
@ -135,7 +135,7 @@ H5P.init = function (target) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create new instance.
|
// Create new instance.
|
||||||
var instance = H5P.newRunnable(library, contentId, $container, true);
|
var instance = H5P.newRunnable(library, contentId, $container, true, {standalone: true});
|
||||||
|
|
||||||
// Check if we should add and display a fullscreen button for this H5P.
|
// Check if we should add and display a fullscreen button for this H5P.
|
||||||
if (contentData.fullScreen == 1 && H5P.canHasFullScreen) {
|
if (contentData.fullScreen == 1 && H5P.canHasFullScreen) {
|
||||||
|
@ -724,6 +724,11 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize, extras) {
|
||||||
extras.previousState = library.userDatas.state;
|
extras.previousState = library.userDatas.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Makes all H5P libraries extend H5P.ContentType:
|
||||||
|
var standalone = extras.standalone || false;
|
||||||
|
// This order makes it possible for an H5P library to override H5P.ContentType functions!
|
||||||
|
constructor.prototype = H5P.jQuery.extend({}, H5P.ContentType(standalone, library).prototype, constructor.prototype);
|
||||||
|
|
||||||
var instance;
|
var instance;
|
||||||
// Some old library versions have their own custom third parameter.
|
// Some old library versions have their own custom third parameter.
|
||||||
// Make sure we don't send them the extras.
|
// Make sure we don't send them the extras.
|
||||||
|
@ -759,6 +764,7 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize, extras) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($attachTo !== undefined) {
|
if ($attachTo !== undefined) {
|
||||||
|
$attachTo.toggleClass('h5p-standalone', standalone);
|
||||||
instance.attach($attachTo);
|
instance.attach($attachTo);
|
||||||
H5P.trigger(instance, 'domChanged', {
|
H5P.trigger(instance, 'domChanged', {
|
||||||
'$target': $attachTo,
|
'$target': $attachTo,
|
||||||
|
|
Loading…
Reference in New Issue