@iris.interactive/handcook 7.2.2-beta → 8.0.0-alpha.2

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 (60) hide show
  1. package/.gitlab-ci.yml +2 -2
  2. package/.nvmrc +1 -1
  3. package/.stylelintrc +89 -0
  4. package/README.md +1 -1
  5. package/biome.json +43 -0
  6. package/package.json +35 -40
  7. package/public/index.css +1 -0
  8. package/public/index.html +33 -36
  9. package/public/index.js +240 -0
  10. package/public/scripts/components/collapse/collapse.component.js +1 -82
  11. package/public/scripts/components/collapse/collapse.component.scss +4 -4
  12. package/public/scripts/components/dropdown/dropdown.component.js +1 -68
  13. package/public/scripts/components/lazyload/lazyload.component.js +1 -48
  14. package/public/scripts/components/lightbox/lightbox.component.js +1 -78
  15. package/public/scripts/components/modal/modal.component.js +1 -70
  16. package/public/scripts/components/nats/nats.component.js +1 -49
  17. package/public/scripts/components/overlay/overlay.component.js +1 -88
  18. package/public/scripts/components/popin/popin.component.js +1 -137
  19. package/public/scripts/components/scroll-reveal/scroll-reveal.component.js +1 -155
  20. package/public/scripts/components/scrollspy/scrollspy.component.js +1 -93
  21. package/public/scripts/components/share/share.component.js +1 -51
  22. package/public/scripts/components/slider/slider.component.js +1 -312
  23. package/public/scripts/components/smooth-scroll/smooth-scroll.component.js +1 -45
  24. package/public/scripts/components/tab/tab.component.js +1 -69
  25. package/public/scripts/components/toggle/toggle.component.js +1 -38
  26. package/public/scripts/components/tooltip/tooltip.component.js +1 -106
  27. package/public/scripts/enumerators/element.enum.js +1 -27
  28. package/public/scripts/enumerators/share.enum.js +1 -6
  29. package/public/scripts/enumerators/smooth-scroll.enum.js +1 -6
  30. package/public/scripts/enumerators/tooltip.enum.js +1 -12
  31. package/public/scripts/handcook.js +1 -36
  32. package/public/scripts/hc_swiper_v11.js +5 -0
  33. package/public/scripts/libraries/swiper-11/index.js +7 -0
  34. package/public/scripts/libraries/swiper-8/index.js +7 -0
  35. package/public/scripts/support/cookie.support.js +1 -22
  36. package/public/scripts/support/hash.support.js +1 -11
  37. package/public/scripts/support/toggle-html.support.js +1 -5
  38. package/public/scripts/support/wrap-select.support.js +1 -3
  39. package/public/styles/hc_swiper_v11.css +1 -0
  40. package/public/styles/hc_swiper_v11.js +1 -0
  41. package/public/styles/scss/_utils.scss +21 -17
  42. package/public/styles/scss/handcook.scss +5 -5
  43. package/public/styles/scss/mixins/_mixin-font.scss +19 -6
  44. package/public/styles/scss/mixins/_mixin-layout.scss +10 -7
  45. package/public/styles/scss/mixins/_mixin-style.scss +63 -60
  46. package/public/styles/scss/style.css +1 -172
  47. package/mix-manifest.json +0 -57
  48. package/public/scripts/components/collapse/collapse.component.min.js +0 -1
  49. package/public/scripts/components/dropdown/dropdown.component.min.js +0 -1
  50. package/public/scripts/components/lazyload/lazyload.component.min.js +0 -1
  51. package/public/scripts/components/lightbox/lightbox.component.min.js +0 -1
  52. package/public/scripts/components/modal/modal.component.min.js +0 -1
  53. package/public/scripts/components/scrollspy/scrollspy.component.min.js +0 -1
  54. package/public/scripts/components/slider/slider.component.min.js +0 -1
  55. package/public/scripts/components/smooth-scroll/smooth-scroll.component.min.js +0 -1
  56. package/public/scripts/components/tab/tab.component.min.js +0 -1
  57. package/public/scripts/components/toggle/toggle.component.min.js +0 -1
  58. package/public/scripts/components/tooltip/tooltip.component.min.js +0 -1
  59. package/public/scripts/index.js.LICENSE.txt +0 -1
  60. package/public/styles/style.css +0 -28
