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,481 +0,0 @@
1
- "use strict";
2
- exports.id = 6176;
3
- exports.ids = [6176,7781];
4
- exports.modules = {
5
-
6
- /***/ 6176:
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 InformationScreen, InformationScreenPanel */
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 _Activity_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1567);
16
- /* harmony import */ var _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7781);
17
- /* harmony import */ var _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9205);
18
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7912);
19
- /**
20
- * File : activities/panels/InformationScreen.js
21
- * Created : 19/05/2015
22
- * By : Francesc Busquets <francesc@gmail.com>
23
- *
24
- * JClic.js
25
- * An HTML5 player of JClic activities
26
- * https://projectestac.github.io/jclic.js
27
- *
28
- * @source https://github.com/projectestac/jclic.js
29
- *
30
- * @license EUPL-1.2
31
- * @licstart
32
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
33
- *
34
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
35
- * the European Commission- subsequent versions of the EUPL (the "Licence");
36
- * You may not use this work except in compliance with the Licence.
37
- *
38
- * You may obtain a copy of the Licence at:
39
- * https://joinup.ec.europa.eu/software/page/eupl
40
- *
41
- * Unless required by applicable law or agreed to in writing, software
42
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
43
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
44
- * Licence for the specific language governing permissions and limitations
45
- * under the Licence.
46
- * @licend
47
- * @module
48
- */
49
-
50
- /* global window */
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
- /**
59
- * This class of {@link module:Activity.Activity Activity} just shows a panel with {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
60
- * Because active boxes can act as a links to specific points in the project's sequence of
61
- * activities, this kind of activity is often used as a menu where users can choose from different
62
- * options.
63
- * @extends module:Activity.Activity
64
- */
65
- class InformationScreen extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I {
66
- /**
67
- * InformationScreen constructor
68
- * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
69
- */
70
- constructor(project) {
71
- super(project);
72
- // This kind of activities are not reported
73
- this.includeInReports = false;
74
- this.reportActions = false;
75
- }
76
- }
77
-
78
- /**
79
- * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/panels/InformationScreen.InformationScreen InformationScreen} activities should display its content
80
- * @extends module:Activity.ActivityPanel
81
- */
82
- class InformationScreenPanel extends _Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .ActivityPanel */ .S {
83
- /**
84
- * InformationScreenPanel constructor
85
- * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
86
- * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
87
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
88
- * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
89
- */
90
- constructor(act, ps, $div) {
91
- super(act, ps, $div);
92
- }
93
-
94
- /**
95
- * Miscellaneous cleaning operations
96
- * @override
97
- */
98
- clear() {
99
- if (this.bg) {
100
- this.bg.end();
101
- this.bg = null;
102
- }
103
- }
104
-
105
- /**
106
- * Prepares the visual components of the activity
107
- * @override
108
- */
109
- buildVisualComponents() {
110
- if (this.firstRun)
111
- super.buildVisualComponents();
112
- this.clear();
113
- const abc = this.act.abc['primary'];
114
- if (abc) {
115
- if (abc.image) {
116
- abc.setImgContent(this.act.project.mediaBag, null, false);
117
- if (abc.animatedGifFile && !abc.shaper.rectangularShapes)
118
- this.$animatedBg = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<span/>').css({
119
- 'background-image': `url(${abc.animatedGifFile})`,
120
- 'background-position': 'center',
121
- 'background-repeat': 'no-repeat',
122
- position: 'absolute'
123
- }).appendTo(this.$div);
124
- }
125
-
126
- if (this.act.acp !== null)
127
- this.act.acp.generateContent(abc.nch, abc.ncw, [abc], false);
128
-
129
- this.bg = _boxes_ActiveBoxGrid_js__WEBPACK_IMPORTED_MODULE_2__["default"].createEmptyGrid(null, this,
130
- this.act.margin, this.act.margin,
131
- abc);
132
- this.bg.setContent(abc);
133
- if (this.$animatedBg)
134
- this.bg.setCellAttr('tmpTrans', true);
135
- this.bg.setVisible(true);
136
- }
137
- }
138
-
139
- /**
140
- * Basic initialization procedure
141
- * @override
142
- */
143
- initActivity() {
144
- super.initActivity();
145
- if (!this.firstRun)
146
- this.buildVisualComponents();
147
- else
148
- this.firstRun = false;
149
-
150
- this.invalidate().update();
151
- this.setAndPlayMsg('initial', 'start');
152
- this.playing = true;
153
- }
154
-
155
- /**
156
- * Updates the graphic content of this panel.
157
- * This method will be called from {@link module:AWT.Container#update} when needed.
158
- * @override
159
- * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
160
- * it's the whole panel.
161
- */
162
- updateContent(dirtyRegion) {
163
- super.updateContent(dirtyRegion);
164
- if (this.bg && this.$canvas) {
165
- const
166
- canvas = this.$canvas.get(-1),
167
- ctx = canvas.getContext('2d');
168
- if (!dirtyRegion)
169
- dirtyRegion = new _AWT_js__WEBPACK_IMPORTED_MODULE_4__/* .Rectangle */ .M_(0, 0, canvas.width, canvas.height);
170
- ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
171
- this.bg.update(ctx, dirtyRegion);
172
- }
173
- return this;
174
- }
175
-
176
- /**
177
- * Sets the real dimension of this panel.
178
- * @override
179
- * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
180
- * @returns {module:AWT.Dimension}
181
- */
182
- setDimension(preferredMaxSize) {
183
- return this.getBounds().equals(preferredMaxSize) ?
184
- preferredMaxSize :
185
- _boxes_BoxBag_js__WEBPACK_IMPORTED_MODULE_3__["default"].layoutSingle(preferredMaxSize, this.bg, this.act.margin);
186
- }
187
-
188
- /**
189
- * Sets the size and position of this activity panel
190
- * @override
191
- * @param {module:AWT.Rectangle} rect
192
- */
193
- setBounds(rect) {
194
- if (this.$canvas)
195
- this.$canvas.remove();
196
-
197
- super.setBounds(rect);
198
- if (this.bg) {
199
- this.$canvas = jquery__WEBPACK_IMPORTED_MODULE_0___default()('<canvas width="' + rect.dim.width + '" height="' + rect.dim.height + '"/>').css({
200
- position: 'absolute',
201
- top: 0,
202
- left: 0
203
- });
204
- // Resize animated gif background
205
- if (this.$animatedBg) {
206
- const bgRect = this.bg.getBounds();
207
- this.$animatedBg.css({
208
- left: bgRect.pos.x,
209
- top: bgRect.pos.y,
210
- width: `${bgRect.dim.width}px`,
211
- height: `${bgRect.dim.height}px`,
212
- 'background-size': `${bgRect.dim.width}px ${bgRect.dim.height}px`
213
- });
214
- }
215
- this.$div.append(this.$canvas);
216
- this.invalidate().update();
217
- window.setTimeout(() => this.bg ? this.bg.buildAccessibleElements(this.$canvas, this.$div) : null, 0);
218
- }
219
- }
220
-
221
- /**
222
- * Builds the accessible components needed for this ActivityPanel
223
- * This method is called when all main elements are placed and visible, when the activity is ready
224
- * to start or when resized.
225
- * @override
226
- */
227
- buildAccessibleComponents() {
228
- if (this.$canvas && this.accessibleCanvas && this.bg) {
229
- super.buildAccessibleComponents();
230
- this.bg.buildAccessibleElements(this.$canvas, this.$div);
231
- }
232
- }
233
-
234
- /**
235
- * Main handler used to process mouse, touch, keyboard and edit events
236
- * @override
237
- * @param {external:Event} event - The HTML event to be processed
238
- * @returns {boolean} - When this event handler returns `false`, jQuery will stop its
239
- * propagation through the DOM tree. See: {@link http://api.jquery.com/on}
240
- */
241
- processEvent(event) {
242
- if (this.playing) {
243
- const p = new _AWT_js__WEBPACK_IMPORTED_MODULE_4__/* .Point */ .bR(
244
- event.pageX - this.$div.offset().left,
245
- event.pageY - this.$div.offset().top);
246
- // Array to be filled with actions to be executed at the end of event processing
247
- const delayedActions = [];
248
- this.ps.stopMedia(1);
249
- const bx = this.bg.findActiveBox(p);
250
- if (bx) {
251
- if (!bx.playMedia(this.ps, delayedActions))
252
- this.playEvent('click');
253
- }
254
- delayedActions.forEach(action => action());
255
- event.preventDefault();
256
- }
257
- }
258
- }
259
-
260
- Object.assign(InformationScreenPanel.prototype, {
261
- /**
262
- * The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} containing the information to be displayed.
263
- * @name module:activities/panels/InformationScreen.InformationScreenPanel#bg
264
- * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
265
- bg: null,
266
- /**
267
- * List of mouse, touch and keyboard events intercepted by this panel
268
- * @override
269
- * @name module:activities/panels/InformationScreen.InformationScreenPanel#events
270
- * @type {string[]} */
271
- events: ['click'],
272
- });
273
-
274
- /**
275
- * Panel class associated to this type of activity: {@link module:activities/panels/InformationScreen.InformationScreenPanel InformationScreenPanel}
276
- * @type {class} */
277
- InformationScreen.Panel = InformationScreenPanel;
278
-
279
- // Register activity class
280
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_Activity_js__WEBPACK_IMPORTED_MODULE_1__/* .Activity */ .I.registerClass('@panels.InformationScreen', InformationScreen));
281
-
282
-
283
- /***/ }),
284
-
285
- /***/ 7781:
286
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
287
-
288
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
289
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
290
- /* harmony export */ });
291
- /* unused harmony export ActiveBoxGrid */
292
- /* harmony import */ var _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(427);
293
- /* harmony import */ var _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1725);
294
- /* harmony import */ var _AWT_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7912);
295
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1253);
296
- /**
297
- * File : boxes/ActiveBoxGrid.js
298
- * Created : 19/05/2015
299
- * By : Francesc Busquets <francesc@gmail.com>
300
- *
301
- * JClic.js
302
- * An HTML5 player of JClic activities
303
- * https://projectestac.github.io/jclic.js
304
- *
305
- * @source https://github.com/projectestac/jclic.js
306
- *
307
- * @license EUPL-1.2
308
- * @licstart
309
- * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)
310
- *
311
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
312
- * the European Commission- subsequent versions of the EUPL (the "Licence");
313
- * You may not use this work except in compliance with the Licence.
314
- *
315
- * You may obtain a copy of the Licence at:
316
- * https://joinup.ec.europa.eu/software/page/eupl
317
- *
318
- * Unless required by applicable law or agreed to in writing, software
319
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
320
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
321
- * Licence for the specific language governing permissions and limitations
322
- * under the Licence.
323
- * @licend
324
- * @module
325
- */
326
-
327
-
328
-
329
-
330
-
331
-
332
- /**
333
- * This class extends {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with constructors that take an argument of type
334
- * {@link module:shapers/Shaper.Shaper Shaper} used to build all its {@link module:boxes/ActiveBox.ActiveBox ActiveBox}components. It also maintains information
335
- * about the number of "rows" and "columns", useful to compute valid (integer) values when
336
- * resizing or moving its components.
337
- * @extends module:boxes/ActiveBoxBag.ActiveBoxBag
338
- */
339
- class ActiveBoxGrid extends _ActiveBoxBag_js__WEBPACK_IMPORTED_MODULE_0__["default"] {
340
- /**
341
- * ActiveBxGrid constructor
342
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
343
- * @param {module:AWT.Container} container - The container where this box grid is placed.
344
- * @param {module:boxes/BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
345
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
346
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
347
- * @param {number} setWidth - Total width of the box grid
348
- * @param {number} setHeight - Total height of the box grid
349
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
350
- */
351
- constructor(parent, container, boxBase, px, py, setWidth, setHeight, sh) {
352
- // ActiveBoxGrid derives from ActiveBoxBag
353
- super(parent, container, boxBase);
354
-
355
- this.nCols = sh.nCols;
356
- this.nRows = sh.nRows;
357
-
358
- // This will be the enclosing rectangle of this ActiveBox bag
359
- const r = new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Rectangle */ .M_(
360
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(px, py),
361
- new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
362
- Math.round(setWidth / this.nCols) * this.nCols,
363
- Math.round(setHeight / this.nRows) * this.nRows));
364
-
365
- // Create all the [ActiveBox](ActiveBox.html) objects based on the
366
- // shapes provided by the [Shaper](Shaper.html)
367
- for (let i = 0; i < sh.nCells; i++) {
368
- const
369
- tmpSh = sh.getShape(i, r),
370
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, i, tmpSh.getBounds());
371
- if (!sh.rectangularShapes)
372
- bx.setShape(tmpSh);
373
- this.addActiveBox(bx);
374
- }
375
-
376
- // If the Shaper has `remainder` (extra space), set the background box of this
377
- // [BoxBag](BoxBag.html)
378
- if (sh.hasRemainder) {
379
- const
380
- tmpSh = sh.getRemainderShape(r),
381
- bx = new _ActiveBox_js__WEBPACK_IMPORTED_MODULE_1__["default"](this, container, boxBase, 0, tmpSh.getBounds());
382
- bx.setShape(tmpSh);
383
- this.setBackgroundBox(bx);
384
- }
385
- }
386
-
387
- /**
388
- * This factory constructor creates a new empty grid with the number of cells indicated by the
389
- * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} `abc`, not filling the cells with any content.
390
- * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs
391
- * @param {module:AWT.Container} container - The container where this box grid is placed.
392
- * @param {number} px - `X` coordinate of the upper left corner of this box grid
393
- * @param {number} py - `Y` coordinate of the upper left corner of this box grid
394
- * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - Used only to get the number of cells and the shaper (when `sh` is `null`)
395
- * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects
396
- * @param {module:boxes/BoxBase.BoxBase} boxBase - The object where colors, fonts, border and other graphic properties
397
- * of this box grid are defined.
398
- * @returns {module:boxes/ActiveBoxGrid.ActiveBoxGrid}
399
- */
400
- static createEmptyGrid(parent, container, px, py, abc, sh, boxBase) {
401
- const result = abc ? new ActiveBoxGrid(parent, container,
402
- boxBase || abc.style,
403
- px, py,
404
- abc.getTotalWidth(), abc.getTotalHeight(),
405
- sh || abc.getShaper()) : null;
406
-
407
- if (result)
408
- result.setBorder(abc.border);
409
-
410
- return result;
411
- }
412
-
413
- /**
414
- * Gets the minimum size of this grid
415
- * @returns {module:AWT.Dimension}
416
- */
417
- getMinimumSize() {
418
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
419
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nCols,
420
- _Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .settings */ .W0.MIN_CELL_SIZE * this.nRows);
421
- }
422
-
423
- /**
424
- * Gets a scaled size of this grid, rounded to the nearest integer values
425
- * @param {number} scale - The scale factor
426
- * @returns {module:AWT.Dimension}
427
- */
428
- getScaledSize(scale) {
429
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Dimension */ .fg(
430
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.width, this.nCols),
431
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__/* .roundTo */ .GB)(scale * this.preferredBounds.dim.height, this.nRows));
432
- }
433
-
434
- /**
435
- * Returns the logical coordinates of the provided {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.
436
- * The units of the result are not pixels, but ordinal numbers (relative positions) of columns
437
- * and rows in the grid.
438
- * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to process
439
- * @returns {module:AWT.Point}
440
- */
441
- getCoord(bx) {
442
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(bx.idLoc % this.nCols, Math.floor(bx.idLoc / this.nCols));
443
- }
444
-
445
- /**
446
- * Calculates the logical distance between two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
447
- * Resulting units are not pixels, but ordinal numbers (relative positions) of columns and rows
448
- * in the grid.
449
- * @param {module:boxes/ActiveBox.ActiveBox} src - First box
450
- * @param {module:boxes/ActiveBox.ActiveBox} dest - Second box
451
- * @returns {module:AWT.Point}
452
- */
453
- getCoordDist(src, dest) {
454
- const
455
- ptSrc = this.getCoord(src),
456
- ptDest = this.getCoord(dest);
457
- return new _AWT_js__WEBPACK_IMPORTED_MODULE_2__/* .Point */ .bR(ptDest.x - ptSrc.x, ptDest.y - ptSrc.y);
458
- }
459
- }
460
-
461
- Object.assign(ActiveBoxGrid.prototype, {
462
- /**
463
- * Number of columns of this box grid
464
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nCols
465
- * @type {number} */
466
- nCols: 1,
467
- /**
468
- * Number of rows of this box grid
469
- * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nRows
470
- * @type {number} */
471
- nRows: 1,
472
- });
473
-
474
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveBoxGrid);
475
-
476
-
477
- /***/ })
478
-
479
- };
480
- ;
481
- //# sourceMappingURL=6176.jclic-node.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"6176.jclic-node.js","mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEuB;AACqC;AACH;AACd;AACK;;AAEhD;AACA,kBAAkB,yCAAyC,yBAAyB,kDAAkD;AACtI;AACA;AACA;AACA;AACA;AACO,gCAAgC,2DAAQ;AAC/C;AACA;AACA,aAAa,0CAA0C,eAAe,6DAA6D;AACnI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAQ,mDAAmD,OAAO,sFAAsF;AACxJ;AACA;AACO,qCAAqC,gEAAa;AACzD;AACA;AACA,aAAa,0BAA0B,WAAW,yCAAyC;AAC3F,aAAa,gCAAgC;AAC7C;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,6CAAC;AAC9B,uCAAuC,oBAAoB;AAC3D;AACA;AACA;AACA,WAAW;AACX;;AAEA;AACA;;AAEA,gBAAgB,+DAAa;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,sCAAsC,mCAAmC;AACzE;AACA,aAAa,sBAAsB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,wDAAS;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC,eAAe;AACf;AACA;AACA;AACA;AACA,MAAM,wDAAM;AACZ;;AAEA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA,qBAAqB,6CAAC;AACtB;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,iBAAiB;AACrC,qBAAqB,kBAAkB;AACvC,gCAAgC,iBAAiB,KAAK,kBAAkB;AACxE,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,gBAAgB;AAC7B,eAAe,SAAS;AACxB,6CAA6C;AAC7C;AACA;AACA;AACA,oBAAoB,oDAAK;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU,2DAA2D;AACrE;AACA,YAAY,wCAAwC;AACpD;AACA;AACA;AACA;AACA;AACA,YAAY,UAAU;AACtB;AACA,CAAC;;AAED;AACA,qDAAqD;AACrD,UAAU,OAAO;AACjB;;AAEA;AACA,iEAAe,2DAAQ,8DAA8D,EAAC;;;;;;;;;;;;;;;;ACrQtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAE6C;AACN;AACiB;AACR;;AAEhD;AACA,uBAAuB,2DAA2D;AAClF,IAAI,2CAA2C,uBAAuB,iDAAiD;AACvH;AACA;AACA;AACA;AACO,4BAA4B,wDAAY;AAC/C;AACA;AACA,aAAa,sCAAsC;AACnD,aAAa,sBAAsB;AACnC,aAAa,sBAAsB;AACnC,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,8BAA8B;AAC3C;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,kBAAkB,wDAAS;AAC3B,UAAU,oDAAK;AACf,UAAU,wDAAS;AACnB;AACA;;AAEA;AACA;AACA,oBAAoB,eAAe;AACnC;AACA;AACA,iBAAiB,qDAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,qDAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM,uEAAuE;AAC7E,aAAa,sCAAsC;AACnD,aAAa,sBAAsB;AACnC,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,gDAAgD;AAC7D,aAAa,8BAA8B;AAC3C,aAAa,8BAA8B;AAC3C;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA,eAAe,wDAAS;AACxB,MAAM,yDAAQ;AACd,MAAM,yDAAQ;AACd;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,eAAe,wDAAS;AACxB,MAAM,4DAAO;AACb,MAAM,4DAAO;AACb;;AAEA;AACA,sDAAsD,iDAAiD;AACvG;AACA;AACA,aAAa,kCAAkC;AAC/C,eAAe;AACf;AACA;AACA,eAAe,oDAAK;AACpB;;AAEA;AACA,kDAAkD,kDAAkD;AACpG;AACA;AACA,aAAa,kCAAkC;AAC/C,aAAa,kCAAkC;AAC/C,eAAe;AACf;AACA;AACA;AACA;AACA;AACA,eAAe,oDAAK;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA,CAAC;;AAED,iEAAe,aAAa,EAAC","sources":["webpack://jclic/./src/activities/panels/InformationScreen.js","webpack://jclic/./src/boxes/ActiveBoxGrid.js"],"sourcesContent":["/**\n * File : activities/panels/InformationScreen.js\n * Created : 19/05/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\n/* global window */\n\nimport $ from 'jquery';\nimport { Activity, ActivityPanel } from '../../Activity.js';\nimport ActiveBoxGrid from '../../boxes/ActiveBoxGrid.js';\nimport BoxBag from '../../boxes/BoxBag.js';\nimport { Rectangle, Point } from '../../AWT.js';\n\n/**\n * This class of {@link module:Activity.Activity Activity} just shows a panel with {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.\n * Because active boxes can act as a links to specific points in the project's sequence of\n * activities, this kind of activity is often used as a menu where users can choose from different\n * options.\n * @extends module:Activity.Activity\n */\nexport class InformationScreen extends Activity {\n /**\n * InformationScreen constructor\n * @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs\n */\n constructor(project) {\n super(project);\n // This kind of activities are not reported\n this.includeInReports = false;\n this.reportActions = false;\n }\n}\n\n/**\n * The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/panels/InformationScreen.InformationScreen InformationScreen} activities should display its content\n * @extends module:Activity.ActivityPanel\n */\nexport class InformationScreenPanel extends ActivityPanel {\n /**\n * InformationScreenPanel constructor\n * @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs\n * @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the\n * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.\n * @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy\n */\n constructor(act, ps, $div) {\n super(act, ps, $div);\n }\n\n /**\n * Miscellaneous cleaning operations\n * @override\n */\n clear() {\n if (this.bg) {\n this.bg.end();\n this.bg = null;\n }\n }\n\n /**\n * Prepares the visual components of the activity\n * @override\n */\n buildVisualComponents() {\n if (this.firstRun)\n super.buildVisualComponents();\n this.clear();\n const abc = this.act.abc['primary'];\n if (abc) {\n if (abc.image) {\n abc.setImgContent(this.act.project.mediaBag, null, false);\n if (abc.animatedGifFile && !abc.shaper.rectangularShapes)\n this.$animatedBg = $('<span/>').css({\n 'background-image': `url(${abc.animatedGifFile})`,\n 'background-position': 'center',\n 'background-repeat': 'no-repeat',\n position: 'absolute'\n }).appendTo(this.$div);\n }\n\n if (this.act.acp !== null)\n this.act.acp.generateContent(abc.nch, abc.ncw, [abc], false);\n\n this.bg = ActiveBoxGrid.createEmptyGrid(null, this,\n this.act.margin, this.act.margin,\n abc);\n this.bg.setContent(abc);\n if (this.$animatedBg)\n this.bg.setCellAttr('tmpTrans', true);\n this.bg.setVisible(true);\n }\n }\n\n /**\n * Basic initialization procedure\n * @override\n */\n initActivity() {\n super.initActivity();\n if (!this.firstRun)\n this.buildVisualComponents();\n else\n this.firstRun = false;\n\n this.invalidate().update();\n this.setAndPlayMsg('initial', 'start');\n this.playing = true;\n }\n\n /**\n * Updates the graphic content of this panel.\n * This method will be called from {@link module:AWT.Container#update} when needed.\n * @override\n * @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,\n * it's the whole panel.\n */\n updateContent(dirtyRegion) {\n super.updateContent(dirtyRegion);\n if (this.bg && this.$canvas) {\n const\n canvas = this.$canvas.get(-1),\n ctx = canvas.getContext('2d');\n if (!dirtyRegion)\n dirtyRegion = new Rectangle(0, 0, canvas.width, canvas.height);\n ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);\n this.bg.update(ctx, dirtyRegion);\n }\n return this;\n }\n\n /**\n * Sets the real dimension of this panel.\n * @override\n * @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel\n * @returns {module:AWT.Dimension}\n */\n setDimension(preferredMaxSize) {\n return this.getBounds().equals(preferredMaxSize) ?\n preferredMaxSize :\n BoxBag.layoutSingle(preferredMaxSize, this.bg, this.act.margin);\n }\n\n /**\n * Sets the size and position of this activity panel\n * @override\n * @param {module:AWT.Rectangle} rect\n */\n setBounds(rect) {\n if (this.$canvas)\n this.$canvas.remove();\n\n super.setBounds(rect);\n if (this.bg) {\n this.$canvas = $('<canvas width=\"' + rect.dim.width + '\" height=\"' + rect.dim.height + '\"/>').css({\n position: 'absolute',\n top: 0,\n left: 0\n });\n // Resize animated gif background\n if (this.$animatedBg) {\n const bgRect = this.bg.getBounds();\n this.$animatedBg.css({\n left: bgRect.pos.x,\n top: bgRect.pos.y,\n width: `${bgRect.dim.width}px`,\n height: `${bgRect.dim.height}px`,\n 'background-size': `${bgRect.dim.width}px ${bgRect.dim.height}px`\n });\n }\n this.$div.append(this.$canvas);\n this.invalidate().update();\n window.setTimeout(() => this.bg ? this.bg.buildAccessibleElements(this.$canvas, this.$div) : null, 0);\n }\n }\n\n /**\n * Builds the accessible components needed for this ActivityPanel\n * This method is called when all main elements are placed and visible, when the activity is ready\n * to start or when resized.\n * @override\n */\n buildAccessibleComponents() {\n if (this.$canvas && this.accessibleCanvas && this.bg) {\n super.buildAccessibleComponents();\n this.bg.buildAccessibleElements(this.$canvas, this.$div);\n }\n }\n\n /**\n * Main handler used to process mouse, touch, keyboard and edit events\n * @override\n * @param {external:Event} event - The HTML event to be processed\n * @returns {boolean} - When this event handler returns `false`, jQuery will stop its\n * propagation through the DOM tree. See: {@link http://api.jquery.com/on}\n */\n processEvent(event) {\n if (this.playing) {\n const p = new Point(\n event.pageX - this.$div.offset().left,\n event.pageY - this.$div.offset().top);\n // Array to be filled with actions to be executed at the end of event processing\n const delayedActions = [];\n this.ps.stopMedia(1);\n const bx = this.bg.findActiveBox(p);\n if (bx) {\n if (!bx.playMedia(this.ps, delayedActions))\n this.playEvent('click');\n }\n delayedActions.forEach(action => action());\n event.preventDefault();\n }\n }\n}\n\nObject.assign(InformationScreenPanel.prototype, {\n /**\n * The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} containing the information to be displayed.\n * @name module:activities/panels/InformationScreen.InformationScreenPanel#bg\n * @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */\n bg: null,\n /**\n * List of mouse, touch and keyboard events intercepted by this panel\n * @override\n * @name module:activities/panels/InformationScreen.InformationScreenPanel#events\n * @type {string[]} */\n events: ['click'],\n});\n\n/**\n * Panel class associated to this type of activity: {@link module:activities/panels/InformationScreen.InformationScreenPanel InformationScreenPanel}\n * @type {class} */\nInformationScreen.Panel = InformationScreenPanel;\n\n// Register activity class\nexport default Activity.registerClass('@panels.InformationScreen', InformationScreen);\n","/**\n * File : boxes/ActiveBoxGrid.js\n * Created : 19/05/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Catalan Educational Telematic Network (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\nimport ActiveBoxBag from './ActiveBoxBag.js';\nimport ActiveBox from './ActiveBox.js';\nimport { Rectangle, Dimension, Point } from '../AWT.js';\nimport { settings, roundTo } from '../Utils.js';\n\n/**\n * This class extends {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} with constructors that take an argument of type\n * {@link module:shapers/Shaper.Shaper Shaper} used to build all its {@link module:boxes/ActiveBox.ActiveBox ActiveBox}components. It also maintains information\n * about the number of \"rows\" and \"columns\", useful to compute valid (integer) values when\n * resizing or moving its components.\n * @extends module:boxes/ActiveBoxBag.ActiveBoxBag\n */\nexport class ActiveBoxGrid extends ActiveBoxBag {\n /**\n * ActiveBxGrid constructor\n * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs\n * @param {module:AWT.Container} container - The container where this box grid is placed.\n * @param {module:boxes/BoxBase} boxBase - The object where colors, fonts, border and other graphic properties\n * @param {number} px - `X` coordinate of the upper left corner of this box grid\n * @param {number} py - `Y` coordinate of the upper left corner of this box grid\n * @param {number} setWidth - Total width of the box grid\n * @param {number} setHeight - Total height of the box grid\n * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects\n */\n constructor(parent, container, boxBase, px, py, setWidth, setHeight, sh) {\n // ActiveBoxGrid derives from ActiveBoxBag\n super(parent, container, boxBase);\n\n this.nCols = sh.nCols;\n this.nRows = sh.nRows;\n\n // This will be the enclosing rectangle of this ActiveBox bag\n const r = new Rectangle(\n new Point(px, py),\n new Dimension(\n Math.round(setWidth / this.nCols) * this.nCols,\n Math.round(setHeight / this.nRows) * this.nRows));\n\n // Create all the [ActiveBox](ActiveBox.html) objects based on the\n // shapes provided by the [Shaper](Shaper.html)\n for (let i = 0; i < sh.nCells; i++) {\n const\n tmpSh = sh.getShape(i, r),\n bx = new ActiveBox(this, container, boxBase, i, tmpSh.getBounds());\n if (!sh.rectangularShapes)\n bx.setShape(tmpSh);\n this.addActiveBox(bx);\n }\n\n // If the Shaper has `remainder` (extra space), set the background box of this\n // [BoxBag](BoxBag.html)\n if (sh.hasRemainder) {\n const\n tmpSh = sh.getRemainderShape(r),\n bx = new ActiveBox(this, container, boxBase, 0, tmpSh.getBounds());\n bx.setShape(tmpSh);\n this.setBackgroundBox(bx);\n }\n }\n\n /**\n * This factory constructor creates a new empty grid with the number of cells indicated by the\n * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} `abc`, not filling the cells with any content.\n * @param {module:boxes/AbstractBox.AbstractBox} parent - The AbstractBox to which this box grid belongs\n * @param {module:AWT.Container} container - The container where this box grid is placed.\n * @param {number} px - `X` coordinate of the upper left corner of this box grid\n * @param {number} py - `Y` coordinate of the upper left corner of this box grid\n * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - Used only to get the number of cells and the shaper (when `sh` is `null`)\n * @param {module:shapers/Shaper.Shaper} sh - Shaper used to build the ActiveBox objects\n * @param {module:boxes/BoxBase.BoxBase} boxBase - The object where colors, fonts, border and other graphic properties\n * of this box grid are defined.\n * @returns {module:boxes/ActiveBoxGrid.ActiveBoxGrid}\n */\n static createEmptyGrid(parent, container, px, py, abc, sh, boxBase) {\n const result = abc ? new ActiveBoxGrid(parent, container,\n boxBase || abc.style,\n px, py,\n abc.getTotalWidth(), abc.getTotalHeight(),\n sh || abc.getShaper()) : null;\n\n if (result)\n result.setBorder(abc.border);\n\n return result;\n }\n\n /**\n * Gets the minimum size of this grid\n * @returns {module:AWT.Dimension}\n */\n getMinimumSize() {\n return new Dimension(\n settings.MIN_CELL_SIZE * this.nCols,\n settings.MIN_CELL_SIZE * this.nRows);\n }\n\n /**\n * Gets a scaled size of this grid, rounded to the nearest integer values\n * @param {number} scale - The scale factor\n * @returns {module:AWT.Dimension}\n */\n getScaledSize(scale) {\n return new Dimension(\n roundTo(scale * this.preferredBounds.dim.width, this.nCols),\n roundTo(scale * this.preferredBounds.dim.height, this.nRows));\n }\n\n /**\n * Returns the logical coordinates of the provided {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.\n * The units of the result are not pixels, but ordinal numbers (relative positions) of columns\n * and rows in the grid.\n * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to process\n * @returns {module:AWT.Point}\n */\n getCoord(bx) {\n return new Point(bx.idLoc % this.nCols, Math.floor(bx.idLoc / this.nCols));\n }\n\n /**\n * Calculates the logical distance between two {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.\n * Resulting units are not pixels, but ordinal numbers (relative positions) of columns and rows\n * in the grid.\n * @param {module:boxes/ActiveBox.ActiveBox} src - First box\n * @param {module:boxes/ActiveBox.ActiveBox} dest - Second box\n * @returns {module:AWT.Point}\n */\n getCoordDist(src, dest) {\n const\n ptSrc = this.getCoord(src),\n ptDest = this.getCoord(dest);\n return new Point(ptDest.x - ptSrc.x, ptDest.y - ptSrc.y);\n }\n}\n\nObject.assign(ActiveBoxGrid.prototype, {\n /**\n * Number of columns of this box grid\n * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nCols\n * @type {number} */\n nCols: 1,\n /**\n * Number of rows of this box grid\n * @name module:boxes/ActiveBoxGrid.ActiveBoxGrid#nRows\n * @type {number} */\n nRows: 1,\n});\n\nexport default ActiveBoxGrid;\n"],"names":[],"sourceRoot":""}