wj-elements 0.1.134 → 0.1.136

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 (319) hide show
  1. package/package.json +3 -2
  2. package/dist/dark.css +0 -223
  3. package/dist/infinite-scroll.element-XVJukzjy.js +0 -271
  4. package/dist/light.css +0 -530
  5. package/dist/list.element-Ce1vIm1O.js +0 -49
  6. package/dist/localize.js +0 -67
  7. package/dist/packages/index.d.ts +0 -98
  8. package/dist/packages/localize/localize.d.ts +0 -17
  9. package/dist/packages/translations/en-GB.d.ts +0 -13
  10. package/dist/packages/translations/sk-SK.d.ts +0 -13
  11. package/dist/packages/utils/animations.d.ts +0 -2
  12. package/dist/packages/utils/date.d.ts +0 -1
  13. package/dist/packages/utils/element-utils.d.ts +0 -46
  14. package/dist/packages/utils/event.d.ts +0 -67
  15. package/dist/packages/utils/localize.d.ts +0 -4
  16. package/dist/packages/utils/permissions-api.d.ts +0 -34
  17. package/dist/packages/utils/utils.d.ts +0 -1
  18. package/dist/packages/utils/wje-import-firefox.d.ts +0 -0
  19. package/dist/packages/utils/wje-import.d.ts +0 -0
  20. package/dist/packages/wje-accordion/accordion.d.ts +0 -2
  21. package/dist/packages/wje-accordion/accordion.element.d.ts +0 -72
  22. package/dist/packages/wje-accordion-item/accordion-item.d.ts +0 -2
  23. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +0 -40
  24. package/dist/packages/wje-animation/animation.d.ts +0 -2
  25. package/dist/packages/wje-animation/animation.element.d.ts +0 -153
  26. package/dist/packages/wje-animation/animation.test.d.ts +0 -1
  27. package/dist/packages/wje-aside/aside.d.ts +0 -2
  28. package/dist/packages/wje-aside/aside.element.d.ts +0 -31
  29. package/dist/packages/wje-avatar/avatar.d.ts +0 -2
  30. package/dist/packages/wje-avatar/avatar.element.d.ts +0 -37
  31. package/dist/packages/wje-avatar/service/service.d.ts +0 -40
  32. package/dist/packages/wje-badge/badge.d.ts +0 -2
  33. package/dist/packages/wje-badge/badge.element.d.ts +0 -35
  34. package/dist/packages/wje-badge/badge.test.d.ts +0 -1
  35. package/dist/packages/wje-breadcrumb/breadcrumb.d.ts +0 -2
  36. package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +0 -80
  37. package/dist/packages/wje-breadcrumbs/breadcrumbs.d.ts +0 -2
  38. package/dist/packages/wje-breadcrumbs/breadcrumbs.element.d.ts +0 -97
  39. package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
  40. package/dist/packages/wje-button/button.d.ts +0 -2
  41. package/dist/packages/wje-button/button.element.d.ts +0 -173
  42. package/dist/packages/wje-button/button.test.d.ts +0 -1
  43. package/dist/packages/wje-button-group/button-group.d.ts +0 -2
  44. package/dist/packages/wje-button-group/button-group.element.d.ts +0 -39
  45. package/dist/packages/wje-card/card.d.ts +0 -2
  46. package/dist/packages/wje-card/card.element.d.ts +0 -29
  47. package/dist/packages/wje-card-content/card-content.d.ts +0 -2
  48. package/dist/packages/wje-card-content/card-content.element.d.ts +0 -22
  49. package/dist/packages/wje-card-controls/card-controls.d.ts +0 -2
  50. package/dist/packages/wje-card-controls/card-controls.element.d.ts +0 -23
  51. package/dist/packages/wje-card-header/card-header.d.ts +0 -2
  52. package/dist/packages/wje-card-header/card-header.element.d.ts +0 -22
  53. package/dist/packages/wje-card-subtitle/card-subtitle.d.ts +0 -2
  54. package/dist/packages/wje-card-subtitle/card-subtitle.element.d.ts +0 -30
  55. package/dist/packages/wje-card-title/card-title.d.ts +0 -2
  56. package/dist/packages/wje-card-title/card-title.element.d.ts +0 -32
  57. package/dist/packages/wje-carousel/carousel.d.ts +0 -2
  58. package/dist/packages/wje-carousel/carousel.element.d.ts +0 -146
  59. package/dist/packages/wje-carousel-item/carousel-item.d.ts +0 -2
  60. package/dist/packages/wje-carousel-item/carousel-item.element.d.ts +0 -38
  61. package/dist/packages/wje-checkbox/checkbox.d.ts +0 -2
  62. package/dist/packages/wje-checkbox/checkbox.element.d.ts +0 -171
  63. package/dist/packages/wje-chip/chip.d.ts +0 -2
  64. package/dist/packages/wje-chip/chip.element.d.ts +0 -29
  65. package/dist/packages/wje-col/col.d.ts +0 -2
  66. package/dist/packages/wje-col/col.element.d.ts +0 -16
  67. package/dist/packages/wje-color-picker/color-picker.d.ts +0 -2
  68. package/dist/packages/wje-color-picker/color-picker.element.d.ts +0 -187
  69. package/dist/packages/wje-container/container.d.ts +0 -2
  70. package/dist/packages/wje-container/container.element.d.ts +0 -31
  71. package/dist/packages/wje-copy-button/copy-button.d.ts +0 -2
  72. package/dist/packages/wje-copy-button/copy-button.element.d.ts +0 -89
  73. package/dist/packages/wje-copy-button/service/service.d.ts +0 -12
  74. package/dist/packages/wje-dialog/dialog.d.ts +0 -2
  75. package/dist/packages/wje-dialog/dialog.element.d.ts +0 -116
  76. package/dist/packages/wje-divider/divider.d.ts +0 -2
  77. package/dist/packages/wje-divider/divider.element.d.ts +0 -32
  78. package/dist/packages/wje-dropdown/dropdown.d.ts +0 -2
  79. package/dist/packages/wje-dropdown/dropdown.element.d.ts +0 -85
  80. package/dist/packages/wje-element/element.d.ts +0 -313
  81. package/dist/packages/wje-element/service/universal-service.d.ts +0 -18
  82. package/dist/packages/wje-file-upload/file-upload.d.ts +0 -2
  83. package/dist/packages/wje-file-upload/file-upload.element.d.ts +0 -191
  84. package/dist/packages/wje-file-upload/service/service.d.ts +0 -70
  85. package/dist/packages/wje-file-upload-item/file-upload-item.d.ts +0 -2
  86. package/dist/packages/wje-file-upload-item/file-upload-item.element.d.ts +0 -62
  87. package/dist/packages/wje-footer/footer.d.ts +0 -2
  88. package/dist/packages/wje-footer/footer.element.d.ts +0 -28
  89. package/dist/packages/wje-form/form.d.ts +0 -2
  90. package/dist/packages/wje-form/form.element.d.ts +0 -28
  91. package/dist/packages/wje-format-digital/format-digital.d.ts +0 -2
  92. package/dist/packages/wje-format-digital/format-digital.element.d.ts +0 -87
  93. package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
  94. package/dist/packages/wje-grid/grid.d.ts +0 -2
  95. package/dist/packages/wje-grid/grid.element.d.ts +0 -26
  96. package/dist/packages/wje-header/header.d.ts +0 -2
  97. package/dist/packages/wje-header/header.element.d.ts +0 -35
  98. package/dist/packages/wje-icon/icon.d.ts +0 -2
  99. package/dist/packages/wje-icon/icon.element.d.ts +0 -40
  100. package/dist/packages/wje-icon/service/service.d.ts +0 -11
  101. package/dist/packages/wje-icon-picker/icon-picker.d.ts +0 -2
  102. package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +0 -197
  103. package/dist/packages/wje-img/img.d.ts +0 -2
  104. package/dist/packages/wje-img/img.element.d.ts +0 -30
  105. package/dist/packages/wje-img-comparer/img-comparer.d.ts +0 -2
  106. package/dist/packages/wje-img-comparer/img-comparer.element.d.ts +0 -60
  107. package/dist/packages/wje-img-comparer/service/service.d.ts +0 -1
  108. package/dist/packages/wje-infinite-scroll/infinite-scroll.d.ts +0 -2
  109. package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +0 -134
  110. package/dist/packages/wje-input/input.d.ts +0 -2
  111. package/dist/packages/wje-input/input.element.d.ts +0 -204
  112. package/dist/packages/wje-input-file/input-file.d.ts +0 -2
  113. package/dist/packages/wje-input-file/input-file.element.d.ts +0 -50
  114. package/dist/packages/wje-item/item.d.ts +0 -2
  115. package/dist/packages/wje-item/item.element.d.ts +0 -68
  116. package/dist/packages/wje-kanban/kanban.d.ts +0 -2
  117. package/dist/packages/wje-kanban/kanban.element.d.ts +0 -183
  118. package/dist/packages/wje-label/label.d.ts +0 -2
  119. package/dist/packages/wje-label/label.element.d.ts +0 -34
  120. package/dist/packages/wje-list/list.d.ts +0 -2
  121. package/dist/packages/wje-list/list.element.d.ts +0 -31
  122. package/dist/packages/wje-main/main.d.ts +0 -2
  123. package/dist/packages/wje-main/main.element.d.ts +0 -30
  124. package/dist/packages/wje-masonry/masonry.d.ts +0 -2
  125. package/dist/packages/wje-masonry/masonry.element.d.ts +0 -114
  126. package/dist/packages/wje-masonry/service/service.d.ts +0 -32
  127. package/dist/packages/wje-menu/menu.d.ts +0 -2
  128. package/dist/packages/wje-menu/menu.element.d.ts +0 -47
  129. package/dist/packages/wje-menu-button/menu-button.d.ts +0 -2
  130. package/dist/packages/wje-menu-button/menu-button.element.d.ts +0 -34
  131. package/dist/packages/wje-menu-item/menu-item.d.ts +0 -2
  132. package/dist/packages/wje-menu-item/menu-item.element.d.ts +0 -139
  133. package/dist/packages/wje-menu-label/menu-label.d.ts +0 -2
  134. package/dist/packages/wje-menu-label/menu-label.element.d.ts +0 -39
  135. package/dist/packages/wje-option/option.d.ts +0 -2
  136. package/dist/packages/wje-option/option.element.d.ts +0 -59
  137. package/dist/packages/wje-options/options.d.ts +0 -2
  138. package/dist/packages/wje-options/options.element.d.ts +0 -180
  139. package/dist/packages/wje-orgchart/orgchart.d.ts +0 -2
  140. package/dist/packages/wje-orgchart/orgchart.element.d.ts +0 -24
  141. package/dist/packages/wje-orgchart-group/orgchart-group.d.ts +0 -2
  142. package/dist/packages/wje-orgchart-group/orgchart-group.element.d.ts +0 -28
  143. package/dist/packages/wje-orgchart-item/orgchart-item.d.ts +0 -2
  144. package/dist/packages/wje-orgchart-item/orgchart-item.element.d.ts +0 -49
  145. package/dist/packages/wje-panel/panel.d.ts +0 -2
  146. package/dist/packages/wje-panel/panel.element.d.ts +0 -34
  147. package/dist/packages/wje-popup/popup.d.ts +0 -2
  148. package/dist/packages/wje-popup/popup.element.d.ts +0 -93
  149. package/dist/packages/wje-progress-bar/progress-bar.d.ts +0 -2
  150. package/dist/packages/wje-progress-bar/progress-bar.element.d.ts +0 -96
  151. package/dist/packages/wje-qr-code/qr-code.d.ts +0 -2
  152. package/dist/packages/wje-qr-code/qr-code.element.d.ts +0 -33
  153. package/dist/packages/wje-radio/radio.d.ts +0 -2
  154. package/dist/packages/wje-radio/radio.element.d.ts +0 -53
  155. package/dist/packages/wje-radio-group/radio-group.d.ts +0 -2
  156. package/dist/packages/wje-radio-group/radio-group.element.d.ts +0 -137
  157. package/dist/packages/wje-rate/rate.d.ts +0 -2
  158. package/dist/packages/wje-rate/rate.element.d.ts +0 -156
  159. package/dist/packages/wje-relative-time/relative-time.d.ts +0 -2
  160. package/dist/packages/wje-relative-time/relative-time.element.d.ts +0 -55
  161. package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
  162. package/dist/packages/wje-reorder/reorder.d.ts +0 -2
  163. package/dist/packages/wje-reorder/reorder.element.d.ts +0 -119
  164. package/dist/packages/wje-reorder-dropzone/reorder-dropzone.d.ts +0 -2
  165. package/dist/packages/wje-reorder-dropzone/reorder-dropzone.element.d.ts +0 -23
  166. package/dist/packages/wje-reorder-handle/reorder-handle.d.ts +0 -2
  167. package/dist/packages/wje-reorder-handle/reorder-handle.element.d.ts +0 -75
  168. package/dist/packages/wje-reorder-item/reorder-item.d.ts +0 -2
  169. package/dist/packages/wje-reorder-item/reorder-item.element.d.ts +0 -24
  170. package/dist/packages/wje-route/route.d.ts +0 -2
  171. package/dist/packages/wje-route/route.element.d.ts +0 -22
  172. package/dist/packages/wje-router/router.d.ts +0 -2
  173. package/dist/packages/wje-router/router.element.d.ts +0 -39
  174. package/dist/packages/wje-router-link/router-link.d.ts +0 -2
  175. package/dist/packages/wje-router-link/router-link.element.d.ts +0 -31
  176. package/dist/packages/wje-router-outlet/router-outlet.d.ts +0 -2
  177. package/dist/packages/wje-router-outlet/router-outlet.element.d.ts +0 -15
  178. package/dist/packages/wje-row/row.d.ts +0 -2
  179. package/dist/packages/wje-row/row.element.d.ts +0 -23
  180. package/dist/packages/wje-select/select.d.ts +0 -2
  181. package/dist/packages/wje-select/select.element.d.ts +0 -315
  182. package/dist/packages/wje-slider/slider.d.ts +0 -2
  183. package/dist/packages/wje-slider/slider.element.d.ts +0 -103
  184. package/dist/packages/wje-split-view/service/service.d.ts +0 -1
  185. package/dist/packages/wje-split-view/split-view.d.ts +0 -2
  186. package/dist/packages/wje-split-view/split-view.element.d.ts +0 -66
  187. package/dist/packages/wje-status/status.d.ts +0 -2
  188. package/dist/packages/wje-status/status.element.d.ts +0 -26
  189. package/dist/packages/wje-step/step.d.ts +0 -2
  190. package/dist/packages/wje-step/step.element.d.ts +0 -23
  191. package/dist/packages/wje-stepper/stepper.d.ts +0 -2
  192. package/dist/packages/wje-stepper/stepper.element.d.ts +0 -78
  193. package/dist/packages/wje-store/default-store-actions.d.ts +0 -20
  194. package/dist/packages/wje-store/pubsub.d.ts +0 -21
  195. package/dist/packages/wje-store/store.d.ts +0 -153
  196. package/dist/packages/wje-tab/tab.d.ts +0 -2
  197. package/dist/packages/wje-tab/tab.element.d.ts +0 -41
  198. package/dist/packages/wje-tab-group/tab-group.d.ts +0 -2
  199. package/dist/packages/wje-tab-group/tab-group.element.d.ts +0 -67
  200. package/dist/packages/wje-tab-panel/tab-panel.d.ts +0 -2
  201. package/dist/packages/wje-tab-panel/tab-panel.element.d.ts +0 -23
  202. package/dist/packages/wje-textarea/textarea.d.ts +0 -2
  203. package/dist/packages/wje-textarea/textarea.element.d.ts +0 -176
  204. package/dist/packages/wje-thumbnail/thumbnail.d.ts +0 -2
  205. package/dist/packages/wje-thumbnail/thumbnail.element.d.ts +0 -31
  206. package/dist/packages/wje-timeline/timeline.d.ts +0 -2
  207. package/dist/packages/wje-timeline/timeline.element.d.ts +0 -25
  208. package/dist/packages/wje-timeline-item/timeline-item.d.ts +0 -2
  209. package/dist/packages/wje-timeline-item/timeline-item.element.d.ts +0 -27
  210. package/dist/packages/wje-toast/toast.d.ts +0 -2
  211. package/dist/packages/wje-toast/toast.element.d.ts +0 -173
  212. package/dist/packages/wje-toast/toast.test.d.ts +0 -1
  213. package/dist/packages/wje-toggle/toggle.d.ts +0 -2
  214. package/dist/packages/wje-toggle/toggle.element.d.ts +0 -65
  215. package/dist/packages/wje-toolbar/toolbar.d.ts +0 -2
  216. package/dist/packages/wje-toolbar/toolbar.element.d.ts +0 -39
  217. package/dist/packages/wje-toolbar-action/toolbar-action.d.ts +0 -2
  218. package/dist/packages/wje-toolbar-action/toolbar-action.element.d.ts +0 -35
  219. package/dist/packages/wje-tooltip/tooltip.d.ts +0 -2
  220. package/dist/packages/wje-tooltip/tooltip.element.d.ts +0 -71
  221. package/dist/packages/wje-visually-hidden/visually-hidden.d.ts +0 -2
  222. package/dist/packages/wje-visually-hidden/visually-hidden.element.d.ts +0 -29
  223. package/dist/popup.element-tyYxow0p.js +0 -1622
  224. package/dist/router-links-CJnOdbas.js +0 -149
  225. package/dist/styles.css +0 -849
  226. package/dist/wje-accordion-item.js +0 -112
  227. package/dist/wje-accordion.js +0 -121
  228. package/dist/wje-animation.js +0 -4323
  229. package/dist/wje-aside.js +0 -54
  230. package/dist/wje-avatar.js +0 -89
  231. package/dist/wje-badge.js +0 -70
  232. package/dist/wje-breadcrumb.js +0 -194
  233. package/dist/wje-breadcrumbs.js +0 -139
  234. package/dist/wje-button-group.js +0 -84
  235. package/dist/wje-button.js +0 -351
  236. package/dist/wje-card-content.js +0 -47
  237. package/dist/wje-card-controls.js +0 -47
  238. package/dist/wje-card-header.js +0 -47
  239. package/dist/wje-card-subtitle.js +0 -54
  240. package/dist/wje-card-title.js +0 -54
  241. package/dist/wje-card.js +0 -55
  242. package/dist/wje-carousel-item.js +0 -62
  243. package/dist/wje-carousel.js +0 -379
  244. package/dist/wje-checkbox.js +0 -539
  245. package/dist/wje-chip.js +0 -75
  246. package/dist/wje-col.js +0 -37
  247. package/dist/wje-color-picker.js +0 -1338
  248. package/dist/wje-container.js +0 -55
  249. package/dist/wje-copy-button.js +0 -217
  250. package/dist/wje-dialog.js +0 -248
  251. package/dist/wje-divider.js +0 -54
  252. package/dist/wje-dropdown.js +0 -193
  253. package/dist/wje-element.js +0 -966
  254. package/dist/wje-fetchAndParseCSS.js +0 -59
  255. package/dist/wje-file-upload-item.js +0 -133
  256. package/dist/wje-file-upload.js +0 -546
  257. package/dist/wje-footer.js +0 -51
  258. package/dist/wje-form.js +0 -52
  259. package/dist/wje-format-digital.js +0 -145
  260. package/dist/wje-grid.js +0 -53
  261. package/dist/wje-header.js +0 -55
  262. package/dist/wje-icon-picker.js +0 -348
  263. package/dist/wje-icon.js +0 -190
  264. package/dist/wje-img-comparer.js +0 -130
  265. package/dist/wje-img.js +0 -71
  266. package/dist/wje-infinite-scroll.js +0 -5
  267. package/dist/wje-input-file.js +0 -110
  268. package/dist/wje-input.js +0 -451
  269. package/dist/wje-item.js +0 -87
  270. package/dist/wje-kanban.js +0 -461
  271. package/dist/wje-label.js +0 -52
  272. package/dist/wje-list.js +0 -5
  273. package/dist/wje-main.js +0 -51
  274. package/dist/wje-masonry.js +0 -266
  275. package/dist/wje-master.js +0 -342
  276. package/dist/wje-menu-button.js +0 -59
  277. package/dist/wje-menu-item.js +0 -544
  278. package/dist/wje-menu-label.js +0 -54
  279. package/dist/wje-menu.js +0 -71
  280. package/dist/wje-option.js +0 -111
  281. package/dist/wje-options.js +0 -341
  282. package/dist/wje-orgchart-group.js +0 -71
  283. package/dist/wje-orgchart-item.js +0 -97
  284. package/dist/wje-orgchart.js +0 -48
  285. package/dist/wje-popup.js +0 -5
  286. package/dist/wje-progress-bar.js +0 -212
  287. package/dist/wje-qr-code.js +0 -2891
  288. package/dist/wje-radio-group.js +0 -227
  289. package/dist/wje-radio.js +0 -105
  290. package/dist/wje-rate.js +0 -299
  291. package/dist/wje-relative-time.js +0 -114
  292. package/dist/wje-reorder-dropzone.js +0 -48
  293. package/dist/wje-reorder-handle.js +0 -217
  294. package/dist/wje-reorder-item.js +0 -60
  295. package/dist/wje-reorder.js +0 -280
  296. package/dist/wje-route.js +0 -42
  297. package/dist/wje-router-link.js +0 -63
  298. package/dist/wje-router-outlet.js +0 -191
  299. package/dist/wje-routerx.js +0 -1436
  300. package/dist/wje-row.js +0 -48
  301. package/dist/wje-select.js +0 -629
  302. package/dist/wje-slider.js +0 -220
  303. package/dist/wje-sliding-container.js +0 -477
  304. package/dist/wje-split-view.js +0 -152
  305. package/dist/wje-status.js +0 -60
  306. package/dist/wje-step.js +0 -49
  307. package/dist/wje-stepper.js +0 -230
  308. package/dist/wje-store.js +0 -387
  309. package/dist/wje-tab-group.js +0 -136
  310. package/dist/wje-tab-panel.js +0 -45
  311. package/dist/wje-tab.js +0 -58
  312. package/dist/wje-textarea.js +0 -372
  313. package/dist/wje-thumbnail.js +0 -53
  314. package/dist/wje-toast.js +0 -333
  315. package/dist/wje-toggle.js +0 -124
  316. package/dist/wje-toolbar-action.js +0 -71
  317. package/dist/wje-toolbar.js +0 -62
  318. package/dist/wje-tooltip.js +0 -165
  319. package/dist/wje-visually-hidden.js +0 -54
