jclic 2.1.21 → 2.1.22

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 (173) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/jclic-node.js +1 -1
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/GlobalData.js +1 -1
  8. package/dist/1078.jclic-node.js +0 -282
  9. package/dist/1078.jclic-node.js.map +0 -1
  10. package/dist/1196.jclic-node.js +0 -808
  11. package/dist/1196.jclic-node.js.map +0 -1
  12. package/dist/1253.jclic-node.js +0 -1432
  13. package/dist/1253.jclic-node.js.map +0 -1
  14. package/dist/13.jclic-node.js +0 -103
  15. package/dist/13.jclic-node.js.map +0 -1
  16. package/dist/1567.jclic-node.js +0 -2313
  17. package/dist/1567.jclic-node.js.map +0 -1
  18. package/dist/1588.jclic-node.js +0 -602
  19. package/dist/1588.jclic-node.js.map +0 -1
  20. package/dist/1725.jclic-node.js +0 -836
  21. package/dist/1725.jclic-node.js.map +0 -1
  22. package/dist/1731.jclic-node.js +0 -438
  23. package/dist/1731.jclic-node.js.map +0 -1
  24. package/dist/1842.jclic-node.js +0 -651
  25. package/dist/1842.jclic-node.js.map +0 -1
  26. package/dist/2160.jclic-node.js +0 -1016
  27. package/dist/2160.jclic-node.js.map +0 -1
  28. package/dist/222.jclic-node.js +0 -129
  29. package/dist/222.jclic-node.js.map +0 -1
  30. package/dist/2316.jclic-node.js +0 -949
  31. package/dist/2316.jclic-node.js.map +0 -1
  32. package/dist/2355.jclic-node.js +0 -371
  33. package/dist/2355.jclic-node.js.map +0 -1
  34. package/dist/2366.jclic-node.js +0 -431
  35. package/dist/2366.jclic-node.js.map +0 -1
  36. package/dist/2379.jclic-node.js +0 -202
  37. package/dist/2379.jclic-node.js.map +0 -1
  38. package/dist/2437.jclic-node.js +0 -450
  39. package/dist/2437.jclic-node.js.map +0 -1
  40. package/dist/2531.jclic-node.js +0 -869
  41. package/dist/2531.jclic-node.js.map +0 -1
  42. package/dist/2608.jclic-node.js +0 -160
  43. package/dist/2608.jclic-node.js.map +0 -1
  44. package/dist/2715.jclic-node.js +0 -554
  45. package/dist/2715.jclic-node.js.map +0 -1
  46. package/dist/277.jclic-node.js +0 -22
  47. package/dist/277.jclic-node.js.map +0 -1
  48. package/dist/2921.jclic-node.js +0 -660
  49. package/dist/2921.jclic-node.js.map +0 -1
  50. package/dist/2952.jclic-node.js +0 -101
  51. package/dist/2952.jclic-node.js.map +0 -1
  52. package/dist/3018.jclic-node.js +0 -421
  53. package/dist/3018.jclic-node.js.map +0 -1
  54. package/dist/3019.jclic-node.js +0 -682
  55. package/dist/3019.jclic-node.js.map +0 -1
  56. package/dist/3231.jclic-node.js +0 -274
  57. package/dist/3231.jclic-node.js.map +0 -1
  58. package/dist/331.jclic-node.js +0 -115
  59. package/dist/331.jclic-node.js.map +0 -1
  60. package/dist/3391.jclic-node.js +0 -276
  61. package/dist/3391.jclic-node.js.map +0 -1
  62. package/dist/3502.jclic-node.js +0 -671
  63. package/dist/3502.jclic-node.js.map +0 -1
  64. package/dist/3653.jclic-node.js +0 -982
  65. package/dist/3653.jclic-node.js.map +0 -1
  66. package/dist/371.jclic.min.js +0 -2
  67. package/dist/371.jclic.min.js.map +0 -1
  68. package/dist/3856.jclic-node.js +0 -575
  69. package/dist/3856.jclic-node.js.map +0 -1
  70. package/dist/4112.jclic-node.js +0 -659
  71. package/dist/4112.jclic-node.js.map +0 -1
  72. package/dist/4123.jclic-node.js +0 -910
  73. package/dist/4123.jclic-node.js.map +0 -1
  74. package/dist/427.jclic-node.js +0 -894
  75. package/dist/427.jclic-node.js.map +0 -1
  76. package/dist/4483.jclic-node.js +0 -327
  77. package/dist/4483.jclic-node.js.map +0 -1
  78. package/dist/4548.jclic-node.js +0 -1078
  79. package/dist/4548.jclic-node.js.map +0 -1
  80. package/dist/466.jclic-node.js +0 -99
  81. package/dist/466.jclic-node.js.map +0 -1
  82. package/dist/485.jclic-node.js +0 -783
  83. package/dist/485.jclic-node.js.map +0 -1
  84. package/dist/4921.jclic-node.js +0 -500
  85. package/dist/4921.jclic-node.js.map +0 -1
  86. package/dist/5091.jclic-node.js +0 -239
  87. package/dist/5091.jclic-node.js.map +0 -1
  88. package/dist/520.jclic-node.js +0 -550
  89. package/dist/520.jclic-node.js.map +0 -1
  90. package/dist/5312.jclic-node.js +0 -1126
  91. package/dist/5312.jclic-node.js.map +0 -1
  92. package/dist/5338.jclic-node.js +0 -212
  93. package/dist/5338.jclic-node.js.map +0 -1
  94. package/dist/5344.jclic-node.js +0 -229
  95. package/dist/5344.jclic-node.js.map +0 -1
  96. package/dist/5550.jclic-node.js +0 -238
  97. package/dist/5550.jclic-node.js.map +0 -1
  98. package/dist/5626.jclic-node.js +0 -614
  99. package/dist/5626.jclic-node.js.map +0 -1
  100. package/dist/5977.jclic-node.js +0 -1081
  101. package/dist/5977.jclic-node.js.map +0 -1
  102. package/dist/6148.jclic-node.js +0 -345
  103. package/dist/6148.jclic-node.js.map +0 -1
  104. package/dist/6176.jclic-node.js +0 -481
  105. package/dist/6176.jclic-node.js.map +0 -1
  106. package/dist/6221.jclic-node.js +0 -1072
  107. package/dist/6221.jclic-node.js.map +0 -1
  108. package/dist/6238.jclic-node.js +0 -718
  109. package/dist/6238.jclic-node.js.map +0 -1
  110. package/dist/6454.jclic-node.js +0 -1413
  111. package/dist/6454.jclic-node.js.map +0 -1
  112. package/dist/6565.jclic-node.js +0 -294
  113. package/dist/6565.jclic-node.js.map +0 -1
  114. package/dist/6579.jclic-node.js +0 -719
  115. package/dist/6579.jclic-node.js.map +0 -1
  116. package/dist/6715.jclic-node.js +0 -148
  117. package/dist/6715.jclic-node.js.map +0 -1
  118. package/dist/6777.jclic-node.js +0 -171
  119. package/dist/6777.jclic-node.js.map +0 -1
  120. package/dist/6782.jclic-node.js +0 -1611
  121. package/dist/6782.jclic-node.js.map +0 -1
  122. package/dist/6847.jclic-node.js +0 -601
  123. package/dist/6847.jclic-node.js.map +0 -1
  124. package/dist/6856.jclic-node.js +0 -252
  125. package/dist/6856.jclic-node.js.map +0 -1
  126. package/dist/696.jclic-node.js +0 -1821
  127. package/dist/696.jclic-node.js.map +0 -1
  128. package/dist/698.jclic-node.js +0 -583
  129. package/dist/698.jclic-node.js.map +0 -1
  130. package/dist/704.jclic-node.js +0 -80
  131. package/dist/704.jclic-node.js.map +0 -1
  132. package/dist/7046.jclic-node.js +0 -735
  133. package/dist/7046.jclic-node.js.map +0 -1
  134. package/dist/7220.jclic-node.js +0 -156
  135. package/dist/7220.jclic-node.js.map +0 -1
  136. package/dist/7257.jclic-node.js +0 -931
  137. package/dist/7257.jclic-node.js.map +0 -1
  138. package/dist/743.jclic-node.js +0 -583
  139. package/dist/743.jclic-node.js.map +0 -1
  140. package/dist/757.jclic-node.js +0 -1072
  141. package/dist/757.jclic-node.js.map +0 -1
  142. package/dist/7781.jclic-node.js +0 -202
  143. package/dist/7781.jclic-node.js.map +0 -1
  144. package/dist/7912.jclic-node.js +0 -2103
  145. package/dist/7912.jclic-node.js.map +0 -1
  146. package/dist/827.jclic-node.js +0 -708
  147. package/dist/827.jclic-node.js.map +0 -1
  148. package/dist/8276.jclic-node.js +0 -409
  149. package/dist/8276.jclic-node.js.map +0 -1
  150. package/dist/8322.jclic-node.js +0 -498
  151. package/dist/8322.jclic-node.js.map +0 -1
  152. package/dist/8641.jclic-node.js +0 -360
  153. package/dist/8641.jclic-node.js.map +0 -1
  154. package/dist/8837.jclic-node.js +0 -651
  155. package/dist/8837.jclic-node.js.map +0 -1
  156. package/dist/8895.jclic-node.js +0 -151
  157. package/dist/8895.jclic-node.js.map +0 -1
  158. package/dist/9072.jclic-node.js +0 -1285
  159. package/dist/9072.jclic-node.js.map +0 -1
  160. package/dist/9078.jclic-node.js +0 -935
  161. package/dist/9078.jclic-node.js.map +0 -1
  162. package/dist/9103.jclic-node.js +0 -718
  163. package/dist/9103.jclic-node.js.map +0 -1
  164. package/dist/9359.jclic-node.js +0 -145
  165. package/dist/9359.jclic-node.js.map +0 -1
  166. package/dist/9409.jclic-node.js +0 -921
  167. package/dist/9409.jclic-node.js.map +0 -1
  168. package/dist/9513.jclic-node.js +0 -720
  169. package/dist/9513.jclic-node.js.map +0 -1
  170. package/dist/9704.jclic-node.js +0 -81
  171. package/dist/9704.jclic-node.js.map +0 -1
  172. package/dist/9950.jclic-node.js +0 -827
  173. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,783 +0,0 @@
