@bbn/bbn 1.0.58 → 1.0.60

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 (464) hide show
  1. package/dist/_.js +1 -1
  2. package/dist/bundle.d.ts +3804 -242
  3. package/dist/bundle.js +4063 -504
  4. package/dist/db.js +3 -3
  5. package/dist/fn/ajax/_addLoader.d.ts +16 -0
  6. package/dist/fn/ajax/_addLoader.js +51 -0
  7. package/dist/fn/ajax/_deleteLoader.d.ts +16 -0
  8. package/dist/fn/ajax/_deleteLoader.js +39 -0
  9. package/dist/fn/ajax/abort.d.ts +24 -0
  10. package/dist/fn/ajax/abort.js +36 -0
  11. package/dist/fn/ajax/abortURL.d.ts +22 -0
  12. package/dist/fn/ajax/abortURL.js +33 -0
  13. package/dist/fn/ajax/ajax.d.ts +58 -0
  14. package/dist/fn/ajax/ajax.js +170 -0
  15. package/dist/fn/ajax/callback.d.ts +37 -0
  16. package/dist/fn/ajax/callback.js +117 -0
  17. package/dist/fn/ajax/download.d.ts +30 -0
  18. package/dist/fn/ajax/download.js +64 -0
  19. package/dist/fn/ajax/downloadContent.d.ts +28 -0
  20. package/dist/fn/ajax/downloadContent.js +74 -0
  21. package/dist/fn/ajax/getLoader.d.ts +37 -0
  22. package/dist/fn/ajax/getLoader.js +44 -0
  23. package/dist/fn/ajax/getRequestId.d.ts +50 -0
  24. package/dist/fn/ajax/getRequestId.js +62 -0
  25. package/dist/fn/ajax/link.d.ts +26 -0
  26. package/dist/fn/ajax/link.js +129 -0
  27. package/dist/fn/ajax/post.d.ts +35 -0
  28. package/dist/fn/ajax/post.js +45 -0
  29. package/dist/fn/ajax/postOut.d.ts +21 -0
  30. package/dist/fn/ajax/postOut.js +49 -0
  31. package/dist/fn/ajax/setNavigationVars.d.ts +25 -0
  32. package/dist/fn/ajax/setNavigationVars.js +80 -0
  33. package/dist/fn/ajax/treatAjaxArguments.d.ts +53 -0
  34. package/dist/fn/ajax/treatAjaxArguments.js +127 -0
  35. package/dist/fn/ajax/upload.d.ts +18 -0
  36. package/dist/fn/ajax/upload.js +52 -0
  37. package/dist/fn/ajax.js +3 -3
  38. package/dist/fn/browser/copy.d.ts +15 -0
  39. package/dist/fn/browser/copy.js +50 -0
  40. package/dist/fn/browser/eraseCookie.d.ts +15 -0
  41. package/dist/fn/browser/eraseCookie.js +17 -0
  42. package/dist/fn/browser/error.d.ts +14 -0
  43. package/dist/fn/browser/error.js +29 -0
  44. package/dist/fn/browser/getBrowserName.d.ts +9 -0
  45. package/dist/fn/browser/getBrowserName.js +28 -0
  46. package/dist/fn/browser/getBrowserVersion.d.ts +9 -0
  47. package/dist/fn/browser/getBrowserVersion.js +29 -0
  48. package/dist/fn/browser/getCookie.d.ts +16 -0
  49. package/dist/fn/browser/getCookie.js +32 -0
  50. package/dist/fn/browser/getDeviceType.d.ts +14 -0
  51. package/dist/fn/browser/getDeviceType.js +23 -0
  52. package/dist/fn/browser/getEventData.d.ts +16 -0
  53. package/dist/fn/browser/getEventData.js +116 -0
  54. package/dist/fn/browser/happy.d.ts +14 -0
  55. package/dist/fn/browser/happy.js +22 -0
  56. package/dist/fn/browser/history.d.ts +2 -0
  57. package/dist/fn/browser/history.js +4 -0
  58. package/dist/fn/browser/info.d.ts +10 -0
  59. package/dist/fn/browser/info.js +19 -0
  60. package/dist/fn/browser/isActiveInterface.d.ts +14 -0
  61. package/dist/fn/browser/isActiveInterface.js +20 -0
  62. package/dist/fn/browser/isDesktopDevice.d.ts +14 -0
  63. package/dist/fn/browser/isDesktopDevice.js +17 -0
  64. package/dist/fn/browser/isFocused.d.ts +21 -0
  65. package/dist/fn/browser/isFocused.js +23 -0
  66. package/dist/fn/browser/isMobile.d.ts +14 -0
  67. package/dist/fn/browser/isMobile.js +18 -0
  68. package/dist/fn/browser/isMobileDevice.d.ts +2 -0
  69. package/dist/fn/browser/isMobileDevice.js +5 -0
  70. package/dist/fn/browser/isTabletDevice.d.ts +14 -0
  71. package/dist/fn/browser/isTabletDevice.js +17 -0
  72. package/dist/fn/browser/log.d.ts +15 -0
  73. package/dist/fn/browser/log.js +46 -0
  74. package/dist/fn/browser/replaceSelection.d.ts +2 -0
  75. package/dist/fn/browser/replaceSelection.js +42 -0
  76. package/dist/fn/browser/selectElementText.d.ts +21 -0
  77. package/dist/fn/browser/selectElementText.js +42 -0
  78. package/dist/fn/browser/setCookie.d.ts +16 -0
  79. package/dist/fn/browser/setCookie.js +25 -0
  80. package/dist/fn/browser/toggleFullScreen.d.ts +2 -0
  81. package/dist/fn/browser/toggleFullScreen.js +39 -0
  82. package/dist/fn/browser/warning.d.ts +14 -0
  83. package/dist/fn/browser/warning.js +24 -0
  84. package/dist/fn/convert/arrayBuffer2String.d.ts +2 -0
  85. package/dist/fn/convert/arrayBuffer2String.js +4 -0
  86. package/dist/fn/convert/canvasToImage.d.ts +16 -0
  87. package/dist/fn/convert/canvasToImage.js +20 -0
  88. package/dist/fn/convert/colorToHex.d.ts +20 -0
  89. package/dist/fn/convert/colorToHex.js +24 -0
  90. package/dist/fn/convert/fromXml.d.ts +12 -0
  91. package/dist/fn/convert/fromXml.js +54 -0
  92. package/dist/fn/convert/hex2rgb.d.ts +24 -0
  93. package/dist/fn/convert/hex2rgb.js +29 -0
  94. package/dist/fn/convert/imageToCanvas.d.ts +15 -0
  95. package/dist/fn/convert/imageToCanvas.js +21 -0
  96. package/dist/fn/convert/imgToBase64.d.ts +2 -0
  97. package/dist/fn/convert/imgToBase64.js +7 -0
  98. package/dist/fn/convert/rgb2hex.d.ts +20 -0
  99. package/dist/fn/convert/rgb2hex.js +28 -0
  100. package/dist/fn/convert/string2ArrayBuffer.d.ts +2 -0
  101. package/dist/fn/convert/string2ArrayBuffer.js +9 -0
  102. package/dist/fn/convert/toCSV.d.ts +26 -0
  103. package/dist/fn/convert/toCSV.js +64 -0
  104. package/dist/fn/datetime/calendar.d.ts +2 -0
  105. package/dist/fn/datetime/calendar.js +23 -0
  106. package/dist/fn/datetime/chrono.d.ts +25 -0
  107. package/dist/fn/datetime/chrono.js +45 -0
  108. package/dist/fn/datetime/date.d.ts +18 -0
  109. package/dist/fn/datetime/date.js +44 -0
  110. package/dist/fn/datetime/dateSQL.d.ts +20 -0
  111. package/dist/fn/datetime/dateSQL.js +26 -0
  112. package/dist/fn/datetime/daysInMonth.d.ts +17 -0
  113. package/dist/fn/datetime/daysInMonth.js +24 -0
  114. package/dist/fn/datetime/fdate.d.ts +11 -0
  115. package/dist/fn/datetime/fdate.js +28 -0
  116. package/dist/fn/datetime/fdatetime.d.ts +9 -0
  117. package/dist/fn/datetime/fdatetime.js +30 -0
  118. package/dist/fn/datetime/formatDate.d.ts +2 -0
  119. package/dist/fn/datetime/formatDate.js +4 -0
  120. package/dist/fn/datetime/ftime.d.ts +9 -0
  121. package/dist/fn/datetime/ftime.js +21 -0
  122. package/dist/fn/datetime/getDay.d.ts +11 -0
  123. package/dist/fn/datetime/getDay.js +26 -0
  124. package/dist/fn/datetime/timestamp.d.ts +15 -0
  125. package/dist/fn/datetime/timestamp.js +18 -0
  126. package/dist/fn/default/defaultAjaxAbortFunction.d.ts +2 -0
  127. package/dist/fn/default/defaultAjaxAbortFunction.js +5 -0
  128. package/dist/fn/default/defaultAjaxErrorFunction.d.ts +2 -0
  129. package/dist/fn/default/defaultAjaxErrorFunction.js +4 -0
  130. package/dist/fn/default/defaultAlertFunction.d.ts +2 -0
  131. package/dist/fn/default/defaultAlertFunction.js +5 -0
  132. package/dist/fn/default/defaultConfirmFunction.d.ts +2 -0
  133. package/dist/fn/default/defaultConfirmFunction.js +14 -0
  134. package/dist/fn/default/defaultEndLoadingFunction.d.ts +2 -0
  135. package/dist/fn/default/defaultEndLoadingFunction.js +4 -0
  136. package/dist/fn/default/defaultErrorFunction.d.ts +2 -0
  137. package/dist/fn/default/defaultErrorFunction.js +5 -0
  138. package/dist/fn/default/defaultHistoryFunction.d.ts +2 -0
  139. package/dist/fn/default/defaultHistoryFunction.js +4 -0
  140. package/dist/fn/default/defaultLinkFunction.d.ts +2 -0
  141. package/dist/fn/default/defaultLinkFunction.js +4 -0
  142. package/dist/fn/default/defaultPostLinkFunction.d.ts +2 -0
  143. package/dist/fn/default/defaultPostLinkFunction.js +4 -0
  144. package/dist/fn/default/defaultPreLinkFunction.d.ts +2 -0
  145. package/dist/fn/default/defaultPreLinkFunction.js +4 -0
  146. package/dist/fn/default/defaultResizeFunction.d.ts +2 -0
  147. package/dist/fn/default/defaultResizeFunction.js +4 -0
  148. package/dist/fn/default/defaultStartLoadingFunction.d.ts +2 -0
  149. package/dist/fn/default/defaultStartLoadingFunction.js +4 -0
  150. package/dist/fn/form/addInputs.d.ts +43 -0
  151. package/dist/fn/form/addInputs.js +81 -0
  152. package/dist/fn/form/fieldValue.d.ts +12 -0
  153. package/dist/fn/form/fieldValue.js +34 -0
  154. package/dist/fn/form/formdata.d.ts +45 -0
  155. package/dist/fn/form/formdata.js +95 -0
  156. package/dist/fn/form/objectToFormData.d.ts +12 -0
  157. package/dist/fn/form/objectToFormData.js +45 -0
  158. package/dist/fn/form/submit.d.ts +20 -0
  159. package/dist/fn/form/submit.js +51 -0
  160. package/dist/fn/html/adjustHeight.d.ts +2 -0
  161. package/dist/fn/html/adjustHeight.js +10 -0
  162. package/dist/fn/html/adjustSize.d.ts +2 -0
  163. package/dist/fn/html/adjustSize.js +21 -0
  164. package/dist/fn/html/adjustWidth.d.ts +2 -0
  165. package/dist/fn/html/adjustWidth.js +10 -0
  166. package/dist/fn/html/getAllTags.d.ts +6 -0
  167. package/dist/fn/html/getAllTags.js +9 -0
  168. package/dist/fn/html/getAncestors.d.ts +2 -0
  169. package/dist/fn/html/getAncestors.js +25 -0
  170. package/dist/fn/html/getAttributes.d.ts +6 -0
  171. package/dist/fn/html/getAttributes.js +16 -0
  172. package/dist/fn/html/getHTMLOfSelection.d.ts +2 -0
  173. package/dist/fn/html/getHTMLOfSelection.js +18 -0
  174. package/dist/fn/html/getHtml.d.ts +2 -0
  175. package/dist/fn/html/getHtml.js +9 -0
  176. package/dist/fn/html/getPath.d.ts +10 -0
  177. package/dist/fn/html/getPath.js +50 -0
  178. package/dist/fn/html/getText.d.ts +2 -0
  179. package/dist/fn/html/getText.js +4 -0
  180. package/dist/fn/html/html2text.d.ts +17 -0
  181. package/dist/fn/html/html2text.js +22 -0
  182. package/dist/fn/html/isInside.d.ts +2 -0
  183. package/dist/fn/html/isInside.js +23 -0
  184. package/dist/fn/html/makeReactive.d.ts +2 -0
  185. package/dist/fn/html/makeReactive.js +185 -0
  186. package/dist/fn/html/selector.d.ts +10 -0
  187. package/dist/fn/html/selector.js +12 -0
  188. package/dist/fn/init.d.ts +13 -0
  189. package/dist/fn/init.js +25 -12
  190. package/dist/fn/loop/each.d.ts +33 -0
  191. package/dist/fn/loop/each.js +54 -0
  192. package/dist/fn/loop/fori.d.ts +36 -0
  193. package/dist/fn/loop/fori.js +53 -0
  194. package/dist/fn/loop/forir.d.ts +36 -0
  195. package/dist/fn/loop/forir.js +53 -0
  196. package/dist/fn/loop/iterate.d.ts +22 -0
  197. package/dist/fn/loop/iterate.js +36 -0
  198. package/dist/fn/loop/riterate.d.ts +21 -0
  199. package/dist/fn/loop/riterate.js +24 -0
  200. package/dist/fn/misc/analyzeFunction.d.ts +11 -0
  201. package/dist/fn/misc/analyzeFunction.js +141 -0
  202. package/dist/fn/misc/getTimeoff.d.ts +14 -0
  203. package/dist/fn/misc/getTimeoff.js +19 -0
  204. package/dist/fn/misc/money.d.ts +23 -0
  205. package/dist/fn/misc/money.js +122 -0
  206. package/dist/fn/misc/percent.d.ts +23 -0
  207. package/dist/fn/misc/percent.js +25 -0
  208. package/dist/fn/misc/randomInt.d.ts +22 -0
  209. package/dist/fn/misc/randomInt.js +24 -0
  210. package/dist/fn/misc/roundDecimal.d.ts +11 -0
  211. package/dist/fn/misc/roundDecimal.js +13 -0
  212. package/dist/fn/misc/translate.d.ts +2 -0
  213. package/dist/fn/misc/translate.js +8 -0
  214. package/dist/fn/object/_compareValues.d.ts +40 -0
  215. package/dist/fn/object/_compareValues.js +78 -0
  216. package/dist/fn/object/arrayFromProp.d.ts +33 -0
  217. package/dist/fn/object/arrayFromProp.js +41 -0
  218. package/dist/fn/object/autoExtend.d.ts +33 -0
  219. package/dist/fn/object/autoExtend.js +44 -0
  220. package/dist/fn/object/checkProps.d.ts +2 -0
  221. package/dist/fn/object/checkProps.js +5 -0
  222. package/dist/fn/object/checkPropsDetails.d.ts +2 -0
  223. package/dist/fn/object/checkPropsDetails.js +53 -0
  224. package/dist/fn/object/checkPropsOrDie.d.ts +2 -0
  225. package/dist/fn/object/checkPropsOrDie.js +9 -0
  226. package/dist/fn/object/circularReplacer.d.ts +7 -0
  227. package/dist/fn/object/circularReplacer.js +39 -0
  228. package/dist/fn/object/clone.d.ts +19 -0
  229. package/dist/fn/object/clone.js +33 -0
  230. package/dist/fn/object/compare.d.ts +53 -0
  231. package/dist/fn/object/compare.js +150 -0
  232. package/dist/fn/object/compareConditions.d.ts +46 -0
  233. package/dist/fn/object/compareConditions.js +86 -0
  234. package/dist/fn/object/count.d.ts +56 -0
  235. package/dist/fn/object/count.js +59 -0
  236. package/dist/fn/object/createObject.d.ts +2 -0
  237. package/dist/fn/object/createObject.js +9 -0
  238. package/dist/fn/object/deepPath.d.ts +57 -0
  239. package/dist/fn/object/deepPath.js +78 -0
  240. package/dist/fn/object/deleteProp.d.ts +8 -0
  241. package/dist/fn/object/deleteProp.js +13 -0
  242. package/dist/fn/object/diffObj.d.ts +79 -0
  243. package/dist/fn/object/diffObj.js +168 -0
  244. package/dist/fn/object/extend.d.ts +87 -0
  245. package/dist/fn/object/extend.js +158 -0
  246. package/dist/fn/object/extendOut.d.ts +18 -0
  247. package/dist/fn/object/extendOut.js +40 -0
  248. package/dist/fn/object/filter.d.ts +50 -0
  249. package/dist/fn/object/filter.js +94 -0
  250. package/dist/fn/object/filterToConditions.d.ts +48 -0
  251. package/dist/fn/object/filterToConditions.js +68 -0
  252. package/dist/fn/object/findAll.d.ts +57 -0
  253. package/dist/fn/object/findAll.js +73 -0
  254. package/dist/fn/object/getField.d.ts +30 -0
  255. package/dist/fn/object/getField.js +37 -0
  256. package/dist/fn/object/getFieldValues.d.ts +30 -0
  257. package/dist/fn/object/getFieldValues.js +41 -0
  258. package/dist/fn/object/getProp.d.ts +8 -0
  259. package/dist/fn/object/getProp.js +13 -0
  260. package/dist/fn/object/getProperty.d.ts +30 -0
  261. package/dist/fn/object/getProperty.js +39 -0
  262. package/dist/fn/object/getRow.d.ts +42 -0
  263. package/dist/fn/object/getRow.js +49 -0
  264. package/dist/fn/object/map.d.ts +74 -0
  265. package/dist/fn/object/map.js +83 -0
  266. package/dist/fn/object/move.d.ts +34 -0
  267. package/dist/fn/object/move.js +43 -0
  268. package/dist/fn/object/multiorder.d.ts +40 -0
  269. package/dist/fn/object/multiorder.js +60 -0
  270. package/dist/fn/object/numProperties.d.ts +31 -0
  271. package/dist/fn/object/numProperties.js +36 -0
  272. package/dist/fn/object/order.d.ts +28 -0
  273. package/dist/fn/object/order.js +36 -0
  274. package/dist/fn/object/pickValue.d.ts +2 -0
  275. package/dist/fn/object/pickValue.js +6 -0
  276. package/dist/fn/object/removeEmpty.d.ts +18 -0
  277. package/dist/fn/object/removeEmpty.js +47 -0
  278. package/dist/fn/object/removePrivateProp.d.ts +24 -0
  279. package/dist/fn/object/removePrivateProp.js +41 -0
  280. package/dist/fn/object/search.d.ts +101 -0
  281. package/dist/fn/object/search.js +177 -0
  282. package/dist/fn/object/setProp.d.ts +11 -0
  283. package/dist/fn/object/setProp.js +17 -0
  284. package/dist/fn/object/setProperty.d.ts +30 -0
  285. package/dist/fn/object/setProperty.js +50 -0
  286. package/dist/fn/object/shortenObj.d.ts +25 -0
  287. package/dist/fn/object/shortenObj.js +40 -0
  288. package/dist/fn/object/shuffle.d.ts +2 -0
  289. package/dist/fn/object/shuffle.js +13 -0
  290. package/dist/fn/object/stat.d.ts +2 -0
  291. package/dist/fn/object/stat.js +49 -0
  292. package/dist/fn/object/sum.d.ts +46 -0
  293. package/dist/fn/object/sum.js +57 -0
  294. package/dist/fn/object/unique.d.ts +18 -0
  295. package/dist/fn/object/unique.js +22 -0
  296. package/dist/fn/string/baseName.d.ts +24 -0
  297. package/dist/fn/string/baseName.js +39 -0
  298. package/dist/fn/string/br2nl.d.ts +19 -0
  299. package/dist/fn/string/br2nl.js +22 -0
  300. package/dist/fn/string/camelToCss.d.ts +18 -0
  301. package/dist/fn/string/camelToCss.js +26 -0
  302. package/dist/fn/string/camelize.d.ts +20 -0
  303. package/dist/fn/string/camelize.js +27 -0
  304. package/dist/fn/string/correctCase.d.ts +18 -0
  305. package/dist/fn/string/correctCase.js +20 -0
  306. package/dist/fn/string/crc32.d.ts +2 -0
  307. package/dist/fn/string/crc32.js +20 -0
  308. package/dist/fn/string/dirName.d.ts +17 -0
  309. package/dist/fn/string/dirName.js +33 -0
  310. package/dist/fn/string/escapeDquotes.d.ts +2 -0
  311. package/dist/fn/string/escapeDquotes.js +8 -0
  312. package/dist/fn/string/escapeRegExp.d.ts +19 -0
  313. package/dist/fn/string/escapeRegExp.js +21 -0
  314. package/dist/fn/string/escapeSquotes.d.ts +2 -0
  315. package/dist/fn/string/escapeSquotes.js +8 -0
  316. package/dist/fn/string/escapeTicks.d.ts +2 -0
  317. package/dist/fn/string/escapeTicks.js +8 -0
  318. package/dist/fn/string/escapeUrl.d.ts +9 -0
  319. package/dist/fn/string/escapeUrl.js +47 -0
  320. package/dist/fn/string/fileExt.d.ts +38 -0
  321. package/dist/fn/string/fileExt.js +47 -0
  322. package/dist/fn/string/format.d.ts +2 -0
  323. package/dist/fn/string/format.js +14 -0
  324. package/dist/fn/string/formatBytes.d.ts +14 -0
  325. package/dist/fn/string/formatBytes.js +20 -0
  326. package/dist/fn/string/formatSize.d.ts +2 -0
  327. package/dist/fn/string/formatSize.js +12 -0
  328. package/dist/fn/string/hash.d.ts +7 -0
  329. package/dist/fn/string/hash.js +42 -0
  330. package/dist/fn/string/md5.d.ts +22 -0
  331. package/dist/fn/string/md5.js +142 -0
  332. package/dist/fn/string/nl2br.d.ts +17 -0
  333. package/dist/fn/string/nl2br.js +20 -0
  334. package/dist/fn/string/printf.d.ts +10 -0
  335. package/dist/fn/string/printf.js +15 -0
  336. package/dist/fn/string/quotes2html.d.ts +30 -0
  337. package/dist/fn/string/quotes2html.js +39 -0
  338. package/dist/fn/string/randomString.d.ts +28 -0
  339. package/dist/fn/string/randomString.js +72 -0
  340. package/dist/fn/string/removeAccents.d.ts +17 -0
  341. package/dist/fn/string/removeAccents.js +30 -0
  342. package/dist/fn/string/removeExtraSpaces.d.ts +7 -0
  343. package/dist/fn/string/removeExtraSpaces.js +9 -0
  344. package/dist/fn/string/removeHtmlComments.d.ts +2 -0
  345. package/dist/fn/string/removeHtmlComments.js +8 -0
  346. package/dist/fn/string/removeTrailingChars.d.ts +11 -0
  347. package/dist/fn/string/removeTrailingChars.js +25 -0
  348. package/dist/fn/string/repeat.d.ts +16 -0
  349. package/dist/fn/string/repeat.js +18 -0
  350. package/dist/fn/string/replaceAll.d.ts +23 -0
  351. package/dist/fn/string/replaceAll.js +29 -0
  352. package/dist/fn/string/sanitize.d.ts +17 -0
  353. package/dist/fn/string/sanitize.js +34 -0
  354. package/dist/fn/string/shorten.d.ts +27 -0
  355. package/dist/fn/string/shorten.js +42 -0
  356. package/dist/fn/string/simpleHash.d.ts +2 -0
  357. package/dist/fn/string/simpleHash.js +8 -0
  358. package/dist/fn/string/simpleHash1.d.ts +2 -0
  359. package/dist/fn/string/simpleHash1.js +10 -0
  360. package/dist/fn/string/simpleHash2.d.ts +2 -0
  361. package/dist/fn/string/simpleHash2.js +10 -0
  362. package/dist/fn/string/substr.d.ts +23 -0
  363. package/dist/fn/string/substr.js +38 -0
  364. package/dist/fn/string/trim.d.ts +2 -0
  365. package/dist/fn/string/trim.js +20 -0
  366. package/dist/fn/string/uniqString.d.ts +18 -0
  367. package/dist/fn/string/uniqString.js +49 -0
  368. package/dist/fn/style/addColors.d.ts +17 -0
  369. package/dist/fn/style/addColors.js +76 -0
  370. package/dist/fn/style/addStyle.d.ts +12 -0
  371. package/dist/fn/style/addStyle.js +20 -0
  372. package/dist/fn/style/animateCss.d.ts +13 -0
  373. package/dist/fn/style/animateCss.js +31 -0
  374. package/dist/fn/style/center.d.ts +16 -0
  375. package/dist/fn/style/center.js +40 -0
  376. package/dist/fn/style/cssExists.d.ts +12 -0
  377. package/dist/fn/style/cssExists.js +40 -0
  378. package/dist/fn/style/getCssVar.d.ts +7 -0
  379. package/dist/fn/style/getCssVar.js +12 -0
  380. package/dist/fn/style/getScrollBarSize.d.ts +2 -0
  381. package/dist/fn/style/getScrollBarSize.js +25 -0
  382. package/dist/fn/style/lightenDarkenHex.d.ts +20 -0
  383. package/dist/fn/style/lightenDarkenHex.js +45 -0
  384. package/dist/fn/style/outerHeight.d.ts +11 -0
  385. package/dist/fn/style/outerHeight.js +19 -0
  386. package/dist/fn/style/outerWidth.d.ts +10 -0
  387. package/dist/fn/style/outerWidth.js +16 -0
  388. package/dist/fn/style/resize.d.ts +2 -0
  389. package/dist/fn/style/resize.js +39 -0
  390. package/dist/fn/style/setCssVar.d.ts +8 -0
  391. package/dist/fn/style/setCssVar.js +14 -0
  392. package/dist/fn/type/checkType.d.ts +2 -0
  393. package/dist/fn/type/checkType.js +59 -0
  394. package/dist/fn/type/isArray.d.ts +14 -0
  395. package/dist/fn/type/isArray.js +23 -0
  396. package/dist/fn/type/isBlob.d.ts +9 -0
  397. package/dist/fn/type/isBlob.js +18 -0
  398. package/dist/fn/type/isBoolean.d.ts +16 -0
  399. package/dist/fn/type/isBoolean.js +25 -0
  400. package/dist/fn/type/isCanvas.d.ts +16 -0
  401. package/dist/fn/type/isCanvas.js +25 -0
  402. package/dist/fn/type/isColor.d.ts +31 -0
  403. package/dist/fn/type/isColor.js +45 -0
  404. package/dist/fn/type/isComment.d.ts +14 -0
  405. package/dist/fn/type/isComment.js +23 -0
  406. package/dist/fn/type/isCp.d.ts +2 -0
  407. package/dist/fn/type/isCp.js +17 -0
  408. package/dist/fn/type/isDate.d.ts +20 -0
  409. package/dist/fn/type/isDate.js +29 -0
  410. package/dist/fn/type/isDimension.d.ts +11 -0
  411. package/dist/fn/type/isDimension.js +24 -0
  412. package/dist/fn/type/isDom.d.ts +14 -0
  413. package/dist/fn/type/isDom.js +23 -0
  414. package/dist/fn/type/isEmail.d.ts +23 -0
  415. package/dist/fn/type/isEmail.js +37 -0
  416. package/dist/fn/type/isEmpty.d.ts +41 -0
  417. package/dist/fn/type/isEmpty.js +57 -0
  418. package/dist/fn/type/isEvent.d.ts +9 -0
  419. package/dist/fn/type/isEvent.js +18 -0
  420. package/dist/fn/type/isFunction.d.ts +16 -0
  421. package/dist/fn/type/isFunction.js +25 -0
  422. package/dist/fn/type/isHostname.d.ts +2 -0
  423. package/dist/fn/type/isHostname.js +16 -0
  424. package/dist/fn/type/isIP.d.ts +2 -0
  425. package/dist/fn/type/isIP.js +12 -0
  426. package/dist/fn/type/isInt.d.ts +18 -0
  427. package/dist/fn/type/isInt.js +27 -0
  428. package/dist/fn/type/isIterable.d.ts +27 -0
  429. package/dist/fn/type/isIterable.js +37 -0
  430. package/dist/fn/type/isNull.d.ts +14 -0
  431. package/dist/fn/type/isNull.js +23 -0
  432. package/dist/fn/type/isNumber.d.ts +19 -0
  433. package/dist/fn/type/isNumber.js +30 -0
  434. package/dist/fn/type/isObject.d.ts +19 -0
  435. package/dist/fn/type/isObject.js +28 -0
  436. package/dist/fn/type/isPercent.d.ts +14 -0
  437. package/dist/fn/type/isPercent.js +23 -0
  438. package/dist/fn/type/isPrimitive.d.ts +18 -0
  439. package/dist/fn/type/isPrimitive.js +27 -0
  440. package/dist/fn/type/isPromise.d.ts +18 -0
  441. package/dist/fn/type/isPromise.js +27 -0
  442. package/dist/fn/type/isPropSize.d.ts +2 -0
  443. package/dist/fn/type/isPropSize.js +12 -0
  444. package/dist/fn/type/isSQLDate.d.ts +10 -0
  445. package/dist/fn/type/isSQLDate.js +20 -0
  446. package/dist/fn/type/isSame.d.ts +41 -0
  447. package/dist/fn/type/isSame.js +72 -0
  448. package/dist/fn/type/isString.d.ts +14 -0
  449. package/dist/fn/type/isString.js +23 -0
  450. package/dist/fn/type/isSymbol.d.ts +15 -0
  451. package/dist/fn/type/isSymbol.js +24 -0
  452. package/dist/fn/type/isURL.d.ts +2 -0
  453. package/dist/fn/type/isURL.js +11 -0
  454. package/dist/fn/type/isValidDimension.d.ts +11 -0
  455. package/dist/fn/type/isValidDimension.js +24 -0
  456. package/dist/fn/type/isValidName.d.ts +27 -0
  457. package/dist/fn/type/isValidName.js +38 -0
  458. package/dist/fn/type/isValue.d.ts +26 -0
  459. package/dist/fn/type/isValue.js +36 -0
  460. package/dist/fn/type/isVue.d.ts +16 -0
  461. package/dist/fn/type/isVue.js +42 -0
  462. package/dist/fn.d.ts +4 -5
  463. package/dist/fn.js +226 -228
  464. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ import { ajax } from './ajax';
