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,894 +0,0 @@
1
- "use strict";
2
- exports.id = 427;
3
- exports.ids = [427];
4
- exports.modules = {
5
-
6
- /***/ 427:
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 export ActiveBoxBag */
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 _BoxBag_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9205);
16
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
17
- /**
18
- * File : boxes/ActiveBoxBag.js
19
- * Created : 21/04/2015
20
- * By : Francesc Busquets <francesc@gmail.com>
21
- *
22
- * JClic.js
23
- * An HTML5 player of JClic activities
24
- * https://projectestac.github.io/jclic.js
25
- *
26
- * @source https://github.com/projectestac/jclic.js
27
- *
28
- * @license EUPL-1.2
29
- * @licstart
30
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
31
- *
32
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
33
- * the European Commission- subsequent versions of the EUPL (the "Licence");
34
- * You may not use this work except in compliance with the Licence.
35
- *
36
- * You may obtain a copy of the Licence at:
37
- * https://joinup.ec.europa.eu/software/page/eupl
38
- *
39
- * Unless required by applicable law or agreed to in writing, software
40
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
41
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
42
- * Licence for the specific language governing permissions and limitations
43
- * under the Licence.
44
- * @licend
45
- * @module
46
- */
47
-
48
-
49
-
50
-
51
-
52
- /**
53
- * This class is a special case of {@link module:boxes/BoxBag.BoxBag BoxBag} containing only objects of type {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
54
- * In addition to the members and methods of `BoxBag`, it implements specific methods to deal with
55
- * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} objects and with the other specific members of `ActiveBox` like its "ids"
56
- * (`idOrder`, `idLoc` and `idAss`).
57
- * @extends module:boxes/BoxBag.BoxBag
58
- */
59
- class ActiveBoxBag extends _BoxBag_js__WEBPACK_IMPORTED_MODULE_1__["default"] {
60
- /**
61
- * ActiveBoxBag constructor
62
- * @param {module:boxes/AbstractBox.AbstractBox} [parent] - The AbstractBox to which this box bag belongs
63
- * @param {module:AWT.Container} [container] - The container where this box bag is placed.
64
- * @param {module:boxes/BoxBase.BoxBase} [boxBase] - The object where colors, fonts, border and other graphic properties
65
- * of this box bag are defined.
66
- */
67
- constructor(parent, container, boxBase) {
68
- // ActiveBoxBag extends BoxBag
69
- super(parent, container, boxBase);
70
- }
71
-
72
- /**
73
- * Adds an {@link module:boxes/ActiveBox.ActiveBox ActiveBox} to this bag
74
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The ActiveBox to be added to this bag
75
- */
76
- addActiveBox(bx) {
77
- bx.idLoc = this.cells.length;
78
- bx.idOrder = bx.idLoc;
79
- return this.addBox(bx);
80
- }
81
-
82
- /**
83
- * Finds an ActiveBox by its relative location (`idLoc` field)
84
- * @param {number} idLoc
85
- * @returns {module:boxes/ActiveBox.ActiveBox}
86
- */
87
- getActiveBox(idLoc) {
88
- return this.getBox(idLoc);
89
- }
90
-
91
- /**
92
- * Gets the background box
93
- * @returns {module:boxes/ActiveBox.ActiveBox}
94
- */
95
- getBackgroundActiveBox() {
96
- return this.getBackgroundBox();
97
- }
98
-
99
- /**
100
- * Sets the content of members of this ActiveBoxBag, based on one or more {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent}
101
- * objects.
102
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - The main bag of content
103
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} [altAbc] - The alternative bag of content
104
- * @param {number} [fromIndex] - Starts taking the cell content located at this position on the bag
105
- * @param {number} [toCell] - Starts filling the box located at this position on the ActiveBoxBag
106
- * @param {number} [numCells] - Acts only with a limited number of elements.
107
- */
108
- setContent(abc, altAbc, fromIndex, toCell, numCells) {
109
- if (!fromIndex)
110
- fromIndex = 0;
111
- if (!toCell)
112
- toCell = 0;
113
- if (!numCells)
114
- numCells = this.cells.length;
115
-
116
- for (let i = 0; i < numCells; i++) {
117
- const bx = this.getActiveBox(toCell + i);
118
- bx.setContent(abc, fromIndex + i);
119
- bx.setAlternative(false);
120
- if (altAbc)
121
- bx.setAltContent(altAbc, fromIndex + i);
122
- }
123
-
124
- if (abc.backgroundContent !== null && this.getBackgroundActiveBox() !== null) {
125
- const bx = this.getBackgroundActiveBox();
126
- bx.setContent(abc.backgroundContent);
127
- if (abc.style !== bx.boxBase)
128
- bx.setBoxBase(abc.style);
129
- }
130
- }
131
-
132
- /**
133
- * Finds an ActiveBox by location
134
- * @param {module:AWT.Point} point - The location to search for
135
- * @returns {module:boxes/ActiveBox.ActiveBox}
136
- */
137
- findActiveBox(point) {
138
- return this.findBox(point);
139
- }
140
-
141
- /**
142
- * Clears the content of all boxes
143
- */
144
- clearAllBoxes() {
145
- this.cells.forEach(bx => bx.clear());
146
- }
147
-
148
- /**
149
- * Clears the content of all boxes and background box
150
- */
151
- clearAll() {
152
- this.clearAllBoxes();
153
- if (this.backgroundBox !== null)
154
- this.getBackgroundActiveBox().clear();
155
- }
156
-
157
- /**
158
- * Count the number of cells that are at its original place
159
- * @returns {number}
160
- */
161
- countCellsAtPlace() {
162
- return this.cells.reduce((n, bx) => bx.isAtPlace() ? ++n : n, 0);
163
- }
164
-
165
- /**
166
- * Finds the {@link module:boxes/ActiveBox.ActiveBox ActiveBox} that has the specified `idLoc` attribute
167
- * @param {number} idLoc - The idLoc to search for
168
- * @returns {module:boxes/ActiveBox.ActiveBox}
169
- */
170
- getActiveBoxWithIdLoc(idLoc) {
171
- return this.cells.find(bx => bx.idLoc === idLoc) || null;
172
- }
173
-
174
- /**
175
- * Checks if the place occupied by a cell corresponds to a cell with equivalent content.
176
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to check
177
- * @param {boolean} checkCase - If `true`, check case when comparing texts
178
- * @returns {boolean}
179
- */
180
- cellIsAtEquivalentPlace(bx, checkCase) {
181
- return bx.isAtPlace() ||
182
- bx.isEquivalent(this.getActiveBoxWithIdLoc(bx.idOrder), checkCase);
183
- }
184
-
185
- /**
186
- * Count the number of cells that are at its original place or equivalent
187
- * @param {boolean} checkCase - - If `true`, check case when comparing texts
188
- * @returns {number}
189
- */
190
- countCellsAtEquivalentPlace(checkCase) {
191
- return this.cells.reduce((n, bx) => this.cellIsAtEquivalentPlace(bx, checkCase) ? ++n : n, 0);
192
- }
193
-
194
- /**
195
- * Counts the number of cells that have the provided `idAss` attribute
196
- * @param {number} idAss - The `idAss` attribute to search
197
- * @returns {number}
198
- */
199
- countCellsWithIdAss(idAss) {
200
- return this.cells.reduce((n, bx) => bx.idAss === idAss ? ++n : n, 0);
201
- }
202
-
203
- /**
204
- * Resets the default `idAss` attribute on all cells
205
- */
206
- setDefaultIdAss() {
207
- this.cells.map(bx => bx.setDefaultIdAss());
208
- }
209
-
210
- /**
211
- * Shuffles the cells
212
- * @param {number} times - Number of times to shuffle
213
- * @param {boolean} fitInArea - Ensure that all cells are inside the bag rectangle
214
- */
215
- shuffleCells(times, fitInArea) {
216
- let nc = this.cells.length;
217
- if (nc >= 2) {
218
- // Array of AWT.Point objects
219
- const
220
- pos = [],
221
- idLoc = [],
222
- p = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR();
223
-
224
- for (let i = 0; i < nc; i++) {
225
- const bx = this.getActiveBox(i);
226
- pos[i] = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bx.pos);
227
- idLoc[i] = bx.idLoc;
228
- }
229
-
230
- for (let i = 0; i < times; i++) {
231
- const
232
- r1 = Math.floor(Math.random() * nc),
233
- r2 = Math.floor(Math.random() * nc);
234
- if (r1 !== r2) {
235
- p.moveTo(pos[r1]);
236
- pos[r1].moveTo(pos[r2]);
237
- pos[r2].moveTo(p);
238
- const j = idLoc[r1];
239
- idLoc[r1] = idLoc[r2];
240
- idLoc[r2] = j;
241
- }
242
- }
243
-
244
- for (let i = 0; i < nc; i++) {
245
- const
246
- bx = this.getActiveBox(i),
247
- px = pos[i].x,
248
- py = pos[i].y;
249
- bx.moveTo(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(px, py));
250
- if (fitInArea)
251
- this.fitCellsInArea([bx]);
252
- bx.idLoc = idLoc[i];
253
- }
254
- }
255
- }
256
-
257
- /**
258
- * Fits cells inside the ActiveBoxBag area. Useful when non-rectangular cells exchange its positions.
259
- * @param {module:boxes/ActiveBox.ActiveBox[]} boxes - The boxes to be checked
260
- */
261
- fitCellsInArea(boxes) {
262
- const
263
- maxX = this.pos.x + this.dim.width,
264
- maxY = this.pos.y + this.dim.height;
265
-
266
- boxes.forEach(bx => {
267
- // Save original position
268
- if (!bx.pos0)
269
- bx.pos0 = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bx.pos);
270
-
271
- const
272
- px = Math.min(Math.max(bx.pos.x, this.pos.x), maxX - bx.dim.width),
273
- py = Math.min(Math.max(bx.pos.y, this.pos.y), maxY - bx.dim.height);
274
- if (px !== bx.pos.x || py !== bx.pos.y)
275
- bx.moveTo(new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(px, py));
276
- });
277
- }
278
-
279
- /**
280
- * Exchange the positions of two cells inside the ActiveBoxBag area.
281
- * @param {module:boxes/ActiveBox.ActiveBox} bxa - The first box
282
- * @param {module:boxes/ActiveBox.ActiveBox} bxb - The second box
283
- * @param {boolean} fitInArea - Ensure that all cells are inside the bag rectangle
284
- */
285
- swapCellPositions(bxa, bxb, fitInArea) {
286
- // Save backup of bxb significant properties
287
- const
288
- posB = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bxb.pos),
289
- posB0 = bxb.pos0,
290
- idLocB = bxb.idLoc;
291
-
292
- bxb.moveTo(bxa.pos0 || bxa.pos);
293
- bxb.pos0 = bxa.pos0;
294
- bxb.idLoc = bxa.idLoc;
295
-
296
- bxa.moveTo(posB0 || posB);
297
- bxa.pos0 = posB0;
298
- bxa.idLoc = idLocB;
299
-
300
- if (fitInArea)
301
- this.fitCellsInArea([bxa, bxb]);
302
- }
303
-
304
- /**
305
- * Resets the IDs of all cells
306
- */
307
- resetIds() {
308
- this.cells.forEach((bx, i) => {
309
- if (bx) {
310
- bx.idOrder = i;
311
- bx.idAss = i;
312
- bx.idLoc = i;
313
- }
314
- });
315
- }
316
-
317
- /**
318
- * Gets the index of box located in the `cells` array after the provided index, having the
319
- * provided `idAssValid` value as `idAss` attribute.
320
- * When `idAssValid` is `null` or `undefined`, search for the next cell with `idAss>0`
321
- * @param {number} currentItem - The index after to which start scanning
322
- * @param {string} [idAssValid] - The `idAss` attribute value to search
323
- * @returns {number}
324
- */
325
- getNextItem(currentItem, idAssValid) {
326
- const IDASSNOTUSED = -12345;
327
- if (!idAssValid)
328
- idAssValid = IDASSNOTUSED;
329
- let i = currentItem + 1;
330
- for (; i < this.cells.length; i++) {
331
- const bx = this.cells[i];
332
- if (!bx)
333
- break;
334
- if (idAssValid !== IDASSNOTUSED) {
335
- if (idAssValid === bx.idAss)
336
- break;
337
- } else if (bx.idAss >= 0)
338
- break;
339
- }
340
- return i;
341
- }
342
-
343
- /**
344
- * Builds a group of hidden `buton` elements that will act as a accessible objects associated
345
- * to the canvas area of this ActiveBoxBag.
346
- * The buttons will only be created when `CanvasRenderingContext2D` has a method named `addHitRegion`.
347
- * See https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Hit_regions_and_accessibility
348
- * for more information and supported browsers.
349
- * @param {external:jQuery} $canvas - The `canvas` where this `ActiveBoxBag` will deploy, wrapped up in a jQuery object
350
- * @param {external:jQuery} $clickReceiver - The DOM element that will be notified when a button is clicked.
351
- * @param {string} [eventType] - Type of event sent to $clickReceiver. Default is `click`.
352
- * @returns {external:jQuery} - The $accessibleDiv member, containing the accessible elements associated to this ActiveBoxBag.
353
- */
354
- buildAccessibleElements($canvas, $clickReceiver, eventType) {
355
- this.$accessibleDiv = this.accessibleText !== '' ? jquery__WEBPACK_IMPORTED_MODULE_0___default()('<div/>', { 'aria-label': this.accessibleText, tabindex: 0 }) : null;
356
- $canvas.append(this.$accessibleDiv);
357
- this.cells
358
- .map(a => a)
359
- .sort((a, b) => a.idLoc > b.idLoc ? 1 : -1)
360
- .forEach(bx => bx.buildAccessibleElement($canvas, $clickReceiver, this.$accessibleDiv, eventType));
361
- return this.$accessibleDiv;
362
- }
363
- }
364
-
365
- Object.assign(ActiveBoxBag.prototype, {
366
- /**
367
- * `div` containing the accessible elements associated to this ActiveBoxBag
368
- * @name module:boxes/ActiveBoxBag.ActiveBoxBag#$accessibleDiv
369
- * @type {external:jQuery} */
370
- $accessibleDiv: null,
371
- });
372
-
373
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveBoxBag);
374
-
375
-
376
- /***/ }),
377
-
378
- /***/ 9205:
379
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
380
-
381
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
382
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
383
- /* harmony export */ });
384
- /* unused harmony export BoxBag */
385
- /* harmony import */ var _AbstractBox_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9513);
386
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7912);
387
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1253);
388
- /**
389
- * File : boxes/BoxBag.js
390
- * Created : 21/04/2015
391
- * By : Francesc Busquets <francesc@gmail.com>
392
- *
393
- * JClic.js
394
- * An HTML5 player of JClic activities
395
- * https://projectestac.github.io/jclic.js
396
- *
397
- * @source https://github.com/projectestac/jclic.js
398
- *
399
- * @license EUPL-1.2
400
- * @licstart
401
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
402
- *
403
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
404
- * the European Commission- subsequent versions of the EUPL (the "Licence");
405
- * You may not use this work except in compliance with the Licence.
406
- *
407
- * You may obtain a copy of the Licence at:
408
- * https://joinup.ec.europa.eu/software/page/eupl
409
- *
410
- * Unless required by applicable law or agreed to in writing, software
411
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
412
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
413
- * Licence for the specific language governing permissions and limitations
414
- * under the Licence.
415
- * @licend
416
- * @module
417
- */
418
-
419
-
420
-
421
-
422
-
423
- /**
424
- * BoxBag is a class derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox} that contains a collection of "boxes"
425
- * (objects also derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox}). This class implements methods to add, remove
426
- * and retrieve boxes, and to manage some of its properties like visibility, status, location and size.
427
- * @extends module:boxes/AbstractBox.AbstractBox
428
- */
429
- class BoxBag extends _AbstractBox_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
430
- /**
431
- * BoxBag constructor
432
- * @param {module:boxes/AbstractBox.AbstractBox} [parent] - The AbstractBox to which this box bag belongs
433
- * @param {module:AWT.Container} [container] - The container where this box bag is placed.
434
- * @param {module:boxes/BoxBase.BoxBase} [boxBase] - The object where colors, fonts, border and other graphic properties
435
- */
436
- constructor(parent, container, boxBase) {
437
- // BoxBag extends AbstractBox
438
- super(parent, container, boxBase);
439
- this.preferredBounds = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_();
440
- this.cells = [];
441
- }
442
-
443
- /**
444
- * Static method that sets the position and dimension of a `Resizable` object based on a
445
- * preferred maximum dimension and a margin.
446
- * @param {module:AWT.Dimension} preferredMaxSize - The preferred maximum size
447
- * @param {Resizable} rs - A resizable object implementing the methods described in the
448
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/boxes/Resizable.html Resizable}
449
- * interface of JClic. Currently a {@link module:boxes/BoxBag.BoxBag BoxBag} or {@link module:boxes/TextGrid.TextGrid TextGrid}.
450
- * @param {number} margin - The margin between the available area and the BoxBag
451
- * @returns {module:AWT.Dimension} - The resulting size of the container
452
- */
453
- static layoutSingle(preferredMaxSize, rs, margin) {
454
-
455
- // Avoid exceptions when rs is null
456
- if (!rs)
457
- return preferredMaxSize;
458
-
459
- // optimal, maximal and minimal dimensions
460
- let
461
- d = rs.getPreferredSize(),
462
- minSize = rs.getMinimumSize(),
463
- maxSize = preferredMaxSize;
464
-
465
- // remove margins
466
- maxSize.width -= 2 * margin;
467
- maxSize.height -= 2 * margin;
468
- // correct maxSize if less than minSize
469
- if (minSize.width > maxSize.width || minSize.height > maxSize.height) {
470
- maxSize = minSize;
471
- }
472
- // compute scale factor
473
- let scale = d.width > maxSize.width ? maxSize.width / d.width : 1;
474
- if (scale * d.height > maxSize.height)
475
- scale = maxSize.height / d.height;
476
-
477
- // resize the `Resizable` object
478
- d = rs.getScaledSize(scale);
479
- rs.setBounds(margin, margin, d.width, d.height);
480
-
481
- // restore margins
482
- d.width += 2 * margin;
483
- d.height += 2 * margin;
484
-
485
- return d;
486
- }
487
-
488
- /**
489
- * Static method that sets the position and dimension of two `Resizable` objects based on a
490
- * preferred maximum size, a layout schema and a margin.
491
- * @param {module:AWT.Dimension} desiredMaxSize - The preferred maximum size
492
- * @param {Resizable} rsA - First resizable object implementing the methods described in the
493
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/boxes/Resizable.html Resizable}
494
- * interface of JClic. Currently a {@link module:boxes/BoxBag.BoxBag BoxBag} or {@link module:boxes/TextGrid.TextGrid TextGrid}.
495
- * @param {Resizable} rsB - Second resizable object
496
- * @param {string} boxGridPos - The layout schema. Possible values are:
497
- * - "AB" (_A_ at left, _B_ at right)
498
- * - "BA" (_B_ at left, _A_ at right)
499
- * - "AUB" (_A_ above _B_)
500
- * - "BUA" (_A_ below _B_).
501
- * @param {number} margin - The margin between the available area and the BoxBag
502
- * @returns {module:AWT.Dimension} - The resulting size of the container
503
- */
504
- static layoutDouble(desiredMaxSize, rsA, rsB, boxGridPos, margin) {
505
- // number of horizontal and vertical grid lines
506
- let
507
- isHLayout = false,
508
- nbh = 1,
509
- nbv = 1;
510
- switch (boxGridPos) {
511
- case 'AB':
512
- case 'BA':
513
- nbh = 2;
514
- nbv = 1;
515
- isHLayout = true;
516
- break;
517
- case 'AUB':
518
- case 'BUA':
519
- nbh = 1;
520
- nbv = 2;
521
- isHLayout = false;
522
- break;
523
- }
524
- const
525
- ra = rsA.getBounds(),
526
- rb = rsB.getBounds();
527
-
528
- // optimal dimensions
529
- let
530
- da = rsA.getPreferredSize(),
531
- db = rsB.getPreferredSize();
532
-
533
- const d = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(
534
- isHLayout ? da.width + db.width : Math.max(da.width, db.width),
535
- isHLayout ? Math.max(da.height, db.height) : da.height + db.height
536
- );
537
-
538
- // minimal dimensions
539
- const
540
- minSizeA = rsA.getMinimumSize(),
541
- minSizeB = rsB.getMinimumSize(),
542
- minSize = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(
543
- isHLayout ? minSizeA.width + minSizeB.width : Math.max(minSizeA.width, minSizeB.width),
544
- isHLayout ? Math.max(minSizeA.height, minSizeB.height) : minSizeA.height + minSizeB.height
545
- ),
546
- maxSize = desiredMaxSize;
547
-
548
- // remove margins
549
- maxSize.width -= (1 + nbh) * margin;
550
- maxSize.height -= (1 + nbv) * margin;
551
-
552
- // correct maxSize if less than minSize
553
- if (minSize.width > maxSize.width || minSize.height > maxSize.height)
554
- maxSize.setDimension(minSize);
555
-
556
- // compute scale factor
557
- let scale = d.width > maxSize.width ? maxSize.width / d.width : 1;
558
- if (scale * d.height > maxSize.height)
559
- scale = maxSize.height / d.height;
560
-
561
- //
562
- // correct possible minimal infractions
563
- // ...
564
- // resize
565
- da = rsA.getScaledSize(scale);
566
- db = rsB.getScaledSize(scale);
567
-
568
- // set margins to center one box relative to the other
569
- let
570
- dah = db.width > da.width ? (db.width - da.width) / 2 : 0,
571
- dbh = da.width > db.width ? (da.width - db.width) / 2 : 0,
572
- dav = db.height > da.height ? (db.height - da.height) / 2 : 0,
573
- dbv = da.height > db.height ? (da.height - db.height) / 2 : 0;
574
-
575
- switch (boxGridPos) {
576
- case 'AB':
577
- rsA.setBounds(margin, margin + dav, da.width, da.height);
578
- rsB.setBounds(2 * margin + da.width, margin + dbv, db.width, db.height);
579
- break;
580
- case 'BA':
581
- rsB.setBounds(margin, margin + dbv, db.width, db.height);
582
- rsA.setBounds(2 * margin + db.width, margin + dav, da.width, da.height);
583
- break;
584
- case 'AUB':
585
- rsA.setBounds(margin + dah, margin, da.width, da.height);
586
- rsB.setBounds(margin + dbh, 2 * margin + da.height, db.width, db.height);
587
- break;
588
- case 'BUA':
589
- rsB.setBounds(margin + dbh, margin, db.width, db.height);
590
- rsA.setBounds(margin + dah, 2 * margin + db.height, da.width, da.height);
591
- break;
592
- default:
593
- rsA.setBounds(
594
- Math.round(margin + scale * ra.pos.x),
595
- Math.round(margin + scale * ra.pos.y),
596
- da.width, da.height);
597
- rsB.setBounds(
598
- Math.round(margin + scale * rb.pos.x),
599
- Math.round(margin + scale * rb.pos.y),
600
- da.width, da.height);
601
- break;
602
- }
603
-
604
- // recompute 'd' adding margins
605
- const r = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(rsA.getBounds());
606
- r.add(rsB.getBounds());
607
- d.width = r.dim.width + 2 * margin;
608
- d.height = r.dim.height + 2 * margin;
609
-
610
- return d;
611
- }
612
-
613
- /**
614
- * Gets the preferred size of this `BoxBag`
615
- * @returns {module:AWT.Dimension}
616
- */
617
- getPreferredSize() {
618
- return this.preferredBounds.dim;
619
- }
620
-
621
- /**
622
- * Gets the minimum size requested by this `BoxBag`
623
- * @returns {module:AWT.Dimension}
624
- */
625
- getMinimumSize() {
626
- const d = this.getPreferredSize();
627
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(
628
- Math.max(_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .settings */ .W0.MIN_CELL_SIZE, d.width),
629
- Math.max(_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .settings */ .W0.MIN_CELL_SIZE, d.height));
630
- }
631
-
632
- /**
633
- * Scales the current size of this box bag, multiplying all values by a specific factor
634
- * @param {number} scale - The scale factor
635
- * @returns {module:AWT.Dimension}
636
- */
637
- getScaledSize(scale) {
638
- const d = this.getPreferredSize();
639
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(Math.round(scale * d.width), Math.round(scale * d.height));
640
- }
641
-
642
- /**
643
- * Adds an {@link module:boxes/AbstractBox.AbstractBox AbstractBox} to the collection of cells
644
- * @param {module:boxes/AbstractBox.AbstractBox} bx - The box to add
645
- */
646
- addBox(bx) {
647
- this.cells.push(bx);
648
- bx.setParent(this);
649
-
650
- if (this.cells.length === 1)
651
- _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_.prototype.setBounds.call(this, bx);
652
- else
653
- this.add(bx);
654
-
655
- this.preferredBounds.setBounds(this.getBounds());
656
- }
657
-
658
- /**
659
- * Returns the index of a specific box in the `cells` array
660
- * @param {module:boxes/AbstractBox.AbstractBox} bx
661
- * @returns {number}
662
- */
663
- boxIndex(bx) {
664
- return bx === null ? -1 : this.cells.indexOf(bx);
665
- }
666
-
667
- /**
668
- * Returns the box at a specific index in the `cells` array
669
- * @param {number} n - The index
670
- * @returns {module:boxes/AbstractBox.AbstractBox}
671
- */
672
- getBox(n) {
673
- return n < 0 || n >= this.cells.length ? null : this.cells[n];
674
- }
675
-
676
- /**
677
- * Gets the background box
678
- * @returns {module:boxes/AbstractBox.AbstractBox}
679
- */
680
- getBackgroundBox() {
681
- return this.backgroundBox;
682
- }
683
-
684
- /**
685
- * Sets the background box
686
- * @param {module:boxes/AbstractBox.AbstractBox} bx
687
- */
688
- setBackgroundBox(bx) {
689
- this.backgroundBox = bx;
690
- if (bx !== null) {
691
- bx.setParent(this);
692
- bx.isBackground = true;
693
- }
694
- // Add the `backgroundbox` rectangle to the global BoxBag rectangle
695
- _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_.prototype.add.call(this, bx);
696
- this.preferredBounds.setBounds(this.getBounds());
697
- }
698
-
699
- /**
700
- * Recalculates the total size of this BoxBag (useful after direct additions o deletions of
701
- * elements in the `cells` array).
702
- * Updates `preferredBounds` and the current position and size of the box bag.
703
- */
704
- recalcSize() {
705
- let r = this.backgroundBox ? new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(this.backgroundBox.pos, this.backgroundBox.dim) : null;
706
- this.cells.forEach(cell => {
707
- if (!r)
708
- r = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(cell.pos, cell.dim);
709
- else
710
- r.add(cell);
711
- });
712
- if (!r)
713
- r = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(this.pos.x, this.pos.y, 0, 0);
714
- this.preferredBounds.setRect(r);
715
- this.x = r.pos.x;
716
- this.y = r.pos.y;
717
- this.dim.width = r.dim.width;
718
- this.dim.height = r.dim.height;
719
- }
720
-
721
- /**
722
- * Returns the number of cells stored in this BoxBag
723
- * @returns {number}
724
- */
725
- getNumCells() {
726
- return this.cells.length;
727
- }
728
-
729
- /**
730
- * Sets the specified key - value pair to all cells of this bag.
731
- * @param {string} key - The key to be established
732
- * @param {any} value - The value, of any type
733
- */
734
- setCellAttr(key, value) {
735
- this.cells.forEach(bx => bx[key] = value);
736
- if (this.backgroundBox)
737
- this.backgroundBox[key] = value;
738
- }
739
-
740
- /**
741
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setBorder} iterating over all the cells stored in this box bag.
742
- * @override
743
- * @param {boolean} newVal - Whether to set or unset the border
744
- */
745
- setBorder(newVal) {
746
- this.cells.forEach(bx => bx.setBorder(newVal));
747
- }
748
-
749
- /**
750
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setVisible} iterating over all the cells stored in this box bag.
751
- * @override
752
- * @param {boolean} newVal - Whether to set the cells visible or not
753
- */
754
- setVisible(newVal) {
755
- this.cells.forEach(bx => bx.setVisible(newVal));
756
- }
757
-
758
- /**
759
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setAlternative} iterating over all the cells stored in this box bag.
760
- * @override
761
- * @param {boolean} newVal - Whether to set or unset the cells in "alternative" mode
762
- */
763
- setAlternative(newVal) {
764
- super.setAlternative(newVal);
765
- this.cells.forEach(bx => bx.setAlternative(newVal));
766
- }
767
-
768
- /**
769
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setBounds} adjusting the position and size of all cells
770
- * @override
771
- * @param {(AWT.Rectangle|number)} rect - An AWT.Rectangle object, or the `x` coordinate of the
772
- * upper-left corner of a new rectangle.
773
- * @param {number} [ry] - `y` coordinate of the upper-left corner of the new rectangle.
774
- * @param {number} [rw] - Width of the new rectangle.
775
- * @param {number} [rh] - Height of the new rectangle.
776
- */
777
- setBounds(rect, ry, rw, rh) {
778
- if (typeof rect === 'number') {
779
- // Arguments are co-ordinates and size
780
- rect = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(rect, ry, rw, rh);
781
- }
782
- if (rect.getSurface() > 0 && !rect.equals(this)) {
783
- const
784
- scaleW = rect.dim.width / this.dim.width,
785
- scaleH = rect.dim.height / this.dim.height,
786
- dx = rect.pos.x - this.pos.x,
787
- dy = rect.pos.y - this.pos.y;
788
- this.cells.forEach(bx => {
789
- const p = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Point */ .bR(bx.pos.x - this.pos.x, bx.pos.y - this.pos.y);
790
- bx.setBounds(
791
- dx + this.pos.x + scaleW * p.x,
792
- dy + this.pos.y + scaleH * p.y,
793
- scaleW * bx.dim.width,
794
- scaleH * bx.dim.height);
795
- // Clear pos0
796
- bx.pos0 = null;
797
- });
798
- if (this.backgroundBox !== null) {
799
- const
800
- bx = this.backgroundBox,
801
- p = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Point */ .bR(bx.pos.x - this.pos.x, bx.pos.y - this.pos.y);
802
- bx.setBounds(
803
- dx + this.pos.x + scaleW * p.x,
804
- dy + this.pos.y + scaleH * p.y,
805
- scaleW * bx.dim.width,
806
- scaleH * bx.dim.height);
807
- }
808
- }
809
- super.setBounds(rect);
810
- }
811
-
812
- /**
813
- * Performs graphics operations for each cell.
814
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#update}
815
- * @override
816
- * @param {external:CanvasRenderingContext2D} ctx - The canvas rendering context used to draw the
817
- * box contents.
818
- * @param {module:AWT.Rectangle} [dirtyRegion] - The area that must be repainted. `null` refers to the whole box.
819
- */
820
- update(ctx, dirtyRegion) {
821
- if (this.isEmpty() || !this.isVisible() || this.isTemporaryHidden())
822
- return false;
823
-
824
- if (dirtyRegion && !this.intersects(dirtyRegion))
825
- return false;
826
-
827
- if (this.backgroundBox !== null)
828
- this.backgroundBox.update(ctx, dirtyRegion);
829
-
830
- this.cells.forEach(bx => {
831
- if (!bx.isMarked())
832
- bx.update(ctx, dirtyRegion);
833
- });
834
-
835
- // Make a second loop to repaint marked cells
836
- this.cells.forEach(bx => {
837
- if (bx.isMarked())
838
- bx.update(ctx, dirtyRegion);
839
- });
840
- return true;
841
- }
842
-
843
- /**
844
- * Finds the first visible {@link module:boxes/AbstractBox.AbstractBox AbstractBox} located under the specified point
845
- * @param {module:AWT.Point} p
846
- * @returns {module:boxes/AbstractBox.AbstractBox}
847
- */
848
- findBox(p) {
849
- let result = null;
850
- for (let i = this.cells.length - 1; i >= 0; i--) {
851
- const bx = this.getBox(i);
852
- if (bx.isVisible() && bx.contains(p)) {
853
- result = bx;
854
- break;
855
- }
856
- }
857
- return result;
858
- }
859
-
860
- /**
861
- * Count the number of cells of this BoxBag that are in "inactive" state
862
- * @returns {number}
863
- */
864
- countInactiveCells() {
865
- return this.cells.reduce((n, bx) => bx.isInactive() ? ++n : n, 0);
866
- }
867
- }
868
-
869
- Object.assign(BoxBag.prototype, {
870
- /**
871
- * The array of cells
872
- * @name module:boxes/BoxBag.BoxBag#cells
873
- * @type {module:boxes/AbstractBox.AbstractBox[]} */
874
- cells: [],
875
- /**
876
- * Rectangle containing the preferred bounds of the BoxBag
877
- * @name module:boxes/BoxBag.BoxBag#preferredBounds
878
- * @type {module:AWT.Rectangle} */
879
- preferredBounds: new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(),
880
- /**
881
- * An optional box used as a background by this BoxBag
882
- * @name module:boxes/BoxBag.BoxBag#backgroundBox
883
- * @type {module:boxes/AbstractBox.AbstractBox} */
884
- backgroundBox: null,
885
- });
886
-
887
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxBag);
888
-
889
-
890
- /***/ })
891
-
892
- };
893
- ;
894
- //# sourceMappingURL=427.jclic-node.js.map