@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.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/ulu-frontend.min.css +1 -0
- package/dist/ulu-frontend.min.js +1 -0
- package/index.js +2 -0
- package/js/deprecated/doc-ready.js +28 -0
- package/js/deprecated/jquery-prototypes.js +309 -0
- package/js/deprecated/mini-collapsible-popper-positioning.js +126 -0
- package/js/deprecated/mini-collapsible.js +607 -0
- package/js/deprecated/script-loader.js +60 -0
- package/js/events/index.js +42 -0
- package/js/helpers/css-breakpoint.js +247 -0
- package/js/helpers/file-save.js +48 -0
- package/js/helpers/node-data-manager.js +74 -0
- package/js/helpers/pause-youtube-video.js +42 -0
- package/js/helpers/scrollbar-width-property.js +10 -0
- package/js/index.js +15 -0
- package/js/polyfills/element-closest.js +17 -0
- package/js/ui/flipcard.js +202 -0
- package/js/ui/grid.js +67 -0
- package/js/ui/modals.js +219 -0
- package/js/ui/overflow-scroller-pager.js +58 -0
- package/js/ui/overflow-scroller.js +160 -0
- package/js/ui/programmatic-modal.js +91 -0
- package/js/ui/resizer.js +60 -0
- package/js/ui/slider.js +468 -0
- package/js/ui/tabs.js +109 -0
- package/js/ui/tooltip.js +82 -0
- package/js/utils/array.js +28 -0
- package/js/utils/dom.js +122 -0
- package/js/utils/logger.js +69 -0
- package/js/utils/object.js +22 -0
- package/js/utils/performance.js +43 -0
- package/js/utils/regex.js +10 -0
- package/js/utils/string.js +107 -0
- package/js/waypoints/README.md +3 -0
- package/js/waypoints/anchor-menu.js +76 -0
- package/js/waypoints/element-waypoint.js +75 -0
- package/js/waypoints/examples/page-link-menu.md +106 -0
- package/js/waypoints/state-in-attribute.js +32 -0
- package/package.json +38 -0
- package/scss/README.md +58 -0
- package/scss/_breakpoint.scss +190 -0
- package/scss/_button.scss +241 -0
- package/scss/_calculate.scss +64 -0
- package/scss/_color.scss +211 -0
- package/scss/_cssvar.scss +116 -0
- package/scss/_element.scss +276 -0
- package/scss/_grid.scss +699 -0
- package/scss/_index.scss +29 -0
- package/scss/_layout.scss +202 -0
- package/scss/_path.scss +58 -0
- package/scss/_selector.scss +81 -0
- package/scss/_typography.scss +320 -0
- package/scss/_units.scss +47 -0
- package/scss/_utility.scss +12 -0
- package/scss/_utils.scss +209 -0
- package/scss/base/_color.scss +13 -0
- package/scss/base/_elements.scss +188 -0
- package/scss/base/_index.scss +62 -0
- package/scss/base/_keyframes.scss +78 -0
- package/scss/base/_layout.scss +100 -0
- package/scss/base/_normalize.scss +315 -0
- package/scss/base/_typography.scss +41 -0
- package/scss/components/README.md +5 -0
- package/scss/components/README.todos +15 -0
- package/scss/components/_button.scss +95 -0
- package/scss/components/_index.scss +63 -0
- package/scss/components/_links.scss +34 -0
- package/scss/components/_list-lines.scss +73 -0
- package/scss/components/_list-ordered.scss +16 -0
- package/scss/components/_list-unordered.scss +21 -0
- package/scss/components/_rule.scss +93 -0
- package/scss/helpers/_color.scss +14 -0
- package/scss/helpers/_display.scss +73 -0
- package/scss/helpers/_index.scss +67 -0
- package/scss/helpers/_print.scss +58 -0
- package/scss/helpers/_typography.scss +80 -0
- package/scss/helpers/_units.scss +79 -0
- package/scss/helpers/_utilities.scss +102 -0
- package/scss/stylesheets/README.md +3 -0
- package/scss/stylesheets/full.scss +17 -0
- package/trash/js-old/deprecated/doc-ready.js +28 -0
- package/trash/js-old/deprecated/jquery-prototypes.js +309 -0
- package/trash/js-old/deprecated/mini-collapsible-popper-positioning.js +126 -0
- package/trash/js-old/deprecated/mini-collapsible.js +607 -0
- package/trash/js-old/deprecated/script-loader.js +60 -0
- package/trash/js-old/events/index.js +42 -0
- package/trash/js-old/helpers/css-breakpoint.js +247 -0
- package/trash/js-old/helpers/file-save.js +48 -0
- package/trash/js-old/helpers/node-data-manager.js +74 -0
- package/trash/js-old/helpers/pause-youtube-video.js +42 -0
- package/trash/js-old/index.js +15 -0
- package/trash/js-old/polyfills/element-closest.js +17 -0
- package/trash/js-old/ui/flipcard.js +202 -0
- package/trash/js-old/ui/grid.js +67 -0
- package/trash/js-old/ui/modals.js +219 -0
- package/trash/js-old/ui/programmatic-modal.js +91 -0
- package/trash/js-old/ui/resizer.js +60 -0
- package/trash/js-old/ui/slider.js +469 -0
- package/trash/js-old/ui/tabs.js +109 -0
- package/trash/js-old/ui/tooltip.js +82 -0
- package/trash/js-old/utils/array.js +28 -0
- package/trash/js-old/utils/dom.js +122 -0
- package/trash/js-old/utils/logger.js +69 -0
- package/trash/js-old/utils/object.js +22 -0
- package/trash/js-old/utils/performance.js +43 -0
- package/trash/js-old/utils/regex.js +10 -0
- package/trash/js-old/utils/string.js +107 -0
- package/trash/js-old/waypoints/README.md +3 -0
- package/trash/js-old/waypoints/anchor-menu.js +76 -0
- package/trash/js-old/waypoints/element-waypoint.js +75 -0
- package/trash/js-old/waypoints/examples/page-link-menu.md +106 -0
- package/trash/js-old/waypoints/state-in-attribute.js +32 -0
- package/trash/js-old-230729/deprecated/doc-ready.js +28 -0
- package/trash/js-old-230729/deprecated/jquery-prototypes.js +309 -0
- package/trash/js-old-230729/deprecated/mini-collapsible-popper-positioning.js +126 -0
- package/trash/js-old-230729/deprecated/mini-collapsible.js +607 -0
- package/trash/js-old-230729/deprecated/script-loader.js +60 -0
- package/trash/js-old-230729/events/index.js +42 -0
- package/trash/js-old-230729/helpers/css-breakpoint.js +247 -0
- package/trash/js-old-230729/helpers/file-save.js +48 -0
- package/trash/js-old-230729/helpers/node-data-manager.js +74 -0
- package/trash/js-old-230729/helpers/pause-youtube-video.js +42 -0
- package/trash/js-old-230729/helpers/scrollbar-width-property.js +10 -0
- package/trash/js-old-230729/index.js +15 -0
- package/trash/js-old-230729/polyfills/element-closest.js +17 -0
- package/trash/js-old-230729/ui/flipcard.js +202 -0
- package/trash/js-old-230729/ui/grid.js +67 -0
- package/trash/js-old-230729/ui/modals.js +219 -0
- package/trash/js-old-230729/ui/overflow-scroller-pager.js +58 -0
- package/trash/js-old-230729/ui/overflow-scroller.js +160 -0
- package/trash/js-old-230729/ui/programmatic-modal.js +91 -0
- package/trash/js-old-230729/ui/resizer.js +60 -0
- package/trash/js-old-230729/ui/slider.js +468 -0
- package/trash/js-old-230729/ui/tabs.js +109 -0
- package/trash/js-old-230729/ui/tooltip.js +82 -0
- package/trash/js-old-230729/utils/array.js +28 -0
- package/trash/js-old-230729/utils/dom.js +122 -0
- package/trash/js-old-230729/utils/logger.js +69 -0
- package/trash/js-old-230729/utils/object.js +22 -0
- package/trash/js-old-230729/utils/performance.js +43 -0
- package/trash/js-old-230729/utils/regex.js +10 -0
- package/trash/js-old-230729/utils/string.js +107 -0
- package/trash/js-old-230729/waypoints/README.md +3 -0
- package/trash/js-old-230729/waypoints/anchor-menu.js +76 -0
- package/trash/js-old-230729/waypoints/element-waypoint.js +75 -0
- package/trash/js-old-230729/waypoints/examples/page-link-menu.md +106 -0
- package/trash/js-old-230729/waypoints/state-in-attribute.js +32 -0
- package/trash/logo-1.svg +13 -0
- package/trash/logo.svg +16 -0
- package/trash/scss-before-cqc-update/README.md +58 -0
- package/trash/scss-before-cqc-update/_breakpoint.scss +190 -0
- package/trash/scss-before-cqc-update/_button.scss +229 -0
- package/trash/scss-before-cqc-update/_calculate.scss +65 -0
- package/trash/scss-before-cqc-update/_color.scss +211 -0
- package/trash/scss-before-cqc-update/_cssvar.scss +116 -0
- package/trash/scss-before-cqc-update/_element.scss +275 -0
- package/trash/scss-before-cqc-update/_index.scss +29 -0
- package/trash/scss-before-cqc-update/_layout.scss +247 -0
- package/trash/scss-before-cqc-update/_path.scss +59 -0
- package/trash/scss-before-cqc-update/_selector.scss +82 -0
- package/trash/scss-before-cqc-update/_typography.scss +322 -0
- package/trash/scss-before-cqc-update/_units.scss +48 -0
- package/trash/scss-before-cqc-update/_utility.scss +13 -0
- package/trash/scss-before-cqc-update/_utils.scss +211 -0
- package/trash/scss-before-cqc-update/base/_color.scss +14 -0
- package/trash/scss-before-cqc-update/base/_elements.scss +189 -0
- package/trash/scss-before-cqc-update/base/_index.scss +63 -0
- package/trash/scss-before-cqc-update/base/_keyframes.scss +74 -0
- package/trash/scss-before-cqc-update/base/_layout.scss +88 -0
- package/trash/scss-before-cqc-update/base/_normalize.scss +316 -0
- package/trash/scss-before-cqc-update/base/_typography.scss +42 -0
- package/trash/scss-before-cqc-update/components/README.md +5 -0
- package/trash/scss-before-cqc-update/components/README.todos +15 -0
- package/trash/scss-before-cqc-update/components/_button.scss +96 -0
- package/trash/scss-before-cqc-update/components/_grid.scss +671 -0
- package/trash/scss-before-cqc-update/components/_index.scss +70 -0
- package/trash/scss-before-cqc-update/components/_links.scss +35 -0
- package/trash/scss-before-cqc-update/components/_list-lines.scss +74 -0
- package/trash/scss-before-cqc-update/components/_list-ordered.scss +17 -0
- package/trash/scss-before-cqc-update/components/_list-unordered.scss +22 -0
- package/trash/scss-before-cqc-update/components/_rule.scss +94 -0
- package/trash/scss-before-cqc-update/helpers/_color.scss +15 -0
- package/trash/scss-before-cqc-update/helpers/_display.scss +73 -0
- package/trash/scss-before-cqc-update/helpers/_index.scss +68 -0
- package/trash/scss-before-cqc-update/helpers/_print.scss +59 -0
- package/trash/scss-before-cqc-update/helpers/_typography.scss +73 -0
- package/trash/scss-before-cqc-update/helpers/_units.scss +79 -0
- package/trash/scss-before-cqc-update/helpers/_utilities.scss +88 -0
- package/trash/scss-before-cqc-update/stylesheets/README.md +3 -0
- package/trash/scss-before-cqc-update/stylesheets/full.scss +17 -0
- package/trash/scss-old/README.md +58 -0
- package/trash/scss-old/_breakpoint.scss +140 -0
- package/trash/scss-old/_button.scss +223 -0
- package/trash/scss-old/_calculate.scss +64 -0
- package/trash/scss-old/_color.scss +200 -0
- package/trash/scss-old/_element.scss +262 -0
- package/trash/scss-old/_grid.scss +558 -0
- package/trash/scss-old/_index.scss +25 -0
- package/trash/scss-old/_layout.scss +170 -0
- package/trash/scss-old/_path.scss +58 -0
- package/trash/scss-old/_selector.scss +81 -0
- package/trash/scss-old/_typography.scss +320 -0
- package/trash/scss-old/_units.scss +47 -0
- package/trash/scss-old/_utility.scss +12 -0
- package/trash/scss-old/_utils.scss +186 -0
- package/trash/scss-old/base/_color.scss +13 -0
- package/trash/scss-old/base/_elements.scss +183 -0
- package/trash/scss-old/base/_index.scss +62 -0
- package/trash/scss-old/base/_keyframes.scss +74 -0
- package/trash/scss-old/base/_layout.scss +81 -0
- package/trash/scss-old/base/_normalize.scss +316 -0
- package/trash/scss-old/base/_typography.scss +42 -0
- package/trash/scss-old/components/README.md +5 -0
- package/trash/scss-old/components/README.todos +15 -0
- package/trash/scss-old/components/_button.scss +74 -0
- package/trash/scss-old/components/_index.scss +63 -0
- package/trash/scss-old/components/_links.scss +34 -0
- package/trash/scss-old/components/_list-lines.scss +73 -0
- package/trash/scss-old/components/_list-ordered.scss +16 -0
- package/trash/scss-old/components/_list-unordered.scss +21 -0
- package/trash/scss-old/components/_rule.scss +84 -0
- package/trash/scss-old/helpers/_color.scss +14 -0
- package/trash/scss-old/helpers/_display.scss +68 -0
- package/trash/scss-old/helpers/_index.scss +67 -0
- package/trash/scss-old/helpers/_print.scss +59 -0
- package/trash/scss-old/helpers/_typography.scss +73 -0
- package/trash/scss-old/helpers/_units.scss +68 -0
- package/trash/scss-old/helpers/_utilities.scss +82 -0
- package/trash/scss-old/packages/README.md +3 -0
- package/trash/scss-old/packages/everything.scss +17 -0
- package/trash/scss-old-2/README.md +58 -0
- package/trash/scss-old-2/_breakpoint.scss +139 -0
- package/trash/scss-old-2/_button.scss +223 -0
- package/trash/scss-old-2/_calculate.scss +64 -0
- package/trash/scss-old-2/_color.scss +202 -0
- package/trash/scss-old-2/_element.scss +263 -0
- package/trash/scss-old-2/_grid.scss +558 -0
- package/trash/scss-old-2/_index.scss +25 -0
- package/trash/scss-old-2/_layout.scss +170 -0
- package/trash/scss-old-2/_path.scss +58 -0
- package/trash/scss-old-2/_selector.scss +81 -0
- package/trash/scss-old-2/_typography.scss +320 -0
- package/trash/scss-old-2/_units.scss +47 -0
- package/trash/scss-old-2/_utility.scss +12 -0
- package/trash/scss-old-2/_utils.scss +186 -0
- package/trash/scss-old-2/base/_color.scss +13 -0
- package/trash/scss-old-2/base/_elements.scss +182 -0
- package/trash/scss-old-2/base/_index.scss +62 -0
- package/trash/scss-old-2/base/_keyframes.scss +73 -0
- package/trash/scss-old-2/base/_layout.scss +83 -0
- package/trash/scss-old-2/base/_normalize.scss +315 -0
- package/trash/scss-old-2/base/_typography.scss +41 -0
- package/trash/scss-old-2/components/README.md +5 -0
- package/trash/scss-old-2/components/README.todos +15 -0
- package/trash/scss-old-2/components/_button.scss +95 -0
- package/trash/scss-old-2/components/_index.scss +63 -0
- package/trash/scss-old-2/components/_links.scss +33 -0
- package/trash/scss-old-2/components/_list-lines.scss +73 -0
- package/trash/scss-old-2/components/_list-ordered.scss +16 -0
- package/trash/scss-old-2/components/_list-unordered.scss +21 -0
- package/trash/scss-old-2/components/_rule.scss +84 -0
- package/trash/scss-old-2/helpers/_color.scss +14 -0
- package/trash/scss-old-2/helpers/_display.scss +67 -0
- package/trash/scss-old-2/helpers/_index.scss +67 -0
- package/trash/scss-old-2/helpers/_print.scss +58 -0
- package/trash/scss-old-2/helpers/_typography.scss +72 -0
- package/trash/scss-old-2/helpers/_units.scss +68 -0
- package/trash/scss-old-2/helpers/_utilities.scss +81 -0
- package/trash/scss-old-2/packages/README.md +3 -0
- package/trash/scss-old-2/packages/everything.scss +17 -0
- package/trash/scss-old-230729/README.md +58 -0
- package/trash/scss-old-230729/_breakpoint.scss +139 -0
- package/trash/scss-old-230729/_button.scss +223 -0
- package/trash/scss-old-230729/_calculate.scss +64 -0
- package/trash/scss-old-230729/_color.scss +202 -0
- package/trash/scss-old-230729/_element.scss +273 -0
- package/trash/scss-old-230729/_grid.scss +694 -0
- package/trash/scss-old-230729/_index.scss +25 -0
- package/trash/scss-old-230729/_layout.scss +193 -0
- package/trash/scss-old-230729/_path.scss +58 -0
- package/trash/scss-old-230729/_selector.scss +81 -0
- package/trash/scss-old-230729/_typography.scss +320 -0
- package/trash/scss-old-230729/_units.scss +47 -0
- package/trash/scss-old-230729/_utility.scss +12 -0
- package/trash/scss-old-230729/_utils.scss +186 -0
- package/trash/scss-old-230729/base/_color.scss +13 -0
- package/trash/scss-old-230729/base/_elements.scss +188 -0
- package/trash/scss-old-230729/base/_index.scss +62 -0
- package/trash/scss-old-230729/base/_keyframes.scss +73 -0
- package/trash/scss-old-230729/base/_layout.scss +83 -0
- package/trash/scss-old-230729/base/_normalize.scss +315 -0
- package/trash/scss-old-230729/base/_typography.scss +41 -0
- package/trash/scss-old-230729/components/README.md +5 -0
- package/trash/scss-old-230729/components/README.todos +15 -0
- package/trash/scss-old-230729/components/_button.scss +95 -0
- package/trash/scss-old-230729/components/_index.scss +63 -0
- package/trash/scss-old-230729/components/_links.scss +34 -0
- package/trash/scss-old-230729/components/_list-lines.scss +73 -0
- package/trash/scss-old-230729/components/_list-ordered.scss +16 -0
- package/trash/scss-old-230729/components/_list-unordered.scss +21 -0
- package/trash/scss-old-230729/components/_rule.scss +93 -0
- package/trash/scss-old-230729/helpers/_color.scss +14 -0
- package/trash/scss-old-230729/helpers/_display.scss +73 -0
- package/trash/scss-old-230729/helpers/_index.scss +67 -0
- package/trash/scss-old-230729/helpers/_print.scss +58 -0
- package/trash/scss-old-230729/helpers/_typography.scss +72 -0
- package/trash/scss-old-230729/helpers/_units.scss +68 -0
- package/trash/scss-old-230729/helpers/_utilities.scss +87 -0
- package/trash/scss-old-230729/packages/README.md +3 -0
- package/trash/scss-old-230729/packages/everything.scss +17 -0
- package/trash/vue/directives/background-image-url.js +12 -0
- package/trash/vue/helpers/add-required-components.js +14 -0
- package/trash/vue/ui/CollapsibleRegion/CollapsibleRegion.vue +277 -0
- package/trash/vue/ui/CollapsibleRegion/Demo.vue +101 -0
- package/trash/vue/ui/Dropdown/Dropdown.vue +184 -0
- package/trash/vue/ui/Modals/components/Modal.vue +49 -0
- package/trash/vue/ui/Modals/components/Modals.vue +103 -0
- package/trash/vue/ui/Modals/plugin.js +215 -0
- package/trash/vue/ui/Modals/readme.note +10 -0
- package/trash/vue/ui/Modals/reference/example-usage.vue +27 -0
- 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
|
+
}
|