@@ -1,2891 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import WJElement from "./wje-element.js";
5
- const styles = ".container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: relative;\n gap: 0.5rem;\n padding: 0.5rem;\n}\n";
6
- function getDefaultExportFromCjs(x) {
7
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
8
- }
9
- var qrious$1 = { exports: {} };
10
- var qrious = qrious$1.exports;
11
- var hasRequiredQrious;
12
- function requireQrious() {
13
- if (hasRequiredQrious) return qrious$1.exports;
14
- hasRequiredQrious = 1;
15
- (function(module, exports) {
16
- (function(global, factory) {
17
- module.exports = factory();
18
- })(qrious, function() {
19
- var Constructor = (
20
- /* istanbul ignore next */
21
- function() {
22
- }
23
- );
24
- var hasOwnProperty = Object.prototype.hasOwnProperty;
25
- var slice = Array.prototype.slice;
26
- function createObject(prototype, properties) {
27
- var result;
28
- if (typeof Object.create === "function") {
29
- result = Object.create(prototype);
30
- } else {
31
- Constructor.prototype = prototype;
32
- result = new Constructor();
33
- Constructor.prototype = null;
34
- }
35
- if (properties) {
36
- extendObject(true, result, properties);
37
- }
38
- return result;
39
- }
40
- function extend(name, constructor, prototype, statics) {
41
- var superConstructor = this;
42
- if (typeof name !== "string") {
43
- statics = prototype;
44
- prototype = constructor;
45
- constructor = name;
46
- name = null;
47
- }
48
- if (typeof constructor !== "function") {
49
- statics = prototype;
50
- prototype = constructor;
51
- constructor = function() {
52
- return superConstructor.apply(this, arguments);
53
- };
54
- }
55
- extendObject(false, constructor, superConstructor, statics);
56
- constructor.prototype = createObject(superConstructor.prototype, prototype);
57
- constructor.prototype.constructor = constructor;
58
- constructor.class_ = name || superConstructor.class_;
59
- constructor.super_ = superConstructor;
60
- return constructor;
61
- }
62
- function extendObject(own, target, sources) {
63
- sources = slice.call(arguments, 2);
64
- var property;
65
- var source;
66
- for (var i = 0, length = sources.length; i < length; i++) {
67
- source = sources[i];
68
- for (property in source) {
69
- if (!own || hasOwnProperty.call(source, property)) {
70
- target[property] = source[property];
71
- }
72
- }
73
- }
74
- }
75
- var extend_1 = extend;
76
- function Nevis() {
77
- }
78
- Nevis.class_ = "Nevis";
79
- Nevis.super_ = Object;
80
- Nevis.extend = extend_1;
81
- var nevis = Nevis;
82
- var lite = nevis;
83
- var Renderer = lite.extend(function(qrious2, element, enabled) {
84
- this.qrious = qrious2;
85
- this.element = element;
86
- this.element.qrious = qrious2;
87
- this.enabled = Boolean(enabled);
88
- }, {
89
- /**
90
- * Draws the specified QR code <code>frame</code> on the underlying element.
91
- *
92
- * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
93
- *
94
- * @param {Frame} frame - the {@link Frame} to be drawn
95
- * @return {void}
96
- * @protected
97
- * @abstract
98
- * @memberof Renderer#
99
- */
100
- draw: function(frame) {
101
- },
102
- /**
103
- * Returns the element onto which this {@link Renderer} is rendering the QR code.
104
- *
105
- * If this method is called while this {@link Renderer} is disabled, it will be immediately enabled and rendered
106
- * before the element is returned.
107
- *
108
- * @return {*} The element.
109
- * @public
110
- * @memberof Renderer#
111
- */
112
- getElement: function() {
113
- if (!this.enabled) {
114
- this.enabled = true;
115
- this.render();
116
- }
117
- return this.element;
118
- },
119
- /**
120
- * Calculates the size (in pixel units) to represent an individual module within the QR code based on the
121
- * <code>frame</code> provided.
122
- *
123
- * Any configured padding will be excluded from the returned size.
124
- *
125
- * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents.
126
- * This is done so that the inevitable clipping is handled more gracefully since this way at least something is
127
- * displayed instead of just a blank space filled by the background color.
128
- *
129
- * @param {Frame} frame - the {@link Frame} from which the module size is to be derived
130
- * @return {number} The pixel size for each module in the QR code which will be no less than one.
131
- * @protected
132
- * @memberof Renderer#
133
- */
134
- getModuleSize: function(frame) {
135
- var qrious2 = this.qrious;
136
- var padding = qrious2.padding || 0;
137
- var pixels = Math.floor((qrious2.size - padding * 2) / frame.width);
138
- return Math.max(1, pixels);
139
- },
140
- /**
141
- * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the <code>frame</code>
142
- * provided.
143
- *
144
- * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its
145
- * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally
146
- * and it is not clipped from all directions.
147
- *
148
- * @param {Frame} frame - the {@link Frame} from which the offset is to be derived
149
- * @return {number} The pixel offset for the QR code which will be no less than zero.
150
- * @protected
151
- * @memberof Renderer#
152
- */
153
- getOffset: function(frame) {
154
- var qrious2 = this.qrious;
155
- var padding = qrious2.padding;
156
- if (padding != null) {
157
- return padding;
158
- }
159
- var moduleSize = this.getModuleSize(frame);
160
- var offset = Math.floor((qrious2.size - moduleSize * frame.width) / 2);
161
- return Math.max(0, offset);
162
- },
163
- /**
164
- * Renders a QR code on the underlying element based on the <code>frame</code> provided.
165
- *
166
- * @param {Frame} frame - the {@link Frame} to be rendered
167
- * @return {void}
168
- * @public
169
- * @memberof Renderer#
170
- */
171
- render: function(frame) {
172
- if (this.enabled) {
173
- this.resize();
174
- this.reset();
175
- this.draw(frame);
176
- }
177
- },
178
- /**
179
- * Resets the underlying element, effectively clearing any previously rendered QR code.
180
- *
181
- * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
182
- *
183
- * @return {void}
184
- * @protected
185
- * @abstract
186
- * @memberof Renderer#
187
- */
188
- reset: function() {
189
- },
190
- /**
191
- * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance.
192
- *
193
- * Implementations of {@link Renderer} <b>must</b> override this method with their own specific logic.
194
- *
195
- * @return {void}
196
- * @protected
197
- * @abstract
198
- * @memberof Renderer#
199
- */
200
- resize: function() {
201
- }
202
- });
203
- var Renderer_1 = Renderer;
204
- var CanvasRenderer = Renderer_1.extend({
205
- /**
206
- * @override
207
- */
208
- draw: function(frame) {
209
- var i, j;
210
- var qrious2 = this.qrious;
211
- var moduleSize = this.getModuleSize(frame);
212
- var offset = this.getOffset(frame);
213
- var context = this.element.getContext("2d");
214
- context.fillStyle = qrious2.foreground;
215
- context.globalAlpha = qrious2.foregroundAlpha;
216
- for (i = 0; i < frame.width; i++) {
217
- for (j = 0; j < frame.width; j++) {
218
- if (frame.buffer[j * frame.width + i]) {
219
- context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize);
220
- }
221
- }
222
- }
223
- },
224
- /**
225
- * @override
226
- */
227
- reset: function() {
228
- var qrious2 = this.qrious;
229
- var context = this.element.getContext("2d");
230
- var size = qrious2.size;
231
- context.lineWidth = 1;
232
- context.clearRect(0, 0, size, size);
233
- context.fillStyle = qrious2.background;
234
- context.globalAlpha = qrious2.backgroundAlpha;
235
- context.fillRect(0, 0, size, size);
236
- },
237
- /**
238
- * @override
239
- */
240
- resize: function() {
241
- var element = this.element;
242
- element.width = element.height = this.qrious.size;
243
- }
244
- });
245
- var CanvasRenderer_1 = CanvasRenderer;
246
- var Alignment = lite.extend(null, {
247
- /**
248
- * The alignment pattern block.
249
- *
250
- * @public
251
- * @static
252
- * @type {number[]}
253
- * @memberof Alignment
254
- */
255
- BLOCK: [
256
- 0,
257
- 11,
258
- 15,
259
- 19,
260
- 23,
261
- 27,
262
- 31,
263
- 16,
264
- 18,
265
- 20,
266
- 22,
267
- 24,
268
- 26,
269
- 28,
270
- 20,
271
- 22,
272
- 24,
273
- 24,
274
- 26,
275
- 28,
276
- 28,
277
- 22,
278
- 24,
279
- 24,
280
- 26,
281
- 26,
282
- 28,
283
- 28,
284
- 24,
285
- 24,
286
- 26,
287
- 26,
288
- 26,
289
- 28,
290
- 28,
291
- 24,
292
- 26,
293
- 26,
294
- 26,
295
- 28,
296
- 28
297
- ]
298
- });
299
- var Alignment_1 = Alignment;
300
- var ErrorCorrection = lite.extend(null, {
301
- /**
302
- * The error correction blocks.
303
- *
304
- * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally
305
- * the ECC width.
306
- *
307
- * @public
308
- * @static
309
- * @type {number[]}
310
- * @memberof ErrorCorrection
311
- */
312
- BLOCKS: [
313
- 1,
314
- 0,
315
- 19,
316
- 7,
317
- 1,
318
- 0,
319
- 16,
320
- 10,
321
- 1,
322
- 0,
323
- 13,
324
- 13,
325
- 1,
326
- 0,
327
- 9,
328
- 17,
329
- 1,
330
- 0,
331
- 34,
332
- 10,
333
- 1,
334
- 0,
335
- 28,
336
- 16,
337
- 1,
338
- 0,
339
- 22,
340
- 22,
341
- 1,
342
- 0,
343
- 16,
344
- 28,
345
- 1,
346
- 0,
347
- 55,
348
- 15,
349
- 1,
350
- 0,
351
- 44,
352
- 26,
353
- 2,
354
- 0,
355
- 17,
356
- 18,
357
- 2,
358
- 0,
359
- 13,
360
- 22,
361
- 1,
362
- 0,
363
- 80,
364
- 20,
365
- 2,
366
- 0,
367
- 32,
368
- 18,
369
- 2,
370
- 0,
371
- 24,
372
- 26,
373
- 4,
374
- 0,
375
- 9,
376
- 16,
377
- 1,
378
- 0,
379
- 108,
380
- 26,
381
- 2,
382
- 0,
383
- 43,
384
- 24,
385
- 2,
386
- 2,
387
- 15,
388
- 18,
389
- 2,
390
- 2,
391
- 11,
392
- 22,
393
- 2,
394
- 0,
395
- 68,
396
- 18,
397
- 4,
398
- 0,
399
- 27,
400
- 16,
401
- 4,
402
- 0,
403
- 19,
404
- 24,
405
- 4,
406
- 0,
407
- 15,
408
- 28,
409
- 2,
410
- 0,
411
- 78,
412
- 20,
413
- 4,
414
- 0,
415
- 31,
416
- 18,
417
- 2,
418
- 4,
419
- 14,
420
- 18,
421
- 4,
422
- 1,
423
- 13,
424
- 26,
425
- 2,
426
- 0,
427
- 97,
428
- 24,
429
- 2,
430
- 2,
431
- 38,
432
- 22,
433
- 4,
434
- 2,
435
- 18,
436
- 22,
437
- 4,
438
- 2,
439
- 14,
440
- 26,
441
- 2,
442
- 0,
443
- 116,
444
- 30,
445
- 3,
446
- 2,
447
- 36,
448
- 22,
449
- 4,
450
- 4,
451
- 16,
452
- 20,
453
- 4,
454
- 4,
455
- 12,
456
- 24,
457
- 2,
458
- 2,
459
- 68,
460
- 18,
461
- 4,
462
- 1,
463
- 43,
464
- 26,
465
- 6,
466
- 2,
467
- 19,
468
- 24,
469
- 6,
470
- 2,
471
- 15,
472
- 28,
473
- 4,
474
- 0,
475
- 81,
476
- 20,
477
- 1,
478
- 4,
479
- 50,
480
- 30,
481
- 4,
482
- 4,
483
- 22,
484
- 28,
485
- 3,
486
- 8,
487
- 12,
488
- 24,
489
- 2,
490
- 2,
491
- 92,
492
- 24,
493
- 6,
494
- 2,
495
- 36,
496
- 22,
497
- 4,
498
- 6,
499
- 20,
500
- 26,
501
- 7,
502
- 4,
503
- 14,
504
- 28,
505
- 4,
506
- 0,
507
- 107,
508
- 26,
509
- 8,
510
- 1,
511
- 37,
512
- 22,
513
- 8,
514
- 4,
515
- 20,
516
- 24,
517
- 12,
518
- 4,
519
- 11,
520
- 22,
521
- 3,
522
- 1,
523
- 115,
524
- 30,
525
- 4,
526
- 5,
527
- 40,
528
- 24,
529
- 11,
530
- 5,
531
- 16,
532
- 20,
533
- 11,
534
- 5,
535
- 12,
536
- 24,
537
- 5,
538
- 1,
539
- 87,
540
- 22,
541
- 5,
542
- 5,
543
- 41,
544
- 24,
545
- 5,
546
- 7,
547
- 24,
548
- 30,
549
- 11,
550
- 7,
551
- 12,
552
- 24,
553
- 5,
554
- 1,
555
- 98,
556
- 24,
557
- 7,
558
- 3,
559
- 45,
560
- 28,
561
- 15,
562
- 2,
563
- 19,
564
- 24,
565
- 3,
566
- 13,
567
- 15,
568
- 30,
569
- 1,
570
- 5,
571
- 107,
572
- 28,
573
- 10,
574
- 1,
575
- 46,
576
- 28,
577
- 1,
578
- 15,
579
- 22,
580
- 28,
581
- 2,
582
- 17,
583
- 14,
584
- 28,
585
- 5,
586
- 1,
587
- 120,
588
- 30,
589
- 9,
590
- 4,
591
- 43,
592
- 26,
593
- 17,
594
- 1,
595
- 22,
596
- 28,
597
- 2,
598
- 19,
599
- 14,
600
- 28,
601
- 3,
602
- 4,
603
- 113,
604
- 28,
605
- 3,
606
- 11,
607
- 44,
608
- 26,
609
- 17,
610
- 4,
611
- 21,
612
- 26,
613
- 9,
614
- 16,
615
- 13,
616
- 26,
617
- 3,
618
- 5,
619
- 107,
620
- 28,
621
- 3,
622
- 13,
623
- 41,
624
- 26,
625
- 15,
626
- 5,
627
- 24,
628
- 30,
629
- 15,
630
- 10,
631
- 15,
632
- 28,
633
- 4,
634
- 4,
635
- 116,
636
- 28,
637
- 17,
638
- 0,
639
- 42,
640
- 26,
641
- 17,
642
- 6,
643
- 22,
644
- 28,
645
- 19,
646
- 6,
647
- 16,
648
- 30,
649
- 2,
650
- 7,
651
- 111,
652
- 28,
653
- 17,
654
- 0,
655
- 46,
656
- 28,
657
- 7,
658
- 16,
659
- 24,
660
- 30,
661
- 34,
662
- 0,
663
- 13,
664
- 24,
665
- 4,
666
- 5,
667
- 121,
668
- 30,
669
- 4,
670
- 14,
671
- 47,
672
- 28,
673
- 11,
674
- 14,
675
- 24,
676
- 30,
677
- 16,
678
- 14,
679
- 15,
680
- 30,
681
- 6,
682
- 4,
683
- 117,
684
- 30,
685
- 6,
686
- 14,
687
- 45,
688
- 28,
689
- 11,
690
- 16,
691
- 24,
692
- 30,
693
- 30,
694
- 2,
695
- 16,
696
- 30,
697
- 8,
698
- 4,
699
- 106,
700
- 26,
701
- 8,
702
- 13,
703
- 47,
704
- 28,
705
- 7,
706
- 22,
707
- 24,
708
- 30,
709
- 22,
710
- 13,
711
- 15,
712
- 30,
713
- 10,
714
- 2,
715
- 114,
716
- 28,
717
- 19,
718
- 4,
719
- 46,
720
- 28,
721
- 28,
722
- 6,
723
- 22,
724
- 28,
725
- 33,
726
- 4,
727
- 16,
728
- 30,
729
- 8,
730
- 4,
731
- 122,
732
- 30,
733
- 22,
734
- 3,
735
- 45,
736
- 28,
737
- 8,
738
- 26,
739
- 23,
740
- 30,
741
- 12,
742
- 28,
743
- 15,
744
- 30,
745
- 3,
746
- 10,
747
- 117,
748
- 30,
749
- 3,
750
- 23,
751
- 45,
752
- 28,
753
- 4,
754
- 31,
755
- 24,
756
- 30,
757
- 11,
758
- 31,
759
- 15,
760
- 30,
761
- 7,
762
- 7,
763
- 116,
764
- 30,
765
- 21,
766
- 7,
767
- 45,
768
- 28,
769
- 1,
770
- 37,
771
- 23,
772
- 30,
773
- 19,
774
- 26,
775
- 15,
776
- 30,
777
- 5,
778
- 10,
779
- 115,
780
- 30,
781
- 19,
782
- 10,
783
- 47,
784
- 28,
785
- 15,
786
- 25,
787
- 24,
788
- 30,
789
- 23,
790
- 25,
791
- 15,
792
- 30,
793
- 13,
794
- 3,
795
- 115,
796
- 30,
797
- 2,
798
- 29,
799
- 46,
800
- 28,
801
- 42,
802
- 1,
803
- 24,
804
- 30,
805
- 23,
806
- 28,
807
- 15,
808
- 30,
809
- 17,
810
- 0,
811
- 115,
812
- 30,
813
- 10,
814
- 23,
815
- 46,
816
- 28,
817
- 10,
818
- 35,
819
- 24,
820
- 30,
821
- 19,
822
- 35,
823
- 15,
824
- 30,
825
- 17,
826
- 1,
827
- 115,
828
- 30,
829
- 14,
830
- 21,
831
- 46,
832
- 28,
833
- 29,
834
- 19,
835
- 24,
836
- 30,
837
- 11,
838
- 46,
839
- 15,
840
- 30,
841
- 13,
842
- 6,
843
- 115,
844
- 30,
845
- 14,
846
- 23,
847
- 46,
848
- 28,
849
- 44,
850
- 7,
851
- 24,
852
- 30,
853
- 59,
854
- 1,
855
- 16,
856
- 30,
857
- 12,
858
- 7,
859
- 121,
860
- 30,
861
- 12,
862
- 26,
863
- 47,
864
- 28,
865
- 39,
866
- 14,
867
- 24,
868
- 30,
869
- 22,
870
- 41,
871
- 15,
872
- 30,
873
- 6,
874
- 14,
875
- 121,
876
- 30,
877
- 6,
878
- 34,
879
- 47,
880
- 28,
881
- 46,
882
- 10,
883
- 24,
884
- 30,
885
- 2,
886
- 64,
887
- 15,
888
- 30,
889
- 17,
890
- 4,
891
- 122,
892
- 30,
893
- 29,
894
- 14,
895
- 46,
896
- 28,
897
- 49,
898
- 10,
899
- 24,
900
- 30,
901
- 24,
902
- 46,
903
- 15,
904
- 30,
905
- 4,
906
- 18,
907
- 122,
908
- 30,
909
- 13,
910
- 32,
911
- 46,
912
- 28,
913
- 48,
914
- 14,
915
- 24,
916
- 30,
917
- 42,
918
- 32,
919
- 15,
920
- 30,
921
- 20,
922
- 4,
923
- 117,
924
- 30,
925
- 40,
926
- 7,
927
- 47,
928
- 28,
929
- 43,
930
- 22,
931
- 24,
932
- 30,
933
- 10,
934
- 67,
935
- 15,
936
- 30,
937
- 19,
938
- 6,
939
- 118,
940
- 30,
941
- 18,
942
- 31,
943
- 47,
944
- 28,
945
- 34,
946
- 34,
947
- 24,
948
- 30,
949
- 20,
950
- 61,
951
- 15,
952
- 30
953
- ],
954
- /**
955
- * The final format bits with mask (level << 3 | mask).
956
- *
957
- * @public
958
- * @static
959
- * @type {number[]}
960
- * @memberof ErrorCorrection
961
- */
962
- FINAL_FORMAT: [
963
- // L
964
- 30660,
965
- 29427,
966
- 32170,
967
- 30877,
968
- 26159,
969
- 25368,
970
- 27713,
971
- 26998,
972
- // M
973
- 21522,
974
- 20773,
975
- 24188,
976
- 23371,
977
- 17913,
978
- 16590,
979
- 20375,
980
- 19104,
981
- // Q
982
- 13663,
983
- 12392,
984
- 16177,
985
- 14854,
986
- 9396,
987
- 8579,
988
- 11994,
989
- 11245,
990
- // H
991
- 5769,
992
- 5054,
993
- 7399,
994
- 6608,
995
- 1890,
996
- 597,
997
- 3340,
998
- 2107
999
- ],
1000
- /**
1001
- * A map of human-readable ECC levels.
1002
- *
1003
- * @public
1004
- * @static
1005
- * @type {Object.<string, number>}
1006
- * @memberof ErrorCorrection
1007
- */
1008
- LEVELS: {
1009
- L: 1,
1010
- M: 2,
1011
- Q: 3,
1012
- H: 4
1013
- }
1014
- });
1015
- var ErrorCorrection_1 = ErrorCorrection;
1016
- var Galois = lite.extend(null, {
1017
- /**
1018
- * The Galois field exponent table.
1019
- *
1020
- * @public
1021
- * @static
1022
- * @type {number[]}
1023
- * @memberof Galois
1024
- */
1025
- EXPONENT: [
1026
- 1,
1027
- 2,
1028
- 4,
1029
- 8,
1030
- 16,
1031
- 32,
1032
- 64,
1033
- 128,
1034
- 29,
1035
- 58,
1036
- 116,
1037
- 232,
1038
- 205,
1039
- 135,
1040
- 19,
1041
- 38,
1042
- 76,
1043
- 152,
1044
- 45,
1045
- 90,
1046
- 180,
1047
- 117,
1048
- 234,
1049
- 201,
1050
- 143,
1051
- 3,
1052
- 6,
1053
- 12,
1054
- 24,
1055
- 48,
1056
- 96,
1057
- 192,
1058
- 157,
1059
- 39,
1060
- 78,
1061
- 156,
1062
- 37,
1063
- 74,
1064
- 148,
1065
- 53,
1066
- 106,
1067
- 212,
1068
- 181,
1069
- 119,
1070
- 238,
1071
- 193,
1072
- 159,
1073
- 35,
1074
- 70,
1075
- 140,
1076
- 5,
1077
- 10,
1078
- 20,
1079
- 40,
1080
- 80,
1081
- 160,
1082
- 93,
1083
- 186,
1084
- 105,
1085
- 210,
1086
- 185,
1087
- 111,
1088
- 222,
1089
- 161,
1090
- 95,
1091
- 190,
1092
- 97,
1093
- 194,
1094
- 153,
1095
- 47,
1096
- 94,
1097
- 188,
1098
- 101,
1099
- 202,
1100
- 137,
1101
- 15,
1102
- 30,
1103
- 60,
1104
- 120,
1105
- 240,
1106
- 253,
1107
- 231,
1108
- 211,
1109
- 187,
1110
- 107,
1111
- 214,
1112
- 177,
1113
- 127,
1114
- 254,
1115
- 225,
1116
- 223,
1117
- 163,
1118
- 91,
1119
- 182,
1120
- 113,
1121
- 226,
1122
- 217,
1123
- 175,
1124
- 67,
1125
- 134,
1126
- 17,
1127
- 34,
1128
- 68,
1129
- 136,
1130
- 13,
1131
- 26,
1132
- 52,
1133
- 104,
1134
- 208,
1135
- 189,
1136
- 103,
1137
- 206,
1138
- 129,
1139
- 31,
1140
- 62,
1141
- 124,
1142
- 248,
1143
- 237,
1144
- 199,
1145
- 147,
1146
- 59,
1147
- 118,
1148
- 236,
1149
- 197,
1150
- 151,
1151
- 51,
1152
- 102,
1153
- 204,
1154
- 133,
1155
- 23,
1156
- 46,
1157
- 92,
1158
- 184,
1159
- 109,
1160
- 218,
1161
- 169,
1162
- 79,
1163
- 158,
1164
- 33,
1165
- 66,
1166
- 132,
1167
- 21,
1168
- 42,
1169
- 84,
1170
- 168,
1171
- 77,
1172
- 154,
1173
- 41,
1174
- 82,
1175
- 164,
1176
- 85,
1177
- 170,
1178
- 73,
1179
- 146,
1180
- 57,
1181
- 114,
1182
- 228,
1183
- 213,
1184
- 183,
1185
- 115,
1186
- 230,
1187
- 209,
1188
- 191,
1189
- 99,
1190
- 198,
1191
- 145,
1192
- 63,
1193
- 126,
1194
- 252,
1195
- 229,
1196
- 215,
1197
- 179,
1198
- 123,
1199
- 246,
1200
- 241,
1201
- 255,
1202
- 227,
1203
- 219,
1204
- 171,
1205
- 75,
1206
- 150,
1207
- 49,
1208
- 98,
1209
- 196,
1210
- 149,
1211
- 55,
1212
- 110,
1213
- 220,
1214
- 165,
1215
- 87,
1216
- 174,
1217
- 65,
1218
- 130,
1219
- 25,
1220
- 50,
1221
- 100,
1222
- 200,
1223
- 141,
1224
- 7,
1225
- 14,
1226
- 28,
1227
- 56,
1228
- 112,
1229
- 224,
1230
- 221,
1231
- 167,
1232
- 83,
1233
- 166,
1234
- 81,
1235
- 162,
1236
- 89,
1237
- 178,
1238
- 121,
1239
- 242,
1240
- 249,
1241
- 239,
1242
- 195,
1243
- 155,
1244
- 43,
1245
- 86,
1246
- 172,
1247
- 69,
1248
- 138,
1249
- 9,
1250
- 18,
1251
- 36,
1252
- 72,
1253
- 144,
1254
- 61,
1255
- 122,
1256
- 244,
1257
- 245,
1258
- 247,
1259
- 243,
1260
- 251,
1261
- 235,
1262
- 203,
1263
- 139,
1264
- 11,
1265
- 22,
1266
- 44,
1267
- 88,
1268
- 176,
1269
- 125,
1270
- 250,
1271
- 233,
1272
- 207,
1273
- 131,
1274
- 27,
1275
- 54,
1276
- 108,
1277
- 216,
1278
- 173,
1279
- 71,
1280
- 142,
1281
- 0
1282
- ],
1283
- /**
1284
- * The Galois field log table.
1285
- *
1286
- * @public
1287
- * @static
1288
- * @type {number[]}
1289
- * @memberof Galois
1290
- */
1291
- LOG: [
1292
- 255,
1293
- 0,
1294
- 1,
1295
- 25,
1296
- 2,
1297
- 50,
1298
- 26,
1299
- 198,
1300
- 3,
1301
- 223,
1302
- 51,
1303
- 238,
1304
- 27,
1305
- 104,
1306
- 199,
1307
- 75,
1308
- 4,
1309
- 100,
1310
- 224,
1311
- 14,
1312
- 52,
1313
- 141,
1314
- 239,
1315
- 129,
1316
- 28,
1317
- 193,
1318
- 105,
1319
- 248,
1320
- 200,
1321
- 8,
1322
- 76,
1323
- 113,
1324
- 5,
1325
- 138,
1326
- 101,
1327
- 47,
1328
- 225,
1329
- 36,
1330
- 15,
1331
- 33,
1332
- 53,
1333
- 147,
1334
- 142,
1335
- 218,
1336
- 240,
1337
- 18,
1338
- 130,
1339
- 69,
1340
- 29,
1341
- 181,
1342
- 194,
1343
- 125,
1344
- 106,
1345
- 39,
1346
- 249,
1347
- 185,
1348
- 201,
1349
- 154,
1350
- 9,
1351
- 120,
1352
- 77,
1353
- 228,
1354
- 114,
1355
- 166,
1356
- 6,
1357
- 191,
1358
- 139,
1359
- 98,
1360
- 102,
1361
- 221,
1362
- 48,
1363
- 253,
1364
- 226,
1365
- 152,
1366
- 37,
1367
- 179,
1368
- 16,
1369
- 145,
1370
- 34,
1371
- 136,
1372
- 54,
1373
- 208,
1374
- 148,
1375
- 206,
1376
- 143,
1377
- 150,
1378
- 219,
1379
- 189,
1380
- 241,
1381
- 210,
1382
- 19,
1383
- 92,
1384
- 131,
1385
- 56,
1386
- 70,
1387
- 64,
1388
- 30,
1389
- 66,
1390
- 182,
1391
- 163,
1392
- 195,
1393
- 72,
1394
- 126,
1395
- 110,
1396
- 107,
1397
- 58,
1398
- 40,
1399
- 84,
1400
- 250,
1401
- 133,
1402
- 186,
1403
- 61,
1404
- 202,
1405
- 94,
1406
- 155,
1407
- 159,
1408
- 10,
1409
- 21,
1410
- 121,
1411
- 43,
1412
- 78,
1413
- 212,
1414
- 229,
1415
- 172,
1416
- 115,
1417
- 243,
1418
- 167,
1419
- 87,
1420
- 7,
1421
- 112,
1422
- 192,
1423
- 247,
1424
- 140,
1425
- 128,
1426
- 99,
1427
- 13,
1428
- 103,
1429
- 74,
1430
- 222,
1431
- 237,
1432
- 49,
1433
- 197,
1434
- 254,
1435
- 24,
1436
- 227,
1437
- 165,
1438
- 153,
1439
- 119,
1440
- 38,
1441
- 184,
1442
- 180,
1443
- 124,
1444
- 17,
1445
- 68,
1446
- 146,
1447
- 217,
1448
- 35,
1449
- 32,
1450
- 137,
1451
- 46,
1452
- 55,
1453
- 63,
1454
- 209,
1455
- 91,
1456
- 149,
1457
- 188,
1458
- 207,
1459
- 205,
1460
- 144,
1461
- 135,
1462
- 151,
1463
- 178,
1464
- 220,
1465
- 252,
1466
- 190,
1467
- 97,
1468
- 242,
1469
- 86,
1470
- 211,
1471
- 171,
1472
- 20,
1473
- 42,
1474
- 93,
1475
- 158,
1476
- 132,
1477
- 60,
1478
- 57,
1479
- 83,
1480
- 71,
1481
- 109,
1482
- 65,
1483
- 162,
1484
- 31,
1485
- 45,
1486
- 67,
1487
- 216,
1488
- 183,
1489
- 123,
1490
- 164,
1491
- 118,
1492
- 196,
1493
- 23,
1494
- 73,
1495
- 236,
1496
- 127,
1497
- 12,
1498
- 111,
1499
- 246,
1500
- 108,
1501
- 161,
1502
- 59,
1503
- 82,
1504
- 41,
1505
- 157,
1506
- 85,
1507
- 170,
1508
- 251,
1509
- 96,
1510
- 134,
1511
- 177,
1512
- 187,
1513
- 204,
1514
- 62,
1515
- 90,
1516
- 203,
1517
- 89,
1518
- 95,
1519
- 176,
1520
- 156,
1521
- 169,
1522
- 160,
1523
- 81,
1524
- 11,
1525
- 245,
1526
- 22,
1527
- 235,
1528
- 122,
1529
- 117,
1530
- 44,
1531
- 215,
1532
- 79,
1533
- 174,
1534
- 213,
1535
- 233,
1536
- 230,
1537
- 231,
1538
- 173,
1539
- 232,
1540
- 116,
1541
- 214,
1542
- 244,
1543
- 234,
1544
- 168,
1545
- 80,
1546
- 88,
1547
- 175
1548
- ]
1549
- });
1550
- var Galois_1 = Galois;
1551
- var Version = lite.extend(null, {
1552
- /**
1553
- * The version pattern block.
1554
- *
1555
- * @public
1556
- * @static
1557
- * @type {number[]}
1558
- * @memberof Version
1559
- */
1560
- BLOCK: [
1561
- 3220,
1562
- 1468,
1563
- 2713,
1564
- 1235,
1565
- 3062,
1566
- 1890,
1567
- 2119,
1568
- 1549,
1569
- 2344,
1570
- 2936,
1571
- 1117,
1572
- 2583,
1573
- 1330,
1574
- 2470,
1575
- 1667,
1576
- 2249,
1577
- 2028,
1578
- 3780,
1579
- 481,
1580
- 4011,
1581
- 142,
1582
- 3098,
1583
- 831,
1584
- 3445,
1585
- 592,
1586
- 2517,
1587
- 1776,
1588
- 2234,
1589
- 1951,
1590
- 2827,
1591
- 1070,
1592
- 2660,
1593
- 1345,
1594
- 3177
1595
- ]
1596
- });
1597
- var Version_1 = Version;
1598
- var Frame = lite.extend(function(options) {
1599
- var dataBlock, eccBlock, index2, neccBlock1, neccBlock2;
1600
- var valueLength = options.value.length;
1601
- this._badness = [];
1602
- this._level = ErrorCorrection_1.LEVELS[options.level];
1603
- this._polynomial = [];
1604
- this._value = options.value;
1605
- this._version = 0;
1606
- this._stringBuffer = [];
1607
- while (this._version < 40) {
1608
- this._version++;
1609
- index2 = (this._level - 1) * 4 + (this._version - 1) * 16;
1610
- neccBlock1 = ErrorCorrection_1.BLOCKS[index2++];
1611
- neccBlock2 = ErrorCorrection_1.BLOCKS[index2++];
1612
- dataBlock = ErrorCorrection_1.BLOCKS[index2++];
1613
- eccBlock = ErrorCorrection_1.BLOCKS[index2];
1614
- index2 = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9);
1615
- if (valueLength <= index2) {
1616
- break;
1617
- }
1618
- }
1619
- this._dataBlock = dataBlock;
1620
- this._eccBlock = eccBlock;
1621
- this._neccBlock1 = neccBlock1;
1622
- this._neccBlock2 = neccBlock2;
1623
- var width = this.width = 17 + 4 * this._version;
1624
- this.buffer = Frame._createArray(width * width);
1625
- this._ecc = Frame._createArray(dataBlock + (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2);
1626
- this._mask = Frame._createArray((width * (width + 1) + 1) / 2);
1627
- this._insertFinders();
1628
- this._insertAlignments();
1629
- this.buffer[8 + width * (width - 8)] = 1;
1630
- this._insertTimingGap();
1631
- this._reverseMask();
1632
- this._insertTimingRowAndColumn();
1633
- this._insertVersion();
1634
- this._syncMask();
1635
- this._convertBitStream(valueLength);
1636
- this._calculatePolynomial();
1637
- this._appendEccToData();
1638
- this._interleaveBlocks();
1639
- this._pack();
1640
- this._finish();
1641
- }, {
1642
- _addAlignment: function(x, y) {
1643
- var i;
1644
- var buffer = this.buffer;
1645
- var width = this.width;
1646
- buffer[x + width * y] = 1;
1647
- for (i = -2; i < 2; i++) {
1648
- buffer[x + i + width * (y - 2)] = 1;
1649
- buffer[x - 2 + width * (y + i + 1)] = 1;
1650
- buffer[x + 2 + width * (y + i)] = 1;
1651
- buffer[x + i + 1 + width * (y + 2)] = 1;
1652
- }
1653
- for (i = 0; i < 2; i++) {
1654
- this._setMask(x - 1, y + i);
1655
- this._setMask(x + 1, y - i);
1656
- this._setMask(x - i, y - 1);
1657
- this._setMask(x + i, y + 1);
1658
- }
1659
- },
1660
- _appendData: function(data, dataLength, ecc, eccLength) {
1661
- var bit, i, j;
1662
- var polynomial = this._polynomial;
1663
- var stringBuffer = this._stringBuffer;
1664
- for (i = 0; i < eccLength; i++) {
1665
- stringBuffer[ecc + i] = 0;
1666
- }
1667
- for (i = 0; i < dataLength; i++) {
1668
- bit = Galois_1.LOG[stringBuffer[data + i] ^ stringBuffer[ecc]];
1669
- if (bit !== 255) {
1670
- for (j = 1; j < eccLength; j++) {
1671
- stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^ Galois_1.EXPONENT[Frame._modN(bit + polynomial[eccLength - j])];
1672
- }
1673
- } else {
1674
- for (j = ecc; j < ecc + eccLength; j++) {
1675
- stringBuffer[j] = stringBuffer[j + 1];
1676
- }
1677
- }
1678
- stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois_1.EXPONENT[Frame._modN(bit + polynomial[0])];
1679
- }
1680
- },
1681
- _appendEccToData: function() {
1682
- var i;
1683
- var data = 0;
1684
- var dataBlock = this._dataBlock;
1685
- var ecc = this._calculateMaxLength();
1686
- var eccBlock = this._eccBlock;
1687
- for (i = 0; i < this._neccBlock1; i++) {
1688
- this._appendData(data, dataBlock, ecc, eccBlock);
1689
- data += dataBlock;
1690
- ecc += eccBlock;
1691
- }
1692
- for (i = 0; i < this._neccBlock2; i++) {
1693
- this._appendData(data, dataBlock + 1, ecc, eccBlock);
1694
- data += dataBlock + 1;
1695
- ecc += eccBlock;
1696
- }
1697
- },
1698
- _applyMask: function(mask) {
1699
- var r3x, r3y, x, y;
1700
- var buffer = this.buffer;
1701
- var width = this.width;
1702
- switch (mask) {
1703
- case 0:
1704
- for (y = 0; y < width; y++) {
1705
- for (x = 0; x < width; x++) {
1706
- if (!(x + y & 1) && !this._isMasked(x, y)) {
1707
- buffer[x + y * width] ^= 1;
1708
- }
1709
- }
1710
- }
1711
- break;
1712
- case 1:
1713
- for (y = 0; y < width; y++) {
1714
- for (x = 0; x < width; x++) {
1715
- if (!(y & 1) && !this._isMasked(x, y)) {
1716
- buffer[x + y * width] ^= 1;
1717
- }
1718
- }
1719
- }
1720
- break;
1721
- case 2:
1722
- for (y = 0; y < width; y++) {
1723
- for (r3x = 0, x = 0; x < width; x++, r3x++) {
1724
- if (r3x === 3) {
1725
- r3x = 0;
1726
- }
1727
- if (!r3x && !this._isMasked(x, y)) {
1728
- buffer[x + y * width] ^= 1;
1729
- }
1730
- }
1731
- }
1732
- break;
1733
- case 3:
1734
- for (r3y = 0, y = 0; y < width; y++, r3y++) {
1735
- if (r3y === 3) {
1736
- r3y = 0;
1737
- }
1738
- for (r3x = r3y, x = 0; x < width; x++, r3x++) {
1739
- if (r3x === 3) {
1740
- r3x = 0;
1741
- }
1742
- if (!r3x && !this._isMasked(x, y)) {
1743
- buffer[x + y * width] ^= 1;
1744
- }
1745
- }
1746
- }
1747
- break;
1748
- case 4:
1749
- for (y = 0; y < width; y++) {
1750
- for (r3x = 0, r3y = y >> 1 & 1, x = 0; x < width; x++, r3x++) {
1751
- if (r3x === 3) {
1752
- r3x = 0;
1753
- r3y = !r3y;
1754
- }
1755
- if (!r3y && !this._isMasked(x, y)) {
1756
- buffer[x + y * width] ^= 1;
1757
- }
1758
- }
1759
- }
1760
- break;
1761
- case 5:
1762
- for (r3y = 0, y = 0; y < width; y++, r3y++) {
1763
- if (r3y === 3) {
1764
- r3y = 0;
1765
- }
1766
- for (r3x = 0, x = 0; x < width; x++, r3x++) {
1767
- if (r3x === 3) {
1768
- r3x = 0;
1769
- }
1770
- if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) {
1771
- buffer[x + y * width] ^= 1;
1772
- }
1773
- }
1774
- }
1775
- break;
1776
- case 6:
1777
- for (r3y = 0, y = 0; y < width; y++, r3y++) {
1778
- if (r3y === 3) {
1779
- r3y = 0;
1780
- }
1781
- for (r3x = 0, x = 0; x < width; x++, r3x++) {
1782
- if (r3x === 3) {
1783
- r3x = 0;
1784
- }
1785
- if (!((x & y & 1) + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) {
1786
- buffer[x + y * width] ^= 1;
1787
- }
1788
- }
1789
- }
1790
- break;
1791
- case 7:
1792
- for (r3y = 0, y = 0; y < width; y++, r3y++) {
1793
- if (r3y === 3) {
1794
- r3y = 0;
1795
- }
1796
- for (r3x = 0, x = 0; x < width; x++, r3x++) {
1797
- if (r3x === 3) {
1798
- r3x = 0;
1799
- }
1800
- if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) {
1801
- buffer[x + y * width] ^= 1;
1802
- }
1803
- }
1804
- }
1805
- break;
1806
- }
1807
- },
1808
- _calculateMaxLength: function() {
1809
- return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2;
1810
- },
1811
- _calculatePolynomial: function() {
1812
- var i, j;
1813
- var eccBlock = this._eccBlock;
1814
- var polynomial = this._polynomial;
1815
- polynomial[0] = 1;
1816
- for (i = 0; i < eccBlock; i++) {
1817
- polynomial[i + 1] = 1;
1818
- for (j = i; j > 0; j--) {
1819
- polynomial[j] = polynomial[j] ? polynomial[j - 1] ^ Galois_1.EXPONENT[Frame._modN(Galois_1.LOG[polynomial[j]] + i)] : polynomial[j - 1];
1820
- }
1821
- polynomial[0] = Galois_1.EXPONENT[Frame._modN(Galois_1.LOG[polynomial[0]] + i)];
1822
- }
1823
- for (i = 0; i <= eccBlock; i++) {
1824
- polynomial[i] = Galois_1.LOG[polynomial[i]];
1825
- }
1826
- },
1827
- _checkBadness: function() {
1828
- var b, b1, h, x, y;
1829
- var bad = 0;
1830
- var badness = this._badness;
1831
- var buffer = this.buffer;
1832
- var width = this.width;
1833
- for (y = 0; y < width - 1; y++) {
1834
- for (x = 0; x < width - 1; x++) {
1835
- if (buffer[x + width * y] && buffer[x + 1 + width * y] && buffer[x + width * (y + 1)] && buffer[x + 1 + width * (y + 1)] || // All background colour.
1836
- !(buffer[x + width * y] || buffer[x + 1 + width * y] || buffer[x + width * (y + 1)] || buffer[x + 1 + width * (y + 1)])) {
1837
- bad += Frame.N2;
1838
- }
1839
- }
1840
- }
1841
- var bw = 0;
1842
- for (y = 0; y < width; y++) {
1843
- h = 0;
1844
- badness[0] = 0;
1845
- for (b = 0, x = 0; x < width; x++) {
1846
- b1 = buffer[x + width * y];
1847
- if (b === b1) {
1848
- badness[h]++;
1849
- } else {
1850
- badness[++h] = 1;
1851
- }
1852
- b = b1;
1853
- bw += b ? 1 : -1;
1854
- }
1855
- bad += this._getBadness(h);
1856
- }
1857
- if (bw < 0) {
1858
- bw = -bw;
1859
- }
1860
- var count = 0;
1861
- var big = bw;
1862
- big += big << 2;
1863
- big <<= 1;
1864
- while (big > width * width) {
1865
- big -= width * width;
1866
- count++;
1867
- }
1868
- bad += count * Frame.N4;
1869
- for (x = 0; x < width; x++) {
1870
- h = 0;
1871
- badness[0] = 0;
1872
- for (b = 0, y = 0; y < width; y++) {
1873
- b1 = buffer[x + width * y];
1874
- if (b === b1) {
1875
- badness[h]++;
1876
- } else {
1877
- badness[++h] = 1;
1878
- }
1879
- b = b1;
1880
- }
1881
- bad += this._getBadness(h);
1882
- }
1883
- return bad;
1884
- },
1885
- _convertBitStream: function(length) {
1886
- var bit, i;
1887
- var ecc = this._ecc;
1888
- var version = this._version;
1889
- for (i = 0; i < length; i++) {
1890
- ecc[i] = this._value.charCodeAt(i);
1891
- }
1892
- var stringBuffer = this._stringBuffer = ecc.slice();
1893
- var maxLength = this._calculateMaxLength();
1894
- if (length >= maxLength - 2) {
1895
- length = maxLength - 2;
1896
- if (version > 9) {
1897
- length--;
1898
- }
1899
- }
1900
- var index2 = length;
1901
- if (version > 9) {
1902
- stringBuffer[index2 + 2] = 0;
1903
- stringBuffer[index2 + 3] = 0;
1904
- while (index2--) {
1905
- bit = stringBuffer[index2];
1906
- stringBuffer[index2 + 3] |= 255 & bit << 4;
1907
- stringBuffer[index2 + 2] = bit >> 4;
1908
- }
1909
- stringBuffer[2] |= 255 & length << 4;
1910
- stringBuffer[1] = length >> 4;
1911
- stringBuffer[0] = 64 | length >> 12;
1912
- } else {
1913
- stringBuffer[index2 + 1] = 0;
1914
- stringBuffer[index2 + 2] = 0;
1915
- while (index2--) {
1916
- bit = stringBuffer[index2];
1917
- stringBuffer[index2 + 2] |= 255 & bit << 4;
1918
- stringBuffer[index2 + 1] = bit >> 4;
1919
- }
1920
- stringBuffer[1] |= 255 & length << 4;
1921
- stringBuffer[0] = 64 | length >> 4;
1922
- }
1923
- index2 = length + 3 - (version < 10);
1924
- while (index2 < maxLength) {
1925
- stringBuffer[index2++] = 236;
1926
- stringBuffer[index2++] = 17;
1927
- }
1928
- },
1929
- _getBadness: function(length) {
1930
- var i;
1931
- var badRuns = 0;
1932
- var badness = this._badness;
1933
- for (i = 0; i <= length; i++) {
1934
- if (badness[i] >= 5) {
1935
- badRuns += Frame.N1 + badness[i] - 5;
1936
- }
1937
- }
1938
- for (i = 3; i < length - 1; i += 2) {
1939
- if (badness[i - 2] === badness[i + 2] && badness[i + 2] === badness[i - 1] && badness[i - 1] === badness[i + 1] && badness[i - 1] * 3 === badness[i] && // Background around the foreground pattern? Not part of the specs.
1940
- (badness[i - 3] === 0 || i + 3 > length || badness[i - 3] * 3 >= badness[i] * 4 || badness[i + 3] * 3 >= badness[i] * 4)) {
1941
- badRuns += Frame.N3;
1942
- }
1943
- }
1944
- return badRuns;
1945
- },
1946
- _finish: function() {
1947
- this._stringBuffer = this.buffer.slice();
1948
- var currentMask, i;
1949
- var bit = 0;
1950
- var mask = 3e4;
1951
- for (i = 0; i < 8; i++) {
1952
- this._applyMask(i);
1953
- currentMask = this._checkBadness();
1954
- if (currentMask < mask) {
1955
- mask = currentMask;
1956
- bit = i;
1957
- }
1958
- if (bit === 7) {
1959
- break;
1960
- }
1961
- this.buffer = this._stringBuffer.slice();
1962
- }
1963
- if (bit !== i) {
1964
- this._applyMask(bit);
1965
- }
1966
- mask = ErrorCorrection_1.FINAL_FORMAT[bit + (this._level - 1 << 3)];
1967
- var buffer = this.buffer;
1968
- var width = this.width;
1969
- for (i = 0; i < 8; i++, mask >>= 1) {
1970
- if (mask & 1) {
1971
- buffer[width - 1 - i + width * 8] = 1;
1972
- if (i < 6) {
1973
- buffer[8 + width * i] = 1;
1974
- } else {
1975
- buffer[8 + width * (i + 1)] = 1;
1976
- }
1977
- }
1978
- }
1979
- for (i = 0; i < 7; i++, mask >>= 1) {
1980
- if (mask & 1) {
1981
- buffer[8 + width * (width - 7 + i)] = 1;
1982
- if (i) {
1983
- buffer[6 - i + width * 8] = 1;
1984
- } else {
1985
- buffer[7 + width * 8] = 1;
1986
- }
1987
- }
1988
- }
1989
- },
1990
- _interleaveBlocks: function() {
1991
- var i, j;
1992
- var dataBlock = this._dataBlock;
1993
- var ecc = this._ecc;
1994
- var eccBlock = this._eccBlock;
1995
- var k = 0;
1996
- var maxLength = this._calculateMaxLength();
1997
- var neccBlock1 = this._neccBlock1;
1998
- var neccBlock2 = this._neccBlock2;
1999
- var stringBuffer = this._stringBuffer;
2000
- for (i = 0; i < dataBlock; i++) {
2001
- for (j = 0; j < neccBlock1; j++) {
2002
- ecc[k++] = stringBuffer[i + j * dataBlock];
2003
- }
2004
- for (j = 0; j < neccBlock2; j++) {
2005
- ecc[k++] = stringBuffer[neccBlock1 * dataBlock + i + j * (dataBlock + 1)];
2006
- }
2007
- }
2008
- for (j = 0; j < neccBlock2; j++) {
2009
- ecc[k++] = stringBuffer[neccBlock1 * dataBlock + i + j * (dataBlock + 1)];
2010
- }
2011
- for (i = 0; i < eccBlock; i++) {
2012
- for (j = 0; j < neccBlock1 + neccBlock2; j++) {
2013
- ecc[k++] = stringBuffer[maxLength + i + j * eccBlock];
2014
- }
2015
- }
2016
- this._stringBuffer = ecc;
2017
- },
2018
- _insertAlignments: function() {
2019
- var i, x, y;
2020
- var version = this._version;
2021
- var width = this.width;
2022
- if (version > 1) {
2023
- i = Alignment_1.BLOCK[version];
2024
- y = width - 7;
2025
- for (; ; ) {
2026
- x = width - 7;
2027
- while (x > i - 3) {
2028
- this._addAlignment(x, y);
2029
- if (x < i) {
2030
- break;
2031
- }
2032
- x -= i;
2033
- }
2034
- if (y <= i + 9) {
2035
- break;
2036
- }
2037
- y -= i;
2038
- this._addAlignment(6, y);
2039
- this._addAlignment(y, 6);
2040
- }
2041
- }
2042
- },
2043
- _insertFinders: function() {
2044
- var i, j, x, y;
2045
- var buffer = this.buffer;
2046
- var width = this.width;
2047
- for (i = 0; i < 3; i++) {
2048
- j = 0;
2049
- y = 0;
2050
- if (i === 1) {
2051
- j = width - 7;
2052
- }
2053
- if (i === 2) {
2054
- y = width - 7;
2055
- }
2056
- buffer[y + 3 + width * (j + 3)] = 1;
2057
- for (x = 0; x < 6; x++) {
2058
- buffer[y + x + width * j] = 1;
2059
- buffer[y + width * (j + x + 1)] = 1;
2060
- buffer[y + 6 + width * (j + x)] = 1;
2061
- buffer[y + x + 1 + width * (j + 6)] = 1;
2062
- }
2063
- for (x = 1; x < 5; x++) {
2064
- this._setMask(y + x, j + 1);
2065
- this._setMask(y + 1, j + x + 1);
2066
- this._setMask(y + 5, j + x);
2067
- this._setMask(y + x + 1, j + 5);
2068
- }
2069
- for (x = 2; x < 4; x++) {
2070
- buffer[y + x + width * (j + 2)] = 1;
2071
- buffer[y + 2 + width * (j + x + 1)] = 1;
2072
- buffer[y + 4 + width * (j + x)] = 1;
2073
- buffer[y + x + 1 + width * (j + 4)] = 1;
2074
- }
2075
- }
2076
- },
2077
- _insertTimingGap: function() {
2078
- var x, y;
2079
- var width = this.width;
2080
- for (y = 0; y < 7; y++) {
2081
- this._setMask(7, y);
2082
- this._setMask(width - 8, y);
2083
- this._setMask(7, y + width - 7);
2084
- }
2085
- for (x = 0; x < 8; x++) {
2086
- this._setMask(x, 7);
2087
- this._setMask(x + width - 8, 7);
2088
- this._setMask(x, width - 8);
2089
- }
2090
- },
2091
- _insertTimingRowAndColumn: function() {
2092
- var x;
2093
- var buffer = this.buffer;
2094
- var width = this.width;
2095
- for (x = 0; x < width - 14; x++) {
2096
- if (x & 1) {
2097
- this._setMask(8 + x, 6);
2098
- this._setMask(6, 8 + x);
2099
- } else {
2100
- buffer[8 + x + width * 6] = 1;
2101
- buffer[6 + width * (8 + x)] = 1;
2102
- }
2103
- }
2104
- },
2105
- _insertVersion: function() {
2106
- var i, j, x, y;
2107
- var buffer = this.buffer;
2108
- var version = this._version;
2109
- var width = this.width;
2110
- if (version > 6) {
2111
- i = Version_1.BLOCK[version - 7];
2112
- j = 17;
2113
- for (x = 0; x < 6; x++) {
2114
- for (y = 0; y < 3; y++, j--) {
2115
- if (1 & (j > 11 ? version >> j - 12 : i >> j)) {
2116
- buffer[5 - x + width * (2 - y + width - 11)] = 1;
2117
- buffer[2 - y + width - 11 + width * (5 - x)] = 1;
2118
- } else {
2119
- this._setMask(5 - x, 2 - y + width - 11);
2120
- this._setMask(2 - y + width - 11, 5 - x);
2121
- }
2122
- }
2123
- }
2124
- }
2125
- },
2126
- _isMasked: function(x, y) {
2127
- var bit = Frame._getMaskBit(x, y);
2128
- return this._mask[bit] === 1;
2129
- },
2130
- _pack: function() {
2131
- var bit, i, j;
2132
- var k = 1;
2133
- var v = 1;
2134
- var width = this.width;
2135
- var x = width - 1;
2136
- var y = width - 1;
2137
- var length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2;
2138
- for (i = 0; i < length; i++) {
2139
- bit = this._stringBuffer[i];
2140
- for (j = 0; j < 8; j++, bit <<= 1) {
2141
- if (128 & bit) {
2142
- this.buffer[x + width * y] = 1;
2143
- }
2144
- do {
2145
- if (v) {
2146
- x--;
2147
- } else {
2148
- x++;
2149
- if (k) {
2150
- if (y !== 0) {
2151
- y--;
2152
- } else {
2153
- x -= 2;
2154
- k = !k;
2155
- if (x === 6) {
2156
- x--;
2157
- y = 9;
2158
- }
2159
- }
2160
- } else if (y !== width - 1) {
2161
- y++;
2162
- } else {
2163
- x -= 2;
2164
- k = !k;
2165
- if (x === 6) {
2166
- x--;
2167
- y -= 8;
2168
- }
2169
- }
2170
- }
2171
- v = !v;
2172
- } while (this._isMasked(x, y));
2173
- }
2174
- }
2175
- },
2176
- _reverseMask: function() {
2177
- var x, y;
2178
- var width = this.width;
2179
- for (x = 0; x < 9; x++) {
2180
- this._setMask(x, 8);
2181
- }
2182
- for (x = 0; x < 8; x++) {
2183
- this._setMask(x + width - 8, 8);
2184
- this._setMask(8, x);
2185
- }
2186
- for (y = 0; y < 7; y++) {
2187
- this._setMask(8, y + width - 7);
2188
- }
2189
- },
2190
- _setMask: function(x, y) {
2191
- var bit = Frame._getMaskBit(x, y);
2192
- this._mask[bit] = 1;
2193
- },
2194
- _syncMask: function() {
2195
- var x, y;
2196
- var width = this.width;
2197
- for (y = 0; y < width; y++) {
2198
- for (x = 0; x <= y; x++) {
2199
- if (this.buffer[x + width * y]) {
2200
- this._setMask(x, y);
2201
- }
2202
- }
2203
- }
2204
- }
2205
- }, {
2206
- _createArray: function(length) {
2207
- var i;
2208
- var array = [];
2209
- for (i = 0; i < length; i++) {
2210
- array[i] = 0;
2211
- }
2212
- return array;
2213
- },
2214
- _getMaskBit: function(x, y) {
2215
- var bit;
2216
- if (x > y) {
2217
- bit = x;
2218
- x = y;
2219
- y = bit;
2220
- }
2221
- bit = y;
2222
- bit += y * y;
2223
- bit >>= 1;
2224
- bit += x;
2225
- return bit;
2226
- },
2227
- _modN: function(x) {
2228
- while (x >= 255) {
2229
- x -= 255;
2230
- x = (x >> 8) + (x & 255);
2231
- }
2232
- return x;
2233
- },
2234
- // *Badness* coefficients.
2235
- N1: 3,
2236
- N2: 3,
2237
- N3: 40,
2238
- N4: 10
2239
- });
2240
- var Frame_1 = Frame;
2241
- var ImageRenderer = Renderer_1.extend({
2242
- /**
2243
- * @override
2244
- */
2245
- draw: function() {
2246
- this.element.src = this.qrious.toDataURL();
2247
- },
2248
- /**
2249
- * @override
2250
- */
2251
- reset: function() {
2252
- this.element.src = "";
2253
- },
2254
- /**
2255
- * @override
2256
- */
2257
- resize: function() {
2258
- var element = this.element;
2259
- element.width = element.height = this.qrious.size;
2260
- }
2261
- });
2262
- var ImageRenderer_1 = ImageRenderer;
2263
- var Option = lite.extend(function(name, modifiable, defaultValue, valueTransformer) {
2264
- this.name = name;
2265
- this.modifiable = Boolean(modifiable);
2266
- this.defaultValue = defaultValue;
2267
- this._valueTransformer = valueTransformer;
2268
- }, {
2269
- /**
2270
- * Transforms the specified <code>value</code> so that it can be applied for this {@link Option}.
2271
- *
2272
- * If a value transformer has been specified for this {@link Option}, it will be called upon to transform
2273
- * <code>value</code>. Otherwise, <code>value</code> will be returned directly.
2274
- *
2275
- * @param {*} value - the value to be transformed
2276
- * @return {*} The transformed value or <code>value</code> if no value transformer is specified.
2277
- * @public
2278
- * @memberof Option#
2279
- */
2280
- transform: function(value) {
2281
- var transformer = this._valueTransformer;
2282
- if (typeof transformer === "function") {
2283
- return transformer(value, this);
2284
- }
2285
- return value;
2286
- }
2287
- });
2288
- var Option_1 = Option;
2289
- var Utilities = lite.extend(null, {
2290
- /**
2291
- * Returns the absolute value of a given number.
2292
- *
2293
- * This method is simply a convenient shorthand for <code>Math.abs</code> while ensuring that nulls are returned as
2294
- * <code>null</code> instead of zero.
2295
- *
2296
- * @param {number} value - the number whose absolute value is to be returned
2297
- * @return {number} The absolute value of <code>value</code> or <code>null</code> if <code>value</code> is
2298
- * <code>null</code>.
2299
- * @public
2300
- * @static
2301
- * @memberof Utilities
2302
- */
2303
- abs: function(value) {
2304
- return value != null ? Math.abs(value) : null;
2305
- },
2306
- /**
2307
- * Returns whether the specified <code>object</code> has a property with the specified <code>name</code> as an own
2308
- * (not inherited) property.
2309
- *
2310
- * @param {Object} object - the object on which the property is to be checked
2311
- * @param {string} name - the name of the property to be checked
2312
- * @return {boolean} <code>true</code> if <code>object</code> has an own property with <code>name</code>.
2313
- * @public
2314
- * @static
2315
- * @memberof Utilities
2316
- */
2317
- hasOwn: function(object, name) {
2318
- return Object.prototype.hasOwnProperty.call(object, name);
2319
- },
2320
- /**
2321
- * A non-operation method that does absolutely nothing.
2322
- *
2323
- * @return {void}
2324
- * @public
2325
- * @static
2326
- * @memberof Utilities
2327
- */
2328
- noop: function() {
2329
- },
2330
- /**
2331
- * Transforms the specified <code>string</code> to upper case while remaining null-safe.
2332
- *
2333
- * @param {string} string - the string to be transformed to upper case
2334
- * @return {string} <code>string</code> transformed to upper case if <code>string</code> is not <code>null</code>.
2335
- * @public
2336
- * @static
2337
- * @memberof Utilities
2338
- */
2339
- toUpperCase: function(string) {
2340
- return string != null ? string.toUpperCase() : null;
2341
- }
2342
- });
2343
- var Utilities_1 = Utilities;
2344
- var OptionManager = lite.extend(function(options) {
2345
- this.options = {};
2346
- options.forEach(function(option) {
2347
- this.options[option.name] = option;
2348
- }, this);
2349
- }, {
2350
- /**
2351
- * Returns whether an option with the specified <code>name</code> is available.
2352
- *
2353
- * @param {string} name - the name of the {@link Option} whose existence is to be checked
2354
- * @return {boolean} <code>true</code> if an {@link Option} exists with <code>name</code>; otherwise
2355
- * <code>false</code>.
2356
- * @public
2357
- * @memberof OptionManager#
2358
- */
2359
- exists: function(name) {
2360
- return this.options[name] != null;
2361
- },
2362
- /**
2363
- * Returns the value of the option with the specified <code>name</code> on the <code>target</code> object provided.
2364
- *
2365
- * @param {string} name - the name of the {@link Option} whose value on <code>target</code> is to be returned
2366
- * @param {Object} target - the object from which the value of the named {@link Option} is to be returned
2367
- * @return {*} The value of the {@link Option} with <code>name</code> on <code>target</code>.
2368
- * @public
2369
- * @memberof OptionManager#
2370
- */
2371
- get: function(name, target) {
2372
- return OptionManager._get(this.options[name], target);
2373
- },
2374
- /**
2375
- * Returns a copy of all of the available options on the <code>target</code> object provided.
2376
- *
2377
- * @param {Object} target - the object from which the option name/value pairs are to be returned
2378
- * @return {Object.<string, *>} A hash containing the name/value pairs of all options on <code>target</code>.
2379
- * @public
2380
- * @memberof OptionManager#
2381
- */
2382
- getAll: function(target) {
2383
- var name;
2384
- var options = this.options;
2385
- var result = {};
2386
- for (name in options) {
2387
- if (Utilities_1.hasOwn(options, name)) {
2388
- result[name] = OptionManager._get(options[name], target);
2389
- }
2390
- }
2391
- return result;
2392
- },
2393
- /**
2394
- * Initializes the available options for the <code>target</code> object provided and then applies the initial values
2395
- * within the speciifed <code>options</code>.
2396
- *
2397
- * This method will throw an error if any of the names within <code>options</code> does not match an available option.
2398
- *
2399
- * This involves setting the default values and defining properties for all of the available options on
2400
- * <code>target</code> before finally calling {@link OptionMananger#setAll} with <code>options</code> and
2401
- * <code>target</code>. Any options that are configured to be modifiable will have a setter included in their defined
2402
- * property that will allow its corresponding value to be modified.
2403
- *
2404
- * If a change handler is specified, it will be called whenever the value changes on <code>target</code> for a
2405
- * modifiable option, but only when done so via the defined property's setter.
2406
- *
2407
- * @param {Object.<string, *>} options - the name/value pairs of the initial options to be set
2408
- * @param {Object} target - the object on which the options are to be initialized
2409
- * @param {Function} [changeHandler] - the function to be called whenever the value of an modifiable option changes on
2410
- * <code>target</code>
2411
- * @return {void}
2412
- * @throws {Error} If <code>options</code> contains an invalid option name.
2413
- * @public
2414
- * @memberof OptionManager#
2415
- */
2416
- init: function(options, target, changeHandler) {
2417
- if (typeof changeHandler !== "function") {
2418
- changeHandler = Utilities_1.noop;
2419
- }
2420
- var name, option;
2421
- for (name in this.options) {
2422
- if (Utilities_1.hasOwn(this.options, name)) {
2423
- option = this.options[name];
2424
- OptionManager._set(option, option.defaultValue, target);
2425
- OptionManager._createAccessor(option, target, changeHandler);
2426
- }
2427
- }
2428
- this._setAll(options, target, true);
2429
- },
2430
- /**
2431
- * Sets the value of the option with the specified <code>name</code> on the <code>target</code> object provided to
2432
- * <code>value</code>.
2433
- *
2434
- * This method will throw an error if <code>name</code> does not match an available option or matches an option that
2435
- * cannot be modified.
2436
- *
2437
- * If <code>value</code> is <code>null</code> and the {@link Option} has a default value configured, then that default
2438
- * value will be used instead. If the {@link Option} also has a value transformer configured, it will be used to
2439
- * transform whichever value was determined to be used.
2440
- *
2441
- * This method returns whether the value of the underlying field on <code>target</code> was changed as a result.
2442
- *
2443
- * @param {string} name - the name of the {@link Option} whose value is to be set
2444
- * @param {*} value - the value to be set for the named {@link Option} on <code>target</code>
2445
- * @param {Object} target - the object on which <code>value</code> is to be set for the named {@link Option}
2446
- * @return {boolean} <code>true</code> if the underlying field on <code>target</code> was changed; otherwise
2447
- * <code>false</code>.
2448
- * @throws {Error} If <code>name</code> is invalid or is for an option that cannot be modified.
2449
- * @public
2450
- * @memberof OptionManager#
2451
- */
2452
- set: function(name, value, target) {
2453
- return this._set(name, value, target);
2454
- },
2455
- /**
2456
- * Sets all of the specified <code>options</code> on the <code>target</code> object provided to their corresponding
2457
- * values.
2458
- *
2459
- * This method will throw an error if any of the names within <code>options</code> does not match an available option
2460
- * or matches an option that cannot be modified.
2461
- *
2462
- * If any value within <code>options</code> is <code>null</code> and the corresponding {@link Option} has a default
2463
- * value configured, then that default value will be used instead. If an {@link Option} also has a value transformer
2464
- * configured, it will be used to transform whichever value was determined to be used.
2465
- *
2466
- * This method returns whether the value for any of the underlying fields on <code>target</code> were changed as a
2467
- * result.
2468
- *
2469
- * @param {Object.<string, *>} options - the name/value pairs of options to be set
2470
- * @param {Object} target - the object on which the options are to be set
2471
- * @return {boolean} <code>true</code> if any of the underlying fields on <code>target</code> were changed; otherwise
2472
- * <code>false</code>.
2473
- * @throws {Error} If <code>options</code> contains an invalid option name or an option that cannot be modiifed.
2474
- * @public
2475
- * @memberof OptionManager#
2476
- */
2477
- setAll: function(options, target) {
2478
- return this._setAll(options, target);
2479
- },
2480
- _set: function(name, value, target, allowUnmodifiable) {
2481
- var option = this.options[name];
2482
- if (!option) {
2483
- throw new Error("Invalid option: " + name);
2484
- }
2485
- if (!option.modifiable && !allowUnmodifiable) {
2486
- throw new Error("Option cannot be modified: " + name);
2487
- }
2488
- return OptionManager._set(option, value, target);
2489
- },
2490
- _setAll: function(options, target, allowUnmodifiable) {
2491
- if (!options) {
2492
- return false;
2493
- }
2494
- var name;
2495
- var changed = false;
2496
- for (name in options) {
2497
- if (Utilities_1.hasOwn(options, name) && this._set(name, options[name], target, allowUnmodifiable)) {
2498
- changed = true;
2499
- }
2500
- }
2501
- return changed;
2502
- }
2503
- }, {
2504
- _createAccessor: function(option, target, changeHandler) {
2505
- var descriptor = {
2506
- get: function() {
2507
- return OptionManager._get(option, target);
2508
- }
2509
- };
2510
- if (option.modifiable) {
2511
- descriptor.set = function(value) {
2512
- if (OptionManager._set(option, value, target)) {
2513
- changeHandler(value, option);
2514
- }
2515
- };
2516
- }
2517
- Object.defineProperty(target, option.name, descriptor);
2518
- },
2519
- _get: function(option, target) {
2520
- return target["_" + option.name];
2521
- },
2522
- _set: function(option, value, target) {
2523
- var fieldName = "_" + option.name;
2524
- var oldValue = target[fieldName];
2525
- var newValue = option.transform(value != null ? value : option.defaultValue);
2526
- target[fieldName] = newValue;
2527
- return newValue !== oldValue;
2528
- }
2529
- });
2530
- var OptionManager_1 = OptionManager;
2531
- var ServiceManager = lite.extend(function() {
2532
- this._services = {};
2533
- }, {
2534
- /**
2535
- * Returns the {@link Service} being managed with the specified <code>name</code>.
2536
- *
2537
- * @param {string} name - the name of the {@link Service} to be returned
2538
- * @return {Service} The {@link Service} is being managed with <code>name</code>.
2539
- * @throws {Error} If no {@link Service} is being managed with <code>name</code>.
2540
- * @public
2541
- * @memberof ServiceManager#
2542
- */
2543
- getService: function(name) {
2544
- var service = this._services[name];
2545
- if (!service) {
2546
- throw new Error("Service is not being managed with name: " + name);
2547
- }
2548
- return service;
2549
- },
2550
- /**
2551
- * Sets the {@link Service} implementation to be managed for the specified <code>name</code> to the
2552
- * <code>service</code> provided.
2553
- *
2554
- * @param {string} name - the name of the {@link Service} to be managed with <code>name</code>
2555
- * @param {Service} service - the {@link Service} implementation to be managed
2556
- * @return {void}
2557
- * @throws {Error} If a {@link Service} is already being managed with the same <code>name</code>.
2558
- * @public
2559
- * @memberof ServiceManager#
2560
- */
2561
- setService: function(name, service) {
2562
- if (this._services[name]) {
2563
- throw new Error("Service is already managed with name: " + name);
2564
- }
2565
- if (service) {
2566
- this._services[name] = service;
2567
- }
2568
- }
2569
- });
2570
- var ServiceManager_1 = ServiceManager;
2571
- var optionManager = new OptionManager_1([
2572
- new Option_1("background", true, "white"),
2573
- new Option_1("backgroundAlpha", true, 1, Utilities_1.abs),
2574
- new Option_1("element"),
2575
- new Option_1("foreground", true, "black"),
2576
- new Option_1("foregroundAlpha", true, 1, Utilities_1.abs),
2577
- new Option_1("level", true, "L", Utilities_1.toUpperCase),
2578
- new Option_1("mime", true, "image/png"),
2579
- new Option_1("padding", true, null, Utilities_1.abs),
2580
- new Option_1("size", true, 100, Utilities_1.abs),
2581
- new Option_1("value", true, "")
2582
- ]);
2583
- var serviceManager = new ServiceManager_1();
2584
- var QRious2 = lite.extend(function(options) {
2585
- optionManager.init(options, this, this.update.bind(this));
2586
- var element = optionManager.get("element", this);
2587
- var elementService = serviceManager.getService("element");
2588
- var canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas();
2589
- var image = element && elementService.isImage(element) ? element : elementService.createImage();
2590
- this._canvasRenderer = new CanvasRenderer_1(this, canvas, true);
2591
- this._imageRenderer = new ImageRenderer_1(this, image, image === element);
2592
- this.update();
2593
- }, {
2594
- /**
2595
- * Returns all of the options configured for this {@link QRious}.
2596
- *
2597
- * Any changes made to the returned object will not be reflected in the options themselves or their corresponding
2598
- * underlying fields.
2599
- *
2600
- * @return {Object.<string, *>} A copy of the applied options.
2601
- * @public
2602
- * @memberof QRious#
2603
- */
2604
- get: function() {
2605
- return optionManager.getAll(this);
2606
- },
2607
- /**
2608
- * Sets all of the specified <code>options</code> and automatically updates this {@link QRious} if any of the
2609
- * underlying fields are changed as a result.
2610
- *
2611
- * This is the preferred method for updating multiple options at one time to avoid unnecessary updates between
2612
- * changes.
2613
- *
2614
- * @param {QRious~Options} options - the options to be set
2615
- * @return {void}
2616
- * @throws {Error} If any <code>options</code> are invalid or cannot be modified.
2617
- * @public
2618
- * @memberof QRious#
2619
- */
2620
- set: function(options) {
2621
- if (optionManager.setAll(options, this)) {
2622
- this.update();
2623
- }
2624
- },
2625
- /**
2626
- * Returns the image data URI for the generated QR code using the <code>mime</code> provided.
2627
- *
2628
- * @param {string} [mime] - the MIME type for the image
2629
- * @return {string} The image data URI for the QR code.
2630
- * @public
2631
- * @memberof QRious#
2632
- */
2633
- toDataURL: function(mime) {
2634
- return this.canvas.toDataURL(mime || this.mime);
2635
- },
2636
- /**
2637
- * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code.
2638
- *
2639
- * @return {void}
2640
- * @protected
2641
- * @memberof QRious#
2642
- */
2643
- update: function() {
2644
- var frame = new Frame_1({
2645
- level: this.level,
2646
- value: this.value
2647
- });
2648
- this._canvasRenderer.render(frame);
2649
- this._imageRenderer.render(frame);
2650
- }
2651
- }, {
2652
- /**
2653
- * Configures the <code>service</code> provided to be used by all {@link QRious} instances.
2654
- *
2655
- * @param {Service} service - the {@link Service} to be configured
2656
- * @return {void}
2657
- * @throws {Error} If a {@link Service} has already been configured with the same name.
2658
- * @public
2659
- * @static
2660
- * @memberof QRious
2661
- */
2662
- use: function(service) {
2663
- serviceManager.setService(service.getName(), service);
2664
- }
2665
- });
2666
- Object.defineProperties(QRious2.prototype, {
2667
- canvas: {
2668
- /**
2669
- * Returns the <code>canvas</code> element being used to render the QR code for this {@link QRious}.
2670
- *
2671
- * @return {*} The <code>canvas</code> element.
2672
- * @public
2673
- * @memberof QRious#
2674
- * @alias canvas
2675
- */
2676
- get: function() {
2677
- return this._canvasRenderer.getElement();
2678
- }
2679
- },
2680
- image: {
2681
- /**
2682
- * Returns the <code>img</code> element being used to render the QR code for this {@link QRious}.
2683
- *
2684
- * @return {*} The <code>img</code> element.
2685
- * @public
2686
- * @memberof QRious#
2687
- * @alias image
2688
- */
2689
- get: function() {
2690
- return this._imageRenderer.getElement();
2691
- }
2692
- }
2693
- });
2694
- var QRious_1$2 = QRious2;
2695
- var index = QRious_1$2;
2696
- var Service = lite.extend({
2697
- /**
2698
- * Returns the name of this {@link Service}.
2699
- *
2700
- * @return {string} The service name.
2701
- * @public
2702
- * @abstract
2703
- * @memberof Service#
2704
- */
2705
- getName: function() {
2706
- }
2707
- });
2708
- var Service_1 = Service;
2709
- var ElementService = Service_1.extend({
2710
- /**
2711
- * Creates an instance of a canvas element.
2712
- *
2713
- * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
2714
- *
2715
- * @return {*} The newly created canvas element.
2716
- * @public
2717
- * @abstract
2718
- * @memberof ElementService#
2719
- */
2720
- createCanvas: function() {
2721
- },
2722
- /**
2723
- * Creates an instance of a image element.
2724
- *
2725
- * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
2726
- *
2727
- * @return {*} The newly created image element.
2728
- * @public
2729
- * @abstract
2730
- * @memberof ElementService#
2731
- */
2732
- createImage: function() {
2733
- },
2734
- /**
2735
- * @override
2736
- */
2737
- getName: function() {
2738
- return "element";
2739
- },
2740
- /**
2741
- * Returns whether the specified <code>element</code> is a canvas.
2742
- *
2743
- * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
2744
- *
2745
- * @param {*} element - the element to be checked
2746
- * @return {boolean} <code>true</code> if <code>element</code> is a canvas; otherwise <code>false</code>.
2747
- * @public
2748
- * @abstract
2749
- * @memberof ElementService#
2750
- */
2751
- isCanvas: function(element) {
2752
- },
2753
- /**
2754
- * Returns whether the specified <code>element</code> is an image.
2755
- *
2756
- * Implementations of {@link ElementService} <b>must</b> override this method with their own specific logic.
2757
- *
2758
- * @param {*} element - the element to be checked
2759
- * @return {boolean} <code>true</code> if <code>element</code> is an image; otherwise <code>false</code>.
2760
- * @public
2761
- * @abstract
2762
- * @memberof ElementService#
2763
- */
2764
- isImage: function(element) {
2765
- }
2766
- });
2767
- var ElementService_1 = ElementService;
2768
- var BrowserElementService = ElementService_1.extend({
2769
- /**
2770
- * @override
2771
- */
2772
- createCanvas: function() {
2773
- return document.createElement("canvas");
2774
- },
2775
- /**
2776
- * @override
2777
- */
2778
- createImage: function() {
2779
- return document.createElement("img");
2780
- },
2781
- /**
2782
- * @override
2783
- */
2784
- isCanvas: function(element) {
2785
- return element instanceof HTMLCanvasElement;
2786
- },
2787
- /**
2788
- * @override
2789
- */
2790
- isImage: function(element) {
2791
- return element instanceof HTMLImageElement;
2792
- }
2793
- });
2794
- var BrowserElementService_1 = BrowserElementService;
2795
- index.use(new BrowserElementService_1());
2796
- var QRious_1 = index;
2797
- return QRious_1;
2798
- });
2799
- })(qrious$1);
2800
- return qrious$1.exports;
2801
- }
2802
- var qriousExports = requireQrious();
2803
- const QRious = /* @__PURE__ */ getDefaultExportFromCjs(qriousExports);
2804
- class QrCode extends WJElement {
2805
- /**
2806
- * Creates an instance of QrCode.
2807
- */
2808
- constructor() {
2809
- super();
2810
- /**
2811
- * The class name for the component.
2812
- * @type {string}
2813
- */
2814
- __publicField(this, "className", "QrCode");
2815
- }
2816
- /**
2817
- * Returns the CSS stylesheet for the component.
2818
- * @returns {CSSStyleSheet} The CSS stylesheet.
2819
- */
2820
- static get cssStyleSheet() {
2821
- return styles;
2822
- }
2823
- /**
2824
- * Sets up the attributes for the component.
2825
- */
2826
- setupAttributes() {
2827
- this.isShadowRoot = "open";
2828
- }
2829
- /**
2830
- * Returns the list of observed attributes.
2831
- * @returns {string[]} The list of observed attributes.
2832
- */
2833
- static get observedAttributes() {
2834
- return ["value", "background", "backgroundAlpha", "foreground", "foregroundAlpha", "level", "padding", "size"];
2835
- }
2836
- /**
2837
- * Draws the QR code component.
2838
- * @returns {DocumentFragment} The document fragment containing the QR code component.
2839
- */
2840
- draw() {
2841
- let fragment = document.createDocumentFragment();
2842
- let wrapper = document.createElement("div");
2843
- wrapper.classList.add("container");
2844
- let qrCode = document.createElement("canvas");
2845
- qrCode.classList.add("qr");
2846
- qrCode.setAttribute("part", "native");
2847
- let slotTop = document.createElement("slot");
2848
- slotTop.setAttribute("name", "top");
2849
- let slotBottom = document.createElement("slot");
2850
- slotBottom.setAttribute("name", "bottom");
2851
- wrapper.appendChild(slotTop);
2852
- wrapper.appendChild(qrCode);
2853
- wrapper.appendChild(slotBottom);
2854
- fragment.appendChild(wrapper);
2855
- return fragment;
2856
- }
2857
- /**
2858
- * Called after the component is drawn to generate the QR code.
2859
- */
2860
- afterDraw() {
2861
- const canvas = this.shadowRoot.querySelector("canvas");
2862
- const qrOptions = {};
2863
- const attributes = [
2864
- "value",
2865
- "background",
2866
- "backgroundAlpha",
2867
- "foreground",
2868
- "foregroundAlpha",
2869
- "level",
2870
- "padding",
2871
- "size"
2872
- ];
2873
- attributes.forEach((attribute) => {
2874
- const value = this.getAttribute(attribute);
2875
- if (value !== null) {
2876
- qrOptions[attribute] = value;
2877
- }
2878
- });
2879
- if (!qrOptions.hasOwnProperty("value")) {
2880
- qrOptions.value = "empty value";
2881
- }
2882
- new QRious({
2883
- element: canvas,
2884
- ...qrOptions
2885
- });
2886
- }
2887
- }
2888
- QrCode.define("wje-qr-code", QrCode);
2889
- export {
2890
- QrCode as default
2891
- };