@ulu/frontend 0.1.0-beta.33 → 0.1.0-beta.34
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/CHANGELOG.md +38 -17
- package/dist/ulu-frontend.min.css +1 -1
- package/dist/ulu-frontend.min.js +23 -23
- package/docs-dev/changelog/index.html +94 -10
- package/docs-dev/demos/accordion/index.html +30 -0
- package/docs-dev/demos/button/index.html +30 -0
- package/docs-dev/demos/button-verbose/index.html +30 -0
- package/docs-dev/demos/callout/index.html +39 -0
- package/docs-dev/demos/captioned-figure/index.html +30 -0
- package/docs-dev/demos/card/index.html +44 -14
- package/docs-dev/demos/card-grid/index.html +30 -0
- package/docs-dev/demos/css-icons/index.html +30 -0
- package/docs-dev/demos/data-grid/index.html +30 -0
- package/docs-dev/demos/data-table/index.html +55 -25
- package/docs-dev/demos/details-group/index.html +63 -0
- package/docs-dev/demos/file-save/index.html +30 -0
- package/docs-dev/demos/flipcard/index.html +30 -0
- package/docs-dev/demos/form-theme/index.html +30 -0
- package/docs-dev/demos/index.html +30 -0
- package/docs-dev/demos/list-inline/index.html +30 -0
- package/docs-dev/demos/list-lines/index.html +30 -0
- package/docs-dev/demos/menu-stack/index.html +30 -0
- package/docs-dev/demos/modals/index.html +43 -2
- package/docs-dev/demos/nav-strip/index.html +30 -0
- package/docs-dev/demos/overlay-section/index.html +30 -0
- package/docs-dev/demos/popovers/index.html +30 -0
- package/docs-dev/demos/print/index.html +30 -0
- package/docs-dev/demos/pull-quote/index.html +30 -0
- package/docs-dev/demos/rule/index.html +30 -0
- package/docs-dev/demos/scrollpoints/index.html +31 -1
- package/docs-dev/demos/spoke-spinner/index.html +30 -0
- package/docs-dev/demos/sticky-list/index.html +30 -0
- package/docs-dev/demos/tabs/index.html +66 -0
- package/docs-dev/demos/tag/index.html +30 -0
- package/docs-dev/demos/theme-toggle/index.html +30 -0
- package/docs-dev/demos/tiles/index.html +30 -0
- package/docs-dev/demos/tooltip/index.html +30 -0
- package/docs-dev/guide/building-stylesheet/index.html +30 -0
- package/docs-dev/guide/developing-ulu-scss-module/index.html +30 -0
- package/docs-dev/guide/index.html +30 -0
- package/docs-dev/index.html +30 -0
- package/docs-dev/javascript/events/index.html +30 -0
- package/docs-dev/javascript/index.html +30 -0
- package/docs-dev/javascript/settings/index.html +30 -0
- package/docs-dev/javascript/ui-breakpoints/index.html +30 -0
- package/docs-dev/javascript/ui-collapsible/index.html +30 -0
- package/docs-dev/javascript/ui-details-group/index.html +48 -30
- package/docs-dev/javascript/ui-dialog/index.html +62 -17
- package/docs-dev/javascript/ui-flipcard/index.html +91 -5
- package/docs-dev/javascript/ui-grid/index.html +40 -36
- package/docs-dev/javascript/ui-modal-builder/index.html +41 -32
- package/docs-dev/javascript/ui-overflow-scroller/index.html +30 -0
- package/docs-dev/javascript/ui-overflow-scroller-pager/index.html +30 -0
- package/docs-dev/javascript/ui-page/index.html +30 -0
- package/docs-dev/javascript/ui-popover/index.html +38 -12
- package/docs-dev/javascript/ui-print/index.html +30 -8
- package/docs-dev/javascript/ui-print-details/index.html +30 -0
- package/docs-dev/javascript/ui-programmatic-modal/index.html +30 -0
- package/docs-dev/javascript/ui-proxy-click/index.html +117 -2
- package/docs-dev/javascript/ui-resizer/index.html +30 -0
- package/docs-dev/javascript/ui-scroll-slider/index.html +68 -6
- package/docs-dev/javascript/ui-scrollpoint/index.html +36 -13
- package/docs-dev/javascript/ui-slider/index.html +226 -5
- package/docs-dev/javascript/ui-tabs/index.html +41 -48
- package/docs-dev/javascript/ui-theme-toggle/index.html +35 -13
- package/docs-dev/javascript/ui-tooltip/index.html +37 -11
- package/docs-dev/javascript/utils-class-logger/index.html +30 -0
- package/docs-dev/javascript/utils-dom/index.html +55 -0
- package/docs-dev/javascript/utils-file-save/index.html +30 -0
- package/docs-dev/javascript/utils-floating-ui/index.html +30 -0
- package/docs-dev/javascript/utils-id/index.html +30 -0
- package/docs-dev/javascript/utils-pause-youtube-video/index.html +30 -0
- package/docs-dev/javascript/utils-system/index.html +5437 -0
- package/docs-dev/sass/base/color/index.html +30 -0
- package/docs-dev/sass/base/elements/index.html +30 -0
- package/docs-dev/sass/base/index/index.html +30 -0
- package/docs-dev/sass/base/index.html +30 -0
- package/docs-dev/sass/base/keyframes/index.html +30 -0
- package/docs-dev/sass/base/layout/index.html +30 -0
- package/docs-dev/sass/base/normalize/index.html +30 -0
- package/docs-dev/sass/base/print/index.html +30 -0
- package/docs-dev/sass/base/root/index.html +30 -0
- package/docs-dev/sass/base/typography/index.html +30 -0
- package/docs-dev/sass/components/accordion/index.html +31 -1
- package/docs-dev/sass/components/adaptive-spacing/index.html +30 -0
- package/docs-dev/sass/components/badge/index.html +30 -0
- package/docs-dev/sass/components/basic-hero/index.html +30 -0
- package/docs-dev/sass/components/button/index.html +30 -0
- package/docs-dev/sass/components/button-verbose/index.html +30 -0
- package/docs-dev/sass/components/callout/index.html +30 -0
- package/docs-dev/sass/components/captioned-figure/index.html +30 -0
- package/docs-dev/sass/components/card/index.html +30 -0
- package/docs-dev/sass/components/card-grid/index.html +30 -0
- package/docs-dev/sass/components/css-icon/index.html +30 -0
- package/docs-dev/sass/components/data-grid/index.html +30 -0
- package/docs-dev/sass/components/data-table/index.html +45 -8
- package/docs-dev/sass/components/fill-context/index.html +30 -0
- package/docs-dev/sass/components/flipcard/index.html +30 -0
- package/docs-dev/sass/components/flipcard-grid/index.html +30 -0
- package/docs-dev/sass/components/form-theme/index.html +76 -52
- package/docs-dev/sass/components/hero/index.html +30 -0
- package/docs-dev/sass/components/horizontal-rule/index.html +30 -0
- package/docs-dev/sass/components/image-grid/index.html +30 -0
- package/docs-dev/sass/components/index/index.html +30 -0
- package/docs-dev/sass/components/index.html +30 -0
- package/docs-dev/sass/components/links/index.html +30 -0
- package/docs-dev/sass/components/list-inline/index.html +30 -0
- package/docs-dev/sass/components/list-lines/index.html +30 -0
- package/docs-dev/sass/components/list-ordered/index.html +30 -0
- package/docs-dev/sass/components/list-unordered/index.html +30 -0
- package/docs-dev/sass/components/menu-stack/index.html +30 -0
- package/docs-dev/sass/components/modal/index.html +30 -0
- package/docs-dev/sass/components/nav-strip/index.html +30 -0
- package/docs-dev/sass/components/overlay-section/index.html +30 -0
- package/docs-dev/sass/components/pager/index.html +30 -0
- package/docs-dev/sass/components/placeholder-block/index.html +30 -0
- package/docs-dev/sass/components/popover/index.html +30 -0
- package/docs-dev/sass/components/pull-quote/index.html +30 -0
- package/docs-dev/sass/components/ratio-box/index.html +30 -0
- package/docs-dev/sass/components/rule/index.html +30 -0
- package/docs-dev/sass/components/scroll-slider/index.html +38 -20
- package/docs-dev/sass/components/skip-link/index.html +30 -0
- package/docs-dev/sass/components/slider/index.html +30 -0
- package/docs-dev/sass/components/spoke-spinner/index.html +30 -0
- package/docs-dev/sass/components/sticky-list/index.html +30 -0
- package/docs-dev/sass/components/tabs/index.html +30 -0
- package/docs-dev/sass/components/tag/index.html +30 -0
- package/docs-dev/sass/components/tile-button/index.html +30 -0
- package/docs-dev/sass/components/tile-grid/index.html +30 -0
- package/docs-dev/sass/components/tile-grid-overlay/index.html +30 -0
- package/docs-dev/sass/components/vignette/index.html +30 -0
- package/docs-dev/sass/components/wysiwyg/index.html +30 -0
- package/docs-dev/sass/core/breakpoint/index.html +30 -0
- package/docs-dev/sass/core/button/index.html +30 -0
- package/docs-dev/sass/core/color/index.html +30 -0
- package/docs-dev/sass/core/cssvar/index.html +30 -0
- package/docs-dev/sass/core/element/index.html +30 -0
- package/docs-dev/sass/core/index.html +30 -0
- package/docs-dev/sass/core/layout/index.html +30 -0
- package/docs-dev/sass/core/path/index.html +30 -0
- package/docs-dev/sass/core/selector/index.html +30 -0
- package/docs-dev/sass/core/typography/index.html +30 -0
- package/docs-dev/sass/core/units/index.html +30 -0
- package/docs-dev/sass/core/utils/index.html +30 -0
- package/docs-dev/sass/helpers/color/index.html +30 -0
- package/docs-dev/sass/helpers/display/index.html +30 -0
- package/docs-dev/sass/helpers/index/index.html +30 -0
- package/docs-dev/sass/helpers/index.html +30 -0
- package/docs-dev/sass/helpers/print/index.html +30 -0
- package/docs-dev/sass/helpers/typography/index.html +30 -0
- package/docs-dev/sass/helpers/units/index.html +30 -0
- package/docs-dev/sass/helpers/utilities/index.html +30 -0
- package/docs-dev/sass/index.html +30 -0
- package/js/ui/breakpoints.js +1 -2
- package/js/ui/details-group.js +33 -42
- package/js/ui/dialog.js +64 -41
- package/js/ui/dialog.todo +2 -36
- package/js/ui/flipcard.js +37 -57
- package/js/ui/grid.js +15 -13
- package/js/ui/modal-builder.js +24 -38
- package/js/ui/popover.js +38 -39
- package/js/ui/print.js +16 -25
- package/js/ui/proxy-click.js +50 -36
- package/js/ui/scroll-slider.js +24 -30
- package/js/ui/scrollpoint.js +27 -63
- package/js/ui/slider.js +53 -55
- package/js/ui/tabs.js +23 -36
- package/js/ui/theme-toggle.js +37 -41
- package/js/ui/tooltip.js +27 -33
- package/js/utils/dom.js +12 -0
- package/js/utils/system.js +154 -0
- package/package.json +1 -1
- package/scss/components/_accordion.scss +1 -2
- package/scss/components/_data-table.scss +3 -0
- package/scss/components/_form-theme.scss +24 -25
- package/scss/components/_scroll-slider.scss +0 -4
- package/types/ui/breakpoints.d.ts.map +1 -1
- package/types/ui/details-group.d.ts +7 -12
- package/types/ui/details-group.d.ts.map +1 -1
- package/types/ui/dialog.d.ts +19 -14
- package/types/ui/dialog.d.ts.map +1 -1
- package/types/ui/flipcard.d.ts +16 -10
- package/types/ui/flipcard.d.ts.map +1 -1
- package/types/ui/grid.d.ts +4 -6
- package/types/ui/grid.d.ts.map +1 -1
- package/types/ui/modal-builder.d.ts +5 -9
- package/types/ui/modal-builder.d.ts.map +1 -1
- package/types/ui/popover.d.ts +6 -7
- package/types/ui/popover.d.ts.map +1 -1
- package/types/ui/print.d.ts +0 -4
- package/types/ui/print.d.ts.map +1 -1
- package/types/ui/proxy-click.d.ts +19 -3
- package/types/ui/proxy-click.d.ts.map +1 -1
- package/types/ui/scroll-slider.d.ts +5 -7
- package/types/ui/scroll-slider.d.ts.map +1 -1
- package/types/ui/scrollpoint.d.ts +3 -8
- package/types/ui/scrollpoint.d.ts.map +1 -1
- package/types/ui/slider.d.ts +22 -12
- package/types/ui/slider.d.ts.map +1 -1
- package/types/ui/tabs.d.ts +6 -8
- package/types/ui/tabs.d.ts.map +1 -1
- package/types/ui/theme-toggle.d.ts +6 -13
- package/types/ui/theme-toggle.d.ts.map +1 -1
- package/types/ui/tooltip.d.ts +3 -5
- package/types/ui/tooltip.d.ts.map +1 -1
- package/types/utils/dom.d.ts +6 -0
- package/types/utils/dom.d.ts.map +1 -1
- package/types/utils/system.d.ts +113 -0
- package/types/utils/system.d.ts.map +1 -0
package/js/ui/breakpoints.js
CHANGED
|
@@ -97,9 +97,8 @@ export class BreakpointManager {
|
|
|
97
97
|
logError(this, 'Unable to get current breakpoint, maybe order is incorrect? Breakpoint check skipped!');
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
// console.log('name:\n', name);
|
|
101
100
|
if (name === this.active) return;
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
// Update active and cache last
|
|
104
103
|
this.previous = this.active;
|
|
105
104
|
this.previousIndex = this.activeIndex;
|
package/js/ui/details-group.js
CHANGED
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
* @description Manages groups of details (ie. onlyOneOpen at a time)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { getDatasetOptionalJson } from "../utils/dom.js";
|
|
6
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const attrSelector = key => `[${ attrs[key] }]`;
|
|
17
|
-
const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
|
|
8
|
+
/**
|
|
9
|
+
* Dialog Component Initializer
|
|
10
|
+
*/
|
|
11
|
+
export const initializer = new ComponentInitializer({
|
|
12
|
+
type: "details-group",
|
|
13
|
+
baseAttribute: "data-ulu-details-group"
|
|
14
|
+
});
|
|
18
15
|
|
|
19
|
-
const
|
|
16
|
+
const childInitAttr = initializer.getAttribute("child-init");
|
|
17
|
+
const defaults = {
|
|
20
18
|
onlyOneOpen: true,
|
|
21
19
|
childSelector: ":scope > details"
|
|
22
20
|
};
|
|
@@ -26,24 +24,14 @@ const defaults = {
|
|
|
26
24
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
27
25
|
*/
|
|
28
26
|
export function init() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
export function setup(context = document) {
|
|
39
|
-
// Added try because we are using querySelectorAll with :scope by default
|
|
40
|
-
// which will not work in Internet Explorer or early edge (some alt. browsers too)
|
|
41
|
-
try {
|
|
42
|
-
const elements = context.querySelectorAll(attrSelectorInitial("group"));
|
|
43
|
-
return [...elements].map(setupGroup);
|
|
44
|
-
} catch(error) {
|
|
45
|
-
console.error(error);
|
|
46
|
-
}
|
|
27
|
+
initializer.init({
|
|
28
|
+
withData: true,
|
|
29
|
+
events: ["pageModified"],
|
|
30
|
+
setup({ element, data, initialize }) {
|
|
31
|
+
setupGroup(element, data);
|
|
32
|
+
initialize();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
47
35
|
}
|
|
48
36
|
|
|
49
37
|
/**
|
|
@@ -56,14 +44,19 @@ export function setup(context = document) {
|
|
|
56
44
|
/**
|
|
57
45
|
* Sets up a single group of details elements to manage their behavior.
|
|
58
46
|
* @param {HTMLElement} element - The parent element containing the details elements.
|
|
47
|
+
* @param {Object} options - The options for this group
|
|
59
48
|
* @returns {DetailsGroupInstance}
|
|
60
49
|
*/
|
|
61
|
-
export function setupGroup(element) {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
50
|
+
export function setupGroup(element, userOptions) {
|
|
51
|
+
const options = Object.assign({}, defaults, userOptions);
|
|
52
|
+
|
|
53
|
+
// Added try because we are using querySelectorAll with :scope by default
|
|
54
|
+
// which will not work in Internet Explorer or early edge (some alt. browsers too)
|
|
55
|
+
try {
|
|
56
|
+
setupChildren();
|
|
57
|
+
} catch(error) {
|
|
58
|
+
console.error(error);
|
|
59
|
+
}
|
|
67
60
|
|
|
68
61
|
/**
|
|
69
62
|
* Queries all current children in element
|
|
@@ -78,13 +71,11 @@ export function setupGroup(element) {
|
|
|
78
71
|
*/
|
|
79
72
|
function setupChildren() {
|
|
80
73
|
queryChildren().forEach(child => {
|
|
81
|
-
if (child.hasAttribute(
|
|
74
|
+
if (child.hasAttribute(childInitAttr)) {
|
|
82
75
|
return;
|
|
83
76
|
} else {
|
|
84
|
-
child.setAttribute(
|
|
77
|
+
child.setAttribute(childInitAttr, "");
|
|
85
78
|
}
|
|
86
|
-
console.log(child);
|
|
87
|
-
|
|
88
79
|
child.addEventListener("toggle", toggleHandler);
|
|
89
80
|
});
|
|
90
81
|
}
|
|
@@ -112,9 +103,9 @@ export function setupGroup(element) {
|
|
|
112
103
|
function destroy() {
|
|
113
104
|
queryChildren().forEach(child => {
|
|
114
105
|
child.removeEventListener("toggle", toggleHandler);
|
|
115
|
-
child.removeAttribute(
|
|
106
|
+
child.removeAttribute(childInitAttr);
|
|
116
107
|
});
|
|
117
|
-
element.removeAttribute(
|
|
108
|
+
element.removeAttribute(initializer.getAttribute("init"));
|
|
118
109
|
}
|
|
119
110
|
|
|
120
111
|
return { destroy, element, setupChildren };
|
package/js/ui/dialog.js
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
* @module ui/dialog
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
6
|
+
import { wasClickOutside } from "../utils/dom.js";
|
|
7
7
|
import { pauseVideos as pauseYoutubeVideos, prepVideos as prepYoutubeVideos } from "../utils/pause-youtube-video.js";
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
+
* Base attribute for a dialog
|
|
10
11
|
*/
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
12
|
+
export const baseAttribute = "data-ulu-dialog"; // Exposed for modal builder
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Dialog Component Initializer
|
|
16
|
+
*/
|
|
17
|
+
export const initializer = new ComponentInitializer({ type: "dialog", baseAttribute });
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
19
|
+
/**
|
|
20
|
+
* Attribute for close buttons within a dialog
|
|
21
|
+
*/
|
|
22
|
+
export const closeAttribute = initializer.getAttribute("close"); // Exposed for modal builder
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Dialog Defaults
|
|
@@ -42,6 +43,10 @@ export const defaults = {
|
|
|
42
43
|
* Whether or not to pause videos when dialog closes (currently just youtube and native)
|
|
43
44
|
*/
|
|
44
45
|
pauseVideos: true,
|
|
46
|
+
/**
|
|
47
|
+
* When open and not non-modal, the body is prevented from scrolling (defaults to true).
|
|
48
|
+
*/
|
|
49
|
+
preventScroll: true,
|
|
45
50
|
};
|
|
46
51
|
|
|
47
52
|
|
|
@@ -49,7 +54,7 @@ export const defaults = {
|
|
|
49
54
|
let currentDefaults = { ...defaults };
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
|
-
* @param {Object} options Change options used as default for dialogs, can then be
|
|
57
|
+
* @param {Object} options Change options used as default for dialogs, can then be overridden by data attribute settings on element
|
|
53
58
|
*/
|
|
54
59
|
export function setDefaults(options) {
|
|
55
60
|
currentDefaults = Object.assign({}, currentDefaults, options);
|
|
@@ -60,35 +65,40 @@ export function setDefaults(options) {
|
|
|
60
65
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
61
66
|
*/
|
|
62
67
|
export function init() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
// Initialize all the dialogs
|
|
69
|
+
initializer.init({
|
|
70
|
+
events: ["pageModified"],
|
|
71
|
+
withData: true,
|
|
72
|
+
setup({ element, initialize, data }) {
|
|
73
|
+
setupDialog(element, data);
|
|
74
|
+
initialize();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Initialize all triggers (things that trigger opening a dialog)
|
|
79
|
+
initializer.init({
|
|
80
|
+
key: "trigger",
|
|
81
|
+
events: ["pageModified"],
|
|
82
|
+
withData: true,
|
|
83
|
+
setup({ element, initialize, data: dialogId }) {
|
|
84
|
+
setupTrigger(element, dialogId);
|
|
85
|
+
initialize();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
/**
|
|
80
91
|
* Setup click handlers on a trigger
|
|
81
|
-
* @param {Node} trigger
|
|
92
|
+
* @param {Node} trigger Trigger button element
|
|
93
|
+
* @param {String} dialogId The dialog's id to open
|
|
82
94
|
*/
|
|
83
|
-
export function setupTrigger(trigger) {
|
|
95
|
+
export function setupTrigger(trigger, dialogId) {
|
|
84
96
|
trigger.addEventListener("click", handleTrigger);
|
|
85
|
-
trigger.setAttribute(attrs.init, "");
|
|
86
97
|
|
|
87
98
|
function handleTrigger() {
|
|
88
|
-
const
|
|
89
|
-
const dialog = document.getElementById(id);
|
|
99
|
+
const dialog = document.getElementById(dialogId);
|
|
90
100
|
if (!dialog) {
|
|
91
|
-
console.error("Could not locate dialog (id)",
|
|
101
|
+
console.error("Could not locate dialog (id)", dialogId);
|
|
92
102
|
return;
|
|
93
103
|
}
|
|
94
104
|
if (dialog?.tagName?.toLowerCase() !== "dialog") {
|
|
@@ -104,20 +114,33 @@ export function setupTrigger(trigger) {
|
|
|
104
114
|
* Setup click handlers for a dialog
|
|
105
115
|
* @param {Node} dialog
|
|
106
116
|
*/
|
|
107
|
-
export function setupDialog(dialog) {
|
|
108
|
-
const options =
|
|
117
|
+
export function setupDialog(dialog, userOptions) {
|
|
118
|
+
const options = Object.assign({}, currentDefaults, userOptions);
|
|
119
|
+
const body = document.body;
|
|
120
|
+
|
|
109
121
|
dialog.addEventListener("click", handleClicks);
|
|
110
|
-
|
|
122
|
+
|
|
111
123
|
if (options.documentEnd) {
|
|
112
|
-
|
|
124
|
+
body.appendChild(dialog);
|
|
113
125
|
}
|
|
114
126
|
if (options.pauseVideos) {
|
|
115
127
|
prepVideos(dialog);
|
|
116
128
|
}
|
|
117
129
|
|
|
130
|
+
// Allow preventScroll if it is a modal dialog
|
|
131
|
+
// Caching value of overflow before setting so we don't assume what it's initial value is
|
|
132
|
+
if (!options.nonModal && options.preventScroll) {
|
|
133
|
+
let overflowValue = body.style.overflow;
|
|
134
|
+
dialog.addEventListener("toggle", (event) => {
|
|
135
|
+
const isOpen = event.newState === "open";
|
|
136
|
+
if (isOpen) overflowValue = body.style.overflow;
|
|
137
|
+
body.style.overflow = isOpen ? "hidden" : overflowValue;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
118
141
|
function handleClicks(event) {
|
|
119
142
|
const { target } = event;
|
|
120
|
-
const closeFromButton = target.closest("
|
|
143
|
+
const closeFromButton = target.closest(initializer.attributeSelector("close"));
|
|
121
144
|
let closeFromOutside = options.clickOutsideCloses &&
|
|
122
145
|
target === dialog &&
|
|
123
146
|
wasClickOutside(dialog, event);
|
|
@@ -136,8 +159,7 @@ export function setupDialog(dialog) {
|
|
|
136
159
|
* @returns {Object}
|
|
137
160
|
*/
|
|
138
161
|
export function getDialogOptions(dialog) {
|
|
139
|
-
|
|
140
|
-
return Object.assign({}, currentDefaults, options);
|
|
162
|
+
return Object.assign({}, currentDefaults, initializer.getData(dialog));
|
|
141
163
|
}
|
|
142
164
|
|
|
143
165
|
/**
|
|
@@ -146,6 +168,7 @@ export function getDialogOptions(dialog) {
|
|
|
146
168
|
function prepVideos(dialog) {
|
|
147
169
|
prepYoutubeVideos(dialog);
|
|
148
170
|
}
|
|
171
|
+
|
|
149
172
|
/**
|
|
150
173
|
* Prep videos to be paused for a given dialog
|
|
151
174
|
*/
|
package/js/ui/dialog.todo
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
✔ Animations? @done
|
|
3
|
-
☐ Check styling on left right
|
|
1
|
+
Dialog Todos:
|
|
4
2
|
☐ Setup fullscreen option / modifier
|
|
5
|
-
☐
|
|
6
|
-
☐ Resizing
|
|
7
|
-
✔ Work out how this can work with native and click outside @done
|
|
8
|
-
✔ Figure out how to setup icon for the resizer for all sites @done
|
|
9
|
-
* Fontawesome, or should this just be CSS so we don't need any icons for it
|
|
10
|
-
* Same for close button should we just use CSS and omit any FA requirements
|
|
11
|
-
* Or make it super easy to implement the icon only in the template (like default icon classses)
|
|
12
|
-
* Then user can choose to implement their own (via class) or use the styles that come with it
|
|
13
|
-
☐ Prevent Browser Scroll
|
|
14
|
-
✔ How should height work? Should a centered modal expand to it's content's height (up to the viewport height) or always be cropped and scroll (static height)? @done
|
|
15
|
-
Todos:
|
|
16
|
-
✔ How should the relationship between a dialog and it's trigger work @done
|
|
17
|
-
* Think there should be no relationship? Just triggers are triggers just attach a handler to open DOM centric way (add errors when the dialog doesn't exist)
|
|
18
|
-
* For the dialogs they should just have handlers attached for close
|
|
19
|
-
* Init should find all one's that need to be built and build them, then it should initialize them the same way as non-built dialogs
|
|
20
|
-
✔ Support both modal and non-modal dialogs (rename)? @done
|
|
21
|
-
✘ Divide into 4 modules @cancelled
|
|
22
|
-
1. Initializer (data-attributes)
|
|
23
|
-
2. Templater (for Drupal projects and standard modals)
|
|
24
|
-
3. Open/Close Behaviors
|
|
25
|
-
4. Programmatic Modal
|
|
26
|
-
* This is tough because its opionated towards our system in Drupal (jQuery)
|
|
27
|
-
✔ How should this all be structured @done
|
|
28
|
-
* JS template dialogs?
|
|
29
|
-
* Pros
|
|
30
|
-
* Many users create the modals in content in CMS we don't want to make that difficult or get stuck with structure
|
|
31
|
-
* Cons
|
|
32
|
-
* Templating is in JS so dialogs don't make much sense on their own
|
|
33
|
-
* Could continue the div to dialog conversion (so modal content is inline unless JS running). Don't want to optimize too much for no js anymore anyways
|
|
34
|
-
* writing the dialog by hand makes sense for non defualt modal styles or users that have another structure but need the scripting part
|
|
35
|
-
* Solution
|
|
36
|
-
* Breakup module into two parts the underlying modal scripting (open close trigger) and (conversion modal templating [w. resizer] and as <div>)
|
|
37
|
-
* Then we can have both without any extra code and seperation
|
|
3
|
+
☐ Prevent Browser Scroll
|
package/js/ui/flipcard.js
CHANGED
|
@@ -2,14 +2,43 @@
|
|
|
2
2
|
* @module ui/flipcard
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
5
6
|
import { trimWhitespace } from "@ulu/utils/string.js";
|
|
6
7
|
import { log, logError } from "../utils/class-logger.js";
|
|
7
|
-
import { getName } from "../events/index.js";
|
|
8
|
-
import { getDatasetOptionalJson } from "../utils/dom.js";
|
|
9
|
-
const debugMode = false; // Global dev debug
|
|
10
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Flipcard Component Initializer
|
|
11
|
+
*/
|
|
12
|
+
export const initializer = new ComponentInitializer({
|
|
13
|
+
type: "flipcard",
|
|
14
|
+
baseAttribute: "data-ulu-flipcard"
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize flipcards using data-ulu-flipcard attribute
|
|
19
|
+
*/
|
|
20
|
+
export function init() {
|
|
21
|
+
initializer.init({
|
|
22
|
+
withData: true,
|
|
23
|
+
events: ["pageModified"],
|
|
24
|
+
setup({ element, data, initialize }) {
|
|
25
|
+
const options = Object.assign({}, data);
|
|
26
|
+
const front = element.querySelector(initializer.attributeSelector("front"));
|
|
27
|
+
const back = element.querySelector(initializer.attributeSelector("back"));
|
|
28
|
+
(new Flipcard(element, front, back, options));
|
|
29
|
+
initialize();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Flipcard class (creates flipcard instance and behaviors)
|
|
36
|
+
*/
|
|
11
37
|
export class Flipcard {
|
|
12
38
|
static instances = [];
|
|
39
|
+
/**
|
|
40
|
+
* Default options for Flipcard
|
|
41
|
+
*/
|
|
13
42
|
static defaults = {
|
|
14
43
|
namespace: "Flipcard",
|
|
15
44
|
proxyClick: {
|
|
@@ -18,25 +47,25 @@ export class Flipcard {
|
|
|
18
47
|
exclude: "a, input, textarea, button" // Selectors to avoid closing a flipcard onProxyclick
|
|
19
48
|
},
|
|
20
49
|
};
|
|
21
|
-
constructor(container, front, back, config
|
|
50
|
+
constructor(container, front, back, config) {
|
|
22
51
|
if (!container, !front, !back) {
|
|
23
52
|
logError(this, 'Missing an element (container, front, back)');
|
|
24
53
|
}
|
|
25
54
|
this.options = Object.assign({}, Flipcard.defaults, config);
|
|
26
55
|
const { namespace } = this.options;
|
|
56
|
+
|
|
27
57
|
Flipcard.instances.push(this);
|
|
28
58
|
|
|
29
|
-
this.debug = debugMode || debug;
|
|
30
59
|
this.elements = { container, front, back };
|
|
31
60
|
this.isOpen = false;
|
|
32
61
|
this.uid = `${ namespace }-id-${ Flipcard.instances.length }`;
|
|
33
62
|
this.stateAttr = `data-${ namespace }-state`.toLowerCase();
|
|
34
63
|
this.setup();
|
|
35
|
-
this.
|
|
64
|
+
this.setVisibility(false);
|
|
36
65
|
log(this, this);
|
|
37
66
|
}
|
|
38
67
|
toggle() {
|
|
39
|
-
this.
|
|
68
|
+
this.setVisibility(!this.isOpen);
|
|
40
69
|
}
|
|
41
70
|
setup() {
|
|
42
71
|
const { uid } = this;
|
|
@@ -98,7 +127,7 @@ export class Flipcard {
|
|
|
98
127
|
<span class="hidden-visually">Show More Information</span>
|
|
99
128
|
`;
|
|
100
129
|
}
|
|
101
|
-
|
|
130
|
+
setVisibility(visible) {
|
|
102
131
|
const { back, container, control } = this.elements;
|
|
103
132
|
const state = visible ? "open" : "closed";
|
|
104
133
|
back.style.zIndex = visible ? "10" : "1";
|
|
@@ -128,56 +157,7 @@ export class Flipcard {
|
|
|
128
157
|
}
|
|
129
158
|
}
|
|
130
159
|
|
|
131
|
-
/**
|
|
132
|
-
* Default data attributes
|
|
133
|
-
*/
|
|
134
|
-
export const attrs = {
|
|
135
|
-
init: "data-ulu-flipcard-init",
|
|
136
|
-
flipcard: "data-ulu-flipcard",
|
|
137
|
-
front: "data-ulu-flipcard-front",
|
|
138
|
-
back: "data-ulu-flipcard-back",
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// Utils for selecting things based on attributes
|
|
142
|
-
const attrSelector = key => `[${ attrs[key] }]`;
|
|
143
|
-
const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
|
|
144
|
-
|
|
145
|
-
// const containers = document.querySelectorAll('[data-ulu-flipcard]');
|
|
146
|
-
const instances = [];
|
|
147
|
-
|
|
148
|
-
export function init() {
|
|
149
|
-
document.addEventListener(getName("pageModified"), setup);
|
|
150
|
-
setup();
|
|
151
|
-
}
|
|
152
160
|
|
|
153
|
-
export function setup() {
|
|
154
|
-
const builders = document.querySelectorAll(attrSelectorInitial("flipcard"));
|
|
155
|
-
builders.forEach(setupFlipcard);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// containers.forEach(init);
|
|
159
|
-
|
|
160
|
-
function setupFlipcard(container) {
|
|
161
|
-
container.setAttribute(attrs.init, "");
|
|
162
|
-
const options = getDatasetOptionalJson(container, "uluFlipcard");
|
|
163
|
-
const config = Object.assign({}, options);
|
|
164
|
-
const front = container.querySelector(attrSelectorInitial("front"));
|
|
165
|
-
const back = container.querySelector(attrSelectorInitial("back"));
|
|
166
|
-
instances.push(new Flipcard(container, front, back, config));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// getDatasetOptionalJson
|
|
170
|
-
function setupSlider(container) {
|
|
171
|
-
container.setAttribute(attrs.init, "");
|
|
172
|
-
const options = getDatasetOptionalJson(container, "uluFlipcard");
|
|
173
|
-
const config = Object.assign({}, options);
|
|
174
|
-
const elements = {
|
|
175
|
-
track: container.querySelector(attrSelector("track")),
|
|
176
|
-
controls: container.querySelector(attrSelector("controls"))
|
|
177
|
-
};
|
|
178
|
-
// replace with OverflowScroller when finished removing sitescrollslider
|
|
179
|
-
instances.push(new SiteScrollSlider(elements, config));
|
|
180
|
-
}
|
|
181
161
|
|
|
182
162
|
/**
|
|
183
163
|
* Preliminary Notes:
|
package/js/ui/grid.js
CHANGED
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
* @module ui/grid
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
5
6
|
import { setPositionClasses } from "../utils/dom.js";
|
|
6
|
-
import { getName } from "../events/index.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param {String} selector The selector for the parent element
|
|
11
|
-
* @param {Object} classes Classes (optional) @see setPositionClasses
|
|
9
|
+
* Dialog Component Initializer
|
|
12
10
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
11
|
+
export const initializer = new ComponentInitializer({
|
|
12
|
+
type: "grid",
|
|
13
|
+
baseAttribute: "data-grid"
|
|
14
|
+
});
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {String} selector The selector for the parent element
|
|
17
|
+
* Sets up document for grid position classes
|
|
22
18
|
* @param {Object} classes Classes (optional) @see setPositionClasses
|
|
23
19
|
*/
|
|
24
|
-
export function
|
|
25
|
-
|
|
20
|
+
export function init(classes) {
|
|
21
|
+
initializer.init({
|
|
22
|
+
events: ["pageModified", "pageResized"],
|
|
23
|
+
setup({ element, initialize }) {
|
|
24
|
+
setPositionClasses(element, classes);
|
|
25
|
+
initialize();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
26
28
|
}
|
package/js/ui/modal-builder.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module ui/modal-builder
|
|
3
|
+
* @description Note this module needs to be initialized before dialogs!
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
7
7
|
import { wrapSettingString } from "../settings.js";
|
|
8
8
|
import { getName } from "../events/index.js";
|
|
9
9
|
import { createElementFromHtml } from "@ulu/utils/browser/dom.js";
|
|
10
10
|
import { Resizer } from "./resizer.js";
|
|
11
|
-
import {
|
|
12
|
-
import { defaults as dialogDefaults, attrs as dialogAttrs } from "./dialog.js";
|
|
13
|
-
|
|
14
|
-
const attrs = {
|
|
15
|
-
builder: "data-ulu-modal-builder",
|
|
16
|
-
body: "data-ulu-modal-builder-body",
|
|
17
|
-
resizer: "data-ulu-modal-builder-resizer"
|
|
18
|
-
};
|
|
11
|
+
import { baseAttribute, closeAttribute, defaults as dialogDefaults } from "./dialog.js";
|
|
19
12
|
|
|
20
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Modal Builder Component Initializer
|
|
15
|
+
*/
|
|
16
|
+
export const initializer = new ComponentInitializer({
|
|
17
|
+
type: "modal-builder",
|
|
18
|
+
baseAttribute: "data-ulu-modal-builder"
|
|
19
|
+
});
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Default builder options (extends dialog defaults, watch name collisions)
|
|
@@ -75,14 +74,14 @@ export const defaults = {
|
|
|
75
74
|
}
|
|
76
75
|
<span class="modal__title-text">${ config.title }</span>
|
|
77
76
|
</h2>
|
|
78
|
-
<button class="modal__close" aria-label="Close modal" ${
|
|
77
|
+
<button class="modal__close" aria-label="Close modal" ${ closeAttribute } autofocus>
|
|
79
78
|
${ config.templateCloseIcon(config) }
|
|
80
79
|
</button>
|
|
81
80
|
</header>
|
|
82
81
|
` : "" }
|
|
83
|
-
<div class="modal__body" ${
|
|
82
|
+
<div class="modal__body" ${ initializer.getAttribute("body") }></div>
|
|
84
83
|
${ config.hasResizer ?
|
|
85
|
-
`<div class="modal__resizer" ${
|
|
84
|
+
`<div class="modal__resizer" ${ initializer.getAttribute("resizer") }>
|
|
86
85
|
${ config.templateResizerIcon(config) }
|
|
87
86
|
</div>` : ""
|
|
88
87
|
}
|
|
@@ -106,26 +105,13 @@ export function setDefaults(options) {
|
|
|
106
105
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
107
106
|
*/
|
|
108
107
|
export function init() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
export function setup() {
|
|
117
|
-
const builders = document.querySelectorAll(attrSelector("builder"));
|
|
118
|
-
builders.forEach(setupBuilder);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Build a dialog for the given content
|
|
123
|
-
* @param {Node} element
|
|
124
|
-
*/
|
|
125
|
-
export function setupBuilder(element) {
|
|
126
|
-
const options = getDatasetJson(element, "uluModalBuilder");
|
|
127
|
-
element.removeAttribute(attrs.builder);
|
|
128
|
-
buildModal(element, options);
|
|
108
|
+
initializer.init({
|
|
109
|
+
withData: true,
|
|
110
|
+
events: ["pageModified"],
|
|
111
|
+
setup({ element, data }) {
|
|
112
|
+
buildModal(element, data);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
129
115
|
}
|
|
130
116
|
|
|
131
117
|
/**
|
|
@@ -141,7 +127,7 @@ export function buildModal(content, options) {
|
|
|
141
127
|
config.hasResizer = true;
|
|
142
128
|
}
|
|
143
129
|
if (config.debug) {
|
|
144
|
-
|
|
130
|
+
initializer.log(config, content);
|
|
145
131
|
}
|
|
146
132
|
if (!content.id) {
|
|
147
133
|
throw new Error("Missing ID on modal");
|
|
@@ -149,7 +135,7 @@ export function buildModal(content, options) {
|
|
|
149
135
|
|
|
150
136
|
const markup = config.template(content.id, config);
|
|
151
137
|
const modal = createElementFromHtml(markup.trim());
|
|
152
|
-
const selectChild = key => modal.querySelector(
|
|
138
|
+
const selectChild = key => modal.querySelector(initializer.attributeSelector(key));
|
|
153
139
|
const body = selectChild("body");
|
|
154
140
|
const resizer = selectChild("resizer");
|
|
155
141
|
const dialogOptions = separateDialogOptions(config);
|
|
@@ -157,12 +143,12 @@ export function buildModal(content, options) {
|
|
|
157
143
|
// Replace content with new dialog, and then insert the content into the new dialogs body
|
|
158
144
|
content.removeAttribute("id");
|
|
159
145
|
content.removeAttribute("hidden");
|
|
160
|
-
content.removeAttribute(
|
|
146
|
+
content.removeAttribute(initializer.getAttribute());
|
|
161
147
|
content.parentNode.replaceChild(modal, content);
|
|
162
148
|
body.appendChild(content);
|
|
163
149
|
|
|
164
150
|
// Add dialog options for other scripts
|
|
165
|
-
modal.setAttribute(
|
|
151
|
+
modal.setAttribute(baseAttribute, JSON.stringify(dialogOptions));
|
|
166
152
|
|
|
167
153
|
if (config.hasResizer) {
|
|
168
154
|
new Resizer(modal, resizer, {
|