2
+ import { substr } from '../string/substr';
3
+ import { baseName } from '../string/baseName';
4
+ import { isBlob } from '../type/isBlob';
5
+ import { fileExt } from '../string/fileExt';
6
+ import { downloadContent } from './downloadContent';
7
+ import { defaultAjaxErrorFunction } from '../default/defaultAjaxErrorFunction';
8
+ /**
9
+ * Downloads a file with given filename from a URL.
10
+ *
11
+ * Gets the file's content as Blob through XHR, then sends it to bbn.fn.downloadContent.
12
+ * __Attention__ The CORS policy applies
13
+ *
14
+ * @method download
15
+ * @global
16
+ * @memberof bbn.fn
17
+ *
18
+ * @example
19
+ * ```javascript
20
+ * // Forcing the download of an image
21
+ * bbn.fn.download('/bbn/js-title-black.png');
22
+ *
23
+ * // Forcing the download of a PDF
24
+ * bbn.fn.download('/files/my-document.pdf');
25
+ *
26
+ * // Changing the name as it is downloaded
27
+ * bbn.fn.download('/files/f4b1092d71aefd96458feaa71d170f69.pdf', 'myDocument_' + bbn.fn.dateSQL() + '.pdf');
28
+ * ```
29
+ *
30
+ * @param {String} url The URL from which the file will be requested
31
+ * @param {String} filename The name for the downloaded file (otherwise it will take the basename of the url)
32
+ * @param {Object} params A data object to send with the request
33
+ *
34
+ * @returns {undefined}
35
+ */
36
+ const download = function (url, filename, params) {
37
+ // We can intervert the arguments
38
+ if (filename && (typeof (filename) === 'object')) {
39
+ params = filename;
40
+ filename = '';
41
+ }
42
+ return ajax(url, 'blob', params || { _bbn_download: 1 }, (d, headers) => {
43
+ if (!filename) {
44
+ let cd = 'attachment; filename=';
45
+ if (headers?.['content-disposition'] && headers['content-disposition'].indexOf(cd) === 0) {
46
+ filename = substr(headers['content-disposition'], cd.length + 1, headers['content-disposition'].length - cd.length - 2);
47
+ }
48
+ else {
49
+ filename = baseName(url);
50
+ }
51
+ }
52
+ if (isBlob(d)) {
53
+ let extension = fileExt(filename);
54
+ let htmlExtensions = ['php', 'html'];
55
+ if ((typeof filename === 'string') && ((('type' in d) && (d.type !== 'text/html')) || htmlExtensions.includes(extension))) {
56
+ downloadContent(filename, d);
57
+ return;
58
+ }
59
+ }
60
+ }, e => {
61
+ defaultAjaxErrorFunction(e);
62
+ });
63
+ };
64
+ export { download };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Downloads a file with given filename from the given content.
3
+ *
4
+ * Creates a link putting in href a URL Object Blob made of the given content,
5
+ * which can be a canvas, a file or a blob object, or just a string.
6
+ *
7
+ * @method downloadContent
8
+ * @global
9
+ * @memberof bbn.fn
10
+ *
11
+ * @example
12
+ * ```javascript
13
+ * // Download from a string
14
+ * bbn.fn.downloadContent('myTextFile.txt', 'Just a string\nThat we can save directly in a file', 'text/plain');
15
+ *
16
+ * // Download from a file
17
+ * let file = new File(["foo"], "foo.txt", {type: "text/plain"});
18
+ * bbn.fn.downloadContent('foo.txt', file);
19
+ * ```
20
+ *
21
+ * @param {String} filename The name for the downloaded file
22
+ * @param {HTMLCanvasElement|File|String} content A Canvas, a File object or a String
23
+ * @param {String} type The type of file to be made
24
+ *
25
+ * @returns {undefined}
26
+ */
27
+ declare const downloadContent: (filename: string, content: any, type?: string) => void;
28
+ export { downloadContent };
@@ -0,0 +1,74 @@
1
+ import { isCanvas } from '../type/isCanvas';
2
+ import { isObject } from '../type/isObject';
3
+ import { isString } from '../type/isString';
4
+ import { log } from '../browser/log';
5
+ /**
6
+ * Downloads a file with given filename from the given content.
7
+ *
8
+ * Creates a link putting in href a URL Object Blob made of the given content,
9
+ * which can be a canvas, a file or a blob object, or just a string.
10
+ *
11
+ * @method downloadContent
12
+ * @global
13
+ * @memberof bbn.fn
14
+ *
15
+ * @example
16
+ * ```javascript
17
+ * // Download from a string
18
+ * bbn.fn.downloadContent('myTextFile.txt', 'Just a string\nThat we can save directly in a file', 'text/plain');
19
+ *
20
+ * // Download from a file
21
+ * let file = new File(["foo"], "foo.txt", {type: "text/plain"});
22
+ * bbn.fn.downloadContent('foo.txt', file);
23
+ * ```
24
+ *
25
+ * @param {String} filename The name for the downloaded file
26
+ * @param {HTMLCanvasElement|File|String} content A Canvas, a File object or a String
27
+ * @param {String} type The type of file to be made
28
+ *
29
+ * @returns {undefined}
30
+ */
31
+ const downloadContent = function (filename, content, type) {
32
+ if (isCanvas(content)) {
33
+ content.toBlob((blob) => {
34
+ // blob ready, download it
35
+ let a = document.createElement('a');
36
+ a.download = filename;
37
+ a.href = window.URL.createObjectURL(blob);
38
+ a.className = 'bbn-no';
39
+ a.click();
40
+ // delete the internal blob reference, to let the browser clear memory from it
41
+ window.URL.revokeObjectURL(a.href);
42
+ }, type || 'image/png');
43
+ return;
44
+ }
45
+ if (!type) {
46
+ type = isObject(content) && content.type ? content.type : 'octet/stream';
47
+ }
48
+ else if (type.indexOf('/') === -1) {
49
+ type = 'text/' + type;
50
+ }
51
+ let a = window.document.createElement('a');
52
+ a.className = 'bbn-no';
53
+ let src = null;
54
+ if (isString(content)) {
55
+ src = new Blob([content], { type: type });
56
+ }
57
+ else {
58
+ try {
59
+ src = content;
60
+ }
61
+ catch (e) {
62
+ log(e);
63
+ }
64
+ }
65
+ a.href = window.URL.createObjectURL(src);
66
+ a.download = filename;
67
+ // Append anchor to body.
68
+ document.body.appendChild(a);
69
+ a.click();
70
+ window.URL.revokeObjectURL(a.href);
71
+ // Remove anchor from body
72
+ document.body.removeChild(a);
73
+ };
74
+ export { downloadContent };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Finds the loader object corresponding to the given unique ID and returns it if found.
3
+ *
4
+ * The loader is an object representing an Ajax request, with the following properties:
5
+ * * _key_ is the unique ID (_requestId_) of the loader
6
+ * * _url_ is the URL called by the request
7
+ * * _loader_ is the Promise from the Axios XHR
8
+ * * _source_ is the source object for aborting the request
9
+ * * _start_ is the timestamp of the moment the request was sent
10
+ *
11
+ * @method getLoader
12
+ * @global
13
+ * @memberof bbn.fn
14
+ *
15
+ * @example
16
+ * ```javascript
17
+ * bbn.fn.post('my/script', {a: 1, b: 2});
18
+ * let requestId = bbn.fn.getRequestId('my/script', {a: 1, b: 2});
19
+ * if (requestId) {
20
+ * let loader = bbn.fn.getLoader(requestId);
21
+ * console.log(loader);
22
+ * // {
23
+ * // key: "my/script:af27f0e81533ae2bae3c25dea67359f6",
24
+ * // url: "my/script",
25
+ * // loader: {Promise},
26
+ * // source: {token: {CancelToken}, cancel: {Function}},
27
+ * // start: 1591804716757
28
+ * // }
29
+ * }
30
+ * ```
31
+ *
32
+ * @param {String} requestId The unique ID of the request as used in bbn.env.loaders
33
+ *
34
+ * @returns {false|Object} The corresponding loader Object if it exists, false otherwise
35
+ */
36
+ declare const getLoader: (requestId: string) => BbnLoader | null;
37
+ export { getLoader };
@@ -0,0 +1,44 @@
1
+ import { search } from '../object/search';
2
+ /**
3
+ * Finds the loader object corresponding to the given unique ID and returns it if found.
4
+ *
5
+ * The loader is an object representing an Ajax request, with the following properties:
6
+ * * _key_ is the unique ID (_requestId_) of the loader
7
+ * * _url_ is the URL called by the request
8
+ * * _loader_ is the Promise from the Axios XHR
9
+ * * _source_ is the source object for aborting the request
10
+ * * _start_ is the timestamp of the moment the request was sent
11
+ *
12
+ * @method getLoader
13
+ * @global
14
+ * @memberof bbn.fn
15
+ *
16
+ * @example
17
+ * ```javascript
18
+ * bbn.fn.post('my/script', {a: 1, b: 2});
19
+ * let requestId = bbn.fn.getRequestId('my/script', {a: 1, b: 2});
20
+ * if (requestId) {
21
+ * let loader = bbn.fn.getLoader(requestId);
22
+ * console.log(loader);
23
+ * // {
24
+ * // key: "my/script:af27f0e81533ae2bae3c25dea67359f6",
25
+ * // url: "my/script",
26
+ * // loader: {Promise},
27
+ * // source: {token: {CancelToken}, cancel: {Function}},
28
+ * // start: 1591804716757
29
+ * // }
30
+ * }
31
+ * ```
32
+ *
33
+ * @param {String} requestId The unique ID of the request as used in bbn.env.loaders
34
+ *
35
+ * @returns {false|Object} The corresponding loader Object if it exists, false otherwise
36
+ */
37
+ const getLoader = function (requestId) {
38
+ let idx = search(bbn.env.loaders, { key: requestId });
39
+ if (idx > -1) {
40
+ return bbn.env.loaders[idx];
41
+ }
42
+ return null;
43
+ };
44
+ export { getLoader };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Returns a unique ID for a "loader" based on the URL, the data keys and the datatype.
3
+ *
4
+ * The routing functions don't allow to send the same request at the same moment,
5
+ * therefore a unique ID is generated to identify them, based on the URL,
6
+ * the keys of the data sent, and the expected returned data type.
7
+ *
8
+ * @method getRequestId
9
+ * @global
10
+ *
11
+ * @example
12
+ * ```javascript
13
+ * // The URL is the first part of the key
14
+ * bbn.fn.getRequestId('my/location', {a: 1, b: 2});
15
+ * // my/location:af27f0e81533ae2bae3c25dea67359f6
16
+ * bbn.fn.getRequestId('my/other/location', {a: 1, b: 2});
17
+ * // my/other/location:af27f0e81533ae2bae3c25dea67359f6
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * // A change of value will not change the requestId
23
+ * bbn.fn.getRequestId('my/location', {a: 1, b: 3});
24
+ * // my/location:af27f0e81533ae2bae3c25dea67359f6
25
+ * // A change of key will
26
+ * bbn.fn.getRequestId('my/location', {a: 1, c: 3});
27
+ * // my/location:fde97ca7c6c998c911f4ab481a136d5f
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```javascript
32
+ * // Same with nested object
33
+ * bbn.fn.getRequestId('my/location', {data: {a: 1, b: 3}});
34
+ * // my/location:a7a58435275054106c4e4c9fb0cea5e5
35
+ * bbn.fn.getRequestId('my/location', {data: {a: 1, b: 2}});
36
+ * // my/location:a7a58435275054106c4e4c9fb0cea5e5
37
+ * bbn.fn.getRequestId('my/location', {data: {a: 1, c: 3}});
38
+ * // my/location:730da481e30d421afbadf1f1282dabb7
39
+ * ```
40
+ *
41
+ * @memberof bbn.fn
42
+ *
43
+ * @param {String} url The URL used by the request
44
+ * @param {Object} data The data sent to the URL
45
+ * @param {String} datatype The type of data requested (JSON by default)
46
+ *
47
+ * @returns {String} The unique ID
48
+ */
49
+ declare const getRequestId: (url: any, data: any, datatype: any) => string;
50
+ export { getRequestId };
@@ -0,0 +1,62 @@
1
+ import { iterate } from '../loop/iterate';
2
+ import { md5 } from '../string/md5';
3
+ /**
4
+ * Returns a unique ID for a "loader" based on the URL, the data keys and the datatype.
5
+ *
6
+ * The routing functions don't allow to send the same request at the same moment,
7
+ * therefore a unique ID is generated to identify them, based on the URL,
8
+ * the keys of the data sent, and the expected returned data type.
9
+ *
10
+ * @method getRequestId
11
+ * @global
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * // The URL is the first part of the key
16
+ * bbn.fn.getRequestId('my/location', {a: 1, b: 2});
17
+ * // my/location:af27f0e81533ae2bae3c25dea67359f6
18
+ * bbn.fn.getRequestId('my/other/location', {a: 1, b: 2});
19
+ * // my/other/location:af27f0e81533ae2bae3c25dea67359f6
20
+ * ```
21
+ *
22
+ * @example
23
+ * ```javascript
24
+ * // A change of value will not change the requestId
25
+ * bbn.fn.getRequestId('my/location', {a: 1, b: 3});
26
+ * // my/location:af27f0e81533ae2bae3c25dea67359f6
27
+ * // A change of key will
28
+ * bbn.fn.getRequestId('my/location', {a: 1, c: 3});
29
+ * // my/location:fde97ca7c6c998c911f4ab481a136d5f
30
+ * ```
31
+ *
32
+ * @example
33
+ * ```javascript
34
+ * // Same with nested object
35
+ * bbn.fn.getRequestId('my/location', {data: {a: 1, b: 3}});
36
+ * // my/location:a7a58435275054106c4e4c9fb0cea5e5
37
+ * bbn.fn.getRequestId('my/location', {data: {a: 1, b: 2}});
38
+ * // my/location:a7a58435275054106c4e4c9fb0cea5e5
39
+ * bbn.fn.getRequestId('my/location', {data: {a: 1, c: 3}});
40
+ * // my/location:730da481e30d421afbadf1f1282dabb7
41
+ * ```
42
+ *
43
+ * @memberof bbn.fn
44
+ *
45
+ * @param {String} url The URL used by the request
46
+ * @param {Object} data The data sent to the URL
47
+ * @param {String} datatype The type of data requested (JSON by default)
48
+ *
49
+ * @returns {String} The unique ID
50
+ */
51
+ const getRequestId = function (url, data, datatype) {
52
+ let d = {};
53
+ if (data) {
54
+ iterate(data, (a, n) => {
55
+ if (n.indexOf('_bbn') === -1) {
56
+ d[n] = a;
57
+ }
58
+ });
59
+ }
60
+ return url + ':' + md5((datatype || 'json') + JSON.stringify(d));
61
+ };
62
+ export { getRequestId };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Follows a link and if needed by sending the corresponding Ajax request and executing bbn.fn.defaultPreLinkFunction.
3
+ *
4
+ * Once bbn has been initiated this function will be triggered every time a link is clicked.
5
+ * It accepts the same arguments as seen in treatAjaxArguments but will tipically just be called with a URL,
6
+ * the defaultLinkURL functions being in charge of loading the content
7
+ *
8
+ * @method link
9
+ * @todo Manage anchors + returned data unclear
10
+ * @global
11
+ * @memberof bbn.fn
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * // Will open in a new window/tab
16
+ * bbn.fn.link('https://nytimes.com');
17
+ * // Will send an Ajax request
18
+ * bbn.fn.link('my/page');
19
+ * // Will open your default email program
20
+ * bbn.fn.link('mailto:postmaster@test.com');
21
+ * ```
22
+ *
23
+ * @returns
24
+ */
25
+ declare const link: (...args: any[]) => any;
26
+ export { link };
@@ -0,0 +1,129 @@
1
+ import { treatAjaxArguments } from './treatAjaxArguments';
2
+ import { getLoader } from './getLoader';
3
+ import { defaultPreLinkFunction } from '../default/defaultPreLinkFunction';
4
+ import { ajax } from './ajax';
5
+ import { log } from '../browser/log';
6
+ import { isObject } from '../type/isObject';
7
+ import { callback } from './callback';
8
+ import { setNavigationVars } from './setNavigationVars';
9
+ /**
10
+ * Follows a link and if needed by sending the corresponding Ajax request and executing bbn.fn.defaultPreLinkFunction.
11
+ *
12
+ * Once bbn has been initiated this function will be triggered every time a link is clicked.
13
+ * It accepts the same arguments as seen in treatAjaxArguments but will tipically just be called with a URL,
14
+ * the defaultLinkURL functions being in charge of loading the content
15
+ *
16
+ * @method link
17
+ * @todo Manage anchors + returned data unclear
18
+ * @global
19
+ * @memberof bbn.fn
20
+ *
21
+ * @example
22
+ * ```javascript
23
+ * // Will open in a new window/tab
24
+ * bbn.fn.link('https://nytimes.com');
25
+ * // Will send an Ajax request
26
+ * bbn.fn.link('my/page');
27
+ * // Will open your default email program
28
+ * bbn.fn.link('mailto:postmaster@test.com');
29
+ * ```
30
+ *
31
+ * @returns
32
+ */
33
+ const link = function (...args) {
34
+ let cfg = treatAjaxArguments(args);
35
+ let ok = true;
36
+ /* If we can't find a correct link we load the current URL */
37
+ if (!cfg) {
38
+ return link(window.location.href);
39
+ }
40
+ /* Just executing the javascript if there is */
41
+ if (cfg.url.indexOf('javascript:') === 0) {
42
+ return true;
43
+ }
44
+ if (cfg.url.indexOf('data:') === 0) {
45
+ return true;
46
+ }
47
+ if (cfg.url.indexOf('#') === 0) {
48
+ location.href = bbn.env.url + cfg.url;
49
+ /*
50
+ if ( window.history ){
51
+ bbn.env.historyDisabled = true;
52
+ let state = h.state;
53
+ window.history.replaceState(null, state.title, bbn.env.url);
54
+ }
55
+ bbn.env.historyDisabled = false;
56
+ */
57
+ return true;
58
+ }
59
+ else if (cfg.url.indexOf('mailto:') === 0) {
60
+ /* Mail link */
61
+ bbn.env.ignoreUnload = true;
62
+ window.location.href = cfg.url;
63
+ setTimeout(() => {
64
+ bbn.env.ignoreUnload = false;
65
+ }, 0);
66
+ return false;
67
+ }
68
+ if (getLoader(cfg.url)) {
69
+ return false;
70
+ }
71
+ /* Opens an external page in a new window */
72
+ if ((cfg.url.indexOf('http://') === 0 || cfg.url.indexOf('https://') === 0) &&
73
+ cfg.url.indexOf(bbn.env.host) !== 0) {
74
+ if (cfg.e) {
75
+ cfg.e.preventDefault();
76
+ }
77
+ window.open(cfg.url);
78
+ return false;
79
+ }
80
+ else if (cfg.url !== bbn.env.params.join('/') || cfg.force) {
81
+ /* The URL is fine so go ahead if something is not already loading */
82
+ /* If a second callback is defined, it is triggered instead of defaultPreLinkFunction */
83
+ if (cfg.successFn) {
84
+ ok = cfg.successFn(cfg.url);
85
+ }
86
+ else if (defaultPreLinkFunction) {
87
+ ok = defaultPreLinkFunction(cfg.url, cfg.force, cfg.ele);
88
+ /*
89
+ if (ok.data !== undefined) {
90
+ extend(cfg.obj, ok.data);
91
+ ok = 1;
92
+ }
93
+ */
94
+ }
95
+ if (ok) {
96
+ if (ok !== 1 && typeof ok === 'string') {
97
+ cfg.url = ok;
98
+ }
99
+ /** todo Do we keep obj in the unique string or do we make that only one concurrent connection to the same address can occur at the same time? */
100
+ let errSt = bbn._('The Ajax call to') + ' ' + cfg.url + ' ';
101
+ return ajax(cfg.url, cfg.datatype, cfg.obj, function (res) {
102
+ if (!res) {
103
+ log(errSt + bbn._('returned no answer'));
104
+ }
105
+ if (isObject(res)) {
106
+ // If there's nothing in the result, just an empty object, the callback stops here and the URL is not changed
107
+ if (Object.keys(res).length === 0) {
108
+ log(errSt + bbn._('returned an empty object'));
109
+ }
110
+ if (res.new_url) {
111
+ res.old_path = cfg.url;
112
+ cfg.url = res.new_url;
113
+ }
114
+ else if (res.url && cfg.url !== res.url) {
115
+ res.old_path = cfg.url;
116
+ }
117
+ }
118
+ if (callback(cfg.url, res, cfg.successFn, null, cfg.ele) && res.noNav === undefined) {
119
+ // This solution is not very clean (we can't shorten a URL)
120
+ if (bbn.env.path.indexOf(cfg.url) !== 0) {
121
+ setNavigationVars(cfg.url, (res.title ? res.title + ' - ' : '') + bbn.env.siteTitle);
122
+ }
123
+ }
124
+ }, cfg.errorFn || null);
125
+ }
126
+ }
127
+ return true;
128
+ };
129
+ export { link };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Creates a POST XHR through bbn.fn.ajax then launches bbn.fn.callback with the result.
3
+ *
4
+ * URL is the only mandatory argument (see treatAjaxArguments for the arguments).
5
+ *
6
+ * @method post
7
+ * @global
8
+ * @memberof bbn.fn
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * bbn.fn.post('logout').then(() => {
13
+ * document.location.reload();
14
+ * });
15
+ * // With data
16
+ * bbn.fn.post('login', {user: 'tn', pass: 'xxx'}).then((d) => {
17
+ * if (d && d.success) {
18
+ * alert('Welcome!');
19
+ * }
20
+ * });
21
+ * // With the callback as argument
22
+ * bbn.fn.post('login', {user: 'tn', pass: 'xxx'}, (d) => {
23
+ * if (d && d.success) {
24
+ * alert('Welcome!');
25
+ * }
26
+ * }, (err) => {
27
+ * bbn.fn.log(err);
28
+ * mySpecialErrorFunction(err);
29
+ * });
30
+ * ```
31
+ *
32
+ * @returns {undefined|Promise}
33
+ */
34
+ declare const post: (...args: any[]) => any;
35
+ export { post };
@@ -0,0 +1,45 @@
1
+ import { treatAjaxArguments } from './treatAjaxArguments';
2
+ import { ajax } from './ajax';
3
+ import { callback } from './callback';
4
+ /**
5
+ * Creates a POST XHR through bbn.fn.ajax then launches bbn.fn.callback with the result.
6
+ *
7
+ * URL is the only mandatory argument (see treatAjaxArguments for the arguments).
8
+ *
9
+ * @method post
10
+ * @global
11
+ * @memberof bbn.fn
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * bbn.fn.post('logout').then(() => {
16
+ * document.location.reload();
17
+ * });
18
+ * // With data
19
+ * bbn.fn.post('login', {user: 'tn', pass: 'xxx'}).then((d) => {
20
+ * if (d && d.success) {
21
+ * alert('Welcome!');
22
+ * }
23
+ * });
24
+ * // With the callback as argument
25
+ * bbn.fn.post('login', {user: 'tn', pass: 'xxx'}, (d) => {
26
+ * if (d && d.success) {
27
+ * alert('Welcome!');
28
+ * }
29
+ * }, (err) => {
30
+ * bbn.fn.log(err);
31
+ * mySpecialErrorFunction(err);
32
+ * });
33
+ * ```
34
+ *
35
+ * @returns {undefined|Promise}
36
+ */
37
+ const post = function (...args) {
38
+ let cfg = treatAjaxArguments(args);
39
+ if (cfg.url) {
40
+ return ajax(cfg.url, cfg.datatype, cfg.obj, (res) => {
41
+ callback(cfg.url, res, cfg.successFn, null, cfg.ele);
42
+ }, cfg.errorFn, cfg.abortFn);
43
+ }
44
+ };
45
+ export { post };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Posts a request in a new window.
3
+ *
4
+ * @method postOut
5
+ * @global
6
+ * @memberof bbn.fn
7
+ *
8
+ * @example
9
+ * ```javascript
10
+ * bbn.fn.postOut('https://external-service.com/download/account-2019-06.pdf', {clientId: 547912, token: xxx});
11
+ * ```
12
+ *
13
+ * @param {String} url The url to which the request should be sent
14
+ * @param {Object} data The data to be sent
15
+ * @param {Function} success A function to execute in case of success
16
+ * @param {String} target The target attribute of the form
17
+ *
18
+ * @returns {undefined}
19
+ */
20
+ declare const postOut: (url: string, data: BbnBasicObject, success?: () => any, target?: string) => void;
21
+ export { postOut };
@@ -0,0 +1,49 @@
1
+ import { createObject } from '../object/createObject';
2
+ import { addInputs } from '../form/addInputs';
3
+ /**
4
+ * Posts a request in a new window.
5
+ *
6
+ * @method postOut
7
+ * @global
8
+ * @memberof bbn.fn
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * bbn.fn.postOut('https://external-service.com/download/account-2019-06.pdf', {clientId: 547912, token: xxx});
13
+ * ```
14
+ *
15
+ * @param {String} url The url to which the request should be sent
16
+ * @param {Object} data The data to be sent
17
+ * @param {Function} success A function to execute in case of success
18
+ * @param {String} target The target attribute of the form
19
+ *
20
+ * @returns {undefined}
21
+ */
22
+ const postOut = function (url, data, success, target) {
23
+ let form = document.body.querySelector('form#bbn-form_out');
24
+ if (!form) {
25
+ form = document.createElement('form');
26
+ form.classList.add('bbn-no');
27
+ form.setAttribute('id', 'bbn-form_out');
28
+ form.setAttribute('method', 'post');
29
+ form.setAttribute('enctype', 'multipart/form-data-encoded');
30
+ form.style.display = 'none';
31
+ document.body.appendChild(form);
32
+ }
33
+ form.innerHTML = '';
34
+ form.setAttribute('action', url);
35
+ form.setAttribute('target', target || '_blank');
36
+ if (!data) {
37
+ data = {};
38
+ }
39
+ data = createObject(data);
40
+ if (!data.bbn) {
41
+ data.bbn = 'public';
42
+ }
43
+ addInputs(form, data);
44
+ form.submit();
45
+ if (success) {
46
+ success();
47
+ }
48
+ };
49
+ export { postOut };