1 | /* |
||
2 | * |
||
3 | * @Project |
||
4 | * @Copyright Djoudi |
||
5 | * @Created 2018-02-20 |
||
6 | * @Filename laravel-h5p.js |
||
7 | * @Description |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | (function ($) { |
||
12 | ns.init = function () { |
||
0 ignored issues
–
show
|
|||
13 | ns.$ = H5P.jQuery; |
||
0 ignored issues
–
show
The variable
H5P seems to be never declared. If this is a global, consider adding a /** global: H5P */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() The variable
ns seems to be never declared. If this is a global, consider adding a /** global: ns */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
14 | |||
15 | if (H5PIntegration !== undefined && H5PIntegration.editor !== undefined) { |
||
0 ignored issues
–
show
Comprehensibility
Bug
Compatibility
introduced
by
|
|||
16 | ns.basePath = H5PIntegration.editor.libraryUrl; |
||
17 | ns.fileIcon = H5PIntegration.editor.fileIcon; |
||
18 | ns.ajaxPath = H5PIntegration.editor.ajaxPath; |
||
19 | ns.filesPath = H5PIntegration.editor.filesPath; |
||
20 | ns.apiVersion = H5PIntegration.editor.apiVersion; |
||
21 | // Semantics describing what copyright information can be stored for media. |
||
22 | ns.copyrightSemantics = H5PIntegration.editor.copyrightSemantics; |
||
23 | // Required styles and scripts for the editor |
||
24 | ns.assets = H5PIntegration.editor.assets; |
||
25 | // Required for assets |
||
26 | ns.baseUrl = ''; |
||
27 | ns.metadataSemantics = H5PIntegration.editor.metadataSemantics |
||
28 | if (H5PIntegration.editor.nodeVersionId !== undefined) { |
||
29 | ns.contentId = H5PIntegration.editor.nodeVersionId; |
||
30 | } |
||
31 | |||
32 | var h5peditor; |
||
33 | var $upload = $('.laravel-h5p-upload').parents('.laravel-h5p-upload-container'); |
||
34 | var $editor = $('#laravel-h5p-editor'); |
||
35 | var $create = $('#laravel-h5p-create').hide(); |
||
36 | var $type = $('.laravel-h5p-type'); |
||
37 | var $params = $('#laravel-h5p-parameters'); |
||
38 | var $library = $('#laravel-h5p-library'); |
||
39 | var library = $library.val(); |
||
40 | |||
41 | $type.change(function () { |
||
42 | if ($type.filter(':checked').val() === 'upload') { |
||
43 | $create.hide(); |
||
44 | $upload.show(); |
||
45 | } else { |
||
46 | $upload.hide(); |
||
47 | if (h5peditor === undefined) { |
||
48 | h5peditor = new ns.Editor(library, $params.val(), $editor[0]); |
||
0 ignored issues
–
show
The variable
ns seems to be never declared. If this is a global, consider adding a /** global: ns */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
49 | } |
||
50 | $create.show(); |
||
51 | } |
||
52 | }); |
||
53 | |||
54 | if ($type.filter(':checked').val() === 'upload') { |
||
55 | $type.change(); |
||
56 | } else { |
||
57 | $type.filter('input[value="create"]').attr('checked', true).change(); |
||
58 | } |
||
59 | |||
60 | $('#laravel-h5p-form').submit(function () { |
||
61 | if (h5peditor !== undefined) { |
||
62 | var params = h5peditor.getParams(); |
||
63 | |||
64 | if (params !== undefined) { |
||
65 | $library.val(h5peditor.getLibrary()); |
||
66 | $params.val(JSON.stringify(params)); |
||
67 | } else { |
||
68 | return false; |
||
69 | } |
||
70 | } |
||
71 | |||
72 | $(this).find('.btn').button('loading'); |
||
0 ignored issues
–
show
|
|||
73 | }); |
||
74 | |||
75 | // Title label |
||
76 | var $title = $('#laravel-h5p-title'); |
||
77 | var $label = $title.prev(); |
||
78 | $title.focus(function () { |
||
79 | $label.addClass('screen-reader-text'); |
||
80 | }).blur(function () { |
||
81 | |||
82 | if ($title.val() === '') { |
||
83 | ns.getAjaxUrl('libraries') |
||
0 ignored issues
–
show
The variable
ns seems to be never declared. If this is a global, consider adding a /** global: ns */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
84 | $label.removeClass('screen-reader-text'); |
||
85 | } |
||
86 | }).focus(); |
||
87 | |||
88 | // Delete confirm |
||
89 | $('#laravel-h5p-destory').click(function () { |
||
90 | return confirm(H5PIntegration.editor.deleteMessage); |
||
0 ignored issues
–
show
The variable
H5PIntegration seems to be never declared. If this is a global, consider adding a /** global: H5PIntegration */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() Debugging Code
Best Practice
introduced
by
|
|||
91 | }); |
||
92 | } |
||
93 | |||
94 | |||
95 | } |
||
96 | |||
97 | |||
98 | ns.getAjaxUrl = function (action, parameters) { |
||
99 | var url = H5PIntegration.editor.ajaxPath + action + '/?'; |
||
0 ignored issues
–
show
The variable
H5PIntegration seems to be never declared. If this is a global, consider adding a /** global: H5PIntegration */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
100 | var request_params = []; |
||
101 | |||
102 | if (parameters !== undefined) { |
||
103 | for (var property in parameters) { |
||
104 | if (parameters.hasOwnProperty(property)) { |
||
105 | request_params.push(encodeURIComponent(property) + "=" + encodeURIComponent(parameters[property])); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | return url + request_params.join('&'); |
||
110 | }; |
||
111 | |||
112 | |||
113 | |||
114 | $(document).ready(ns.init); |
||
115 | |||
116 | |||
117 | })(H5P.jQuery); |
||
0 ignored issues
–
show
The variable
H5P seems to be never declared. If this is a global, consider adding a /** global: H5P */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
118 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.