@newlogic-digital/ui 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +8 -12
  2. package/gulpfile.js +16 -168
  3. package/package.json +13 -8
  4. package/src/emails/email.css +15 -9
  5. package/src/emails/email.twig +7 -7
  6. package/src/icons.svg +32 -0
  7. package/src/main.json +14 -27
  8. package/src/scripts/Components/+.js +2 -2
  9. package/src/scripts/Components/CookieConsent.js +66 -64
  10. package/src/scripts/Components/Form.js +28 -21
  11. package/src/scripts/Layout/+.js +2 -1
  12. package/src/scripts/Layout/Header.js +18 -0
  13. package/src/scripts/Layout/Main.js +49 -45
  14. package/src/scripts/Libraries/+.js +12 -10
  15. package/src/scripts/Libraries/Anchor.js +18 -43
  16. package/src/scripts/Libraries/CookieConsent.js +37 -58
  17. package/src/scripts/Libraries/Dialog.js +56 -55
  18. package/src/scripts/Libraries/Drawer.js +23 -23
  19. package/src/scripts/Libraries/NativeSlider.js +86 -86
  20. package/src/scripts/Libraries/ReCaptcha.js +20 -18
  21. package/src/scripts/Libraries/Ripple.js +16 -32
  22. package/src/scripts/Libraries/Stimulus.js +30 -34
  23. package/src/scripts/Libraries/Swup.js +47 -50
  24. package/src/scripts/Libraries/Tabs.js +12 -18
  25. package/src/scripts/Libraries/Tippy.js +118 -0
  26. package/src/scripts/Ui/+.js +5 -3
  27. package/src/scripts/Ui/Checkbox.js +19 -0
  28. package/src/scripts/Ui/Input.js +188 -161
  29. package/src/scripts/Ui/Radio.js +23 -0
  30. package/src/scripts/Ui/Select.js +64 -37
  31. package/src/scripts/Ui/Text.js +25 -0
  32. package/src/scripts/Utils/Functions/+.js +6 -6
  33. package/src/scripts/Utils/Functions/dataValue.js +28 -25
  34. package/src/scripts/Utils/Functions/importScript.js +9 -11
  35. package/src/scripts/Utils/Functions/importStyle.js +18 -5
  36. package/src/scripts/Utils/Functions/inView.js +19 -21
  37. package/src/scripts/Utils/Functions/loadStimulus.js +22 -20
  38. package/src/scripts/Utils/cdn.js +6 -4
  39. package/src/scripts/Utils/global.js +10 -33
  40. package/src/scripts/main.js +6 -6
  41. package/src/styles/Components/CookieConsent.css +40 -179
  42. package/src/styles/Components/Dialog/Default.css +12 -15
  43. package/src/styles/Components/Form/CookieConsent.css +7 -12
  44. package/src/styles/Components/Item/+.css +1 -0
  45. package/src/styles/Layout/+.css +2 -0
  46. package/src/{templates/Components/Dialogs/.gitkeep → styles/Layout/Header.css} +0 -0
  47. package/src/styles/Layout/Main.css +28 -63
  48. package/src/styles/Layout/Nav.css +43 -0
  49. package/src/styles/Libraries/+.css +1 -1
  50. package/src/styles/Libraries/Datepicker.css +85 -39
  51. package/src/styles/Libraries/Dialog.css +6 -5
  52. package/src/styles/Libraries/Drawer.css +15 -15
  53. package/src/styles/Libraries/Hint.css +29 -23
  54. package/src/styles/Libraries/Lazysizes.css +2 -1
  55. package/src/styles/Libraries/NativeSlider.css +19 -18
  56. package/src/styles/Libraries/Ripple.css +8 -5
  57. package/src/styles/Libraries/Tabs.css +4 -4
  58. package/src/styles/Libraries/Tippy.css +87 -0
  59. package/src/styles/Sections/+.css +1 -0
  60. package/src/styles/Ui/+.css +5 -1
  61. package/src/styles/Ui/Badge.css +33 -19
  62. package/src/styles/Ui/Btn.css +80 -53
  63. package/src/styles/Ui/Checkbox.css +80 -41
  64. package/src/styles/Ui/Dropdown.css +5 -0
  65. package/src/styles/Ui/Heading.css +12 -12
  66. package/src/styles/Ui/Icon.css +27 -8
  67. package/src/styles/Ui/Image.css +23 -0
  68. package/src/styles/Ui/Input.css +295 -220
  69. package/src/styles/Ui/Label.css +14 -0
  70. package/src/styles/Ui/Link.css +3 -3
  71. package/src/styles/Ui/Notice.css +14 -16
  72. package/src/styles/Ui/Progress.css +10 -21
  73. package/src/styles/Ui/Radio.css +3 -8
  74. package/src/styles/Ui/Select.css +63 -112
  75. package/src/styles/Ui/Switch.css +70 -0
  76. package/src/styles/Ui/{Wsw.css → Text.css} +61 -80
  77. package/src/styles/Ui/Title.css +8 -4
  78. package/src/styles/Utils/default.css +75 -67
  79. package/src/styles/Utils/icons.css +9 -0
  80. package/src/styles/Utils/keyframes.css +182 -0
  81. package/src/styles/Utils/normalize.css +223 -0
  82. package/src/styles/Utils/print.css +1 -0
  83. package/src/styles/Utils/tailwind/base.css +15 -0
  84. package/src/styles/Utils/tailwind/gutters.css +264 -263
  85. package/src/styles/Utils/theme/main.css +24 -21
  86. package/src/styles/Utils/vars.css +58 -35
  87. package/src/styles/Utils/vendor.css +1 -2
  88. package/src/styles/main.css +6 -3
  89. package/src/styles/tailwind.css +1 -4
  90. package/src/templates/Components/CookieConsent.twig +30 -0
  91. package/src/templates/Components/Dialogs/Basic.twig +7 -3
  92. package/src/templates/Layout/Header.twig +42 -0
  93. package/src/templates/Layout/Main.twig +47 -64
  94. package/src/templates/Sections/Gdpr.twig +64 -0
  95. package/src/templates/Sections/Ui.twig +2104 -0
  96. package/src/templates/dialog-basic.twig +2 -2
  97. package/src/templates/gdpr.json +11 -0
  98. package/src/templates/index.json +8 -2
  99. package/src/templates/json-tippy.twig +16 -0
  100. package/src/templates/ui.json +11 -0
  101. package/CHANGELOG +0 -231
  102. package/src/icons/selection.json +0 -1
  103. package/src/icons/style.css +0 -171
  104. package/src/icons/variables.css +0 -31
  105. package/src/scripts/Ui/Wsw.js +0 -25
  106. package/src/scripts/Utils/Functions/bodyLoaded.js +0 -12
  107. package/src/styles/Libraries/Animate.css +0 -184
  108. package/src/styles/Utils/reference.css +0 -2
  109. package/src/styles/Utils/tailwind/content.css +0 -24
  110. package/src/styles/Utils/theme/vars.css +0 -19
  111. package/src/styles/preload.css +0 -29
  112. package/src/templates/Layout/Preload.twig +0 -21
  113. package/src/templates/Sections/.gitkeep +0 -0
