jclic 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +5 -7
  2. package/dist-node/jclic-node.js +14157 -0
  3. package/dist-node/jclic-node.umd.cjs +530 -0
  4. package/package.json +38 -26
  5. package/.vscode/launch.json +0 -33
  6. package/.vscode/settings.json +0 -13
  7. package/CHANGELOG.md +0 -672
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31680
  11. package/dist/jclic-node.js.map +0 -1
  12. package/dist/jclic.components.LICENSE +0 -2254
  13. package/dist/jclic.min.js +0 -27
  14. package/dist/jclic.min.js.map +0 -1
  15. package/eslint.config.mjs +0 -31
  16. package/jsdoc.config.js +0 -71
  17. package/locales/ar.po +0 -244
  18. package/locales/ast.po +0 -246
  19. package/locales/bs.po +0 -247
  20. package/locales/ca.po +0 -248
  21. package/locales/ca_ES@valencia.po +0 -248
  22. package/locales/cs.po +0 -244
  23. package/locales/da.po +0 -244
  24. package/locales/de.po +0 -246
  25. package/locales/el.po +0 -244
  26. package/locales/es.po +0 -248
  27. package/locales/eu.po +0 -244
  28. package/locales/fr.po +0 -244
  29. package/locales/gl.po +0 -244
  30. package/locales/he.po +0 -244
  31. package/locales/hr.po +0 -245
  32. package/locales/it.po +0 -246
  33. package/locales/ja.po +0 -242
  34. package/locales/jclic.js.pot +0 -241
  35. package/locales/nb_NO.po +0 -244
  36. package/locales/nl.po +0 -244
  37. package/locales/pl.po +0 -244
  38. package/locales/pt.po +0 -244
  39. package/locales/pt_BR.po +0 -248
  40. package/locales/ro.po +0 -248
  41. package/locales/ru.po +0 -245
  42. package/locales/ta.po +0 -244
  43. package/locales/tr.po +0 -246
  44. package/locales/uk.po +0 -247
  45. package/locales/vec.po +0 -244
  46. package/locales/zh_TW.po +0 -246
  47. package/patches/po2json+1.0.0-beta-3.patch +0 -12
  48. package/src/AWT.js +0 -2067
  49. package/src/Activity.js +0 -1311
  50. package/src/Deps.js +0 -232
  51. package/src/GlobalData.js +0 -5
  52. package/src/JClic.js +0 -196
  53. package/src/JClicPlayer.js +0 -1308
  54. package/src/PlayerHistory.js +0 -305
  55. package/src/Utils.js +0 -1355
  56. package/src/activities/associations/ComplexAssociation.js +0 -321
  57. package/src/activities/associations/SimpleAssociation.js +0 -519
  58. package/src/activities/memory/MemoryGame.js +0 -423
  59. package/src/activities/panels/Explore.js +0 -349
  60. package/src/activities/panels/Identify.js +0 -356
  61. package/src/activities/panels/InformationScreen.js +0 -262
  62. package/src/activities/panels/Menu.js +0 -209
  63. package/src/activities/panels/icons/ico00.png +0 -0
  64. package/src/activities/panels/icons/ico01.png +0 -0
  65. package/src/activities/panels/icons/ico02.png +0 -0
  66. package/src/activities/panels/icons/ico03.png +0 -0
  67. package/src/activities/panels/icons/icofolder.png +0 -0
  68. package/src/activities/puzzles/DoublePuzzle.js +0 -424
  69. package/src/activities/puzzles/ExchangePuzzle.js +0 -374
  70. package/src/activities/puzzles/HolePuzzle.js +0 -360
  71. package/src/activities/text/Complete.js +0 -127
  72. package/src/activities/text/Evaluator.js +0 -534
  73. package/src/activities/text/FillInBlanks.js +0 -426
  74. package/src/activities/text/IdentifyText.js +0 -253
  75. package/src/activities/text/OrderText.js +0 -421
  76. package/src/activities/text/TextActivityBase.js +0 -557
  77. package/src/activities/text/TextActivityDocument.js +0 -660
  78. package/src/activities/text/WrittenAnswer.js +0 -557
  79. package/src/activities/textGrid/CrossWord.js +0 -565
  80. package/src/activities/textGrid/WordSearch.js +0 -458
  81. package/src/activities/textGrid/icons/hIcon.svg +0 -3
  82. package/src/activities/textGrid/icons/vIcon.svg +0 -3
  83. package/src/automation/AutoContentProvider.js +0 -182
  84. package/src/automation/arith/Arith.js +0 -864
  85. package/src/bags/ActivitySequence.js +0 -318
  86. package/src/bags/ActivitySequenceElement.js +0 -161
  87. package/src/bags/ActivitySequenceJump.js +0 -140
  88. package/src/bags/ConditionalJumpInfo.js +0 -113
  89. package/src/bags/JumpInfo.js +0 -136
  90. package/src/bags/MediaBag.js +0 -215
  91. package/src/bags/MediaBagElement.js +0 -516
  92. package/src/boxes/AbstractBox.js +0 -699
  93. package/src/boxes/ActiveBagContent.js +0 -494
  94. package/src/boxes/ActiveBox.js +0 -810
  95. package/src/boxes/ActiveBoxBag.js +0 -357
  96. package/src/boxes/ActiveBoxContent.js +0 -484
  97. package/src/boxes/ActiveBoxGrid.js +0 -179
  98. package/src/boxes/BoxBag.js +0 -500
  99. package/src/boxes/BoxBase.js +0 -398
  100. package/src/boxes/BoxConnector.js +0 -325
  101. package/src/boxes/TextGrid.js +0 -887
  102. package/src/boxes/TextGridContent.js +0 -215
  103. package/src/init-jsdom.js +0 -65
  104. package/src/jclic-node.js +0 -219
  105. package/src/media/ActiveMediaBag.js +0 -145
  106. package/src/media/ActiveMediaPlayer.js +0 -297
  107. package/src/media/AudioBuffer.js +0 -219
  108. package/src/media/EventSounds.js +0 -169
  109. package/src/media/EventSoundsElement.js +0 -155
  110. package/src/media/MediaContent.js +0 -328
  111. package/src/media/MidiAudioPlayer.js +0 -254
  112. package/src/media/icons/audio.svg +0 -3
  113. package/src/media/icons/generic.svg +0 -3
  114. package/src/media/icons/mic.svg +0 -3
  115. package/src/media/icons/movie.svg +0 -3
  116. package/src/media/icons/music.svg +0 -3
  117. package/src/media/icons/url.svg +0 -3
  118. package/src/media/sounds/actionError.mp3 +0 -0
  119. package/src/media/sounds/actionOk.mp3 +0 -0
  120. package/src/media/sounds/click.mp3 +0 -0
  121. package/src/media/sounds/finishedError.mp3 +0 -0
  122. package/src/media/sounds/finishedOk.mp3 +0 -0
  123. package/src/media/sounds/start.mp3 +0 -0
  124. package/src/project/JClicProject.js +0 -282
  125. package/src/project/ProjectSettings.js +0 -273
  126. package/src/report/ActionReg.js +0 -123
  127. package/src/report/ActivityReg.js +0 -271
  128. package/src/report/EncryptMin.js +0 -210
  129. package/src/report/Reporter.js +0 -727
  130. package/src/report/SCORM.js +0 -272
  131. package/src/report/SequenceReg.js +0 -275
  132. package/src/report/SessionReg.js +0 -340
  133. package/src/report/SessionStorageReporter.js +0 -131
  134. package/src/report/TCPReporter.js +0 -628
  135. package/src/shapers/ClassicJigSaw.js +0 -138
  136. package/src/shapers/Holes.js +0 -77
  137. package/src/shapers/JigSaw.js +0 -161
  138. package/src/shapers/Rectangular.js +0 -78
  139. package/src/shapers/Shaper.js +0 -386
  140. package/src/shapers/TriangularJigSaw.js +0 -121
  141. package/src/skins/BlueSkin.js +0 -80
  142. package/src/skins/Counter.js +0 -152
  143. package/src/skins/CustomSkin.js +0 -412
  144. package/src/skins/DefaultSkin.js +0 -376
  145. package/src/skins/EmptySkin.js +0 -82
  146. package/src/skins/GreenSkin.js +0 -94
  147. package/src/skins/MiniSkin.js +0 -130
  148. package/src/skins/OrangeSkin.js +0 -78
  149. package/src/skins/SimpleSkin.js +0 -92
  150. package/src/skins/Skin.js +0 -1021
  151. package/src/skins/assets/actionsIcon.svg +0 -3
  152. package/src/skins/assets/appLogo.svg +0 -8
  153. package/src/skins/assets/basic.css +0 -41
  154. package/src/skins/assets/closeDialogIcon.svg +0 -3
  155. package/src/skins/assets/closeIcon.svg +0 -3
  156. package/src/skins/assets/copyIcon.svg +0 -3
  157. package/src/skins/assets/fullScreenExitIcon.svg +0 -3
  158. package/src/skins/assets/fullScreenIcon.svg +0 -3
  159. package/src/skins/assets/infoIcon.svg +0 -3
  160. package/src/skins/assets/main.css +0 -43
  161. package/src/skins/assets/mainHalf.css +0 -23
  162. package/src/skins/assets/mainTwoThirds.css +0 -23
  163. package/src/skins/assets/mini.css +0 -15
  164. package/src/skins/assets/nextIcon.svg +0 -3
  165. package/src/skins/assets/okDialogIcon.svg +0 -3
  166. package/src/skins/assets/prevIcon.svg +0 -3
  167. package/src/skins/assets/reports.css +0 -156
  168. package/src/skins/assets/reportsIcon.svg +0 -3
  169. package/src/skins/assets/scoreIcon.svg +0 -3
  170. package/src/skins/assets/simple.css +0 -16
  171. package/src/skins/assets/simpleHalf.css +0 -11
  172. package/src/skins/assets/simpleTwoThirds.css +0 -11
  173. package/src/skins/assets/timeIcon.svg +0 -4
  174. package/src/skins/assets/waitAnim.css +0 -54
  175. package/src/skins/assets/waitImgBig.svg +0 -3
  176. package/src/skins/assets/waitImgSmall.svg +0 -3
  177. package/webpack.config.mjs +0 -169
