MDL-67814 core_h5p: Revert of eslintignore change
[moodle.git] / h5p / amd / src / editor_display.js
CommitLineData
eeb90e7e
VDF
1// This file is part of Moodle - http://moodle.org/
2//
3// Moodle is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// Moodle is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15
16/**
17 * This module handles the display of the H5P authoring tool.
18 *
19 * @module core_h5p/editor_display
20 * @package core_h5p
21 * @copyright 2020 Victor Deniz <victor@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25import $ from 'jquery';
1e33203b 26/* global H5PEditor */
eeb90e7e
VDF
27
28/**
29 * Display the H5P authoring tool.
30 *
31 * @param {String} elementId Root element.
32 */
33export const init = (elementId) => {
34 const editorwrapper = $('#' + elementId);
35 const editor = $('.h5p-editor');
36 const mform = editor.closest("form");
37 const editorupload = $("h5p-editor-upload");
38 const h5plibrary = $('input[name="h5plibrary"]');
39 const h5pparams = $('input[name="h5pparams"]');
40 const inputname = $('input[name="name"]');
41 const h5paction = $('input[name="h5paction"]');
42
43 // Cancel validation and submission of form if clicking cancel button.
44 const cancelSubmitCallback = function($button) {
45 return $button.is('[name="cancel"]');
46 };
47
48 h5paction.val("create");
49
50 H5PEditor.init(
51 mform,
52 h5paction,
53 editorupload,
54 editorwrapper,
55 editor,
56 h5plibrary,
57 h5pparams,
58 '',
59 inputname,
60 cancelSubmitCallback
61 );
62};