@@ -1,80 +1,82 @@
1
- import {LibStimulus, Controller} from "../Libraries/Stimulus.js";
2
- import LibCookieConsent from "../Libraries/CookieConsent.js";
1
+ import { LibStimulus, Controller } from '../Libraries/Stimulus.js'
2
+ import LibCookieConsent from '../Libraries/CookieConsent.js'
3
3
 
4
- LibCookieConsent.init();
5
-
6
- LibStimulus.register("c-cookieconsent", class extends Controller {
4
+ LibStimulus.register('c-cookieconsent', class extends Controller {
7
5
  connect() {
8
- const selector = this.element;
6
+ const selector = this.element
7
+
8
+ if (document.querySelector('.c-form-cookieconsent') !== null) {
9
+ return
10
+ }
9
11
 
10
- if (localStorage.getItem('cookieconsent') === null) {
12
+ if (localStorage.getItem('lib-cookieconsent') === null || parseInt(localStorage.getItem('lib-cookieconsent-expire')) < Date.now()) {
11
13
  setTimeout(() => {
12
- selector._addDataValue("state", "active");
13
- selector.classList.add("is-animate");
14
- },1500);
14
+ selector._addDataValue('state', 'active')
15
+ selector.classList.add('is-animate')
16
+ }, 1500)
15
17
  }
16
18
 
17
- selector.addEventListener("click", () => {
18
- selector.classList.add("is-mobile-show");
19
- });
20
-
21
- selector.querySelector("[data-lib-cookieconsent-approve]").addEventListener("click", () => {
22
- LibCookieConsent.set("approve");
23
- selector.classList.remove("is-animate");
24
-
25
- setTimeout(function(){
26
- selector._removeDataValue("state", "active");
27
- selector.remove();
28
- },500);
29
- });
30
-
31
- selector.querySelector("[data-lib-cookieconsent-decline]").addEventListener("click", () => {
32
- LibCookieConsent.set("performance");
33
- selector.classList.remove("is-animate");
34
-
35
- setTimeout(function(){
36
- selector._removeDataValue("state", "active");
37
- selector.remove();
38
- },500);
39
- });
19
+ selector._hasDataValue('type', 'closable') &&
20
+ selector.addEventListener('click', e => {
21
+ if (e.target.closest('.c-cookieconsent > .wrp') === null) {
22
+ this.hide([])
23
+ }
24
+ })
25
+
26
+ selector.querySelector('[data-lib-cookieconsent-approve]').addEventListener('click', () => {
27
+ this.hide(['performance', 'marketing'])
28
+ })
29
+ }
30
+
31
+ hide(type) {
32
+ LibCookieConsent.set(type)
33
+ this.element.classList.remove('is-animate')
34
+
35
+ setTimeout(() => {
36
+ this.element._removeDataValue('state', 'active')
37
+ this.element.remove()
38
+ }, 500)
40
39
  }
41
- });
40
+ })
42
41
 