@@ -1,557 +0,0 @@
1
- /**
2
- * File : activities/text/TextActivityBase.js
3
- * Created : 16/05/2015
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- /* global window */
33
-
34
- import $ from 'jquery';
35
- import { stringToWords } from '../../Utils.js';
36
- import { Activity, ActivityPanel } from '../../Activity.js';
37
- import ActiveBox from '../../boxes/ActiveBox.js';
38
- import BoxBase from '../../boxes/BoxBase.js';
39
-
40
- /**
41
- * This class and its visual component {@link module:activities/text/TextActivityBase.TextActivityBasePanel TextActivityBasePanel} are the base for text
42
- * activities like {@link module:activities/text/FillInBlanks.FillInBlanks FillInBlanks}, {@link module:activities/text/IdentifyText.IdentifyText IdentifyText}, {@link module:activities/text/OrderText.OrderText OrderText} and {@link module:activities/text/Complete.Complete Complete}.
43
- * @extends module:Activity.Activity
44
- */
45
- export class TextActivityBase extends Activity {
46
- /**
47
- * TextActivityBase constructor
48
- * @param {module:project/JClicProject.JClicProject} project - The project to which this activity belongs
49
- */
50
- constructor(project) {
51
- super(project);
52
- }
53
-
54
- /**
55
- * Retrieves the minimum number of actions needed to solve this activity
56
- * @override
57
- * @returns {number}
58
- */
59
- getMinNumActions() {
60
- return this.document ? this.document.numTargets : 0;
61
- }
62
- }
63
-
64
- Object.assign(TextActivityBase.prototype, {
65
- /**
66
- * This is the object used to evaluate user's answers in text activities.
67
- * @name module:activities/text/TextActivityBase.TextActivityBase#ev
68
- * @type {module:activities/text/Evaluator.Evaluator} */
69
- ev: null,
70
- /**
71
- * This is the label used by text activities for the `check` button, when present.
72
- * @name module:activities/text/TextActivityBase.TextActivityBase#checkButtonText
73
- * @type {string} */
74
- checkButtonText: null,
75
- /**
76
- * When `true`, a text will be shown before the beginning of the activity.
77
- * @name module:activities/text/TextActivityBase.TextActivityBase#prevScreen
78
- * @type {boolean} */
79
- prevScreen: false,
80
- /**
81
- * Optional text to be shown before the beginning of the activity. When `null`, this text is
82
- * the main document.
83
- * @name module:activities/text/TextActivityBase.TextActivityBase#prevScreenText
84
- * @type {string} */
85
- prevScreenText: null,
86
- /**
87
- * The style of the optional text to be shown before the beginning of the activity.
88
- * @name module:activities/text/TextActivityBase.TextActivityBase#prevScreenStyle
89
- * @type {module:boxes/BoxBase.BoxBase} */
90
- prevScreenStyle: null,
91
- /**
92
- * Maximum amount of time for showing the previous document.
93
- * @name module:activities/text/TextActivityBase.TextActivityBase#prevScreenMaxTime
94
- * @type {number} */
95
- prevScreenMaxTime: -1,
96
- });
97
-
98
- /**
99
- * The {@link module:Activity.ActivityPanel ActivityPanel} where text activities (based on {@link module:activities/text/TextActivityBase.TextActivityBase TextActivityBase}) are played.
100
- * @extends module:Activity.ActivityPanel
101
- */
102
- //export class TextActivityBasePanel extends Activity.Panel {
103
- export class TextActivityBasePanel extends ActivityPanel {
104
- /**
105
- * TextActivityBasePanel constructor
106
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
107
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
108
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
109
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
110
- */
111
- constructor(act, ps, $div) {
112
- super(act, ps, $div);
113
- this.targets = [];
114
- }
115
-
116
- /**
117
- * Fills a jQuery DOM element (usually a 'div') with the specified {@link module:activities/text/TextActivityDocument.TextActivityDocument TextActivityDocument}.
118
- * @param {external:jQuery} $div - The jQuery DOM object to be filled with the document.
119
- * @param {module:activities/text/TextActivityDocument.TextActivityDocument} doc - The document
120
- */
121
- setDocContent($div, doc) {
122
-
123
- // Empties the container of any pre-existing content
124
- // and sets the background and other attributes indicated by the main
125
- // style of the document.
126
- // It also sets the 'overflow' CSS attribute to 'auto', which will display a
127
- // vertical scroll bar when needed
128
- $div.empty().css(doc.style['default'].css).css({ display: 'flex', 'flex-direction': 'column' });
129
-
130
- const $scroller = $('<div/>').css({ 'flex-grow': 1, overflow: 'auto' });
131
- const $doc = $('<div/>', { class: 'JClicTextDocument' }).css({ 'padding': 4 }).css(doc.style['default'].css);
132
-
133
- let currentPStyle = null;
134
- const popupSpans = [];
135
-
136
- //
137
- // Process paragraphs
138
- doc.p.forEach(p => {
139
- // Creates a new DOM paragraph
140
- const $p = $('<p/>').css({ margin: 0 });
141
- let empty = true;
142
-
143
- // Check if the paragraph has its own style
144
- if (p.style) {
145
- currentPStyle = doc.style[p.style].css;
146
- $p.css(currentPStyle);
147
- } else
148
- currentPStyle = null;
149
-
150
- // Check if the paragraph has a special alignment
151
- if (p.Alignment) {
152
- const al = Number(p.Alignment);
153
- $p.css({ 'text-align': al === 1 ? 'center' : al === 2 ? 'right' : 'left' });
154
- }
155
-
156
- // Process the paragraph elements
157
- p.elements.forEach(element => {
158
- // Elements will be inserted as 'span' DOM elements, or as simple text if they don't
159
- // have specific attributes.
160
- let $span;
161
- switch (element.objectType) {
162
- case 'text':
163
- const parsedText = $('<span/>').html(element.text).text();
164
- const fragments = this.spanText
165
- ? stringToWords(parsedText)
166
- : [{ text: parsedText, sep: '' }];
167
- fragments.forEach(({ text, sep }) => {
168
- let initialCSS = { ...this.act.document.style['default'].css };
169
- if (element?.attr?.style)
170
- initialCSS = { ...initialCSS, ...doc.style[element.attr.style].css };
171
- if (element?.attr?.css)
172
- initialCSS = { ...initialCSS, ...element.attr.css };
173
- const txtBlocs = this.spanChars ? [...text] : [text];
174
- txtBlocs.forEach((str) => {
175
- if (element.attr) {
176
- // Text uses a specific style and/or individual attributes
177
- $span = $('<span/>').html(str).css(initialCSS);
178
- // Save initialCSS for later use
179
- $span.initialCSS = initialCSS;
180
- $p.append(this.$createSpanElement($span));
181
- } else {
182
- if (this.spanText) {
183
- $span = $('<span/>').html(str);
184
- $p.append(this.$createSpanElement($span));
185
- }
186
- else
187
- $p.append(str);
188
- }
189
- });
190
- if (sep !== '')
191
- $p.append(sep);
192
- });
193
- break;
194
-
195
- case 'cell':
196
- // Create a new ActiveBox based on this ActiveBoxContent
197
- $span = $('<span/>');
198
- const box = ActiveBox.createCell($span.css({ position: 'relative' }), element);
199
- $span.css({ 'display': 'inline-block', 'vertical-align': 'middle' });
200
- if (element.mediaContent) {
201
- $span.on('click', event => {
202
- event.preventDefault();
203
- this.ps.stopMedia(1);
204
- box.playMedia(this.ps);
205
- return false;
206
- });
207
- }
208
- $p.append($span);
209
- break;
210
-
211
- case 'target':
212
- $span = $('<span/>');
213
- if (this.showingPrevScreen) {
214
- $span.text(element.text);
215
- $p.append($span);
216
- break;
217
- }
218
-
219
- const target = element;
220
- let $popup = null;
221
- // Process target popups
222
- if (target.infoMode !== 'no_info' && target.popupContent) {
223
- $popup = $('<span/>').css({ position: 'absolute', 'padding-top': '2pt', display: 'none' });
224
- // Create a new ActiveBox based on popupContent
225
- const popupBox = ActiveBox.createCell($popup, target.popupContent);
226
- if (target.popupContent.mediaContent) {
227
- $popup.on('click', event => {
228
- event.preventDefault();
229
- this.ps.stopMedia(1);
230
- if (popupBox)
231
- popupBox.playMedia(this.ps);
232
- else if (target.popupContent.mediaContent)
233
- this.ps.playMedia(target.popupContent.mediaContent);
234
- return false;
235
- });
236
- }
237
- target.$popup = $popup;
238
- // Save for later setting of top-margin
239
- popupSpans.push({ p: $p, span: $popup, box: popupBox });
240
- }
241
-
242
- $span = this.$createTargetElement(target, $span);
243
- target.num = this.targets.length;
244
- target.pos = target.num;
245
- this.targets.push(target);
246
- if ($span) {
247
- $span.css(doc.style['default'].css);
248
- if (currentPStyle)
249
- $span.css(currentPStyle);
250
- if (this.targetsMarked) {
251
- if (target.attr) {
252
- // Default style name for targets is 'target'
253
- if (!target.attr.style)
254
- target.attr.style = 'target';
255
- $span.css(doc.style[target.attr.style].css);
256
- // Check if target has specific attributes
257
- if (target.attr.css)
258
- $span.css(target.attr.css);
259
- } else if (doc.style['target'])
260
- $span.css(doc.style['target'].css);
261
- } else {
262
- target.targetStatus = 'HIDDEN';
263
- }
264
-
265
- // Catch on-demand popups with `F1`, cancel with `Escape`
266
- if ($popup !== null && target.infoMode === 'onDemand') {
267
- $span.on('keydown', ev => {
268
- if (ev.key === target.popupKey) {
269
- ev.preventDefault();
270
- this.showPopup($popup, target.popupMaxTime, target.popupDelay);
271
- } else if (ev.key === 'Escape') {
272
- ev.preventDefault();
273
- this.showPopup(null);
274
- }
275
- });
276
- }
277
- }
278
-
279
- if ($popup && $span) {
280
- if (target.isList)
281
- $p.append($span).append($popup);
282
- else
283
- $p.append($popup).append($span);
284
- } else if ($span)
285
- $p.append($span);
286
-
287
- target.$p = $p;
288
- break;
289
- }
290
- empty = false;
291
- });
292
- if (empty)
293
- // Don't leave paragraphs empty
294
- $p.html('&nbsp;');
295
-
296
- // Adds the paragraph to the DOM element
297
- $doc.append($p);
298
- });
299
-
300
- $div.append($scroller.append($doc));
301
-
302
- if (this.act.checkButtonText && !this.showingPrevScreen) {
303
- this.$checkButton = $('<button/>', { class: 'StockBtn' })
304
- .html(this.act.checkButtonText)
305
- .css({ width: '100%', 'flex-shrink': 0 })
306
- .on('click', () => this.evaluatePanel());
307
- $div.append(this.$checkButton);
308
- }
309
-
310
- // Place popups below its target baseline
311
- popupSpans.forEach(pspan => pspan.span.css({ 'margin-top': pspan.p.css('font-size') }));
312
-
313
- // Init Evaluator
314
- if (this.act.ev)
315
- this.act.ev.init(this.act.project.settings.locales);
316
-
317
- return $div;
318
- }
319
-
320
- /**
321
- * Creates a target DOM element.
322
- * This method can be overridden in subclasses to create specific types of targets.
323
- * @param {module:activities/text/TextActivityDocument.TextTarget} target - The target related to the DOM object to be created
324
- * @param {external:jQuery} $span - An initial DOM object (usually a `span`) that can be used
325
- * to store the target, or replaced by another type of object.
326
- * @returns {external:jQuery} - The jQuery DOM element loaded with the target data.
327
- */
328
- $createTargetElement(target, $span) {
329
- $span.text(target.text);
330
- target.$span = $span;
331
- return $span;
332
- }
333
-
334
- /**
335
- * Creates a 'span' element, used to isolate elements of text not involved in targets.
336
- * Used only when {@link spanText} is true.
337
- * @param {external:jQuery} $span - An initial DOM object (usually a `span`) that can be used
338
- * to store the target, or replaced by another type of object.
339
- * @returns {external:jQuery} - The jQuery DOM element loaded with the span data.
340
- */
341
- $createSpanElement($span) {
342
- return $span;
343
- }
344
-
345
- /**
346
- * Basic initialization procedure, common to all activities.
347
- * @override
348
- */
349
- initActivity() {
350
- if (this.act.prevScreen)
351
- this.preInitActivity();
352
- else
353
- this.startActivity();
354
- }
355
-
356
- /**
357
- * Called when the activity starts playing
358
- * @override
359
- */
360
- startActivity() {
361
- super.initActivity();
362
- this.setAndPlayMsg('initial', 'start');
363
- this.setDocContent(this.$div, this.act.document);
364
- this.playing = true;
365
- }
366
-
367
- /**
368
- * Called when the text activity has a 'previous screen' information to be shown before the
369
- * activity starts
370
- */
371
- preInitActivity() {
372
- if (!this.act.prevScreen)
373
- return;
374
-
375
- const prevScreenEnd = () => {
376
- this.showingPrevScreen = false;
377
- this.$div.off('click');
378
- if (this.prevScreenTimer) {
379
- window.clearTimeout(this.prevScreenTimer);
380
- this.prevScreenTimer = null;
381
- }
382
- this.startActivity();
383
- return true;
384
- };
385
-
386
- this.showingPrevScreen = true;
387
- this.$div.empty();
388
-
389
- if (!this.act.prevScreenText) {
390
- this.setDocContent(this.$div, this.act.document);
391
- } else {
392
- if (!this.act.prevScreenStyle)
393
- this.act.prevScreenStyle = new BoxBase();
394
- this.$div.css(this.act.prevScreenStyle.getCSS()).css('overflow', 'auto');
395
- const $html = $('<div/>', { class: 'JClicTextDocument' })
396
- .css({ 'padding': 4 })
397
- .css(this.act.prevScreenStyle.getCSS())
398
- .append(this.act.prevScreenText);
399
- this.$div.append($html);
400
- }
401
-
402
- this.enableCounters(true, false, false);
403
- this.ps.setCounterValue('time', 0);
404
-
405
- this.ps.setMsg(this.act.messages['previous']);
406
-
407
- if (this.act.prevScreenMaxTime > 0) {
408
- this.ps.setCountDown('time', this.act.prevScreenMaxTime);
409
- this.prevScreenTimer = window.setTimeout(prevScreenEnd, this.act.prevScreenMaxTime * 1000);
410
- }
411
-
412
- this.$div.on('click', prevScreenEnd);
413
- this.ps.playMsg();
414
- }
415
-
416
- /**
417
- * Called when the user clicks on the check button
418
- * @returns {boolean} - `true` when the panel is OK, `false` otherwise.
419
- */
420
- evaluatePanel() {
421
- this.finishActivity(true);
422
- return true;
423
- }
424
-
425
- /**
426
- * Ordinary ending of the activity, usually called form `processEvent`
427
- * @override
428
- * @param {boolean} result - `true` if the activity was successfully completed, `false` otherwise
429
- */
430
- finishActivity(result) {
431
- if (this.$checkButton)
432
- this.$checkButton.prop('disabled', true);
433
- this.targets.forEach(t => {
434
- if (t.$comboList)
435
- t.$comboList.prop('disabled', true);
436
- });
437
- this.showPopup(null);
438
- super.finishActivity(result);
439
- }
440
-
441
- /**
442
- * Main handler used to process mouse, touch, keyboard and edit events
443
- * @override
444
- * @param {external:Event} _event - The HTML event to be processed
445
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
446
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
447
- */
448
- processEvent(_event) {
449
- return this.playing;
450
- }
451
-
452
- /**
453
- * @param {external:jQuery} $popup - The popup to display, or _null _ to just hide the current popup
454
- * @param {number} maxTime - The maximum time to mantain the popup on screen, in seconds
455
- * @param {number} waitTime - When set, indicates the number of seconds to wait before show the popup
456
- */
457
- showPopup($popup, maxTime, waitTime) {
458
- // Hide current popup
459
- if (this.$currentPopup) {
460
- this.$currentPopup.css({ display: 'none' });
461
- this.$currentPopup = null;
462
- if (this.currentPopupTimer) {
463
- window.clearTimeout(this.currentPopupTimer);
464
- this.currentPopupTimer = 0;
465
- }
466
- }
467
-
468
- // Clear popupWaitTimer
469
- if (this.popupWaitTimer) {
470
- window.clearTimeout(this.popupWaitTimer);
471
- this.popupWaitTimer = 0;
472
- }
473
-
474
- // Prepare popup timer
475
- if (waitTime) {
476
- this.popupWaitTimer = window.setTimeout(() => {
477
- this.showPopup($popup, maxTime);
478
- }, waitTime * 1000);
479
- return;
480
- }
481
-
482
- if ($popup) {
483
- $popup.css({ display: '' });
484
- $popup.trigger('click');
485
-
486
- this.$currentPopup = $popup;
487
- if (maxTime) {
488
- this.currentPopupTimer = window.setTimeout(() => {
489
- $popup.css({ display: 'none' });
490
- if (this.$currentPopup === $popup) {
491
- this.$currentPopup = null;
492
- this.currentPopupTimer = 0;
493
- }
494
- }, maxTime * 1000);
495
- }
496
- }
497
- }
498
- }
499
-
500
- Object.assign(TextActivityBasePanel.prototype, {
501
- /**
502
- * Array of jQuery DOM elements (usually of type 'span') containing the targets of this activity
503
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#targets
504
- * @type {external:jQuery[]} */
505
- targets: null,
506
- /**
507
- * Flag indicating if targets must be visually marked at the beginning of the activity.
508
- * Should be `true` except for {@link module:activities/text/IdentifyText.IdentifyText IdentifyText} activities.
509
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#targetsMarked
510
- * @type {boolean} */
511
- targetsMarked: true,
512
- /**
513
- * The button used to check the activity, only when `Activity.checkButtonText` is not null
514
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#$checkButton
515
- * @type {external:jQuery}*/
516
- $checkButton: null,
517
- /**
518
- * System timer used to close the previous document when act.maxTime is reached.
519
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#prevScreenTimer
520
- * @type {number} */
521
- prevScreenTimer: null,
522
- /**
523
- * The popup currently been displayed
524
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#$currentPopup
525
- * @type {external:jQuery} */
526
- $currentPopup: null,
527
- /**
528
- * A timer controlling the time the current popup will be displayed
529
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#currentPopupTimer
530
- * @type {number} */
531
- currentPopupTimer: 0,
532
- /**
533
- * A timer prepared to display a popup after a while
534
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#popupWaitTimer
535
- * @type {number} */
536
- popupWaitTimer: 0,
537
- /**
538
- * When true, all text outside of targets and cells will be inserted as independent words or letters,
539
- * using 'span' elements. {@link module:activities/text/TextActivityBase.TextActivityBasePanel#$createSpanElement} can be used
540
- * to customize these elements.
541
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#spanText
542
- * @type {boolean} */
543
- spanText: false,
544
- /**
545
- * When true, text spanning will be done at char level: each single letter will be a clickacle span.
546
- * Used only in activities of type "itentify letters"
547
- * @name module:activities/text/TextActivityBase.TextActivityBasePanel#spanChars
548
- * @type {boolean} */
549
- spanChars: false,
550
- });
551
-
552
- /**
553
- * Panel class associated to this type of activity: {@link module:activities/text/TextActivityBase.TextActivityBasePanel TextActivityBasePanel}
554
- * @type {class} */
555
- TextActivityBase.Panel = TextActivityBasePanel;
556
-
557
- export default TextActivityBase;