@ulu/frontend 0.0.3

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 (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/ulu-frontend.min.css +1 -0
  4. package/dist/ulu-frontend.min.js +1 -0
  5. package/index.js +2 -0
  6. package/js/deprecated/doc-ready.js +28 -0
  7. package/js/deprecated/jquery-prototypes.js +309 -0
  8. package/js/deprecated/mini-collapsible-popper-positioning.js +126 -0
  9. package/js/deprecated/mini-collapsible.js +607 -0
  10. package/js/deprecated/script-loader.js +60 -0
  11. package/js/events/index.js +42 -0
  12. package/js/helpers/css-breakpoint.js +247 -0
  13. package/js/helpers/file-save.js +48 -0
  14. package/js/helpers/node-data-manager.js +74 -0
  15. package/js/helpers/pause-youtube-video.js +42 -0
  16. package/js/helpers/scrollbar-width-property.js +10 -0
  17. package/js/index.js +15 -0
  18. package/js/polyfills/element-closest.js +17 -0
  19. package/js/ui/flipcard.js +202 -0
  20. package/js/ui/grid.js +67 -0
  21. package/js/ui/modals.js +219 -0
  22. package/js/ui/overflow-scroller-pager.js +58 -0
  23. package/js/ui/overflow-scroller.js +160 -0
  24. package/js/ui/programmatic-modal.js +91 -0
  25. package/js/ui/resizer.js +60 -0
  26. package/js/ui/slider.js +468 -0
  27. package/js/ui/tabs.js +109 -0
  28. package/js/ui/tooltip.js +82 -0
  29. package/js/utils/array.js +28 -0
  30. package/js/utils/dom.js +122 -0
  31. package/js/utils/logger.js +69 -0
  32. package/js/utils/object.js +22 -0
  33. package/js/utils/performance.js +43 -0
  34. package/js/utils/regex.js +10 -0
  35. package/js/utils/string.js +107 -0
  36. package/js/waypoints/README.md +3 -0
  37. package/js/waypoints/anchor-menu.js +76 -0
  38. package/js/waypoints/element-waypoint.js +75 -0
  39. package/js/waypoints/examples/page-link-menu.md +106 -0
  40. package/js/waypoints/state-in-attribute.js +32 -0
  41. package/package.json +38 -0
  42. package/scss/README.md +58 -0
  43. package/scss/_breakpoint.scss +190 -0
  44. package/scss/_button.scss +241 -0
  45. package/scss/_calculate.scss +64 -0
  46. package/scss/_color.scss +211 -0
  47. package/scss/_cssvar.scss +116 -0
  48. package/scss/_element.scss +276 -0
  49. package/scss/_grid.scss +699 -0
  50. package/scss/_index.scss +29 -0
  51. package/scss/_layout.scss +202 -0
  52. package/scss/_path.scss +58 -0
  53. package/scss/_selector.scss +81 -0
  54. package/scss/_typography.scss +320 -0
  55. package/scss/_units.scss +47 -0
  56. package/scss/_utility.scss +12 -0
  57. package/scss/_utils.scss +209 -0
  58. package/scss/base/_color.scss +13 -0
  59. package/scss/base/_elements.scss +188 -0
  60. package/scss/base/_index.scss +62 -0
  61. package/scss/base/_keyframes.scss +78 -0
  62. package/scss/base/_layout.scss +100 -0
  63. package/scss/base/_normalize.scss +315 -0
  64. package/scss/base/_typography.scss +41 -0
  65. package/scss/components/README.md +5 -0
  66. package/scss/components/README.todos +15 -0
  67. package/scss/components/_button.scss +95 -0
  68. package/scss/components/_index.scss +63 -0
  69. package/scss/components/_links.scss +34 -0
  70. package/scss/components/_list-lines.scss +73 -0
  71. package/scss/components/_list-ordered.scss +16 -0
  72. package/scss/components/_list-unordered.scss +21 -0
  73. package/scss/components/_rule.scss +93 -0
  74. package/scss/helpers/_color.scss +14 -0
  75. package/scss/helpers/_display.scss +73 -0
  76. package/scss/helpers/_index.scss +67 -0
  77. package/scss/helpers/_print.scss +58 -0
  78. package/scss/helpers/_typography.scss +80 -0
  79. package/scss/helpers/_units.scss +79 -0
  80. package/scss/helpers/_utilities.scss +102 -0
  81. package/scss/stylesheets/README.md +3 -0
  82. package/scss/stylesheets/full.scss +17 -0
  83. package/trash/js-old/deprecated/doc-ready.js +28 -0
  84. package/trash/js-old/deprecated/jquery-prototypes.js +309 -0
  85. package/trash/js-old/deprecated/mini-collapsible-popper-positioning.js +126 -0
  86. package/trash/js-old/deprecated/mini-collapsible.js +607 -0
  87. package/trash/js-old/deprecated/script-loader.js +60 -0
  88. package/trash/js-old/events/index.js +42 -0
  89. package/trash/js-old/helpers/css-breakpoint.js +247 -0
  90. package/trash/js-old/helpers/file-save.js +48 -0
  91. package/trash/js-old/helpers/node-data-manager.js +74 -0
  92. package/trash/js-old/helpers/pause-youtube-video.js +42 -0
  93. package/trash/js-old/index.js +15 -0
  94. package/trash/js-old/polyfills/element-closest.js +17 -0
  95. package/trash/js-old/ui/flipcard.js +202 -0
  96. package/trash/js-old/ui/grid.js +67 -0
  97. package/trash/js-old/ui/modals.js +219 -0
  98. package/trash/js-old/ui/programmatic-modal.js +91 -0
  99. package/trash/js-old/ui/resizer.js +60 -0
  100. package/trash/js-old/ui/slider.js +469 -0
  101. package/trash/js-old/ui/tabs.js +109 -0
  102. package/trash/js-old/ui/tooltip.js +82 -0
  103. package/trash/js-old/utils/array.js +28 -0
  104. package/trash/js-old/utils/dom.js +122 -0
  105. package/trash/js-old/utils/logger.js +69 -0
  106. package/trash/js-old/utils/object.js +22 -0
  107. package/trash/js-old/utils/performance.js +43 -0
  108. package/trash/js-old/utils/regex.js +10 -0
  109. package/trash/js-old/utils/string.js +107 -0
  110. package/trash/js-old/waypoints/README.md +3 -0
  111. package/trash/js-old/waypoints/anchor-menu.js +76 -0
  112. package/trash/js-old/waypoints/element-waypoint.js +75 -0
  113. package/trash/js-old/waypoints/examples/page-link-menu.md +106 -0
  114. package/trash/js-old/waypoints/state-in-attribute.js +32 -0
  115. package/trash/js-old-230729/deprecated/doc-ready.js +28 -0
  116. package/trash/js-old-230729/deprecated/jquery-prototypes.js +309 -0
  117. package/trash/js-old-230729/deprecated/mini-collapsible-popper-positioning.js +126 -0
  118. package/trash/js-old-230729/deprecated/mini-collapsible.js +607 -0
  119. package/trash/js-old-230729/deprecated/script-loader.js +60 -0
  120. package/trash/js-old-230729/events/index.js +42 -0
  121. package/trash/js-old-230729/helpers/css-breakpoint.js +247 -0
  122. package/trash/js-old-230729/helpers/file-save.js +48 -0
  123. package/trash/js-old-230729/helpers/node-data-manager.js +74 -0
  124. package/trash/js-old-230729/helpers/pause-youtube-video.js +42 -0
  125. package/trash/js-old-230729/helpers/scrollbar-width-property.js +10 -0
  126. package/trash/js-old-230729/index.js +15 -0
  127. package/trash/js-old-230729/polyfills/element-closest.js +17 -0
  128. package/trash/js-old-230729/ui/flipcard.js +202 -0
  129. package/trash/js-old-230729/ui/grid.js +67 -0
  130. package/trash/js-old-230729/ui/modals.js +219 -0
  131. package/trash/js-old-230729/ui/overflow-scroller-pager.js +58 -0
  132. package/trash/js-old-230729/ui/overflow-scroller.js +160 -0
  133. package/trash/js-old-230729/ui/programmatic-modal.js +91 -0
  134. package/trash/js-old-230729/ui/resizer.js +60 -0
  135. package/trash/js-old-230729/ui/slider.js +468 -0
  136. package/trash/js-old-230729/ui/tabs.js +109 -0
  137. package/trash/js-old-230729/ui/tooltip.js +82 -0
  138. package/trash/js-old-230729/utils/array.js +28 -0
  139. package/trash/js-old-230729/utils/dom.js +122 -0
  140. package/trash/js-old-230729/utils/logger.js +69 -0
  141. package/trash/js-old-230729/utils/object.js +22 -0
  142. package/trash/js-old-230729/utils/performance.js +43 -0
  143. package/trash/js-old-230729/utils/regex.js +10 -0
  144. package/trash/js-old-230729/utils/string.js +107 -0
  145. package/trash/js-old-230729/waypoints/README.md +3 -0
  146. package/trash/js-old-230729/waypoints/anchor-menu.js +76 -0
  147. package/trash/js-old-230729/waypoints/element-waypoint.js +75 -0
  148. package/trash/js-old-230729/waypoints/examples/page-link-menu.md +106 -0
  149. package/trash/js-old-230729/waypoints/state-in-attribute.js +32 -0
  150. package/trash/logo-1.svg +13 -0
  151. package/trash/logo.svg +16 -0
  152. package/trash/scss-before-cqc-update/README.md +58 -0
  153. package/trash/scss-before-cqc-update/_breakpoint.scss +190 -0
  154. package/trash/scss-before-cqc-update/_button.scss +229 -0
  155. package/trash/scss-before-cqc-update/_calculate.scss +65 -0
  156. package/trash/scss-before-cqc-update/_color.scss +211 -0
  157. package/trash/scss-before-cqc-update/_cssvar.scss +116 -0
  158. package/trash/scss-before-cqc-update/_element.scss +275 -0
  159. package/trash/scss-before-cqc-update/_index.scss +29 -0
  160. package/trash/scss-before-cqc-update/_layout.scss +247 -0
  161. package/trash/scss-before-cqc-update/_path.scss +59 -0
  162. package/trash/scss-before-cqc-update/_selector.scss +82 -0
  163. package/trash/scss-before-cqc-update/_typography.scss +322 -0
  164. package/trash/scss-before-cqc-update/_units.scss +48 -0
  165. package/trash/scss-before-cqc-update/_utility.scss +13 -0
  166. package/trash/scss-before-cqc-update/_utils.scss +211 -0
  167. package/trash/scss-before-cqc-update/base/_color.scss +14 -0
  168. package/trash/scss-before-cqc-update/base/_elements.scss +189 -0
  169. package/trash/scss-before-cqc-update/base/_index.scss +63 -0
  170. package/trash/scss-before-cqc-update/base/_keyframes.scss +74 -0
  171. package/trash/scss-before-cqc-update/base/_layout.scss +88 -0
  172. package/trash/scss-before-cqc-update/base/_normalize.scss +316 -0
  173. package/trash/scss-before-cqc-update/base/_typography.scss +42 -0
  174. package/trash/scss-before-cqc-update/components/README.md +5 -0
  175. package/trash/scss-before-cqc-update/components/README.todos +15 -0
  176. package/trash/scss-before-cqc-update/components/_button.scss +96 -0
  177. package/trash/scss-before-cqc-update/components/_grid.scss +671 -0
  178. package/trash/scss-before-cqc-update/components/_index.scss +70 -0
  179. package/trash/scss-before-cqc-update/components/_links.scss +35 -0
  180. package/trash/scss-before-cqc-update/components/_list-lines.scss +74 -0
  181. package/trash/scss-before-cqc-update/components/_list-ordered.scss +17 -0
  182. package/trash/scss-before-cqc-update/components/_list-unordered.scss +22 -0
  183. package/trash/scss-before-cqc-update/components/_rule.scss +94 -0
  184. package/trash/scss-before-cqc-update/helpers/_color.scss +15 -0
  185. package/trash/scss-before-cqc-update/helpers/_display.scss +73 -0
  186. package/trash/scss-before-cqc-update/helpers/_index.scss +68 -0
  187. package/trash/scss-before-cqc-update/helpers/_print.scss +59 -0
  188. package/trash/scss-before-cqc-update/helpers/_typography.scss +73 -0
  189. package/trash/scss-before-cqc-update/helpers/_units.scss +79 -0
  190. package/trash/scss-before-cqc-update/helpers/_utilities.scss +88 -0
  191. package/trash/scss-before-cqc-update/stylesheets/README.md +3 -0
  192. package/trash/scss-before-cqc-update/stylesheets/full.scss +17 -0
  193. package/trash/scss-old/README.md +58 -0
  194. package/trash/scss-old/_breakpoint.scss +140 -0
  195. package/trash/scss-old/_button.scss +223 -0
  196. package/trash/scss-old/_calculate.scss +64 -0
  197. package/trash/scss-old/_color.scss +200 -0
  198. package/trash/scss-old/_element.scss +262 -0
  199. package/trash/scss-old/_grid.scss +558 -0
  200. package/trash/scss-old/_index.scss +25 -0
  201. package/trash/scss-old/_layout.scss +170 -0
  202. package/trash/scss-old/_path.scss +58 -0
  203. package/trash/scss-old/_selector.scss +81 -0
  204. package/trash/scss-old/_typography.scss +320 -0
  205. package/trash/scss-old/_units.scss +47 -0
  206. package/trash/scss-old/_utility.scss +12 -0
  207. package/trash/scss-old/_utils.scss +186 -0
  208. package/trash/scss-old/base/_color.scss +13 -0
  209. package/trash/scss-old/base/_elements.scss +183 -0
  210. package/trash/scss-old/base/_index.scss +62 -0
  211. package/trash/scss-old/base/_keyframes.scss +74 -0
  212. package/trash/scss-old/base/_layout.scss +81 -0
  213. package/trash/scss-old/base/_normalize.scss +316 -0
  214. package/trash/scss-old/base/_typography.scss +42 -0
  215. package/trash/scss-old/components/README.md +5 -0
  216. package/trash/scss-old/components/README.todos +15 -0
  217. package/trash/scss-old/components/_button.scss +74 -0
  218. package/trash/scss-old/components/_index.scss +63 -0
  219. package/trash/scss-old/components/_links.scss +34 -0
  220. package/trash/scss-old/components/_list-lines.scss +73 -0
  221. package/trash/scss-old/components/_list-ordered.scss +16 -0
  222. package/trash/scss-old/components/_list-unordered.scss +21 -0
  223. package/trash/scss-old/components/_rule.scss +84 -0
  224. package/trash/scss-old/helpers/_color.scss +14 -0
  225. package/trash/scss-old/helpers/_display.scss +68 -0
  226. package/trash/scss-old/helpers/_index.scss +67 -0
  227. package/trash/scss-old/helpers/_print.scss +59 -0
  228. package/trash/scss-old/helpers/_typography.scss +73 -0
  229. package/trash/scss-old/helpers/_units.scss +68 -0
  230. package/trash/scss-old/helpers/_utilities.scss +82 -0
  231. package/trash/scss-old/packages/README.md +3 -0
  232. package/trash/scss-old/packages/everything.scss +17 -0
  233. package/trash/scss-old-2/README.md +58 -0
  234. package/trash/scss-old-2/_breakpoint.scss +139 -0
  235. package/trash/scss-old-2/_button.scss +223 -0
  236. package/trash/scss-old-2/_calculate.scss +64 -0
  237. package/trash/scss-old-2/_color.scss +202 -0
  238. package/trash/scss-old-2/_element.scss +263 -0
  239. package/trash/scss-old-2/_grid.scss +558 -0
  240. package/trash/scss-old-2/_index.scss +25 -0
  241. package/trash/scss-old-2/_layout.scss +170 -0
  242. package/trash/scss-old-2/_path.scss +58 -0
  243. package/trash/scss-old-2/_selector.scss +81 -0
  244. package/trash/scss-old-2/_typography.scss +320 -0
  245. package/trash/scss-old-2/_units.scss +47 -0
  246. package/trash/scss-old-2/_utility.scss +12 -0
  247. package/trash/scss-old-2/_utils.scss +186 -0
  248. package/trash/scss-old-2/base/_color.scss +13 -0
  249. package/trash/scss-old-2/base/_elements.scss +182 -0
  250. package/trash/scss-old-2/base/_index.scss +62 -0
  251. package/trash/scss-old-2/base/_keyframes.scss +73 -0
  252. package/trash/scss-old-2/base/_layout.scss +83 -0
  253. package/trash/scss-old-2/base/_normalize.scss +315 -0
  254. package/trash/scss-old-2/base/_typography.scss +41 -0
  255. package/trash/scss-old-2/components/README.md +5 -0
  256. package/trash/scss-old-2/components/README.todos +15 -0
  257. package/trash/scss-old-2/components/_button.scss +95 -0
  258. package/trash/scss-old-2/components/_index.scss +63 -0
  259. package/trash/scss-old-2/components/_links.scss +33 -0
  260. package/trash/scss-old-2/components/_list-lines.scss +73 -0
  261. package/trash/scss-old-2/components/_list-ordered.scss +16 -0
  262. package/trash/scss-old-2/components/_list-unordered.scss +21 -0
  263. package/trash/scss-old-2/components/_rule.scss +84 -0
  264. package/trash/scss-old-2/helpers/_color.scss +14 -0
  265. package/trash/scss-old-2/helpers/_display.scss +67 -0
  266. package/trash/scss-old-2/helpers/_index.scss +67 -0
  267. package/trash/scss-old-2/helpers/_print.scss +58 -0
  268. package/trash/scss-old-2/helpers/_typography.scss +72 -0
  269. package/trash/scss-old-2/helpers/_units.scss +68 -0
  270. package/trash/scss-old-2/helpers/_utilities.scss +81 -0
  271. package/trash/scss-old-2/packages/README.md +3 -0
  272. package/trash/scss-old-2/packages/everything.scss +17 -0
  273. package/trash/scss-old-230729/README.md +58 -0
  274. package/trash/scss-old-230729/_breakpoint.scss +139 -0
  275. package/trash/scss-old-230729/_button.scss +223 -0
  276. package/trash/scss-old-230729/_calculate.scss +64 -0
  277. package/trash/scss-old-230729/_color.scss +202 -0
  278. package/trash/scss-old-230729/_element.scss +273 -0
  279. package/trash/scss-old-230729/_grid.scss +694 -0
  280. package/trash/scss-old-230729/_index.scss +25 -0
  281. package/trash/scss-old-230729/_layout.scss +193 -0
  282. package/trash/scss-old-230729/_path.scss +58 -0
  283. package/trash/scss-old-230729/_selector.scss +81 -0
  284. package/trash/scss-old-230729/_typography.scss +320 -0
  285. package/trash/scss-old-230729/_units.scss +47 -0
  286. package/trash/scss-old-230729/_utility.scss +12 -0
  287. package/trash/scss-old-230729/_utils.scss +186 -0
  288. package/trash/scss-old-230729/base/_color.scss +13 -0
  289. package/trash/scss-old-230729/base/_elements.scss +188 -0
  290. package/trash/scss-old-230729/base/_index.scss +62 -0
  291. package/trash/scss-old-230729/base/_keyframes.scss +73 -0
  292. package/trash/scss-old-230729/base/_layout.scss +83 -0
  293. package/trash/scss-old-230729/base/_normalize.scss +315 -0
  294. package/trash/scss-old-230729/base/_typography.scss +41 -0
  295. package/trash/scss-old-230729/components/README.md +5 -0
  296. package/trash/scss-old-230729/components/README.todos +15 -0
  297. package/trash/scss-old-230729/components/_button.scss +95 -0
  298. package/trash/scss-old-230729/components/_index.scss +63 -0
  299. package/trash/scss-old-230729/components/_links.scss +34 -0
  300. package/trash/scss-old-230729/components/_list-lines.scss +73 -0
  301. package/trash/scss-old-230729/components/_list-ordered.scss +16 -0
  302. package/trash/scss-old-230729/components/_list-unordered.scss +21 -0
  303. package/trash/scss-old-230729/components/_rule.scss +93 -0
  304. package/trash/scss-old-230729/helpers/_color.scss +14 -0
  305. package/trash/scss-old-230729/helpers/_display.scss +73 -0
  306. package/trash/scss-old-230729/helpers/_index.scss +67 -0
  307. package/trash/scss-old-230729/helpers/_print.scss +58 -0
  308. package/trash/scss-old-230729/helpers/_typography.scss +72 -0
  309. package/trash/scss-old-230729/helpers/_units.scss +68 -0
  310. package/trash/scss-old-230729/helpers/_utilities.scss +87 -0
  311. package/trash/scss-old-230729/packages/README.md +3 -0
  312. package/trash/scss-old-230729/packages/everything.scss +17 -0
  313. package/trash/vue/directives/background-image-url.js +12 -0
  314. package/trash/vue/helpers/add-required-components.js +14 -0
  315. package/trash/vue/ui/CollapsibleRegion/CollapsibleRegion.vue +277 -0
  316. package/trash/vue/ui/CollapsibleRegion/Demo.vue +101 -0
  317. package/trash/vue/ui/Dropdown/Dropdown.vue +184 -0
  318. package/trash/vue/ui/Modals/components/Modal.vue +49 -0
  319. package/trash/vue/ui/Modals/components/Modals.vue +103 -0
  320. package/trash/vue/ui/Modals/plugin.js +215 -0
  321. package/trash/vue/ui/Modals/readme.note +10 -0
  322. package/trash/vue/ui/Modals/reference/example-usage.vue +27 -0
  323. package/trash/vue/ui/Modals/reference/wcag-example/dialog.js +324 -0
@@ -0,0 +1,42 @@
1
+ import { debounce } from "../utils/performance";
2
+
3
+ /**
4
+ * Event object - called on dispatch
5
+ */
6
+ const events = {
7
+ pageModified(context) {
8
+ context.dispatchEvent(new Event(getName("pageModified"), { bubbles: true }));
9
+ },
10
+ pageResized(context) {
11
+ context.dispatchEvent(new Event(getName("pageResized"), { bubbles: true }));
12
+ }
13
+ }
14
+
15
+ // Add global document events
16
+ window.addEventListener('resize', debounce(() => dispatch("pageResized", document), 250));
17
+
18
+ /**
19
+ * Triggers one of our custom events
20
+ * @param {String} type Type of event to dispatch
21
+ * @param {Node} context Element to trigger the event from
22
+ * @example
23
+ * if (updatedMarkup) {
24
+ * dispatch("pageModified", modalElement);
25
+ * }
26
+ */
27
+ export function dispatch(type, context) {
28
+ if (events[type]) {
29
+ events[type](context);
30
+ } else {
31
+ console.warn(`Unable to dispatch site event: ${ type } in context:`, context);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Handles the actual event names being used (future could namespace)
37
+ * @param {String} type Type of event to get the actual event name for
38
+ * @returns {String}
39
+ */
40
+ export function getName(type) {
41
+ return "ulu:" + type;
42
+ }
@@ -0,0 +1,247 @@
1
+ // =============================================================================
2
+ // Grabs Breakpoint from CSS
3
+ // =============================================================================
4
+
5
+ // Version: 1.0.6
6
+
7
+ // Description: Pass breakpoints from CSS to stylesheet, use this to attach
8
+ // behaviors on breakpoints
9
+
10
+ import { debounce } from "../utils/performance";
11
+ import { getName } from "../events/index.js";
12
+ import { removeArrayElement } from "../utils/array";
13
+ import { log, logError } from "../utils/logger.js";
14
+
15
+ /**
16
+ * Resize Handler to update breakpoints for all instances (Called after resize finished)
17
+ */
18
+ window.addEventListener(getName("pageResized"), () => {
19
+ CssBreakpoints.instances.forEach(i => i.update());
20
+ });
21
+
22
+ /**
23
+ * Class that provides method for retrieving and acting on breakpoints passed
24
+ * from CSS (using element psuedo content prop)
25
+ */
26
+ export class CssBreakpoints {
27
+ static instances = [];
28
+ static defaults = {
29
+ element: document.body,
30
+ psuedoSelector: ':before',
31
+ debug: false
32
+ }
33
+ /**
34
+ * @param {Object} config Configruation object
35
+ * @param {Array} config.order Required, Array of strings that correspond to the breakpoints setup in the styles, Breakpoints from smallest to largest
36
+ * @param {Node} config.element The element to retrieve active breakpoint from stylesheet (default is body)
37
+ * @param {String} config.psuedoSelector Change psuedo selector used to get the breakpoint from the psuedo's content property
38
+ */
39
+ constructor(config) {
40
+ if (!config.order) {
41
+ logError(this, 'Missing order (required)!');
42
+ }
43
+ Object.assign(this, CssBreakpoints.defaults, config);
44
+ this.active = null;
45
+ this.previous = null;
46
+ this.activeIndex = null;
47
+ this.resizeDirection = null;
48
+ this.previousIndex = null;
49
+ this.breakpoints = {};
50
+ this.order.forEach(n => this.breakpoints[n] = new Breakpoint(n, this));
51
+ log(this, this);
52
+ this.update(); // Run for the first time, then whenever browser resizes
53
+ CssBreakpoints.instances.push(this);
54
+ }
55
+ /**
56
+ * Get breakpoint from element (design note: user could override prototype)
57
+ */
58
+ getBreakpoint() {
59
+ return window.getComputedStyle(this.element, this.psuedoSelector).content.replace(/^"|"$/g, '');
60
+ }
61
+ /**
62
+ * Updates the active breakpoint by checking the element and executes handlers on change
63
+ */
64
+ update() {
65
+ const name = this.getBreakpoint();
66
+ // console.log('name:\n', name);
67
+ if (name === this.active) return;
68
+ // this.log(`current breakpoint: ${ name }`);
69
+ // Update active and cache last
70
+ this.previous = this.active;
71
+ this.previousIndex = this.activeIndex;
72
+
73
+ const index = this.order.indexOf(name);
74
+ this.active = name;
75
+ this.activeIndex = index;
76
+ const activeBreakpoint = this.at(this.active);
77
+ // Get arrays of breakpoints based on the order array
78
+ const mapBreakpoints = n => this.at(n);
79
+ // From breakpoint to end (highest)
80
+ const max = this.order.slice(index).map(mapBreakpoints);
81
+ const notMax = this.order.slice(0, index).map(mapBreakpoints);
82
+ // From start up to this breakpoint
83
+ const min = this.order.slice(0, index + 1).map(mapBreakpoints);
84
+ const notMin = this.order.slice(index + 1).map(mapBreakpoints);
85
+ const notOnly = this.order.slice().map(mapBreakpoints);
86
+ notOnly.splice(index, 1);
87
+
88
+ log(this, 'max:', max.map(b => b.name).join());
89
+ log(this, 'min:', min.map(b => b.name).join());
90
+
91
+ max.forEach(b => b._setDirection('max', true));
92
+ min.forEach(b => b._setDirection('min', true));
93
+ activeBreakpoint._setDirection('only', true);
94
+
95
+ notMax.forEach(b => b._setDirection('max', false));
96
+ notMin.forEach(b => b._setDirection('min', false));
97
+ notOnly.forEach(b => b._setDirection('only', false));
98
+
99
+ // Set direction (extra info if needed)
100
+ if (this.previousIndex !== null) {
101
+ this.resizeDirection = this.previousIndex < index ? "up" : "down";
102
+ }
103
+ }
104
+ /**
105
+ * Get a breakpoint by key
106
+ * @param {String} name The name of the breakpoint to get
107
+ */
108
+ at(name) {
109
+ const bp = this.breakpoints[name];
110
+ if (!name) {
111
+ logError(this, 'Unable to find breakpoint for:', bp);
112
+ }
113
+ return bp;
114
+ }
115
+ }
116
+ /**
117
+ * Used to handle a breakpoints direction's handler and state
118
+ */
119
+ class BreakpointDirection {
120
+ constructor(direction, breakpoint) {
121
+ this.direction = direction; // String name (logging)
122
+ this.active = false;
123
+ this.on = [];
124
+ this.off = []; // Triggered when direction has been set to active and then set to inactive (not on initial inactive)
125
+ this.breakpoint = breakpoint; // Reference to parent
126
+ }
127
+ /**
128
+ * Change the state of the direction
129
+ */
130
+ change(to) {
131
+ if (this.active !== to) {
132
+ if (to) this._call(true);
133
+ else if (this.active) this._call(false); // Going from active to inactive
134
+ this.active = to;
135
+ }
136
+ }
137
+ /**
138
+ * Calls all functions in handlers or
139
+ */
140
+ _call(forActive) {
141
+ const handlers = forActive ? this.on : this.off;
142
+ handlers.forEach(handler => handler());
143
+ log(this.breakpoint._manager, `Handlers called (${ forActive ? 'on' : 'off' }): ${ this.direction }`);
144
+ }
145
+ /**
146
+ * Returns handlers in normalized object format on/off
147
+ */
148
+ getHandlers(handler) {
149
+ return typeof handler !== "object" ? { on: handler } : handler;
150
+ }
151
+ /**
152
+ * Adds a handler for the direction, optionally use object to add off state handler
153
+ * @param {Function|Object} handler Function to be executed when direction is active, read object description for on/off
154
+ * @param {Function|Object} handler.on Function to be executed when direction is active
155
+ * @param {Function|Object} handler.off Function to be executed when direction was active and is now changed to inactive
156
+ */
157
+ add(handler) {
158
+ const handlers = this.getHandlers(handler);
159
+ if (handlers.on) {
160
+ this.on.push(handlers.on);
161
+ }
162
+ if (handlers.off) {
163
+ this.off.push(handlers.off);
164
+ }
165
+ // Already active when handler was added, fire now
166
+ if (this.active && handlers.on) {
167
+ handlers.on();
168
+ log(this.breakpoint._manager, `Handler called immediately: ${ this.direction }`, handlers.on);
169
+ }
170
+ }
171
+ /**
172
+ * Removes a handler
173
+ */
174
+ remove(handler) {
175
+ const handlers = this.getHandlers(handler);
176
+ if (handlers.on) {
177
+ removeArrayElement(this.on, handlers.on);
178
+ }
179
+ if (handlers.off) {
180
+ removeArrayElement(this.off, handlers.off);
181
+ }
182
+ }
183
+ }
184
+ /**
185
+ * Single breakpoint management
186
+ */
187
+ class Breakpoint {
188
+ constructor(name, manager) {
189
+ this.directions = {
190
+ max: new BreakpointDirection('max', this),
191
+ min: new BreakpointDirection('min', this),
192
+ only: new BreakpointDirection('only', this)
193
+ };
194
+ this._manager = manager; // Ref to parent class
195
+ this.name = name;
196
+ }
197
+ /**
198
+ * Private method used inrternally for managing direction activation
199
+ * - Each direction manages it's own state and handlers
200
+ * @param {String} direction The directional key
201
+ * @param {Boolean} active State of that direction to set
202
+ */
203
+ _setDirection(direction, active) {
204
+ this.directions[direction].change(active);
205
+ }
206
+ /**
207
+ * Attach handler to be executed from the breakpoint and to all breakpoints below.
208
+ * - If the browser resizes from a breakpoint below this breakpoint,
209
+ * and above the breakpoint name specified, this handler will fire
210
+ * @param {Function} handler Handler to be executed
211
+ */
212
+ max(handler) {
213
+ this.directions.max.add(handler);
214
+ }
215
+ /**
216
+ * Attach handler to be executed from the breakpoint and to all breakpoints below.
217
+ * - If the browser resizes from a breakpoint above this breakpoint,
218
+ * and below the breakpoint name specified, this handler will fire
219
+ * @param {Function} handler Handler to be executed
220
+ */
221
+ min(handler) {
222
+ this.directions.min.add(handler);
223
+ }
224
+ /**
225
+ * Attach a handler to fire when the breakpoint is within the key
226
+ * @param {Function} handler Handler to be executed
227
+ */
228
+ only(handler) {
229
+ this.directions.only.add(handler);
230
+ }
231
+ /**
232
+ * Remove handler
233
+ * @param {Function} handler Handler to be removed, extended on/off object style can be used
234
+ * @param {String} direction Remove handler only from specified direction, else search all directions
235
+ */
236
+ remove(handler, direction) {
237
+ const directions = direction ? [ direction ] : ['max', 'min', 'only'];
238
+ directions.forEach(d => d.remove(handler));
239
+ }
240
+
241
+ log(...msg) {
242
+ msg.unshift(`Breakpoint (${ this.name }):`);
243
+ this._manager.log.apply(this._manager, msg);
244
+ }
245
+ }
246
+
247
+ export default CssBreakpoints;
@@ -0,0 +1,48 @@
1
+ // Description: Simple script that is useful for testing. It will:
2
+ // - Make a file
3
+ // - Create a URL to it
4
+ // - Gives utility function to create a link to the file (for front end)
5
+ // - Gives method to destroy the file when no longer needed
6
+ // - User can redefine the program by passing options object matching props.
7
+
8
+ // Dependencies: No
9
+
10
+ // Support: Limited to knew browsers that support Blob(), also user preferences or
11
+ // type of browser may limit access to Blob functionality
12
+
13
+ // Related Docs:
14
+ // - https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob
15
+ // - https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
16
+ // - https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
17
+
18
+
19
+ class FileSave {
20
+ constructor(data, options) {
21
+ this.filename = "filesave-file.txt";
22
+ this.type = "text/plain;charset=utf-8";
23
+ // Allow user to override above
24
+ if (options) Object.assign(this, options);
25
+ this.data = data;
26
+ this.blob = new Blob([data], { type: this.type });
27
+ this.url = URL.createObjectURL(this.blob);
28
+ }
29
+ destroy() {
30
+ return URL.revokeObjectURL(this.url);
31
+ }
32
+ getUrl() {
33
+ return this.url;
34
+ }
35
+ createLink(text) {
36
+ var link = d.createElement('a');
37
+ text = d.createTextNode(text);
38
+ link.setAttribute('download', this.filename);
39
+ link.setAttribute('href', this.url);
40
+ link.appendChild(text);
41
+ return link;
42
+ }
43
+ static isBrowserSupported() {
44
+ return "FileReader" in window;
45
+ }
46
+ }
47
+
48
+ export default FileSave;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Class that provides a method to store data based on node/element
3
+ */
4
+ export default class NodeDataManager {
5
+ constructor() {
6
+ this.store = [];
7
+ }
8
+ /**
9
+ * Get data for an element/node
10
+ * @param {Node} node Html Node/Element to get data for
11
+ * @param {String|Boolean} key If key is passed, return that key's data for the element, if falsey return elements complete dataset
12
+ */
13
+ get(node, key = false) {
14
+ const nodeData = this.find(node);
15
+ if (nodeData) {
16
+ return nodeData.get(key);
17
+ }
18
+ }
19
+ /**
20
+ * Bind data to a specific Node/Element
21
+ * @param {Node} node Html Node/Element to get data for
22
+ * @param {String} key Key to save the data under
23
+ * @param {*} value Value to save
24
+ */
25
+ set(node, key, value) {
26
+ const nodeData = this.find(node);
27
+ if (nodeData) {
28
+ nodeData.set(key, value);
29
+ } else {
30
+ this.store.push(new NodeDataStore(node, { [key] : value }));
31
+ }
32
+ }
33
+ /**
34
+ * Return an elements store object
35
+ */
36
+ find(node) {
37
+ return this.store.find(nd => nd.isNode(node));
38
+ }
39
+ /**
40
+ * Destroy all references to data and nodes/elements
41
+ */
42
+ destroy() {
43
+ this.store.forEach(nd => nd.destroy());
44
+ this.store = [];
45
+ }
46
+ }
47
+ /**
48
+ * Child class that provides a store for one specific node/element
49
+ */
50
+ export class NodeDataStore {
51
+ constructor(node, data) {
52
+ this.node = node;
53
+ this.data = data || {}; // Lookup
54
+ }
55
+ set(key, value) {
56
+ this.data[key] = value;
57
+ }
58
+ get(key = false) {
59
+ return key ? this.data[key] : this.data;
60
+ }
61
+ remove(key) {
62
+ delete this.data[key];
63
+ }
64
+ isNode(node) {
65
+ return this.node.isSameNode(node);
66
+ }
67
+ clearData() {
68
+ this.data = {};
69
+ }
70
+ destroy() {
71
+ this.clearData();
72
+ this.node = null;
73
+ }
74
+ }
@@ -0,0 +1,42 @@
1
+ // Version: 1.0.4
2
+ // Description: Pauses youtube using js api (iframe post message)
3
+
4
+ const selectors = [
5
+ '.youtube-embedded-video',
6
+ 'iframe[title*="YouTube video player"]',
7
+ 'iframe[src*="youtube.com/embed"]'
8
+ ];
9
+ /**
10
+ * Somewhat hacky way to pause the video
11
+ * - https://www.digitalredpanther.com/blog/play-pause-stop-youtube-embed
12
+ * - Actual JS API documentation (Didn't follow this for now) (https://developers.google.com/youtube/iframe_api_reference)
13
+ * @param {Element|Node} context The DOM element to search for and pause videos within
14
+ */
15
+ export function pauseVideos(context = document) {
16
+ const videos = getVideos(context);
17
+ videos.forEach(video => {
18
+ try {
19
+ video.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*');
20
+ } catch (error) {
21
+ console.error(error);
22
+ }
23
+ });
24
+ }
25
+ /**
26
+ * Prep videos to be paused
27
+ * - Add query parameters for js API
28
+ * - Removes all other query parameters from iframe.src
29
+ */
30
+ export function prepVideos(context = document) {
31
+ const videos = getVideos(context);
32
+ videos.forEach(video => {
33
+ const { src } = video;
34
+ if (src) {
35
+ video.src = src.split("?")[0] + "?rel=0&enablejsapi=1";
36
+ }
37
+ })
38
+ }
39
+
40
+ function getVideos(context) {
41
+ return context.querySelectorAll(selectors.join(", "));
42
+ }
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * Sets a CSS custom property equal to the scrollbar width
4
+ * @param {Node} element The element that is the child of a scrollabel container
5
+ * @param {Node} container The container that can be scrolled
6
+ */
7
+ export default function addScrollbarProperty(element = document.body, container = window) {
8
+ const scrollbarWidth = container.innerWidth - element.clientWidth;
9
+ element.style.setProperty("--scrollbar-width", `${ scrollbarWidth }px`);
10
+ }
package/js/index.js ADDED
@@ -0,0 +1,15 @@
1
+ // =============================================================================
2
+ // Main Library Import
3
+ // =============================================================================
4
+
5
+ // Used for:
6
+ // - Allow users to access commonly needed items with at one point/file
7
+ // - Could allow changing of the ulu/js file structure if needed
8
+ // - Will not include things that aren't used in every site (those would need to
9
+ // imported manually
10
+
11
+ import "./polyfills/element-closest.js";
12
+
13
+ export { CssBreakpoints } from "./helpers/css-breakpoint.js";
14
+ export * as events from "./events/index.js";
15
+ export * as grid from "./ui/grid.js";
@@ -0,0 +1,17 @@
1
+ if (!Element.prototype.matches) {
2
+ Element.prototype.matches =
3
+ Element.prototype.msMatchesSelector ||
4
+ Element.prototype.webkitMatchesSelector;
5
+ }
6
+
7
+ if (!Element.prototype.closest) {
8
+ Element.prototype.closest = function(s) {
9
+ var el = this;
10
+
11
+ do {
12
+ if (Element.prototype.matches.call(el, s)) return el;
13
+ el = el.parentElement || el.parentNode;
14
+ } while (el !== null && el.nodeType === 1);
15
+ return null;
16
+ };
17
+ }