jclic 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +5 -7
  2. package/dist-node/jclic-node.js +14157 -0
  3. package/dist-node/jclic-node.umd.cjs +530 -0
  4. package/package.json +38 -26
  5. package/.vscode/launch.json +0 -33
  6. package/.vscode/settings.json +0 -13
  7. package/CHANGELOG.md +0 -664
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31678
  11. package/dist/jclic-node.js.map +0 -1
  12. package/dist/jclic.components.LICENSE +0 -2254
  13. package/dist/jclic.min.js +0 -27
  14. package/dist/jclic.min.js.map +0 -1
  15. package/eslint.config.mjs +0 -31
  16. package/jsdoc.config.js +0 -71
  17. package/locales/ar.po +0 -244
  18. package/locales/ast.po +0 -246
  19. package/locales/bs.po +0 -247
  20. package/locales/ca.po +0 -248
  21. package/locales/ca_ES@valencia.po +0 -248
  22. package/locales/cs.po +0 -244
  23. package/locales/da.po +0 -244
  24. package/locales/de.po +0 -246
  25. package/locales/el.po +0 -244
  26. package/locales/es.po +0 -248
  27. package/locales/eu.po +0 -244
  28. package/locales/fr.po +0 -244
  29. package/locales/gl.po +0 -244
  30. package/locales/he.po +0 -244
  31. package/locales/hr.po +0 -245
  32. package/locales/it.po +0 -246
  33. package/locales/ja.po +0 -242
  34. package/locales/jclic.js.pot +0 -241
  35. package/locales/nb_NO.po +0 -244
  36. package/locales/nl.po +0 -244
  37. package/locales/pl.po +0 -244
  38. package/locales/pt.po +0 -244
  39. package/locales/pt_BR.po +0 -248
  40. package/locales/ro.po +0 -248
  41. package/locales/ru.po +0 -245
  42. package/locales/ta.po +0 -244
  43. package/locales/tr.po +0 -246
  44. package/locales/uk.po +0 -247
  45. package/locales/vec.po +0 -244
  46. package/locales/zh_TW.po +0 -246
  47. package/patches/po2json+1.0.0-beta-3.patch +0 -12
  48. package/src/AWT.js +0 -2067
  49. package/src/Activity.js +0 -1311
  50. package/src/Deps.js +0 -232
  51. package/src/GlobalData.js +0 -5
  52. package/src/JClic.js +0 -196
  53. package/src/JClicPlayer.js +0 -1308
  54. package/src/PlayerHistory.js +0 -305
  55. package/src/Utils.js +0 -1355
  56. package/src/activities/associations/ComplexAssociation.js +0 -321
  57. package/src/activities/associations/SimpleAssociation.js +0 -519
  58. package/src/activities/memory/MemoryGame.js +0 -423
  59. package/src/activities/panels/Explore.js +0 -349
  60. package/src/activities/panels/Identify.js +0 -356
  61. package/src/activities/panels/InformationScreen.js +0 -262
  62. package/src/activities/panels/Menu.js +0 -209
  63. package/src/activities/panels/icons/ico00.png +0 -0
  64. package/src/activities/panels/icons/ico01.png +0 -0
  65. package/src/activities/panels/icons/ico02.png +0 -0
  66. package/src/activities/panels/icons/ico03.png +0 -0
  67. package/src/activities/panels/icons/icofolder.png +0 -0
  68. package/src/activities/puzzles/DoublePuzzle.js +0 -424
  69. package/src/activities/puzzles/ExchangePuzzle.js +0 -374
  70. package/src/activities/puzzles/HolePuzzle.js +0 -360
  71. package/src/activities/text/Complete.js +0 -127
  72. package/src/activities/text/Evaluator.js +0 -534
  73. package/src/activities/text/FillInBlanks.js +0 -426
  74. package/src/activities/text/IdentifyText.js +0 -253
  75. package/src/activities/text/OrderText.js +0 -421
  76. package/src/activities/text/TextActivityBase.js +0 -557
  77. package/src/activities/text/TextActivityDocument.js +0 -658
  78. package/src/activities/text/WrittenAnswer.js +0 -557
  79. package/src/activities/textGrid/CrossWord.js +0 -565
  80. package/src/activities/textGrid/WordSearch.js +0 -458
  81. package/src/activities/textGrid/icons/hIcon.svg +0 -3
  82. package/src/activities/textGrid/icons/vIcon.svg +0 -3
  83. package/src/automation/AutoContentProvider.js +0 -182
  84. package/src/automation/arith/Arith.js +0 -864
  85. package/src/bags/ActivitySequence.js +0 -318
  86. package/src/bags/ActivitySequenceElement.js +0 -161
  87. package/src/bags/ActivitySequenceJump.js +0 -140
  88. package/src/bags/ConditionalJumpInfo.js +0 -113
  89. package/src/bags/JumpInfo.js +0 -136
  90. package/src/bags/MediaBag.js +0 -215
  91. package/src/bags/MediaBagElement.js +0 -516
  92. package/src/boxes/AbstractBox.js +0 -699
  93. package/src/boxes/ActiveBagContent.js +0 -494
  94. package/src/boxes/ActiveBox.js +0 -810
  95. package/src/boxes/ActiveBoxBag.js +0 -357
  96. package/src/boxes/ActiveBoxContent.js +0 -484
  97. package/src/boxes/ActiveBoxGrid.js +0 -179
  98. package/src/boxes/BoxBag.js +0 -500
  99. package/src/boxes/BoxBase.js +0 -398
  100. package/src/boxes/BoxConnector.js +0 -325
  101. package/src/boxes/TextGrid.js +0 -887
  102. package/src/boxes/TextGridContent.js +0 -215
  103. package/src/init-jsdom.js +0 -65
  104. package/src/jclic-node.js +0 -219
  105. package/src/media/ActiveMediaBag.js +0 -145
  106. package/src/media/ActiveMediaPlayer.js +0 -297
  107. package/src/media/AudioBuffer.js +0 -219
  108. package/src/media/EventSounds.js +0 -169
  109. package/src/media/EventSoundsElement.js +0 -155
  110. package/src/media/MediaContent.js +0 -328
  111. package/src/media/MidiAudioPlayer.js +0 -254
  112. package/src/media/icons/audio.svg +0 -3
  113. package/src/media/icons/generic.svg +0 -3
  114. package/src/media/icons/mic.svg +0 -3
  115. package/src/media/icons/movie.svg +0 -3
  116. package/src/media/icons/music.svg +0 -3
  117. package/src/media/icons/url.svg +0 -3
  118. package/src/media/sounds/actionError.mp3 +0 -0
  119. package/src/media/sounds/actionOk.mp3 +0 -0
  120. package/src/media/sounds/click.mp3 +0 -0
  121. package/src/media/sounds/finishedError.mp3 +0 -0
  122. package/src/media/sounds/finishedOk.mp3 +0 -0
  123. package/src/media/sounds/start.mp3 +0 -0
  124. package/src/project/JClicProject.js +0 -282
  125. package/src/project/ProjectSettings.js +0 -273
  126. package/src/report/ActionReg.js +0 -123
  127. package/src/report/ActivityReg.js +0 -271
  128. package/src/report/EncryptMin.js +0 -210
  129. package/src/report/Reporter.js +0 -727
  130. package/src/report/SCORM.js +0 -272
  131. package/src/report/SequenceReg.js +0 -275
  132. package/src/report/SessionReg.js +0 -340
  133. package/src/report/SessionStorageReporter.js +0 -131
  134. package/src/report/TCPReporter.js +0 -628
  135. package/src/shapers/ClassicJigSaw.js +0 -138
  136. package/src/shapers/Holes.js +0 -77
  137. package/src/shapers/JigSaw.js +0 -161
  138. package/src/shapers/Rectangular.js +0 -78
  139. package/src/shapers/Shaper.js +0 -386
  140. package/src/shapers/TriangularJigSaw.js +0 -121
  141. package/src/skins/BlueSkin.js +0 -80
  142. package/src/skins/Counter.js +0 -152
  143. package/src/skins/CustomSkin.js +0 -412
  144. package/src/skins/DefaultSkin.js +0 -376
  145. package/src/skins/EmptySkin.js +0 -82
  146. package/src/skins/GreenSkin.js +0 -94
  147. package/src/skins/MiniSkin.js +0 -130
  148. package/src/skins/OrangeSkin.js +0 -78
  149. package/src/skins/SimpleSkin.js +0 -92
  150. package/src/skins/Skin.js +0 -1021
  151. package/src/skins/assets/actionsIcon.svg +0 -3
  152. package/src/skins/assets/appLogo.svg +0 -8
  153. package/src/skins/assets/basic.css +0 -41
  154. package/src/skins/assets/closeDialogIcon.svg +0 -3
  155. package/src/skins/assets/closeIcon.svg +0 -3
  156. package/src/skins/assets/copyIcon.svg +0 -3
  157. package/src/skins/assets/fullScreenExitIcon.svg +0 -3
  158. package/src/skins/assets/fullScreenIcon.svg +0 -3
  159. package/src/skins/assets/infoIcon.svg +0 -3
  160. package/src/skins/assets/main.css +0 -43
  161. package/src/skins/assets/mainHalf.css +0 -23
  162. package/src/skins/assets/mainTwoThirds.css +0 -23
  163. package/src/skins/assets/mini.css +0 -15
  164. package/src/skins/assets/nextIcon.svg +0 -3
  165. package/src/skins/assets/okDialogIcon.svg +0 -3
  166. package/src/skins/assets/prevIcon.svg +0 -3
  167. package/src/skins/assets/reports.css +0 -156
  168. package/src/skins/assets/reportsIcon.svg +0 -3
  169. package/src/skins/assets/scoreIcon.svg +0 -3
  170. package/src/skins/assets/simple.css +0 -16
  171. package/src/skins/assets/simpleHalf.css +0 -11
  172. package/src/skins/assets/simpleTwoThirds.css +0 -11
  173. package/src/skins/assets/timeIcon.svg +0 -4
  174. package/src/skins/assets/waitAnim.css +0 -54
  175. package/src/skins/assets/waitImgBig.svg +0 -3
  176. package/src/skins/assets/waitImgSmall.svg +0 -3
  177. package/webpack.config.mjs +0 -169
