jclic 2.1.21 → 2.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/jclic-node.js +9 -8
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +4 -4
  7. package/src/GlobalData.js +1 -1
  8. package/src/JClicPlayer.js +2 -2
  9. package/src/bags/MediaBag.js +6 -5
  10. package/dist/1078.jclic-node.js +0 -282
  11. package/dist/1078.jclic-node.js.map +0 -1
  12. package/dist/1196.jclic-node.js +0 -808
  13. package/dist/1196.jclic-node.js.map +0 -1
  14. package/dist/1253.jclic-node.js +0 -1432
  15. package/dist/1253.jclic-node.js.map +0 -1
  16. package/dist/13.jclic-node.js +0 -103
  17. package/dist/13.jclic-node.js.map +0 -1
  18. package/dist/1567.jclic-node.js +0 -2313
  19. package/dist/1567.jclic-node.js.map +0 -1
  20. package/dist/1588.jclic-node.js +0 -602
  21. package/dist/1588.jclic-node.js.map +0 -1
  22. package/dist/1725.jclic-node.js +0 -836
  23. package/dist/1725.jclic-node.js.map +0 -1
  24. package/dist/1731.jclic-node.js +0 -438
  25. package/dist/1731.jclic-node.js.map +0 -1
  26. package/dist/1842.jclic-node.js +0 -651
  27. package/dist/1842.jclic-node.js.map +0 -1
  28. package/dist/2160.jclic-node.js +0 -1016
  29. package/dist/2160.jclic-node.js.map +0 -1
  30. package/dist/222.jclic-node.js +0 -129
  31. package/dist/222.jclic-node.js.map +0 -1
  32. package/dist/2316.jclic-node.js +0 -949
  33. package/dist/2316.jclic-node.js.map +0 -1
  34. package/dist/2355.jclic-node.js +0 -371
  35. package/dist/2355.jclic-node.js.map +0 -1
  36. package/dist/2366.jclic-node.js +0 -431
  37. package/dist/2366.jclic-node.js.map +0 -1
  38. package/dist/2379.jclic-node.js +0 -202
  39. package/dist/2379.jclic-node.js.map +0 -1
  40. package/dist/2437.jclic-node.js +0 -450
  41. package/dist/2437.jclic-node.js.map +0 -1
  42. package/dist/2531.jclic-node.js +0 -869
  43. package/dist/2531.jclic-node.js.map +0 -1
  44. package/dist/2608.jclic-node.js +0 -160
  45. package/dist/2608.jclic-node.js.map +0 -1
  46. package/dist/2715.jclic-node.js +0 -554
  47. package/dist/2715.jclic-node.js.map +0 -1
  48. package/dist/277.jclic-node.js +0 -22
  49. package/dist/277.jclic-node.js.map +0 -1
  50. package/dist/2921.jclic-node.js +0 -660
  51. package/dist/2921.jclic-node.js.map +0 -1
  52. package/dist/2952.jclic-node.js +0 -101
  53. package/dist/2952.jclic-node.js.map +0 -1
  54. package/dist/3018.jclic-node.js +0 -421
  55. package/dist/3018.jclic-node.js.map +0 -1
  56. package/dist/3019.jclic-node.js +0 -682
  57. package/dist/3019.jclic-node.js.map +0 -1
  58. package/dist/3231.jclic-node.js +0 -274
  59. package/dist/3231.jclic-node.js.map +0 -1
  60. package/dist/331.jclic-node.js +0 -115
  61. package/dist/331.jclic-node.js.map +0 -1
  62. package/dist/3391.jclic-node.js +0 -276
  63. package/dist/3391.jclic-node.js.map +0 -1
  64. package/dist/3502.jclic-node.js +0 -671
  65. package/dist/3502.jclic-node.js.map +0 -1
  66. package/dist/3653.jclic-node.js +0 -982
  67. package/dist/3653.jclic-node.js.map +0 -1
  68. package/dist/371.jclic.min.js +0 -2
  69. package/dist/371.jclic.min.js.map +0 -1
  70. package/dist/3856.jclic-node.js +0 -575
  71. package/dist/3856.jclic-node.js.map +0 -1
  72. package/dist/4112.jclic-node.js +0 -659
  73. package/dist/4112.jclic-node.js.map +0 -1
  74. package/dist/4123.jclic-node.js +0 -910
  75. package/dist/4123.jclic-node.js.map +0 -1
  76. package/dist/427.jclic-node.js +0 -894
  77. package/dist/427.jclic-node.js.map +0 -1
  78. package/dist/4483.jclic-node.js +0 -327
  79. package/dist/4483.jclic-node.js.map +0 -1
  80. package/dist/4548.jclic-node.js +0 -1078
  81. package/dist/4548.jclic-node.js.map +0 -1
  82. package/dist/466.jclic-node.js +0 -99
  83. package/dist/466.jclic-node.js.map +0 -1
  84. package/dist/485.jclic-node.js +0 -783
  85. package/dist/485.jclic-node.js.map +0 -1
  86. package/dist/4921.jclic-node.js +0 -500
  87. package/dist/4921.jclic-node.js.map +0 -1
  88. package/dist/5091.jclic-node.js +0 -239
  89. package/dist/5091.jclic-node.js.map +0 -1
  90. package/dist/520.jclic-node.js +0 -550
  91. package/dist/520.jclic-node.js.map +0 -1
  92. package/dist/5312.jclic-node.js +0 -1126
  93. package/dist/5312.jclic-node.js.map +0 -1
  94. package/dist/5338.jclic-node.js +0 -212
  95. package/dist/5338.jclic-node.js.map +0 -1
  96. package/dist/5344.jclic-node.js +0 -229
  97. package/dist/5344.jclic-node.js.map +0 -1
  98. package/dist/5550.jclic-node.js +0 -238
  99. package/dist/5550.jclic-node.js.map +0 -1
  100. package/dist/5626.jclic-node.js +0 -614
  101. package/dist/5626.jclic-node.js.map +0 -1
  102. package/dist/5977.jclic-node.js +0 -1081
  103. package/dist/5977.jclic-node.js.map +0 -1
  104. package/dist/6148.jclic-node.js +0 -345
  105. package/dist/6148.jclic-node.js.map +0 -1
  106. package/dist/6176.jclic-node.js +0 -481
  107. package/dist/6176.jclic-node.js.map +0 -1
  108. package/dist/6221.jclic-node.js +0 -1072
  109. package/dist/6221.jclic-node.js.map +0 -1
  110. package/dist/6238.jclic-node.js +0 -718
  111. package/dist/6238.jclic-node.js.map +0 -1
  112. package/dist/6454.jclic-node.js +0 -1413
  113. package/dist/6454.jclic-node.js.map +0 -1
  114. package/dist/6565.jclic-node.js +0 -294
  115. package/dist/6565.jclic-node.js.map +0 -1
  116. package/dist/6579.jclic-node.js +0 -719
  117. package/dist/6579.jclic-node.js.map +0 -1
  118. package/dist/6715.jclic-node.js +0 -148
  119. package/dist/6715.jclic-node.js.map +0 -1
  120. package/dist/6777.jclic-node.js +0 -171
  121. package/dist/6777.jclic-node.js.map +0 -1
  122. package/dist/6782.jclic-node.js +0 -1611
  123. package/dist/6782.jclic-node.js.map +0 -1
  124. package/dist/6847.jclic-node.js +0 -601
  125. package/dist/6847.jclic-node.js.map +0 -1
  126. package/dist/6856.jclic-node.js +0 -252
  127. package/dist/6856.jclic-node.js.map +0 -1
  128. package/dist/696.jclic-node.js +0 -1821
  129. package/dist/696.jclic-node.js.map +0 -1
  130. package/dist/698.jclic-node.js +0 -583
  131. package/dist/698.jclic-node.js.map +0 -1
  132. package/dist/704.jclic-node.js +0 -80
  133. package/dist/704.jclic-node.js.map +0 -1
  134. package/dist/7046.jclic-node.js +0 -735
  135. package/dist/7046.jclic-node.js.map +0 -1
  136. package/dist/7220.jclic-node.js +0 -156
  137. package/dist/7220.jclic-node.js.map +0 -1
  138. package/dist/7257.jclic-node.js +0 -931
  139. package/dist/7257.jclic-node.js.map +0 -1
  140. package/dist/743.jclic-node.js +0 -583
  141. package/dist/743.jclic-node.js.map +0 -1
  142. package/dist/757.jclic-node.js +0 -1072
  143. package/dist/757.jclic-node.js.map +0 -1
  144. package/dist/7781.jclic-node.js +0 -202
  145. package/dist/7781.jclic-node.js.map +0 -1
  146. package/dist/7912.jclic-node.js +0 -2103
  147. package/dist/7912.jclic-node.js.map +0 -1
  148. package/dist/827.jclic-node.js +0 -708
  149. package/dist/827.jclic-node.js.map +0 -1
  150. package/dist/8276.jclic-node.js +0 -409
  151. package/dist/8276.jclic-node.js.map +0 -1
  152. package/dist/8322.jclic-node.js +0 -498
  153. package/dist/8322.jclic-node.js.map +0 -1
  154. package/dist/8641.jclic-node.js +0 -360
  155. package/dist/8641.jclic-node.js.map +0 -1
  156. package/dist/8837.jclic-node.js +0 -651
  157. package/dist/8837.jclic-node.js.map +0 -1
  158. package/dist/8895.jclic-node.js +0 -151
  159. package/dist/8895.jclic-node.js.map +0 -1
  160. package/dist/9072.jclic-node.js +0 -1285
  161. package/dist/9072.jclic-node.js.map +0 -1
  162. package/dist/9078.jclic-node.js +0 -935
  163. package/dist/9078.jclic-node.js.map +0 -1
  164. package/dist/9103.jclic-node.js +0 -718
  165. package/dist/9103.jclic-node.js.map +0 -1
  166. package/dist/9359.jclic-node.js +0 -145
  167. package/dist/9359.jclic-node.js.map +0 -1
  168. package/dist/9409.jclic-node.js +0 -921
  169. package/dist/9409.jclic-node.js.map +0 -1
  170. package/dist/9513.jclic-node.js +0 -720
  171. package/dist/9513.jclic-node.js.map +0 -1
  172. package/dist/9704.jclic-node.js +0 -81
  173. package/dist/9704.jclic-node.js.map +0 -1
  174. package/dist/9950.jclic-node.js +0 -827
  175. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,682 +0,0 @@
