hr-design-system-handlebars 0.56.7 → 0.56.10
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 +36 -0
- package/build/helpers/ifCond.js +28 -0
- package/dist/assets/index.css +45 -32
- package/dist/assets/js/views/base/autosuggest/autoSuggest.feature.js +1 -1
- package/dist/assets/js/views/generic/hrQuery.subfeature.js +154 -54
- package/dist/views/base/autosuggest/autoSuggest.feature.js +1 -1
- package/dist/views/components/content_nav/content_nav.hbs +14 -51
- package/dist/views/components/content_nav/content_nav_container.hbs +18 -0
- package/dist/views/components/content_nav/content_nav_item.hbs +7 -6
- package/dist/views/components/content_nav/content_nav_list.hbs +4 -4
- package/dist/views/components/content_nav/dropdown.hbs +19 -16
- package/dist/views/components/site_header/header_alpine.js +26 -10
- package/dist/views/components/teaser/content_nav/teaser_content_nav.hbs +4 -16
- package/dist/views/generic/hrQuery.subfeature.js +154 -54
- package/package.json +1 -1
- package/src/assets/fixtures/teaser/teaser_content_nav_flow_100.json +3 -3
- package/src/assets/fixtures/teaser/teaser_content_nav_flow_autosuggest.json +183 -0
- package/src/assets/fixtures/teaser/teaser_content_nav_list_100.json +4 -5
- package/src/assets/fixtures/teaser/teaser_content_nav_list_autosuggest.json +181 -0
- package/src/assets/fixtures/teaser/teaser_content_nav_mixed_100.json +2 -2
- package/src/assets/fixtures/teaser/teaser_content_nav_mixed_autosuggest.json +1 -1
- package/src/stories/views/base/autosuggest/autoSuggest.feature.js +1 -1
- package/src/stories/views/components/content_nav/content_nav.hbs +14 -51
- package/src/stories/views/components/content_nav/content_nav_container.hbs +18 -0
- package/src/stories/views/components/content_nav/content_nav_item.hbs +7 -6
- package/src/stories/views/components/content_nav/content_nav_list.hbs +4 -4
- package/src/stories/views/components/content_nav/dropdown.hbs +19 -16
- package/src/stories/views/components/site_header/header_alpine.js +26 -10
- package/src/stories/views/components/teaser/content_nav/teaser_content_nav.hbs +4 -16
- package/src/stories/views/components/teaser/content_nav/teaser_content_nav.stories.mdx +14 -5
- package/src/stories/views/components/teaser/fixtures/teaser_content_nav_flow_100.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_content_nav_flow_autosuggest.json +1 -0
- package/src/stories/views/components/teaser/fixtures/teaser_content_nav_list_100.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_content_nav_list_autosuggest.json +1 -0
- package/src/stories/views/components/teaser/fixtures/teaser_content_nav_mixed_100.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_content_nav_mixed_autosuggest.json +1 -1
- package/src/stories/views/components/teaser/fixtures/teaser_group_100_contentNav.json +1 -1
- package/src/stories/views/generic/hrQuery.subfeature.js +154 -54
- package/tailwind.config.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
# v0.56.10 (Fri Sep 02 2022)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- DPE-1689 : new JSON Key 'isListOrFlow' and some design tweaks [#315](https://github.com/mumprod/hr-design-system-handlebars/pull/315) ([@StefanVesper](https://github.com/StefanVesper))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- SonicSoulSurfer ([@StefanVesper](https://github.com/StefanVesper))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v0.56.9 (Fri Sep 02 2022)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- Feature/dpe 1567 [#314](https://github.com/mumprod/hr-design-system-handlebars/pull/314) ([@szuelch](https://github.com/szuelch))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- [@szuelch](https://github.com/szuelch)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# v0.56.8 (Thu Sep 01 2022)
|
|
26
|
+
|
|
27
|
+
#### 🐛 Bug Fix
|
|
28
|
+
|
|
29
|
+
- Content nav part9 [#313](https://github.com/mumprod/hr-design-system-handlebars/pull/313) ([@StefanVesper](https://github.com/StefanVesper))
|
|
30
|
+
|
|
31
|
+
#### Authors: 1
|
|
32
|
+
|
|
33
|
+
- SonicSoulSurfer ([@StefanVesper](https://github.com/StefanVesper))
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
1
37
|
# v0.56.7 (Thu Sep 01 2022)
|
|
2
38
|
|
|
3
39
|
#### 🐛 Bug Fix
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const handlebars = require("handlebars");
|
|
2
|
+
module.exports = function (v1, operator, v2, options) {
|
|
3
|
+
var options = arguments[3];
|
|
4
|
+
switch (operator) {
|
|
5
|
+
case '==':
|
|
6
|
+
return (v1 == v2) ? options.fn(this) : options.inverse(this);
|
|
7
|
+
case '===':
|
|
8
|
+
return (v1 === v2) ? options.fn(this) : options.inverse(this);
|
|
9
|
+
case '!=':
|
|
10
|
+
return (v1 != v2) ? options.fn(this) : options.inverse(this);
|
|
11
|
+
case '!==':
|
|
12
|
+
return (v1 !== v2) ? options.fn(this) : options.inverse(this);
|
|
13
|
+
case '<':
|
|
14
|
+
return (v1 < v2) ? options.fn(this) : options.inverse(this);
|
|
15
|
+
case '<=':
|
|
16
|
+
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
|
|
17
|
+
case '>':
|
|
18
|
+
return (v1 > v2) ? options.fn(this) : options.inverse(this);
|
|
19
|
+
case '>=':
|
|
20
|
+
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
|
|
21
|
+
case '&&':
|
|
22
|
+
return (v1 && v2) ? options.fn(this) : options.inverse(this);
|
|
23
|
+
case '||':
|
|
24
|
+
return (v1 || v2) ? options.fn(this) : options.inverse(this);
|
|
25
|
+
default:
|
|
26
|
+
return options.inverse(this);
|
|
27
|
+
}
|
|
28
|
+
};
|
package/dist/assets/index.css
CHANGED
|
@@ -434,7 +434,7 @@ video {
|
|
|
434
434
|
--tw-scale-y: 1;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
.btn--secondary,
|
|
437
|
+
.btn--secondary, .\!shadow-\[1px_8px_9px_0px_rgba\(50\2c 50\2c 93\2c 0\.10\)\], .shadow-\[1px_4px_5px_0px_rgba\(50\2c 50\2c 93\2c 0\.10\)\], .shadow-inner, .shadow-xl {
|
|
438
438
|
--tw-ring-offset-shadow: 0 0 rgba(0,0,0,0);
|
|
439
439
|
--tw-ring-shadow: 0 0 rgba(0,0,0,0);
|
|
440
440
|
--tw-shadow: 0 0 rgba(0,0,0,0);
|
|
@@ -689,6 +689,14 @@ video {
|
|
|
689
689
|
.m-1 {
|
|
690
690
|
margin: 0.25rem;
|
|
691
691
|
}
|
|
692
|
+
.mx-2 {
|
|
693
|
+
margin-left: 0.5rem;
|
|
694
|
+
margin-right: 0.5rem;
|
|
695
|
+
}
|
|
696
|
+
.mx-0 {
|
|
697
|
+
margin-left: 0px;
|
|
698
|
+
margin-right: 0px;
|
|
699
|
+
}
|
|
692
700
|
.mx-4 {
|
|
693
701
|
margin-left: 1rem;
|
|
694
702
|
margin-right: 1rem;
|
|
@@ -709,10 +717,6 @@ video {
|
|
|
709
717
|
margin-left: 1px;
|
|
710
718
|
margin-right: 1px;
|
|
711
719
|
}
|
|
712
|
-
.mx-0 {
|
|
713
|
-
margin-left: 0px;
|
|
714
|
-
margin-right: 0px;
|
|
715
|
-
}
|
|
716
720
|
.mx-1\.5 {
|
|
717
721
|
margin-left: 0.375rem;
|
|
718
722
|
margin-right: 0.375rem;
|
|
@@ -733,12 +737,12 @@ video {
|
|
|
733
737
|
.mt-0 {
|
|
734
738
|
margin-top: 0px;
|
|
735
739
|
}
|
|
736
|
-
.mt-1 {
|
|
737
|
-
margin-top: 0.25rem;
|
|
738
|
-
}
|
|
739
740
|
.ml-2 {
|
|
740
741
|
margin-left: 0.5rem;
|
|
741
742
|
}
|
|
743
|
+
.mb-2 {
|
|
744
|
+
margin-bottom: 0.5rem;
|
|
745
|
+
}
|
|
742
746
|
.-mt-2 {
|
|
743
747
|
margin-top: -0.5rem;
|
|
744
748
|
}
|
|
@@ -748,9 +752,6 @@ video {
|
|
|
748
752
|
.-mt-10 {
|
|
749
753
|
margin-top: -2.5rem;
|
|
750
754
|
}
|
|
751
|
-
.mb-2 {
|
|
752
|
-
margin-bottom: 0.5rem;
|
|
753
|
-
}
|
|
754
755
|
.\!mb-0 {
|
|
755
756
|
margin-bottom: 0px !important;
|
|
756
757
|
}
|
|
@@ -1295,6 +1296,10 @@ video {
|
|
|
1295
1296
|
.bg-transparent {
|
|
1296
1297
|
background-color: transparent;
|
|
1297
1298
|
}
|
|
1299
|
+
.bg-grey-light {
|
|
1300
|
+
--tw-bg-opacity: 1;
|
|
1301
|
+
background-color: rgba(248, 248, 248, var(--tw-bg-opacity));
|
|
1302
|
+
}
|
|
1298
1303
|
.bg-gray-200 {
|
|
1299
1304
|
--tw-bg-opacity: 1;
|
|
1300
1305
|
background-color: rgba(229, 231, 235, var(--tw-bg-opacity));
|
|
@@ -1683,6 +1688,10 @@ video {
|
|
|
1683
1688
|
--tw-text-opacity: 1 !important;
|
|
1684
1689
|
color: rgba(20, 83, 45, var(--tw-text-opacity)) !important;
|
|
1685
1690
|
}
|
|
1691
|
+
.text-yellow-400 {
|
|
1692
|
+
--tw-text-opacity: 1;
|
|
1693
|
+
color: rgba(250, 204, 21, var(--tw-text-opacity));
|
|
1694
|
+
}
|
|
1686
1695
|
.text-white {
|
|
1687
1696
|
--tw-text-opacity: 1;
|
|
1688
1697
|
color: rgba(255, 255, 255, var(--tw-text-opacity));
|
|
@@ -1699,6 +1708,10 @@ video {
|
|
|
1699
1708
|
--tw-text-opacity: 1;
|
|
1700
1709
|
color: rgba(29, 78, 216, var(--tw-text-opacity));
|
|
1701
1710
|
}
|
|
1711
|
+
.text-grey-dark {
|
|
1712
|
+
--tw-text-opacity: 1;
|
|
1713
|
+
color: rgba(112, 112, 112, var(--tw-text-opacity));
|
|
1714
|
+
}
|
|
1702
1715
|
.text-blue-congress {
|
|
1703
1716
|
--tw-text-opacity: 1;
|
|
1704
1717
|
color: rgba(0, 82, 147, var(--tw-text-opacity));
|
|
@@ -1776,14 +1789,14 @@ video {
|
|
|
1776
1789
|
.opacity-80 {
|
|
1777
1790
|
opacity: 0.8;
|
|
1778
1791
|
}
|
|
1779
|
-
|
|
1780
|
-
--tw-shadow: 1px 8px 9px 0px rgba(50,50,93,0.10);
|
|
1781
|
-
--tw-shadow-colored: 1px 8px 9px 0px var(--tw-shadow-color);
|
|
1782
|
-
-webkit-box-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0), var(--tw-shadow);
|
|
1783
|
-
box-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0), var(--tw-shadow);
|
|
1784
|
-
box-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0), var(--tw-shadow);
|
|
1785
|
-
-webkit-box-shadow: var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)), var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)), var(--tw-shadow);
|
|
1786
|
-
box-shadow: var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)), var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)), var(--tw-shadow);
|
|
1792
|
+
.\!shadow-\[1px_8px_9px_0px_rgba\(50\2c 50\2c 93\2c 0\.10\)\] {
|
|
1793
|
+
--tw-shadow: 1px 8px 9px 0px rgba(50,50,93,0.10) !important;
|
|
1794
|
+
--tw-shadow-colored: 1px 8px 9px 0px var(--tw-shadow-color) !important;
|
|
1795
|
+
-webkit-box-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0), var(--tw-shadow) !important;
|
|
1796
|
+
box-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0), var(--tw-shadow) !important;
|
|
1797
|
+
box-shadow: 0 0 rgba(0,0,0,0), 0 0 rgba(0,0,0,0), var(--tw-shadow) !important;
|
|
1798
|
+
-webkit-box-shadow: var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)), var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)), var(--tw-shadow) !important;
|
|
1799
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)), var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)), var(--tw-shadow) !important;
|
|
1787
1800
|
}
|
|
1788
1801
|
.shadow-\[1px_4px_5px_0px_rgba\(50\2c 50\2c 93\2c 0\.10\)\] {
|
|
1789
1802
|
--tw-shadow: 1px 4px 5px 0px rgba(50,50,93,0.10);
|
|
@@ -1896,7 +1909,7 @@ video {
|
|
|
1896
1909
|
transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
|
|
1897
1910
|
}
|
|
1898
1911
|
.counter-reset {
|
|
1899
|
-
counter-reset:
|
|
1912
|
+
counter-reset: cnt1662131944866;
|
|
1900
1913
|
}
|
|
1901
1914
|
.placeholder-text-xs::-webkit-input-placeholder {
|
|
1902
1915
|
font-size: 0.75rem;
|
|
@@ -2279,7 +2292,7 @@ video {
|
|
|
2279
2292
|
--tw-ring-color: rgba(255, 255, 255, 0.5);
|
|
2280
2293
|
}
|
|
2281
2294
|
.-ordered {
|
|
2282
|
-
counter-increment:
|
|
2295
|
+
counter-increment: cnt1662131944866 1;
|
|
2283
2296
|
}
|
|
2284
2297
|
.-ordered::before {
|
|
2285
2298
|
position: absolute;
|
|
@@ -2296,7 +2309,7 @@ video {
|
|
|
2296
2309
|
letter-spacing: .0125em;
|
|
2297
2310
|
--tw-text-opacity: 1;
|
|
2298
2311
|
color: rgba(0, 0, 0, var(--tw-text-opacity));
|
|
2299
|
-
content: counter(
|
|
2312
|
+
content: counter(cnt1662131944866);
|
|
2300
2313
|
}
|
|
2301
2314
|
/*! purgecss start ignore */
|
|
2302
2315
|
:root,
|
|
@@ -2664,25 +2677,25 @@ video {
|
|
|
2664
2677
|
right: 0;
|
|
2665
2678
|
bottom: 0;
|
|
2666
2679
|
}
|
|
2667
|
-
.placeholder\:text-
|
|
2680
|
+
.placeholder\:text-grey-dark::-webkit-input-placeholder {
|
|
2668
2681
|
--tw-text-opacity: 1;
|
|
2669
|
-
color: rgba(
|
|
2682
|
+
color: rgba(112, 112, 112, var(--tw-text-opacity));
|
|
2670
2683
|
}
|
|
2671
|
-
.placeholder\:text-
|
|
2684
|
+
.placeholder\:text-grey-dark::-moz-placeholder {
|
|
2672
2685
|
--tw-text-opacity: 1;
|
|
2673
|
-
color: rgba(
|
|
2686
|
+
color: rgba(112, 112, 112, var(--tw-text-opacity));
|
|
2674
2687
|
}
|
|
2675
|
-
.placeholder\:text-
|
|
2688
|
+
.placeholder\:text-grey-dark:-ms-input-placeholder {
|
|
2676
2689
|
--tw-text-opacity: 1;
|
|
2677
|
-
color: rgba(
|
|
2690
|
+
color: rgba(112, 112, 112, var(--tw-text-opacity));
|
|
2678
2691
|
}
|
|
2679
|
-
.placeholder\:text-
|
|
2692
|
+
.placeholder\:text-grey-dark::-ms-input-placeholder {
|
|
2680
2693
|
--tw-text-opacity: 1;
|
|
2681
|
-
color: rgba(
|
|
2694
|
+
color: rgba(112, 112, 112, var(--tw-text-opacity));
|
|
2682
2695
|
}
|
|
2683
|
-
.placeholder\:text-
|
|
2696
|
+
.placeholder\:text-grey-dark::placeholder {
|
|
2684
2697
|
--tw-text-opacity: 1;
|
|
2685
|
-
color: rgba(
|
|
2698
|
+
color: rgba(112, 112, 112, var(--tw-text-opacity));
|
|
2686
2699
|
}
|
|
2687
2700
|
.first\:border-t:first-child {
|
|
2688
2701
|
border-top-width: 1px;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Initializer from 'initializer'
|
|
2
2
|
import loadFeature from 'loadFeature'
|
|
3
3
|
|
|
4
|
-
const hr$ = (selector, element)
|
|
4
|
+
const hr$ = function (selector, element) {
|
|
5
5
|
// if element set, use it
|
|
6
6
|
// if not use document as default
|
|
7
7
|
const rootElement = element || document
|
|
@@ -34,24 +34,19 @@ const hr$ = (selector, element) => {
|
|
|
34
34
|
return rootElement.querySelectorAll(selector)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const stripTags = text =>
|
|
38
|
-
if (text) {
|
|
39
|
-
return text.replace(/(<([^>]+)>)/gi, '')
|
|
40
|
-
}
|
|
41
|
-
return false
|
|
42
|
-
}
|
|
37
|
+
const stripTags = (text) => (text ? text.replace(/(<([^>]+)>)/gi, '') : false)
|
|
43
38
|
|
|
44
39
|
const getViewportWidth = () =>
|
|
45
40
|
Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
|
|
46
41
|
|
|
47
|
-
const isString = value => Object.prototype.toString.call(value) === '[object String]'
|
|
42
|
+
const isString = (value) => Object.prototype.toString.call(value) === '[object String]'
|
|
48
43
|
|
|
49
|
-
const isElementInViewport = el => {
|
|
44
|
+
const isElementInViewport = (el) => {
|
|
50
45
|
const rect = el.getBoundingClientRect()
|
|
51
46
|
return rect.top <= (document.documentElement || document.body).clientHeight
|
|
52
47
|
}
|
|
53
48
|
|
|
54
|
-
const getClosestParentWithTag = (tagName, node)
|
|
49
|
+
const getClosestParentWithTag = function (tagName, node) {
|
|
55
50
|
while (node !== null && node.tagName !== 'BODY') {
|
|
56
51
|
if (node.tagName && node.tagName.toLowerCase() === tagName) {
|
|
57
52
|
return node
|
|
@@ -61,7 +56,7 @@ const getClosestParentWithTag = (tagName, node) => {
|
|
|
61
56
|
return false
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
const getNodeWithClassInPath = (className, startNode)
|
|
59
|
+
const getNodeWithClassInPath = function (className, startNode) {
|
|
65
60
|
let node = startNode
|
|
66
61
|
|
|
67
62
|
while (node && node !== document) {
|
|
@@ -73,7 +68,7 @@ const getNodeWithClassInPath = (className, startNode) => {
|
|
|
73
68
|
return false
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
const isDescendant = (parent, child)
|
|
71
|
+
const isDescendant = function (parent, child) {
|
|
77
72
|
let node = child.parentNode
|
|
78
73
|
while (node !== null) {
|
|
79
74
|
if (node === parent) {
|
|
@@ -85,9 +80,9 @@ const isDescendant = (parent, child) => {
|
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
/* wartet x ms seit dem letzen aufruf bis es ausgeführt wird */
|
|
88
|
-
const debounce = (fn, delay)
|
|
83
|
+
const debounce = function (fn, delay) {
|
|
89
84
|
let timer = null
|
|
90
|
-
return (...args)
|
|
85
|
+
return function (...args) {
|
|
91
86
|
const context = this
|
|
92
87
|
clearTimeout(timer)
|
|
93
88
|
timer = setTimeout(() => {
|
|
@@ -96,11 +91,11 @@ const debounce = (fn, delay) => {
|
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
93
|
/* feuert all x ms */
|
|
99
|
-
const throttle = (fn, threshhold, scope)
|
|
94
|
+
const throttle = function (fn, threshhold, scope) {
|
|
100
95
|
threshhold = threshhold || 250
|
|
101
96
|
let last
|
|
102
97
|
let deferTimer
|
|
103
|
-
return (...args)
|
|
98
|
+
return function (...args) {
|
|
104
99
|
const context = scope || this
|
|
105
100
|
|
|
106
101
|
const now = +new Date()
|
|
@@ -128,10 +123,10 @@ const throttle = (fn, threshhold, scope) => {
|
|
|
128
123
|
canOnlyFireOnce(); // nada
|
|
129
124
|
*
|
|
130
125
|
*/
|
|
131
|
-
const once = (fn, context)
|
|
126
|
+
const once = function (fn, context) {
|
|
132
127
|
let result
|
|
133
128
|
|
|
134
|
-
return (...args)
|
|
129
|
+
return function (...args) {
|
|
135
130
|
if (fn) {
|
|
136
131
|
result = fn.apply(context || this, args)
|
|
137
132
|
fn = null
|
|
@@ -141,16 +136,25 @@ const once = (fn, context) => {
|
|
|
141
136
|
}
|
|
142
137
|
}
|
|
143
138
|
|
|
144
|
-
const listen = (eventName, fn, documentNode)
|
|
139
|
+
const listen = function (eventName, fn, documentNode, forceActive = false) {
|
|
145
140
|
documentNode = documentNode === undefined ? document : documentNode
|
|
146
141
|
|
|
142
|
+
// Use passive listeners to improve scrolling performance
|
|
143
|
+
// See:
|
|
144
|
+
// https://web.dev/uses-passive-event-listeners/
|
|
145
|
+
// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
146
|
+
|
|
147
|
+
const isTouchOrMouseEvent =
|
|
148
|
+
eventName === 'touchstart' || eventName === 'touchmove' || eventName === 'wheel'
|
|
149
|
+
const isPassive = Modernizr.passiveeventlisteners && !forceActive && isTouchOrMouseEvent
|
|
150
|
+
|
|
147
151
|
if (window.attachEvent) {
|
|
148
152
|
documentNode.attachEvent(eventName, fn)
|
|
149
153
|
} else {
|
|
150
|
-
documentNode.addEventListener(eventName, fn)
|
|
154
|
+
documentNode.addEventListener(eventName, fn, isPassive ? { passive: true } : false)
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
|
-
const unlisten = (eventName, fn, documentNode)
|
|
157
|
+
const unlisten = function (eventName, fn, documentNode) {
|
|
154
158
|
documentNode = documentNode === undefined ? document : documentNode
|
|
155
159
|
|
|
156
160
|
if (window.attachEvent) {
|
|
@@ -159,7 +163,7 @@ const unlisten = (eventName, fn, documentNode) => {
|
|
|
159
163
|
documentNode.removeEventListener(eventName, fn)
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
|
-
const listenOnce = (eventName, fn, documentNode)
|
|
166
|
+
const listenOnce = function (eventName, fn, documentNode) {
|
|
163
167
|
documentNode = documentNode === undefined ? document : documentNode
|
|
164
168
|
|
|
165
169
|
documentNode.addEventListener(eventName, fn, { once: true })
|
|
@@ -194,7 +198,7 @@ const setJSONCookie = (cookieName, cookieValue, cookieLifetime) => {
|
|
|
194
198
|
setCookie(cookieName, JSON.stringify(cookieValue), cookieLifetime)
|
|
195
199
|
}
|
|
196
200
|
|
|
197
|
-
const setCookie = (cookieName, cookieValue, cookieLifetime)
|
|
201
|
+
const setCookie = function (cookieName, cookieValue, cookieLifetime) {
|
|
198
202
|
let expires
|
|
199
203
|
|
|
200
204
|
const domain = getDomain()
|
|
@@ -211,7 +215,7 @@ const setCookie = (cookieName, cookieValue, cookieLifetime) => {
|
|
|
211
215
|
cookieName + '=' + cookieValue + ';expires=' + expires + ';domain=' + domain + ';path=/;'
|
|
212
216
|
}
|
|
213
217
|
|
|
214
|
-
const getJSONCookie = cookieName => {
|
|
218
|
+
const getJSONCookie = (cookieName) => {
|
|
215
219
|
let cookie
|
|
216
220
|
|
|
217
221
|
try {
|
|
@@ -221,12 +225,12 @@ const getJSONCookie = cookieName => {
|
|
|
221
225
|
return cookie
|
|
222
226
|
}
|
|
223
227
|
|
|
224
|
-
const getCookie = cookieName => {
|
|
228
|
+
const getCookie = (cookieName) => {
|
|
225
229
|
let cookieString = RegExp('' + cookieName + '[^;]+').exec(document.cookie)
|
|
226
230
|
return unescape(!!cookieString ? cookieString.toString().replace(/^[^=]+./, '') : '')
|
|
227
231
|
}
|
|
228
232
|
|
|
229
|
-
const deleteCookie = cookieName => {
|
|
233
|
+
const deleteCookie = (cookieName) => {
|
|
230
234
|
const domain = getDomain()
|
|
231
235
|
document.cookie =
|
|
232
236
|
cookieName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=' + domain + ';path=/;'
|
|
@@ -235,17 +239,18 @@ const deleteCookie = cookieName => {
|
|
|
235
239
|
const getDomain = () => {
|
|
236
240
|
return window.location.hostname.substring(window.location.hostname.indexOf('.') + 1)
|
|
237
241
|
}
|
|
238
|
-
const requestTimeout = (fn, delay)
|
|
239
|
-
var requestAnimFrame = (function() {
|
|
242
|
+
const requestTimeout = function (fn, delay) {
|
|
243
|
+
var requestAnimFrame = (function () {
|
|
240
244
|
return (
|
|
241
245
|
window.requestAnimationFrame ||
|
|
242
|
-
function(callback, element) {
|
|
246
|
+
function (callback, element) {
|
|
243
247
|
window.setTimeout(callback, 1000 / 60)
|
|
244
248
|
}
|
|
245
249
|
)
|
|
246
250
|
})(),
|
|
247
251
|
start = new Date().getTime(),
|
|
248
252
|
handle = {}
|
|
253
|
+
|
|
249
254
|
function loop() {
|
|
250
255
|
var current = new Date().getTime(),
|
|
251
256
|
delta = current - start
|
|
@@ -255,11 +260,12 @@ const requestTimeout = (fn, delay) => {
|
|
|
255
260
|
handle.value = requestAnimFrame(loop)
|
|
256
261
|
}
|
|
257
262
|
}
|
|
263
|
+
|
|
258
264
|
handle.value = requestAnimFrame(loop)
|
|
259
265
|
return handle
|
|
260
266
|
}
|
|
261
267
|
|
|
262
|
-
const replaceAnimated = (
|
|
268
|
+
const replaceAnimated = function (
|
|
263
269
|
elem,
|
|
264
270
|
data,
|
|
265
271
|
rescan,
|
|
@@ -269,7 +275,7 @@ const replaceAnimated = (
|
|
|
269
275
|
valueTo,
|
|
270
276
|
easing,
|
|
271
277
|
duration
|
|
272
|
-
)
|
|
278
|
+
) {
|
|
273
279
|
const property = 'opacity'
|
|
274
280
|
timeoutDelay = timeoutDelay || 800
|
|
275
281
|
valueFrom = valueFrom || 0.2
|
|
@@ -283,7 +289,7 @@ const replaceAnimated = (
|
|
|
283
289
|
|
|
284
290
|
elem.style[property] = valueFrom
|
|
285
291
|
|
|
286
|
-
requestTimeout(function() {
|
|
292
|
+
requestTimeout(function () {
|
|
287
293
|
if (data) {
|
|
288
294
|
elem.innerHTML = data
|
|
289
295
|
}
|
|
@@ -300,33 +306,33 @@ const replaceAnimated = (
|
|
|
300
306
|
}, timeoutDelay)
|
|
301
307
|
}
|
|
302
308
|
|
|
303
|
-
|
|
304
|
-
|
|
309
|
+
const getScrollY = () =>
|
|
310
|
+
window.pageYOffset !== undefined
|
|
311
|
+
? window.pageYOffset
|
|
312
|
+
: (document.documentElement || document.body.parentNode || document.body).scrollTop
|
|
305
313
|
|
|
306
|
-
|
|
307
|
-
|
|
314
|
+
//Funktion um X & Y Offset eines Elements zu ermitteln
|
|
315
|
+
const getElementOffset = function (el) {
|
|
316
|
+
let _x = 0
|
|
317
|
+
let _y = 0
|
|
318
|
+
_x = Math.round(el.getBoundingClientRect().left)
|
|
319
|
+
_y = Math.round(el.getBoundingClientRect().top)
|
|
308
320
|
|
|
309
|
-
|
|
310
|
-
|
|
321
|
+
return { top: _y, left: _x }
|
|
322
|
+
}
|
|
311
323
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
324
|
+
const reinitializeFeature = function (element) {
|
|
325
|
+
Initializer.run(element, loadFeature)
|
|
326
|
+
}
|
|
315
327
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
callback(null, e)
|
|
321
|
-
},
|
|
322
|
-
false
|
|
323
|
-
)
|
|
328
|
+
const removeScript = function (id) {
|
|
329
|
+
const element = document.getElementById(id)
|
|
330
|
+
if (element) {
|
|
331
|
+
element.parentNode.removeChild(element)
|
|
324
332
|
}
|
|
325
|
-
|
|
326
|
-
firstScriptTagInPage.parentNode.insertBefore(scriptTag, firstScriptTagInPage)
|
|
327
333
|
}
|
|
328
334
|
|
|
329
|
-
const loadScript = (id, scriptUrl, async, callback)
|
|
335
|
+
const loadScript = function (id, scriptUrl, async, callback) {
|
|
330
336
|
if (document.getElementById(id)) return
|
|
331
337
|
|
|
332
338
|
let firstScriptTagInPage = hr$('script')[0],
|
|
@@ -342,7 +348,7 @@ const loadScript = (id, scriptUrl, async, callback) => {
|
|
|
342
348
|
if (callback) {
|
|
343
349
|
scriptTag.addEventListener(
|
|
344
350
|
'load',
|
|
345
|
-
function(e) {
|
|
351
|
+
function (e) {
|
|
346
352
|
callback(null, e)
|
|
347
353
|
},
|
|
348
354
|
false
|
|
@@ -352,7 +358,94 @@ const loadScript = (id, scriptUrl, async, callback) => {
|
|
|
352
358
|
firstScriptTagInPage.parentNode.insertBefore(scriptTag, firstScriptTagInPage)
|
|
353
359
|
}
|
|
354
360
|
|
|
361
|
+
/*
|
|
362
|
+
* Fügt ein "style" bereich zum dokument hinzu
|
|
363
|
+
* und gibt eine referenz darauf zurück
|
|
364
|
+
* auf der man dann mit insertRule arbeiten kann
|
|
365
|
+
*/
|
|
366
|
+
const addStyle = function (css, mediaQuery) {
|
|
367
|
+
// Create the <style> tag
|
|
368
|
+
const style = document.createElement('style')
|
|
369
|
+
|
|
370
|
+
if (mediaQuery) {
|
|
371
|
+
style.setAttribute('media', mediaQuery)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Add the <style> element to the page
|
|
375
|
+
if (style.styleSheet) {
|
|
376
|
+
style.styleSheet.cssText = css || ''
|
|
377
|
+
} else {
|
|
378
|
+
style.appendChild(document.createTextNode(css || ''))
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
document.head.appendChild(style)
|
|
382
|
+
|
|
383
|
+
return style.sheet
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const simulateClickOn = function (elem) {
|
|
387
|
+
elem.dispatchEvent(
|
|
388
|
+
new MouseEvent('click', {
|
|
389
|
+
view: window,
|
|
390
|
+
bubbles: true,
|
|
391
|
+
cancelable: true,
|
|
392
|
+
})
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/*!
|
|
397
|
+
* Behaves the same as setInterval except uses requestAnimationFrame() where possible for better performance
|
|
398
|
+
* modified gist.github.com/joelambert/1002116
|
|
399
|
+
* the fallback function requestAnimFrame is incorporated
|
|
400
|
+
* gist.github.com/joelambert/1002116
|
|
401
|
+
* gist.github.com/englishextra/873c8f78bfda7cafc905f48a963df07b
|
|
402
|
+
* jsfiddle.net/englishextra/sxrzktkz/
|
|
403
|
+
* @param {Object} fn The callback function
|
|
404
|
+
* @param {Int} delay The delay in milliseconds
|
|
405
|
+
* requestInterval(fn, delay);
|
|
406
|
+
*/
|
|
407
|
+
const requestInterval = function (fn, delay) {
|
|
408
|
+
const requestAnimFrame = (function () {
|
|
409
|
+
return (
|
|
410
|
+
window.requestAnimationFrame ||
|
|
411
|
+
function (callback, element) {
|
|
412
|
+
window.setTimeout(callback, 1000 / 60)
|
|
413
|
+
}
|
|
414
|
+
)
|
|
415
|
+
})(),
|
|
416
|
+
handle = {}
|
|
417
|
+
let start = new Date().getTime()
|
|
418
|
+
|
|
419
|
+
function loop() {
|
|
420
|
+
handle.value = requestAnimFrame(loop)
|
|
421
|
+
const current = new Date().getTime(),
|
|
422
|
+
delta = current - start
|
|
423
|
+
if (delta >= delay) {
|
|
424
|
+
fn.call()
|
|
425
|
+
start = new Date().getTime()
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
handle.value = requestAnimFrame(loop)
|
|
430
|
+
return handle
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/*!
|
|
434
|
+
* Behaves the same as clearInterval except uses cancelRequestAnimationFrame()
|
|
435
|
+
* where possible for better performance
|
|
436
|
+
* gist.github.com/joelambert/1002116
|
|
437
|
+
* gist.github.com/englishextra/873c8f78bfda7cafc905f48a963df07b
|
|
438
|
+
* jsfiddle.net/englishextra/sxrzktkz/
|
|
439
|
+
* @param {Int|Object} handle function handle, or function
|
|
440
|
+
* clearRequestInterval(handle);
|
|
441
|
+
*/
|
|
442
|
+
const clearRequestInterval = (handle) =>
|
|
443
|
+
window.cancelAnimationFrame && handle
|
|
444
|
+
? window.cancelAnimationFrame(handle.value)
|
|
445
|
+
: window.clearInterval(handle)
|
|
446
|
+
|
|
355
447
|
export {
|
|
448
|
+
addStyle,
|
|
356
449
|
hr$,
|
|
357
450
|
stripTags,
|
|
358
451
|
getViewportWidth,
|
|
@@ -373,8 +466,15 @@ export {
|
|
|
373
466
|
setJSONCookie,
|
|
374
467
|
getJSONCookie,
|
|
375
468
|
getCookie,
|
|
469
|
+
getScrollY,
|
|
470
|
+
getElementOffset,
|
|
376
471
|
deleteCookie,
|
|
472
|
+
requestInterval,
|
|
473
|
+
clearRequestInterval,
|
|
377
474
|
requestTimeout,
|
|
378
475
|
replaceAnimated,
|
|
379
|
-
loadScript
|
|
476
|
+
loadScript,
|
|
477
|
+
removeScript,
|
|
478
|
+
reinitializeFeature,
|
|
479
|
+
simulateClickOn,
|
|
380
480
|
}
|