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,1016 +0,0 @@
1
- "use strict";
2
- exports.id = 2160;
3
- exports.ids = [2160,7781,6148];
4
- exports.modules = {
5
-
6
- /***/ 2160:
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 WordSearch, WordSearchPanel */
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 _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7781);
17
- /* harmony import */ var _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9205);
18
- /* harmony import */ var _boxes_BoxConnector_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6148);
19
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7912);
20
- /* harmony import */ var _boxes_TextGrid_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4123);
21
- /**
22
- * File : activities/textGrid/WordSearch.js
23
- * Created : 15/06/2015
24
- * By : Francesc Busquets <francesc@gmail.com>
25
- *
26
- * JClic.js
27
- * An HTML5 player of JClic activities
28
- * https://projectestac.github.io/jclic.js
29
- *
30
- * @source https://github.com/projectestac/jclic.js
31
- *
32
- * @license EUPL-1.2
33
- * @licstart
34
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
35
- *
36
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
37
- * the European Commission- subsequent versions of the EUPL (the "Licence");
38
- * You may not use this work except in compliance with the Licence.
39
- *
40
- * You may obtain a copy of the Licence at:
41
- * https://joinup.ec.europa.eu/software/page/eupl
42
- *
43
- * Unless required by applicable law or agreed to in writing, software
44
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
45
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
46
- * Licence for the specific language governing permissions and limitations
47
- * under the Licence.
48
- * @licend
49
- * @module
50
- */
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
- /**
61
- * This class of {@link module:Activity.Activity Activity} shows a {@link module:boxes/TextGrid.TextGrid TextGrid} with some words placed in horizontal,
62
- * vertical or diagonal direction, written right or upside down. The remaining grid cells will be
63
- * filled with randomly selected characters.
64
- *
65
- * The aim of the activity is to find all the words hidden on the text grid.
66
- * The content of an optional {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} can be revealed on an auxiliary panel as
67
- * words are found.
68
- * @extends module:Activity.Activity
69
- */
70
- class WordSearch extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I {
71
- /**
72
- * WordSearch constructor
73
- * @param {module:project/JClicProject.JClicProject} project - The JClic project to which this activity belongs
74
- */
75
- constructor(project) {
76
- super(project);
77
- }
78
-
79
- /**
80
- * Retrieves the minimum number of actions needed to solve this activity
81
- * @override
82
- * @returns {number}
83
- */
84
- getMinNumActions() {
85
- return this.clues.length;
86
- }
87
-
88
- /**
89
- * This type of activity permits the user to display the solution
90
- * @override
91
- * @returns {boolean}
92
- */
93
- helpSolutionAllowed() {
94
- return true;
95
- }
96
-
97
- /**
98
- * This kind of activity uses random numbers to generate the filling characters
99
- * @override
100
- * @returns {boolean}
101
- */
102
- hasRandom() {
103
- return true;
104
- }
105
- }
106
-
107
- Object.assign(WordSearch.prototype, {
108
- /**
109
- * String array containing all the valid clues.
110
- * @name module:activities/textGrid/WordSearch.WordSearch#clues
111
- * @type {string[]} */
112
- clues: null,
113
- /**
114
- * Array of integers containing __for each clue__ the index
115
- * of an associated {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} located on the secondary {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag}.
116
- * This associated element is optional.
117
- * @name module:activities/textGrid/WordSearch.WordSearch#clueItems
118
- * @type {number[]} */
119
- clueItems: null,
120
- /**
121
- * Objects that indicate if box grids A and B must be shuffled.
122
- * (defaults to _false_ in WordSearch activities)
123
- * @name module:activities/textGrid/WordSearch.WordSearch#shuffleA
124
- * @type {boolean} */
125
- shuffleA: false,
126
- /**
127
- * Objects that indicate if box grids A and B must be shuffled.
128
- * (defaults to _false_ in WordSearch activities)
129
- * @name module:activities/textGrid/WordSearch.WordSearch#shuffleB
130
- * @type {boolean} */
131
- shuffleB: false,
132
- });
133
-
134
- /**
135
- * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/textGrid/WordSearch.WordSearch WordSearch} activities are played.
136
- * @extends module:Activity.ActivityPanel
137
- */
138
- class WordSearchPanel extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .ActivityPanel */ .S {
139
- /**
140
- * WordSearchPanel constructor
141
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
142
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
143
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
144
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
145
- */
146
- constructor(act, ps, $div) {
147
- super(act, ps, $div);
148
- this.resolvedClues = [];
149
- }
150
-
151
- /**
152
- * Performs miscellaneous cleaning operations
153
- * @override
154
- */
155
- clear() {
156
- if (this.grid) {
157
- this.grid.end();
158
- this.grid = null;
159
- }
160
- if (this.bgAlt) {
161
- this.bgAlt.end();
162
- this.bgAlt = null;
163
- }
164
- }
165
-
166
- /**
167
- * Prepares the visual components of the activity
168
- * @override
169
- */
170
- buildVisualComponents() {
171
- if (this.firstRun)
172
- super.buildVisualComponents();
173
- this.clear();
174
-
175
- const
176
- tgc = this.act.tgc,
177
- abcAlt = this.act.abc['secondary'];
178
- if (abcAlt) {
179
- if (abcAlt.image) {
180
- abcAlt.setImgContent(this.act.project.mediaBag, null, false);
181
- if (abcAlt.animatedGifFile && !abcAlt.shaper.rectangularShapes && !this.act.shuffleB)
182
- this.$animatedBg = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<span/>').css({
183
- 'background-image': `url(${abcAlt.animatedGifFile})`,
184
- 'background-position': 'center',
185
- 'background-repeat': 'no-repeat',
186
- position: 'absolute'
187
- }).appendTo(this.$div);
188
- }
189
-
190
- if (this.act.acp !== null)
191
- this.act.acp.generateContent(0, 0, [abcAlt], false);
192
- }
193
-
194
- if (tgc) {
195
- this.grid = _boxes_TextGrid_js__WEBPACK_IMPORTED_MODULE_6__["default"].createEmptyGrid(null, this, this.act.margin, this.act.margin, tgc, false);
196
- if (abcAlt) {
197
- this.bgAlt = _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__["default"].createEmptyGrid(null, this, this.act.margin, this.act.margin, abcAlt);
198
- if (this.$animatedBg && this.bgAlt.backgroundBox)
199
- this.bgAlt.backgroundBox['tmpTrans'] = true;
200
- }
201
- this.grid.setVisible(true);
202
- }
203
- }
204
-
205
- /**
206
- * Basic initialization procedure
207
- * @override
208
- */
209
- initActivity() {
210
- super.initActivity();
211
- if (!this.firstRun)
212
- this.buildVisualComponents();
213
- else
214
- this.firstRun = false;
215
-
216
- if (this.grid) {
217
- this.grid.setChars(this.act.tgc.text);
218
- this.grid.randomize();
219
- this.grid.setAllCellsAttribute(_boxes_TextGrid_js__WEBPACK_IMPORTED_MODULE_6__["default"].flags.INVERTED, false);
220
-
221
- this.resolvedClues = Array(this.act.clueItems.length).fill(false);
222
-
223
- if (this.bgAlt) {
224
- this.bgAlt.setContent(this.act.abc['secondary']);
225
- if (this.$animatedBg)
226
- this.bgAlt.clearAllBoxes();
227
- if (this.act.shuffleB)
228
- this.shuffle([this.bgAlt], true, true);
229
- this.bgAlt.setVisible(this.$animatedBg !== null || this.act.invAss);
230
- }
231
-
232
- this.setAndPlayMsg('initial', 'start');
233
- this.invalidate().update();
234
- this.playing = true;
235
- }
236
- }
237
-
238
- /**
239
- * Updates the graphic content of this panel.
240
- * This method will be called from {@link module:AWT.Container#update} when needed.
241
- * @override
242
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
243
- * it's the whole panel.
244
- */
245
- updateContent(dirtyRegion) {
246
- super.updateContent(dirtyRegion);
247
- if (this.grid && this.$canvas) {
248
- const
249
- canvas = this.$canvas.get(-1),
250
- ctx = canvas.getContext('2d');
251
- if (!dirtyRegion)
252
- dirtyRegion = new _AWT_js__WEBPACK_IMPORTED_MODULE_5__/* .Rectangle */ .M_(0, 0, canvas.width, canvas.height);
253
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
254
- this.grid.update(ctx, dirtyRegion);
255
- if (this.bgAlt)
256
- this.bgAlt.update(ctx, dirtyRegion);
257
- }
258
- return this;
259
- }
260
-
261
- /**
262
- * Sets the real dimension of this panel.
263
- * @override
264
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
265
- * @returns {module:AWT.Dimension}
266
- */
267
- setDimension(preferredMaxSize) {
268
- if (!this.grid || this.getBounds().equals(preferredMaxSize))
269
- return preferredMaxSize;
270
- if (this.bgAlt)
271
- return _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__["default"].layoutDouble(preferredMaxSize, this.grid, this.bgAlt, this.act.boxGridPos, this.act.margin);
272
- else
273
- return _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__["default"].layoutSingle(preferredMaxSize, this.grid, this.act.margin);
274
- }
275
-
276
- /**
277
- * Sets the size and position of this activity panel
278
- * @override
279
- * @param {module:AWT.Rectangle} rect
280
- */
281
- setBounds(rect) {
282
- if (this.$canvas)
283
- this.$canvas.remove();
284
- super.setBounds(rect);
285
- if (this.grid) {
286
- // Create the main canvas
287
- this.$canvas = jquery__WEBPACK_IMPORTED_MODULE_0___default()(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
288
- position: 'absolute',
289
- top: 0,
290
- left: 0
291
- });
292
- // Resize animated gif background
293
- if (this.$animatedBg && this.bgAlt) {
294
- const bgRect = this.bgAlt.getBounds();
295
- this.$animatedBg.css({
296
- left: bgRect.pos.x,
297
- top: bgRect.pos.y,
298
- width: `${bgRect.dim.width}px`,
299
- height: `${bgRect.dim.height}px`,
300
- 'background-size': `${bgRect.dim.width}px ${bgRect.dim.height}px`
301
- });
302
- }
303
- this.$div.append(this.$canvas);
304
-
305
- // Create a [BoxConnector](BoxConnector.html) and attach it to the canvas context
306
- this.bc = new _boxes_BoxConnector_js__WEBPACK_IMPORTED_MODULE_4__["default"](this, this.$canvas);
307
-
308
- // Repaint all
309
- this.invalidate().update();
310
- }
311
- }
312
-
313
- /**
314
- * Calculates the current score
315
- * @returns {number}
316
- */
317
- getCurrentScore() {
318
- return this.resolvedClues.reduce((n, resolved) => resolved ? ++n : n, 0);
319
- }
320
-
321
- /**
322
- * Main handler used to process mouse, touch, keyboard and edit events
323
- * @override
324
- * @param {external:Event} event - The HTML event to be processed
325
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
326
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
327
- */
328
- processEvent(event) {
329
- if (this.bc && this.playing) {
330
- //
331
- // The [AWT.Point](AWT.html#Point) where the mouse or touch event has been originated
332
- let p = null;
333
- //
334
- // _touchend_ event don't provide pageX nor pageY information
335
- if (event.type === 'touchend')
336
- p = this.bc.active ? this.bc.dest.clone() : new _AWT_js__WEBPACK_IMPORTED_MODULE_5__/* .Point */ .bR();
337
- else {
338
- // Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
339
- const
340
- x = event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
341
- y = event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY;
342
- p = new _AWT_js__WEBPACK_IMPORTED_MODULE_5__/* .Point */ .bR(x - this.$div.offset().left, y - this.$div.offset().top);
343
- }
344
-
345
- // Flag for tracking `mouseup` events
346
- let up = false;
347
- // Flag for assuring that only one media plays per event (avoid event sounds overlapping
348
- // cell's media sounds)
349
- let m = false;
350
- // Array to be filled with actions to be executed at the end of event processing
351
- const delayedActions = [];
352
-
353
- switch (event.type) {
354
- case 'touchcancel':
355
- // Canvel movement
356
- if (this.bc.active)
357
- this.bc.end();
358
- break;
359
-
360
- case 'mouseup':
361
- // Don't consider drag moves below 3 pixels. Can be a "trembling click"
362
- if (this.bc.active && p.distanceTo(this.bc.origin) <= 3)
363
- break;
364
-
365
- up = true;
366
- /* falls through */
367
- case 'touchend':
368
- case 'touchstart':
369
- case 'mousedown':
370
- if (!this.bc.active) {
371
- // A new word selection starts
372
- //
373
- // Selection of words can never start with a `mouseup` event
374
- if (up)
375
- break;
376
-
377
- this.ps.stopMedia(1);
378
- if (this.grid.contains(p)) {
379
- this.playEvent('click');
380
- this.bc.begin(p);
381
- }
382
- } else {
383
- this.ps.stopMedia(1);
384
- // Word selection completed
385
- //
386
- // Find the active boxes behind `bc.origin` and `p`
387
- const
388
- pt1 = this.grid.getLogicalCoords(this.bc.origin),
389
- pt2 = this.grid.getLogicalCoords(this.bc.dest);
390
- this.bc.end();
391
- const s = this.grid.getStringBetween(pt1.x, pt1.y, pt2.x, pt2.y);
392
- if (s !== null && s.length > 0) {
393
- let ok = false, c = 0;
394
- for (; c < this.act.clues.length; c++) {
395
- if (s === this.act.clues[c]) {
396
- ok = true;
397
- break;
398
- }
399
- }
400
- const repeated = this.resolvedClues[c];
401
- if (ok && !repeated) {
402
- this.resolvedClues[c] = true;
403
- this.grid.setAttributeBetween(pt1.x, pt1.y, pt2.x, pt2.y, _boxes_TextGrid_js__WEBPACK_IMPORTED_MODULE_6__["default"].flags.INVERTED, true);
404
- if (this.bgAlt !== null) {
405
- const k = this.act.clueItems[c];
406
- if (k >= 0 && k < this.bgAlt.getNumCells()) {
407
- const bx = this.bgAlt.getActiveBox(this.act.clueItems[c]);
408
- if (bx) {
409
- bx.setVisible(this.$animatedBg === null && !this.act.invAss);
410
- m = bx.playMedia(this.ps, delayedActions);
411
- }
412
- }
413
- }
414
- }
415
- if (!repeated) {
416
- const r = this.getCurrentScore();
417
- this.ps.reportNewAction(this.act, 'ACTION_SELECT', s, null, ok, r);
418
- if (r === this.act.clues.length)
419
- this.finishActivity(true);
420
- else if (!m)
421
- this.playEvent(ok ? 'actionOK' : 'actionError');
422
- this.invalidate();
423
- } else if (!ok && !m)
424
- this.playEvent('actionError');
425
- } else
426
- this.playEvent('actionError');
427
-
428
- this.update();
429
- }
430
- break;
431
-
432
- case 'mousemove':
433
- case 'touchmove':
434
- this.bc.moveTo(p);
435
- break;
436
- }
437
- delayedActions.forEach(action => action());
438
- event.preventDefault();
439
- }
440
- }
441
- }
442
-
443
- Object.assign(WordSearchPanel.prototype, {
444
- /**
445
- * The {@link module:boxes/TextGrid.TextGrid TextGrid} object of this ActivityPanel
446
- * @name module:activities/textGrid/WordSearch.WordSearchPanel#grid
447
- * @type {module:boxes/TextGrid.TextGrid} */
448
- grid: null,
449
- /**
450
- * An optional {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} used to display information associated with the hidden words.
451
- * @name module:activities/textGrid/WordSearch.WordSearchPanel#bgAlt
452
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
453
- bgAlt: null,
454
- /**
455
- * An array of boolean values indicating which clues have been found
456
- * @name module:activities/textGrid/WordSearch.WordSearchPanel#resolvedClues
457
- * @type {boolean[]} */
458
- resolvedClues: null,
459
- /**
460
- * The box connector object
461
- * @name module:activities/textGrid/WordSearch.WordSearchPanel#bc
462
- * @type {module:boxes/BoxConnector.BoxConnector} */
463
- bc: null,
464
- /**
465
- * Mouse and touch events intercepted by this panel
466
- * @override
467
- * @name module:activities/textGrid/WordSearch.WordSearchPanel#events
468
- * @type {string[]} */
469
- events: ['mousedown', 'mouseup', 'mousemove', 'touchstart', 'touchend', 'touchmove', 'touchcancel'],
470
- });
471
-
472
- /**
473
- * Panel class associated to this type of activity: {@link module:activities/textGrid/WordSearch.WordSearchPanel WordSearchPanel}
474
- * @type {class} */
475
- WordSearch.Panel = WordSearchPanel;
476
-
477
- // Register activity class
478
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I.registerClass('@textGrid.WordSearch', WordSearch));
479
-
480
-
481
- /***/ }),
482
-
483
- /***/ 7781:
484
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
485
-
486
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
487
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
488
- /* harmony export */ });
489
- /* unused harmony export ActiveBoxGrid */
490
- /* harmony import */ var _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(427);
491
- /* harmony import */ var _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1725);
492
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
493
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1253);
494
- /**
495
- * File : boxes/ActiveBoxGrid.js
496
- * Created : 19/05/2015
497
- * By : Francesc Busquets <francesc@gmail.com>
498
- *
499
- * JClic.js
500
- * An HTML5 player of JClic activities
501
- * https://projectestac.github.io/jclic.js
502
- *
503
- * @source https://github.com/projectestac/jclic.js
504
- *
505
- * @license EUPL-1.2
506
- * @licstart
507
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
508
- *
509
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
510
- * the European Commission- subsequent versions of the EUPL (the "Licence");
511
- * You may not use this work except in compliance with the Licence.
512
- *
513
- * You may obtain a copy of the Licence at:
514
- * https://joinup.ec.europa.eu/software/page/eupl
515
- *
516
- * Unless required by applicable law or agreed to in writing, software
517
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
518
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
519
- * Licence for the specific language governing permissions and limitations
520
- * under the Licence.
521
- * @licend
522
- * @module
523
- */
524
-
525
-
526
-
527
-
528
-
529
-
530
- /**
531
- * This class extends {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with constructors that take an argument of type
532
- * {@link module:shapers/Shaper.Shaper Shaper} used to build all its {@link module:boxes/ActiveBox.ActiveBox ActiveBox}components. It also maintains information
533
- * about the number of "rows" and "columns", useful to compute valid (integer) values when
534
- * resizing or moving its components.
535
- * @extends module:boxes/ActiveBoxBag.ActiveBoxBag
536
- */
537
- class ActiveBoxGrid extends _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
538
- /**
539
- * ActiveBxGrid constructor
540
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
541
- * @param {module:AWT.Container} container - The container where this box grid is placed.
542
- * @param {module:boxes/BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
543
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
544
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
545
- * @param {number} setWidth - Total width of the box grid
546
- * @param {number} setHeight - Total height of the box grid
547
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
548
- */
549
- constructor(parent, container, boxBase, px, py, setWidth, setHeight, sh) {
550
- // ActiveBoxGrid derives from ActiveBoxBag
551
- super(parent, container, boxBase);
552
-
553
- this.nCols = sh.nCols;
554
- this.nRows = sh.nRows;
555
-
556
- // This will be the enclosing rectangle of this ActiveBox bag
557
- const r = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(
558
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(px, py),
559
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
560
- Math.round(setWidth / this.nCols) * this.nCols,
561
- Math.round(setHeight / this.nRows) * this.nRows));
562
-
563
- // Create all the [ActiveBox](ActiveBox.html) objects based on the
564
- // shapes provided by the [Shaper](Shaper.html)
565
- for (let i = 0; i < sh.nCells; i++) {
566
- const
567
- tmpSh = sh.getShape(i, r),
568
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, i, tmpSh.getBounds());
569
- if (!sh.rectangularShapes)
570
- bx.setShape(tmpSh);
571
- this.addActiveBox(bx);
572
- }
573
-
574
- // If the Shaper has `remainder` (extra space), set the background box of this
575
- // [BoxBag](BoxBag.html)
576
- if (sh.hasRemainder) {
577
- const
578
- tmpSh = sh.getRemainderShape(r),
579
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, 0, tmpSh.getBounds());
580
- bx.setShape(tmpSh);
581
- this.setBackgroundBox(bx);
582
- }
583
- }
584
-
585
- /**
586
- * This factory constructor creates a new empty grid with the number of cells indicated by the
587
- * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} `abc`, not filling the cells with any content.
588
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
589
- * @param {module:AWT.Container} container - The container where this box grid is placed.
590
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
591
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
592
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - Used only to get the number of cells and the shaper (when `sh` is `null`)
593
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
594
- * @param {module:boxes/BoxBase.BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
595
- * of this box grid are defined.
596
- * @returns {module:boxes/ActiveBoxGrid.ActiveBoxGrid}
597
- */
598
- static createEmptyGrid(parent, container, px, py, abc, sh, boxBase) {
599
- const result = abc ? new ActiveBoxGrid(parent, container,
600
- boxBase || abc.style,
601
- px, py,
602
- abc.getTotalWidth(), abc.getTotalHeight(),
603
- sh || abc.getShaper()) : null;
604
-
605
- if (result)
606
- result.setBorder(abc.border);
607
-
608
- return result;
609
- }
610
-
611
- /**
612
- * Gets the minimum size of this grid
613
- * @returns {module:AWT.Dimension}
614
- */
615
- getMinimumSize() {
616
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
617
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nCols,
618
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nRows);
619
- }
620
-
621
- /**
622
- * Gets a scaled size of this grid, rounded to the nearest integer values
623
- * @param {number} scale - The scale factor
624
- * @returns {module:AWT.Dimension}
625
- */
626
- getScaledSize(scale) {
627
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
628
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.width, this.nCols),
629
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.height, this.nRows));
630
- }
631
-
632
- /**
633
- * Returns the logical coordinates of the provided {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
634
- * The units of the result are not pixels, but ordinal numbers (relative positions) of columns
635
- * and rows in the grid.
636
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to process
637
- * @returns {module:AWT.Point}
638
- */
639
- getCoord(bx) {
640
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bx.idLoc % this.nCols, Math.floor(bx.idLoc / this.nCols));
641
- }
642
-
643
- /**
644
- * Calculates the logical distance between two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
645
- * Resulting units are not pixels, but ordinal numbers (relative positions) of columns and rows
646
- * in the grid.
647
- * @param {module:boxes/ActiveBox.ActiveBox} src - First box
648
- * @param {module:boxes/ActiveBox.ActiveBox} dest - Second box
649
- * @returns {module:AWT.Point}
650
- */
651
- getCoordDist(src, dest) {
652
- const
653
- ptSrc = this.getCoord(src),
654
- ptDest = this.getCoord(dest);
655
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(ptDest.x - ptSrc.x, ptDest.y - ptSrc.y);
656
- }
657
- }
658
-
659
- Object.assign(ActiveBoxGrid.prototype, {
660
- /**
661
- * Number of columns of this box grid
662
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nCols
663
- * @type {number} */
664
- nCols: 1,
665
- /**
666
- * Number of rows of this box grid
667
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nRows
668
- * @type {number} */
669
- nRows: 1,
670
- });
671
-
672
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveBoxGrid);
673
-
674
-
675
- /***/ }),
676
-
677
- /***/ 6148:
678
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
679
-
680
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
681
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
682
- /* harmony export */ });
683
- /* unused harmony export BoxConnector */
684
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7912);
685
- /**
686
- * File : boxes/BoxConnector.js
687
- * Created : 26/05/2015
688
- * By : Francesc Busquets <francesc@gmail.com>
689
- *
690
- * JClic.js
691
- * An HTML5 player of JClic activities
692
- * https://projectestac.github.io/jclic.js
693
- *
694
- * @source https://github.com/projectestac/jclic.js
695
- *
696
- * @license EUPL-1.2
697
- * @licstart
698
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
699
- *
700
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
701
- * the European Commission- subsequent versions of the EUPL (the "Licence");
702
- * You may not use this work except in compliance with the Licence.
703
- *
704
- * You may obtain a copy of the Licence at:
705
- * https://joinup.ec.europa.eu/software/page/eupl
706
- *
707
- * Unless required by applicable law or agreed to in writing, software
708
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
709
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
710
- * Licence for the specific language governing permissions and limitations
711
- * under the Licence.
712
- * @licend
713
- * @module
714
- */
715
-
716
-
717
-
718
- const DEFAULT_COMPOSITE_OP = 'source-over';
719
-
720
- /**
721
- * BoxConnector allows users to visually connect two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects of an
722
- * {@link module:Activity.ActivityPanel ActivityPanel}. There are two modes of operation:
723
- *
724
- * - Drawing a line between an origin point (usually the point where the user clicks on) and a
725
- * destination point.
726
- * - Dragging the ActiveBox from one location to another.
727
- *
728
- * The connecting lines can have arrowheads at its endings.
729
- */
730
- class BoxConnector {
731
- /**
732
- * BoxConnector constructor
733
- * @param {module:AWT.Container} parent - The Container to which this BoxConnector belongs
734
- * @param {external:jQuery} $canvas - The HTML `canvas` element where this BoxConnector will draw.
735
- */
736
- constructor(parent, $canvas) {
737
- this.parent = parent;
738
- this.ctx = $canvas.get(-1).getContext('2d', { willReadFrequently: true });
739
- this.dim = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Dimension */ .fg(this.ctx.canvas.width, this.ctx.canvas.height);
740
- this.origin = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
741
- this.dest = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
742
- this.relativePos = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR();
743
- }
744
-
745
- /**
746
- * Displaces the ending point of the connector
747
- * @param {number} dx - Displacement on the X axis
748
- * @param {number} dy - Displacement on the Y axis
749
- */
750
- moveBy(dx, dy) {
751
- this.moveTo((0,_AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR)(this.dest.x + dx, this.dest.y + dy));
752
- }
753
-
754
- /**
755
- * Moves the ending point of the connector to a new position
756
- * @param {module:AWT.Point} pt - The new position
757
- * @param {boolean} forcePaint - When `true`, forces the repaint of all the area also if there is
758
- * no movement at all.
759
- */
760
- moveTo(pt, forcePaint) {
761
- if (!this.active || !forcePaint && this.dest.equals(pt))
762
- return;
763
-
764
- // Restore the background
765
- if (this.bgRect) {
766
- if (this.bgImg) {
767
- this.ctx.putImageData(
768
- this.bgImg,
769
- 0, 0,
770
- this.bgRect.pos.x, this.bgRect.pos.y,
771
- this.bgRect.dim.width, this.bgRect.dim.height);
772
- } else if (this.parent)
773
- this.parent.updateContent();
774
- }
775
-
776
- this.dest.moveTo(pt);
777
-
778
- // Calculate the bounds of the invalidated area after the move:
779
- // Start with the origin point or box area
780
- const pt1 = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(this.origin.x - this.relativePos.x, this.origin.y - this.relativePos.y);
781
- 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());
782
- // Add the destination point or box area
783
- const pt2 = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(pt.x - this.relativePos.x, pt.y - this.relativePos.y);
784
- 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()));
785
- // Add a generous border around the area
786
- this.bgRect.grow(10, 10);
787
-
788
- if (this.bx !== null) {
789
- // Move the ActiveBox
790
- this.bx.moveTo(new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(pt.x - this.relativePos.x, pt.y - this.relativePos.y));
791
- this.bx.setTemporaryHidden(false);
792
- this.bx.update(this.ctx, null);
793
- this.bx.setTemporaryHidden(true);
794
- } else {
795
- // Draw the connecting line
796
- this.drawLine();
797
- this.linePainted = true;
798
- }
799
- }
800
-
801
- /**
802
- * Starts the box connector operation
803
- * @param {module:AWT.Point} pt - Starting point
804
- * @param {module:boxes/ActiveBox.ActiveBox} [box] - Passed only when the BoxConnector runs in drag&drop mode
805
- */
806
- begin(pt, box) {
807
- if (this.active)
808
- this.end();
809
- this.origin.moveTo(pt);
810
- this.dest.moveTo(pt);
811
- this.linePainted = false;
812
- this.active = true;
813
-
814
- if (box) {
815
- // Remember what box will be moved, hide it from the panel and repaint all
816
- this.bx = box;
817
- this.relativePos.moveTo(pt.x - box.pos.x, pt.y - box.pos.y);
818
- this.bx.setFocused(true);
819
- this.bx.setTemporaryHidden(true);
820
- this.linePainted = false;
821
- this.parent.invalidate().update();
822
- }
823
-
824
- // Save the full image currently displayed on the panel (with the box hidden)
825
- try {
826
- this.bgImg = this.ctx.getImageData(0, 0, this.dim.width, this.dim.height);
827
- } catch (_ex) {
828
- // Avoid "canvas tainted by cross-origin data" errors
829
- // Setting bgImg to null is less efficient, but works
830
- this.bgImg = null;
831
- }
832
- this.bgRect = null;
833
-
834
- // Make a first movement to make the box appear
835
- if (box)
836
- this.moveTo(pt, true);
837
- }
838
-
839
- /**
840
- * Finalizes the operation of this box connector until a new call to `begin`
841
- */
842
- end() {
843
- if (!this.active)
844
- return;
845
-
846
- this.active = false;
847
- this.linePainted = false;
848
- this.bgRect = null;
849
- this.bgImg = null;
850
-
851
- if (this.bx) {
852
- // Restore the original position and attributes of the box
853
- this.bx.setFocused(false);
854
- this.bx.moveTo(this.origin.x - this.relativePos.x, this.origin.y - this.relativePos.y);
855
- this.bx.setTemporaryHidden(false);
856
- this.bx = null;
857
- this.relativePos.moveTo(0, 0);
858
- }
859
-
860
- // Repaint all
861
- this.ctx.clearRect(0, 0, this.dim.width, this.dim.height);
862
- this.parent.invalidate().update();
863
- }
864
-
865
- /**
866
- * Strokes a line between `origin` and `dest`, optionally ended with an arrowhead.
867
- */
868
- drawLine() {
869
- if (this.compositeOp !== DEFAULT_COMPOSITE_OP) {
870
- this.ctx.strokeStyle = this.xorColor;
871
- this.ctx.globalCompositeOperation = this.compositeOp;
872
- } else
873
- this.ctx.strokeStyle = this.lineColor;
874
-
875
- this.ctx.lineWidth = this.lineWidth;
876
-
877
- this.ctx.beginPath();
878
- this.ctx.moveTo(this.origin.x, this.origin.y);
879
- this.ctx.lineTo(this.dest.x, this.dest.y);
880
- this.ctx.stroke();
881
-
882
- if (this.arrow) {
883
- // Draws the arrow head
884
- const
885
- beta = Math.atan2(this.origin.x - this.dest.x, this.dest.x - this.origin.x),
886
- arp = new _AWT_js__WEBPACK_IMPORTED_MODULE_0__/* .Point */ .bR(this.dest.x - this.arrowLength * Math.cos(beta + this.arrowAngle),
887
- this.dest.y + this.arrowLength * Math.sin(beta + this.arrowAngle));
888
- this.ctx.beginPath();
889
- this.ctx.moveTo(this.dest.x, this.dest.y);
890
- this.ctx.lineTo(arp.x, arp.y);
891
- this.ctx.stroke();
892
-
893
- arp.moveTo(this.dest.x - this.arrowLength * Math.cos(beta - this.arrowAngle),
894
- this.dest.y + this.arrowLength * Math.sin(beta - this.arrowAngle));
895
- this.ctx.beginPath();
896
- this.ctx.moveTo(this.dest.x, this.dest.y);
897
- this.ctx.lineTo(arp.x, arp.y);
898
- this.ctx.stroke();
899
- }
900
- if (this.compositeOp !== DEFAULT_COMPOSITE_OP) {
901
- // reset default settings
902
- this.ctx.globalCompositeOperation = DEFAULT_COMPOSITE_OP;
903
- }
904
- }
905
- }
906
-
907
- Object.assign(BoxConnector.prototype, {
908
- /**
909
- * The background image, saved and redrawn on each movement
910
- * @name module:boxes/BoxConnector.BoxConnector#bgImg
911
- * @type {external:HTMLImageElement} */
912
- bgImg: null,
913
- /**
914
- * The rectangle of {@link module:Activity.ActivityPanel ActivityPanel} saved in `bgImg`
915
- * @name module:boxes/BoxConnector.BoxConnector#bgRect
916
- * @type {module:AWT.Rectangle} */
917
- bgRect: null,
918
- /**
919
- * Initial position of the connector
920
- * @name module:boxes/BoxConnector.BoxConnector#origin
921
- * @type {module:AWT.Point} */
922
- origin: null,
923
- /**
924
- * Current (while moving) and final position of the connector
925
- * @name module:boxes/BoxConnector.BoxConnector#dest
926
- * @type {module:AWT.Point} */
927
- dest: null,
928
- /**
929
- * When `true`, the connector must end on arrowhead
930
- * @name module:boxes/BoxConnector.BoxConnector#arrow
931
- * @type {boolean} */
932
- arrow: false,
933
- /**
934
- * `true` while the connector is active
935
- * @name module:boxes/BoxConnector.BoxConnector#active
936
- * @type {boolean} */
937
- active: false,
938
- /**
939
- * `true` while the line has already been painted (used for XOR expressions)
940
- * @name module:boxes/BoxConnector.BoxConnector#linePainted
941
- * @type {boolean} */
942
- linePainted: false,
943
- /**
944
- * The arrowhead length (in pixels)
945
- * @name module:boxes/BoxConnector.BoxConnector#arrowLength
946
- * @type {number} */
947
- arrowLength: 10,
948
- /**
949
- * The arrowhead angle
950
- * @name module:boxes/BoxConnector.BoxConnector#arrowAngle
951
- * @type {number} */
952
- arrowAngle: Math.PI / 6,
953
- /**
954
- * The main color used in XOR operations
955
- * @name module:boxes/BoxConnector.BoxConnector#lineColor
956
- * @type {string} */
957
- lineColor: 'black',
958
- /**
959
- * The complementary color used in XOR operations
960
- * @name module:boxes/BoxConnector.BoxConnector#xorColor
961
- * @type {string} */
962
- xorColor: 'white',
963
- /**
964
- * The global composite operator used when drawing in XOR mode. Default is "difference".
965
- * For a list of possible values see:
966
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation}
967
- * @name module:boxes/BoxConnector.BoxConnector#compositeOp
968
- * @type {string} */
969
- compositeOp: 'difference',
970
- /**
971
- * The default {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation composite operator}
972
- * ("source-over").
973
- * @name module:boxes/BoxConnector.BoxConnector#DEFAULT_COMPOSITE_OP
974
- * @static
975
- * @type {string} */
976
- DEFAULT_COMPOSITE_OP: DEFAULT_COMPOSITE_OP,
977
- /**
978
- * Relative position of point B regarding A
979
- * @name module:boxes/BoxConnector.BoxConnector#relativePos
980
- * @type {module:AWT.Point} */
981
- relativePos: null,
982
- /**
983
- * The ActiveBox to connect or move
984
- * @name module:boxes/BoxConnector.BoxConnector#bx
985
- * @type {module:boxes/ActiveBox.ActiveBox} */
986
- bx: null,
987
- /**
988
- * The Graphics context where the BoxConnector will paint
989
- * @name module:boxes/BoxConnector.BoxConnector#ctx
990
- * @type {external:CanvasRenderingContext2D} */
991
- ctx: null,
992
- /**
993
- * The dimension of the HTML canvas where to draw
994
- * @name module:boxes/BoxConnector.BoxConnector#dim
995
- * @type {module:AWT.Dimension} */
996
- dim: null,
997
- /**
998
- * The container to which this connector belongs
999
- * @name module:boxes/BoxConnector.BoxConnector#parent
1000
- * @type {module:AWT.Container} */
1001
- parent: null,
1002
- /**
1003
- * Width of the connector line
1004
- * @name module:boxes/BoxConnector.BoxConnector#lineWidth
1005
- * @type {number} */
1006
- lineWidth: 1.5,
1007
- });
1008
-
1009
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxConnector);
1010
-
1011
-
1012
- /***/ })
1013
-
1014
- };
1015
- ;
1016
- //# sourceMappingURL=2160.jclic-node.js.map