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,1126 +0,0 @@
1
- "use strict";
2
- exports.id = 5312;
3
- exports.ids = [5312];
4
- exports.modules = {
5
-
6
- /***/ 5312:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
-
10
- // EXPORTS
11
- __webpack_require__.d(__webpack_exports__, {
12
- "default": () => (/* binding */ textGrid_CrossWord)
13
- });
14
-
15
- // UNUSED EXPORTS: CrossWord, CrossWordPanel
16
-
17
- // EXTERNAL MODULE: external "jquery"
18
- var external_jquery_ = __webpack_require__(7750);
19
- var external_jquery_default = /*#__PURE__*/__webpack_require__.n(external_jquery_);
20
- // EXTERNAL MODULE: ./src/Activity.js
21
- var Activity = __webpack_require__(1567);
22
- // EXTERNAL MODULE: ./src/boxes/BoxBase.js
23
- var BoxBase = __webpack_require__(3018);
24
- // EXTERNAL MODULE: ./src/boxes/BoxBag.js
25
- var BoxBag = __webpack_require__(9205);
26
- // EXTERNAL MODULE: ./src/boxes/TextGrid.js
27
- var TextGrid = __webpack_require__(4123);
28
- // EXTERNAL MODULE: ./src/boxes/AbstractBox.js
29
- var AbstractBox = __webpack_require__(9513);
30
- // EXTERNAL MODULE: ./src/boxes/ActiveBox.js
31
- var ActiveBox = __webpack_require__(1725);
32
- // EXTERNAL MODULE: ./src/AWT.js
33
- var AWT = __webpack_require__(7912);
34
- // EXTERNAL MODULE: ./src/Utils.js
35
- var Utils = __webpack_require__(1253);
36
- ;// ./src/activities/textGrid/icons/hIcon.svg
37
- const hIcon_namespaceObject = "<svg fill=\"#FFFFFF\" height=\"36\" viewBox=\"0 0 24 24\" width=\"36\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z\" />\n</svg>\n";
38
- ;// ./src/activities/textGrid/icons/vIcon.svg
39
- const vIcon_namespaceObject = "<svg fill=\"#FFFFFF\" height=\"36\" viewBox=\"0 0 24 24\" width=\"36\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z\" />\n</svg>\n";
40
- ;// ./src/activities/textGrid/CrossWord.js
41
- /**
42
- * File : activities/textGrid/CrossWord.js
43
- * Created : 17/06/2015
44
- * By : Francesc Busquets <francesc@gmail.com>
45
- *
46
- * JClic.js
47
- * An HTML5 player of JClic activities
48
- * https://projectestac.github.io/jclic.js
49
- *
50
- * @source https://github.com/projectestac/jclic.js
51
- *
52
- * @license EUPL-1.2
53
- * @licstart
54
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
55
- *
56
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
57
- * the European Commission- subsequent versions of the EUPL (the "Licence");
58
- * You may not use this work except in compliance with the Licence.
59
- *
60
- * You may obtain a copy of the Licence at:
61
- * https://joinup.ec.europa.eu/software/page/eupl
62
- *
63
- * Unless required by applicable law or agreed to in writing, software
64
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
65
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
66
- * Licence for the specific language governing permissions and limitations
67
- * under the Licence.
68
- * @licend
69
- * @module
70
- */
71
-
72
- /* global window */
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
- // Use Webpack to import SVG files
85
-
86
-
87
-
88
- /**
89
- * This class of {@link module:Activity.Activity Activity} shows a {@link module:boxes/TextGrid.TextGrid TextGrid} initially empty, with some cells
90
- * marked in negative color that act as word stoppers. A blinking "cursor" indicates the cell that
91
- * will receive the next character entered by the user on the keyboard.
92
- *
93
- * The letter in each cell of the grid is always shared by two words: one in horizontal direction
94
- * and the other one in vertical direction. Two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects are placed next to the
95
- * {@link module:boxes/TextGrid.TextGrid TextGrid}, hosting the definitions of the horizontal and vertical words crossing at the
96
- * cell currently marked by the cursor.
97
- *
98
- * Two special buttons placed near this boxes allow to write on the grid horizontally or vertically.
99
- * The aim of the activity is to fill all the text grid with the correct words.
100
- * @extends module:Activity.Activity
101
- */
102
- class CrossWord extends Activity/* Activity */.I {
103
- /**
104
- * CrossWord constructor
105
- * @param {module:project/JClicProject.JClicProject} project - The JClic project to which this activity belongs
106
- */
107
- constructor(project) {
108
- super(project);
109
- }
110
-
111
- /**
112
- * Retrieves the minimum number of actions needed to solve this activity
113
- * @override
114
- * @returns {number}
115
- */
116
- getMinNumActions() {
117
- return this.tgc.getNumChars() - this.tgc.countWildChars();
118
- }
119
-
120
- /**
121
- * Crossword activities always make use of the keyboard
122
- * @override
123
- * @returns {boolean}
124
- */
125
- needsKeyboard() {
126
- return true;
127
- }
128
- }
129
-
130
- Object.assign(CrossWord.prototype, {
131
- /**
132
- * Whether all letters of the {@link module:boxes/TextGrid.TextGrid TextGrid} should be displayed in upper case
133
- * @name module:activities/textGrid/CrossWord.CrossWord#upperCase
134
- * @type {boolean} */
135
- upperCase: true,
136
- /**
137
- * Whether the case is significant to evaluate answers
138
- * @name module:activities/textGrid/CrossWord.CrossWord#checkCase
139
- * @type {boolean} */
140
- checkCase: true,
141
- /**
142
- * When `true`, the wildcard character of the {@link module:boxes/TextGrid.TextGrid TextGrid} will be transparent.
143
- * @name module:activities/textGrid/CrossWord.CrossWord#wildTransparent
144
- * @type {boolean} */
145
- wildTransparent: false,
146
- });
147
-
148
- /**
149
- * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/textGrid/CrossWord.CrossWord CrossWord} activities are played.
150
- * @extends module:Activity.ActivityPanel
151
- */
152
- class CrossWordPanel extends Activity/* ActivityPanel */.S {
153
- /**
154
- * CrossWordPanel constructor
155
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
156
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
157
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
158
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
159
- */
160
- constructor(act, ps, $div) {
161
- super(act, ps, $div);
162
- }
163
-
164
- /**
165
- * Performs miscellaneous cleaning operations
166
- * @override
167
- */
168
- clear() {
169
- if (this.grid) {
170
- this.grid.end();
171
- this.grid = null;
172
- }
173
- if (this.style) {
174
- this.style.end();
175
- this.style = null;
176
- }
177
- }
178
-
179
- /**
180
- * Creates a {@link module:boxes/BoxBag.BoxBag BoxBag} with a label ("Horizontal" or "Vertical") and an {@link module:boxes/ActiveBox.ActiveBox ActiveBox}
181
- * that will be used to display clues.
182
- * @param {string} type - `acrossClues` for horizontal clues, 'downClues' for vertical.
183
- * @returns {module:boxes/BoxBag.BoxBag}
184
- */
185
- createBoxBag(type) {
186
- const
187
- bxb = new BoxBag["default"](null, this, null),
188
- sb = new AbstractBox["default"](bxb, this, this.icoBB);
189
-
190
- sb.setBounds(0, 0, this.LABEL_WIDTH, this.act.abc[type].h);
191
- const $btn = external_jquery_default()('<button/>', { class: 'StockBtn' }).css({
192
- 'width': this.LABEL_WIDTH,
193
- 'height': this.act.abc[type].h,
194
- 'background-image': `url(${type === 'acrossClues' ? this.hIcon : this.vIcon})`,
195
- 'background-repeat': 'no-repeat',
196
- 'background-position': 'center',
197
- 'border-radius': 6,
198
- 'z-index': 10
199
- }).on('click', () => {
200
- this.advance = type === 'acrossClues' ?
201
- this.advance === 'ADVANCE_RIGHT' ?
202
- 'NO_ADVANCE' : 'ADVANCE_RIGHT' :
203
- this.advance === 'ADVANCE_DOWN' ?
204
- 'NO_ADVANCE' : 'ADVANCE_DOWN';
205
- this.setBtnStatus();
206
- }).on('keypress', event => {
207
- if (String.fromCharCode(event.charCode || event.keyCode) === ' ')
208
- event.stopPropagation();
209
- }).appendTo(this.$div);
210
-
211
- sb.setHostedComponent($btn);
212
- bxb.addBox(sb);
213
-
214
- const ab = new ActiveBox["default"](bxb, null, null, type, new AWT/* Rectangle */.M_(this.LABEL_WIDTH + this.act.margin, 0, this.act.abc[type].w, this.act.abc[type].h));
215
- bxb.addBox(ab);
216
- bxb.setBoxBase(this.act.abc[type].style);
217
-
218
- if (type === 'acrossClues') { // Horizontal
219
- this.hClue = ab;
220
- this.hClueBtn = sb;
221
- } else {
222
- this.vClue = ab;
223
- this.vClueBtn = sb;
224
- }
225
- return bxb;
226
- }
227
-
228
- /**
229
- * Prepares the visual components of the activity
230
- * @override
231
- */
232
- buildVisualComponents() {
233
- if (this.firstRun)
234
- super.buildVisualComponents();
235
- this.clear();
236
-
237
- const
238
- tgc = this.act.tgc,
239
- abcH = this.act.abc['acrossClues'],
240
- abcV = this.act.abc['downClues'];
241
-
242
- if (abcH.image)
243
- abcH.setImgContent(this.act.project.mediaBag, null, false);
244
- if (abcV.image)
245
- abcV.setImgContent(this.act.project.mediaBag, null, false);
246
-
247
- if (this.act.acp !== null) {
248
- this.act.acp.generateContent(0, 0, this.act.abc, false);
249
- }
250
-
251
- if (tgc) {
252
- this.grid = TextGrid["default"].createEmptyGrid(null, this, this.act.margin, this.act.margin, tgc, this.act.wildTransparent);
253
- this.style = new BoxBag["default"](null, this, null);
254
- const
255
- bxbh = this.createBoxBag('acrossClues'),
256
- bxbv = this.createBoxBag('downClues');
257
- if (this.act.boxGridPos === 'AUB' || this.act.boxGridPos === 'BUA')
258
- bxbv.moveTo(new AWT/* Point */.bR(bxbh.dim.width + this.act.margin, 0));
259
- else
260
- bxbv.moveTo(new AWT/* Point */.bR(0, bxbh.dim.height + this.act.margin));
261
- this.style.addBox(bxbh);
262
- this.style.addBox(bxbv);
263
- this.grid.setVisible(true);
264
- this.style.setVisible(true);
265
- }
266
- }
267
-
268
- /**
269
- * Basic initialization procedure
270
- * @override
271
- */
272
- initActivity() {
273
- super.initActivity();
274
- if (!this.firstRun)
275
- this.buildVisualComponents();
276
- else
277
- this.firstRun = false;
278
-
279
- if (this.grid) {
280
- this.grid.setChars(this.act.tgc.text);
281
- this.numLetters = this.act.getMinNumActions();
282
- this.grid.setCellAttributes(true, true);
283
- this.grid.setCursorEnabled(true);
284
- this.setCursorAt(0, 0);
285
- this.advance = 'ADVANCE_RIGHT';
286
- this.setBtnStatus();
287
- this.setAndPlayMsg('initial', 'start');
288
- this.invalidate().update();
289
- this.$div.attr("tabindex", 0);
290
- this.$div.focus();
291
- this.playing = true;
292
- }
293
- }
294
-
295
- /**
296
- * Calculates the current score
297
- * @returns {number}
298
- */
299
- getCurrentScore() {
300
- return this.grid ? this.grid.countCoincidences(this.act.checkCase) : 0;
301
- }
302
-
303
- /**
304
- * Updates the graphic content of this panel.
305
- * This method will be called from {@link module:AWT.Container#update} when needed.
306
- * @override
307
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
308
- * it's the whole panel.
309
- */
310
- updateContent(dirtyRegion) {
311
- super.updateContent(dirtyRegion);
312
- if (this.grid && this.$canvas) {
313
- const
314
- canvas = this.$canvas.get(-1),
315
- ctx = canvas.getContext('2d');
316
- if (!dirtyRegion)
317
- dirtyRegion = new AWT/* Rectangle */.M_(0, 0, canvas.width, canvas.height);
318
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
319
- this.grid.update(ctx, dirtyRegion);
320
- this.style.update(ctx, dirtyRegion);
321
- }
322
- return this;
323
- }
324
-
325
- /**
326
- * Sets the real dimension of this panel.
327
- * @override
328
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
329
- * @returns {module:AWT.Dimension}
330
- */
331
- setDimension(preferredMaxSize) {
332
- return !this.grid || !this.style || this.getBounds().equals(preferredMaxSize) ?
333
- preferredMaxSize :
334
- BoxBag["default"].layoutDouble(preferredMaxSize, this.grid, this.style, this.act.boxGridPos, this.act.margin);
335
- }
336
-
337
- /**
338
- * Sets the size and position of this activity panel
339
- * @override
340
- * @param {module:AWT.Rectangle} rect
341
- */
342
- setBounds(rect) {
343
- if (this.$canvas) {
344
- this.$canvas.remove();
345
- this.$canvas = null;
346
- }
347
- super.setBounds(rect);
348
-
349
- if (this.grid) {
350
- // Create the main canvas
351
- this.$canvas = external_jquery_default()(`<canvas width="${rect.dim.width}" height="${rect.dim.height}"/>`).css({
352
- position: 'absolute',
353
- top: 0,
354
- left: 0
355
- });
356
- this.$div.append(this.$canvas);
357
- // Repaint all
358
- this.invalidate().update();
359
- }
360
- }
361
-
362
- /**
363
- * Main handler used to process mouse, touch, keyboard and edit events
364
- * @override
365
- * @param {external:Event} event - The HTML event to be processed
366
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
367
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
368
- */
369
- processEvent(event) {
370
- if (this.playing) {
371
- switch (event.type) {
372
- case 'click':
373
- //
374
- // The [AWT.Point](AWT.html#Point) where the mouse or touch event has been originated
375
- // Touch events can have more than one touch, so `pageX` must be obtained from `touches[0]`
376
- const
377
- x = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0].pageX : event.pageX,
378
- y = event.originalEvent && event.originalEvent.touches ? event.originalEvent.touches[0].pageY : event.pageY,
379
- p = new AWT/* Point */.bR(x - this.$div.offset().left, y - this.$div.offset().top),
380
- // Array to be filled with actions to be executed at the end of event processing
381
- delayedActions = [];
382
-
383
- this.ps.stopMedia(1);
384
- if (this.grid.contains(p)) {
385
- const pt = this.grid.getLogicalCoords(p);
386
- if (pt !== null) {
387
- this.setCursorAt(pt.x, pt.y);
388
- if (Utils/* settings */.W0.TOUCH_DEVICE) {
389
- // We are in a touch device, so prompt user to write text:
390
- const d = this.advance === 'ADVANCE_DOWN';
391
- const txt = window.prompt(`${d ? 'Vertical' : 'Horizontal'} word:`, '');
392
- this.writeChars(txt);
393
- }
394
- }
395
- } else if (this.hClue.contains(p))
396
- this.hClue.playMedia(this.ps, delayedActions);
397
- else if (this.vClue.contains(p))
398
- this.vClue.playMedia(this.ps, delayedActions);
399
- else
400
- break;
401
-
402
- this.update();
403
- delayedActions.forEach(action => action());
404
- break;
405
-
406
- case 'keypress':
407
- const code = event.charCode || event.keyCode;
408
- if (code && this.grid.getCursor()) {
409
- event.preventDefault();
410
- this.writeChars(String.fromCharCode(code));
411
- }
412
- break;
413
-
414
- case 'keydown':
415
- let dx = 0, dy = 0;
416
- switch (event.keyCode) {
417
- case Utils/* settings */.W0.VK.RIGHT:
418
- dx = 1;
419
- break;
420
- case Utils/* settings */.W0.VK.LEFT:
421
- dx = -1;
422
- break;
423
- case Utils/* settings */.W0.VK.DOWN:
424
- dy = 1;
425
- break;
426
- case Utils/* settings */.W0.VK.UP:
427
- dy = -1;
428
- break;
429
- }
430
- if (dx || dy) {
431
- event.preventDefault();
432
- this.moveCursor(dx, dy);
433
- this.update();
434
- }
435
- break;
436
- }
437
- }
438
- }
439
-
440
- /**
441
- * Moves the cursor the specified `dx` and `dy` amount (in logical coordinates)
442
- * @param {number} dx - Amount of cells to horizontally move on
443
- * @param {number} dy - Amount of cells to vertically move on
444
- */
445
- moveCursor(dx, dy) {
446
- if (this.grid) {
447
- this.grid.moveCursor(dx, dy, true);
448
- this.cursorPosChanged();
449
- }
450
- }
451
-
452
- /**
453
- * Places the cursor at the specified location (in logical coordinates)
454
- * @param {number} x
455
- * @param {number} y
456
- */
457
- setCursorAt(x, y) {
458
- this.grid.setCursorAt(x, y, true);
459
- this.cursorPosChanged();
460
- }
461
-
462
- /**
463
- * Method called when the cursor moves to a different location
464
- */
465
- cursorPosChanged() {
466
- const pt = this.grid.getCursor();
467
- if (pt !== null && this.style !== null) {
468
- const items = this.grid.getItemFor(pt.x, pt.y);
469
- if (items !== null) {
470
- this.hClue.setContent(this.act.abc['acrossClues'].getActiveBoxContentWith(pt.y, items.x));
471
- this.vClue.setContent(this.act.abc['downClues'].getActiveBoxContentWith(pt.x, items.y));
472
- }
473
- }
474
- }
475
-
476
- /**
477
- * Writes a string on the grid starting at the current cursor position and
478
- * following the direction marked by the `advance` field
479
- * @param {string} txt - Text to write
480
- */
481
- writeChars(txt) {
482
- if (txt && txt.length > 0) {
483
- for (let i = 0; i < txt.length; i++) {
484
- const cur = this.grid.getCursor();
485
- let ch = txt.charAt(i);
486
- if (this.act.upperCase)
487
- ch = ch.toLocaleUpperCase();
488
- this.grid.setCharAt(cur.x, cur.y, ch);
489
- const
490
- ok = this.grid.isCellOk(cur.x, cur.y, this.act.checkCase),
491
- r = this.getCurrentScore();
492
- this.ps.reportNewAction(this.act, 'WRITE', ch, `X:${cur.x} Y:${cur.y}`, ok, r);
493
- // End activity or play event sound
494
- if (r === this.numLetters) {
495
- this.grid.setCursorEnabled(false);
496
- this.grid.stopCursorBlink();
497
- this.finishActivity(true);
498
- } else {
499
- this.playEvent('click');
500
- if (this.advance === 'ADVANCE_DOWN')
501
- this.moveCursor(0, 1);
502
- else if (this.advance === 'ADVANCE_RIGHT')
503
- this.moveCursor(1, 0);
504
- }
505
- }
506
- }
507
- this.update();
508
- }
509
-
510
- /**
511
- * Sets the status of horizontal and vertical buttons based on the value of `advance`
512
- */
513
- setBtnStatus() {
514
- if (this.hClueBtn)
515
- this.hClueBtn.setInactive(this.advance !== 'ADVANCE_RIGHT');
516
- if (this.vClueBtn)
517
- this.vClueBtn.setInactive(this.advance !== 'ADVANCE_DOWN');
518
- }
519
- }
520
-
521
- Object.assign(CrossWordPanel.prototype, {
522
- /**
523
- * The default width of the 'Horizontal' and 'Vertical' buttons (currently 40 pixels)
524
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#LABEL_WIDTH
525
- * @type {number} */
526
- LABEL_WIDTH: 40,
527
- /**
528
- * The text grid of this ActivityPanel
529
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#grid
530
- * @type {module:boxes/TextGrid.TextGrid} */
531
- grid: null,
532
- /**
533
- * A BoxBag used to place the across and down clues, and the `toggle direction` button.
534
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#style
535
- * @type {module:boxes/BoxBag.BoxBag} */
536
- style: null,
537
- /**
538
- * The total number of letters of this cross word
539
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#numLetters
540
- * @type {number} */
541
- numLetters: 0,
542
- /**
543
- * Flag indicating the type of automatic advance of the cursor.
544
- * Possible values are: `NO_ADVANCE` (default), 'ADVANCE_RIGHT' and 'ADVANCE_DOWN'.
545
- * TODO: Implement 'ADVANCE_LEFT' for LTR languages
546
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#advance
547
- * @type {string} */
548
- advance: 'NO_ADVANCE',
549
- /**
550
- * The ActiveBox object used to display the 'across' clues
551
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#hClue
552
- * @type {module:boxes/ActiveBox.ActiveBox} */
553
- hClue: null,
554
- /**
555
- * The ActiveBox object used to display the 'down' clues
556
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#vClue
557
- * @type {module:boxes/ActiveBox.ActiveBox} */
558
- vClue: null,
559
- /**
560
- * Button used to set the advance mode to 'ADVANCE_RIGHT'
561
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#hClueBtn
562
- * @type {module:boxes/ActiveBox.ActiveBox} */
563
- hClueBtn: null,
564
- /**
565
- * Button used to set the advance mode to 'ADVANCE_BOTTOM'
566
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#vClueBtn
567
- * @type {module:boxes/ActiveBox.ActiveBox} */
568
- vClueBtn: null,
569
- /**
570
- * Mouse and touch events intercepted by this panel
571
- * @override
572
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#events
573
- * @type {string[]} */
574
- events: ['click', 'keydown', 'keypress'],
575
- /**
576
- * Graphic icon for the horizontal direction button, represented as a string containing
577
- * an SVG file codified in base64.
578
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#hIcon
579
- * @type {string} */
580
- hIcon: (0,Utils/* svgToURI */.g8)(hIcon_namespaceObject),
581
- /**
582
- * Graphic icon for the vertical direction button, represented as a string containing
583
- * an SVG file codified in base64.
584
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#vIcon
585
- * @type {string} */
586
- vIcon: (0,Utils/* svgToURI */.g8)(vIcon_namespaceObject),
587
- /**
588
- * Sizes of the icons (currently 36 x 36 pixel)
589
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#icoSize
590
- * @type {object} */
591
- icoSize: { w: 36, h: 36 },
592
- /**
593
- * BoxBase with the style to be used by the direction buttons.
594
- * @name module:activities/textGrid/CrossWord.CrossWordPanel#icoBB
595
- * @type {module:boxes/BoxBase.BoxBase} */
596
- icoBB: new BoxBase["default"]().set('backColor', '#4285F4').set('inactiveColor', '#70A2F6').set('dontFill', true)
597
- });
598
-
599
- /**
600
- * Panel class associated to this type of activity: {@link module:activities/textGrid/CrossWord.CrossWordPanel CrossWordPanel}
601
- * @type {class} */
602
- CrossWord.Panel = CrossWordPanel;
603
-
604
- // Register activity class
605
- /* harmony default export */ const textGrid_CrossWord = (Activity/* Activity */.I.registerClass('@textGrid.CrossWord', CrossWord));
606
-
607
-
608
- /***/ }),
609
-
610
- /***/ 9205:
611
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
612
-
613
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
614
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
615
- /* harmony export */ });
616
- /* unused harmony export BoxBag */
617
- /* harmony import */ var _AbstractBox_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9513);
618
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7912);
619
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1253);
620
- /**
621
- * File : boxes/BoxBag.js
622
- * Created : 21/04/2015
623
- * By : Francesc Busquets <francesc@gmail.com>
624
- *
625
- * JClic.js
626
- * An HTML5 player of JClic activities
627
- * https://projectestac.github.io/jclic.js
628
- *
629
- * @source https://github.com/projectestac/jclic.js
630
- *
631
- * @license EUPL-1.2
632
- * @licstart
633
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
634
- *
635
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
636
- * the European Commission- subsequent versions of the EUPL (the "Licence");
637
- * You may not use this work except in compliance with the Licence.
638
- *
639
- * You may obtain a copy of the Licence at:
640
- * https://joinup.ec.europa.eu/software/page/eupl
641
- *
642
- * Unless required by applicable law or agreed to in writing, software
643
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
644
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
645
- * Licence for the specific language governing permissions and limitations
646
- * under the Licence.
647
- * @licend
648
- * @module
649
- */
650
-
651
-
652
-
653
-
654
-
655
- /**
656
- * BoxBag is a class derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox} that contains a collection of "boxes"
657
- * (objects also derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox}). This class implements methods to add, remove
658
- * and retrieve boxes, and to manage some of its properties like visibility, status, location and size.
659
- * @extends module:boxes/AbstractBox.AbstractBox
660
- */
661
- class BoxBag extends _AbstractBox_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
662
- /**
663
- * BoxBag constructor
664
- * @param {module:boxes/AbstractBox.AbstractBox} [parent] - The AbstractBox to which this box bag belongs
665
- * @param {module:AWT.Container} [container] - The container where this box bag is placed.
666
- * @param {module:boxes/BoxBase.BoxBase} [boxBase] - The object where colors, fonts, border and other graphic properties
667
- */
668
- constructor(parent, container, boxBase) {
669
- // BoxBag extends AbstractBox
670
- super(parent, container, boxBase);
671
- this.preferredBounds = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_();
672
- this.cells = [];
673
- }
674
-
675
- /**
676
- * Static method that sets the position and dimension of a `Resizable` object based on a
677
- * preferred maximum dimension and a margin.
678
- * @param {module:AWT.Dimension} preferredMaxSize - The preferred maximum size
679
- * @param {Resizable} rs - A resizable object implementing the methods described in the
680
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/boxes/Resizable.html Resizable}
681
- * interface of JClic. Currently a {@link module:boxes/BoxBag.BoxBag BoxBag} or {@link module:boxes/TextGrid.TextGrid TextGrid}.
682
- * @param {number} margin - The margin between the available area and the BoxBag
683
- * @returns {module:AWT.Dimension} - The resulting size of the container
684
- */
685
- static layoutSingle(preferredMaxSize, rs, margin) {
686
-
687
- // Avoid exceptions when rs is null
688
- if (!rs)
689
- return preferredMaxSize;
690
-
691
- // optimal, maximal and minimal dimensions
692
- let
693
- d = rs.getPreferredSize(),
694
- minSize = rs.getMinimumSize(),
695
- maxSize = preferredMaxSize;
696
-
697
- // remove margins
698
- maxSize.width -= 2 * margin;
699
- maxSize.height -= 2 * margin;
700
- // correct maxSize if less than minSize
701
- if (minSize.width > maxSize.width || minSize.height > maxSize.height) {
702
- maxSize = minSize;
703
- }
704
- // compute scale factor
705
- let scale = d.width > maxSize.width ? maxSize.width / d.width : 1;
706
- if (scale * d.height > maxSize.height)
707
- scale = maxSize.height / d.height;
708
-
709
- // resize the `Resizable` object
710
- d = rs.getScaledSize(scale);
711
- rs.setBounds(margin, margin, d.width, d.height);
712
-
713
- // restore margins
714
- d.width += 2 * margin;
715
- d.height += 2 * margin;
716
-
717
- return d;
718
- }
719
-
720
- /**
721
- * Static method that sets the position and dimension of two `Resizable` objects based on a
722
- * preferred maximum size, a layout schema and a margin.
723
- * @param {module:AWT.Dimension} desiredMaxSize - The preferred maximum size
724
- * @param {Resizable} rsA - First resizable object implementing the methods described in the
725
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/boxes/Resizable.html Resizable}
726
- * interface of JClic. Currently a {@link module:boxes/BoxBag.BoxBag BoxBag} or {@link module:boxes/TextGrid.TextGrid TextGrid}.
727
- * @param {Resizable} rsB - Second resizable object
728
- * @param {string} boxGridPos - The layout schema. Possible values are:
729
- * - "AB" (_A_ at left, _B_ at right)
730
- * - "BA" (_B_ at left, _A_ at right)
731
- * - "AUB" (_A_ above _B_)
732
- * - "BUA" (_A_ below _B_).
733
- * @param {number} margin - The margin between the available area and the BoxBag
734
- * @returns {module:AWT.Dimension} - The resulting size of the container
735
- */
736
- static layoutDouble(desiredMaxSize, rsA, rsB, boxGridPos, margin) {
737
- // number of horizontal and vertical grid lines
738
- let
739
- isHLayout = false,
740
- nbh = 1,
741
- nbv = 1;
742
- switch (boxGridPos) {
743
- case 'AB':
744
- case 'BA':
745
- nbh = 2;
746
- nbv = 1;
747
- isHLayout = true;
748
- break;
749
- case 'AUB':
750
- case 'BUA':
751
- nbh = 1;
752
- nbv = 2;
753
- isHLayout = false;
754
- break;
755
- }
756
- const
757
- ra = rsA.getBounds(),
758
- rb = rsB.getBounds();
759
-
760
- // optimal dimensions
761
- let
762
- da = rsA.getPreferredSize(),
763
- db = rsB.getPreferredSize();
764
-
765
- const d = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(
766
- isHLayout ? da.width + db.width : Math.max(da.width, db.width),
767
- isHLayout ? Math.max(da.height, db.height) : da.height + db.height
768
- );
769
-
770
- // minimal dimensions
771
- const
772
- minSizeA = rsA.getMinimumSize(),
773
- minSizeB = rsB.getMinimumSize(),
774
- minSize = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(
775
- isHLayout ? minSizeA.width + minSizeB.width : Math.max(minSizeA.width, minSizeB.width),
776
- isHLayout ? Math.max(minSizeA.height, minSizeB.height) : minSizeA.height + minSizeB.height
777
- ),
778
- maxSize = desiredMaxSize;
779
-
780
- // remove margins
781
- maxSize.width -= (1 + nbh) * margin;
782
- maxSize.height -= (1 + nbv) * margin;
783
-
784
- // correct maxSize if less than minSize
785
- if (minSize.width > maxSize.width || minSize.height > maxSize.height)
786
- maxSize.setDimension(minSize);
787
-
788
- // compute scale factor
789
- let scale = d.width > maxSize.width ? maxSize.width / d.width : 1;
790
- if (scale * d.height > maxSize.height)
791
- scale = maxSize.height / d.height;
792
-
793
- //
794
- // correct possible minimal infractions
795
- // ...
796
- // resize
797
- da = rsA.getScaledSize(scale);
798
- db = rsB.getScaledSize(scale);
799
-
800
- // set margins to center one box relative to the other
801
- let
802
- dah = db.width > da.width ? (db.width - da.width) / 2 : 0,
803
- dbh = da.width > db.width ? (da.width - db.width) / 2 : 0,
804
- dav = db.height > da.height ? (db.height - da.height) / 2 : 0,
805
- dbv = da.height > db.height ? (da.height - db.height) / 2 : 0;
806
-
807
- switch (boxGridPos) {
808
- case 'AB':
809
- rsA.setBounds(margin, margin + dav, da.width, da.height);
810
- rsB.setBounds(2 * margin + da.width, margin + dbv, db.width, db.height);
811
- break;
812
- case 'BA':
813
- rsB.setBounds(margin, margin + dbv, db.width, db.height);
814
- rsA.setBounds(2 * margin + db.width, margin + dav, da.width, da.height);
815
- break;
816
- case 'AUB':
817
- rsA.setBounds(margin + dah, margin, da.width, da.height);
818
- rsB.setBounds(margin + dbh, 2 * margin + da.height, db.width, db.height);
819
- break;
820
- case 'BUA':
821
- rsB.setBounds(margin + dbh, margin, db.width, db.height);
822
- rsA.setBounds(margin + dah, 2 * margin + db.height, da.width, da.height);
823
- break;
824
- default:
825
- rsA.setBounds(
826
- Math.round(margin + scale * ra.pos.x),
827
- Math.round(margin + scale * ra.pos.y),
828
- da.width, da.height);
829
- rsB.setBounds(
830
- Math.round(margin + scale * rb.pos.x),
831
- Math.round(margin + scale * rb.pos.y),
832
- da.width, da.height);
833
- break;
834
- }
835
-
836
- // recompute 'd' adding margins
837
- const r = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(rsA.getBounds());
838
- r.add(rsB.getBounds());
839
- d.width = r.dim.width + 2 * margin;
840
- d.height = r.dim.height + 2 * margin;
841
-
842
- return d;
843
- }
844
-
845
- /**
846
- * Gets the preferred size of this `BoxBag`
847
- * @returns {module:AWT.Dimension}
848
- */
849
- getPreferredSize() {
850
- return this.preferredBounds.dim;
851
- }
852
-
853
- /**
854
- * Gets the minimum size requested by this `BoxBag`
855
- * @returns {module:AWT.Dimension}
856
- */
857
- getMinimumSize() {
858
- const d = this.getPreferredSize();
859
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(
860
- Math.max(_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .settings */ .W0.MIN_CELL_SIZE, d.width),
861
- Math.max(_Utils_js__WEBPACK_IMPORTED_MODULE_2__/* .settings */ .W0.MIN_CELL_SIZE, d.height));
862
- }
863
-
864
- /**
865
- * Scales the current size of this box bag, multiplying all values by a specific factor
866
- * @param {number} scale - The scale factor
867
- * @returns {module:AWT.Dimension}
868
- */
869
- getScaledSize(scale) {
870
- const d = this.getPreferredSize();
871
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Dimension */ .fg(Math.round(scale * d.width), Math.round(scale * d.height));
872
- }
873
-
874
- /**
875
- * Adds an {@link module:boxes/AbstractBox.AbstractBox AbstractBox} to the collection of cells
876
- * @param {module:boxes/AbstractBox.AbstractBox} bx - The box to add
877
- */
878
- addBox(bx) {
879
- this.cells.push(bx);
880
- bx.setParent(this);
881
-
882
- if (this.cells.length === 1)
883
- _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_.prototype.setBounds.call(this, bx);
884
- else
885
- this.add(bx);
886
-
887
- this.preferredBounds.setBounds(this.getBounds());
888
- }
889
-
890
- /**
891
- * Returns the index of a specific box in the `cells` array
892
- * @param {module:boxes/AbstractBox.AbstractBox} bx
893
- * @returns {number}
894
- */
895
- boxIndex(bx) {
896
- return bx === null ? -1 : this.cells.indexOf(bx);
897
- }
898
-
899
- /**
900
- * Returns the box at a specific index in the `cells` array
901
- * @param {number} n - The index
902
- * @returns {module:boxes/AbstractBox.AbstractBox}
903
- */
904
- getBox(n) {
905
- return n < 0 || n >= this.cells.length ? null : this.cells[n];
906
- }
907
-
908
- /**
909
- * Gets the background box
910
- * @returns {module:boxes/AbstractBox.AbstractBox}
911
- */
912
- getBackgroundBox() {
913
- return this.backgroundBox;
914
- }
915
-
916
- /**
917
- * Sets the background box
918
- * @param {module:boxes/AbstractBox.AbstractBox} bx
919
- */
920
- setBackgroundBox(bx) {
921
- this.backgroundBox = bx;
922
- if (bx !== null) {
923
- bx.setParent(this);
924
- bx.isBackground = true;
925
- }
926
- // Add the `backgroundbox` rectangle to the global BoxBag rectangle
927
- _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_.prototype.add.call(this, bx);
928
- this.preferredBounds.setBounds(this.getBounds());
929
- }
930
-
931
- /**
932
- * Recalculates the total size of this BoxBag (useful after direct additions o deletions of
933
- * elements in the `cells` array).
934
- * Updates `preferredBounds` and the current position and size of the box bag.
935
- */
936
- recalcSize() {
937
- let r = this.backgroundBox ? new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(this.backgroundBox.pos, this.backgroundBox.dim) : null;
938
- this.cells.forEach(cell => {
939
- if (!r)
940
- r = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(cell.pos, cell.dim);
941
- else
942
- r.add(cell);
943
- });
944
- if (!r)
945
- r = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(this.pos.x, this.pos.y, 0, 0);
946
- this.preferredBounds.setRect(r);
947
- this.x = r.pos.x;
948
- this.y = r.pos.y;
949
- this.dim.width = r.dim.width;
950
- this.dim.height = r.dim.height;
951
- }
952
-
953
- /**
954
- * Returns the number of cells stored in this BoxBag
955
- * @returns {number}
956
- */
957
- getNumCells() {
958
- return this.cells.length;
959
- }
960
-
961
- /**
962
- * Sets the specified key - value pair to all cells of this bag.
963
- * @param {string} key - The key to be established
964
- * @param {any} value - The value, of any type
965
- */
966
- setCellAttr(key, value) {
967
- this.cells.forEach(bx => bx[key] = value);
968
- if (this.backgroundBox)
969
- this.backgroundBox[key] = value;
970
- }
971
-
972
- /**
973
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setBorder} iterating over all the cells stored in this box bag.
974
- * @override
975
- * @param {boolean} newVal - Whether to set or unset the border
976
- */
977
- setBorder(newVal) {
978
- this.cells.forEach(bx => bx.setBorder(newVal));
979
- }
980
-
981
- /**
982
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setVisible} iterating over all the cells stored in this box bag.
983
- * @override
984
- * @param {boolean} newVal - Whether to set the cells visible or not
985
- */
986
- setVisible(newVal) {
987
- this.cells.forEach(bx => bx.setVisible(newVal));
988
- }
989
-
990
- /**
991
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setAlternative} iterating over all the cells stored in this box bag.
992
- * @override
993
- * @param {boolean} newVal - Whether to set or unset the cells in "alternative" mode
994
- */
995
- setAlternative(newVal) {
996
- super.setAlternative(newVal);
997
- this.cells.forEach(bx => bx.setAlternative(newVal));
998
- }
999
-
1000
- /**
1001
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#setBounds} adjusting the position and size of all cells
1002
- * @override
1003
- * @param {(AWT.Rectangle|number)} rect - An AWT.Rectangle object, or the `x` coordinate of the
1004
- * upper-left corner of a new rectangle.
1005
- * @param {number} [ry] - `y` coordinate of the upper-left corner of the new rectangle.
1006
- * @param {number} [rw] - Width of the new rectangle.
1007
- * @param {number} [rh] - Height of the new rectangle.
1008
- */
1009
- setBounds(rect, ry, rw, rh) {
1010
- if (typeof rect === 'number') {
1011
- // Arguments are co-ordinates and size
1012
- rect = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(rect, ry, rw, rh);
1013
- }
1014
- if (rect.getSurface() > 0 && !rect.equals(this)) {
1015
- const
1016
- scaleW = rect.dim.width / this.dim.width,
1017
- scaleH = rect.dim.height / this.dim.height,
1018
- dx = rect.pos.x - this.pos.x,
1019
- dy = rect.pos.y - this.pos.y;
1020
- this.cells.forEach(bx => {
1021
- const p = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Point */ .bR(bx.pos.x - this.pos.x, bx.pos.y - this.pos.y);
1022
- bx.setBounds(
1023
- dx + this.pos.x + scaleW * p.x,
1024
- dy + this.pos.y + scaleH * p.y,
1025
- scaleW * bx.dim.width,
1026
- scaleH * bx.dim.height);
1027
- // Clear pos0
1028
- bx.pos0 = null;
1029
- });
1030
- if (this.backgroundBox !== null) {
1031
- const
1032
- bx = this.backgroundBox,
1033
- p = new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Point */ .bR(bx.pos.x - this.pos.x, bx.pos.y - this.pos.y);
1034
- bx.setBounds(
1035
- dx + this.pos.x + scaleW * p.x,
1036
- dy + this.pos.y + scaleH * p.y,
1037
- scaleW * bx.dim.width,
1038
- scaleH * bx.dim.height);
1039
- }
1040
- }
1041
- super.setBounds(rect);
1042
- }
1043
-
1044
- /**
1045
- * Performs graphics operations for each cell.
1046
- * Overrides {@link module:boxes/AbstractBox.AbstractBox#update}
1047
- * @override
1048
- * @param {external:CanvasRenderingContext2D} ctx - The canvas rendering context used to draw the
1049
- * box contents.
1050
- * @param {module:AWT.Rectangle} [dirtyRegion] - The area that must be repainted. `null` refers to the whole box.
1051
- */
1052
- update(ctx, dirtyRegion) {
1053
- if (this.isEmpty() || !this.isVisible() || this.isTemporaryHidden())
1054
- return false;
1055
-
1056
- if (dirtyRegion && !this.intersects(dirtyRegion))
1057
- return false;
1058
-
1059
- if (this.backgroundBox !== null)
1060
- this.backgroundBox.update(ctx, dirtyRegion);
1061
-
1062
- this.cells.forEach(bx => {
1063
- if (!bx.isMarked())
1064
- bx.update(ctx, dirtyRegion);
1065
- });
1066
-
1067
- // Make a second loop to repaint marked cells
1068
- this.cells.forEach(bx => {
1069
- if (bx.isMarked())
1070
- bx.update(ctx, dirtyRegion);
1071
- });
1072
- return true;
1073
- }
1074
-
1075
- /**
1076
- * Finds the first visible {@link module:boxes/AbstractBox.AbstractBox AbstractBox} located under the specified point
1077
- * @param {module:AWT.Point} p
1078
- * @returns {module:boxes/AbstractBox.AbstractBox}
1079
- */
1080
- findBox(p) {
1081
- let result = null;
1082
- for (let i = this.cells.length - 1; i >= 0; i--) {
1083
- const bx = this.getBox(i);
1084
- if (bx.isVisible() && bx.contains(p)) {
1085
- result = bx;
1086
- break;
1087
- }
1088
- }
1089
- return result;
1090
- }
1091
-
1092
- /**
1093
- * Count the number of cells of this BoxBag that are in "inactive" state
1094
- * @returns {number}
1095
- */
1096
- countInactiveCells() {
1097
- return this.cells.reduce((n, bx) => bx.isInactive() ? ++n : n, 0);
1098
- }
1099
- }
1100
-
1101
- Object.assign(BoxBag.prototype, {
1102
- /**
1103
- * The array of cells
1104
- * @name module:boxes/BoxBag.BoxBag#cells
1105
- * @type {module:boxes/AbstractBox.AbstractBox[]} */
1106
- cells: [],
1107
- /**
1108
- * Rectangle containing the preferred bounds of the BoxBag
1109
- * @name module:boxes/BoxBag.BoxBag#preferredBounds
1110
- * @type {module:AWT.Rectangle} */
1111
- preferredBounds: new _AWT_js__WEBPACK_IMPORTED_MODULE_1__/* .Rectangle */ .M_(),
1112
- /**
1113
- * An optional box used as a background by this BoxBag
1114
- * @name module:boxes/BoxBag.BoxBag#backgroundBox
1115
- * @type {module:boxes/AbstractBox.AbstractBox} */
1116
- backgroundBox: null,
1117
- });
1118
-
1119
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BoxBag);
1120
-
1121
-
1122
- /***/ })
1123
-
1124
- };
1125
- ;
1126
- //# sourceMappingURL=5312.jclic-node.js.map