@ulu/frontend 0.1.0-beta.8 → 0.1.0-beta.80
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 +529 -0
- package/README.dev.md +3 -3
- package/README.md +14 -4
- package/dist/ulu-frontend.min.css +1 -1
- package/dist/ulu-frontend.min.js +35 -28
- package/docs-dev/assets/main.js +8290 -635
- package/docs-dev/assets/placeholder/icon-calendar.svg +1 -0
- package/docs-dev/assets/placeholder/icon-check.svg +1 -0
- package/docs-dev/assets/style.css +789 -338
- package/docs-dev/changelog/index.html +6553 -0
- package/docs-dev/demos/accordion/index.html +850 -328
- package/docs-dev/demos/badge/index.html +5265 -0
- package/docs-dev/demos/basic-hero/index.html +111 -0
- package/docs-dev/demos/breakpoints-manager/index.html +5276 -0
- package/docs-dev/demos/button/index.html +892 -328
- package/docs-dev/demos/button-verbose/index.html +5268 -0
- package/docs-dev/demos/callout/index.html +895 -332
- package/docs-dev/demos/captioned-figure/index.html +850 -327
- package/docs-dev/demos/card/index.html +930 -768
- package/docs-dev/demos/card-grid/index.html +5387 -0
- package/docs-dev/demos/counter-list/index.html +5270 -0
- package/docs-dev/demos/css-icons/index.html +850 -327
- package/docs-dev/demos/data-grid/index.html +870 -347
- package/docs-dev/demos/data-table/index.html +1024 -368
- package/docs-dev/demos/details-group/index.html +5297 -0
- package/docs-dev/demos/file-save/index.html +850 -327
- package/docs-dev/demos/flipcard/index.html +850 -327
- package/docs-dev/demos/form-theme/index.html +868 -358
- package/docs-dev/demos/hero/index.html +12 -4
- package/docs-dev/demos/image-grid/index.html +12 -4
- package/docs-dev/demos/index.html +851 -328
- package/docs-dev/demos/list-inline/index.html +850 -327
- package/docs-dev/demos/list-lines/index.html +850 -327
- package/docs-dev/demos/menu-stack/index.html +884 -346
- package/docs-dev/demos/modals/index.html +968 -330
- package/docs-dev/demos/nav-strip/index.html +850 -327
- package/docs-dev/demos/overlay-section/index.html +939 -346
- package/docs-dev/demos/popovers/index.html +1112 -347
- package/docs-dev/demos/print/index.html +850 -327
- package/docs-dev/demos/pull-quote/index.html +850 -327
- package/docs-dev/demos/rule/index.html +863 -328
- package/docs-dev/demos/scroll-slider/index.html +72 -106
- package/docs-dev/demos/scrollpoints/index.html +851 -328
- package/docs-dev/demos/slider/index.html +12 -4
- package/docs-dev/demos/spoke-spinner/index.html +850 -327
- package/docs-dev/demos/{list-inline.1 → sticky-list}/index.html +883 -357
- package/docs-dev/demos/tabs/index.html +886 -327
- package/docs-dev/demos/tag/index.html +850 -327
- package/docs-dev/demos/theme-toggle/index.html +5309 -0
- package/docs-dev/demos/tile-grid-overlay/index.html +12 -4
- package/docs-dev/demos/tiles/index.html +850 -327
- package/docs-dev/demos/tooltip/index.html +850 -327
- package/docs-dev/guide/building-stylesheet/index.html +850 -327
- package/docs-dev/guide/developing-ulu-scss-module/index.html +850 -327
- package/docs-dev/guide/index.html +850 -327
- package/docs-dev/index.html +850 -327
- package/docs-dev/javascript/events/index.html +847 -326
- package/docs-dev/javascript/index.html +850 -327
- package/docs-dev/javascript/settings/index.html +5430 -0
- package/docs-dev/javascript/ui-breakpoints/index.html +862 -341
- package/docs-dev/javascript/ui-collapsible/index.html +847 -326
- package/docs-dev/javascript/ui-details-group/index.html +5352 -0
- package/docs-dev/javascript/ui-dialog/index.html +879 -343
- package/docs-dev/javascript/ui-flipcard/index.html +908 -331
- package/docs-dev/javascript/ui-grid/index.html +857 -362
- package/docs-dev/javascript/ui-modal-builder/index.html +1047 -386
- package/docs-dev/javascript/ui-overflow-scroller/index.html +847 -326
- package/docs-dev/javascript/ui-overflow-scroller-pager/index.html +847 -326
- package/docs-dev/javascript/ui-page/index.html +847 -326
- package/docs-dev/javascript/ui-popover/index.html +855 -338
- package/docs-dev/javascript/ui-print/index.html +847 -334
- package/docs-dev/javascript/ui-print-details/index.html +847 -326
- package/docs-dev/javascript/ui-programmatic-modal/index.html +847 -326
- package/docs-dev/javascript/ui-proxy-click/index.html +934 -328
- package/docs-dev/javascript/ui-resizer/index.html +847 -326
- package/docs-dev/javascript/ui-scroll-slider/index.html +885 -332
- package/docs-dev/javascript/ui-scrollpoint/index.html +853 -339
- package/docs-dev/javascript/ui-slider/index.html +1043 -331
- package/docs-dev/javascript/ui-tabs/index.html +858 -374
- package/docs-dev/javascript/ui-theme-toggle/index.html +5440 -0
- package/docs-dev/javascript/ui-tooltip/index.html +854 -337
- package/docs-dev/javascript/utils-class-logger/index.html +847 -326
- package/docs-dev/javascript/utils-css/index.html +5254 -0
- package/docs-dev/javascript/utils-dom/index.html +887 -446
- package/docs-dev/javascript/utils-file-save/index.html +847 -326
- package/docs-dev/javascript/utils-floating-ui/index.html +847 -326
- package/docs-dev/javascript/utils-id/index.html +847 -326
- package/docs-dev/javascript/utils-pause-youtube-video/index.html +847 -326
- package/docs-dev/javascript/utils-system/index.html +5557 -0
- package/docs-dev/sass/base/color/index.html +847 -326
- package/docs-dev/sass/base/elements/index.html +847 -326
- package/docs-dev/sass/base/index/index.html +847 -326
- package/docs-dev/sass/base/index.html +850 -327
- package/docs-dev/sass/base/keyframes/index.html +847 -326
- package/docs-dev/sass/base/layout/index.html +847 -326
- package/docs-dev/sass/base/normalize/index.html +847 -326
- package/docs-dev/sass/base/print/index.html +847 -326
- package/docs-dev/sass/base/root/index.html +847 -326
- package/docs-dev/sass/base/typography/index.html +847 -326
- package/docs-dev/sass/components/accordion/index.html +866 -338
- package/docs-dev/sass/components/adaptive-spacing/index.html +847 -326
- package/docs-dev/sass/components/badge/index.html +869 -337
- package/docs-dev/sass/components/basic-hero/index.html +5415 -0
- package/docs-dev/sass/components/button/index.html +847 -326
- package/docs-dev/sass/components/button-verbose/index.html +933 -337
- package/docs-dev/sass/components/callout/index.html +958 -418
- package/docs-dev/sass/components/captioned-figure/index.html +970 -334
- package/docs-dev/sass/components/card/index.html +939 -346
- package/docs-dev/sass/components/card-grid/index.html +847 -326
- package/docs-dev/sass/components/counter-list/index.html +5497 -0
- package/docs-dev/sass/components/css-icon/index.html +864 -336
- package/docs-dev/sass/components/data-grid/index.html +868 -340
- package/docs-dev/sass/components/data-table/index.html +1063 -352
- package/docs-dev/sass/components/fill-context/index.html +847 -326
- package/docs-dev/sass/components/flipcard/index.html +888 -336
- package/docs-dev/sass/components/flipcard-grid/index.html +847 -326
- package/docs-dev/sass/components/form-theme/index.html +1063 -446
- package/docs-dev/sass/components/hero/index.html +903 -334
- package/docs-dev/sass/components/horizontal-rule/index.html +847 -326
- package/docs-dev/sass/components/image-grid/index.html +847 -326
- package/docs-dev/sass/components/index/index.html +860 -336
- package/docs-dev/sass/components/index.html +850 -327
- package/docs-dev/sass/components/links/index.html +847 -326
- package/docs-dev/sass/components/list-inline/index.html +847 -326
- package/docs-dev/sass/components/list-lines/index.html +847 -326
- package/docs-dev/sass/components/list-ordered/index.html +847 -326
- package/docs-dev/sass/components/list-unordered/index.html +847 -326
- package/docs-dev/sass/components/menu-stack/index.html +881 -347
- package/docs-dev/sass/components/modal/index.html +891 -342
- package/docs-dev/sass/components/nav-strip/index.html +855 -334
- package/docs-dev/sass/components/overlay-section/index.html +855 -334
- package/docs-dev/sass/components/pager/index.html +847 -326
- package/docs-dev/sass/components/placeholder-block/index.html +847 -326
- package/docs-dev/sass/components/popover/index.html +904 -347
- package/docs-dev/sass/components/pull-quote/index.html +859 -338
- package/docs-dev/sass/components/ratio-box/index.html +855 -334
- package/docs-dev/sass/components/rule/index.html +848 -327
- package/docs-dev/sass/components/scroll-slider/index.html +855 -346
- package/docs-dev/sass/components/skip-link/index.html +847 -326
- package/docs-dev/sass/components/slider/index.html +897 -388
- package/docs-dev/sass/components/spoke-spinner/index.html +849 -328
- package/docs-dev/sass/components/sticky-list/index.html +5633 -0
- package/docs-dev/sass/components/tabs/index.html +872 -336
- package/docs-dev/sass/components/tag/index.html +849 -328
- package/docs-dev/sass/components/tile-button/index.html +847 -326
- package/docs-dev/sass/components/tile-grid/index.html +847 -326
- package/docs-dev/sass/components/tile-grid-overlay/index.html +847 -326
- package/docs-dev/sass/components/vignette/index.html +861 -334
- package/docs-dev/sass/components/wysiwyg/index.html +847 -326
- package/docs-dev/sass/core/breakpoint/index.html +931 -358
- package/docs-dev/sass/core/button/index.html +847 -326
- package/docs-dev/sass/core/color/index.html +1019 -366
- package/docs-dev/sass/core/cssvar/index.html +847 -326
- package/docs-dev/sass/core/element/index.html +1108 -381
- package/docs-dev/sass/core/index.html +847 -326
- package/docs-dev/sass/core/layout/index.html +903 -363
- package/docs-dev/sass/core/path/index.html +847 -326
- package/docs-dev/sass/core/selector/index.html +847 -326
- package/docs-dev/sass/core/typography/index.html +847 -326
- package/docs-dev/sass/core/units/index.html +857 -330
- package/docs-dev/sass/core/utils/index.html +2104 -476
- package/docs-dev/sass/helpers/color/index.html +847 -326
- package/docs-dev/sass/helpers/display/index.html +848 -327
- package/docs-dev/sass/helpers/index/index.html +847 -326
- package/docs-dev/sass/helpers/index.html +850 -327
- package/docs-dev/sass/helpers/print/index.html +759 -298
- package/docs-dev/sass/helpers/typography/index.html +847 -326
- package/docs-dev/sass/helpers/units/index.html +847 -326
- package/docs-dev/sass/helpers/utilities/index.html +849 -328
- package/docs-dev/sass/index.html +850 -327
- package/js/index.js +1 -0
- package/js/settings.js +95 -0
- package/js/ui/breakpoints.js +19 -16
- package/js/ui/collapsible.js +8 -1
- package/js/ui/details-group.js +112 -0
- package/js/ui/dialog.js +85 -42
- package/js/ui/dialog.todo +2 -36
- package/js/ui/flipcard.js +37 -57
- package/js/ui/grid.js +15 -13
- package/js/ui/index.js +1 -0
- package/js/ui/modal-builder.js +105 -59
- package/js/ui/overflow-scroller.js +6 -4
- package/js/ui/page.js +2 -2
- package/js/ui/popover.js +38 -38
- package/js/ui/print.js +16 -25
- package/js/ui/programmatic-modal.js +9 -3
- package/js/ui/proxy-click.js +50 -36
- package/js/ui/scroll-slider.js +24 -30
- package/js/ui/scrollpoint.js +29 -64
- package/js/ui/slider.js +108 -63
- package/js/ui/tabs.js +23 -36
- package/js/ui/theme-toggle.js +332 -94
- package/js/ui/tooltip.js +27 -32
- package/js/utils/css.js +13 -0
- package/js/utils/dom.js +23 -64
- package/js/utils/font-awesome.js +18 -0
- package/js/utils/index.js +2 -1
- package/js/utils/system.js +155 -0
- package/package.json +23 -8
- package/scss/README.md +4 -0
- package/scss/_breakpoint.scss +38 -4
- package/scss/_color.scss +40 -9
- package/scss/_element.scss +108 -2
- package/scss/_layout.scss +7 -8
- package/scss/_units.scss +3 -2
- package/scss/_utils.scss +380 -16
- package/scss/components/README.todos +14 -0
- package/scss/components/_accordion.scss +33 -19
- package/scss/components/_badge.scss +23 -4
- package/scss/components/_basic-hero.scss +112 -0
- package/scss/components/_button-verbose.scss +100 -18
- package/scss/components/_callout.scss +125 -78
- package/scss/components/_captioned-figure.scss +17 -0
- package/scss/components/_card-grid.scss +1 -1
- package/scss/components/_card.scss +246 -74
- package/scss/components/_counter-list.scss +151 -0
- package/scss/components/_css-icon.scss +25 -21
- package/scss/components/_data-grid.scss +55 -9
- package/scss/components/_data-table.scss +39 -3
- package/scss/components/_flipcard.scss +8 -3
- package/scss/components/_form-theme.scss +119 -108
- package/scss/components/_hero.scss +12 -10
- package/scss/components/_index.scss +18 -0
- package/scss/components/_menu-stack.scss +42 -26
- package/scss/components/_modal.scss +42 -26
- package/scss/components/_nav-strip.scss +2 -0
- package/scss/components/_overlay-section.scss +2 -5
- package/scss/components/_popover.scss +165 -64
- package/scss/components/_pull-quote.scss +13 -13
- package/scss/components/_ratio-box.scss +2 -5
- package/scss/components/_rule.scss +1 -0
- package/scss/components/_scroll-slider.scss +1 -5
- package/scss/components/_slider.scss +49 -72
- package/scss/components/_spoke-spinner.scss +2 -2
- package/scss/components/_sticky-list.scss +206 -0
- package/scss/components/_tabs.scss +22 -4
- package/scss/components/_vignette.scss +3 -5
- package/scss/helpers/_display.scss +15 -18
- package/scss/helpers/_print.scss +12 -7
- package/scss/helpers/_utilities.scss +42 -32
- package/types/index.d.ts +1 -0
- package/types/settings.d.ts +66 -0
- package/types/settings.d.ts.map +1 -0
- package/types/ui/breakpoints.d.ts +14 -14
- package/types/ui/breakpoints.d.ts.map +1 -1
- package/types/ui/collapsible.d.ts.map +1 -1
- package/types/ui/details-group.d.ts +38 -0
- package/types/ui/details-group.d.ts.map +1 -0
- package/types/ui/dialog.d.ts +20 -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/index.d.ts +2 -1
- package/types/ui/modal-builder.d.ts +113 -11
- package/types/ui/modal-builder.d.ts.map +1 -1
- package/types/ui/overflow-scroller.d.ts +2 -2
- package/types/ui/overflow-scroller.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/programmatic-modal.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 +33 -14
- 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 +51 -7
- 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/css.d.ts +11 -0
- package/types/utils/css.d.ts.map +1 -0
- package/types/utils/dom.d.ts +12 -32
- package/types/utils/dom.d.ts.map +1 -1
- package/types/utils/font-awesome.d.ts +5 -0
- package/types/utils/font-awesome.d.ts.map +1 -0
- package/types/utils/index.d.ts +2 -1
- package/types/utils/system.d.ts +113 -0
- package/types/utils/system.d.ts.map +1 -0
package/js/ui/print.js
CHANGED
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
* @module ui/print
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
6
|
+
import { getElement } from "@ulu/utils/browser/dom.js";
|
|
7
7
|
import { printElement } from "@ulu/utils/browser/print.js";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const attrSelector = key => `[${ attrs[key] }]`;
|
|
15
|
-
const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
|
|
16
|
-
const queryAllInitial = key => document.querySelectorAll(attrSelectorInitial(key));
|
|
9
|
+
const initializer = new ComponentInitializer({
|
|
10
|
+
type: "print",
|
|
11
|
+
baseAttribute: "data-ulu-print"
|
|
12
|
+
});
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
15
|
* Default options
|
|
@@ -30,27 +26,22 @@ const defaults = {
|
|
|
30
26
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
31
27
|
*/
|
|
32
28
|
export function init() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function setup() {
|
|
41
|
-
const triggers = queryAllInitial("trigger");
|
|
42
|
-
triggers.forEach(trigger => {
|
|
43
|
-
const options = getDatasetOptionalJson(trigger, "uluPrint");
|
|
44
|
-
setupTrigger(trigger, options);
|
|
29
|
+
initializer.init({
|
|
30
|
+
withData: true,
|
|
31
|
+
events: ["pageModified"],
|
|
32
|
+
setup({ element, data, initialize }) {
|
|
33
|
+
setupTrigger(element, data);
|
|
34
|
+
initialize();
|
|
35
|
+
}
|
|
45
36
|
});
|
|
46
37
|
}
|
|
47
38
|
|
|
48
39
|
/**
|
|
49
40
|
* Setup a single trigger (can be used manually without attr if needed)
|
|
50
41
|
*/
|
|
51
|
-
function setupTrigger(trigger,
|
|
52
|
-
const config = Object.assign({}, defaults,
|
|
53
|
-
trigger.addEventListener("click", (
|
|
42
|
+
function setupTrigger(trigger, userOptions) {
|
|
43
|
+
const config = Object.assign({}, defaults, userOptions);
|
|
44
|
+
trigger.addEventListener("click", () => {
|
|
54
45
|
// Option to print a specific element
|
|
55
46
|
if (config.element) {
|
|
56
47
|
const element = getElement(config.element);
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { getName, dispatch } from "../events/index.js";
|
|
7
7
|
import { newId } from "../utils/id.js";
|
|
8
8
|
import { buildModal } from "./modal-builder.js";
|
|
9
|
+
import { getElement } from "@ulu/utils/browser/dom.js";
|
|
9
10
|
|
|
10
11
|
export class ProgrammaticModalManager {
|
|
11
12
|
static defaults = {
|
|
@@ -43,12 +44,17 @@ export class ProgrammaticModalManager {
|
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
createAndOpen(config, afterCreate) {
|
|
46
|
-
const {
|
|
47
|
-
const content =
|
|
47
|
+
const { noClickTrigger, removeOnClose, element, classes } = config;
|
|
48
|
+
const content = getElement(element);
|
|
48
49
|
if (!content.id) {
|
|
49
50
|
content.id = newId();
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
// Added to match original jquery module api
|
|
54
|
+
if (classes) {
|
|
55
|
+
content.classList.add(...classes);
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
let trigger;
|
|
53
59
|
if (!noClickTrigger) {
|
|
54
60
|
trigger = this.cachedTrigger;
|
|
@@ -57,7 +63,7 @@ export class ProgrammaticModalManager {
|
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
if (!content) {
|
|
60
|
-
console.error("No element found from config.
|
|
66
|
+
console.error("No element found from config.element. ", config);
|
|
61
67
|
return;
|
|
62
68
|
}
|
|
63
69
|
const { modal } = buildModal(content, config.modal);
|
package/js/ui/proxy-click.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module ui/proxy-click
|
|
3
|
+
* @description Used for cards and things that look like they should be clickable
|
|
4
|
+
* even though the link in their content is the only clickable element. This way
|
|
5
|
+
* the entire cards content doesn't need to be in a link (which isn't accessible).
|
|
6
|
+
*
|
|
7
|
+
* The script allows only for clicks with a duration of 250ms to avoid conflict
|
|
8
|
+
* with a user selecting text. Works with either links or buttons because it just
|
|
9
|
+
* uses the elements .click(). Uses data-attributes for selection by default.
|
|
3
10
|
*/
|
|
4
11
|
|
|
12
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
5
13
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { getName } from "../events/index.js";
|
|
14
|
-
import { getDatasetOptionalJson } from "../utils/dom.js";
|
|
15
|
-
|
|
16
|
-
const attrs = {
|
|
17
|
-
trigger: "data-ulu-proxy-click",
|
|
18
|
-
init: "data-ulu-proxy-click-init",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const attrSelector = key => `[${ attrs[key] }]`;
|
|
22
|
-
const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
|
|
14
|
+
/**
|
|
15
|
+
* Proxy Click Component Initializer
|
|
16
|
+
*/
|
|
17
|
+
export const initializer = new ComponentInitializer({
|
|
18
|
+
type: "proxy-click",
|
|
19
|
+
baseAttribute: "data-ulu-proxy-click"
|
|
20
|
+
});
|
|
23
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Default options
|
|
24
|
+
*/
|
|
24
25
|
export const defaults = {
|
|
25
26
|
selector: "[data-ulu-proxy-click-source]",
|
|
26
27
|
selectorPreventBase: "input, select, textarea, button, a, [tabindex='-1']",
|
|
@@ -32,7 +33,7 @@ export const defaults = {
|
|
|
32
33
|
let currentDefaults = { ...defaults };
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
|
-
* @param {Object} options Change options used as default for dialogs, can then be
|
|
36
|
+
* @param {Object} options Change options used as default for dialogs, can then be overridden by data attribute settings on element
|
|
36
37
|
*/
|
|
37
38
|
export function setDefaults(options) {
|
|
38
39
|
currentDefaults = Object.assign({}, currentDefaults, options);
|
|
@@ -42,26 +43,39 @@ export function setDefaults(options) {
|
|
|
42
43
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
43
44
|
*/
|
|
44
45
|
export function init() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
proxies.forEach(proxy => {
|
|
52
|
-
const elOptions = getDatasetOptionalJson(proxy, "siteProxyClick");
|
|
53
|
-
const options = Object.assign({}, currentDefaults, elOptions);
|
|
54
|
-
const child = proxy.querySelector(options.selector);
|
|
55
|
-
if (child) {
|
|
56
|
-
attachHandlers(proxy, child, options);
|
|
57
|
-
proxy.setAttribute(attrs.init, "");
|
|
58
|
-
} else {
|
|
59
|
-
console.error("Unable to locate proxy click source", options.selector);
|
|
46
|
+
initializer.init({
|
|
47
|
+
withData: true,
|
|
48
|
+
events: ["pageModified"],
|
|
49
|
+
setup({ element, data, initialize }) {
|
|
50
|
+
setupProxy(element, data);
|
|
51
|
+
initialize();
|
|
60
52
|
}
|
|
61
53
|
});
|
|
62
54
|
}
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Setup a single proxy click
|
|
58
|
+
* @param {Node} proxy The container who's click should proxy the click of inner element with options.selector (defaults to [data-ulu-proxy-click-source])
|
|
59
|
+
* @param {Object} userOptions Options to override defaults
|
|
60
|
+
*/
|
|
61
|
+
export function setupProxy(proxy, userOptions) {
|
|
62
|
+
const options = Object.assign({}, currentDefaults, userOptions);
|
|
63
|
+
const child = proxy.querySelector(options.selector);
|
|
64
|
+
if (child) {
|
|
65
|
+
attachHandlers(proxy, child, options);
|
|
66
|
+
} else {
|
|
67
|
+
console.error("Unable to locate proxy click source", options.selector);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Main function for attaching behaviors that enable proxy click
|
|
73
|
+
* @param {Node} proxy The container who's click should proxy the click of inner element with options.selector (defaults to [data-ulu-proxy-click-source])
|
|
74
|
+
* @param {Node} child The element who is being proxied and will get clicked if the proxy is clicked (as long as not an interactive element within proxy)
|
|
75
|
+
* @param {Object} config Merged/final options object
|
|
76
|
+
*/
|
|
77
|
+
export function attachHandlers(proxy, child, config) {
|
|
78
|
+
const { selectorPreventBase: spb, selectorPrevent: sp } = config;
|
|
65
79
|
const selectorPrevent = `${ spb }${ sp ? `, ${ sp }` : "" }`;
|
|
66
80
|
let start, shouldProxy;
|
|
67
81
|
proxy.addEventListener("mousedown", ({ target, timeStamp }) => {
|
|
@@ -72,7 +86,7 @@ export function attachHandlers(proxy, child, options) {
|
|
|
72
86
|
}
|
|
73
87
|
});
|
|
74
88
|
proxy.addEventListener("mouseup", ({ timeStamp }) => {
|
|
75
|
-
if (shouldProxy && timeStamp - start <
|
|
89
|
+
if (shouldProxy && timeStamp - start < config.mousedownDurationPrevent) {
|
|
76
90
|
child.click();
|
|
77
91
|
}
|
|
78
92
|
});
|
package/js/ui/scroll-slider.js
CHANGED
|
@@ -2,29 +2,21 @@
|
|
|
2
2
|
* @module ui/scroll-slider
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
5
6
|
import { OverflowScroller } from "./overflow-scroller.js";
|
|
6
7
|
import { createPager } from "./overflow-scroller-pager.js";
|
|
7
|
-
import { getName } from "../events/index.js";
|
|
8
|
-
import { getDatasetOptionalJson } from "../utils/dom.js";
|
|
9
|
-
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* Scroll Slider Component Initializer
|
|
13
11
|
*/
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
controls: "data-ulu-scroll-slider-control-context"
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Utils for selecting things based on attributes
|
|
22
|
-
const attrSelector = key => `[${ attrs[key] }]`;
|
|
23
|
-
const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
|
|
24
|
-
|
|
12
|
+
export const initializer = new ComponentInitializer({
|
|
13
|
+
type: "scroll-slider",
|
|
14
|
+
baseAttribute: "data-ulu-scroll-slider"
|
|
15
|
+
});
|
|
25
16
|
|
|
17
|
+
const attrSelectorTrack = initializer.attributeSelector("track");
|
|
18
|
+
const attrSelectorControls = initializer.attributeSelector("control-context");
|
|
26
19
|
const instances = [];
|
|
27
|
-
|
|
28
20
|
const defaults = {
|
|
29
21
|
amount: createPager()
|
|
30
22
|
};
|
|
@@ -34,23 +26,25 @@ const defaults = {
|
|
|
34
26
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
35
27
|
*/
|
|
36
28
|
export function init() {
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
initializer.init({
|
|
30
|
+
withData: true,
|
|
31
|
+
events: ["pageModified"],
|
|
32
|
+
setup({ element, data, initialize }) {
|
|
33
|
+
setupSlider(element, data);
|
|
34
|
+
initialize();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function setupSlider(container) {
|
|
48
|
-
container.setAttribute(attrs.init, "");
|
|
49
|
-
const options = getDatasetOptionalJson(container, "uluScrollSlider");
|
|
50
|
-
const config = Object.assign({}, defaults, options);
|
|
39
|
+
/**
|
|
40
|
+
* Setup instance of scroll slider based on data-attributes
|
|
41
|
+
* @param {Node} container The scroll slider container
|
|
42
|
+
*/
|
|
43
|
+
function setupSlider(container, userOptions) {
|
|
44
|
+
const config = Object.assign({}, defaults, userOptions);
|
|
51
45
|
const elements = {
|
|
52
|
-
track: container.querySelector(
|
|
53
|
-
controls: container.querySelector(
|
|
46
|
+
track: container.querySelector(attrSelectorTrack),
|
|
47
|
+
controls: container.querySelector(attrSelectorControls)
|
|
54
48
|
};
|
|
55
49
|
instances.push(new OverflowScroller(elements, config));
|
|
56
50
|
}
|
package/js/ui/scrollpoint.js
CHANGED
|
@@ -1,81 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module ui/scrollpoint
|
|
3
|
+
* @description Module that uses intersection observer to add scrollpoint like behavior.
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* TODO:
|
|
8
|
-
* - Included a group option or attribute (on container)
|
|
9
|
-
// for things like anchor menus (one active in group at a time).
|
|
10
|
-
*
|
|
11
|
-
* How to link elements of group
|
|
12
|
-
* <div group={ groupName: test }>
|
|
13
|
-
* <div point={ groupName: test, mirror: ["#menu-link-1"] }>
|
|
14
|
-
* or
|
|
15
|
-
* <div group={ groupName: test, children: [".selector"] }>
|
|
16
|
-
* <div class=".selector">
|
|
17
|
-
*/
|
|
18
|
-
import { getName } from "../events/index.js";
|
|
19
|
-
import { getDatasetOptionalJson, getElement } from "../utils/dom.js";
|
|
6
|
+
import { ComponentInitializer } from "../utils/system.js";
|
|
20
7
|
import { logError } from "../utils/class-logger.js";
|
|
8
|
+
import { getElement } from "@ulu/utils/browser/dom.js";
|
|
9
|
+
|
|
10
|
+
// TODO:
|
|
11
|
+
// - Included a group option or attribute (on container), for things like anchor menus (one active in group at a time).
|
|
12
|
+
//
|
|
13
|
+
// How to link elements of group
|
|
14
|
+
// <div group={ groupName: test }>
|
|
15
|
+
// <div point={ groupName: test, mirror: ["#menu-link-1"] }>
|
|
16
|
+
// or
|
|
17
|
+
// <div group={ groupName: test, children: [".selector"] }>
|
|
18
|
+
// <div class=".selector">
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
21
|
+
* Scrollpoint Component Initializer
|
|
24
22
|
*/
|
|
25
|
-
export const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
point: "data-ulu-scrollpoint",
|
|
31
|
-
group: "data-ulu-scrollpoint-group",
|
|
32
|
-
groupAnchors: "data-ulu-scrollpoint-anchors"
|
|
33
|
-
// Goes on container for all items
|
|
34
|
-
// group: "data-ulu-scrollpoint-group"
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Utils for selecting things based on attributes
|
|
38
|
-
const attrSelector = key => `[${ attrs[key] }]`;
|
|
39
|
-
const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
|
|
40
|
-
const queryAllInitial = key => document.querySelectorAll(attrSelectorInitial(key));
|
|
23
|
+
export const initializer = new ComponentInitializer({
|
|
24
|
+
type: "scrollpoint",
|
|
25
|
+
baseAttribute: "data-ulu-scrollpoint"
|
|
26
|
+
});
|
|
41
27
|
|
|
42
28
|
/**
|
|
43
29
|
* Initialize everything in document
|
|
44
30
|
* - This will only initialize elements once, it is safe to call on page changes
|
|
45
31
|
*/
|
|
46
32
|
export function init() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const elements = queryAllInitial("point");
|
|
56
|
-
// const points = Array.from(elements).map(resolve);
|
|
57
|
-
// const groups = points
|
|
58
|
-
// .filter(({ config }) => config.groupName)
|
|
59
|
-
// .reduce((acc, point) => {
|
|
60
|
-
// const { groupName } = point.config;
|
|
61
|
-
// if (acc.has(groupName)) {
|
|
62
|
-
// acc.get(groupName).push(point);
|
|
63
|
-
// } else {
|
|
64
|
-
// acc.set(groupName, [point]);
|
|
65
|
-
// }
|
|
66
|
-
// }, new Map());
|
|
67
|
-
// const singles = points.filter(({ config }) => !config.groupName);
|
|
68
|
-
// groups.forEach(setupGroup);
|
|
69
|
-
elements.forEach(element => {
|
|
70
|
-
const elOptions = getDatasetOptionalJson(element, "uluScrollpoint");
|
|
71
|
-
const config = Object.assign({}, elOptions);
|
|
72
|
-
element.setAttribute(attrs.init, "");
|
|
73
|
-
new Scrollpoint(element, config);
|
|
33
|
+
initializer.init({
|
|
34
|
+
withData: true,
|
|
35
|
+
events: ["pageModified"],
|
|
36
|
+
setup({ element, data, initialize }) {
|
|
37
|
+
const config = Object.assign({}, data);
|
|
38
|
+
(new Scrollpoint(element, config));
|
|
39
|
+
initialize();
|
|
40
|
+
}
|
|
74
41
|
});
|
|
75
42
|
}
|
|
76
43
|
|
|
77
|
-
|
|
78
|
-
|
|
79
44
|
/**
|
|
80
45
|
* Single scrollpoint
|
|
81
46
|
* - Note "forward" and "reverse" refer to scroll directions
|
|
@@ -141,7 +106,7 @@ export class Scrollpoint {
|
|
|
141
106
|
/**
|
|
142
107
|
* Attribute name to set state info in
|
|
143
108
|
*/
|
|
144
|
-
attributeName: "data-scrollpoint-state",
|
|
109
|
+
attributeName: "data-ulu-scrollpoint-state",
|
|
145
110
|
/**
|
|
146
111
|
* Group multiple points, one active at a time (scroll menus)
|
|
147
112
|
*/
|
|
@@ -191,7 +156,7 @@ export class Scrollpoint {
|
|
|
191
156
|
};
|
|
192
157
|
this.setupObserver();
|
|
193
158
|
if (options.debug) {
|
|
194
|
-
|
|
159
|
+
initializer.log(this);
|
|
195
160
|
}
|
|
196
161
|
}
|
|
197
162
|
getClassname(suffix) {
|
|
@@ -233,7 +198,7 @@ export class Scrollpoint {
|
|
|
233
198
|
};
|
|
234
199
|
const config = this.getObserverOptions();
|
|
235
200
|
if (this.options.debug) {
|
|
236
|
-
|
|
201
|
+
initializer.log("IntersectionObserver (options)", config);
|
|
237
202
|
}
|
|
238
203
|
this.observer = new IntersectionObserver(handler, config);
|
|
239
204
|
this.observer.observe(this.element);
|