Renamed H5P.Base to H5P.ContentType.
Moved H5P.ContentType code to separate file. Made H5P.ContentType extend H5P.EventDispatcher.editor-padding
parent
8cf384f46a
commit
56e74c2d68
|
@ -1643,6 +1643,7 @@ class H5PCore {
|
|||
'js/h5p-event-dispatcher.js',
|
||||
'js/h5p-x-api-event.js',
|
||||
'js/h5p-x-api.js',
|
||||
'js/h5p-content-type.js',
|
||||
);
|
||||
public static $adminScripts = array(
|
||||
'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;
|
||||
};
|
38
js/h5p.js
38
js/h5p.js
|
@ -72,39 +72,6 @@ H5P.DISABLE_ABOUT = 16;
|
|||
*/
|
||||
H5P.opened = {};
|
||||
|
||||
/**
|
||||
* H5P Base class. Adds utility functions to a library's prototype object.
|
||||
*
|
||||
* Functions here may be overridable by the libraries. In special cases,
|
||||
* it is also possible to override H5P.Base on a global level.
|
||||
* */
|
||||
H5P.Base = function (constructor, standalone, library) {
|
||||
/**
|
||||
* Is library standalone or not? Not beeing standalone, means it is
|
||||
* included in another library
|
||||
*
|
||||
* @method isStandalone
|
||||
* @return {Boolean}
|
||||
*/
|
||||
this.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
|
||||
*/
|
||||
this.getLibraryFilePath = function (filePath) {
|
||||
var libraryObject = H5P.libraryFromString(library.library);
|
||||
return H5P.getLibraryPath(libraryObject.machineName + '-' + libraryObject.majorVersion + '.' + libraryObject.minorVersion) + '/' + filePath;
|
||||
};
|
||||
|
||||
// This order makes it possible for an H5P library to override H5P.Base functions!
|
||||
return H5P.jQuery.extend({}, this, constructor.prototype);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize H5P content.
|
||||
* Scans for ".h5p-content" in the document and initializes H5P instances where found.
|
||||
|
@ -757,9 +724,10 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize, extras) {
|
|||
extras.previousState = library.userDatas.state;
|
||||
}
|
||||
|
||||
// Makes all H5P libraries extend H5P.Base:
|
||||
// Makes all H5P libraries extend H5P.ContentType:
|
||||
var standalone = extras.standalone || false;
|
||||
constructor.prototype = H5P.Base(constructor, standalone, library);
|
||||
// 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;
|
||||
// Some old library versions have their own custom third parameter.
|
||||
|
|
Loading…
Reference in New Issue