jclic 2.1.21 → 2.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/jclic-node.js +1 -1
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/GlobalData.js +1 -1
  8. package/dist/1078.jclic-node.js +0 -282
  9. package/dist/1078.jclic-node.js.map +0 -1
  10. package/dist/1196.jclic-node.js +0 -808
  11. package/dist/1196.jclic-node.js.map +0 -1
  12. package/dist/1253.jclic-node.js +0 -1432
  13. package/dist/1253.jclic-node.js.map +0 -1
  14. package/dist/13.jclic-node.js +0 -103
  15. package/dist/13.jclic-node.js.map +0 -1
  16. package/dist/1567.jclic-node.js +0 -2313
  17. package/dist/1567.jclic-node.js.map +0 -1
  18. package/dist/1588.jclic-node.js +0 -602
  19. package/dist/1588.jclic-node.js.map +0 -1
  20. package/dist/1725.jclic-node.js +0 -836
  21. package/dist/1725.jclic-node.js.map +0 -1
  22. package/dist/1731.jclic-node.js +0 -438
  23. package/dist/1731.jclic-node.js.map +0 -1
  24. package/dist/1842.jclic-node.js +0 -651
  25. package/dist/1842.jclic-node.js.map +0 -1
  26. package/dist/2160.jclic-node.js +0 -1016
  27. package/dist/2160.jclic-node.js.map +0 -1
  28. package/dist/222.jclic-node.js +0 -129
  29. package/dist/222.jclic-node.js.map +0 -1
  30. package/dist/2316.jclic-node.js +0 -949
  31. package/dist/2316.jclic-node.js.map +0 -1
  32. package/dist/2355.jclic-node.js +0 -371
  33. package/dist/2355.jclic-node.js.map +0 -1
  34. package/dist/2366.jclic-node.js +0 -431
  35. package/dist/2366.jclic-node.js.map +0 -1
  36. package/dist/2379.jclic-node.js +0 -202
  37. package/dist/2379.jclic-node.js.map +0 -1
  38. package/dist/2437.jclic-node.js +0 -450
  39. package/dist/2437.jclic-node.js.map +0 -1
  40. package/dist/2531.jclic-node.js +0 -869
  41. package/dist/2531.jclic-node.js.map +0 -1
  42. package/dist/2608.jclic-node.js +0 -160
  43. package/dist/2608.jclic-node.js.map +0 -1
  44. package/dist/2715.jclic-node.js +0 -554
  45. package/dist/2715.jclic-node.js.map +0 -1
  46. package/dist/277.jclic-node.js +0 -22
  47. package/dist/277.jclic-node.js.map +0 -1
  48. package/dist/2921.jclic-node.js +0 -660
  49. package/dist/2921.jclic-node.js.map +0 -1
  50. package/dist/2952.jclic-node.js +0 -101
  51. package/dist/2952.jclic-node.js.map +0 -1
  52. package/dist/3018.jclic-node.js +0 -421
  53. package/dist/3018.jclic-node.js.map +0 -1
  54. package/dist/3019.jclic-node.js +0 -682
  55. package/dist/3019.jclic-node.js.map +0 -1
  56. package/dist/3231.jclic-node.js +0 -274
  57. package/dist/3231.jclic-node.js.map +0 -1
  58. package/dist/331.jclic-node.js +0 -115
  59. package/dist/331.jclic-node.js.map +0 -1
  60. package/dist/3391.jclic-node.js +0 -276
  61. package/dist/3391.jclic-node.js.map +0 -1
  62. package/dist/3502.jclic-node.js +0 -671
  63. package/dist/3502.jclic-node.js.map +0 -1
  64. package/dist/3653.jclic-node.js +0 -982
  65. package/dist/3653.jclic-node.js.map +0 -1
  66. package/dist/371.jclic.min.js +0 -2
  67. package/dist/371.jclic.min.js.map +0 -1
  68. package/dist/3856.jclic-node.js +0 -575
  69. package/dist/3856.jclic-node.js.map +0 -1
  70. package/dist/4112.jclic-node.js +0 -659
  71. package/dist/4112.jclic-node.js.map +0 -1
  72. package/dist/4123.jclic-node.js +0 -910
  73. package/dist/4123.jclic-node.js.map +0 -1
  74. package/dist/427.jclic-node.js +0 -894
  75. package/dist/427.jclic-node.js.map +0 -1
  76. package/dist/4483.jclic-node.js +0 -327
  77. package/dist/4483.jclic-node.js.map +0 -1
  78. package/dist/4548.jclic-node.js +0 -1078
  79. package/dist/4548.jclic-node.js.map +0 -1
  80. package/dist/466.jclic-node.js +0 -99
  81. package/dist/466.jclic-node.js.map +0 -1
  82. package/dist/485.jclic-node.js +0 -783
  83. package/dist/485.jclic-node.js.map +0 -1
  84. package/dist/4921.jclic-node.js +0 -500
  85. package/dist/4921.jclic-node.js.map +0 -1
  86. package/dist/5091.jclic-node.js +0 -239
  87. package/dist/5091.jclic-node.js.map +0 -1
  88. package/dist/520.jclic-node.js +0 -550
  89. package/dist/520.jclic-node.js.map +0 -1
  90. package/dist/5312.jclic-node.js +0 -1126
  91. package/dist/5312.jclic-node.js.map +0 -1
  92. package/dist/5338.jclic-node.js +0 -212
  93. package/dist/5338.jclic-node.js.map +0 -1
  94. package/dist/5344.jclic-node.js +0 -229
  95. package/dist/5344.jclic-node.js.map +0 -1
  96. package/dist/5550.jclic-node.js +0 -238
  97. package/dist/5550.jclic-node.js.map +0 -1
  98. package/dist/5626.jclic-node.js +0 -614
  99. package/dist/5626.jclic-node.js.map +0 -1
  100. package/dist/5977.jclic-node.js +0 -1081
  101. package/dist/5977.jclic-node.js.map +0 -1
  102. package/dist/6148.jclic-node.js +0 -345
  103. package/dist/6148.jclic-node.js.map +0 -1
  104. package/dist/6176.jclic-node.js +0 -481
  105. package/dist/6176.jclic-node.js.map +0 -1
  106. package/dist/6221.jclic-node.js +0 -1072
  107. package/dist/6221.jclic-node.js.map +0 -1
  108. package/dist/6238.jclic-node.js +0 -718
  109. package/dist/6238.jclic-node.js.map +0 -1
  110. package/dist/6454.jclic-node.js +0 -1413
  111. package/dist/6454.jclic-node.js.map +0 -1
  112. package/dist/6565.jclic-node.js +0 -294
  113. package/dist/6565.jclic-node.js.map +0 -1
  114. package/dist/6579.jclic-node.js +0 -719
  115. package/dist/6579.jclic-node.js.map +0 -1
  116. package/dist/6715.jclic-node.js +0 -148
  117. package/dist/6715.jclic-node.js.map +0 -1
  118. package/dist/6777.jclic-node.js +0 -171
  119. package/dist/6777.jclic-node.js.map +0 -1
  120. package/dist/6782.jclic-node.js +0 -1611
  121. package/dist/6782.jclic-node.js.map +0 -1
  122. package/dist/6847.jclic-node.js +0 -601
  123. package/dist/6847.jclic-node.js.map +0 -1
  124. package/dist/6856.jclic-node.js +0 -252
  125. package/dist/6856.jclic-node.js.map +0 -1
  126. package/dist/696.jclic-node.js +0 -1821
  127. package/dist/696.jclic-node.js.map +0 -1
  128. package/dist/698.jclic-node.js +0 -583
  129. package/dist/698.jclic-node.js.map +0 -1
  130. package/dist/704.jclic-node.js +0 -80
  131. package/dist/704.jclic-node.js.map +0 -1
  132. package/dist/7046.jclic-node.js +0 -735
  133. package/dist/7046.jclic-node.js.map +0 -1
  134. package/dist/7220.jclic-node.js +0 -156
  135. package/dist/7220.jclic-node.js.map +0 -1
  136. package/dist/7257.jclic-node.js +0 -931
  137. package/dist/7257.jclic-node.js.map +0 -1
  138. package/dist/743.jclic-node.js +0 -583
  139. package/dist/743.jclic-node.js.map +0 -1
  140. package/dist/757.jclic-node.js +0 -1072
  141. package/dist/757.jclic-node.js.map +0 -1
  142. package/dist/7781.jclic-node.js +0 -202
  143. package/dist/7781.jclic-node.js.map +0 -1
  144. package/dist/7912.jclic-node.js +0 -2103
  145. package/dist/7912.jclic-node.js.map +0 -1
  146. package/dist/827.jclic-node.js +0 -708
  147. package/dist/827.jclic-node.js.map +0 -1
  148. package/dist/8276.jclic-node.js +0 -409
  149. package/dist/8276.jclic-node.js.map +0 -1
  150. package/dist/8322.jclic-node.js +0 -498
  151. package/dist/8322.jclic-node.js.map +0 -1
  152. package/dist/8641.jclic-node.js +0 -360
  153. package/dist/8641.jclic-node.js.map +0 -1
  154. package/dist/8837.jclic-node.js +0 -651
  155. package/dist/8837.jclic-node.js.map +0 -1
  156. package/dist/8895.jclic-node.js +0 -151
  157. package/dist/8895.jclic-node.js.map +0 -1
  158. package/dist/9072.jclic-node.js +0 -1285
  159. package/dist/9072.jclic-node.js.map +0 -1
  160. package/dist/9078.jclic-node.js +0 -935
  161. package/dist/9078.jclic-node.js.map +0 -1
  162. package/dist/9103.jclic-node.js +0 -718
  163. package/dist/9103.jclic-node.js.map +0 -1
  164. package/dist/9359.jclic-node.js +0 -145
  165. package/dist/9359.jclic-node.js.map +0 -1
  166. package/dist/9409.jclic-node.js +0 -921
  167. package/dist/9409.jclic-node.js.map +0 -1
  168. package/dist/9513.jclic-node.js +0 -720
  169. package/dist/9513.jclic-node.js.map +0 -1
  170. package/dist/9704.jclic-node.js +0 -81
  171. package/dist/9704.jclic-node.js.map +0 -1
  172. package/dist/9950.jclic-node.js +0 -827
  173. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,651 +0,0 @@
