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":"1842.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;AACiG;AAC1D;;AAE9D,sBAAsB,yDAAQ;;AAE9B;AACA,sEAAsE,wDAAwD;AAC9H;AACA;AACA;AACA,yBAAyB,wDAAwD;AACjF,yBAAyB,wCAAwC;AACjE;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,8BAA8B;AAC3C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA,IAAI,gEAAW;AACf;AACA;AACA;AACA,uBAAuB,+DAAU;AACjC;AACA;AACA;AACA;AACA;AACA,kCAAkC,qDAAM;AACxC;AACA;AACA,kCAAkC,qDAAM;AACxC;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,oBAAoB,6CAAC;AACrB;AACA;AACA,2BAA2B,mDAAI;AAC/B;;AAEA;AACA,gCAAgC,uDAAQ;AACxC;;AAEA;AACA,2BAA2B,+DAAU;AACrC,2BAA2B,+DAAU;AACrC,6BAA6B,+DAAU;AACvC,+BAA+B,+DAAU;AACzC,kCAAkC,+DAAU;AAC5C,6BAA6B,+DAAU;AACvC;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;AACA;AACA;AACA;AACA,mBAAmB,4BAA4B;AAC/C,mBAAmB,4BAA4B;AAC/C,qBAAqB,8BAA8B;AACnD,uBAAuB,gCAAgC;AACvD,0BAA0B,mCAAmC;AAC7D,qBAAqB,8BAA8B;AACnD;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;AACA,QAAQ,yBAAyB,qDAAM,EAAE;AACzC,QAAQ,yBAAyB,qDAAM,EAAE;AACzC,QAAQ,iBAAiB,mDAAI,EAAE;AAC/B,QAAQ,uBAAuB,uDAAQ,EAAE;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,KAAK;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,KAAK;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,gEAAW;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,aAAa,SAAS;AACtB,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,8BAA8B,MAAM,KAAK,MAAM,SAAS,MAAM;AAC9D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,mCAAmC;AAChD,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,UAAU;AACzB,oFAAoF;AACpF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,kBAAkB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA,cAAc,gEAAW;AACzB;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,kBAAkB,wDAAS;AAC3B,OAAO;;AAEP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,8BAA8B;AAC1C;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,iBAAiB;AAC7B,YAAY,mDAAI;AAChB;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,qBAAqB;AACjC;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,mBAAmB;AAC/B,oBAAoB,qDAAM;AAC1B;AACA;AACA;AACA,YAAY,mBAAmB;AAC/B,oBAAoB,qDAAM;AAC1B,CAAC;;AAED;;AAEA,iEAAe,OAAO,EAAC;;;;;;;;;;;;;;;;AC7YvB;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;AAC2D;AAC/C;;AAEnC;AACA,2CAA2C,+CAA+C;AAC1F;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA,qBAAqB,mDAAO;AAC5B;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA,IAAI,gEAAW;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,+DAAU;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,uBAAuB,mDAAO,iBAAiB,6CAAC;AAChD,KAAK;;AAEL;;AAEA,mCAAmC,cAAc;AACjD;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,yDAAQ,cAAc;AAC3C;AACA;;AAEA;AACA;AACA,aAAa,eAAe;AAC5B,eAAe;AACf;AACA;AACA,WAAW,4DAAO;AAClB;AACA;AACA;AACA,QAAQ,kBAAkB,mDAAO,EAAE;AACnC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,sBAAsB,cAAc;AACpC,wBAAwB,cAAc;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA,UAAU,4CAA4C;AACtD;AACA,YAAY,8BAA8B;AAC1C;AACA;AACA;AACA;AACA;AACA,YAAY,UAAU;AACtB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB,eAAe,yDAAQ;AACvB,CAAC;;AAED,iEAAe,eAAe,EAAC","sources":["webpack://jclic/./src/boxes/BoxBase.js","webpack://jclic/./src/boxes/TextGridContent.js"],"sourcesContent":["/**\n * File : boxes/BoxBase.js\n * Created : 12/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 $ from 'jquery';\nimport { settings, attrForEach, getBoolean, checkColor, getAttr, setAttr, cloneObject, isSeparator } from '../Utils.js';\nimport { Stroke, Gradient, Font, Dimension } from '../AWT.js';\n\nconst defaultValues = settings.BoxBase;\n\n/**\n * This class contains all the main visual attributes needed to draw {@link module:boxes/AbstractBox.AbstractBox AbstractBox} objects:\n * background and foreground colors, gradients, colors for special states (inactive, alternative,\n * disabled...), margins, fonts, border strokes, etc.\n *\n * Objects derived from {@link module:boxes/AbstractBox.AbstractBox AbstractBox} can have inheritance: boxes that act as \"containers\"\n * of other boxes (like {@link module:boxes/BoxBag.BoxBag BoxBag}). Most of the attributes of `BoxBase` can be `null`,\n * meaning that the value of the ancestor -or the default value if the box has no ancestors- must\n * be used.\n */\nexport class BoxBase {\n /**\n * BoxBase constructor\n * @param {module:boxes/BoxBase.BoxBase} [parent] - Another BoxBase object used to determine the value of properties not\n * locally set.\n */\n constructor(parent) {\n this.parent = parent || null;\n }\n\n /**\n * Loads the BoxBase settings from a specific JQuery XML element\n * @param {external:jQuery} $xml - The XML element to parse\n */\n setProperties($xml) {\n //\n // Read attributes\n attrForEach($xml.get(0).attributes, (name, val) => {\n switch (name) {\n case 'shadow':\n case 'transparent':\n this[name] = getBoolean(val, false);\n break;\n case 'margin':\n this[name] = Number(val);\n break;\n case 'borderStroke':\n this.borderStroke = new Stroke(Number(val));\n break;\n case 'markerStroke':\n this.markerStroke = new Stroke(Number(val));\n break;\n }\n });\n //\n // Read inner elements\n $xml.children().each((_n, child) => {\n const $node = $(child);\n switch (child.nodeName) {\n case 'font':\n this.font = (new Font()).setProperties($node);\n break;\n\n case 'gradient':\n this.bgGradient = new Gradient().setProperties($node);\n break;\n\n case 'color':\n this.textColor = checkColor($node.attr('foreground'), this.textColor);\n this.backColor = checkColor($node.attr('background'), this.backColor);\n this.shadowColor = checkColor($node.attr('shadow'), this.shadowColor);\n this.inactiveColor = checkColor($node.attr('inactive'), this.inactiveColor);\n this.alternativeColor = checkColor($node.attr('alternative'), this.alternativeColor);\n this.borderColor = checkColor($node.attr('border'), this.borderColor);\n break;\n }\n });\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, [\n 'shadow', 'transparent', 'margin',\n 'borderStroke', 'markerStroke', // AWT.Stroke\n 'font', // AWT.Font\n 'bgGradient', // AWT.Gradient\n `textColor|${BoxBase.prototype.textColor}`,\n `backColor|${BoxBase.prototype.backColor}`,\n `shadowColor|${BoxBase.prototype.shadowColor}`,\n `inactiveColor|${BoxBase.prototype.inactiveColor}`,\n `alternativeColor|${BoxBase.prototype.alternativeColor}`,\n `borderColor|${BoxBase.prototype.borderColor}`,\n ]);\n }\n\n /**\n * Reads the properties of this BoxBase from a data object\n * @param {object} data - The data object to be parsed\n * @returns {module:boxes/BoxBase.BoxBase}\n */\n setAttributes(data) {\n return setAttr(this, data, [\n 'shadow', 'transparent', 'margin',\n { key: 'borderStroke', fn: Stroke },\n { key: 'markerStroke', fn: Stroke },\n { key: 'font', fn: Font },\n { key: 'bgGradient', fn: Gradient },\n 'textColor',\n 'backColor',\n 'shadowColor',\n 'inactiveColor',\n 'alternativeColor',\n 'borderColor',\n ]);\n }\n\n /**\n * Gets the value of the specified property, scanning down to parents and prototype if not defined.\n * @param {string} property - The property to retrieve\n * @returns {any} - The object or value associated to this property\n */\n get(property) {\n if (this.hasOwnProperty(property) || this.parent === null)\n return this[property];\n else\n return this.parent.get(property);\n }\n\n /**\n * Sets the value of a specific property.\n * @param {string} property - The property name.\n * @param {any} value - Depends on the type of property\n */\n set(property, value) {\n this[property] = value;\n return this;\n }\n\n /**\n * Gets the value of the specified property, scanning down to parents if not defined, and returning\n * always an own property (not from prototype)\n * @param {string} property - The property to retrieve\n * @returns {any} - The object or value associated to this property\n */\n getOwn(property) {\n if (this.hasOwnProperty(property))\n return this[property];\n else if (this.parent !== null)\n return this.parent.getOwn(property);\n else {\n if (typeof this[property] === 'object')\n this[property] = cloneObject(BoxBase.prototype[property]);\n else\n this[property] = BoxBase.prototype[property];\n }\n return this[property];\n }\n\n /**\n * Gets the properties defined in this BoxBase as a collection of CSS attributes\n * @param {object} [css] - An optional set of initial CSS properties\n * @param {boolean} [inactive=false] - When `true`, get CSS attributes for an inactive cell\n * @param {boolean} [inverse=false] - When `true`, get CSS attributes for an inverse cell\n * @param {boolean} [alternative=false] - When `true`, get CSS attributes for an alternative cell\n * @returns {object}\n */\n getCSS(css, inactive = false, inverse = false, alternative = false) {\n // (css will be created by [AWT.Font.toCss](AWT.html) if null or undefined)\n const font = this.get('font');\n css = font.toCss(css);\n\n css['color'] = inverse ? this.get('backColor')\n : alternative ? this.get('alternativeColor')\n : this.get('textColor');\n\n const transparent = this.get('transparent');\n css['background-color'] = transparent ? 'transparent'\n : inactive ? this.get('inactiveColor')\n : inverse ? this.get('textColor') : this.get('backColor');\n\n const bgGradient = this.get('bgGradient');\n if (bgGradient && !transparent)\n css['background-image'] = bgGradient.getCss();\n\n if (this.shadow === 1) {\n const delta = Math.max(1, Math.round(font.size / 10));\n const color = this.get('shadowColor');\n css['text-shadow'] = `${delta}px ${delta}px 3px ${color}`;\n }\n return css;\n }\n\n /**\n * This utility method computes the width and height of text lines rendered on an HTML\n * __canvas__ element, reducing the font size of the BoxBase as needed when they exceed the maximum\n * width and/or height.\n * @param {external:CanvasRenderingContext2D} ctx - The canvas rendering context used to draw the text.\n * @param {string} text - The text to drawn.\n * @param {number} maxWidth - Maximum width\n * @param {number} maxHeight - Maximum height\n * @returns {object[]} - An array of objects representing lines of text. Each object has a `text`\n * member with the text displayed in the line, and a `size` member with the line {@link module:AWT.Dimension}\n */\n prepareText(ctx, text, maxWidth, maxHeight) {\n const\n result = [],\n font = this.get('font'),\n height = font.getHeight();\n let totalHeight = 0;\n\n // divide the text in lines\n const lines = text.trim().split('\\n');\n ctx.font = font.cssFont();\n for (let l = 0; l < lines.length; l++) {\n let line = lines[l].trim();\n let width = ctx.measureText(line).width;\n if (width > maxWidth) {\n // retain the last string offset that was inside maxWidth\n let\n lastOK = 0,\n lastOKWidth = 0;\n for (let p = 0; p < line.length; p++) {\n // Find next separator\n if (isSeparator(line[p])) {\n const w = ctx.measureText(line.substring(0, p).trim()).width;\n if (w > maxWidth)\n break;\n lastOK = p;\n lastOKWidth = w;\n }\n }\n if (lastOK > 0) {\n // Add a new line with the tail of the line\n lines.splice(l + 1, 0, line.substring(lastOK + 1).trim());\n // Adjust the current line\n line = lines[l] = line.substring(0, lastOK).trim();\n width = lastOKWidth;\n }\n else {\n // No solution found. Try resizing down the font.\n if (font.size > defaultValues.MIN_FONT_SIZE) {\n this.getOwn('font').zoom(-1);\n return this.prepareText(ctx, text, maxWidth, maxHeight);\n }\n }\n }\n\n // Add the line and the calculated dimension to `result`\n result.push({\n text: line,\n size: new Dimension(width, height)\n });\n\n totalHeight += height;\n\n if (totalHeight > maxHeight && font.size > defaultValues.MIN_FONT_SIZE) {\n // Max height exceeded. Try resizing down the font\n this.getOwn('font').zoom(-1);\n return this.prepareText(ctx, text, maxWidth, maxHeight);\n }\n }\n return result;\n }\n}\n\nObject.assign(BoxBase.prototype, {\n /**\n * The parent BoxBase object\n * @name module:boxes/BoxBase.BoxBase#parent\n * @type {module:boxes/BoxBase.BoxBase} */\n parent: null,\n /**\n * Default values\n * @name module:boxes/BoxBase.BoxBase#defaultValues\n * @type {object} */\n default: defaultValues,\n /**\n * Font size can be dynamically reduced to fit the available space if any element using this\n * `BoxBase` requests it. When this happen, this field contains the real font currently used\n * to draw text.\n * @name module:boxes/BoxBase.BoxBase#font\n * @type {module:AWT.Font} */\n font: new Font(),\n /**\n * The current font size of this BoxBase. Can be dynamically adjusted when drawing.\n * @name module:boxes/BoxBase.BoxBase#dynFontSize\n * @type {number} */\n dynFontSize: 0,\n /**\n * Counts the number of times the `dynFontSize` has been reset. This is useful to avoid excessive\n * recursive loops searching the optimal font size.\n * @name module:boxes/BoxBase.BoxBase#resetFontCounter\n * @type {number} */\n resetFontCounter: 0,\n /**\n * The background color\n * @name module:boxes/BoxBase.BoxBase#backColor\n * @type {string} */\n backColor: defaultValues.BACK_COLOR,\n /**\n * The background gradient. Default is `null`.\n * @name module:boxes/BoxBase.BoxBase#bgGradient\n * @type {module:AWT.Gradient} */\n bgGradient: null,\n /**\n * The color used to write text.\n * @name module:boxes/BoxBase.BoxBase#textColor\n * @type {string} */\n textColor: defaultValues.TEXT_COLOR,\n /**\n * The color used to draw a shadow below regular text.\n * @name module:boxes/BoxBase.BoxBase#shadowColor\n * @type {string} */\n shadowColor: defaultValues.SHADOW_COLOR,\n /**\n * The color of the border.\n * @name module:boxes/BoxBase.BoxBase#borderColor\n * @type {string} */\n borderColor: defaultValues.BORDER_COLOR,\n /**\n * The color used to draw text when a cell is in `inactive` state.\n * @name module:boxes/BoxBase.BoxBase#inactiveColor\n * @type {string} */\n inactiveColor: defaultValues.INACTIVE_COLOR,\n /**\n * The color used to draw text when a cell is in `alternative` state.\n * @name module:boxes/BoxBase.BoxBase#alternativeColor\n * @type {string} */\n alternativeColor: defaultValues.ALTERNATIVE_COLOR,\n /**\n * Whether the text should have a shadow or not\n * @name module:boxes/BoxBase.BoxBase#shadow\n * @type {boolean} */\n shadow: false,\n /**\n * Whether the cell's background (and its hosted component, if any) should be transparent\n * @name module:boxes/BoxBase.BoxBase#transparent\n * @type {boolean} */\n transparent: false,\n /**\n * Wheter the cell's background should be painted or not. This property has no effect on\n * hosted components.\n * @name module:boxes/BoxBase.BoxBase#dontFill\n * @type {boolean} */\n dontFill: false,\n /**\n * The margin to respect between text elements and the limits of the cell or other elements.\n * @name module:boxes/BoxBase.BoxBase#textMargin\n * @type {number} */\n textMargin: defaultValues.AC_MARGIN,\n /**\n * The stroke used to draw the border.\n * @name module:boxes/BoxBase.BoxBase#borderStroke\n * @type {module:AWT.Stroke} */\n borderStroke: new Stroke(defaultValues.BORDER_STROKE_WIDTH),\n /**\n * The stroke used to draw a border around marked cells.\n * @name module:boxes/BoxBase.BoxBase#markerStroke\n * @type {module:AWT.Stroke} */\n markerStroke: new Stroke(defaultValues.MARKER_STROKE_WIDTH),\n});\n\nBoxBase.DEFAULT_BOX_BASE = new BoxBase();\n\nexport default BoxBase;\n","/**\n * File : boxes/TextGridContent.js\n * Created : 14/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 { settings, attrForEach, getBoolean, getAttr, setAttr } from '../Utils.js';\nimport BoxBase from './BoxBase.js';\n\n/**\n * This class encapsulates the content of {@link module:boxes/TextGrid.TextGrid TextGrid} objects.\n *\n * It implements methods to set and retrieve individual characters on the grid, and parsing of\n * XML objects. It also contains information about the optimal size and other graphic properties\n * (fonts, colors, etc.) of the grid.\n */\nexport class TextGridContent {\n /**\n * TextGridContent constructor\n */\n constructor() {\n this.style = new BoxBase(null);\n this.text = [];\n }\n\n /**\n * Loads the object settings from a specific JQuery XML element\n * @param {external:jQuery} $xml\n */\n setProperties($xml) {\n // Read attributes\n attrForEach($xml.get(0).attributes, (name, val) => {\n switch (name) {\n case 'rows':\n // WARNING: Due to a bug in JClic, the meaning of \"rows\" and \"columns\" must be\n // interchanged:\n this.ncw = Number(val);\n break;\n case 'columns':\n this.nch = Number(val);\n break;\n case 'cellWidth':\n this.w = Number(val);\n break;\n case 'cellHeight':\n this.h = Number(val);\n break;\n case 'border':\n this.border = getBoolean(val);\n break;\n case 'wild':\n case 'randomChars':\n this[name] = val;\n break;\n }\n });\n\n // Read inner elements\n $xml.children('style:first').each((_n, child) => {\n this.style = new BoxBase().setProperties($(child));\n });\n\n $xml.find('text:first > row').each((_n, el) => this.text.push(el.textContent));\n\n for (let i = this.text.length; i < this.nch; i++)\n this.text[i] = '';\n\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, [\n 'ncw', 'nch',\n 'w', 'h',\n 'text',\n 'style', // BoxBase\n 'border',\n 'wild|*',\n `randomChars|${settings.RANDOM_CHARS}`,\n ]);\n }\n\n /**\n * Reads the properties of this TextGridContent from a data object\n * @param {object|string} data - The data object to be parsed, or just the text content\n * @returns {module:boxes/TextGridContent.TextGridContent}\n */\n setAttributes(data) {\n return setAttr(this, data, [\n 'ncw', 'nch',\n 'w', 'h',\n 'text',\n { key: 'style', fn: BoxBase },\n 'border',\n 'wild',\n `randomChars`,\n ]);\n }\n\n /**\n * Counts the number of wildcard characters present in this TextGrid\n * @returns {number}\n */\n countWildChars() {\n let result = 0;\n if (this.text)\n for (let y = 0; y < this.nch; y++)\n for (let x = 0; x < this.ncw; x++)\n if (this.text[y].charAt(x) === this.wild)\n result++;\n return result;\n }\n\n /**\n * Counts the total number of characters, including wildcard characters.\n * @returns {number}\n */\n getNumChars() {\n return this.ncw * this.nch;\n }\n\n /**\n * Sets the specified character as a content of the cell located at specific coordinates\n * @param {number} x - The X coordinate of the cell\n * @param {number} y - The X coordinate of the cell\n * @param {string} ch - The character to be placed on the specified cell\n */\n setCharAt(x, y, ch) {\n if (x >= 0 && x < this.ncw && y >= 0 && y < this.nch)\n this.text[y] = this.text[y].substring(0, x) + ch + this.text[y].substring(x + 1);\n }\n}\n\nObject.assign(TextGridContent.prototype, {\n /**\n * Grid columns\n * @name module:boxes/TextGridContent.TextGridContent#ncw\n * @type {number} */\n ncw: 1,\n /**\n * Grid rows\n * @name module:boxes/TextGridContent.TextGridContent#nch\n * @type {number} */\n nch: 1,\n /**\n * Width of cells\n * @name module:boxes/TextGridContent.TextGridContent#w\n * @type {number} */\n w: 20,\n /**\n * Height of cells\n * @name module:boxes/TextGridContent.TextGridContent#h\n * @type {number} */\n h: 20,\n /**\n * Whether the cells must be surrounded by a border or not\n * @name module:boxes/TextGridContent.TextGridContent#border\n * @type {boolean} */\n border: false,\n /**\n * The {@link module:boxes/BoxBase.BoxBase BoxBase} object with visual settings of the text grid\n * @name module:boxes/TextGridContent.TextGridContent#style\n * @type {module:boxes/BoxBase.BoxBase} */\n style: null,\n /**\n * An array of String objects textning the chars of cells. One string per row, one character of\n * this string per cell.\n * @name module:boxes/TextGridContent.TextGridContent#text\n * @type {string[]} */\n text: null,\n /**\n * The letter used as wildcardtext\n * @name module:boxes/TextGridContent.TextGridContent#wild\n * @type {string} */\n wild: '*',\n /**\n * A String with the chars to take as source when randomly filling empty cells\n * @name module:boxes/TextGridContent.TextGridContent#randomChars\n * @type {string} */\n randomChars: settings.RANDOM_CHARS,\n});\n\nexport default TextGridContent;\n"],"names":[],"sourceRoot":""}