1
- "use strict";
2
- exports.id = 3019;
3
- exports.ids = [3019];
4
- exports.modules = {
5
-
6
- /***/ 3019:
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 exports TextActivityDocument, TextTarget */
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 _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9072);
17
- /* harmony import */ var _media_MediaContent_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2355);
18
- /**
19
- * File : activities/text/TextActivityDocument.js
20
- * Created : 14/04/2015
21
- * By : Francesc Busquets <francesc@gmail.com>
22
- *
23
- * JClic.js
24
- * An HTML5 player of JClic activities
25
- * https://projectestac.github.io/jclic.js
26
- *
27
- * @source https://github.com/projectestac/jclic.js
28
- *
29
- * @license EUPL-1.2
30
- * @licstart
31
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
32
- *
33
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
34
- * the European Commission- subsequent versions of the EUPL (the "Licence");
35
- * You may not use this work except in compliance with the Licence.
36
- *
37
- * You may obtain a copy of the Licence at:
38
- * https://joinup.ec.europa.eu/software/page/eupl
39
- *
40
- * Unless required by applicable law or agreed to in writing, software
41
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
42
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
43
- * Licence for the specific language governing permissions and limitations
44
- * under the Licence.
45
- * @licend
46
- * @module
47
- */
48
-
49
-
50
-
51
-
52
-
53
-
54
- /**
55
- * This is the HTML DOM element used in text activities like {@link module:activities/text/FillInBlanks.FillInBlanks FillInBlanks},
56
- * {@link module:activities/text/IdentifyText.IdentifyText IdentifyText}, {@link module:activities/text/OrderText.OrderText OrderText} and {@link module:activities/text/Complete.Complete Complete}. It contains the main document of
57
- * the activity, usually with some elements marked as "targets". In {@link module:activities/text/FillInBlanks.FillInBlanks FillInBlanks}, this
58
- * targets are encapsulated in {@link module:activities/text/TextActivityDocument.TextTarget TextTarget} objects.
59
- */
60
- class TextActivityDocument {
61
- /**
62
- * TextActivityDocument constructor
63
- */
64
- constructor() {
65
- // Make a deep clone of the default style
66
- this.style = { 'default': { ...TextActivityDocument.DEFAULT_DOC_STYLE } };
67
- this.p = [];
68
- }
69
-
70
- /**
71
- * Loads the document settings from a specific JQuery XML element
72
- * @param {external:jQuery} $xml - The XML element to parse
73
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The media bag used to load images and media content
74
- */
75
- setProperties($xml, mediaBag) {
76
- // Read named styles
77
- // Sort styles according to its "base" dependencies
78
- const styles = $xml.children('style').toArray().sort((a, b) => {
79
- var aName = a.getAttribute('name'), aBase = a.getAttribute('base') || null;
80
- var bName = b.getAttribute('name'), bBase = b.getAttribute('base') || null;
81
- // Put 'default' always first, then each style below their base (if any)
82
- return aName === 'default' ? -1 : bName === 'default' ? 1
83
- : aBase === bName ? 1 : bBase === aName ? -1
84
- : !aBase ? -1 : !bBase ? 1 : 0;
85
- });
86
-
87
- // Process the ordered list of styles
88
- styles.forEach(style => {
89
- const attr = this.readDocAttributes(jquery__WEBPACK_IMPORTED_MODULE_0___default()(style));
90
- // Grant always that basic attributes are defined
91
- this.style[attr.name] = attr.name === 'default' ? jquery__WEBPACK_IMPORTED_MODULE_0___default().extend(true, this.style.default, attr) : attr;
92
- });
93
-
94
- // Read paragraphs
95
- $xml.find('section > p').each((_n, par) => {
96
-
97
- const p = { elements: [] };
98
-
99
- // Read paragraph attributes
100
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)(par.attributes, (name, value) => {
101
- switch (name) {
102
- case 'style':
103
- p[name] = value;
104
- break;
105
- case 'bidiLevel':
106
- case 'Alignment':
107
- p[name] = Number(value);
108
- break;
109
- }
110
- });
111
-
112
- // Read paragraph objects
113
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(par).children().each((_n, child) => {
114
- let obj;
115
- const $child = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
116
- switch (child.nodeName) {
117
-
118
- case 'cell':
119
- obj = new _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_2__["default"]().setProperties($child, mediaBag);
120
- break;
121
-
122
- case 'text':
123
- obj = { text: child.textContent.replace(/\t/g, '&#9;') };
124
- const attr = this.readDocAttributes($child);
125
- if (!jquery__WEBPACK_IMPORTED_MODULE_0___default().isEmptyObject(attr)) {
126
- obj.attr = attr;
127
- }
128
- break;
129
-
130
- case 'target':
131
- obj = new TextTarget(this, child.textContent.replace(/\t/g, '&#9;'));
132
- obj.setProperties($child, mediaBag);
133
- this.numTargets++;
134
- break;
135
-
136
- default:
137
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('error', `Unknown object in activity document: "${child.nodeName}"`);
138
- }
139
- if (obj) {
140
- obj.objectType = child.nodeName;
141
- p.elements.push(obj);
142
- }
143
- });
144
-
145
- this.p.push(p);
146
- });
147
- return this;
148
- }
149
-
150
- /**
151
- * Reads sets of text attributes, sometimes in form of named styles
152
- * @param {external:jQuery} $xml - The XML element to parse
153
- * @returns {object}
154
- */
155
- readDocAttributes($xml) {
156
- let
157
- attr = {},
158
- css = {};
159
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .attrForEach */ .GM)($xml.get(0).attributes, (name, val) => {
160
- switch (name) {
161
- case 'background':
162
- val = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)(val, 'white');
163
- attr[name] = val;
164
- css['background-color'] = val;
165
- break;
166
- case 'foreground':
167
- val = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .checkColor */ .I4)(val, 'black');
168
- attr[name] = val;
169
- css['color'] = val;
170
- break;
171
- case 'family':
172
- css['font-family'] = val;
173
- /* falls through */
174
- case 'name':
175
- case 'style':
176
- // Attributes specific to named styles:
177
- attr[name] = val;
178
- break;
179
- case 'base':
180
- attr[name] = val;
181
- // If base style exists, merge it with current settings
182
- if (this.style[val]) {
183
- //attr = Object.apply({}, this.style[val], attr)
184
- attr = jquery__WEBPACK_IMPORTED_MODULE_0___default().extend(true, {}, this.style[val], attr);
185
- if (this.style[val].css)
186
- //css = Object.apply({}, this.style[val].css, css)
187
- css = jquery__WEBPACK_IMPORTED_MODULE_0___default().extend({}, this.style[val].css, css);
188
- }
189
- break;
190
- case 'bold':
191
- val = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val);
192
- attr[name] = val;
193
- css['font-weight'] = val ? 'bold' : 'normal';
194
- break;
195
- case 'italic':
196
- val = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val);
197
- attr[name] = val;
198
- css['font-style'] = val ? 'italic' : 'normal';
199
- break;
200
- case 'target':
201
- attr[name] = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBoolean */ .pW)(val);
202
- break;
203
- case 'size':
204
- attr[name] = Number(val);
205
- css['font-size'] = `${val}px`;
206
- break;
207
- case 'tabWidth':
208
- // `tab-size` CSS attribute is only set when the document has a specific `tabWidth`
209
- // setting. It must be accompanied of `white-space:pre` to successfully work.
210
- this.tabSpc = val;
211
- css['tab-size'] = this.tabSpc;
212
- css['white-space'] = 'pre-wrap';
213
- break;
214
- default:
215
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('warn', `Unknown text attribute: "${name}" = "${val}"`);
216
- attr[name] = val;
217
- break;
218
- }
219
- });
220
-
221
- if (!jquery__WEBPACK_IMPORTED_MODULE_0___default().isEmptyObject(css))
222
- attr['css'] = css;
223
-
224
- return attr;
225
- }
226
-
227
- /**
228
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
229
- * parent references, constants and also attributes retaining the default value.
230
- * The resulting object is commonly usued to serialize elements in JSON format.
231
- * @returns {object} - The resulting object, with minimal attrributes
232
- */
233
- getAttributes() {
234
- // TODO: simplify the serialization of styles (now too verbose!)
235
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, ['style', 'tabSpc', 'targetType', 'p']);
236
- }
237
-
238
- /**
239
- * Reads the properties of this TextActivityDocument from a data object
240
- * @param {object} data - The data object to be parsed, or just the text content
241
- * @returns {module:activities/text/TextActivityDocument.TextActivityDocument}
242
- */
243
- setAttributes(data, mediaBag) {
244
-
245
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(this, data, ['style', 'tabSpc', 'targetType', 'p']);
246
-
247
- // Build paragraphs:
248
- this.p.forEach(p => {
249
- if (p.elements)
250
- p.elements = p.elements.map(el => {
251
- if (el.objectType === 'cell')
252
- return (new _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_2__["default"]()).setAttributes(el, mediaBag);
253
- else if (el.objectType === 'target')
254
- return (new TextTarget(this)).setAttributes(el, mediaBag);
255
- else
256
- return el;
257
- });
258
- else
259
- p.elements = [];
260
- });
261
- return this;
262
- }
263
-
264
- /**
265
- * Gets the full text of this document in raw format
266
- * @returns {string} - The text of the document.
267
- */
268
- getRawText() {
269
- const $html = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<div/>');
270
- // Process paragraphs
271
- this.p.forEach(p => {
272
- // Creates a new DOM paragraph
273
- const $p = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<p/>');
274
- let empty = true;
275
- // Process the paragraph elements
276
- p.elements.forEach(element => {
277
- switch (element.objectType) {
278
- case 'text':
279
- case 'target':
280
- $p.append(element.text);
281
- break;
282
- case 'cell':
283
- // cells are not considered raw text of the document
284
- break;
285
- default:
286
- break;
287
- }
288
- empty = false;
289
- });
290
- if (empty) {
291
- // Don't leave paragraphs empty
292
- $p.html('&nbsp;');
293
- }
294
- // Adds the paragraph to the DOM element
295
- $html.append($p);
296
- });
297
- return $html.text().trim();
298
- }
299
-
300
- /**
301
- * Gets a `style` object filled with default attributes plus attributes present in the
302
- * requested style name.
303
- * @param {string} name - The requested style name
304
- * @returns {object} - The result of combining `default` with the requested style
305
- */
306
- getFullStyle(name) {
307
- const st = jquery__WEBPACK_IMPORTED_MODULE_0___default().extend(true, {}, this.style.default);
308
- return jquery__WEBPACK_IMPORTED_MODULE_0___default().extend(true, st, this.style[name] ? this.style[name] : {});
309
- //return Object.assign({}, this.style.default, this.style[name] ? this.style[name] : {})
310
- }
311
- }
312
-
313
- /**
314
- * Default style
315
- */
316
- TextActivityDocument.DEFAULT_DOC_STYLE = {
317
- background: '0xFFFFFF',
318
- foreground: '0x000000',
319
- family: 'Arial',
320
- bold: false,
321
- italic: false,
322
- size: 17,
323
- css: {
324
- 'background-color': '#FFFFFF',
325
- 'color': '#000000',
326
- 'font-family': 'Arial',
327
- 'font-weight': 'normal',
328
- 'font-style': 'normal',
329
- 'font-size': '17px',
330
- },
331
- };
332
-
333
- Object.assign(TextActivityDocument.prototype, {
334
- /**
335
- * Number of blank spaces between tabulators.
336
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#tabSpc
337
- * @type {number} */
338
- tabSpc: 12,
339
- /**
340
- * Index of the last {@link module:boxes/ActiveBox.ActiveBox ActiveBox} activated.
341
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#lastBoxId
342
- * @type {number} */
343
- lastBoxId: 0,
344
- /**
345
- * A bag of {@link module:activities/text/TextActivityDocument.TargetMarker TargetMarker} objects
346
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#tmb
347
- * @type {object} */
348
- tmb: null,
349
- /**
350
- * Number of targets
351
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#numTargets
352
- * @type {number} */
353
- numTargets: 0,
354
- /**
355
- * Type of targets used in this activity. Possible values are: `TT_FREE`, `TT_CHAR`, `TT_WORD`
356
- * and `TT_PARAGRAPH`.
357
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#targetType
358
- * @type {string} */
359
- targetType: 'TT_FREE',
360
- /**
361
- * Collection of named styles of the document
362
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#style
363
- * @type {object} */
364
- style: null,
365
- /**
366
- * The main document, represented as a collection of DOM objects
367
- * @name module:activities/text/TextActivityDocument.TextActivityDocument#p
368
- * @type {object} */
369
- p: null,
370
- });
371
-
372
- /**
373
- * This class contains the properties and methods of the document elements that are the real
374
- * targets of user actions in text activities.
375
- */
376
- class TextTarget {
377
- /**
378
- * TextTarget constructor
379
- * @param {module:activities/text/TextActivityDocument.TextActivityDocument} doc - The document to which this target belongs.
380
- * @param {string} text - Main text of this target.
381
- */
382
- constructor(doc, text = '') {
383
- this.doc = doc;
384
- this.text = text;
385
- this.numIniChars = text.length;
386
- this.answers = [text];
387
- this.maxLenResp = this.numIniChars;
388
- }
389
-
390
- /**
391
- * Resets the TextTarget status
392
- * @param {string} [status] - The `targetStatus` to be established. Default is `NOT_EDITED`
393
- */
394
- reset(status) {
395
- this.targetStatus = status ? status : 'NOT_EDITED';
396
- this.flagModified = false;
397
- }
398
-
399
- /**
400
- * Loads the text target settings from a specific JQuery XML element
401
- * @param {external:jQuery} $xml - The XML element to parse
402
- * @param {module:bags/MediaBag.MediaBag} mediaBag - The media bag used to load images and media content
403
- */
404
- setProperties($xml, mediaBag) {
405
- let firstAnswer = true;
406
- // Read specific nodes
407
- $xml.children().each((_n, child) => {
408
- const $node = jquery__WEBPACK_IMPORTED_MODULE_0___default()(child);
409
- switch (child.nodeName) {
410
- case 'answer':
411
- if (firstAnswer) {
412
- firstAnswer = false;
413
- this.answers = [];
414
- }
415
- if (this.answers === null)
416
- this.answers = [];
417
- this.answers.push(child.textContent);
418
- break;
419
-
420
- case 'optionList':
421
- $node.children('option').each((_n, opChild) => {
422
- this.isList = true;
423
- if (this.options === null)
424
- this.options = [];
425
- this.options.push(opChild.textContent);
426
- });
427
- break;
428
-
429
- case 'response':
430
- this.iniChar = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getVal */ .eH)($node.attr('fill'), this.iniChar).charAt(0);
431
- // Use underscores instead of whitespace chars
432
- if (_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.WHITESPACES.indexOf(this.iniChar) >= 0)
433
- this.iniChar = '_';
434
- this.numIniChars = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getNumber */ .WZ)($node.attr('length'), this.numIniChars);
435
- this.maxLenResp = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getNumber */ .WZ)($node.attr('maxLength'), this.maxLenResp);
436
- this.iniText = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getVal */ .eH)($node.attr('show'), this.iniText);
437
- break;
438
-
439
- case 'info':
440
- this.infoMode = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getVal */ .eH)($node.attr('mode'), 'always');
441
- this.popupDelay = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getNumber */ .WZ)($node.attr('delay'), this.popupDelay);
442
- this.popupMaxTime = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getNumber */ .WZ)($node.attr('maxTime'), this.popupMaxTime);
443
- $node.children('media').each((_n, media) => {
444
- this.onlyPlay = true;
445
- this.popupContent = new _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_2__["default"]();
446
- this.popupContent.mediaContent = new _media_MediaContent_js__WEBPACK_IMPORTED_MODULE_3__["default"]().setProperties(jquery__WEBPACK_IMPORTED_MODULE_0___default()(media));
447
- });
448
- if (!this.popupContent) {
449
- $node.children('cell').each((_n, cell) => {
450
- this.popupContent = new _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_2__["default"]().setProperties(jquery__WEBPACK_IMPORTED_MODULE_0___default()(cell), mediaBag);
451
- });
452
- }
453
- break;
454
-
455
- case 'text':
456
- this.text = child.textContent.replace(/\t/g, '&#9;');
457
- const attr = this.doc.readDocAttributes(jquery__WEBPACK_IMPORTED_MODULE_0___default()(child));
458
- if (!jquery__WEBPACK_IMPORTED_MODULE_0___default().isEmptyObject(attr))
459
- this.attr = attr;
460
- break;
461
-
462
- default:
463
- break;
464
- }
465
- });
466
- }
467
-
468
- /**
469
- * Gets a object with the basic attributes needed to rebuild this instance excluding functions,
470
- * parent references, constants and also attributes retaining the default value.
471
- * The resulting object is commonly usued to serialize elements in JSON format.
472
- * @returns {object} - The resulting object, with minimal attrributes
473
- */
474
- getAttributes() {
475
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getAttr */ .iu)(this, [
476
- 'objectType', 'text', 'attr', 'isList',
477
- 'answers', 'options', 'iniChar', 'numIniChars', 'maxLenResp', 'iniText',
478
- 'infoMode', 'popupDelay', 'popupKey', 'popupMaxTime', 'onlyPlay',
479
- 'popupContent',
480
- ]);
481
- }
482
-
483
- /**
484
- * Reads the properties of this TextTarget from a data object
485
- * @param {object} data - The data object to be parsed, or just the text content
486
- * @returns {module:activities/text/TextActivityDocument.TextTarget}
487
- */
488
- setAttributes(data, mediaBag) {
489
- return (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .setAttr */ .ob)(this, data, [
490
- 'objectType', 'text', 'attr', 'isList',
491
- 'answers', 'options', 'iniChar', 'numIniChars', 'maxLenResp', 'iniText',
492
- 'infoMode', 'popupDelay', 'popupKey', 'popupMaxTime', 'onlyPlay',
493
- { key: 'popupContent', fn: _boxes_ActiveBoxContent_js__WEBPACK_IMPORTED_MODULE_2__["default"], params: [mediaBag] },
494
- ]);
495
- }
496
-
497
- /**
498
- * Gets a string with all valid answers of this TextTarget. Useful for reporting users' activity.
499
- * @returns {string}
500
- */
501
- getAnswers() {
502
- return this.answers ? this.answers.join('|') : '';
503
- }
504
-
505
- /**
506
- * Sets specific colors to the target jQuery element, based on its `targetStatus` value. Red
507
- * color usually means error.
508
- */
509
- checkColors() {
510
- const $element = this.$comboList || this.$span;
511
- if ($element) {
512
- const style = this.doc.style[
513
- this.targetStatus === 'WITH_ERROR' ? 'targetError' :
514
- this.targetStatus === 'HIDDEN' ? 'default' : 'target'];
515
- if (style && style.css) {
516
- $element.css(style.css);
517
- }
518
- }
519
- }
520
-
521
- /**
522
- * Fills the `currentText` member with the text currently hosted in $span or selected in $comboList
523
- * @returns {string} - The current text of this target
524
- */
525
- readCurrentText() {
526
- if (this.$span)
527
- this.currentText = this.$span.text();
528
- else if (this.$comboList)
529
- this.currentText = this.$comboList.val();
530
- return this.currentText;
531
- }
532
- }
533
-
534
- Object.assign(TextTarget.prototype, {
535
- /**
536
- * The {@link module:activities/text/TextActivityDocument.TextActivityDocument TextActivityDocument} to which this target belongs
537
- * @name module:activities/text/TextActivityDocument.TextTarget#doc
538
- * @type {module:activities/text/TextActivityDocument.TextActivityDocument} */
539
- doc: null,
540
- /**
541
- * The current text displayed by this TextTarget
542
- * @name module:activities/text/TextActivityDocument.TextTarget#text
543
- * @type {string} */
544
- text: null,
545
- /**
546
- * A set of optional attributes for `text`
547
- * @name module:activities/text/TextActivityDocument.TextTarget#attr
548
- * @type {object} */
549
- attr: null,
550
- /**
551
- * `true` when the target is a drop-down list
552
- * @name module:activities/text/TextActivityDocument.TextTarget#isList
553
- * @type {boolean} */
554
- isList: false,
555
- /**
556
- * Number of characters initially displayed on the text field
557
- * @name module:activities/text/TextActivityDocument.TextTarget#numIniChars
558
- * @type {number} */
559
- numIniChars: 1,
560
- /**
561
- * Character used to fill-in the text field
562
- * @name module:activities/text/TextActivityDocument.TextTarget#iniChar
563
- * @type {string} */
564
- iniChar: '_',
565
- /**
566
- * Maximum length of the answer
567
- * @name module:activities/text/TextActivityDocument.TextTarget#maxLenResp
568
- * @type {number} */
569
- maxLenResp: 0,
570
- /**
571
- * Array of valid answers
572
- * @name module:activities/text/TextActivityDocument.TextTarget#answers
573
- * @type {string[]} */
574
- answers: null,
575
- /**
576
- * Set of specific options
577
- * @name module:activities/text/TextActivityDocument.TextTarget#options
578
- * @type {object} */
579
- options: null,
580
- /**
581
- * Text displayed by the target when the activity begins
582
- * @name module:activities/text/TextActivityDocument.TextTarget#iniText
583
- * @type {string} */
584
- iniText: null,
585
- /**
586
- * Type of additional information offered to the user. Possible values are: `no_info`, `always`,
587
- * `onError` and `onDemand`.
588
- * @name module:activities/text/TextActivityDocument.TextTarget#infoMode
589
- * @type {string} */
590
- infoMode: 'no_info',
591
- /**
592
- * Key that triggers the associated popup when `infoMode` is `onDemand`
593
- * @name module:activities/text/TextActivityDocument.TextTarget#popupKey
594
- * @type {string} */
595
- popupKey: 'F1',
596
- /**
597
- * An optional {@link module:boxes/ActiveBoxContent.ActiveBoxContent ActiveBoxContent} with information about this TextTarget
598
- * @name module:activities/text/TextActivityDocument.TextTarget#popupContent
599
- * @type {module:boxes/ActiveBoxContent.ActiveBoxContent} */
600
- popupContent: null,
601
- /**
602
- * Time (seconds) to wait before showing the additional information
603
- * @name module:activities/text/TextActivityDocument.TextTarget#popupDelay
604
- * @type {number} */
605
- popupDelay: 0,
606
- /**
607
- * Maximum amount of time (seconds) that the additional information will be shown
608
- * @name module:activities/text/TextActivityDocument.TextTarget#popupMaxTime
609
- * @type {number} */
610
- popupMaxTime: 0,
611
- /**
612
- * When this flag is `true` and `popupContent` contains audio, no visual feedback will be
613
- * provided (meaning that audio will be just played)
614
- * @name module:activities/text/TextActivityDocument.TextTarget#onlyPlay
615
- * @type {boolean} */
616
- onlyPlay: false,
617
- //
618
- // TRANSIENT PROPERTIES
619
- //
620
- /**
621
- * The drop-down list associated to this target
622
- * @name module:activities/text/TextActivityDocument.TextTarget#$comboList
623
- * @type {external:jQuery} */
624
- $comboList: null,
625
- /**
626
- * The span element associated to this target
627
- * @name module:activities/text/TextActivityDocument.TextTarget#$span
628
- * @type {external:jQuery} */
629
- $span: null,
630
- /**
631
- * The paragraph element where $span is currently located
632
- * @name module:activities/text/TextActivityDocument.TextTarget#$p
633
- * @type {external:jQuery} */
634
- $p: null,
635
- /**
636
- * The span element containing the popup
637
- * @name module:activities/text/TextActivityDocument.TextTarget#$popup
638
- * @type {external:jQuery} */
639
- $popup: null,
640
- /**
641
- * Current text in the $span element
642
- * @name module:activities/text/TextActivityDocument.TextTarget#currentText
643
- * @type {string} */
644
- currentText: '',
645
- /**
646
- * Ordinal number of this target in the collection of targets
647
- * @name module:activities/text/TextActivityDocument.TextTarget#num
648
- * @type {number} */
649
- num: 0,
650
- /**
651
- * Current ordinal position of this target in the document
652
- * (used in {@link module:activities/text/OrderText.OrderText OrderText} activities)
653
- * @name module:activities/text/TextActivityDocument.TextTarget#pos
654
- * @type {number} */
655
- pos: 0,
656
- /**
657
- * Current status of the target. Valid values are: `NOT_EDITED`, `EDITED`, `SOLVED`, `WITH_ERROR` and `HIDDEN`
658
- * @name module:activities/text/TextActivityDocument.TextTarget#targetStatus
659
- * @type {string} */
660
- targetStatus: 'NOT_EDITED',
661
- /**
662
- * Flag to control if the initial content of this TextTarget has been modified
663
- * @name module:activities/text/TextActivityDocument.TextTarget#flagModified
664
- * @type {boolean} */
665
- flagModified: false,
666
- /**
667
- * Pointer to the activity panel containing this TextTarget
668
- * @name module:activities/text/TextActivityDocument.TextTarget#parentPane
669
- * @type {module:activities/text/TextActivityBase.TextActivityBasePanel} */
670
- parentPane: null,
671
- });
672
-
673
- TextActivityDocument.TextTarget = TextTarget;
674
-
675
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextActivityDocument);
676
-
677
-
678
- /***/ })
679
-
680
- };
681
- ;
682
- //# sourceMappingURL=3019.jclic-node.js.map