forked from iucc/h5p-moodle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.js
44 lines (38 loc) · 1.04 KB
/
editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(function($) {
/**
* Get closest row of element
*
* @param {jQuery} $el
* @returns {jQuery}
*/
function getRow($el) {
return $el.closest('.fitem');
}
/**
* Initializes editor
*/
function init() {
var $editor = $('.h5p-editor');
var $fileField = $('input[name="h5pfile"]');
if (H5PIntegration.hubIsEnabled) {
// TODO: This can easily break in new themes. Improve robustness of this
// by not including h5paction in form, when it should not be used.
$('input[name="h5paction"]').parents('.fitem').last().hide();
}
const mformId = H5PIntegration.editor && H5PIntegration.editor.formId !== null
? H5PIntegration.editor.formId
: 'mform1';
H5PEditor.init(
$('#' + mformId),
$('input[name="h5paction"]'),
getRow($fileField),
getRow($editor),
$editor,
$('input[name="h5plibrary"]'),
$('input[name="h5pparams"]'),
$('input[name="h5pmaxscore"]'),
$('input[name="name"]')
);
}
$(document).ready(init);
})(H5P.jQuery);