jclic 2.1.21 → 2.1.23

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