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 +0,0 @@
1
- {"version":3,"file":"427.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;;AAEuB;AACU;AACC;;AAElC;AACA,oCAAoC,yCAAyC,iCAAiC,iDAAiD;AAC/J;AACA,IAAI,uEAAuE;AAC3E;AACA;AACA;AACO,2BAA2B,kDAAM;AACxC;AACA;AACA,aAAa,sCAAsC;AACnD,aAAa,sBAAsB;AACnC,aAAa,8BAA8B;AAC3C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,kDAAkD;AAChE,aAAa,kCAAkC;AAC/C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA,6EAA6E;AAC7E;AACA,aAAa,gDAAgD;AAC7D,aAAa,gDAAgD;AAC7D,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,kDAAkD;AAClE,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,kCAAkC;AAC/C,aAAa,SAAS;AACtB,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,SAAS;AACtB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oDAAK;;AAErB,sBAAsB,QAAQ;AAC9B;AACA,qBAAqB,oDAAK;AAC1B;AACA;;AAEA,sBAAsB,WAAW;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,sBAAsB,QAAQ;AAC9B;AACA;AACA;AACA;AACA,sBAAsB,oDAAK;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,oCAAoC;AACjD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,sBAAsB,oDAAK;;AAE3B;AACA;AACA;AACA;AACA,sBAAsB,oDAAK;AAC3B,KAAK;AACL;;AAEA;AACA;AACA,aAAa,kCAAkC;AAC/C,aAAa,kCAAkC;AAC/C,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA,iBAAiB,oDAAK;AACtB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,iBAAiB;AAC9B,aAAa,iBAAiB;AAC9B,aAAa,QAAQ;AACrB,eAAe,iBAAiB;AAChC;AACA;AACA,uDAAuD,6CAAC,aAAa,gDAAgD;AACrH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,iBAAiB;AAC7B;AACA,CAAC;;AAED,iEAAe,YAAY,EAAC;;;;;;;;;;;;;;;ACpW5B;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;;AAE2C;AACa;AACjB;;AAEvC;AACA,mCAAmC,wDAAwD;AAC3F,+BAA+B,uDAAuD;AACtF;AACA;AACA;AACO,qBAAqB,uDAAW;AACvC;AACA;AACA,aAAa,sCAAsC;AACnD,aAAa,sBAAsB;AACnC,aAAa,8BAA8B;AAC3C;AACA;AACA;AACA;AACA,+BAA+B,wDAAS;AACxC;AACA;;AAEA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC,aAAa,WAAW;AACxB,MAAM;AACN,sCAAsC,yCAAyC,IAAI,8CAA8C;AACjI,aAAa,QAAQ;AACrB,eAAe,sBAAsB;AACrC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,sBAAsB;AACnC,aAAa,WAAW;AACxB,MAAM;AACN,sCAAsC,yCAAyC,IAAI,8CAA8C;AACjI,aAAa,WAAW;AACxB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,sBAAsB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,kBAAkB,wDAAS;AAC3B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oBAAoB,wDAAS;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;AACA,kBAAkB,wDAAS;AAC3B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA,eAAe,wDAAS;AACxB,eAAe,yDAAQ;AACvB,eAAe,yDAAQ;AACvB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA,eAAe,wDAAS;AACxB;;AAEA;AACA,cAAc,wDAAwD;AACtE,aAAa,sCAAsC;AACnD;AACA;AACA;AACA;;AAEA;AACA,MAAM,wDAAS;AACf;AACA;;AAEA;AACA;;AAEA;AACA;AACA,aAAa,sCAAsC;AACnD,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,sCAAsC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,wDAAS;AACb;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,wDAAS;AAC9C;AACA;AACA,gBAAgB,wDAAS;AACzB;AACA;AACA,KAAK;AACL;AACA,cAAc,wDAAS;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,sDAAsD;AACtE;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,uDAAuD;AACvE;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,2DAA2D;AAC3E;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,sDAAsD;AACtE;AACA,aAAa,wBAAwB;AACrC;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,iBAAiB,wDAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,oDAAK;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,kBAAkB,oDAAK;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB;AAChB;AACA,aAAa,mCAAmC;AAChD;AACA,aAAa,sBAAsB;AACnC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA,8BAA8B,wDAAwD;AACtF,aAAa,kBAAkB;AAC/B,eAAe;AACf;AACA;AACA;AACA,wCAAwC,QAAQ;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,wCAAwC;AACpD;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,uBAAuB,wDAAS;AAChC;AACA;AACA;AACA,YAAY,sCAAsC;AAClD;AACA,CAAC;;AAED,iEAAe,MAAM,EAAC","sources":["webpack://jclic/./src/boxes/ActiveBoxBag.js","webpack://jclic/./src/boxes/BoxBag.js"],"sourcesContent":["/**\n * File : boxes/ActiveBoxBag.js\n * Created : 21/04/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\nimport $ from 'jquery';\nimport BoxBag from './BoxBag.js';\nimport { Point } from '../AWT.js';\n\n/**\n * This class is a special case of {@link module:boxes/BoxBag.BoxBag BoxBag} containing only objects of type {@link module:boxes/ActiveBox.ActiveBox ActiveBox}.\n * In addition to the members and methods of `BoxBag`, it implements specific methods to deal with\n * {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent} objects and with the other specific members of `ActiveBox` like its \"ids\"\n * (`idOrder`, `idLoc` and `idAss`).\n * @extends module:boxes/BoxBag.BoxBag\n */\nexport class ActiveBoxBag extends BoxBag {\n /**\n * ActiveBoxBag constructor\n * @param {module:boxes/AbstractBox.AbstractBox} [parent] - The AbstractBox to which this box bag belongs\n * @param {module:AWT.Container} [container] - The container where this box bag is placed.\n * @param {module:boxes/BoxBase.BoxBase} [boxBase] - The object where colors, fonts, border and other graphic properties\n * of this box bag are defined.\n */\n constructor(parent, container, boxBase) {\n // ActiveBoxBag extends BoxBag\n super(parent, container, boxBase);\n }\n\n /**\n * Adds an {@link module:boxes/ActiveBox.ActiveBox ActiveBox} to this bag\n * @param {module:boxes/ActiveBox.ActiveBox} bx - The ActiveBox to be added to this bag\n */\n addActiveBox(bx) {\n bx.idLoc = this.cells.length;\n bx.idOrder = bx.idLoc;\n return this.addBox(bx);\n }\n\n /**\n * Finds an ActiveBox by its relative location (`idLoc` field)\n * @param {number} idLoc\n * @returns {module:boxes/ActiveBox.ActiveBox}\n */\n getActiveBox(idLoc) {\n return this.getBox(idLoc);\n }\n\n /**\n * Gets the background box\n * @returns {module:boxes/ActiveBox.ActiveBox}\n */\n getBackgroundActiveBox() {\n return this.getBackgroundBox();\n }\n\n /**\n * Sets the content of members of this ActiveBoxBag, based on one or more {@link module:boxes/ActiveBagContent.ActiveBagContent ActiveBagContent}\n * objects.\n * @param {module:boxes/ActiveBagContent.ActiveBagContent} abc - The main bag of content\n * @param {module:boxes/ActiveBagContent.ActiveBagContent} [altAbc] - The alternative bag of content\n * @param {number} [fromIndex] - Starts taking the cell content located at this position on the bag\n * @param {number} [toCell] - Starts filling the box located at this position on the ActiveBoxBag\n * @param {number} [numCells] - Acts only with a limited number of elements.\n */\n setContent(abc, altAbc, fromIndex, toCell, numCells) {\n if (!fromIndex)\n fromIndex = 0;\n if (!toCell)\n toCell = 0;\n if (!numCells)\n numCells = this.cells.length;\n\n for (let i = 0; i < numCells; i++) {\n const bx = this.getActiveBox(toCell + i);\n bx.setContent(abc, fromIndex + i);\n bx.setAlternative(false);\n if (altAbc)\n bx.setAltContent(altAbc, fromIndex + i);\n }\n\n if (abc.backgroundContent !== null && this.getBackgroundActiveBox() !== null) {\n const bx = this.getBackgroundActiveBox();\n bx.setContent(abc.backgroundContent);\n if (abc.style !== bx.boxBase)\n bx.setBoxBase(abc.style);\n }\n }\n\n /**\n * Finds an ActiveBox by location\n * @param {module:AWT.Point} point - The location to search for\n * @returns {module:boxes/ActiveBox.ActiveBox}\n */\n findActiveBox(point) {\n return this.findBox(point);\n }\n\n /**\n * Clears the content of all boxes\n */\n clearAllBoxes() {\n this.cells.forEach(bx => bx.clear());\n }\n\n /**\n * Clears the content of all boxes and background box\n */\n clearAll() {\n this.clearAllBoxes();\n if (this.backgroundBox !== null)\n this.getBackgroundActiveBox().clear();\n }\n\n /**\n * Count the number of cells that are at its original place\n * @returns {number}\n */\n countCellsAtPlace() {\n return this.cells.reduce((n, bx) => bx.isAtPlace() ? ++n : n, 0);\n }\n\n /**\n * Finds the {@link module:boxes/ActiveBox.ActiveBox ActiveBox} that has the specified `idLoc` attribute\n * @param {number} idLoc - The idLoc to search for\n * @returns {module:boxes/ActiveBox.ActiveBox}\n */\n getActiveBoxWithIdLoc(idLoc) {\n return this.cells.find(bx => bx.idLoc === idLoc) || null;\n }\n\n /**\n * Checks if the place occupied by a cell corresponds to a cell with equivalent content.\n * @param {module:boxes/ActiveBox.ActiveBox} bx - The box to check\n * @param {boolean} checkCase - If `true`, check case when comparing texts\n * @returns {boolean}\n */\n cellIsAtEquivalentPlace(bx, checkCase) {\n return bx.isAtPlace() ||\n bx.isEquivalent(this.getActiveBoxWithIdLoc(bx.idOrder), checkCase);\n }\n\n /**\n * Count the number of cells that are at its original place or equivalent\n * @param {boolean} checkCase - - If `true`, check case when comparing texts\n * @returns {number}\n */\n countCellsAtEquivalentPlace(checkCase) {\n return this.cells.reduce((n, bx) => this.cellIsAtEquivalentPlace(bx, checkCase) ? ++n : n, 0);\n }\n\n /**\n * Counts the number of cells that have the provided `idAss` attribute\n * @param {number} idAss - The `idAss` attribute to search\n * @returns {number}\n */\n countCellsWithIdAss(idAss) {\n return this.cells.reduce((n, bx) => bx.idAss === idAss ? ++n : n, 0);\n }\n\n /**\n * Resets the default `idAss` attribute on all cells\n */\n setDefaultIdAss() {\n this.cells.map(bx => bx.setDefaultIdAss());\n }\n\n /**\n * Shuffles the cells\n * @param {number} times - Number of times to shuffle\n * @param {boolean} fitInArea - Ensure that all cells are inside the bag rectangle\n */\n shuffleCells(times, fitInArea) {\n let nc = this.cells.length;\n if (nc >= 2) {\n // Array of AWT.Point objects\n const\n pos = [],\n idLoc = [],\n p = new Point();\n\n for (let i = 0; i < nc; i++) {\n const bx = this.getActiveBox(i);\n pos[i] = new Point(bx.pos);\n idLoc[i] = bx.idLoc;\n }\n\n for (let i = 0; i < times; i++) {\n const\n r1 = Math.floor(Math.random() * nc),\n r2 = Math.floor(Math.random() * nc);\n if (r1 !== r2) {\n p.moveTo(pos[r1]);\n pos[r1].moveTo(pos[r2]);\n pos[r2].moveTo(p);\n const j = idLoc[r1];\n idLoc[r1] = idLoc[r2];\n idLoc[r2] = j;\n }\n }\n\n for (let i = 0; i < nc; i++) {\n const\n bx = this.getActiveBox(i),\n px = pos[i].x,\n py = pos[i].y;\n bx.moveTo(new Point(px, py));\n if (fitInArea)\n this.fitCellsInArea([bx]);\n bx.idLoc = idLoc[i];\n }\n }\n }\n\n /**\n * Fits cells inside the ActiveBoxBag area. Useful when non-rectangular cells exchange its positions.\n * @param {module:boxes/ActiveBox.ActiveBox[]} boxes - The boxes to be checked\n */\n fitCellsInArea(boxes) {\n const\n maxX = this.pos.x + this.dim.width,\n maxY = this.pos.y + this.dim.height;\n\n boxes.forEach(bx => {\n // Save original position\n if (!bx.pos0)\n bx.pos0 = new Point(bx.pos);\n\n const\n px = Math.min(Math.max(bx.pos.x, this.pos.x), maxX - bx.dim.width),\n py = Math.min(Math.max(bx.pos.y, this.pos.y), maxY - bx.dim.height);\n if (px !== bx.pos.x || py !== bx.pos.y)\n bx.moveTo(new Point(px, py));\n });\n }\n\n /**\n * Exchange the positions of two cells inside the ActiveBoxBag area.\n * @param {module:boxes/ActiveBox.ActiveBox} bxa - The first box\n * @param {module:boxes/ActiveBox.ActiveBox} bxb - The second box\n * @param {boolean} fitInArea - Ensure that all cells are inside the bag rectangle\n */\n swapCellPositions(bxa, bxb, fitInArea) {\n // Save backup of bxb significant properties\n const\n posB = new Point(bxb.pos),\n posB0 = bxb.pos0,\n idLocB = bxb.idLoc;\n\n bxb.moveTo(bxa.pos0 || bxa.pos);\n bxb.pos0 = bxa.pos0;\n bxb.idLoc = bxa.idLoc;\n\n bxa.moveTo(posB0 || posB);\n bxa.pos0 = posB0;\n bxa.idLoc = idLocB;\n\n if (fitInArea)\n this.fitCellsInArea([bxa, bxb]);\n }\n\n /**\n * Resets the IDs of all cells\n */\n resetIds() {\n this.cells.forEach((bx, i) => {\n if (bx) {\n bx.idOrder = i;\n bx.idAss = i;\n bx.idLoc = i;\n }\n });\n }\n\n /**\n * Gets the index of box located in the `cells` array after the provided index, having the\n * provided `idAssValid` value as `idAss` attribute.\n * When `idAssValid` is `null` or `undefined`, search for the next cell with `idAss>0`\n * @param {number} currentItem - The index after to which start scanning\n * @param {string} [idAssValid] - The `idAss` attribute value to search\n * @returns {number}\n */\n getNextItem(currentItem, idAssValid) {\n const IDASSNOTUSED = -12345;\n if (!idAssValid)\n idAssValid = IDASSNOTUSED;\n let i = currentItem + 1;\n for (; i < this.cells.length; i++) {\n const bx = this.cells[i];\n if (!bx)\n break;\n if (idAssValid !== IDASSNOTUSED) {\n if (idAssValid === bx.idAss)\n break;\n } else if (bx.idAss >= 0)\n break;\n }\n return i;\n }\n\n /**\n * Builds a group of hidden `buton` elements that will act as a accessible objects associated\n * to the canvas area of this ActiveBoxBag.\n * The buttons will only be created when `CanvasRenderingContext2D` has a method named `addHitRegion`.\n * See https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Hit_regions_and_accessibility\n * for more information and supported browsers.\n * @param {external:jQuery} $canvas - The `canvas` where this `ActiveBoxBag` will deploy, wrapped up in a jQuery object\n * @param {external:jQuery} $clickReceiver - The DOM element that will be notified when a button is clicked.\n * @param {string} [eventType] - Type of event sent to $clickReceiver. Default is `click`.\n * @returns {external:jQuery} - The $accessibleDiv member, containing the accessible elements associated to this ActiveBoxBag.\n */\n buildAccessibleElements($canvas, $clickReceiver, eventType) {\n this.$accessibleDiv = this.accessibleText !== '' ? $('<div/>', { 'aria-label': this.accessibleText, tabindex: 0 }) : null;\n $canvas.append(this.$accessibleDiv);\n this.cells\n .map(a => a)\n .sort((a, b) => a.idLoc > b.idLoc ? 1 : -1)\n .forEach(bx => bx.buildAccessibleElement($canvas, $clickReceiver, this.$accessibleDiv, eventType));\n return this.$accessibleDiv;\n }\n}\n\nObject.assign(ActiveBoxBag.prototype, {\n /**\n * `div` containing the accessible elements associated to this ActiveBoxBag\n * @name module:boxes/ActiveBoxBag.ActiveBoxBag#$accessibleDiv\n * @type {external:jQuery} */\n $accessibleDiv: null,\n});\n\nexport default ActiveBoxBag;\n","/**\n * File : boxes/BoxBag.js\n * Created : 21/04/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 AbstractBox from './AbstractBox.js';\nimport { Rectangle, Dimension, Point } from '../AWT.js';\nimport { settings } from '../Utils.js';\n\n/**\n * BoxBag is a class derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox} that contains a collection of \"boxes\"\n * (objects also derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox}). This class implements methods to add, remove\n * and retrieve boxes, and to manage some of its properties like visibility, status, location and size.\n * @extends module:boxes/AbstractBox.AbstractBox\n */\nexport class BoxBag extends AbstractBox {\n /**\n * BoxBag constructor\n * @param {module:boxes/AbstractBox.AbstractBox} [parent] - The AbstractBox to which this box bag belongs\n * @param {module:AWT.Container} [container] - The container where this box bag is placed.\n * @param {module:boxes/BoxBase.BoxBase} [boxBase] - The object where colors, fonts, border and other graphic properties\n */\n constructor(parent, container, boxBase) {\n // BoxBag extends AbstractBox\n super(parent, container, boxBase);\n this.preferredBounds = new Rectangle();\n this.cells = [];\n }\n\n /**\n * Static method that sets the position and dimension of a `Resizable` object based on a\n * preferred maximum dimension and a margin.\n * @param {module:AWT.Dimension} preferredMaxSize - The preferred maximum size\n * @param {Resizable} rs - A resizable object implementing the methods described in the\n * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/boxes/Resizable.html Resizable}\n * interface of JClic. Currently a {@link module:boxes/BoxBag.BoxBag BoxBag} or {@link module:boxes/TextGrid.TextGrid TextGrid}.\n * @param {number} margin - The margin between the available area and the BoxBag\n * @returns {module:AWT.Dimension} - The resulting size of the container\n */\n static layoutSingle(preferredMaxSize, rs, margin) {\n\n // Avoid exceptions when rs is null\n if (!rs)\n return preferredMaxSize;\n\n // optimal, maximal and minimal dimensions\n let\n d = rs.getPreferredSize(),\n minSize = rs.getMinimumSize(),\n maxSize = preferredMaxSize;\n\n // remove margins\n maxSize.width -= 2 * margin;\n maxSize.height -= 2 * margin;\n // correct maxSize if less than minSize\n if (minSize.width > maxSize.width || minSize.height > maxSize.height) {\n maxSize = minSize;\n }\n // compute scale factor\n let scale = d.width > maxSize.width ? maxSize.width / d.width : 1;\n if (scale * d.height > maxSize.height)\n scale = maxSize.height / d.height;\n\n // resize the `Resizable` object\n d = rs.getScaledSize(scale);\n rs.setBounds(margin, margin, d.width, d.height);\n\n // restore margins\n d.width += 2 * margin;\n d.height += 2 * margin;\n\n return d;\n }\n\n /**\n * Static method that sets the position and dimension of two `Resizable` objects based on a\n * preferred maximum size, a layout schema and a margin.\n * @param {module:AWT.Dimension} desiredMaxSize - The preferred maximum size\n * @param {Resizable} rsA - First resizable object implementing the methods described in the\n * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/boxes/Resizable.html Resizable}\n * interface of JClic. Currently a {@link module:boxes/BoxBag.BoxBag BoxBag} or {@link module:boxes/TextGrid.TextGrid TextGrid}.\n * @param {Resizable} rsB - Second resizable object\n * @param {string} boxGridPos - The layout schema. Possible values are:\n * - \"AB\" (_A_ at left, _B_ at right)\n * - \"BA\" (_B_ at left, _A_ at right)\n * - \"AUB\" (_A_ above _B_)\n * - \"BUA\" (_A_ below _B_).\n * @param {number} margin - The margin between the available area and the BoxBag\n * @returns {module:AWT.Dimension} - The resulting size of the container\n */\n static layoutDouble(desiredMaxSize, rsA, rsB, boxGridPos, margin) {\n // number of horizontal and vertical grid lines\n let\n isHLayout = false,\n nbh = 1,\n nbv = 1;\n switch (boxGridPos) {\n case 'AB':\n case 'BA':\n nbh = 2;\n nbv = 1;\n isHLayout = true;\n break;\n case 'AUB':\n case 'BUA':\n nbh = 1;\n nbv = 2;\n isHLayout = false;\n break;\n }\n const\n ra = rsA.getBounds(),\n rb = rsB.getBounds();\n\n // optimal dimensions\n let\n da = rsA.getPreferredSize(),\n db = rsB.getPreferredSize();\n\n const d = new Dimension(\n isHLayout ? da.width + db.width : Math.max(da.width, db.width),\n isHLayout ? Math.max(da.height, db.height) : da.height + db.height\n );\n\n // minimal dimensions\n const\n minSizeA = rsA.getMinimumSize(),\n minSizeB = rsB.getMinimumSize(),\n minSize = new Dimension(\n isHLayout ? minSizeA.width + minSizeB.width : Math.max(minSizeA.width, minSizeB.width),\n isHLayout ? Math.max(minSizeA.height, minSizeB.height) : minSizeA.height + minSizeB.height\n ),\n maxSize = desiredMaxSize;\n\n // remove margins\n maxSize.width -= (1 + nbh) * margin;\n maxSize.height -= (1 + nbv) * margin;\n\n // correct maxSize if less than minSize\n if (minSize.width > maxSize.width || minSize.height > maxSize.height)\n maxSize.setDimension(minSize);\n\n // compute scale factor\n let scale = d.width > maxSize.width ? maxSize.width / d.width : 1;\n if (scale * d.height > maxSize.height)\n scale = maxSize.height / d.height;\n\n //\n // correct possible minimal infractions\n // ...\n // resize\n da = rsA.getScaledSize(scale);\n db = rsB.getScaledSize(scale);\n\n // set margins to center one box relative to the other\n let\n dah = db.width > da.width ? (db.width - da.width) / 2 : 0,\n dbh = da.width > db.width ? (da.width - db.width) / 2 : 0,\n dav = db.height > da.height ? (db.height - da.height) / 2 : 0,\n dbv = da.height > db.height ? (da.height - db.height) / 2 : 0;\n\n switch (boxGridPos) {\n case 'AB':\n rsA.setBounds(margin, margin + dav, da.width, da.height);\n rsB.setBounds(2 * margin + da.width, margin + dbv, db.width, db.height);\n break;\n case 'BA':\n rsB.setBounds(margin, margin + dbv, db.width, db.height);\n rsA.setBounds(2 * margin + db.width, margin + dav, da.width, da.height);\n break;\n case 'AUB':\n rsA.setBounds(margin + dah, margin, da.width, da.height);\n rsB.setBounds(margin + dbh, 2 * margin + da.height, db.width, db.height);\n break;\n case 'BUA':\n rsB.setBounds(margin + dbh, margin, db.width, db.height);\n rsA.setBounds(margin + dah, 2 * margin + db.height, da.width, da.height);\n break;\n default:\n rsA.setBounds(\n Math.round(margin + scale * ra.pos.x),\n Math.round(margin + scale * ra.pos.y),\n da.width, da.height);\n rsB.setBounds(\n Math.round(margin + scale * rb.pos.x),\n Math.round(margin + scale * rb.pos.y),\n da.width, da.height);\n break;\n }\n\n // recompute 'd' adding margins\n const r = new Rectangle(rsA.getBounds());\n r.add(rsB.getBounds());\n d.width = r.dim.width + 2 * margin;\n d.height = r.dim.height + 2 * margin;\n\n return d;\n }\n\n /**\n * Gets the preferred size of this `BoxBag`\n * @returns {module:AWT.Dimension}\n */\n getPreferredSize() {\n return this.preferredBounds.dim;\n }\n\n /**\n * Gets the minimum size requested by this `BoxBag`\n * @returns {module:AWT.Dimension}\n */\n getMinimumSize() {\n const d = this.getPreferredSize();\n return new Dimension(\n Math.max(settings.MIN_CELL_SIZE, d.width),\n Math.max(settings.MIN_CELL_SIZE, d.height));\n }\n\n /**\n * Scales the current size of this box bag, multiplying all values by a specific factor\n * @param {number} scale - The scale factor\n * @returns {module:AWT.Dimension}\n */\n getScaledSize(scale) {\n const d = this.getPreferredSize();\n return new Dimension(Math.round(scale * d.width), Math.round(scale * d.height));\n }\n\n /**\n * Adds an {@link module:boxes/AbstractBox.AbstractBox AbstractBox} to the collection of cells\n * @param {module:boxes/AbstractBox.AbstractBox} bx - The box to add\n */\n addBox(bx) {\n this.cells.push(bx);\n bx.setParent(this);\n\n if (this.cells.length === 1)\n Rectangle.prototype.setBounds.call(this, bx);\n else\n this.add(bx);\n\n this.preferredBounds.setBounds(this.getBounds());\n }\n\n /**\n * Returns the index of a specific box in the `cells` array\n * @param {module:boxes/AbstractBox.AbstractBox} bx\n * @returns {number}\n */\n boxIndex(bx) {\n return bx === null ? -1 : this.cells.indexOf(bx);\n }\n\n /**\n * Returns the box at a specific index in the `cells` array\n * @param {number} n - The index\n * @returns {module:boxes/AbstractBox.AbstractBox}\n */\n getBox(n) {\n return n < 0 || n >= this.cells.length ? null : this.cells[n];\n }\n\n /**\n * Gets the background box\n * @returns {module:boxes/AbstractBox.AbstractBox}\n */\n getBackgroundBox() {\n return this.backgroundBox;\n }\n\n /**\n * Sets the background box\n * @param {module:boxes/AbstractBox.AbstractBox} bx\n */\n setBackgroundBox(bx) {\n this.backgroundBox = bx;\n if (bx !== null) {\n bx.setParent(this);\n bx.isBackground = true;\n }\n // Add the `backgroundbox` rectangle to the global BoxBag rectangle\n Rectangle.prototype.add.call(this, bx);\n this.preferredBounds.setBounds(this.getBounds());\n }\n\n /**\n * Recalculates the total size of this BoxBag (useful after direct additions o deletions of\n * elements in the `cells` array).\n * Updates `preferredBounds` and the current position and size of the box bag.\n */\n recalcSize() {\n let r = this.backgroundBox ? new Rectangle(this.backgroundBox.pos, this.backgroundBox.dim) : null;\n this.cells.forEach(cell => {\n if (!r)\n r = new Rectangle(cell.pos, cell.dim);\n else\n r.add(cell);\n });\n if (!r)\n r = new Rectangle(this.pos.x, this.pos.y, 0, 0);\n this.preferredBounds.setRect(r);\n this.x = r.pos.x;\n this.y = r.pos.y;\n this.dim.width = r.dim.width;\n this.dim.height = r.dim.height;\n }\n\n /**\n * Returns the number of cells stored in this BoxBag\n * @returns {number}\n */\n getNumCells() {\n return this.cells.length;\n }\n\n /**\n * Sets the specified key - value pair to all cells of this bag.\n * @param {string} key - The key to be established\n * @param {any} value - The value, of any type\n */\n setCellAttr(key, value) {\n this.cells.forEach(bx => bx[key] = value);\n if (this.backgroundBox)\n this.backgroundBox[key] = value;\n }\n\n /**\n * Overrides {@link module:boxes/AbstractBox.AbstractBox#setBorder} iterating over all the cells stored in this box bag.\n * @override\n * @param {boolean} newVal - Whether to set or unset the border\n */\n setBorder(newVal) {\n this.cells.forEach(bx => bx.setBorder(newVal));\n }\n\n /**\n * Overrides {@link module:boxes/AbstractBox.AbstractBox#setVisible} iterating over all the cells stored in this box bag.\n * @override\n * @param {boolean} newVal - Whether to set the cells visible or not\n */\n setVisible(newVal) {\n this.cells.forEach(bx => bx.setVisible(newVal));\n }\n\n /**\n * Overrides {@link module:boxes/AbstractBox.AbstractBox#setAlternative} iterating over all the cells stored in this box bag.\n * @override\n * @param {boolean} newVal - Whether to set or unset the cells in \"alternative\" mode\n */\n setAlternative(newVal) {\n super.setAlternative(newVal);\n this.cells.forEach(bx => bx.setAlternative(newVal));\n }\n\n /**\n * Overrides {@link module:boxes/AbstractBox.AbstractBox#setBounds} adjusting the position and size of all cells\n * @override\n * @param {(AWT.Rectangle|number)} rect - An AWT.Rectangle object, or the `x` coordinate of the\n * upper-left corner of a new rectangle.\n * @param {number} [ry] - `y` coordinate of the upper-left corner of the new rectangle.\n * @param {number} [rw] - Width of the new rectangle.\n * @param {number} [rh] - Height of the new rectangle.\n */\n setBounds(rect, ry, rw, rh) {\n if (typeof rect === 'number') {\n // Arguments are co-ordinates and size\n rect = new Rectangle(rect, ry, rw, rh);\n }\n if (rect.getSurface() > 0 && !rect.equals(this)) {\n const\n scaleW = rect.dim.width / this.dim.width,\n scaleH = rect.dim.height / this.dim.height,\n dx = rect.pos.x - this.pos.x,\n dy = rect.pos.y - this.pos.y;\n this.cells.forEach(bx => {\n const p = new Point(bx.pos.x - this.pos.x, bx.pos.y - this.pos.y);\n bx.setBounds(\n dx + this.pos.x + scaleW * p.x,\n dy + this.pos.y + scaleH * p.y,\n scaleW * bx.dim.width,\n scaleH * bx.dim.height);\n // Clear pos0\n bx.pos0 = null;\n });\n if (this.backgroundBox !== null) {\n const\n bx = this.backgroundBox,\n p = new Point(bx.pos.x - this.pos.x, bx.pos.y - this.pos.y);\n bx.setBounds(\n dx + this.pos.x + scaleW * p.x,\n dy + this.pos.y + scaleH * p.y,\n scaleW * bx.dim.width,\n scaleH * bx.dim.height);\n }\n }\n super.setBounds(rect);\n }\n\n /**\n * Performs graphics operations for each cell.\n * Overrides {@link module:boxes/AbstractBox.AbstractBox#update}\n * @override\n * @param {external:CanvasRenderingContext2D} ctx - The canvas rendering context used to draw the\n * box contents.\n * @param {module:AWT.Rectangle} [dirtyRegion] - The area that must be repainted. `null` refers to the whole box.\n */\n update(ctx, dirtyRegion) {\n if (this.isEmpty() || !this.isVisible() || this.isTemporaryHidden())\n return false;\n\n if (dirtyRegion && !this.intersects(dirtyRegion))\n return false;\n\n if (this.backgroundBox !== null)\n this.backgroundBox.update(ctx, dirtyRegion);\n\n this.cells.forEach(bx => {\n if (!bx.isMarked())\n bx.update(ctx, dirtyRegion);\n });\n\n // Make a second loop to repaint marked cells\n this.cells.forEach(bx => {\n if (bx.isMarked())\n bx.update(ctx, dirtyRegion);\n });\n return true;\n }\n\n /**\n * Finds the first visible {@link module:boxes/AbstractBox.AbstractBox AbstractBox} located under the specified point\n * @param {module:AWT.Point} p\n * @returns {module:boxes/AbstractBox.AbstractBox}\n */\n findBox(p) {\n let result = null;\n for (let i = this.cells.length - 1; i >= 0; i--) {\n const bx = this.getBox(i);\n if (bx.isVisible() && bx.contains(p)) {\n result = bx;\n break;\n }\n }\n return result;\n }\n\n /**\n * Count the number of cells of this BoxBag that are in \"inactive\" state\n * @returns {number}\n */\n countInactiveCells() {\n return this.cells.reduce((n, bx) => bx.isInactive() ? ++n : n, 0);\n }\n}\n\nObject.assign(BoxBag.prototype, {\n /**\n * The array of cells\n * @name module:boxes/BoxBag.BoxBag#cells\n * @type {module:boxes/AbstractBox.AbstractBox[]} */\n cells: [],\n /**\n * Rectangle containing the preferred bounds of the BoxBag\n * @name module:boxes/BoxBag.BoxBag#preferredBounds\n * @type {module:AWT.Rectangle} */\n preferredBounds: new Rectangle(),\n /**\n * An optional box used as a background by this BoxBag\n * @name module:boxes/BoxBag.BoxBag#backgroundBox\n * @type {module:boxes/AbstractBox.AbstractBox} */\n backgroundBox: null,\n});\n\nexport default BoxBag;\n"],"names":[],"sourceRoot":""}
@@ -1,327 +0,0 @@
1
- "use strict";
2
- exports.id = 4483;
3
- exports.ids = [4483];
4
- exports.modules = {
5
-
6
- /***/ 4483:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony export PlayerHistory */
13
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
14
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
15
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
16
- /**
17
- * File : PlayerHistory.js
18
- * Created : 28/04/2015
19
- * By : Francesc Busquets <francesc@gmail.com>
20
- *
21
- * JClic.js
22
- * An HTML5 player of JClic activities
23
- * https://projectestac.github.io/jclic.js
24
- *
25
- * @source https://github.com/projectestac/jclic.js
26
- *
27
- * @license EUPL-1.2
28
- * @licstart
29
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
30
- *
31
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
32
- * the European Commission- subsequent versions of the EUPL (the "Licence");
33
- * You may not use this work except in compliance with the Licence.
34
- *
35
- * You may obtain a copy of the Licence at:
36
- * https://joinup.ec.europa.eu/software/page/eupl
37
- *
38
- * Unless required by applicable law or agreed to in writing, software
39
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
40
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
41
- * Licence for the specific language governing permissions and limitations
42
- * under the Licence.
43
- * @licend
44
- * @module
45
- */
46
-
47
- /* global window */
48
-
49
-
50
-
51
-
52
- /**
53
- *
54
- * PlayerHistory uses an array to store the list of projects and activities done by the user.
55
- * This class allows {@link module:JClicPlayer.JClicPlayer JClicPlayer} objects to rewind a sequence or to go back to a caller menu.
56
- */
57
- class PlayerHistory {
58
- /**
59
- * PlayerHistory constructor
60
- * @param {module:JClicPlayer.JClicPlayer} player - The JClicPlayer associated to this history
61
- */
62
- constructor(player) {
63
- this.player = player;
64
- this.sequenceStack = [];
65
- if (window && window.history && player.options.browserHistory) {
66
- this.browserHistory = true;
67
- jquery__WEBPACK_IMPORTED_MODULE_0___default()(window).on('popstate', (ev) => {
68
- const state = ev.originalEvent.state;
69
- if (state)
70
- this.processPopStateEvent(state);
71
- });
72
- }
73
- }
74
-
75
- /**
76
- *
77
- * Process the `state` object received in a `popstate` event
78
- * @param {PlayerHistory#HistoryElement} state - The previously stored state
79
- */
80
- processPopStateEvent(state) {
81
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('info', 'Processing History popstate event with state:', state);
82
- this.processingPop = true;
83
- if (state.projectPath === this.player.project.path &&
84
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isEquivalent */ .l2)(state.fullZipPath, this.player.zip ? this.player.zip.fullZipPath : null))
85
- this.player.load(null, state.activity, null);
86
- else
87
- this.player.load(state.fullZipPath || state.projectPath, state.activity, null);
88
- }
89
-
90
- /**
91
- * Push a new entry on the window.History stack,
92
- * only when `browserHistory` is true and there is no `popstate` event in progress
93
- */
94
- pushBrowserHistory() {
95
- if (this.browserHistory) {
96
-
97
- if (this.processingPop) {
98
- // A 'popstate' event is currently being processed, so just clear this flag and return
99
- this.processingPop = false;
100
- return;
101
- }
102
-
103
- const
104
- ase = this.player.project.activitySequence,
105
- act = ase.currentAct,
106
- title = this.player.actPanel.act.name || 'No name',
107
- state = new this.HistoryElement(
108
- this.player.project.path,
109
- ase.getSequenceForElement(act),
110
- act,
111
- this.player.zip ? this.player.zip.fullZipPath : null);
112
-
113
- // Push a new history entry, or update the current one if it has no `state`
114
- if (!window.history.state)
115
- window.history.replaceState(state, title);
116
- else
117
- window.history.pushState(state, title);
118
- }
119
- }
120
-
121
- /**
122
- *
123
- * Counts the number of {@link module:PlayerHistory.PlayerHistory#HistoryElement HistoryElement} objects stored in
124
- * {@link module:PlayerHistory.PlayerHistory#sequenceStack sequenceStack}
125
- * @returns {number}
126
- */
127
- storedElementsCount() {
128
- return this.sequenceStack.length;
129
- }
130
-
131
- /**
132
- *
133
- * Removes all elements from {@link module:PlayerHistory.PlayerHistory#sequenceStack sequenceStack}
134
- */
135
- clearHistory() {
136
- this.sequenceStack = [0];
137
- }
138
-
139
- /**
140
- * Adds the current project and activity to the top of the history stack.
141
- */
142
- push() {
143
- if (this.player.project !== null && this.player.project.path !== null) {
144
- const
145
- ase = this.player.project.activitySequence,
146
- act = ase.currentAct;
147
- if (act >= 0) {
148
- if (this.sequenceStack.length > 0) {
149
- const last = this.sequenceStack[this.sequenceStack.length - 1];
150
- if (last.projectPath === this.player.project.path && last.activity === act)
151
- return;
152
- }
153
- this.sequenceStack.push(
154
- new this.HistoryElement(
155
- this.player.project.path,
156
- ase.getSequenceForElement(act),
157
- act,
158
- this.player.zip ? this.player.zip.fullZipPath : null));
159
- }
160
- }
161
- }
162
-
163
- /**
164
- * Retrieves the {@link module:PlayerHistory.PlayerHistory#HistoryElement HistoryElement} placed at the top of the
165
- * stack (if any) and instructs {@link module:JClicPlayer.JClicPlayer JClicPlayer} to load it. The obtained effect is to
166
- * "rewind" or "go back", usually to an activity that acts as a menu.
167
- * @returns {boolean}
168
- */
169
- pop() {
170
- // todo: check return value
171
- if (this.sequenceStack.length > 0) {
172
- const e = this.sequenceStack.pop();
173
- if (e.projectPath === this.player.project.path &&
174
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isEquivalent */ .l2)(e.fullZipPath, this.player.zip ? this.player.zip.fullZipPath : null))
175
- this.player.load(null, e.activity, null);
176
- else
177
- if (this.testMode && e.projectPath !== null && e.projectPath.length > 0)
178
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('info', `At this point, a jump to "${e.projectPath}" should be performed.`);
179
- else
180
- this.player.load(e.fullZipPath || e.projectPath, e.activity, null);
181
- }
182
- return true;
183
- }
184
-
185
- /**
186
- *
187
- * Processes the provided {@link module:bags/JumpInfo.JumpInfo JumpInfo} object, instructing {@link module:JClicPlayer.JClicPlayer JClicPlayer} to go back,
188
- * stop or jump to another point in the sequence.
189
- * @param {module:bags/JumpInfo.JumpInfo} ji - The object to be processed
190
- * @param {boolean} allowReturn - When this parameter is `true`, the jump instructed by `ji` (if any)
191
- * will be recorded, thus allowing to return to the current activity.
192
- * @returns {boolean} - `true` if the jump can be processed without errors, `false` otherwise.
193
- */
194
- processJump(ji, allowReturn) {
195
- let result = false;
196
- if (ji !== null && this.player.project !== null) {
197
- switch (ji.action) {
198
- case 'STOP':
199
- break;
200
- case 'RETURN':
201
- if (this.sequenceStack.length > 0 || !this.player.options.returnAsExit) {
202
- result = this.pop();
203
- break;
204
- }
205
- case 'EXIT':
206
- if (this.testMode)
207
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('info', 'At this point, the program should exit.');
208
- else
209
- this.player.exit(ji.sequence);
210
- break;
211
- case 'JUMP':
212
- if (!ji.sequence && !ji.projectPath) {
213
- const ase = this.player.project.activitySequence.getElement(ji.actNum, true);
214
- if (ase !== null) {
215
- if (allowReturn)
216
- this.push();
217
- this.player.load(null, null, ase.activity);
218
- result = true;
219
- }
220
- } else {
221
- if (this.testMode && ji.projectPath !== null && ji.projectPath.length > 0) {
222
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .log */ .Rm)('info', `At this point, a jump to "${ji.projectPath}" should be performed.`);
223
- } else {
224
- result = this.jumpToSequence(ji.sequence,
225
- ji.projectPath ? (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .getPath */ .Yn)(this.player.project.basePath, ji.projectPath) : null,
226
- allowReturn);
227
- }
228
- }
229
- break;
230
- }
231
- }
232
- return result;
233
- }
234
-
235
- /**
236
- * Performs a jump to the specified sequence
237
- * @param {string} sequence - The {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence} tag to jump to.
238
- * @param {string} [path] - When not `null`, indicates a new project file that must be loaded.
239
- * Otherwise, the `sequence` parameter refers to a tag on the {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence} of the
240
- * current project.
241
- * @param {boolean} [allowReturn] - When this parameter is `true`, the jump will be recorded, thus
242
- * allowing to return to the current activity.
243
- */
244
- jumpToSequence(sequence, path = null, allowReturn = false) {
245
- if ((0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isNullOrUndef */ .Pj)(sequence) && (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isNullOrUndef */ .Pj)(path))
246
- return false;
247
- if ((0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isNullOrUndef */ .Pj)(path))
248
- path = this.player.project.path;
249
- if (this.sequenceStack.length > 0) {
250
- const e = this.sequenceStack[this.sequenceStack.length - 1];
251
- if (!(0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .isNullOrUndef */ .Pj)(sequence) && path === e.projectPath) {
252
- let same = sequence === e.sequence;
253
- if (path === this.player.project.path) {
254
- const ase = this.player.project.activitySequence.getElement(e.activity, false);
255
- same = ase !== null && sequence === ase.tag;
256
- }
257
- if (same)
258
- return this.pop();
259
- }
260
- }
261
- if (allowReturn)
262
- this.push();
263
- if (path === this.player.project.path)
264
- this.player.load(null, sequence, null);
265
- else
266
- this.player.load(path, sequence, null);
267
- return true;
268
- }
269
- }
270
-
271
- Object.assign(PlayerHistory.prototype, {
272
- /**
273
- * The {@link module:JClicPlayer.JClicPlayer JClicPlayer} object to which this `PlayerHistory` belongs
274
- * @name module:PlayerHistory.PlayerHistory#player
275
- * @type {module:JClicPlayer.JClicPlayer} */
276
- player: null,
277
- /**
278
- * This is the main member of the class. PlayerHistory puts and retrieves
279
- * on it information about the proects and activities done by the current user.
280
- * @name module:PlayerHistory.PlayerHistory#sequenceStack
281
- * @type {module:PlayerHistory.PlayerHistory#HistoryElement[]} */
282
- sequenceStack: [],
283
- /**
284
- * When in test mode, jumps are only simulated.
285
- * @name module:PlayerHistory.PlayerHistory#testMode
286
- * @type {boolean} */
287
- testMode: false,
288
- /**
289
- * When true, JClic history is in sync with browser history
290
- * @name PlayerHistory#browserHistory
291
- * @type {boolean} */
292
- browserHistory: false,
293
- /**
294
- * When true, a window.history event is currently being processed, so window.pushState should not be performed
295
- * @name PlayerHistory#processingPop
296
- * @type {boolean} */
297
- processingPop: false,
298
- /**
299
- * Inner class used to store history elements.
300
- * @name module:PlayerHistory.PlayerHistory#HistoryElement
301
- */
302
- HistoryElement: class {
303
- /**
304
- * HistoryElement constructor
305
- * @param {string} projectPath - The full path of the project file
306
- * @param {string} sequence - The nearest sequence tag
307
- * @param {number} activity - The index of the current activity on the project's {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence}
308
- * @param {string} fullZipPath - If `projectPath` resides in a {@link external:JSZip JSZip} object,
309
- * the full path of the zip file.
310
- */
311
- constructor(projectPath, sequence, activity, fullZipPath) {
312
- this.projectPath = projectPath;
313
- this.sequence = sequence;
314
- this.activity = activity;
315
- this.fullZipPath = fullZipPath;
316
- }
317
- }
318
- });
319
-
320
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (PlayerHistory);
321
-
322
-
323
- /***/ })
324
-
325
- };
326
- ;
327
- //# sourceMappingURL=4483.jclic-node.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"4483.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;AACgD;;AAEvE;AACA;AACA;AACA,sBAAsB,kDAAkD;AACxE;AACO;AACP;AACA;AACA,aAAa,gCAAgC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,6CAAC;AACP;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA,aAAa,8BAA8B;AAC3C;AACA;AACA,IAAI,wDAAG;AACP;AACA;AACA,MAAM,iEAAY;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,wEAAwE;AACnG,MAAM;AACN,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oBAAoB,wEAAwE;AAC5F,mCAAmC,kDAAkD;AACrF;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,iEAAY;AACpB;AACA;AACA;AACA,UAAU,wDAAG,sCAAsC,cAAc;AACjE;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,6BAA6B,8CAA8C,qBAAqB,kDAAkD;AAClJ;AACA,aAAa,+BAA+B;AAC5C,aAAa,SAAS;AACtB;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,wDAAG;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA,cAAc,wDAAG,sCAAsC,eAAe;AACtE,cAAc;AACd;AACA,iCAAiC,4DAAO;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ,gBAAgB,sEAAsE;AAC3G,aAAa,QAAQ;AACrB,iEAAiE,sEAAsE;AACvI;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA,QAAQ,kEAAa,cAAc,kEAAa;AAChD;AACA,QAAQ,kEAAa;AACrB;AACA;AACA;AACA,WAAW,kEAAa;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU,kDAAkD;AAC5D;AACA,YAAY,gCAAgC;AAC5C;AACA;AACA;AACA;AACA;AACA,YAAY,qDAAqD;AACjE;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB,eAAe,QAAQ,+DAA+D;AACtF,eAAe,QAAQ,6CAA6C,4BAA4B;AAChG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED,iEAAe,aAAa,EAAC","sources":["webpack://jclic/./src/PlayerHistory.js"],"sourcesContent":["/**\n * File : PlayerHistory.js\n * Created : 28/04/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 { log, isEquivalent, getPath, isNullOrUndef } from './Utils.js';\n\n/**\n *\n * PlayerHistory uses an array to store the list of projects and activities done by the user.\n * This class allows {@link module:JClicPlayer.JClicPlayer JClicPlayer} objects to rewind a sequence or to go back to a caller menu.\n */\nexport class PlayerHistory {\n /**\n * PlayerHistory constructor\n * @param {module:JClicPlayer.JClicPlayer} player - The JClicPlayer associated to this history\n */\n constructor(player) {\n this.player = player;\n this.sequenceStack = [];\n if (window && window.history && player.options.browserHistory) {\n this.browserHistory = true;\n $(window).on('popstate', (ev) => {\n const state = ev.originalEvent.state;\n if (state)\n this.processPopStateEvent(state);\n });\n }\n }\n\n /**\n *\n * Process the `state` object received in a `popstate` event\n * @param {PlayerHistory#HistoryElement} state - The previously stored state\n */\n processPopStateEvent(state) {\n log('info', 'Processing History popstate event with state:', state);\n this.processingPop = true;\n if (state.projectPath === this.player.project.path &&\n isEquivalent(state.fullZipPath, this.player.zip ? this.player.zip.fullZipPath : null))\n this.player.load(null, state.activity, null);\n else\n this.player.load(state.fullZipPath || state.projectPath, state.activity, null);\n }\n\n /**\n * Push a new entry on the window.History stack,\n * only when `browserHistory` is true and there is no `popstate` event in progress\n */\n pushBrowserHistory() {\n if (this.browserHistory) {\n\n if (this.processingPop) {\n // A 'popstate' event is currently being processed, so just clear this flag and return\n this.processingPop = false;\n return;\n }\n\n const\n ase = this.player.project.activitySequence,\n act = ase.currentAct,\n title = this.player.actPanel.act.name || 'No name',\n state = new this.HistoryElement(\n this.player.project.path,\n ase.getSequenceForElement(act),\n act,\n this.player.zip ? this.player.zip.fullZipPath : null);\n\n // Push a new history entry, or update the current one if it has no `state`\n if (!window.history.state)\n window.history.replaceState(state, title);\n else\n window.history.pushState(state, title);\n }\n }\n\n /**\n *\n * Counts the number of {@link module:PlayerHistory.PlayerHistory#HistoryElement HistoryElement} objects stored in\n * {@link module:PlayerHistory.PlayerHistory#sequenceStack sequenceStack}\n * @returns {number}\n */\n storedElementsCount() {\n return this.sequenceStack.length;\n }\n\n /**\n *\n * Removes all elements from {@link module:PlayerHistory.PlayerHistory#sequenceStack sequenceStack}\n */\n clearHistory() {\n this.sequenceStack = [0];\n }\n\n /**\n * Adds the current project and activity to the top of the history stack.\n */\n push() {\n if (this.player.project !== null && this.player.project.path !== null) {\n const\n ase = this.player.project.activitySequence,\n act = ase.currentAct;\n if (act >= 0) {\n if (this.sequenceStack.length > 0) {\n const last = this.sequenceStack[this.sequenceStack.length - 1];\n if (last.projectPath === this.player.project.path && last.activity === act)\n return;\n }\n this.sequenceStack.push(\n new this.HistoryElement(\n this.player.project.path,\n ase.getSequenceForElement(act),\n act,\n this.player.zip ? this.player.zip.fullZipPath : null));\n }\n }\n }\n\n /**\n * Retrieves the {@link module:PlayerHistory.PlayerHistory#HistoryElement HistoryElement} placed at the top of the\n * stack (if any) and instructs {@link module:JClicPlayer.JClicPlayer JClicPlayer} to load it. The obtained effect is to\n * \"rewind\" or \"go back\", usually to an activity that acts as a menu.\n * @returns {boolean}\n */\n pop() {\n // todo: check return value\n if (this.sequenceStack.length > 0) {\n const e = this.sequenceStack.pop();\n if (e.projectPath === this.player.project.path &&\n isEquivalent(e.fullZipPath, this.player.zip ? this.player.zip.fullZipPath : null))\n this.player.load(null, e.activity, null);\n else\n if (this.testMode && e.projectPath !== null && e.projectPath.length > 0)\n log('info', `At this point, a jump to \"${e.projectPath}\" should be performed.`);\n else\n this.player.load(e.fullZipPath || e.projectPath, e.activity, null);\n }\n return true;\n }\n\n /**\n *\n * Processes the provided {@link module:bags/JumpInfo.JumpInfo JumpInfo} object, instructing {@link module:JClicPlayer.JClicPlayer JClicPlayer} to go back,\n * stop or jump to another point in the sequence.\n * @param {module:bags/JumpInfo.JumpInfo} ji - The object to be processed\n * @param {boolean} allowReturn - When this parameter is `true`, the jump instructed by `ji` (if any)\n * will be recorded, thus allowing to return to the current activity.\n * @returns {boolean} - `true` if the jump can be processed without errors, `false` otherwise.\n */\n processJump(ji, allowReturn) {\n let result = false;\n if (ji !== null && this.player.project !== null) {\n switch (ji.action) {\n case 'STOP':\n break;\n case 'RETURN':\n if (this.sequenceStack.length > 0 || !this.player.options.returnAsExit) {\n result = this.pop();\n break;\n }\n case 'EXIT':\n if (this.testMode)\n log('info', 'At this point, the program should exit.');\n else\n this.player.exit(ji.sequence);\n break;\n case 'JUMP':\n if (!ji.sequence && !ji.projectPath) {\n const ase = this.player.project.activitySequence.getElement(ji.actNum, true);\n if (ase !== null) {\n if (allowReturn)\n this.push();\n this.player.load(null, null, ase.activity);\n result = true;\n }\n } else {\n if (this.testMode && ji.projectPath !== null && ji.projectPath.length > 0) {\n log('info', `At this point, a jump to \"${ji.projectPath}\" should be performed.`);\n } else {\n result = this.jumpToSequence(ji.sequence,\n ji.projectPath ? getPath(this.player.project.basePath, ji.projectPath) : null,\n allowReturn);\n }\n }\n break;\n }\n }\n return result;\n }\n\n /**\n * Performs a jump to the specified sequence\n * @param {string} sequence - The {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence} tag to jump to.\n * @param {string} [path] - When not `null`, indicates a new project file that must be loaded.\n * Otherwise, the `sequence` parameter refers to a tag on the {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence} of the\n * current project.\n * @param {boolean} [allowReturn] - When this parameter is `true`, the jump will be recorded, thus\n * allowing to return to the current activity.\n */\n jumpToSequence(sequence, path = null, allowReturn = false) {\n if (isNullOrUndef(sequence) && isNullOrUndef(path))\n return false;\n if (isNullOrUndef(path))\n path = this.player.project.path;\n if (this.sequenceStack.length > 0) {\n const e = this.sequenceStack[this.sequenceStack.length - 1];\n if (!isNullOrUndef(sequence) && path === e.projectPath) {\n let same = sequence === e.sequence;\n if (path === this.player.project.path) {\n const ase = this.player.project.activitySequence.getElement(e.activity, false);\n same = ase !== null && sequence === ase.tag;\n }\n if (same)\n return this.pop();\n }\n }\n if (allowReturn)\n this.push();\n if (path === this.player.project.path)\n this.player.load(null, sequence, null);\n else\n this.player.load(path, sequence, null);\n return true;\n }\n}\n\nObject.assign(PlayerHistory.prototype, {\n /**\n * The {@link module:JClicPlayer.JClicPlayer JClicPlayer} object to which this `PlayerHistory` belongs\n * @name module:PlayerHistory.PlayerHistory#player\n * @type {module:JClicPlayer.JClicPlayer} */\n player: null,\n /**\n * This is the main member of the class. PlayerHistory puts and retrieves\n * on it information about the proects and activities done by the current user.\n * @name module:PlayerHistory.PlayerHistory#sequenceStack\n * @type {module:PlayerHistory.PlayerHistory#HistoryElement[]} */\n sequenceStack: [],\n /**\n * When in test mode, jumps are only simulated.\n * @name module:PlayerHistory.PlayerHistory#testMode\n * @type {boolean} */\n testMode: false,\n /**\n * When true, JClic history is in sync with browser history\n * @name PlayerHistory#browserHistory\n * @type {boolean} */\n browserHistory: false,\n /**\n * When true, a window.history event is currently being processed, so window.pushState should not be performed\n * @name PlayerHistory#processingPop\n * @type {boolean} */\n processingPop: false,\n /**\n * Inner class used to store history elements.\n * @name module:PlayerHistory.PlayerHistory#HistoryElement\n */\n HistoryElement: class {\n /**\n * HistoryElement constructor\n * @param {string} projectPath - The full path of the project file\n * @param {string} sequence - The nearest sequence tag\n * @param {number} activity - The index of the current activity on the project's {@link module:bags/ActivitySequence.ActivitySequence ActivitySequence}\n * @param {string} fullZipPath - If `projectPath` resides in a {@link external:JSZip JSZip} object,\n * the full path of the zip file.\n */\n constructor(projectPath, sequence, activity, fullZipPath) {\n this.projectPath = projectPath;\n this.sequence = sequence;\n this.activity = activity;\n this.fullZipPath = fullZipPath;\n }\n }\n});\n\nexport default PlayerHistory;\n"],"names":[],"sourceRoot":""}