I am currently developing an application for the H5P plug in. As I need to develop something for the H5P editor, I found this documentation on how to implement a widget.
/**
* Color selector widget module
*
* @param {H5P.jQuery} $
*/
H5PEditor.widgets.colorSelector = H5PEditor.ColorSelector = (function ($) {
/**
* Creates color selector.
*
* @class H5PEditor.ColorSelector
*
* @param {Object} parent
* @param {Object} field
* @param {string} params
* @param {H5PEditor.SetParameters} setValue
*/
function C(parent, field, params, setValue) {
this.parent = parent;
this.field = field;
this.params = params;
this.setValue = setValue;
}
/**
* Append the field to the wrapper.
*
* @param {H5P.jQuery} $wrapper
*/
C.prototype.appendTo = function ($wrapper) {};
/**
* Validate the current values.
*
* @returns {boolean}
*/
C.prototype.validate = function () {};
/**
* Remove the current field
*/
C.prototype.remove = function () {};
return C;
})(H5P.jQuery);
Since I need to use other classes I already wrote in typesript, I would like to stay consistent in the use of my chosen programming languages. I especially tried to wrap my head around the first and last line of actual code: Do I have to declare two classes with the same contents? To be honest, I've never seen such a construction before.
I would be very thankful for some hints, how to translate this example into typescript correctly. You may also drop some concepts, of how for example to name this construction.
Thank you very much in advance!