Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
(function($) {
2
 
3
  /**
4
   * Get closest row of element
5
   *
6
   * @param {jQuery} $el
7
   * @returns {jQuery}
8
   */
9
  function getRow($el) {
10
    return $el.closest('.fitem');
11
  }
12
 
13
    /**
14
     * Initializes editor
15
     */
16
  function init() {
17
    var $editor = $('.h5p-editor');
18
    var $fileField = $('input[name="h5pfile"]');
19
 
20
    if (H5PIntegration.hubIsEnabled) {
21
      // TODO: This can easily break in new themes. Improve robustness of this
22
      // by not including h5paction in form, when it should not be used.
23
      $('input[name="h5paction"]').parents('.fitem').last().hide();
24
    }
25
 
26
    const mformId = H5PIntegration.editor && H5PIntegration.editor.formId !== null
27
      ? H5PIntegration.editor.formId
28
      : 'mform1';
29
 
30
    // Cancel validation and submission of form if clicking cancel button
31
    const cancelSubmitCallback = function ($button) {
32
      return $button.is('[name="cancel"]');
33
    };
34
 
35
    H5PEditor.init(
36
      $('#' + mformId),
37
      $('input[name="h5paction"]'),
38
      getRow($fileField),
39
      getRow($editor),
40
      $editor,
41
      $('input[name="h5plibrary"]'),
42
      $('input[name="h5pparams"]'),
43
      $('input[name="h5pmaxscore"]'),
44
      $('input[name="name"]'),
45
      cancelSubmitCallback
46
    );
47
  }
48
 
49
  $(document).ready(init);
50
})(H5P.jQuery);