@@ -1,494 +0,0 @@
1
- /**
2
- * File : boxes/ActiveBagContent.js
3
- * Created : 13/04/2015
4
- * By : Francesc Busquets <francesc@gmail.com>
5
- *
6
- * JClic.js
7
- * An HTML5 player of JClic activities
8
- * https://projectestac.github.io/jclic.js
9
- *
10
- * @source https://github.com/projectestac/jclic.js
11
- *
12
- * @license EUPL-1.2
13
- * @licstart
14
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
15
- *
16
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
17
- * the European Commission- subsequent versions of the EUPL (the "Licence");
18
- * You may not use this work except in compliance with the Licence.
19
- *
20
- * You may obtain a copy of the Licence at:
21
- * https://joinup.ec.europa.eu/software/page/eupl
22
- *
23
- * Unless required by applicable law or agreed to in writing, software
24
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
25
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26
- * Licence for the specific language governing permissions and limitations
27
- * under the Licence.
28
- * @licend
29
- * @module
30
- */
31
-
32
- import $ from 'jquery';
33
- import BoxBase from './BoxBase.js';
34
- import ActiveBoxContent from './ActiveBoxContent.js';
35
- import Shaper from '../shapers/Shaper.js';
36
- import { Rectangle } from '../AWT.js';
37
- import { settings, attrForEach, nSlash, getBoolean, getAttr, setAttr } from '../Utils.js';
38
-
39
- /**
40
- * This class packs a collection of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects and provides methods to access
41
- * and manage it. The two main members of `ActiveBagContent` are the {@link module:shapers/Shaper.Shaper Shaper}, responsible for
42
- * determining the position and shape of each {@link module:boxes/ActiveBox.ActiveBox ActiveBox}, and the {@link module:boxes/BoxBase.BoxBase BoxBase} (field `style`),
43
- * provider of a common visual style.
44
- */
45
- export class ActiveBagContent {
46
- /**
47
- * ActiveBagContent constructor
48
- * @param {string} [id] - An optional text tag identifying this ActiveBagContent
49
- * @param {number} ncw - In grid-based distributions, number of columns.
50
- * @param {number} nch - In grid-based distributions, number of rows.
51
- */
52
- constructor(id, ncw, nch) {
53
- if (id)
54
- this.id = id;
55
- this.cells = [];
56
- this.ncw = Math.max(1, ncw);
57
- this.nch = Math.max(1, nch);
58
- }
59
-
60
- /**
61
- * Loads the object settings from a specific JQuery XML element
62
- * @param {external:jQuery} $xml - The XML element to parse
63
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The project's MediaBag
64
- */
65
- setProperties($xml, mediaBag) {
66
- let bug = false;
67
- attrForEach($xml.get(0).attributes, (name, val) => {
68
- switch (name) {
69
- case 'id':
70
- this.id = val;
71
- break;
72
- case 'image':
73
- this.image = nSlash(val);
74
- break;
75
- // Bug in JClic beta 1: "columns" is number of rows, and "rows" is number of columns.
76
- // Was corrected in beta 2: If "cols" is specified, "rows" are rows and "cols" are columns.
77
- case 'rows':
78
- this.nch = Number(val);
79
- break;
80
- case 'columns':
81
- bug = true;
82
- /* falls through */
83
- case 'cols':
84
- this.ncw = Number(val);
85
- break;
86
- case 'cellWidth':
87
- this.w = Number(val);
88
- break;
89
- case 'cellHeight':
90
- this.h = Number(val);
91
- break;
92
- case 'border':
93
- this.border = getBoolean(val);
94
- break;
95
- }
96
- });
97
-
98
- if (bug) {
99
- let n = this.ncw;
100
- this.ncw = this.nch;
101
- this.nch = n;
102
- }
103
-
104
- $xml.children().each((_n, child) => {
105
- const $node = $(child);
106
- switch (child.nodeName) {
107
- case 'style':
108
- this.style = new BoxBase(null).setProperties($node);
109
- break;
110
- case 'shaper':
111
- const shaperClassName = $node.attr('class'),
112
- nCols = Math.max(1, $node.attr('cols')),
113
- nRows = Math.max(1, $node.attr('rows'));
114
- this.shaper = Shaper.getShaper(shaperClassName, nCols, nRows);
115
- this.shaper.setProperties($node);
116
- break;
117
- case 'ids':
118
- // Used in special cases where all cells have empty content with only 'ids'
119
- this.ids = child.textContent;
120
- this.ids.split(' ').forEach((id, i) => { this.cells[i] = new ActiveBoxContent(Number(id)); });
121
- break;
122
- case 'cell':
123
- this.cells.push(new ActiveBoxContent().setProperties($node, mediaBag));
124
- break;
125
- }
126
- });
127
-
128
- let n = this.cells.length;
129
-
130
- // Create cells when `cells` is empty
131
- if (n === 0 && this.shaper && this.shaper.nCells > 0) {
132
- this.initiallyEmptyCells = true;
133
- n = this.shaper.nCells;
134
- this.getActiveBoxContent(n - 1);
135
- }
136
-
137
- // Assign ids when cells have empty content (they are just shapes)
138
- if (n > 0) {
139
- let empty = true;
140
- for (let i = 0; i < n; i++) {
141
- const bxc = this.getActiveBoxContent(i);
142
- if (bxc.id !== -1 || bxc.item !== -1 || !bxc.isEmpty()) {
143
- empty = false;
144
- break;
145
- }
146
- }
147
- if (empty) {
148
- for (let i = 0; i < n; i++)
149
- this.getActiveBoxContent(i).id = i;
150
- }
151
- }
152
-
153
- // Link [BoxBase](BoxBase.html) objects of `cells` elements to `style`
154
- if (this.style)
155
- this.cells.forEach((abc) => { if (abc.style) abc.style.parent = this.style; });
156
-
157
- return this;
158
- }
159
-
160
- /**
161
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
162
- * parent references, constants and also attributes retaining the default value.
163
- * The resulting object is commonly usued to serialize elements in JSON format.
164
- * @returns {object} - The resulting object, with minimal attrributes
165
- */
166
- getAttributes() {
167
- const fields = [
168
- 'id', 'image',
169
- 'ncw', 'nch',
170
- 'w', 'h', 'border',
171
- 'style', // BoxBase
172
- 'shaper', // Shaper
173
- ];
174
- if (!this.initiallyEmptyCells)
175
- fields.push(this.ids ? 'ids' : 'cells'); // ActiveBoxContent
176
- return getAttr(this, fields);
177
- }
178
-
179
- /**
180
- * Reads the properties of this ActiveBagContent from a data object
181
- * @param {object} data - The data object to be parsed
182
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The project's MediaBag
183
- * @returns {module:boxes/ActiveBagContent.ActiveBagContent}
184
- */
185
- setAttributes(data, mediaBag) {
186
- setAttr(this, data, [
187
- 'id', 'image',
188
- 'ncw', 'nch',
189
- 'w', 'h', 'border',
190
- { key: 'style', fn: BoxBase },
191
- { key: 'shaper', fn: Shaper },
192
- 'ids',
193
- { key: 'cells', fn: ActiveBoxContent, group: 'array', params: [mediaBag] },
194
- ]);
195
-
196
- let n = this.cells.length;
197
-
198
- // Create cells when `cells` is empty
199
- if (n === 0 && this.shaper && this.shaper.nCells > 0) {
200
- this.initiallyEmptyCells = true;
201
- n = this.shaper.nCells;
202
- this.getActiveBoxContent(n - 1);
203
- if (this.ids)
204
- this.ids.split(' ').forEach((id, i) => { this.getActiveBoxContent(i).id = Number(id); });
205
- }
206
-
207
- // Assign ids when cells have empty content (they are just shapes)
208
- if (n > 0) {
209
- let empty = true;
210
- for (let i = 0; i < n; i++) {
211
- const bxc = this.getActiveBoxContent(i);
212
- if (bxc.id !== -1 || bxc.item !== -1 || !bxc.isEmpty()) {
213
- empty = false;
214
- break;
215
- }
216
- }
217
- if (empty) {
218
- for (let i = 0; i < n; i++)
219
- this.getActiveBoxContent(i).id = i;
220
- }
221
- }
222
-
223
- // Link [BoxBase](BoxBase.html) objects of `cells` elements to `style`
224
- if (this.style)
225
- this.cells.forEach(abc => { if (abc.style) abc.style.parent = this.style; });
226
-
227
- if (mediaBag)
228
- this.cells.forEach(abc => abc.realizeContent(mediaBag));
229
-
230
- return this;
231
- }
232
-
233
- /**
234
- * Prepares the media content of all elements
235
- * @param {module:JClicPlayer.JClicPlayer} playStation - The {@link module:JClicPlayer.JClicPlayer JClicPlayer}
236
- */
237
- prepareMedia(playStation) {
238
- this.cells.forEach(abc => abc.prepareMedia(playStation));
239
- }
240
-
241
- /**
242
- * Gets the estimated total width of this content bag
243
- * @returns {number}
244
- */
245
- getTotalWidth() {
246
- return this.w * this.ncw;
247
- }
248
-
249
- /**
250
- * Gets the estimated total height of this bag
251
- * @returns {number}
252
- */
253
- getTotalHeight() {
254
- return this.h * this.nch;
255
- }
256
-
257
- /**
258
- * Gets the total number of cells of this bag
259
- * @returns {number}
260
- */
261
- getNumCells() {
262
- return this.cells.length;
263
- }
264
-
265
- /**
266
- * Checks if the bag is empty
267
- * @returns {boolean}
268
- */
269
- isEmpty() {
270
- return this.cells.length === 0;
271
- }
272
-
273
- /**
274
- * Retrieves the {@link module:shapers/Shaper.Shaper Shaper} of this bag, creating a new one if it was _null_
275
- * @returns {module:shapers/Shaper.Shaper}
276
- */
277
- getShaper() {
278
- if (this.shaper === null)
279
- this.shaper = Shaper.getShaper('@Rectangular', this.ncw, this.nch);
280
- return this.shaper;
281
- }
282
-
283
- /**
284
- * Retrieves the {@link module:boxes/BoxBase.BoxBase BoxBase} of this bag, creating a new one if it was _null_
285
- * @returns {module:boxes/BoxBase.BoxBase}
286
- */
287
- getBoxBase() {
288
- if (this.style === null)
289
- this.style = new BoxBase();
290
- return this.style;
291
- }
292
-
293
- /**
294
- * Adds a new {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} to this bag
295
- * @param {module:boxes/ActiveBoxContent.ActiveBoxContent} ab - The ActiveBoxContent to add
296
- */
297
- addActiveBoxContent(ab) {
298
- this.cells.push(ab);
299
- if (this.ncw === 0 || this.nch === 0) {
300
- this.ncw = this.nch = 1;
301
- }
302
- }
303
-
304
- /**
305
- * Gets the nth {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} in `cells`
306
- * @param {number} i - The index of the content to be retrieved
307
- * @returns {module:boxes/ActiveBoxContent.ActiveBoxContent}
308
- */
309
- getActiveBoxContent(i) {
310
- if (i >= this.cells.length) {
311
- for (let j = this.cells.length; j <= i; j++)
312
- this.cells.push(new ActiveBoxContent());
313
- }
314
- return this.cells[i];
315
- }
316
-
317
- /**
318
- * Finds the ActiveBoxContent with specific `id` and `item` values
319
- * @param {number} id
320
- * @param {number} item
321
- * @returns {module:boxes/ActiveBoxContent.ActiveBoxContent}
322
- */
323
- getActiveBoxContentWith(id, item) {
324
- return this.cells.find(bxc => bxc.id === id && bxc.item === item);
325
- }
326
-
327
- /**
328
- * Sets the content of the cells based on a image spliced by a shaper
329
- * @param {module:bags/MediaBag.MediaBag} mb - The MediaBag used to retrieve the image
330
- * @param {module:shapers/Shaper.Shaper} sh - The Shaper used to splice the image
331
- * @param {boolean} roundSizes - When `true`, the size and coordinates of cells will be rounded
332
- * to the nearest integer values.
333
- */
334
- setImgContent(mb, sh, roundSizes) {
335
- if (sh)
336
- this.setShaper(sh);
337
-
338
- if (this.shaper.className === '@Holes')
339
- this.shaper.hasRemainder = true;
340
-
341
- this.ncw = this.shaper.nCols;
342
- this.nch = this.shaper.nRows;
343
- const mbe = mb.elements[this.image];
344
- if (mb && this.image && mbe && mbe.ready) {
345
- this.img = mbe.data;
346
- if (mbe.animated)
347
- this.animatedGifFile = mbe.getFullPath();
348
- this.w = this.img.width / this.ncw;
349
- this.h = this.img.height / this.nch;
350
- if (roundSizes) {
351
- this.w = Math.round(this.w);
352
- this.h = Math.round(this.h);
353
- }
354
- } else {
355
- this.img = null;
356
- this.w = Math.max(this.w, 10);
357
- this.h = Math.max(this.h, 10);
358
- }
359
-
360
- const r = new Rectangle(0, 0, this.w * this.ncw, this.h * this.nch);
361
- for (let i = 0; i < this.shaper.nCells; i++)
362
- this.getActiveBoxContent(i).setImgContent(this.img, this.shaper.getShape(i, r), this.animatedGifFile);
363
-
364
- if (this.shaper.hasRemainder) {
365
- this.backgroundContent = new ActiveBoxContent();
366
- this.backgroundContent.setImgContent(this.img, this.shaper.getRemainderShape(r));
367
- }
368
- }
369
-
370
- /**
371
- * Sets the content of this bag based on an array of strings
372
- * @param {string[]} txt - The array of strings to be used as content.
373
- * @param {number} setNcw - Number of columns
374
- * @param {number} setNch - Number of rows
375
- */
376
- setTextContent(txt, setNcw, setNch) {
377
- this.ncw = Math.max(1, setNcw);
378
- this.nch = Math.max(1, setNch);
379
- const n = this.ncw * this.nch;
380
- for (let i = 0; i < n; i++)
381
- this.getActiveBoxContent(i).setTextContent(i >= txt.length || txt[i] === null ? '' : txt[i]);
382
- }
383
-
384
- /**
385
- * Sets `id` values to a all the {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} elements of his bag.
386
- * @param {number[]} ids -Array of numeric identifiers
387
- */
388
- setIds(ids) {
389
- for (let i = 0; i < ids.length && i < this.cells.length; i++)
390
- this.getActiveBoxContent(i).id = ids[i];
391
- }
392
-
393
- /**
394
- * Sets `value` to the `key` attribute of all cells
395
- * @param {string} key - The key where the value will be stored
396
- * @param {any} value - The supplied value. Can be of any type.
397
- */
398
- setCellsAttribute(key, value) {
399
- this.cells.forEach(abc => abc[key] = value);
400
- }
401
-
402
- /**
403
- *
404
- * Cheks if the `id` values of all {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects are -1 and, if true,
405
- * sets new ids to them, with values between 0 and `maxId`
406
- * @param {number} maxId - The maximum value of identifiers
407
- */
408
- avoidAllIdsNull(maxId) {
409
- if (this.cells.every(abc => abc.id === -1)) {
410
- maxId = Math.max(1, maxId);
411
- this.cells.forEach((abc, n) => { abc.id = n % maxId; });
412
- }
413
- }
414
- }
415
-
416
- Object.assign(ActiveBagContent.prototype, {
417
- /**
418
- * The global identifier of this object: `primary`, `secondary`...
419
- * @name module:boxes/ActiveBagContent.ActiveBagContent#id
420
- * @type {string} */
421
- id: 'primary',
422
- /**
423
- * The name of the image file used as a common image of this bag
424
- * @name module:boxes/ActiveBagContent.ActiveBagContent#image
425
- * @type {string} */
426
- image: null,
427
- /**
428
- * The built image object
429
- * @name module:boxes/ActiveBagContent.ActiveBagContent#img
430
- * @type {external:HTMLImageElement} */
431
- img: null,
432
- /**
433
- * Name of the img source when is an animated GIF
434
- * @name module:boxes/ActiveBagContent.ActiveBagContent#animatedGifFile
435
- * @type {string} */
436
- animatedGifFile: null,
437
- /**
438
- * Number of columns when cells are distributed in a grid
439
- * @name module:boxes/ActiveBagContent.ActiveBagContent#ncw
440
- * @type {number} */
441
- ncw: 1,
442
- /**
443
- * Number of rows when cells are distributed in a grid
444
- * @name module:boxes/ActiveBagContent.ActiveBagContent#nch
445
- * @type {number} */
446
- nch: 1,
447
- /**
448
- * Optimal cell width
449
- * @name module:boxes/ActiveBagContent.ActiveBagContent#w
450
- * @type {number} */
451
- w: settings.DEFAULT_GRID_ELEMENT_SIZE,
452
- /**
453
- * Optimal cell height
454
- * @name module:boxes/ActiveBagContent.ActiveBagContent#h
455
- * @type {number} */
456
- h: settings.DEFAULT_GRID_ELEMENT_SIZE,
457
- /**
458
- * Whether the cells must have a border or not
459
- * @name module:boxes/ActiveBagContent.ActiveBagContent#border
460
- * @type {boolean} */
461
- border: true,
462
- /**
463
- * The BoxBase used for this bag of cell contents
464
- * @name module:boxes/ActiveBagContent.ActiveBagContent#style
465
- * @type {module:boxes/BoxBase.BoxBase} */
466
- style: null,
467
- /**
468
- * The Shaper used to define the specific shape of each cell
469
- * @name module:boxes/ActiveBagContent.ActiveBagContent#shaper
470
- * @type {module:shapers/Shaper.Shaper} */
471
- shaper: null,
472
- /**
473
- * An optional ActiveBoxContent object with background settings.
474
- * @name module:boxes/ActiveBagContent.ActiveBagContent#backgroundContent
475
- * @type {module:boxes/ActiveBoxContent.ActiveBoxContent} */
476
- backgroundContent: null,
477
- /**
478
- * The main Array of {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} objects
479
- * @name module:boxes/ActiveBagContent.ActiveBagContent#cells
480
- * @type {module:boxes/ActiveBoxContent.ActiveBoxContent[]} */
481
- cells: null,
482
- /**
483
- * The default value to be assigned at the 'id' field of children
484
- * @name module:boxes/ActiveBagContent.ActiveBagContent#defaultIdValue
485
- * @type {number} */
486
- defaultIdValue: -1,
487
- /**
488
- * Used in special cases where all cells have empty content with only numeric identifiers
489
- * @name module:boxes/ActiveBagContent.ActiveBagContent#ids
490
- * @type {string} */
491
- ids: null,
492
- });
493
-
494
- export default ActiveBagContent;