1
- "use strict";
2
- exports.id = 485;
3
- exports.ids = [485,6148];
4
- exports.modules = {
5
-
6
- /***/ 485:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony exports OrderText, OrderTextPanel */
13
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _Activity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1567);
16
- /* harmony import */ var _TextActivityBase_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(743);
17
- /* harmony import */ var _boxes_BoxConnector_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6148);
18
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7912);
19
- /**
20
- * File : activities/text/OrderText.js
21
- * Created : 20/06/2015
22
- * By : Francesc Busquets <francesc@gmail.com>
23
- *
24
- * JClic.js
25
- * An HTML5 player of JClic activities
26
- * https://projectestac.github.io/jclic.js
27
- *
28
- * @source https://github.com/projectestac/jclic.js
29
- *
30
- * @license EUPL-1.2
31
- * @licstart
32
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
33
- *
34
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
35
- * the European Commission- subsequent versions of the EUPL (the "Licence");
36
- * You may not use this work except in compliance with the Licence.
37
- *
38
- * You may obtain a copy of the Licence at:
39
- * https://joinup.ec.europa.eu/software/page/eupl
40
- *
41
- * Unless required by applicable law or agreed to in writing, software
42
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
43
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
44
- * Licence for the specific language governing permissions and limitations
45
- * under the Licence.
46
- * @licend
47
- * @module
48
- */
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
- /**
57
- * In this type of text activity users must put in order some words or paragraphs that have been
58
- * initially shuffled.
59
- * @extends module:activities/text/TextActivityBase.TextActivityBase
60
- */
61
- class OrderText extends _TextActivityBase_js__WEBPACK_IMPORTED_MODULE_2__/* .TextActivityBase */ .q {
62
- /**
63
- * OrderText constructor
64
- * @param {module:project/JClicProject.JClicProject} project - The project to which this activity belongs
65
- */
66
- constructor(project) {
67
- super(project);
68
- }
69
-
70
- /**
71
- * Whether or not the activity uses random to shuffle internal components
72
- * @override
73
- * @returns {boolean}
74
- */
75
- hasRandom() {
76
- return true;
77
- }
78
-
79
- /**
80
- * When `true`, the activity must always be shuffled
81
- * @override
82
- * @returns {boolean}
83
- */
84
- shuffleAlways() {
85
- return true;
86
- }
87
-
88
- /**
89
- * Whether the activity allows the user to request help.
90
- * @override
91
- * @returns {boolean}
92
- */
93
- helpSolutionAllowed() {
94
- return true;
95
- }
96
- }
97
-
98
- Object.assign(OrderText.prototype, {
99
- /**
100
- * Whether to allow or not to shuffle words among different paragraphs.
101
- * @name module:activities/text/OrderText.OrderText#amongParagraphs
102
- * @type {boolean} */
103
- amongParagraphs: false,
104
- /**
105
- * The box connector
106
- * @name module:activities/text/OrderText.OrderText#bc
107
- * @type {module:boxes/BoxConnector.BoxConnector} */
108
- bc: null,
109
- });
110
-
111
- /**
112
- * The {@link module:activities/text/TextActivityBase.TextActivityBasePanel TextActivityBasePanel} where {@link module:activities/text/OrderText.OrderText OrderText} activities are played.
113
- * @extends module:activities/text/TextActivityBase.TextActivityBasePanel
114
- */
115
- class OrderTextPanel extends _TextActivityBase_js__WEBPACK_IMPORTED_MODULE_2__/* .TextActivityBasePanel */ .c {
116
- /**
117
- * OrderTextPanel constructor
118
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
119
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
120
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
121
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
122
- */
123
- constructor(act, ps, $div) {
124
- super(act, ps, $div);
125
- }
126
-
127
- /**
128
- * Prepares the text panel
129
- * @override
130
- */
131
- buildVisualComponents() {
132
- this.act.document.style['target'].css.cursor = 'pointer';
133
- super.buildVisualComponents();
134
- }
135
-
136
- /**
137
- * Sets the size and position of this activity panel
138
- * @override
139
- * @param {module:AWT.Rectangle} rect
140
- */
141
- setBounds(rect) {
142
- if (this.$canvas)
143
- this.$canvas.remove();
144
-
145
- super.setBounds(rect);
146
- if (!this.act.dragCells) {
147
- // Create the main canvas
148
- this.$canvas = jquery__WEBPACK_IMPORTED_MODULE_0___default()(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
149
- position: 'absolute',
150
- top: 0,
151
- left: 0,
152
- 'pointer-events': 'none'
153
- });
154
- this.$div.append(this.$canvas);
155
-
156
- // Create a [BoxConnector](BoxConnector.html) and attach it to the canvas context
157
- this.bc = new _boxes_BoxConnector_js__WEBPACK_IMPORTED_MODULE_3__["default"](this, this.$canvas);
158
- this.bc.compositeOp = this.bc.DEFAULT_COMPOSITE_OP;
159
-
160
- // Repaint all
161
- this.invalidate().update();
162
- }
163
- }
164
-
165
- /**
166
- * Creates a target DOM element for the provided target.
167
- * @override
168
- * @param {module:activities/text/TextActivityDocument.TextTarget} target - The target related to the DOM object to be created
169
- * @param {external:jQuery} $span - - An initial DOM object (usually a `span`) that can be used
170
- * to store the target, or replaced by another type of object.
171
- * @returns {external:jQuery} - The jQuery DOM element loaded with the target data.
172
- */
173
- $createTargetElement(target, $span) {
174
- super.$createTargetElement(target, $span);
175
- const idLabel = `target${`000${this.targets.length - 1}`.slice(-3)}`;
176
- $span.addClass('JClicTextTarget').bind('click', event => {
177
- event.textTarget = target;
178
- event.idLabel = idLabel;
179
- this.processEvent(event);
180
- });
181
- return $span;
182
- }
183
-
184
- /**
185
- * Swaps the position of two targets in the document
186
- * @param {module:activities/text/TextActivityDocument.TextTarget} t1 - One target
187
- * @param {module:activities/text/TextActivityDocument.TextTarget} t2 - Another target
188
- */
189
- swapTargets(t1, t2) {
190
- const
191
- $span1 = t1.$span,
192
- $span2 = t2.$span,
193
- $marker = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<span/>');
194
- $marker.insertAfter($span2);
195
- $span2.detach();
196
- $span2.insertAfter($span1);
197
- $span1.detach();
198
- $span1.insertAfter($marker);
199
- $marker.remove();
200
-
201
- const
202
- pos = t1.pos,
203
- $p = t1.$p;
204
- t1.pos = t2.pos;
205
- t1.$p = t2.$p;
206
- t2.pos = pos;
207
- t2.$p = $p;
208
- }
209
-
210
- /**
211
- * Basic initialization procedure
212
- * @override
213
- */
214
- initActivity() {
215
- super.initActivity();
216
- if (!this.firstRun)
217
- this.buildVisualComponents();
218
- else
219
- this.firstRun = false;
220
- }
221
-
222
- /**
223
- * Called when the activity starts playing
224
- * @override
225
- */
226
- startActivity() {
227
- super.startActivity();
228
- if (!this.showingPrevScreen) {
229
- if (this.act.type === 'orderWords' && !this.act.amongParagraphs) {
230
- // Group targets by paragraph
231
- const groups = [];
232
- let
233
- lastTarget = null,
234
- currentGroup = [];
235
- this.targets.forEach(t => {
236
- if (lastTarget !== null && lastTarget.$p !== t.$p) {
237
- groups.push(currentGroup);
238
- currentGroup = [];
239
- }
240
- currentGroup.push(t);
241
- lastTarget = t;
242
- });
243
- if (currentGroup.length > 0)
244
- groups.push(currentGroup);
245
-
246
- // Scramble group by group
247
- groups.forEach(group => this.shuffleTargets(group, this.act.shuffles));
248
- } else
249
- this.shuffleTargets(this.targets, this.act.shuffles);
250
-
251
- this.playing = true;
252
- }
253
- this.setBounds(this);
254
- }
255
-
256
- /**
257
- * Randomly shuffles a set of targets
258
- * @param {module:activities/text/TextActivityDocument.TextTarget[]} targets - The set of targets to shuffle (can be all
259
- * document targets or just the targets belonging to the same paragraph, depending on the value of
260
- * `amongParagraphs` in {@link module:Activity.Activity Activity}.
261
- * @param {number} steps - The number of times to shuffle the elements
262
- */
263
- shuffleTargets(targets, steps) {
264
- const nt = targets.length;
265
- if (nt > 1) {
266
- let repeatCount = 100;
267
- for (let i = 0; i < steps; i++) {
268
- const
269
- r1 = Math.floor(Math.random() * nt),
270
- r2 = Math.floor(Math.random() * nt);
271
- if (r1 !== r2) {
272
- this.swapTargets(targets[r1], targets[r2]);
273
- } else {
274
- if (--repeatCount)
275
- i++;
276
- }
277
- }
278
- }
279
- }
280
-
281
- /**
282
- * Sets the current target
283
- * @param {module:activities/text/TextActivityDocument.TextTarget} target - The currently selected target. Can be `null`.
284
- */
285
- setCurrentTarget(target) {
286
- const targetCss = this.act.document.getFullStyle('target').css;
287
- if (this.currentTarget && this.currentTarget.$span)
288
- this.currentTarget.$span.css(targetCss);
289
- if (target && target.$span) {
290
- target.$span.css({
291
- color: targetCss['background-color'],
292
- 'background-color': targetCss.color
293
- });
294
- }
295
- this.currentTarget = target;
296
- }
297
-
298
- /**
299
- * Counts the number of targets that are at right position
300
- * @returns {number}
301
- */
302
- countSolvedTargets() {
303
- return this.targets.filter(({ num, pos }) => num === pos).length;
304
- }
305
-
306
- /**
307
- * Evaluates all the targets in this panel. This method is usually called from the `Check` button.
308
- * @override
309
- * @returns {boolean} - `true` when all targets are OK, `false` otherwise.
310
- */
311
- evaluatePanel() {
312
- if (this.bc && this.bc.active)
313
- this.bc.end();
314
- this.setCurrentTarget(null);
315
-
316
- let targetsOk = 0;
317
- this.targets.forEach(target => {
318
- const ok = target.num === target.pos;
319
- target.targetStatus = ok ? 'SOLVED' : 'WITH_ERROR';
320
- if (ok)
321
- targetsOk++;
322
- target.checkColors();
323
- this.ps.reportNewAction(this.act, 'PLACE', target.text, target.pos, ok, targetsOk);
324
- });
325
- if (targetsOk === this.targets.length) {
326
- this.finishActivity(true);
327
- return true;
328
- } else {
329
- this.playEvent('finishedError');
330
- }
331
- return false;
332
- }
333
-
334
- /**
335
- * Ordinary ending of the activity, usually called form `processEvent`
336
- * @override
337
- * @param {boolean} result - `true` if the activity was successfully completed, `false` otherwise
338
- */
339
- finishActivity(result) {
340
- jquery__WEBPACK_IMPORTED_MODULE_0___default()('.JClicTextTarget').css('cursor', 'pointer');
341
- return super.finishActivity(result);
342
- }
343
-
344
- /**
345
- * Main handler used to process mouse, touch, keyboard and edit events.
346
- * @override
347
- * @param {external:Event} event - The HTML event to be processed
348
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
349
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
350
- */
351
- processEvent(event) {
352
- if (!super.processEvent(event))
353
- return false;
354
-
355
- const target = event.textTarget;
356
- let p = null;
357
- if (this.bc && this.playing && !this.showingPrevScreen) {
358
- //
359
- // _touchend_ event don't provide pageX nor pageY information
360
- if (event.type === 'touchend')
361
- p = this.bc.active ? this.bc.dest.clone() : new _AWT_js__WEBPACK_IMPORTED_MODULE_4__/* .Point */ .bR();
362
- else {
363
- // Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
364
- const
365
- x = event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
366
- y = event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY;
367
- p = new _AWT_js__WEBPACK_IMPORTED_MODULE_4__/* .Point */ .bR(x - this.$div.offset().left, y - this.$div.offset().top);
368
- }
369
-
370
- switch (event.type) {
371
- case 'click':
372
- if (target && target !== this.currentTarget) {
373
- if (this.currentTarget) {
374
- if (this.bc && this.bc.active)
375
- this.bc.end();
376
- this.swapTargets(target, this.currentTarget);
377
- this.setCurrentTarget(null);
378
-
379
- if (!this.$checkButton) {
380
- // Check and notify action
381
- const
382
- cellsAtPlace = this.countSolvedTargets(),
383
- ok = target.pos === target.num;
384
- this.ps.reportNewAction(this.act, 'PLACE', target.text, target.pos, ok, cellsAtPlace);
385
-
386
- // End activity or play event sound
387
- if (ok && cellsAtPlace === this.targets.length)
388
- this.finishActivity(true);
389
- else
390
- this.playEvent(ok ? 'actionOk' : 'actionError');
391
- }
392
- } else {
393
- this.setCurrentTarget(target);
394
- this.bc.begin(p);
395
- this.playEvent('click');
396
- }
397
- }
398
- break;
399
-
400
- case 'mousemove':
401
- this.bc.moveTo(p);
402
- break;
403
-
404
- default:
405
- break;
406
- }
407
- event.preventDefault();
408
- return true;
409
- }
410
- }
411
- }
412
-
413
- // Properties and methods specific to OrderTextPanel
414
- Object.assign(OrderTextPanel.prototype, {
415
- /**
416
- * Currently selected text target
417
- * @name module:activities/text/OrderText.OrderTextPanel#currentTarget
418
- * @type {module:activities/text/TextActivityDocument.TextActivityDocument.TextTarget} */
419
- currentTarget: null,
420
- /**
421
- * The box connector
422
- * @name module:activities/text/OrderText.OrderTextPanel#bc
423
- * @type {module:boxes/BoxConnector.BoxConnector} */
424
- bc: null,
425
- /**
426
- * List of mouse, touch and keyboard events intercepted by this panel
427
- * @override
428
- * @name module:activities/text/OrderText.OrderTextPanel#events
429
- * @type {string[]} */
430
- events: ['click', 'mousemove'],
431
- });
432
-
433
- /**
434
- * Panel class associated to this type of activity: {@link module:activities/text/OrderText.OrderTextPanel OrderTextPanel}
435
- * @type {class} */
436
- OrderText.Panel = OrderTextPanel;
437
-
438
- // Register activity class
439
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Activity_js__WEBPACK_IMPORTED_MODULE_1__["default"].registerClass('@text.Order', OrderText));
440
-
441
-
442
- /***/ }),
443
-
444
- /***/ 6148:
445
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
446
-
447
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
448
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
449
- /* harmony export */ });
450
- /* unused harmony export BoxConnector */
451
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7912);
452
- /**
453
- * File : boxes/BoxConnector.js
454
- * Created : 26/05/2015
455
- * By : Francesc Busquets <francesc@gmail.com>
456
- *
457
- * JClic.js
458
- * An HTML5 player of JClic activities
459
- * https://projectestac.github.io/jclic.js
460
- *
461
- * @source https://github.com/projectestac/jclic.js
462
- *
463
- * @license EUPL-1.2
464
- * @licstart
465
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
466
- *
467
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
468
- * the European Commission- subsequent versions of the EUPL (the "Licence");
469
- * You may not use this work except in compliance with the Licence.
470
- *
471
- * You may obtain a copy of the Licence at:
472
- * https://joinup.ec.europa.eu/software/page/eupl
473
- *
474
- * Unless required by applicable law or agreed to in writing, software
475
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
476
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
477
- * Licence for the specific language governing permissions and limitations
478
- * under the Licence.
479
- * @licend
480
- * @module
481
- */
482
-
483
-
484
-
485
- const DEFAULT_COMPOSITE_OP = 'source-over';
486
-
487
- /**
488
- * BoxConnector allows users to visually connect two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects of an
489
- * {@link module:Activity.ActivityPanel ActivityPanel}. There are two modes of operation:
490
- *
491
- * - Drawing a line between an origin point (usually the point where the user clicks on) and a
492
- * destination point.
493
- * - Dragging the ActiveBox from one location to another.
494
- *
495
- * The connecting lines can have arrowheads at its endings.
496
- */
497
- class BoxConnector {
498
- /**
499
- * BoxConnector constructor
500
- * @param {module:AWT.Container} parent - The Container to which this BoxConnector belongs
501
- * @param {external:jQuery} $canvas - The HTML `canvas` element where this BoxConnector will draw.
502
- */
503
- constructor(parent, $canvas) {
504
- this.parent = parent;
505
- this.ctx = $canvas.get(-1).getContext('2d', { willReadFrequently: true });
506
- this.dim = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg(this.ctx.canvas.width, this.ctx.canvas.height);
507
- this.origin = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
508
- this.dest = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
509
- this.relativePos = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
510
- }
511
-
512
- /**
513
- * Displaces the ending point of the connector
514
- * @param {number} dx - Displacement on the X axis
515
- * @param {number} dy - Displacement on the Y axis
516
- */
517
- moveBy(dx, dy) {
518
- this.moveTo((0,_AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR)(this.dest.x + dx, this.dest.y + dy));
519
- }
520
-
521
- /**
522
- * Moves the ending point of the connector to a new position
523
- * @param {module:AWT.Point} pt - The new position
524
- * @param {boolean} forcePaint - When `true`, forces the repaint of all the area also if there is
525
- * no movement at all.
526
- */
527
- moveTo(pt, forcePaint) {
528
- if (!this.active || !forcePaint && this.dest.equals(pt))
529
- return;
530
-
531
- // Restore the background
532
- if (this.bgRect) {
533
- if (this.bgImg) {
534
- this.ctx.putImageData(
535
- this.bgImg,
536
- 0, 0,
537
- this.bgRect.pos.x, this.bgRect.pos.y,
538
- this.bgRect.dim.width, this.bgRect.dim.height);
539
- } else if (this.parent)
540
- this.parent.updateContent();
541
- }
542
-
543
- this.dest.moveTo(pt);
544
-
545
- // Calculate the bounds of the invalidated area after the move:
546
- // Start with the origin point or box area
547
- const pt1 = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(this.origin.x - this.relativePos.x, this.origin.y - this.relativePos.y);
548
- this.bgRect = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Rectangle */ .M_(pt1, this.bx ? this.bx.dim : new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg());
549
- // Add the destination point or box area
550
- const pt2 = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(pt.x - this.relativePos.x, pt.y - this.relativePos.y);
551
- this.bgRect.add(new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Rectangle */ .M_(pt2, this.bx ? this.bx.dim : new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg()));
552
- // Add a generous border around the area
553
- this.bgRect.grow(10, 10);
554
-
555
- if (this.bx !== null) {
556
- // Move the ActiveBox
557
- this.bx.moveTo(new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(pt.x - this.relativePos.x, pt.y - this.relativePos.y));
558
- this.bx.setTemporaryHidden(false);
559
- this.bx.update(this.ctx, null);
560
- this.bx.setTemporaryHidden(true);
561
- } else {
562
- // Draw the connecting line
563
- this.drawLine();
564
- this.linePainted = true;
565
- }
566
- }
567
-
568
- /**
569
- * Starts the box connector operation
570
- * @param {module:AWT.Point} pt - Starting point
571
- * @param {module:boxes/ActiveBox.ActiveBox} [box] - Passed only when the BoxConnector runs in drag&drop mode
572
- */
573
- begin(pt, box) {
574
- if (this.active)
575
- this.end();
576
- this.origin.moveTo(pt);
577
- this.dest.moveTo(pt);
578
- this.linePainted = false;
579
- this.active = true;
580
-
581
- if (box) {
582
- // Remember what box will be moved, hide it from the panel and repaint all
583
- this.bx = box;
584
- this.relativePos.moveTo(pt.x - box.pos.x, pt.y - box.pos.y);
585
- this.bx.setFocused(true);
586
- this.bx.setTemporaryHidden(true);
587
- this.linePainted = false;
588
- this.parent.invalidate().update();
589
- }
590
-
591
- // Save the full image currently displayed on the panel (with the box hidden)
592
- try {
593
- this.bgImg = this.ctx.getImageData(0, 0, this.dim.width, this.dim.height);
594
- } catch (_ex) {
595
- // Avoid "canvas tainted by cross-origin data" errors
596
- // Setting bgImg to null is less efficient, but works
597
- this.bgImg = null;
598
- }
599
- this.bgRect = null;
600
-
601
- // Make a first movement to make the box appear
602
- if (box)
603
- this.moveTo(pt, true);
604
- }
605
-
606
- /**
607
- * Finalizes the operation of this box connector until a new call to `begin`
608
- */
609
- end() {
610
- if (!this.active)
611
- return;
612
-
613
- this.active = false;
614
- this.linePainted = false;
615
- this.bgRect = null;
616
- this.bgImg = null;
617
-
618
- if (this.bx) {
619
- // Restore the original position and attributes of the box
620
- this.bx.setFocused(false);
621
- this.bx.moveTo(this.origin.x - this.relativePos.x, this.origin.y - this.relativePos.y);
622
- this.bx.setTemporaryHidden(false);
623
- this.bx = null;
624
- this.relativePos.moveTo(0, 0);
625
- }
626
-
627
- // Repaint all
628
- this.ctx.clearRect(0, 0, this.dim.width, this.dim.height);
629
- this.parent.invalidate().update();
630
- }
631
-
632
- /**
633
- * Strokes a line between `origin` and `dest`, optionally ended with an arrowhead.
634
- */
635
- drawLine() {
636
- if (this.compositeOp !== DEFAULT_COMPOSITE_OP) {
637
- this.ctx.strokeStyle = this.xorColor;
638
- this.ctx.globalCompositeOperation = this.compositeOp;
639
- } else
640
- this.ctx.strokeStyle = this.lineColor;
641
-
642
- this.ctx.lineWidth = this.lineWidth;
643
-
644
- this.ctx.beginPath();
645
- this.ctx.moveTo(this.origin.x, this.origin.y);
646
- this.ctx.lineTo(this.dest.x, this.dest.y);
647
- this.ctx.stroke();
648
-
649
- if (this.arrow) {
650
- // Draws the arrow head
651
- const
652
- beta = Math.atan2(this.origin.x - this.dest.x, this.dest.x - this.origin.x),
653
- arp = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(this.dest.x - this.arrowLength * Math.cos(beta + this.arrowAngle),
654
- this.dest.y + this.arrowLength * Math.sin(beta + this.arrowAngle));
655
- this.ctx.beginPath();
656
- this.ctx.moveTo(this.dest.x, this.dest.y);
657
- this.ctx.lineTo(arp.x, arp.y);
658
- this.ctx.stroke();
659
-
660
- arp.moveTo(this.dest.x - this.arrowLength * Math.cos(beta - this.arrowAngle),
661
- this.dest.y + this.arrowLength * Math.sin(beta - this.arrowAngle));
662
- this.ctx.beginPath();
663
- this.ctx.moveTo(this.dest.x, this.dest.y);
664
- this.ctx.lineTo(arp.x, arp.y);
665
- this.ctx.stroke();
666
- }
667
- if (this.compositeOp !== DEFAULT_COMPOSITE_OP) {
668
- // reset default settings
669
- this.ctx.globalCompositeOperation = DEFAULT_COMPOSITE_OP;
670
- }
671
- }
672
- }
673
-
674
- Object.assign(BoxConnector.prototype, {
675
- /**
676
- * The background image, saved and redrawn on each movement
677
- * @name module:boxes/BoxConnector.BoxConnector#bgImg
678
- * @type {external:HTMLImageElement} */
679
- bgImg: null,
680
- /**
681
- * The rectangle of {@link module:Activity.ActivityPanel ActivityPanel} saved in `bgImg`
682
- * @name module:boxes/BoxConnector.BoxConnector#bgRect
683
- * @type {module:AWT.Rectangle} */
684
- bgRect: null,
685
- /**
686
- * Initial position of the connector
687
- * @name module:boxes/BoxConnector.BoxConnector#origin
688
- * @type {module:AWT.Point} */
689
- origin: null,
690
- /**
691
- * Current (while moving) and final position of the connector
692
- * @name module:boxes/BoxConnector.BoxConnector#dest
693
- * @type {module:AWT.Point} */
694
- dest: null,
695
- /**
696
- * When `true`, the connector must end on arrowhead
697
- * @name module:boxes/BoxConnector.BoxConnector#arrow
698
- * @type {boolean} */
699
- arrow: false,
700
- /**
701
- * `true` while the connector is active
702
- * @name module:boxes/BoxConnector.BoxConnector#active
703
- * @type {boolean} */
704
- active: false,
705
- /**
706
- * `true` while the line has already been painted (used for XOR expressions)
707
- * @name module:boxes/BoxConnector.BoxConnector#linePainted
708
- * @type {boolean} */
709
- linePainted: false,
710
- /**
711
- * The arrowhead length (in pixels)
712
- * @name module:boxes/BoxConnector.BoxConnector#arrowLength
713
- * @type {number} */
714
- arrowLength: 10,
715
- /**
716
- * The arrowhead angle
717
- * @name module:boxes/BoxConnector.BoxConnector#arrowAngle
718
- * @type {number} */
719
- arrowAngle: Math.PI / 6,
720
- /**
721
- * The main color used in XOR operations
722
- * @name module:boxes/BoxConnector.BoxConnector#lineColor
723
- * @type {string} */
724
- lineColor: 'black',
725
- /**
726
- * The complementary color used in XOR operations
727
- * @name module:boxes/BoxConnector.BoxConnector#xorColor
728
- * @type {string} */
729
- xorColor: 'white',
730
- /**
731
- * The global composite operator used when drawing in XOR mode. Default is "difference".
732
- * For a list of possible values see:
733
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation}
734
- * @name module:boxes/BoxConnector.BoxConnector#compositeOp
735
- * @type {string} */
736
- compositeOp: 'difference',
737
- /**
738
- * The default {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation composite operator}
739
- * ("source-over").
740
- * @name module:boxes/BoxConnector.BoxConnector#DEFAULT_COMPOSITE_OP
741
- * @static
742
- * @type {string} */
743
- DEFAULT_COMPOSITE_OP: DEFAULT_COMPOSITE_OP,
744
- /**
745
- * Relative position of point B regarding A
746
- * @name module:boxes/BoxConnector.BoxConnector#relativePos
747
- * @type {module:AWT.Point} */
748
- relativePos: null,
749
- /**
750
- * The ActiveBox to connect or move
751
- * @name module:boxes/BoxConnector.BoxConnector#bx
752
- * @type {module:boxes/ActiveBox.ActiveBox} */
753
- bx: null,
754
- /**
755
- * The Graphics context where the BoxConnector will paint
756
- * @name module:boxes/BoxConnector.BoxConnector#ctx
757
- * @type {external:CanvasRenderingContext2D} */
758
- ctx: null,
759
- /**
760
- * The dimension of the HTML canvas where to draw
761
- * @name module:boxes/BoxConnector.BoxConnector#dim
762
- * @type {module:AWT.Dimension} */
763
- dim: null,
764
- /**
765
- * The container to which this connector belongs
766
- * @name module:boxes/BoxConnector.BoxConnector#parent
767
- * @type {module:AWT.Container} */
768
- parent: null,
769
- /**
770
- * Width of the connector line
771
- * @name module:boxes/BoxConnector.BoxConnector#lineWidth
772
- * @type {number} */
773
- lineWidth: 1.5,
774
- });
775
-
776
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxConnector);
777
-
778
-
779
- /***/ })
780
-
781
- };
782
- ;
783
- //# sourceMappingURL=485.jclic-node.js.map