@@ -11,140 +11,4 @@
11
11
  * @author Stephan JAMBOU
12
12
  * @date 28/01/2022 14:27
13
13
  * @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
14
- */
15
-
16
- import ElementEnum from "../../enumerators/element.enum";
17
- import './popin.component.scss';
18
-
19
- export class HcPopin {
20
-
21
- showEvent;
22
- hideEvent;
23
-
24
- constructor(triggerAttribute = ElementEnum.popin) {
25
- document.querySelectorAll(triggerAttribute).forEach( element => {
26
- this.createEvent(element);
27
-
28
- //Set close cross
29
- let cross = document.createElement('button');
30
- cross.setAttribute('data-hc-popin-close', '');
31
- cross.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"></path></svg>'
32
- element.prepend(cross)
33
-
34
- //Set overlay
35
- if (element.hasAttribute('data-hc-popin-overlay')) {
36
- let overlay = document.createElement('div');
37
- overlay.setAttribute('data-hc-popin-overlay-background', '');
38
- element.prepend(overlay);
39
- element.parentNode.insertBefore(overlay, element);
40
- overlay.appendChild(element);
41
-
42
- //Close overlay
43
- let closeTriggerOverlay = document.querySelectorAll('[data-hc-popin-overlay-background]');
44
- closeTriggerOverlay[0].addEventListener('click', (e) => {
45
- const clickDetect = e.composedPath().includes(element)
46
- if (!clickDetect) {
47
- this.close(element);
48
- }
49
- });
50
- }
51
-
52
- //Set position
53
- if (element.hasAttribute('data-hc-popin-position-top')) {
54
- element.style.top = element.getAttribute('data-hc-popin-position-top');
55
- }
56
-
57
- if (element.hasAttribute('data-hc-popin-position-bottom')) {
58
- element.style.bottom = element.getAttribute('data-hc-popin-position-bottom');
59
- }
60
-
61
- if (element.hasAttribute('data-hc-popin-position-left')) {
62
- element.style.left = element.getAttribute('data-hc-popin-position-left');
63
- }
64
-
65
- if (element.hasAttribute('data-hc-popin-position-right')) {
66
- element.style.right = element.getAttribute('data-hc-popin-position-right');
67
- }
68
-
69
- //Default position
70
- if (!element.hasAttribute('data-hc-popin-position-top') && !element.hasAttribute('data-hc-popin-position-top')) {
71
- element.style.bottom = '20px';
72
- }
73
-
74
- if (!element.hasAttribute('data-hc-popin-position-left') && !element.hasAttribute('data-hc-popin-position-right')) {
75
- element.style.right = '20px';
76
- }
77
-
78
- //Mode (trigger or auto [default])
79
- if (element.hasAttribute('data-hc-popin-mode') && element.getAttribute('data-hc-popin-mode') === 'trigger') {
80
- document.querySelectorAll('[data-hc-popin-trigger]').forEach(trigger => {
81
- trigger.addEventListener('click', (e) => {
82
- let target = e.currentTarget.getAttribute('href');
83
- this.show(document.getElementById(target.substring(1)));
84
- });
85
- });
86
- } else {
87
- //Set delay on mode auto
88
- if (element.hasAttribute('data-hc-popin-delay')) {
89
- setTimeout(() => {
90
- this.show(element);
91
- }, element.getAttribute('data-hc-popin-delay'));
92
- } else {
93
- this.show(element);
94
- }
95
- }
96
-
97
- //Close cross
98
- let closeTrigger = element.querySelectorAll('[data-hc-popin-close]');
99
- closeTrigger[0].addEventListener('click', (e) => {
100
- e.preventDefault();
101
- this.close(element);
102
- });
103
- });
104
- }
105
-
106
- show(element) {
107
- //On affiche la popin
108
- element.classList.add('hc-popin-show');
109
-
110
- //On affiche l'overlay si présent
111
- let parent = element.parentNode;
112
- if (parent.hasAttribute('data-hc-popin-overlay-background')) {
113
- parent.classList.add('hc-popin-overlay-show');
114
- }
115
-
116
- document.dispatchEvent(this.showEvent);
117
- }
118
-
119
- close(element) {
120
- //On cache la popin
121
- element.classList.remove('hc-popin-show');
122
-
123
- //On cache l'overlay si présent
124
- let parent = element.parentNode;
125
- if (parent.hasAttribute('data-hc-popin-overlay-background')) {
126
- parent.classList.remove('hc-popin-overlay-show');
127
- }
128
-
129
- document.dispatchEvent(this.hideEvent);
130
- }
131
-
132
- createEvent(element) {
133
- this.showEvent = new CustomEvent("show.hc.popin", {
134
- detail: {
135
- element
136
- }
137
- } );
138
-
139
- this.hideEvent = new CustomEvent("hide.hc.popin", {
140
- detail: {
141
- element
142
- }
143
- } );
144
- }
145
- }
146
-
147
- const hc_popin = function (trigger) {
148
- new HcPopin(trigger);
149
- }
150
- export default hc_popin;
14
+ */import t from"../../enumerators/element.enum";import"./popin.component.scss";export class HcPopin{showEvent;hideEvent;constructor(e=t.popin){for(let t of e){this.createEvent(t);let e=document.createElement("button");if(e.setAttribute("data-hc-popin-close",""),e.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"></path></svg>',t.prepend(e),t.hasAttribute("data-hc-popin-overlay")){let e=document.createElement("div");e.setAttribute("data-hc-popin-overlay-background",""),t.prepend(e),t.parentNode.insertBefore(e,t),e.appendChild(t),document.querySelectorAll("[data-hc-popin-overlay-background]")[0].addEventListener("click",e=>{e.composedPath().includes(t)||this.close(t)})}if(t.hasAttribute("data-hc-popin-position-top")&&(t.style.top=t.getAttribute("data-hc-popin-position-top")),t.hasAttribute("data-hc-popin-position-bottom")&&(t.style.bottom=t.getAttribute("data-hc-popin-position-bottom")),t.hasAttribute("data-hc-popin-position-left")&&(t.style.left=t.getAttribute("data-hc-popin-position-left")),t.hasAttribute("data-hc-popin-position-right")&&(t.style.right=t.getAttribute("data-hc-popin-position-right")),t.hasAttribute("data-hc-popin-position-top")||t.hasAttribute("data-hc-popin-position-top")||(t.style.bottom="20px"),t.hasAttribute("data-hc-popin-position-left")||t.hasAttribute("data-hc-popin-position-right")||(t.style.right="20px"),t.hasAttribute("data-hc-popin-mode")&&"trigger"===t.getAttribute("data-hc-popin-mode"))for(let t of document.querySelectorAll("[data-hc-popin-trigger]"))t.addEventListener("click",t=>{let e=t.currentTarget.getAttribute("href");this.show(document.getElementById(e.substring(1)))});else t.hasAttribute("data-hc-popin-delay")?setTimeout(()=>{this.show(t)},t.getAttribute("data-hc-popin-delay")):this.show(t);t.querySelectorAll("[data-hc-popin-close]")[0].addEventListener("click",e=>{e.preventDefault(),this.close(t)})}}show(t){t.classList.add("hc-popin-show");let e=t.parentNode;e.hasAttribute("data-hc-popin-overlay-background")&&e.classList.add("hc-popin-overlay-show"),document.dispatchEvent(this.showEvent)}close(t){t.classList.remove("hc-popin-show");let e=t.parentNode;e.hasAttribute("data-hc-popin-overlay-background")&&e.classList.remove("hc-popin-overlay-show"),document.dispatchEvent(this.hideEvent)}createEvent(t){this.showEvent=new CustomEvent("show.hc.popin",{detail:{element:t}}),this.hideEvent=new CustomEvent("hide.hc.popin",{detail:{element:t}})}}let hc_popin=t=>{new HcPopin(t)};export default hc_popin;
@@ -11,158 +11,4 @@
11
11
  * @author Stephan JAMBOU
12
12
  * @date 11/10/2023 18:27
13
13
  * @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
14
- */
15
-
16
- import ElementEnum from "../../enumerators/element.enum";
17
- import "./scroll-reveal.component.scss";
18
-
19
- export class HcScrollReveal {
20
-
21
- //Default
22
- static distanceDefault = getComputedStyle(document.documentElement).getPropertyValue('--hc-scroll-reveal-distance');
23
- static delayDefault = getComputedStyle(document.documentElement).getPropertyValue('--hc-scroll-reveal-delay');
24
- static durationDefault = getComputedStyle(document.documentElement).getPropertyValue('--hc-scroll-reveal-duration');
25
- static intervalDefault = getComputedStyle(document.documentElement).getPropertyValue('--hc-scroll-reveal-interval');
26
- static originDefault = getComputedStyle(document.documentElement).getPropertyValue('--hc-scroll-reveal-origin');
27
- static timingFunctionDefault = getComputedStyle(document.documentElement).getPropertyValue('--hc-scroll-reveal-timing-function');
28
-
29
- constructor() {
30
-
31
- //Get all scrollreveal elements
32
- const items = Array.prototype.slice.call(document.querySelectorAll(ElementEnum.scrollReveal)).concat(Array.prototype.slice.call(document.querySelectorAll(ElementEnum.scrollRevealChildren)));
33
-
34
- //Init scrollreveal
35
- HcScrollReveal.init(items);
36
- }
37
-
38
- static init(items) {
39
- let childOffset = 0;
40
- let childRowCount = 1;
41
- const observerOptions = {
42
- root: null,
43
- rootMargin: '-20px 0px -20px 0px',
44
- threshold: 0
45
- }
46
-
47
- const observer = new IntersectionObserver((entries) => {
48
- entries.forEach(entry => {
49
- if (entry.isIntersecting) {
50
- if (entry.target.classList.contains('hc-sr')) {
51
- entry.target.classList.add('hc-sr--show');
52
- }
53
- } else {
54
- entry.target.classList.add('hc-sr');
55
- }
56
- });
57
- }, observerOptions)
58
-
59
- items.forEach(item => {
60
- let options;
61
- let isChild = false;
62
-
63
- //Get options
64
- if (!item.hasAttribute('data-hc-scroll-reveal-parent') && !item.hasAttribute('data-hc-scroll-reveal') && !item.hasAttribute('data-hc-noscroll-reveal')) {
65
- let parent = item.parentElement;
66
- isChild = true;
67
- options = HcScrollReveal.getOptions(parent);
68
- } else {
69
- options = HcScrollReveal.getOptions(item);
70
- }
71
-
72
- //Apply options if different than default
73
- if (options.distance !== HcScrollReveal.distanceDefault && options.distance !== '') {
74
- item.style.setProperty('--hc-scroll-reveal-distance', options.distance);
75
- }
76
-
77
- if (options.delay !== HcScrollReveal.delayDefault && options.delay !== null) {
78
- item.style.setProperty('--hc-scroll-reveal-delay', options.delay);
79
- }
80
-
81
- if (options.duration !== HcScrollReveal.durationDefault && options.duration !== null) {
82
- item.style.setProperty('--hc-scroll-reveal-duration', options.duration);
83
- }
84
-
85
- if (options.timing !== HcScrollReveal.timingFunctionDefault && options.timing !== null) {
86
- item.style.setProperty('--hc-scroll-reveal-timing-function', options.timing);
87
- }
88
-
89
- //Interval on items in same row
90
- if (options.interval !== null && options.delay !== null) {
91
- if (isChild) {
92
- if (childOffset == item.offsetTop) {
93
- let delayValue = parseInt(options.delay.replace('ms', ''));
94
- let intervalValue = parseInt(options.interval.replace('ms', ''));
95
- let newDelay = delayValue + (intervalValue * childRowCount);
96
- options.delay = newDelay+'ms';
97
- childRowCount++;
98
- } else {
99
- childOffset = item.offsetTop;
100
- childRowCount = 1;
101
- }
102
-
103
- item.style.setProperty('--hc-scroll-reveal-delay', options.delay);
104
- }
105
- }
106
-
107
- //Generate translate according to origin
108
- if (options.origin !== '') {
109
- item.style.setProperty('--hc-scroll-reveal-origin', options.origin);
110
-
111
- if (options.origin == 'top') {
112
- item.style.setProperty('--hc-scroll-reveal-translate', 'translateY(calc(var(--hc-scroll-reveal-distance) * -1))');
113
- } else if(options.origin == 'left') {
114
- item.style.setProperty('--hc-scroll-reveal-translate', 'translateX(calc(var(--hc-scroll-reveal-distance) * -1))');
115
- } else if(options.origin == 'right') {
116
- item.style.setProperty('--hc-scroll-reveal-translate', 'translateX(var(--hc-scroll-reveal-distance))');
117
- } else {
118
- item.style.setProperty('--hc-scroll-reveal-translate', 'translateY(var(--hc-scroll-reveal-distance))');
119
- }
120
- }
121
-
122
- //Observe
123
- observer.observe(item);
124
- });
125
- }
126
-
127
- static getOptions(item) {
128
- let options = {
129
- distance: HcScrollReveal.distanceDefault,
130
- delay: HcScrollReveal.delayDefault,
131
- duration: HcScrollReveal.durationDefault,
132
- interval: HcScrollReveal.intervalDefault,
133
- origin: HcScrollReveal.originDefault,
134
- timing: HcScrollReveal.timingFunctionDefault
135
- }
136
-
137
- if (item.hasAttribute('data-hc-scroll-reveal-distance')) {
138
- options.distance = item.getAttribute('data-hc-scroll-reveal-distance');
139
- }
140
-
141
- if (item.hasAttribute('data-hc-scroll-reveal-delay')) {
142
- options.delay = item.getAttribute('data-hc-scroll-reveal-delay')+'ms';
143
- }
144
-
145
- if (item.hasAttribute('data-hc-scroll-reveal-duration')) {
146
- options.duration = item.getAttribute('data-hc-scroll-reveal-duration')+'ms';
147
- }
148
-
149
- if (item.hasAttribute('data-hc-scroll-reveal-interval')) {
150
- options.interval = item.getAttribute('data-hc-scroll-reveal-interval')+'ms';
151
- }
152
-
153
- if (item.hasAttribute('data-hc-scroll-reveal-origin')) {
154
- options.origin = item.getAttribute('data-hc-scroll-reveal-origin');
155
- }
156
-
157
- if (item.hasAttribute('data-hc-scroll-reveal-timing-function')) {
158
- options.timing = item.getAttribute('data-hc-scroll-reveal-timing-function');
159
- }
160
-
161
- return options;
162
- }
163
- }
164
-
165
- const hc_scroll_reveal = function () {
166
- return new HcScrollReveal();
167
- }
168
- export default hc_scroll_reveal;
14
+ */import e from"../../enumerators/element.enum";import"./scroll-reveal.component.scss";export class HcScrollReveal{static distanceDefault=getComputedStyle(document.documentElement).getPropertyValue("--hc-scroll-reveal-distance");static delayDefault=getComputedStyle(document.documentElement).getPropertyValue("--hc-scroll-reveal-delay");static durationDefault=getComputedStyle(document.documentElement).getPropertyValue("--hc-scroll-reveal-duration");static intervalDefault=getComputedStyle(document.documentElement).getPropertyValue("--hc-scroll-reveal-interval");static originDefault=getComputedStyle(document.documentElement).getPropertyValue("--hc-scroll-reveal-origin");static timingFunctionDefault=getComputedStyle(document.documentElement).getPropertyValue("--hc-scroll-reveal-timing-function");constructor(){let t=Array.prototype.slice.call(document.querySelectorAll(e.scrollReveal)).concat(Array.prototype.slice.call(document.querySelectorAll(e.scrollRevealChildren)));HcScrollReveal.init(t)}static init(e){let t=0,l=1,r=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting?t.target.classList.contains("hc-sr")&&t.target.classList.add("hc-sr--show"):t.target.classList.add("hc-sr")},{root:null,rootMargin:"-20px 0px -20px 0px",threshold:0});for(let a of e){let e;let c=!1;if(a.hasAttribute("data-hc-scroll-reveal-parent")||a.hasAttribute("data-hc-scroll-reveal")||a.hasAttribute("data-hc-noscroll-reveal"))e=HcScrollReveal.getOptions(a);else{let t=a.parentElement;c=!0,e=HcScrollReveal.getOptions(t)}if(e.distance!==HcScrollReveal.distanceDefault&&""!==e.distance&&a.style.setProperty("--hc-scroll-reveal-distance",e.distance),e.delay!==HcScrollReveal.delayDefault&&null!==e.delay&&a.style.setProperty("--hc-scroll-reveal-delay",e.delay),e.duration!==HcScrollReveal.durationDefault&&null!==e.duration&&a.style.setProperty("--hc-scroll-reveal-duration",e.duration),e.timing!==HcScrollReveal.timingFunctionDefault&&null!==e.timing&&a.style.setProperty("--hc-scroll-reveal-timing-function",e.timing),null!==e.interval&&null!==e.delay&&c){if(t===a.offsetTop){let t=Number.parseInt(e.delay.replace("ms",""))+Number.parseInt(e.interval.replace("ms",""))*l;e.delay=`${t}ms`,l++}else t=a.offsetTop,l=1;a.style.setProperty("--hc-scroll-reveal-delay",e.delay)}""!==e.origin&&(a.style.setProperty("--hc-scroll-reveal-origin",e.origin),"top"===e.origin?a.style.setProperty("--hc-scroll-reveal-translate","translateY(calc(var(--hc-scroll-reveal-distance) * -1))"):"left"===e.origin?a.style.setProperty("--hc-scroll-reveal-translate","translateX(calc(var(--hc-scroll-reveal-distance) * -1))"):"right"===e.origin?a.style.setProperty("--hc-scroll-reveal-translate","translateX(var(--hc-scroll-reveal-distance))"):a.style.setProperty("--hc-scroll-reveal-translate","translateY(var(--hc-scroll-reveal-distance))")),r.observe(a)}}static getOptions(e){let t={distance:HcScrollReveal.distanceDefault,delay:HcScrollReveal.delayDefault,duration:HcScrollReveal.durationDefault,interval:HcScrollReveal.intervalDefault,origin:HcScrollReveal.originDefault,timing:HcScrollReveal.timingFunctionDefault};return e.hasAttribute("data-hc-scroll-reveal-distance")&&(t.distance=e.getAttribute("data-hc-scroll-reveal-distance")),e.hasAttribute("data-hc-scroll-reveal-delay")&&(t.delay=`${e.getAttribute("data-hc-scroll-reveal-delay")}ms`),e.hasAttribute("data-hc-scroll-reveal-duration")&&(t.duration=`${e.getAttribute("data-hc-scroll-reveal-duration")}ms`),e.hasAttribute("data-hc-scroll-reveal-interval")&&(t.interval=`${e.getAttribute("data-hc-scroll-reveal-interval")}ms`),e.hasAttribute("data-hc-scroll-reveal-origin")&&(t.origin=e.getAttribute("data-hc-scroll-reveal-origin")),e.hasAttribute("data-hc-scroll-reveal-timing-function")&&(t.timing=e.getAttribute("data-hc-scroll-reveal-timing-function")),t}}let hc_scroll_reveal=()=>new HcScrollReveal;export default hc_scroll_reveal;
@@ -1,93 +1 @@
1
- import ElementEnum from "../../enumerators/element.enum";
2
-
3
- export class HcScrollspy {
4
-
5
- activeEvent;
6
-
7
- constructor(elements = ElementEnum.scrollspy) {
8
- document.querySelectorAll(elements).forEach(element => {
9
- const navElement = document.querySelector(element.dataset.hcScrollspy);
10
- const shift = element.getAttribute('data-hc-scrollspy-shift') !== null ? parseInt(element.getAttribute('data-hc-scrollspy-shift')) : 0;
11
- if (navElement !== null) {
12
- this.activeItem(navElement, ElementEnum.scrollspyNavItem, shift);
13
- }
14
- });
15
- }
16
-
17
- getPartsConfig(navElement, childElement) {
18
- let offsetTop = [];
19
- navElement.querySelectorAll(childElement).forEach(item => {
20
- const part = item.getAttribute('href') !== null ? {
21
- id: item.getAttribute('href'),
22
- value: 0,
23
- attribute: 'href'
24
- } : {
25
- id: item.getAttribute(ElementEnum.scrollspyNavItemHref),
26
- value: 0,
27
- attribute: ElementEnum.scrollspyNavItemHref
28
- };
29
- if (document.querySelector(part.id) !== null) {
30
- // part.value = document.querySelector(part.id).offsetTop;
31
- part.value = this.getOffset(document.querySelector(part.id)).top;
32
- offsetTop = [
33
- ...offsetTop,
34
- part
35
- ];
36
- }
37
- });
38
- return offsetTop;
39
- }
40
-
41
- activeItem(navElement, childElement, shift = 0) {
42
- let item = navElement.querySelector(`${childElement}:first-child`);
43
- window.addEventListener('scroll', () => {
44
- const partsConfig = this.getPartsConfig(navElement, childElement);
45
- const top = window.scrollY;
46
- partsConfig.forEach(offsetTop => {
47
- if (top > (offsetTop.value - (shift + 50))) {
48
- item = navElement.querySelector('[' + offsetTop.attribute + '="' + offsetTop.id + '"]');
49
- }
50
- })
51
- navElement.querySelectorAll(childElement).forEach(child => {
52
- if (child !== item) {
53
- const deactiveEvent = new CustomEvent('deactive.hc.scrollspy', {
54
- detail: {
55
- nav: navElement,
56
- item: item
57
- }
58
- });
59
- document.dispatchEvent(deactiveEvent);
60
- if(child.classList.contains('active')) {
61
- child.classList.remove('active');
62
- }
63
- }
64
- });
65
- if (!item.classList.contains('active')) {
66
- const activeEvent = new CustomEvent('active.hc.scrollspy', {
67
- detail: {
68
- nav: navElement,
69
- item: item
70
- }
71
- });
72
- document.dispatchEvent(activeEvent);
73
- item.classList.add('active');
74
- }
75
- });
76
- }
77
-
78
- getOffset( element ) {
79
- let x = 0;
80
- let y = 0;
81
- while( element && !isNaN( element.offsetLeft ) && !isNaN( element.offsetTop ) ) {
82
- x += element.offsetLeft - element.scrollLeft;
83
- y += element.offsetTop - element.scrollTop;
84
- element = element.offsetParent;
85
- }
86
- return { top: y, left: x };
87
- }
88
- }
89
-
90
- const hc_scrollspy = function (trigger) {
91
- return new HcScrollspy(trigger);
92
- }
93
- export default hc_scrollspy;
1
+ import t from"../../enumerators/element.enum";export class HcScrollspy{activeEvent;constructor(e=t.scrollspy){for(let l of document.querySelectorAll(e)){let e=document.querySelector(l.dataset.hcScrollspy),r=null!==l.getAttribute("data-hc-scrollspy-shift")?Number.parseInt(l.getAttribute("data-hc-scrollspy-shift")):0;null!==e&&this.activeItem(e,t.scrollspyNavItem,r)}}getPartsConfig(e,l){let r=[];for(let s of e.querySelectorAll(l)){let e=null!==s.getAttribute("href")?{id:s.getAttribute("href"),value:0,attribute:"href"}:{id:s.getAttribute(t.scrollspyNavItemHref),value:0,attribute:t.scrollspyNavItemHref};null!==document.querySelector(e.id)&&(e.value=this.getOffset(document.querySelector(e.id)).top,r=[...r,e])}return r}activeItem(t,e,l=0){let r=t.querySelector(`${e}:first-child`);window.addEventListener("scroll",()=>{let s=this.getPartsConfig(t,e),o=window.scrollY;for(let e of s)o>e.value-(l+50)&&(r=t.querySelector(`[${e.attribute}="${e.id}"]`));for(let l of t.querySelectorAll(e))if(l!==r){let e=new CustomEvent("deactive.hc.scrollspy",{detail:{nav:t,item:r}});document.dispatchEvent(e),l.classList.contains("active")&&l.classList.remove("active")}if(!r.classList.contains("active")){let e=new CustomEvent("active.hc.scrollspy",{detail:{nav:t,item:r}});document.dispatchEvent(e),r.classList.add("active")}})}getOffset(t){let e=0,l=0,r=t;for(;r&&!Number.isNaN(r.offsetLeft)&&!Number.isNaN(r.offsetTop);)e+=r.offsetLeft-r.scrollLeft,l+=r.offsetTop-r.scrollTop,r=r.offsetParent;return{top:l,left:e}}}let hc_scrollspy=t=>new HcScrollspy(t);export default hc_scrollspy;
@@ -1,51 +1 @@
1
- import ShareEnum from "../../enumerators/share.enum";
2
-
3
- export default class ShareComponent {
4
-
5
- constructor() {
6
- }
7
-
8
- static manageDisplayOfShareButtons() {
9
-
10
- if (navigator.share && window.matchMedia('(max-width: 1024px)').matches) {
11
- $(ShareEnum.shareMobile).removeClass('hidden');
12
- $(ShareEnum.shareDesktop).addClass('hidden');
13
- } else {
14
- $(ShareEnum.shareMobile).addClass('hidden');
15
- $(ShareEnum.shareDesktop).removeClass('hidden');
16
- }
17
- }
18
-
19
- static sharePage() {
20
- let shareButton = $('[data-share="mobile"]');
21
-
22
- shareButton.on('click', event => {
23
- event.preventDefault();
24
-
25
- if (navigator.share) {
26
- navigator.share({
27
- title: document.title,
28
- url: window.location.href
29
- })
30
- } else {
31
- // fallback
32
- }
33
- });
34
- }
35
-
36
- static shareOnWhatsappWeb() {
37
-
38
- $(ShareEnum.shareWhatsappService).on('click', function (e) {
39
- e.preventDefault();
40
- window.open('https://web.whatsapp.com/send?text='+$(location).attr('href'), '_blank');
41
- })
42
- }
43
-
44
- static shareOnMessengerWeb() {
45
-
46
- $(ShareEnum.shareMessengerService).on('click', function (e) {
47
- e.preventDefault();
48
- window.open('http://www.facebook.com/dialog/send?app_id=702473707947207&link='+$(location).attr('href')+'&redirect_uri='+$(location).attr('href'), '_blank');
49
- })
50
- }
51
- }
1
+ import e from"../../enumerators/share.enum";export default class a{static manageDisplayOfShareButtons(){navigator.share&&window.matchMedia("(max-width: 1024px)").matches?($(e.shareMobile).removeClass("hidden"),$(e.shareDesktop).addClass("hidden")):($(e.shareMobile).addClass("hidden"),$(e.shareDesktop).removeClass("hidden"))}static sharePage(){$('[data-share="mobile"]').on("click",e=>{e.preventDefault(),navigator.share&&navigator.share({title:document.title,url:window.location.href})})}static shareOnWhatsappWeb(){$(e.shareWhatsappService).on("click",e=>{e.preventDefault(),window.open(`https://web.whatsapp.com/send?text=${$(location).attr("href")}`,"_blank")})}static shareOnMessengerWeb(){$(e.shareMessengerService).on("click",e=>{e.preventDefault(),window.open(`http://www.facebook.com/dialog/send?app_id=702473707947207&link=${$(location).attr("href")}&redirect_uri=${$(location).attr("href")}`,"_blank")})}}