jclic 2.2.1 → 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 -672
  8. package/TRANSLATIONS.md +0 -11
  9. package/build-locales.mjs +0 -82
  10. package/dist/jclic-node.js +0 -31680
  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 -660
  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,484 +0,0 @@
1
- /**
2
- * File : boxes/ActiveBoxContent.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 Catalan Educational Telematic Network (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 { Dimension } from '../AWT.js';
34
- import { getAttr, setAttr, attrForEach, getBoolean, nSlash, startsWith, getMsg } from '../Utils.js';
35
- import BoxBase from './BoxBase.js';
36
- import MediaContent from '../media/MediaContent.js';
37
-
38
- /**
39
- * This class is used as a container for horizontal and vertical alignments of content inside a cell.
40
- */
41
- export class AlignType {
42
- /**
43
- * AlignType constructor
44
- * @param {string} [h] - Horizontal alignment. Possible values are `left`, `center` and `right`
45
- * @param {string} [v] - Vertical alignment. Possible values are `top`, `center` and `bottom`
46
- */
47
- constructor(h, v) {
48
- if (h)
49
- this.h = h;
50
- if (v)
51
- this.v = v;
52
- }
53
-
54
- /**
55
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
56
- * parent references, constants and also attributes retaining the default value.
57
- * The resulting object is commonly usued to serialize elements in JSON format.
58
- * @returns {object} - The resulting object, with minimal attrributes
59
- */
60
- getAttributes() {
61
- return getAttr(this, ['h|center', 'v|center']);
62
- }
63
-
64
- /**
65
- * Reads the properties of this AlignType from a data object
66
- * @param {object} data - The data object to be parsed
67
- * @returns {module:boxes/ActiveBoxContent.AlignType}
68
- */
69
- setAttributes(data) {
70
- return setAttr(this, data, ['h', 'v']);
71
- }
72
- }
73
-
74
- Object.assign(AlignType.prototype, {
75
- h: 'center',
76
- v: 'center',
77
- });
78
-
79
- /**
80
- * This class defines a content that can be displayed by {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects. This content
81
- * can be a text, an image, a fragment of an image or a combination of text and images. The style
82
- * (colors, font and size, borders, shadows, margins, etc.) are specified in the `style` attribute,
83
- * always pointing to a {@link module:boxes/BoxBase.BoxBase BoxBase} object.
84
- */
85
- export class ActiveBoxContent {
86
- /**
87
- * ActiveBoxContent constructor
88
- * @param {string} [id] - An optional identifier.
89
- */
90
- constructor(id) {
91
- if (typeof id !== 'undefined')
92
- this.id = id;
93
- this.imgAlign = new AlignType();
94
- this.txtAlign = new AlignType();
95
- }
96
-
97
- /**
98
- *
99
- * Loads settings from a specific JQuery XML element
100
- * @param {external:jQuery} $xml - The XML element to be parsed
101
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The media bag used to retrieve images and other media
102
- */
103
- setProperties($xml, mediaBag) {
104
- //
105
- // Read attributes
106
- attrForEach($xml.get(0).attributes, (name, val) => {
107
- switch (name) {
108
- case 'id':
109
- case 'item':
110
- this[name] = Number(val);
111
- break;
112
-
113
- case 'width':
114
- case 'height':
115
- if (this.dimension === null)
116
- this.dimension = new Dimension(0, 0);
117
- this.dimension[name] = Number(val);
118
- break;
119
-
120
- case 'txtAlign':
121
- case 'imgAlign':
122
- this[name] = this.readAlign(val);
123
- break;
124
-
125
- case 'hAlign':
126
- // Old style
127
- this['txtAlign'] = this.readAlign(val + ',center');
128
- this['imgAlign'] = this.readAlign(val + ',center');
129
- break;
130
-
131
- case 'border':
132
- case 'avoidOverlapping':
133
- this[name] = getBoolean(val);
134
- break;
135
-
136
- case 'image':
137
- this.image = nSlash(val);
138
- break;
139
- }
140
- });
141
-
142
- //
143
- // Read inner elements
144
- $xml.children().each((_n, child) => {
145
- const $node = $(child);
146
- switch (child.nodeName) {
147
- case 'style':
148
- this.style = new BoxBase(null).setProperties($node);
149
- break;
150
- case 'media':
151
- this.mediaContent = new MediaContent().setProperties($node);
152
- break;
153
- case 'p':
154
- if (this.text === null)
155
- this.text = '';
156
- else
157
- this.text += '\n';
158
- this.text += child.textContent;
159
- break;
160
- }
161
- });
162
-
163
- if (mediaBag)
164
- this.realizeContent(mediaBag);
165
-
166
- return this;
167
- }
168
-
169
- /**
170
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
171
- * parent references, constants and also attributes retaining the default value.
172
- * The resulting object is commonly usued to serialize elements in JSON format.
173
- * @returns {object} - The resulting object, with minimal attrributes
174
- */
175
- getAttributes() {
176
- return getAttr(this, [
177
- 'id', 'item', 'dimension', 'border', 'avoidOverlapping', 'image', 'text',
178
- 'objectType', // Used in TextActivityDocument
179
- 'txtAlign', 'imgAlign', // AlignType
180
- 'style', // BoxBase
181
- 'mediaContent', // MediaContent
182
- ]);
183
- }
184
-
185
- /**
186
- * Reads the properties of this ActiveBoxContent from a data object
187
- * @param {object|string} data - The data object to be parsed, or just the text content
188
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The media bag used to retrieve images and other media
189
- * @returns {module:boxes/ActiveBoxContent.ActiveBoxContent}
190
- */
191
- setAttributes(data, mediaBag) {
192
-
193
- if (typeof data === 'string')
194
- this.text = data;
195
- else
196
- setAttr(this, data, [
197
- 'id', 'item', 'border', 'avoidOverlapping', 'image', 'text',
198
- 'objectType',
199
- { key: 'dimension', fn: Dimension },
200
- { key: 'txtAlign', fn: AlignType },
201
- { key: 'imgAlign', fn: AlignType },
202
- { key: 'style', fn: BoxBase },
203
- { key: 'mediaContent', fn: MediaContent },
204
- ]);
205
-
206
- if (mediaBag)
207
- this.realizeContent(mediaBag);
208
-
209
- return this;
210
- }
211
-
212
- /**
213
- * Decode expressions with combined values of horizontal and vertical alignments in the form:
214
- * "(left|middle|right),(top|middle|bottom)"
215
- * @param {string} str - The string to parse
216
- * @returns {module:boxes/ActiveBoxContent.ActiveBoxContent~alignType}
217
- */
218
- readAlign(str) {
219
- const align = new AlignType();
220
- if (str) {
221
- const v = str.split(',');
222
- align.h = v[0].replace('middle', 'center');
223
- align.v = v[1].replace('middle', 'center');
224
- }
225
- return align;
226
- }
227
-
228
- /**
229
- * Checks if this is an empty content (`text` and `img` are _null_)
230
- */
231
- isEmpty() {
232
- return this.text === null && this.img === null;
233
- }
234
-
235
- /**
236
- * Checks if two contents are equivalent
237
- * @param {module:boxes/ActiveBoxContent.ActiveBoxContent} abc - The content to compare with this.
238
- * @param {boolean} checkCase - When `true` the comparing will be case-sensitive.
239
- * @returns {boolean}
240
- */
241
- isEquivalent(abc, checkCase) {
242
- if (abc === this)
243
- return true;
244
- let result = false;
245
- if (abc !== null) {
246
- if (this.isEmpty() && abc.isEmpty())
247
- result = this.id === abc.id;
248
- else
249
- result = (this.text === null ? abc.text === null
250
- : checkCase ? this.text === abc.text
251
- : this.text.toLocaleLowerCase() === abc.text.toLocaleLowerCase()
252
- ) &&
253
- (this.mediaContent === null ? abc.mediaContent === null
254
- : this.mediaContent.isEquivalent(abc.mediaContent)
255
- ) &&
256
- this.img === abc.img &&
257
- (this.imgClip === null ? abc.imgClip === null
258
- : this.imgClip.equals(abc.imgClip));
259
- }
260
- return result;
261
- }
262
-
263
- /**
264
- * Sets the text content of this ActiveBox
265
- * @param {string} tx
266
- */
267
- setTextContent(tx) {
268
- // only plain text allowed!
269
- if (tx !== null) {
270
- this.text = tx;
271
- this.checkHtmlText();
272
- } else {
273
- this.text = null;
274
- this.innerHtmlText = null;
275
- }
276
- }
277
-
278
- /**
279
- * Checks if cell's text uses HTML, initializing the `innerHtmlText` member as needed.
280
- */
281
- checkHtmlText() {
282
- this.innerHtmlText = null;
283
- if (startsWith(this.text, '<html>', true)) {
284
- const htmlText = this.text.trim();
285
- const s = htmlText.toLocaleLowerCase();
286
- if (s.indexOf('<body') === -1) {
287
- const s2 = s.indexOf('</html>');
288
- if (s2 >= 0)
289
- this.innerHtmlText = htmlText.substring(6, s2);
290
- }
291
- }
292
- }
293
-
294
- /**
295
- * Sets a fragment of a main image as a graphic content of this cell.
296
- * Cells cannot have two graphic contents, so `image` (the specific image of this cell) should
297
- * be cleared with this setting.
298
- * @param {external:HTMLImageElement} img - The image data
299
- * @param {module:AWT.Shape} imgClip - A shape that clips the portion of image assigned to this content.
300
- * @param {string} [animatedGifFile] - When `img` is an animated GIF, its file name
301
- */
302
- setImgContent(img, imgClip, animatedGifFile) {
303
- this.img = img;
304
- this.image = null;
305
- this.imgClip = imgClip;
306
- if (animatedGifFile)
307
- this.animatedGifFile = animatedGifFile;
308
- }
309
-
310
- /**
311
- * Prepares the media content
312
- * @param {module:JClicPlayer.JClicPlayer} playStation - Usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}
313
- */
314
- prepareMedia(playStation) {
315
- if (!this.amp && this.mediaContent && this.mediaContent.type === 'PLAY_VIDEO') {
316
- this.amp = playStation.getActiveMediaPlayer(this.mediaContent);
317
- this.amp.realize();
318
- }
319
- }
320
-
321
- /**
322
- * Reads and initializes the image associated to this content
323
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The media bag of the current project.
324
- */
325
- realizeContent(mediaBag, ps = null) {
326
- if (this.image !== null && this.image.length > 0) {
327
- this.mbe = mediaBag.getElement(this.image, true);
328
- if (this.mbe) {
329
- this.mbe.build(() => {
330
- this.img = this.mbe.data;
331
- this.animatedGifFile = this.mbe.animated ? this.mbe.getFullPath() : null;
332
- }, ps, true);
333
- }
334
- }
335
- if (this.mediaContent !== null) {
336
- if (this.image === null && (this.text === null || this.text.length === 0)) {
337
- this.img = this.mediaContent.getIcon();
338
- this.animatedGifFile = null;
339
- }
340
- }
341
- this.checkHtmlText(mediaBag);
342
- }
343
-
344
- /**
345
- * Gets a string representing this content, useful for checking if two different contents are
346
- * equivalent.
347
- * @returns {string}
348
- */
349
- getDescription() {
350
- const result = [];
351
- if (this.text && this.text.length)
352
- result.push(this.text);
353
- if (this.image)
354
- result.push(`${getMsg('image')} ${this.image}`);
355
- if (this.imgClip)
356
- result.push(this.imgClip.toString());
357
- if (this.mediaContent)
358
- result.push(this.mediaContent.getDescription());
359
- return result.join(' ');
360
- }
361
-
362
- /**
363
- *
364
- * Overwrites the original `Object.toString` method, returning `getDescription` instead
365
- * @returns {string}
366
- */
367
- toString() {
368
- const result = [];
369
- if (this.text && this.text.length)
370
- result.push(this.text);
371
- if (this.image)
372
- result.push(`${getMsg('image')} ${this.image}`);
373
- if (this.imgClip)
374
- result.push(`${getMsg('image fragment')} ${(this.id >= 0 ? this.id : this.item) + 1}`);
375
- return result.join(' ') || getMsg('cell');
376
- }
377
- }
378
-
379
- Object.assign(ActiveBoxContent.prototype, {
380
- /**
381
- * The {@link module:boxes/BoxBase.BoxBase BoxBase} attribute of this content. Can be `null`, meaning {@link module:boxes/ActiveBox.ActiveBox ActiveBox} will
382
- * try to find a suitable style scanning down through its own BoxBase, their parent's and, finally,
383
- * the default values defined in `BoxBase.prototype`.
384
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#style
385
- * @type {module:boxes/BoxBase.BoxBase} */
386
- style: null,
387
- /**
388
- * Optimal dimension of any {@link module:boxes/ActiveBox.ActiveBox ActiveBox} taking this content.
389
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#dimension
390
- * @type {module:AWT.Dimension} */
391
- dimension: null,
392
- /**
393
- * The {@link module:boxes/ActiveBox.ActiveBox ActiveBox} can have or not a border despite the settings of {@link module:boxes/BoxBase.BoxBase BoxBase}.
394
- * The default value `null` means not to take in consideration this setting.
395
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#border
396
- * @type {boolean|null} */
397
- border: null,
398
- /**
399
- * The text to display on the {@link module:boxes/ActiveBox.ActiveBox ActiveBox}. It can have up to two paragraphs.
400
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#text
401
- * @type {string} */
402
- text: null,
403
- /**
404
- * The name of the image file to display on the {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
405
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#image
406
- * @type {string} */
407
- image: null,
408
- /**
409
- * An optional shape used to clip the image.
410
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#imgClip
411
- * @type {module:AWT.Shape} */
412
- imgClip: null,
413
- /**
414
- * The media content associated with this object.
415
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#mediaContent
416
- * @type {module:media/MediaContent.MediaContent} */
417
- mediaContent: null,
418
- /**
419
- * @typedef ActiveBoxContent~alignType
420
- * @type {object}
421
- * @property {string} h - Valid values are: `left`, `middle`, `right`
422
- * @property {string} v - Valud values are: `top`, `middle`, `bottom` */
423
- /**
424
- * The horizontal and vertical alignment of the image inside the cell.
425
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#imgAlign
426
- * @type {module:boxes/ActiveBoxContent.AlignType} */
427
- imgAlign: null,
428
- /**
429
- * The horizontal and vertical alignment of the text inside the cell.
430
- * Valid values are: `left`, `middle`, `right`, `top` and `bottom`.
431
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#txtAlign
432
- * @type {module:boxes/ActiveBoxContent.AlignType} */
433
- txtAlign: null,
434
- /**
435
- * Whether to avoid overlapping of image and text inside the cell when both are present.
436
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#avoidOverlapping
437
- * @type {boolean} */
438
- avoidOverlapping: false,
439
- /**
440
- * Numeric identifier used in activities to resolve relationships between cells
441
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#id
442
- * @type {number} */
443
- id: -1,
444
- /**
445
- * Numeric identifier used in activities to resolve relationships between cells
446
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#item
447
- * @type {number} */
448
- item: -1,
449
- //
450
- // Transient properties build and modified at run-time
451
- /**
452
- * The realized image used by this box content.
453
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#img
454
- * @type {external:HTMLImageElement} */
455
- img: null,
456
- /**
457
- * When `img` is an animated GIF file, this field should contain its file name
458
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#animatedGifFile
459
- * @type {string} */
460
- animatedGifFile: null,
461
- /**
462
- * When not null, this content should be treated as an HTML element
463
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#innerHtmlText
464
- * @type {string} */
465
- innerHtmlText: null,
466
- /**
467
- * The {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} associated with this content. Updated at run-time.
468
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#amp
469
- * @type {module:media/ActiveMediaPlayer.ActiveMediaPlayer} */
470
- amp: null,
471
- /**
472
- * The {@link module:bads/MediaBagElement.MediaBagElement} associated with this content, if any. Updated at run-time.
473
- * @name module:boxes/ActiveBoxContent.ActiveBoxContent#mbe
474
- * @type {module:bags/MediaBagElement.MediaBagElement} */
475
- mbe: null,
476
- });
477
-
478
- /**
479
- * An empty ActiveBoxContent
480
- * @type {module:boxes/ActiveBoxContent.ActiveBoxContent}
481
- */
482
- ActiveBoxContent.EMPTY_CONTENT = new ActiveBoxContent();
483
-
484
- export default ActiveBoxContent;
@@ -1,179 +0,0 @@
1
- /**
2
- * File : boxes/ActiveBoxGrid.js
3
- * Created : 19/05/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 Catalan Educational Telematic Network (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 ActiveBoxBag from './ActiveBoxBag.js';
33
- import ActiveBox from './ActiveBox.js';
34
- import { Rectangle, Dimension, Point } from '../AWT.js';
35
- import { settings, roundTo } from '../Utils.js';
36
-
37
- /**
38
- * This class extends {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with constructors that take an argument of type
39
- * {@link module:shapers/Shaper.Shaper Shaper} used to build all its {@link module:boxes/ActiveBox.ActiveBox ActiveBox}components. It also maintains information
40
- * about the number of "rows" and "columns", useful to compute valid (integer) values when
41
- * resizing or moving its components.
42
- * @extends module:boxes/ActiveBoxBag.ActiveBoxBag
43
- */
44
- export class ActiveBoxGrid extends ActiveBoxBag {
45
- /**
46
- * ActiveBxGrid constructor
47
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
48
- * @param {module:AWT.Container} container - The container where this box grid is placed.
49
- * @param {module:boxes/BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
50
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
51
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
52
- * @param {number} setWidth - Total width of the box grid
53
- * @param {number} setHeight - Total height of the box grid
54
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
55
- */
56
- constructor(parent, container, boxBase, px, py, setWidth, setHeight, sh) {
57
- // ActiveBoxGrid derives from ActiveBoxBag
58
- super(parent, container, boxBase);
59
-
60
- this.nCols = sh.nCols;
61
- this.nRows = sh.nRows;
62
-
63
- // This will be the enclosing rectangle of this ActiveBox bag
64
- const r = new Rectangle(
65
- new Point(px, py),
66
- new Dimension(
67
- Math.round(setWidth / this.nCols) * this.nCols,
68
- Math.round(setHeight / this.nRows) * this.nRows));
69
-
70
- // Create all the [ActiveBox](ActiveBox.html) objects based on the
71
- // shapes provided by the [Shaper](Shaper.html)
72
- for (let i = 0; i < sh.nCells; i++) {
73
- const
74
- tmpSh = sh.getShape(i, r),
75
- bx = new ActiveBox(this, container, boxBase, i, tmpSh.getBounds());
76
- if (!sh.rectangularShapes)
77
- bx.setShape(tmpSh);
78
- this.addActiveBox(bx);
79
- }
80
-
81
- // If the Shaper has `remainder` (extra space), set the background box of this
82
- // [BoxBag](BoxBag.html)
83
- if (sh.hasRemainder) {
84
- const
85
- tmpSh = sh.getRemainderShape(r),
86
- bx = new ActiveBox(this, container, boxBase, 0, tmpSh.getBounds());
87
- bx.setShape(tmpSh);
88
- this.setBackgroundBox(bx);
89
- }
90
- }
91
-
92
- /**
93
- * This factory constructor creates a new empty grid with the number of cells indicated by the
94
- * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} `abc`, not filling the cells with any content.
95
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
96
- * @param {module:AWT.Container} container - The container where this box grid is placed.
97
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
98
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
99
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - Used only to get the number of cells and the shaper (when `sh` is `null`)
100
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
101
- * @param {module:boxes/BoxBase.BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
102
- * of this box grid are defined.
103
- * @returns {module:boxes/ActiveBoxGrid.ActiveBoxGrid}
104
- */
105
- static createEmptyGrid(parent, container, px, py, abc, sh, boxBase) {
106
- const result = abc ? new ActiveBoxGrid(parent, container,
107
- boxBase || abc.style,
108
- px, py,
109
- abc.getTotalWidth(), abc.getTotalHeight(),
110
- sh || abc.getShaper()) : null;
111
-
112
- if (result)
113
- result.setBorder(abc.border);
114
-
115
- return result;
116
- }
117
-
118
- /**
119
- * Gets the minimum size of this grid
120
- * @returns {module:AWT.Dimension}
121
- */
122
- getMinimumSize() {
123
- return new Dimension(
124
- settings.MIN_CELL_SIZE * this.nCols,
125
- settings.MIN_CELL_SIZE * this.nRows);
126
- }
127
-
128
- /**
129
- * Gets a scaled size of this grid, rounded to the nearest integer values
130
- * @param {number} scale - The scale factor
131
- * @returns {module:AWT.Dimension}
132
- */
133
- getScaledSize(scale) {
134
- return new Dimension(
135
- roundTo(scale * this.preferredBounds.dim.width, this.nCols),
136
- roundTo(scale * this.preferredBounds.dim.height, this.nRows));
137
- }
138
-
139
- /**
140
- * Returns the logical coordinates of the provided {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
141
- * The units of the result are not pixels, but ordinal numbers (relative positions) of columns
142
- * and rows in the grid.
143
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to process
144
- * @returns {module:AWT.Point}
145
- */
146
- getCoord(bx) {
147
- return new Point(bx.idLoc % this.nCols, Math.floor(bx.idLoc / this.nCols));
148
- }
149
-
150
- /**
151
- * Calculates the logical distance between two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
152
- * Resulting units are not pixels, but ordinal numbers (relative positions) of columns and rows
153
- * in the grid.
154
- * @param {module:boxes/ActiveBox.ActiveBox} src - First box
155
- * @param {module:boxes/ActiveBox.ActiveBox} dest - Second box
156
- * @returns {module:AWT.Point}
157
- */
158
- getCoordDist(src, dest) {
159
- const
160
- ptSrc = this.getCoord(src),
161
- ptDest = this.getCoord(dest);
162
- return new Point(ptDest.x - ptSrc.x, ptDest.y - ptSrc.y);
163
- }
164
- }
165
-
166
- Object.assign(ActiveBoxGrid.prototype, {
167
- /**
168
- * Number of columns of this box grid
169
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nCols
170
- * @type {number} */
171
- nCols: 1,
172
- /**
173
- * Number of rows of this box grid
174
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nRows
175
- * @type {number} */
176
- nRows: 1,
177
- });
178
-
179
- export default ActiveBoxGrid;