1
- "use strict";
2
- exports.id = 1842;
3
- exports.ids = [1842,3018];
4
- exports.modules = {
5
-
6
- /***/ 3018:
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 BoxBase */
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 _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
16
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
17
- /**
18
- * File : boxes/BoxBase.js
19
- * Created : 12/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 Catalan Educational Telematic Network (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
- const defaultValues = _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.BoxBase;
53
-
54
- /**
55
- * This class contains all the main visual attributes needed to draw {@link module:boxes/AbstractBox.AbstractBox AbstractBox} objects:
56
- * background and foreground colors, gradients, colors for special states (inactive, alternative,
57
- * disabled...), margins, fonts, border strokes, etc.
58
- *
59
- * Objects derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox} can have inheritance: boxes that act as "containers"
60
- * of other boxes (like {@link module:boxes/BoxBag.BoxBag BoxBag}). Most of the attributes of `BoxBase` can be `null`,
61
- * meaning that the value of the ancestor -or the default value if the box has no ancestors- must
62
- * be used.
63
- */
64
- class BoxBase {
65
- /**
66
- * BoxBase constructor
67
- * @param {module:boxes/BoxBase.BoxBase} [parent] - Another BoxBase object used to determine the value of properties not
68
- * locally set.
69
- */
70
- constructor(parent) {
71
- this.parent = parent || null;
72
- }
73
-
74
- /**
75
- * Loads the BoxBase settings from a specific JQuery XML element
76
- * @param {external:jQuery} $xml - The XML element to parse
77
- */
78
- setProperties($xml) {
79
- //
80
- // Read attributes
81
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, val) => {
82
- switch (name) {
83
- case 'shadow':
84
- case 'transparent':
85
- this[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val, false);
86
- break;
87
- case 'margin':
88
- this[name] = Number(val);
89
- break;
90
- case 'borderStroke':
91
- this.borderStroke = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Stroke */ .tc(Number(val));
92
- break;
93
- case 'markerStroke':
94
- this.markerStroke = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Stroke */ .tc(Number(val));
95
- break;
96
- }
97
- });
98
- //
99
- // Read inner elements
100
- $xml.children().each((_n, child) => {
101
- const $node = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
102
- switch (child.nodeName) {
103
- case 'font':
104
- this.font = (new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Font */ .KQ()).setProperties($node);
105
- break;
106
-
107
- case 'gradient':
108
- this.bgGradient = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Gradient */ .Hf().setProperties($node);
109
- break;
110
-
111
- case 'color':
112
- this.textColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('foreground'), this.textColor);
113
- this.backColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('background'), this.backColor);
114
- this.shadowColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('shadow'), this.shadowColor);
115
- this.inactiveColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('inactive'), this.inactiveColor);
116
- this.alternativeColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('alternative'), this.alternativeColor);
117
- this.borderColor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)($node.attr('border'), this.borderColor);
118
- break;
119
- }
120
- });
121
- return this;
122
- }
123
-
124
- /**
125
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
126
- * parent references, constants and also attributes retaining the default value.
127
- * The resulting object is commonly usued to serialize elements in JSON format.
128
- * @returns {object} - The resulting object, with minimal attrributes
129
- */
130
- getAttributes() {
131
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, [
132
- 'shadow', 'transparent', 'margin',
133
- 'borderStroke', 'markerStroke', // AWT.Stroke
134
- 'font', // AWT.Font
135
- 'bgGradient', // AWT.Gradient
136
- `textColor|${BoxBase.prototype.textColor}`,
137
- `backColor|${BoxBase.prototype.backColor}`,
138
- `shadowColor|${BoxBase.prototype.shadowColor}`,
139
- `inactiveColor|${BoxBase.prototype.inactiveColor}`,
140
- `alternativeColor|${BoxBase.prototype.alternativeColor}`,
141
- `borderColor|${BoxBase.prototype.borderColor}`,
142
- ]);
143
- }
144
-
145
- /**
146
- * Reads the properties of this BoxBase from a data object
147
- * @param {object} data - The data object to be parsed
148
- * @returns {module:boxes/BoxBase.BoxBase}
149
- */
150
- setAttributes(data) {
151
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(this, data, [
152
- 'shadow', 'transparent', 'margin',
153
- { key: 'borderStroke', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Stroke */ .tc },
154
- { key: 'markerStroke', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Stroke */ .tc },
155
- { key: 'font', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Font */ .KQ },
156
- { key: 'bgGradient', fn: _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Gradient */ .Hf },
157
- 'textColor',
158
- 'backColor',
159
- 'shadowColor',
160
- 'inactiveColor',
161
- 'alternativeColor',
162
- 'borderColor',
163
- ]);
164
- }
165
-
166
- /**
167
- * Gets the value of the specified property, scanning down to parents and prototype if not defined.
168
- * @param {string} property - The property to retrieve
169
- * @returns {any} - The object or value associated to this property
170
- */
171
- get(property) {
172
- if (this.hasOwnProperty(property) || this.parent === null)
173
- return this[property];
174
- else
175
- return this.parent.get(property);
176
- }
177
-
178
- /**
179
- * Sets the value of a specific property.
180
- * @param {string} property - The property name.
181
- * @param {any} value - Depends on the type of property
182
- */
183
- set(property, value) {
184
- this[property] = value;
185
- return this;
186
- }
187
-
188
- /**
189
- * Gets the value of the specified property, scanning down to parents if not defined, and returning
190
- * always an own property (not from prototype)
191
- * @param {string} property - The property to retrieve
192
- * @returns {any} - The object or value associated to this property
193
- */
194
- getOwn(property) {
195
- if (this.hasOwnProperty(property))
196
- return this[property];
197
- else if (this.parent !== null)
198
- return this.parent.getOwn(property);
199
- else {
200
- if (typeof this[property] === 'object')
201
- this[property] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .cloneObject */ .h2)(BoxBase.prototype[property]);
202
- else
203
- this[property] = BoxBase.prototype[property];
204
- }
205
- return this[property];
206
- }
207
-
208
- /**
209
- * Gets the properties defined in this BoxBase as a collection of CSS attributes
210
- * @param {object} [css] - An optional set of initial CSS properties
211
- * @param {boolean} [inactive=false] - When `true`, get CSS attributes for an inactive cell
212
- * @param {boolean} [inverse=false] - When `true`, get CSS attributes for an inverse cell
213
- * @param {boolean} [alternative=false] - When `true`, get CSS attributes for an alternative cell
214
- * @returns {object}
215
- */
216
- getCSS(css, inactive = false, inverse = false, alternative = false) {
217
- // (css will be created by [AWT.Font.toCss](AWT.html) if null or undefined)
218
- const font = this.get('font');
219
- css = font.toCss(css);
220
-
221
- css['color'] = inverse ? this.get('backColor')
222
- : alternative ? this.get('alternativeColor')
223
- : this.get('textColor');
224
-
225
- const transparent = this.get('transparent');
226
- css['background-color'] = transparent ? 'transparent'
227
- : inactive ? this.get('inactiveColor')
228
- : inverse ? this.get('textColor') : this.get('backColor');
229
-
230
- const bgGradient = this.get('bgGradient');
231
- if (bgGradient && !transparent)
232
- css['background-image'] = bgGradient.getCss();
233
-
234
- if (this.shadow === 1) {
235
- const delta = Math.max(1, Math.round(font.size / 10));
236
- const color = this.get('shadowColor');
237
- css['text-shadow'] = `${delta}px ${delta}px 3px ${color}`;
238
- }
239
- return css;
240
- }
241
-
242
- /**
243
- * This utility method computes the width and height of text lines rendered on an HTML
244
- * __canvas__ element, reducing the font size of the BoxBase as needed when they exceed the maximum
245
- * width and/or height.
246
- * @param {external:CanvasRenderingContext2D} ctx - The canvas rendering context used to draw the text.
247
- * @param {string} text - The text to drawn.
248
- * @param {number} maxWidth - Maximum width
249
- * @param {number} maxHeight - Maximum height
250
- * @returns {object[]} - An array of objects representing lines of text. Each object has a `text`
251
- * member with the text displayed in the line, and a `size` member with the line {@link module:AWT.Dimension}
252
- */
253
- prepareText(ctx, text, maxWidth, maxHeight) {
254
- const
255
- result = [],
256
- font = this.get('font'),
257
- height = font.getHeight();
258
- let totalHeight = 0;
259
-
260
- // divide the text in lines
261
- const lines = text.trim().split('\n');
262
- ctx.font = font.cssFont();
263
- for (let l = 0; l < lines.length; l++) {
264
- let line = lines[l].trim();
265
- let width = ctx.measureText(line).width;
266
- if (width > maxWidth) {
267
- // retain the last string offset that was inside maxWidth
268
- let
269
- lastOK = 0,
270
- lastOKWidth = 0;
271
- for (let p = 0; p < line.length; p++) {
272
- // Find next separator
273
- if ((0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isSeparator */ .k$)(line[p])) {
274
- const w = ctx.measureText(line.substring(0, p).trim()).width;
275
- if (w > maxWidth)
276
- break;
277
- lastOK = p;
278
- lastOKWidth = w;
279
- }
280
- }
281
- if (lastOK > 0) {
282
- // Add a new line with the tail of the line
283
- lines.splice(l + 1, 0, line.substring(lastOK + 1).trim());
284
- // Adjust the current line
285
- line = lines[l] = line.substring(0, lastOK).trim();
286
- width = lastOKWidth;
287
- }
288
- else {
289
- // No solution found. Try resizing down the font.
290
- if (font.size > defaultValues.MIN_FONT_SIZE) {
291
- this.getOwn('font').zoom(-1);
292
- return this.prepareText(ctx, text, maxWidth, maxHeight);
293
- }
294
- }
295
- }
296
-
297
- // Add the line and the calculated dimension to `result`
298
- result.push({
299
- text: line,
300
- size: new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(width, height)
301
- });
302
-
303
- totalHeight += height;
304
-
305
- if (totalHeight > maxHeight && font.size > defaultValues.MIN_FONT_SIZE) {
306
- // Max height exceeded. Try resizing down the font
307
- this.getOwn('font').zoom(-1);
308
- return this.prepareText(ctx, text, maxWidth, maxHeight);
309
- }
310
- }
311
- return result;
312
- }
313
- }
314
-
315
- Object.assign(BoxBase.prototype, {
316
- /**
317
- * The parent BoxBase object
318
- * @name module:boxes/BoxBase.BoxBase#parent
319
- * @type {module:boxes/BoxBase.BoxBase} */
320
- parent: null,
321
- /**
322
- * Default values
323
- * @name module:boxes/BoxBase.BoxBase#defaultValues
324
- * @type {object} */
325
- default: defaultValues,
326
- /**
327
- * Font size can be dynamically reduced to fit the available space if any element using this
328
- * `BoxBase` requests it. When this happen, this field contains the real font currently used
329
- * to draw text.
330
- * @name module:boxes/BoxBase.BoxBase#font
331
- * @type {module:AWT.Font} */
332
- font: new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Font */ .KQ(),
333
- /**
334
- * The current font size of this BoxBase. Can be dynamically adjusted when drawing.
335
- * @name module:boxes/BoxBase.BoxBase#dynFontSize
336
- * @type {number} */
337
- dynFontSize: 0,
338
- /**
339
- * Counts the number of times the `dynFontSize` has been reset. This is useful to avoid excessive
340
- * recursive loops searching the optimal font size.
341
- * @name module:boxes/BoxBase.BoxBase#resetFontCounter
342
- * @type {number} */
343
- resetFontCounter: 0,
344
- /**
345
- * The background color
346
- * @name module:boxes/BoxBase.BoxBase#backColor
347
- * @type {string} */
348
- backColor: defaultValues.BACK_COLOR,
349
- /**
350
- * The background gradient. Default is `null`.
351
- * @name module:boxes/BoxBase.BoxBase#bgGradient
352
- * @type {module:AWT.Gradient} */
353
- bgGradient: null,
354
- /**
355
- * The color used to write text.
356
- * @name module:boxes/BoxBase.BoxBase#textColor
357
- * @type {string} */
358
- textColor: defaultValues.TEXT_COLOR,
359
- /**
360
- * The color used to draw a shadow below regular text.
361
- * @name module:boxes/BoxBase.BoxBase#shadowColor
362
- * @type {string} */
363
- shadowColor: defaultValues.SHADOW_COLOR,
364
- /**
365
- * The color of the border.
366
- * @name module:boxes/BoxBase.BoxBase#borderColor
367
- * @type {string} */
368
- borderColor: defaultValues.BORDER_COLOR,
369
- /**
370
- * The color used to draw text when a cell is in `inactive` state.
371
- * @name module:boxes/BoxBase.BoxBase#inactiveColor
372
- * @type {string} */
373
- inactiveColor: defaultValues.INACTIVE_COLOR,
374
- /**
375
- * The color used to draw text when a cell is in `alternative` state.
376
- * @name module:boxes/BoxBase.BoxBase#alternativeColor
377
- * @type {string} */
378
- alternativeColor: defaultValues.ALTERNATIVE_COLOR,
379
- /**
380
- * Whether the text should have a shadow or not
381
- * @name module:boxes/BoxBase.BoxBase#shadow
382
- * @type {boolean} */
383
- shadow: false,
384
- /**
385
- * Whether the cell's background (and its hosted component, if any) should be transparent
386
- * @name module:boxes/BoxBase.BoxBase#transparent
387
- * @type {boolean} */
388
- transparent: false,
389
- /**
390
- * Wheter the cell's background should be painted or not. This property has no effect on
391
- * hosted components.
392
- * @name module:boxes/BoxBase.BoxBase#dontFill
393
- * @type {boolean} */
394
- dontFill: false,
395
- /**
396
- * The margin to respect between text elements and the limits of the cell or other elements.
397
- * @name module:boxes/BoxBase.BoxBase#textMargin
398
- * @type {number} */
399
- textMargin: defaultValues.AC_MARGIN,
400
- /**
401
- * The stroke used to draw the border.
402
- * @name module:boxes/BoxBase.BoxBase#borderStroke
403
- * @type {module:AWT.Stroke} */
404
- borderStroke: new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Stroke */ .tc(defaultValues.BORDER_STROKE_WIDTH),
405
- /**
406
- * The stroke used to draw a border around marked cells.
407
- * @name module:boxes/BoxBase.BoxBase#markerStroke
408
- * @type {module:AWT.Stroke} */
409
- markerStroke: new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Stroke */ .tc(defaultValues.MARKER_STROKE_WIDTH),
410
- });
411
-
412
- BoxBase.DEFAULT_BOX_BASE = new BoxBase();
413
-
414
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxBase);
415
-
416
-
417
- /***/ }),
418
-
419
- /***/ 1842:
420
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
421
-
422
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
423
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
424
- /* harmony export */ });
425
- /* unused harmony export TextGridContent */
426
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
427
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
428
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
429
- /* harmony import */ var _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3018);
430
- /**
431
- * File : boxes/TextGridContent.js
432
- * Created : 14/04/2015
433
- * By : Francesc Busquets <francesc@gmail.com>
434
- *
435
- * JClic.js
436
- * An HTML5 player of JClic activities
437
- * https://projectestac.github.io/jclic.js
438
- *
439
- * @source https://github.com/projectestac/jclic.js
440
- *
441
- * @license EUPL-1.2
442
- * @licstart
443
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
444
- *
445
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
446
- * the European Commission- subsequent versions of the EUPL (the "Licence");
447
- * You may not use this work except in compliance with the Licence.
448
- *
449
- * You may obtain a copy of the Licence at:
450
- * https://joinup.ec.europa.eu/software/page/eupl
451
- *
452
- * Unless required by applicable law or agreed to in writing, software
453
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
454
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
455
- * Licence for the specific language governing permissions and limitations
456
- * under the Licence.
457
- * @licend
458
- * @module
459
- */
460
-
461
-
462
-
463
-
464
-
465
- /**
466
- * This class encapsulates the content of {@link module:boxes/TextGrid.TextGrid TextGrid} objects.
467
- *
468
- * It implements methods to set and retrieve individual characters on the grid, and parsing of
469
- * XML objects. It also contains information about the optimal size and other graphic properties
470
- * (fonts, colors, etc.) of the grid.
471
- */
472
- class TextGridContent {
473
- /**
474
- * TextGridContent constructor
475
- */
476
- constructor() {
477
- this.style = new _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__["default"](null);
478
- this.text = [];
479
- }
480
-
481
- /**
482
- * Loads the object settings from a specific JQuery XML element
483
- * @param {external:jQuery} $xml
484
- */
485
- setProperties($xml) {
486
- // Read attributes
487
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, val) => {
488
- switch (name) {
489
- case 'rows':
490
- // WARNING: Due to a bug in JClic, the meaning of "rows" and "columns" must be
491
- // interchanged:
492
- this.ncw = Number(val);
493
- break;
494
- case 'columns':
495
- this.nch = Number(val);
496
- break;
497
- case 'cellWidth':
498
- this.w = Number(val);
499
- break;
500
- case 'cellHeight':
501
- this.h = Number(val);
502
- break;
503
- case 'border':
504
- this.border = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val);
505
- break;
506
- case 'wild':
507
- case 'randomChars':
508
- this[name] = val;
509
- break;
510
- }
511
- });
512
-
513
- // Read inner elements
514
- $xml.children('style:first').each((_n, child) => {
515
- this.style = new _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__["default"]().setProperties(jquery__WEBPACK_IMPORTED_MODULE_0___default()(child));
516
- });
517
-
518
- $xml.find('text:first > row').each((_n, el) => this.text.push(el.textContent));
519
-
520
- for (let i = this.text.length; i < this.nch; i++)
521
- this.text[i] = '';
522
-
523
- return this;
524
- }
525
-
526
- /**
527
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
528
- * parent references, constants and also attributes retaining the default value.
529
- * The resulting object is commonly usued to serialize elements in JSON format.
530
- * @returns {object} - The resulting object, with minimal attrributes
531
- */
532
- getAttributes() {
533
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, [
534
- 'ncw', 'nch',
535
- 'w', 'h',
536
- 'text',
537
- 'style', // BoxBase
538
- 'border',
539
- 'wild|*',
540
- `randomChars|${_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.RANDOM_CHARS}`,
541
- ]);
542
- }
543
-
544
- /**
545
- * Reads the properties of this TextGridContent from a data object
546
- * @param {object|string} data - The data object to be parsed, or just the text content
547
- * @returns {module:boxes/TextGridContent.TextGridContent}
548
- */
549
- setAttributes(data) {
550
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(this, data, [
551
- 'ncw', 'nch',
552
- 'w', 'h',
553
- 'text',
554
- { key: 'style', fn: _BoxBase_js__WEBPACK_IMPORTED_MODULE_2__["default"] },
555
- 'border',
556
- 'wild',
557
- `randomChars`,
558
- ]);
559
- }
560
-
561
- /**
562
- * Counts the number of wildcard characters present in this TextGrid
563
- * @returns {number}
564
- */
565
- countWildChars() {
566
- let result = 0;
567
- if (this.text)
568
- for (let y = 0; y < this.nch; y++)
569
- for (let x = 0; x < this.ncw; x++)
570
- if (this.text[y].charAt(x) === this.wild)
571
- result++;
572
- return result;
573
- }
574
-
575
- /**
576
- * Counts the total number of characters, including wildcard characters.
577
- * @returns {number}
578
- */
579
- getNumChars() {
580
- return this.ncw * this.nch;
581
- }
582
-
583
- /**
584
- * Sets the specified character as a content of the cell located at specific coordinates
585
- * @param {number} x - The X coordinate of the cell
586
- * @param {number} y - The X coordinate of the cell
587
- * @param {string} ch - The character to be placed on the specified cell
588
- */
589
- setCharAt(x, y, ch) {
590
- if (x >= 0 && x < this.ncw && y >= 0 && y < this.nch)
591
- this.text[y] = this.text[y].substring(0, x) + ch + this.text[y].substring(x + 1);
592
- }
593
- }
594
-
595
- Object.assign(TextGridContent.prototype, {
596
- /**
597
- * Grid columns
598
- * @name module:boxes/TextGridContent.TextGridContent#ncw
599
- * @type {number} */
600
- ncw: 1,
601
- /**
602
- * Grid rows
603
- * @name module:boxes/TextGridContent.TextGridContent#nch
604
- * @type {number} */
605
- nch: 1,
606
- /**
607
- * Width of cells
608
- * @name module:boxes/TextGridContent.TextGridContent#w
609
- * @type {number} */
610
- w: 20,
611
- /**
612
- * Height of cells
613
- * @name module:boxes/TextGridContent.TextGridContent#h
614
- * @type {number} */
615
- h: 20,
616
- /**
617
- * Whether the cells must be surrounded by a border or not
618
- * @name module:boxes/TextGridContent.TextGridContent#border
619
- * @type {boolean} */
620
- border: false,
621
- /**
622
- * The {@link module:boxes/BoxBase.BoxBase BoxBase} object with visual settings of the text grid
623
- * @name module:boxes/TextGridContent.TextGridContent#style
624
- * @type {module:boxes/BoxBase.BoxBase} */
625
- style: null,
626
- /**
627
- * An array of String objects textning the chars of cells. One string per row, one character of
628
- * this string per cell.
629
- * @name module:boxes/TextGridContent.TextGridContent#text
630
- * @type {string[]} */
631
- text: null,
632
- /**
633
- * The letter used as wildcardtext
634
- * @name module:boxes/TextGridContent.TextGridContent#wild
635
- * @type {string} */
636
- wild: '*',
637
- /**
638
- * A String with the chars to take as source when randomly filling empty cells
639
- * @name module:boxes/TextGridContent.TextGridContent#randomChars
640
- * @type {string} */
641
- randomChars: _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.RANDOM_CHARS,
642
- });
643
-
644
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextGridContent);
645
-
646
-
647
- /***/ })
648
-
649
- };
650
- ;
651
- //# sourceMappingURL=1842.jclic-node.js.map