Skip to content
Snippets Groups Projects
Select Git revision
  • a1a2fa818ff108b9924e04ffa0f7d425a951c69b
  • main default protected
  • dev/grabowski
  • origin/main
  • hsh_1.22.4
  • 1.22.4
  • 1.22.3
  • 1.22.2
  • 1.22.1
  • 1.22
  • 1.21
  • 1.20.2
  • 1.20.1
  • 1.20.0
  • 1.19.1
  • 1.19
  • 1.18
  • 1.17.2
  • 1.17.1
  • 1.17
  • 1.16
  • 1.15
  • 1.14
  • 1.13
24 results

editor.js

Blame
  • editor.js 1.25 KiB
    (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';
    
        // Cancel validation and submission of form if clicking cancel button
        const cancelSubmitCallback = function ($button) {
          return $button.is('[name="cancel"]');
        };
    
        H5PEditor.init(
          $('#' + mformId),
          $('input[name="h5paction"]'),
          getRow($fileField),
          getRow($editor),
          $editor,
          $('input[name="h5plibrary"]'),
          $('input[name="h5pparams"]'),
          $('input[name="h5pmaxscore"]'),
          $('input[name="name"]'),
          cancelSubmitCallback
        );
      }
    
      $(document).ready(init);
    })(H5P.jQuery);