43
- LibStimulus.register("c-form-cookieconsent", class extends Controller {
42
+ LibStimulus.register('c-form-cookieconsent', class extends Controller {
44
43
  connect() {
45
- const selector = this.element;
46
-
47
- if (localStorage.getItem('cookieconsent') !== null) {
48
- if (localStorage.getItem('cookieconsent') === "approve") {
49
- let type = localStorage.getItem('cookieconsent_type');
50
- if (type !== null) {
51
- if (type === "performance") {
52
- selector.querySelector(`input[value="performance"]`).checked = true;
53
- } else {
54
- selector.querySelector(`input[value="approve"]`).checked = true;
55
- }
56
- } else {
57
- selector.querySelector(`input[value="approve"]`).checked = true;
44
+ const selector = this.element
45
+ const type = localStorage.getItem('lib-cookieconsent')
46
+
47
+ document.querySelector('.c-cookieconsent').classList.remove('is-animate')
48
+ document.querySelector('.c-cookieconsent')._removeDataValue('state', 'active')
49
+
50
+ if (type !== null) {
51
+ this.element.querySelectorAll('input:not([disabled])').forEach(input => {
52
+ input.checked = false
53
+ })
54
+
55
+ JSON.parse(type).forEach(type => {
56
+ if (selector.querySelector(`input[value="${type}"]`) !== null) {
57
+ selector.querySelector(`input[value="${type}"]`).checked = true
58
58
  }
59
- } else if (localStorage.getItem('cookieconsent') === "decline") {
60
- selector.querySelector(`input[value="decline"]`).checked = true;
61
- }
59
+ })
62
60
  }
63
61
 
64
- selector.addEventListener("submit", (e) => {
65
- e.preventDefault();
62
+ selector.addEventListener('submit', e => {
63
+ e.preventDefault()
66
64
 
67
- let value = (new FormData(e.target)).get("cookies");
65
+ const type = []
68
66
 
69
- if (value === "approve") {
70
- LibCookieConsent.set("marketing");
71
- location.reload();
72
- } else if (value === "performance") {
73
- LibCookieConsent.set("performance");
74
- location.reload();
75
- } else if (value === "decline") {
76
- LibCookieConsent.set("decline", () => location.reload());
77
- }
67
+ this.element.querySelectorAll('input:not([disabled])').forEach(input => {
68
+ input.checked && type.push(input.value)
69
+ })
70
+
71
+ LibCookieConsent.set(type)
72
+ location.reload()
78
73
  })
79
74
  }
80
- });
75
+
76
+ disconnect() {
77
+ if (localStorage.getItem('lib-cookieconsent') === null || parseInt(localStorage.getItem('lib-cookieconsent-expire')) < Date.now()) {
78
+ document.querySelector('.c-cookieconsent')._addDataValue('state', 'active')
79
+ document.querySelector('.c-cookieconsent').classList.add('is-animate')
80
+ }
81
+ }
82
+ })
@@ -1,26 +1,33 @@
1
- import {LibStimulus, Controller} from "../Libraries/Stimulus.js";
1
+ import { LibStimulus, Controller, getController } from '../Libraries/Stimulus.js'
2
2
 
3
- LibStimulus.register("c-form", class extends Controller {
4
- connect() {
5
- let element = this.element;
3
+ LibStimulus.register('c-form', class extends Controller {
4
+ validate(element, e) {
5
+ if (element.reportValidity() === false) {
6
+ e.preventDefault()
7
+ e.stopPropagation()
8
+ }
6
9
 
7
- if (typeof HTMLFormElement.prototype.reportValidity !== "undefined") {
8
- element.setAttribute("novalidate","");
9
- element.addEventListener('submit', (event) => {
10
- if (element.reportValidity() === false) {
11
- event.preventDefault();
12
- event.stopPropagation();
13
- }
10
+ element.querySelectorAll('.ui-input').forEach(element => {
11
+ getController(element, 'ui-input').validate(element, true)
12
+ })
14
13
 
15
- [...element.querySelectorAll(".ui-input")].map((element) => {
16
- console.log(element);
17
- LibStimulus.getController(element, "ui-input").validateInput(element, true)
18
- });
14
+ element.querySelectorAll('.ui-select:not([data-state*="active"]) select[required]').forEach(select => {
15
+ getController(select.parentNode, 'ui-select').validate(select.parentNode, select)
16
+ })
19
17
 
20
- [...element.querySelectorAll(`.ui-select:not([data-state*="active"]) select[required]`)].map((element) => {
21
- element.parentNode._addDataValue("state", "invalid");
22
- });
23
- }, false);
24
- }
18
+ element.querySelectorAll('[data-controller="ui-checkbox"] input:not([type="hidden"])').forEach(input => {
19
+ input.parentNode._removeDataValue('state', 'valid invalid')
20
+
21
+ if (input.checkValidity()) {
22
+ input.parentNode._addDataValue('state', 'valid')
23
+ } else {
24
+ input.parentNode._addDataValue('state', 'invalid')
25
+ }
26
+ })
27
+ }
28
+
29
+ connect() {
30
+ this.element.setAttribute('novalidate', '')
31
+ this.element.addEventListener('submit', e => this.validate(this.element, e))
25
32
  }
26
- });
33
+ })
@@ -1 +1,2 @@
1
- import './Main.js';
1
+ import './Header.js'
2
+ import './Main.js'
@@ -0,0 +1,18 @@
1
+ import { LibStimulus, Controller, getController } from '../Libraries/Stimulus.js'
2
+
3
+ LibStimulus.register('l-header', class extends Controller {
4
+ connect() {
5
+ if (document.querySelector('#l-nav') === null) {
6
+ this.element.insertAdjacentHTML('afterend', '<div id="l-nav" class="lib-drawer" data-lib-drawer-target="nav" data-action="scroll->lib-drawer#scroll"><div class="wrp_nav"><div class="wrp_nav_head"></div><div class="wrp_nav_body"></div></div></div>')
7
+
8
+ getController(document.body, 'lib-drawer').init()
9
+
10
+ const layoutNav = document.querySelector('#l-nav')
11
+ const logo = this.element.querySelector('.elm_header_logo').outerHTML
12
+ const nav = this.element.querySelector('.elm_header_nav').outerHTML
13
+
14
+ layoutNav.querySelector('.wrp_nav_head').insertAdjacentHTML('beforeend', logo)
15
+ layoutNav.querySelector('.wrp_nav_body').insertAdjacentHTML('beforeend', nav)
16
+ }
17
+ }
18
+ })
@@ -1,76 +1,80 @@
1
- import {LibStimulus, Controller, loadStimulus} from "../Libraries/Stimulus.js";
2
- import {bodyLoaded, importScript} from "../Utils/Functions/+.js";
3
- import LibRipple from "../Libraries/Ripple.js";
4
- import LibAnchor from "../Libraries/Anchor.js";
5
- import LibDialog from "../Libraries/Dialog.js";
6
- import LibTabs from "../Libraries/Tabs.js";
7
- import LibNativeSlider from "../Libraries/NativeSlider.js";
8
- import cdn from "../Utils/cdn.js";
1
+ import { LibStimulus, Controller, loadStimulus } from '../Libraries/Stimulus.js'
2
+ import { importScript } from '../Utils/Functions/+.js'
3
+ import LibRipple from '../Libraries/Ripple.js'
4
+ import LibAnchor from '../Libraries/Anchor.js'
5
+ import LibDialog from '../Libraries/Dialog.js'
6
+ import LibTippy from '../Libraries/Tippy.js'
7
+ import LibTabs from '../Libraries/Tabs.js'
8
+ import LibNativeSlider from '../Libraries/NativeSlider.js'
9
+ import cdn from '../Utils/cdn.js'
10
+
11
+ LibStimulus.register('lib', class extends Controller {
12
+ connect() {
13
+ if (!('scrollBehavior' in document.documentElement.style)) {
14
+ importScript(cdn.seamless).then(() => window.seamless.polyfill())
15
+ }
16
+ }
9
17
 
10
- LibStimulus.register("lib", class extends Controller {
11
18
  ripple(e) {
12
- LibRipple(e.currentTarget, e)
19
+ LibRipple(e)
13
20
  }
14
21
 
15
22
  anchor(e) {
16
- e.preventDefault();
23
+ e.preventDefault()
17
24
  LibAnchor.action(e.currentTarget)
18
25
  }
19
26
 
20
- darkMode(e) {
21
- let currentTarget = e.currentTarget;
22
-
27
+ darkMode() {
23
28
  if (document.documentElement.classList.contains('dark')) {
24
- localStorage.theme = 'light';
25
- document.documentElement.classList.remove('dark');
26
- currentTarget.classList.remove("icon-light");
29
+ localStorage.theme = 'light'
30
+ document.documentElement.classList.remove('dark')
27
31
  } else {
28
- localStorage.theme = 'dark';
29
- document.documentElement.classList.add('dark');
30
- currentTarget.classList.add("icon-light");
32
+ localStorage.theme = 'dark'
33
+ document.documentElement.classList.add('dark')
31
34
  }
32
35
  }
33
- });
36
+ })
34
37
 
35
- LibStimulus.register("lib-dialog", class extends Controller {
36
- connect() {
37
- let element = this.element;
38
-
39
- if (typeof element.dataset.libDialogOpen !== "undefined") {
40
- let url = element.getAttribute("data-action-url");
38
+ LibStimulus.register('lib-dialog', class extends Controller {
39
+ async connect() {
40
+ if (this.element.getAttribute('data-lib-dialog-open')) {
41
+ const url = this.element.getAttribute('data-action-url')
41
42
 
42
43
  if (url) {
43
- LibDialog.action(element, url, () => loadStimulus(document.querySelector(".lib-dialog")) );
44
+ await LibDialog.action(this.element, url, () => loadStimulus(document.querySelector('.lib-dialog')))
44
45
  } else {
45
- LibDialog.show(document.querySelector(element.dataset.libDialogOpen).innerHTML, () => loadStimulus(document.querySelector(".lib-dialog")));
46
+ await LibDialog.show(document.querySelector(this.element.getAttribute('data-lib-dialog-open')).innerHTML, () => loadStimulus(document.querySelector('.lib-dialog')))
46
47
  }
47
48
  }
48
49
  }
49
50
 
50
- show(e) {
51
- let element = e.currentTarget;
52
- let url = element.getAttribute("data-action-url");
51
+ async show({ currentTarget }) {
52
+ const url = currentTarget.getAttribute('data-action-url')
53
53
 
54
- LibDialog.action(element, url, () => loadStimulus(document.querySelector(".lib-dialog")));
54
+ await LibDialog.action(currentTarget, url)
55
55
  }
56
56
 
57
- hide() {
58
- LibDialog.hide();
57
+ async hide() {
58
+ await LibDialog.hide()
59
59
  }
60
- });
60
+ })
61
61
 
62
- LibStimulus.register("lib-tabs", class extends Controller {
62
+ LibStimulus.register('lib-tabs', class extends Controller {
63
63
  connect() {
64
- LibTabs(this.element);
64
+ LibTabs(this.element)
65
65
  }
66
- });
66
+ })
67
67
 
68
- LibStimulus.register("lib-ns", class extends Controller {
68
+ LibStimulus.register('lib-ns', class extends Controller {
69
69
  connect() {
70
- if (!('scrollBehavior' in document.documentElement.style)) {
71
- importScript(cdn.seamless).then(() => window.seamless.polyfill())
72
- }
70
+ LibNativeSlider(this.element.querySelector('[data-lib-ns]'), this.element)
71
+ }
72
+ })
73
+
74
+ LibStimulus.register('lib-tippy', class extends Controller {
75
+ connect() {
76
+ const attributes = this.element.getAttribute('data-lib-tippy')
73
77
 
74
- bodyLoaded(() => LibNativeSlider(this.element.querySelector("[data-lib-ns]"), this.element))
78
+ new LibTippy(this.element, attributes !== null ? attributes.replace(/\s/g, '').split(',') : undefined)
75
79
  }
76
- });
80
+ })
@@ -1,10 +1,12 @@
1
- export { default as Anchor } from './Anchor.js';
2
- export { default as CookieConsent } from './CookieConsent.js';
3
- export { default as Dialog } from './Dialog.js';
4
- import './Drawer.js';
5
- export { default as NativeSlider } from './NativeSlider.js';
6
- import './ReCaptcha.js';
7
- export { default as Ripple } from './Ripple.js';
8
- import './Stimulus.js';
9
- export { default as Swup } from './Swup.js';
10
- export { default as Tabs } from './Tabs.js';
1
+ export { default as Anchor } from './Anchor.js'
2
+ export { default as CookieConsent } from './CookieConsent.js'
3
+ export { default as Dialog } from './Dialog.js'
4
+ import './Drawer.js'
5
+ import './Fetch.js'
6
+ export { default as NativeSlider } from './NativeSlider.js'
7
+ import './ReCaptcha.js'
8
+ export { default as Ripple } from './Ripple.js'
9
+ import './Stimulus.js'
10
+ export { default as Swup } from './Swup.js'
11
+ export { default as Tabs } from './Tabs.js'
12
+ export { default as Tippy } from './Tippy.js'
@@ -1,60 +1,35 @@
1
1
  const LibAnchor = {
2
2
  animation: (element) => {
3
- let offset;
4
- let attr = "data-offset";
3
+ const offset = parseInt(window.getComputedStyle(document.documentElement).getPropertyValue('scroll-padding-top'))
5
4
 
6
- if (window.innerWidth > 960) {
7
- offset = 0;
8
- if (element.getAttribute(attr) !== null) {
9
- if (isNaN(parseInt(element.getAttribute(attr)))) {
10
- offset = document.querySelector(element.getAttribute(attr)).offsetHeight;
11
- } else {
12
- offset = parseInt(element.getAttribute(attr));
13
- }
14
- }
15
- }
16
-
17
- document.documentElement.scroll({top: element.offsetTop - offset, behavior: "smooth"});
5
+ document.documentElement.scroll({ top: element.offsetTop - offset, behavior: 'smooth' })
18
6
  },
19
7
  action: (element) => {
20
- let href = element.getAttribute("href");
21
-
22
- if (href === null) {
23
- href = element.getAttribute("data-action-href");
24
- }
25
-
26
- let id = document.querySelector("[id=" + href.replace('#', '') + "]");
27
- let options = element.getAttribute("data-action-options");
8
+ const href = element.href ? element.getAttribute('href') : element.getAttribute('data-action-href')
9
+ const data = element.dataset.libAnhor ? element.dataset.libAnhor : ''
10
+ const target = document.querySelector(`[id="${href.replace('#', '')}"]`)
28
11
 
29
- if (options === null) {
30
- options = "";
31
- }
32
-
33
- if (id !== null) {
34
- if (!(options.indexOf("mobile") > -1 && window.innerWidth > 960)) {
35
-
36
- LibAnchor.animation(id);
12
+ if (target !== null) {
13
+ if (!(data.includes('mobile') && window.innerWidth > 960)) {
14
+ LibAnchor.animation(target)
15
+ }
37
16
 
38
- if (options.indexOf("hash") > -1) {
39
- window.location.hash = id;
40
- }
17
+ if (!data.includes('silent')) {
18
+ window.location.hash = target.id
41
19
  }
42
20
  }
43
21
  },
44
22
  init: () => {
45
- let selector = [...document.querySelectorAll("[id]")];
23
+ const selector = document.querySelectorAll('[id]')
46
24
 
47
25
  if (selector[0] !== null) {
48
-
49
- selector.forEach((element) => {
50
- if (window.location.hash && element.getAttribute("id") === window.location.hash.replace('#', '')) {
51
- LibAnchor.animation(element);
26
+ selector.forEach(element => {
27
+ if (window.location.hash && element.getAttribute('id') === window.location.hash.replace('#', '')) {
28
+ LibAnchor.animation(element)
52
29
  }
53
- });
30
+ })
54
31
  }
55
32
  }
56
- };
57
-
58
- LibAnchor.init();
33
+ }
59
34
 
60
- export default LibAnchor;
35
+ export default LibAnchor
@@ -1,82 +1,61 @@
1
1
  const LibCookieConsent = {
2
2
  init: () => {
3
- if (localStorage.getItem('cookieconsent') === "approve") {
4
- let type = localStorage.getItem('cookieconsent_type');
5
- if (type !== null) {
6
- if (type === "performance") {
7
- LibCookieConsent.append("performance");
8
- } else if (type === "marketing") {
9
- LibCookieConsent.append("all");
10
- }
11
- } else {
12
- LibCookieConsent.append("all");
13
- }
14
- } else if (localStorage.getItem('cookieconsent') === null) {
15
- LibCookieConsent.append("all");
3
+ const type = localStorage.getItem('lib-cookieconsent')
4
+
5
+ if (type !== null) {
6
+ JSON.parse(type).forEach(type => LibCookieConsent.append(type))
16
7
  }
17
8
  },
18
- set: (type, callback) => {
19
- if (type === "approve") {
20
- localStorage.setItem("cookieconsent", "approve");
21
- LibCookieConsent.append("all");
22
-
23
- } else if (type === "performance") {
24
- localStorage.setItem("cookieconsent", "approve");
25
- localStorage.setItem("cookieconsent_type", "performance");
26
- LibCookieConsent.append("performance");
27
-
28
- } else if (type === "marketing") {
29
- localStorage.setItem("cookieconsent", "approve");
30
- localStorage.setItem("cookieconsent_type", "marketing");
31
- LibCookieConsent.append("all");
32
-
33
- } else if (type === "decline") {
34
- localStorage.setItem("cookieconsent", "decline");
35
- localStorage.removeItem("cookieconsent_type");
36
- LibCookieConsent.remove();
37
-
38
- if (callback) {
39
- callback();
40
- }
9
+ set: (type) => {
10
+ localStorage.setItem('lib-cookieconsent', JSON.stringify(type))
11
+ localStorage.setItem('lib-cookieconsent-expire', (Date.now() + 31556926 * 1000).toString())
12
+
13
+ if (type.length > 0) {
14
+ type.forEach(type => LibCookieConsent.append(type))
15
+ } else {
16
+ localStorage.setItem('lib-cookieconsent', JSON.stringify([]))
17
+ LibCookieConsent.remove()
41
18
  }
42
19
  },
43
20
  remove: () => {
44
- document.cookie.split(";").forEach(function(c) {
45
- document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
46
- });
21
+ document.cookie.split(';').forEach(c => {
22
+ document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')
23
+ })
47
24
  },
48
25
  append: (type) => {
49
- [...document.querySelectorAll("[data-lib-cookieconsent]")].map((elm) => {
50
- if (type === "all" || elm.getAttribute("data-lib-cookieconsent") === type) {
51
- let script = document.createElement("script");
52
- let delay = 0;
26
+ document.querySelectorAll('[data-lib-cookieconsent]').forEach(elm => {
27
+ if (type === 'all' || elm.getAttribute('data-lib-cookieconsent') === type) {
28
+ const script = document.createElement('script')
29
+ let delay = 0
53
30
 
54
- [...elm.attributes].forEach((attribute) => {
31
+ ;[...elm.attributes].forEach((attribute) => {
55
32
  if (attribute.specified) {
56
- if (attribute.name.indexOf("data-lib-cookieconsent") === -1 && attribute.name.indexOf("type") === -1) {
57
- script.setAttribute(attribute.name, attribute.value);
33
+ if (attribute.name.indexOf('data-lib-cookieconsent') === -1 && attribute.name.indexOf('type') === -1) {
34
+ script.setAttribute(attribute.name, attribute.value)
58
35
  }
59
36
  }
60
- });
37
+ })
61
38
 
62
- script.innerHTML = elm.innerHTML;
39
+ script.innerHTML = elm.innerHTML
63
40
 
64
- if (elm.getAttribute("data-lib-cookieconsent-delay")) {
65
- delay = parseInt(elm.getAttribute("data-lib-cookieconsent-delay"));
41
+ if (elm.getAttribute('data-lib-cookieconsent-delay')) {
42
+ delay = parseInt(elm.getAttribute('data-lib-cookieconsent-delay'))
66
43
  }
67
44
 
68
45
  setTimeout(() => {
69
- if (elm.closest("body") !== null) {
70
- document.body.appendChild(script);
71
- } else if (elm.closest("head") !== null) {
72
- document.head.appendChild(script);
46
+ if (elm.closest('body') !== null) {
47
+ document.body.appendChild(script)
48
+ } else if (elm.closest('head') !== null) {
49
+ document.head.appendChild(script)
73
50
  }
74
51
 
75
- elm.remove();
76
- }, delay);
52
+ elm.remove()
53
+ }, delay)
77
54
  }
78
55
  })
79
56
  }
80
- };
57
+ }
58
+
59
+ LibCookieConsent.init()
81
60
 
82
- export default LibCookieConsent;
61
+ export default LibCookieConsent