@iris.interactive/handcook 7.1.1-beta → 8.0.0-alpha.1
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/.gitlab-ci.yml +2 -2
- package/.nvmrc +1 -1
- package/README.md +1 -1
- package/package.json +12 -18
- package/public/index.html +33 -36
- package/public/scripts/components/collapse/collapse.component.js +1 -95
- package/public/scripts/components/collapse/collapse.component.scss +4 -4
- package/public/scripts/components/dropdown/dropdown.component.js +1 -81
- package/public/scripts/components/lazyload/lazyload.component.js +1 -61
- package/public/scripts/components/lightbox/lightbox.component.js +1 -91
- package/public/scripts/components/modal/modal.component.js +1 -83
- package/public/scripts/components/nats/nats.component.js +1 -62
- package/public/scripts/components/overlay/overlay.component.js +1 -88
- package/public/scripts/components/popin/popin.component.js +1 -150
- package/public/scripts/components/scroll-reveal/scroll-reveal.component.js +1 -168
- package/public/scripts/components/scrollspy/scrollspy.component.js +1 -93
- package/public/scripts/components/share/share.component.js +1 -0
- package/public/scripts/components/slider/slider.component.js +1 -317
- package/public/scripts/components/smooth-scroll/smooth-scroll.component.js +1 -59
- package/public/scripts/components/tab/tab.component.js +1 -82
- package/public/scripts/components/toggle/toggle.component.js +1 -51
- package/public/scripts/components/tooltip/tooltip.component.js +1 -119
- package/public/scripts/enumerators/element.enum.js +1 -40
- package/public/scripts/enumerators/share.enum.js +1 -0
- package/public/scripts/enumerators/smooth-scroll.enum.js +1 -19
- package/public/scripts/enumerators/tooltip.enum.js +1 -25
- package/public/scripts/handcook.js +1 -49
- package/public/scripts/support/cookie.support.js +1 -0
- package/public/scripts/support/hash.support.js +1 -0
- package/public/scripts/support/toggle-html.support.js +1 -0
- package/public/scripts/support/wrap-select.support.js +1 -0
- package/public/static/css/989.b832cc44.css +1 -0
- package/public/static/css/index.0ac21166.css +1 -0
- package/public/static/js/989.a4a97e0e.js +23 -0
- package/public/static/js/989.a4a97e0e.js.LICENSE.txt +5 -0
- package/public/static/js/index.67977b9b.js +1 -0
- package/public/styles/scss/_utils.scss +21 -17
- package/public/styles/scss/_variables.scss +0 -4
- package/public/styles/scss/handcook.scss +5 -5
- package/public/styles/scss/mixins/_mixin-font.scss +8 -6
- package/public/styles/scss/mixins/_mixin-layout.scss +17 -14
- package/public/styles/scss/mixins/_mixin-style.scss +70 -63
- package/public/styles/scss/style.css +1 -172
- package/mix-manifest.json +0 -51
- package/public/scripts/components/collapse/collapse.component.min.js +0 -1
- package/public/scripts/components/dropdown/dropdown.component.min.js +0 -1
- package/public/scripts/components/lazyload/lazyload.component.min.js +0 -1
- package/public/scripts/components/lightbox/lightbox.component.min.js +0 -1
- package/public/scripts/components/modal/modal.component.min.js +0 -1
- package/public/scripts/components/scrollspy/scrollspy.component.min.js +0 -1
- package/public/scripts/components/slider/slider.component.min.js +0 -1
- package/public/scripts/components/smooth-scroll/smooth-scroll.component.min.js +0 -1
- package/public/scripts/components/tab/tab.component.min.js +0 -1
- package/public/scripts/components/toggle/toggle.component.min.js +0 -1
- package/public/scripts/components/tooltip/tooltip.component.min.js +0 -1
- package/public/scripts/index.js.LICENSE.txt +0 -1
- package/public/styles/style.css +0 -28
|
@@ -1,317 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* IRIS Interactive
|
|
3
|
-
*
|
|
4
|
-
* NOTICE OF LICENSE
|
|
5
|
-
*
|
|
6
|
-
* This source file is no subject to a specific license
|
|
7
|
-
* but it belongs to the company IRIS Interactive.
|
|
8
|
-
* You can contact IRIS Interactive at the following
|
|
9
|
-
* address: contact@iris-interactive.fr
|
|
10
|
-
*
|
|
11
|
-
* @author Lucas ROCHE
|
|
12
|
-
* @date 22/02/2022 17:21
|
|
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 Swiper from "swiper/bundle";
|
|
18
|
-
import "swiper/css";
|
|
19
|
-
import "swiper/css/effect-fade";
|
|
20
|
-
|
|
21
|
-
export class HcSlider {
|
|
22
|
-
|
|
23
|
-
slider;
|
|
24
|
-
instances = [];
|
|
25
|
-
|
|
26
|
-
breakpoints = [{
|
|
27
|
-
name: "medium",
|
|
28
|
-
value: 651
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: "large",
|
|
32
|
-
value: 1001
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "xlarge",
|
|
36
|
-
value: 1454
|
|
37
|
-
}];
|
|
38
|
-
|
|
39
|
-
// Options
|
|
40
|
-
options = {};
|
|
41
|
-
|
|
42
|
-
// Events
|
|
43
|
-
initEvent;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @param elements
|
|
47
|
-
*/
|
|
48
|
-
constructor(elements = ElementEnum.slider) {
|
|
49
|
-
document.querySelectorAll(elements).forEach(element => {
|
|
50
|
-
this.initEvent = new Event("init.hc.slider");
|
|
51
|
-
this.initOptions();
|
|
52
|
-
this.slider = element;
|
|
53
|
-
this.setOptions();
|
|
54
|
-
this.buildDom();
|
|
55
|
-
const instance = new Swiper(element, this.options);
|
|
56
|
-
this.instances.push(instance);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
setOptions() {
|
|
61
|
-
const attr = this.slider.getAttribute('data-hc-slider-autoplay');
|
|
62
|
-
if (attr !== null) {
|
|
63
|
-
this.options['autoplay'] = {
|
|
64
|
-
delay: attr
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let breakpointOptions = {};
|
|
69
|
-
|
|
70
|
-
let breakpointKeyConfig = [
|
|
71
|
-
{
|
|
72
|
-
'hcKey': 'gap',
|
|
73
|
-
'libKey': 'spaceBetween',
|
|
74
|
-
'callback': 'parseFloat'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
'hcKey': 'slides-per-view',
|
|
78
|
-
'libKey': 'slidesPerView',
|
|
79
|
-
'callback': 'parseFloat'
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
'hcKey': 'no-swipe',
|
|
83
|
-
'libKey': 'allowTouchMove',
|
|
84
|
-
'callback': 'parseReverseBool'
|
|
85
|
-
}
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
breakpointKeyConfig.map(config => {
|
|
89
|
-
let defaultVal = this.slider.getAttribute(`data-hc-slider-${config.hcKey}`);
|
|
90
|
-
if (defaultVal !== null) {
|
|
91
|
-
if ( config.callback === 'parseReverseBool' ) {
|
|
92
|
-
defaultVal = defaultVal !== 'true';
|
|
93
|
-
}
|
|
94
|
-
if ( config.callback === 'parseBool' ) {
|
|
95
|
-
defaultVal = defaultVal === 'true';
|
|
96
|
-
}
|
|
97
|
-
if ( config.callback === 'parseFloat' ) {
|
|
98
|
-
defaultVal = parseFloat(defaultVal);
|
|
99
|
-
}
|
|
100
|
-
this.options[config.libKey] = defaultVal;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
this.breakpoints.forEach(breakpoint => {
|
|
105
|
-
let breakpointOptionsConfig = {};
|
|
106
|
-
breakpointKeyConfig.map(config => {
|
|
107
|
-
let val = this.slider.getAttribute(`data-hc-slider-${config.hcKey}-${breakpoint.name}`);
|
|
108
|
-
if (val !== null) {
|
|
109
|
-
if (config.callback === 'parseReverseBool') {
|
|
110
|
-
val = val !== 'true';
|
|
111
|
-
}
|
|
112
|
-
if (config.callback === 'parseBool') {
|
|
113
|
-
val = val === 'true';
|
|
114
|
-
}
|
|
115
|
-
if (config.callback === 'parseFloat') {
|
|
116
|
-
val = parseFloat(val);
|
|
117
|
-
}
|
|
118
|
-
breakpointOptionsConfig[config.libKey] = val;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
if ( Object.getOwnPropertyNames(breakpointOptionsConfig).length > 0 ) {
|
|
123
|
-
breakpointOptions[breakpoint.value] = breakpointOptionsConfig;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
this.options.breakpoints = breakpointOptions;
|
|
128
|
-
|
|
129
|
-
const freeMode = this.slider.getAttribute('data-hc-slider-free-mode');
|
|
130
|
-
if (freeMode !== null) {
|
|
131
|
-
this.options['freeMode'] = {
|
|
132
|
-
enabled: true
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (this.slider.hasAttribute('data-hc-slider-pagination')) {
|
|
137
|
-
this.options['pagination'] = {
|
|
138
|
-
el: '.hc-slider-pagination',
|
|
139
|
-
type: 'bullets',
|
|
140
|
-
clickable: true,
|
|
141
|
-
dynamicBullets: false,
|
|
142
|
-
bulletClass: 'hc-slider-pagination-bullet',
|
|
143
|
-
clickableClass: 'hc-slider-pagination-clickable',
|
|
144
|
-
currentClass: 'hc-slider-pagination-current',
|
|
145
|
-
bulletActiveClass: 'hc-slider-pagination-bullet-active'
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
if (this.slider.hasAttribute('data-hc-slider-arrows')) {
|
|
149
|
-
const suffix = this.slider.getAttribute('data-hc-slider-arrows');
|
|
150
|
-
const wrapperElement = this.slider.hasAttribute('data-hc-slider-arrows-wrapper') ? '.hc-slider-buttons' : null;
|
|
151
|
-
const prevElement = this.slider.hasAttribute('data-hc-slider-arrow-prev') ? this.slider.getAttribute('data-hc-slider-arrow-prev') : `.hc-slider-button-prev${suffix}`;
|
|
152
|
-
const nextElement = this.slider.hasAttribute('data-hc-slider-arrow-next') ? this.slider.getAttribute('data-hc-slider-arrow-next') : `.hc-slider-button-next${suffix}`;
|
|
153
|
-
|
|
154
|
-
this.options['navigation'] = {
|
|
155
|
-
prevEl: prevElement,
|
|
156
|
-
nextEl: nextElement,
|
|
157
|
-
wrapperEl: wrapperElement,
|
|
158
|
-
disabledClass: `hc-slider-button-disabled${suffix}`,
|
|
159
|
-
hiddenClass: `hc-slider-button-hidden${suffix}`
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (this.slider.hasAttribute('data-hc-slider-fade-effect')) {
|
|
164
|
-
this.options['effect'] = 'fade';
|
|
165
|
-
this.options['fadeEffect'] = {
|
|
166
|
-
crossFade: true
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (this.slider.hasAttribute('data-hc-slider-infinite')) {
|
|
171
|
-
this.options['loop'] = true;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (this.slider.hasAttribute('data-hc-slider-disable-mousewheel')) {
|
|
175
|
-
this.options['mousewheel'] = false;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (this.slider.hasAttribute('data-hc-slider-lazy')) {
|
|
179
|
-
this.options['lazy'] = {
|
|
180
|
-
enabled: true,
|
|
181
|
-
checkInView: true,
|
|
182
|
-
loadPrevNext: true,
|
|
183
|
-
elementClass: 'hc-slider-lazy',
|
|
184
|
-
loadedClass: 'hc-slider-lazy-loaded',
|
|
185
|
-
loadingClass: 'hc-slider-lazy-loading',
|
|
186
|
-
preloaderClass: 'hc-slider-lazy-preloader',
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
this.options['watchOverflow'] = true;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
buildDom() {
|
|
194
|
-
// Si le DOM n'est pas créé correctement, on le fait
|
|
195
|
-
if (this.slider.querySelectorAll('.swiper-wrapper').length === 0) {
|
|
196
|
-
// On recupère les slide items (element de DOM enfant de premier niveau)
|
|
197
|
-
// et on leur ajoute la classe des slide item
|
|
198
|
-
const items = [].slice.call(this.slider.children);
|
|
199
|
-
items.forEach(item => {
|
|
200
|
-
item.classList.add('swiper-slide');
|
|
201
|
-
item.setAttribute('aria-roledescription', 'slide');
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// On ajoute la classe swiper a notre slider,
|
|
205
|
-
// on crée la div wrapper et on insére les slider item dedans
|
|
206
|
-
const wrapperElement = document.createElement("div");
|
|
207
|
-
wrapperElement.classList.add("swiper-wrapper");
|
|
208
|
-
items.forEach(item => {
|
|
209
|
-
wrapperElement.appendChild(item);
|
|
210
|
-
});
|
|
211
|
-
this.slider.appendChild(wrapperElement);
|
|
212
|
-
|
|
213
|
-
// On ajout les différentes div utile en fonction des options passées
|
|
214
|
-
// et si les elements n'existent pas déjà
|
|
215
|
-
if (this.options.pagination !== false) {
|
|
216
|
-
|
|
217
|
-
const el = this.slider.querySelectorAll(this.options.pagination.el);
|
|
218
|
-
if (el.length === 0) {
|
|
219
|
-
const paginationElement = document.createElement("div");
|
|
220
|
-
paginationElement.classList.add(this.options.pagination.el.substr(1));
|
|
221
|
-
this.slider.appendChild(paginationElement);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (this.options.navigation !== false) {
|
|
225
|
-
|
|
226
|
-
const prevEl = this.slider.querySelectorAll(this.options.navigation.prevEl);
|
|
227
|
-
const nextEl = this.slider.querySelectorAll(this.options.navigation.nextEl);
|
|
228
|
-
|
|
229
|
-
if (this.slider.hasAttribute('data-hc-slider-arrows-wrapper') && prevEl.length === 0 && nextEl.length === 0) {
|
|
230
|
-
const buttonsWrapper = document.createElement("div");
|
|
231
|
-
const buttonPrev = document.createElement("div");
|
|
232
|
-
const buttonNext = document.createElement("div");
|
|
233
|
-
|
|
234
|
-
buttonPrev.classList.add(this.options.navigation.prevEl.substr(1));
|
|
235
|
-
buttonNext.classList.add(this.options.navigation.nextEl.substr(1));
|
|
236
|
-
buttonsWrapper.classList.add(this.options.navigation.wrapperEl.substr(1));
|
|
237
|
-
|
|
238
|
-
buttonsWrapper.appendChild(buttonPrev);
|
|
239
|
-
buttonsWrapper.appendChild(buttonNext);
|
|
240
|
-
|
|
241
|
-
this.slider.prepend(buttonsWrapper);
|
|
242
|
-
} else {
|
|
243
|
-
if (!this.slider.hasAttribute('data-hc-slider-arrow-prev') && prevEl.length === 0) {
|
|
244
|
-
const buttonPrev = document.createElement("div");
|
|
245
|
-
buttonPrev.classList.add(this.options.navigation.prevEl.substr(1));
|
|
246
|
-
this.slider.appendChild(buttonPrev);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (!this.slider.hasAttribute('data-hc-slider-arrow-next') && nextEl.length === 0) {
|
|
250
|
-
const buttonNext = document.createElement("div");
|
|
251
|
-
buttonNext.classList.add(this.options.navigation.nextEl.substr(1));
|
|
252
|
-
this.slider.appendChild(buttonNext);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
initOptions() {
|
|
260
|
-
this.options = {
|
|
261
|
-
slidesPerView: "auto",
|
|
262
|
-
pagination: false,
|
|
263
|
-
navigation: false,
|
|
264
|
-
mousewheel: {
|
|
265
|
-
forceToAxis: true,
|
|
266
|
-
},
|
|
267
|
-
grabCursor: true,
|
|
268
|
-
loop: false,
|
|
269
|
-
watchSlidesProgress: true,
|
|
270
|
-
a11y: {
|
|
271
|
-
prevSlideMessage: IRISCollectionTheme.translate.slider.prevSlideMessage ?? 'Slide précédente',
|
|
272
|
-
nextSlideMessage: IRISCollectionTheme.translate.slider.nextSlideMessage ?? 'Slide suivante',
|
|
273
|
-
firstSlideMessage: IRISCollectionTheme.translate.slider.firstSlideMessage ?? 'Vous êtes sur la première slide',
|
|
274
|
-
lastSlideMessage: IRISCollectionTheme.translate.slider.lastSlideMessage ?? 'Vous avez atteint la dernière slide',
|
|
275
|
-
paginationBulletMessage: IRISCollectionTheme.translate.slider.paginationBulletMessage ?? 'Aller sur la slide {{index}}',
|
|
276
|
-
slideLabelMessage: IRISCollectionTheme.translate.slider.slideLabelMessage ?? 'Slide {{index}} sur {{slidesLength}}',
|
|
277
|
-
},
|
|
278
|
-
on: {
|
|
279
|
-
init: (swiper) => {
|
|
280
|
-
|
|
281
|
-
// layout
|
|
282
|
-
swiper.$el.find('.swiper-wrapper').addClass('hc-slider-wrapper');
|
|
283
|
-
swiper.$el.addClass('hc-slider-initialized');
|
|
284
|
-
|
|
285
|
-
// slide item
|
|
286
|
-
swiper.$el.find('.swiper-slide').addClass('hc-slider-slide');
|
|
287
|
-
swiper.$el.find('.swiper-slide-active').addClass('hc-slider-slide-active');
|
|
288
|
-
swiper.$el.find('.swiper-slide-next').addClass('hc-slider-slide-next');
|
|
289
|
-
swiper.$el.find('.swiper-slide-prev').addClass('hc-slider-slide-prev');
|
|
290
|
-
|
|
291
|
-
if (swiper.isLocked) {
|
|
292
|
-
swiper.$el.addClass('hc-slider-lock');
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
this.slider.dispatchEvent(this.initEvent);
|
|
296
|
-
},
|
|
297
|
-
slideChangeTransitionEnd: (swiper) => {
|
|
298
|
-
|
|
299
|
-
// slide item
|
|
300
|
-
swiper.$el.find('.swiper-slide')
|
|
301
|
-
.removeClass('hc-slider-slide-active')
|
|
302
|
-
.removeClass('hc-slider-slide-next')
|
|
303
|
-
.removeClass('hc-slider-slide-prev');
|
|
304
|
-
swiper.$el.find('.swiper-slide-active').addClass('hc-slider-slide-active');
|
|
305
|
-
swiper.$el.find('.swiper-slide-next').addClass('hc-slider-slide-next');
|
|
306
|
-
swiper.$el.find('.swiper-slide-prev').addClass('hc-slider-slide-prev');
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
breakpoints: {}
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
const hc_slider = function (trigger) {
|
|
315
|
-
return new HcSlider(trigger);
|
|
316
|
-
}
|
|
317
|
-
export default hc_slider;
|
|
1
|
+
import e from"../../enumerators/element.enum";import i from"swiper/bundle";import"swiper/css";import"swiper/css/effect-fade";export class HcSlider{slider;instances=[];breakpoints=[{name:"medium",value:651},{name:"large",value:1001},{name:"xlarge",value:1454}];options={};initEvent;constructor(s=e.slider){document.querySelectorAll(s).forEach(e=>{this.initEvent=new Event("init.hc.slider"),this.initOptions(),this.slider=e,this.setOptions(),this.buildDom();let s=new i(e,this.options);this.instances.push(s)})}setOptions(){let e=this.slider.getAttribute("data-hc-slider-autoplay");null!==e&&(this.options.autoplay={delay:e});let i={},s=[{hcKey:"gap",libKey:"spaceBetween",callback:"parseFloat"},{hcKey:"slides-per-view",libKey:"slidesPerView",callback:"parseFloat"},{hcKey:"no-swipe",libKey:"allowTouchMove",callback:"parseReverseBool"}];if(s.map(e=>{let i=this.slider.getAttribute(`data-hc-slider-${e.hcKey}`);null!==i&&("parseReverseBool"===e.callback&&(i="true"!==i),"parseBool"===e.callback&&(i="true"===i),"parseFloat"===e.callback&&(i=parseFloat(i)),this.options[e.libKey]=i)}),this.breakpoints.forEach(e=>{let t={};s.map(i=>{let s=this.slider.getAttribute(`data-hc-slider-${i.hcKey}-${e.name}`);null!==s&&("parseReverseBool"===i.callback&&(s="true"!==s),"parseBool"===i.callback&&(s="true"===s),"parseFloat"===i.callback&&(s=parseFloat(s)),t[i.libKey]=s)}),Object.getOwnPropertyNames(t).length>0&&(i[e.value]=t)}),this.options.breakpoints=i,null!==this.slider.getAttribute("data-hc-slider-free-mode")&&(this.options.freeMode={enabled:!0}),this.slider.hasAttribute("data-hc-slider-pagination")&&(this.options.pagination={el:".hc-slider-pagination",type:"bullets",clickable:!0,dynamicBullets:!1,bulletClass:"hc-slider-pagination-bullet",clickableClass:"hc-slider-pagination-clickable",currentClass:"hc-slider-pagination-current",bulletActiveClass:"hc-slider-pagination-bullet-active"}),this.slider.hasAttribute("data-hc-slider-arrows")){let e=this.slider.getAttribute("data-hc-slider-arrows"),i=this.slider.hasAttribute("data-hc-slider-arrows-wrapper")?".hc-slider-buttons":null,s=this.slider.hasAttribute("data-hc-slider-arrow-prev")?this.slider.getAttribute("data-hc-slider-arrow-prev"):`.hc-slider-button-prev${e}`,t=this.slider.hasAttribute("data-hc-slider-arrow-next")?this.slider.getAttribute("data-hc-slider-arrow-next"):`.hc-slider-button-next${e}`;this.options.navigation={prevEl:s,nextEl:t,wrapperEl:i,disabledClass:`hc-slider-button-disabled${e}`,hiddenClass:`hc-slider-button-hidden${e}`}}this.slider.hasAttribute("data-hc-slider-fade-effect")&&(this.options.effect="fade",this.options.fadeEffect={crossFade:!0}),this.slider.hasAttribute("data-hc-slider-infinite")&&(this.options.loop=!0),this.slider.hasAttribute("data-hc-slider-disable-mousewheel")&&(this.options.mousewheel=!1),this.slider.hasAttribute("data-hc-slider-lazy")&&(this.options.lazy={enabled:!0,checkInView:!0,loadPrevNext:!0,elementClass:"hc-slider-lazy",loadedClass:"hc-slider-lazy-loaded",loadingClass:"hc-slider-lazy-loading",preloaderClass:"hc-slider-lazy-preloader"}),this.options.watchOverflow=!0}buildDom(){if(0===this.slider.querySelectorAll(".swiper-wrapper").length){let e=[].slice.call(this.slider.children);e.forEach(e=>{e.classList.add("swiper-slide")});let i=document.createElement("div");if(i.classList.add("swiper-wrapper"),e.forEach(e=>{i.appendChild(e)}),this.slider.appendChild(i),!1!==this.options.pagination&&0===this.slider.querySelectorAll(this.options.pagination.el).length){let e=document.createElement("div");e.classList.add(this.options.pagination.el.substr(1)),this.slider.appendChild(e)}if(!1!==this.options.navigation){let e=this.slider.querySelectorAll(this.options.navigation.prevEl),i=this.slider.querySelectorAll(this.options.navigation.nextEl);if(this.slider.hasAttribute("data-hc-slider-arrows-wrapper")&&0===e.length&&0===i.length){let e=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div");i.classList.add(this.options.navigation.prevEl.substr(1)),s.classList.add(this.options.navigation.nextEl.substr(1)),e.classList.add(this.options.navigation.wrapperEl.substr(1)),e.appendChild(i),e.appendChild(s),this.slider.appendChild(e)}else{if(!this.slider.hasAttribute("data-hc-slider-arrow-prev")&&0===e.length){let e=document.createElement("div");e.classList.add(this.options.navigation.prevEl.substr(1)),this.slider.appendChild(e)}if(!this.slider.hasAttribute("data-hc-slider-arrow-next")&&0===i.length){let e=document.createElement("div");e.classList.add(this.options.navigation.nextEl.substr(1)),this.slider.appendChild(e)}}}}}initOptions(){this.options={slidesPerView:"auto",pagination:!1,navigation:!1,mousewheel:{forceToAxis:!0},grabCursor:!0,loop:!1,watchSlidesProgress:!0,on:{init:e=>{e.$el.find(".swiper-wrapper").addClass("hc-slider-wrapper"),e.$el.addClass("hc-slider-initialized"),e.$el.find(".swiper-slide").addClass("hc-slider-slide"),e.$el.find(".swiper-slide-active").addClass("hc-slider-slide-active"),e.$el.find(".swiper-slide-next").addClass("hc-slider-slide-next"),e.$el.find(".swiper-slide-prev").addClass("hc-slider-slide-prev"),e.isLocked&&e.$el.addClass("hc-slider-lock"),this.slider.dispatchEvent(this.initEvent)},slideChangeTransitionEnd:e=>{e.$el.find(".swiper-slide").removeClass("hc-slider-slide-active").removeClass("hc-slider-slide-next").removeClass("hc-slider-slide-prev"),e.$el.find(".swiper-slide-active").addClass("hc-slider-slide-active"),e.$el.find(".swiper-slide-next").addClass("hc-slider-slide-next"),e.$el.find(".swiper-slide-prev").addClass("hc-slider-slide-prev")}},breakpoints:{}}}}let hc_slider=function(e){return new HcSlider(e)};export default hc_slider;
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* IRIS Interactive
|
|
3
|
-
*
|
|
4
|
-
* NOTICE OF LICENSE
|
|
5
|
-
*
|
|
6
|
-
* This source file is no subject to a specific license
|
|
7
|
-
* but it belongs to the company IRIS Interactive.
|
|
8
|
-
* You can contact IRIS Interactive at the following
|
|
9
|
-
* address: contact@iris-interactive.fr
|
|
10
|
-
*
|
|
11
|
-
* @author Lucas ROCHE
|
|
12
|
-
* @date 28/01/2022 14:27
|
|
13
|
-
* @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
|
|
14
|
-
* @deprecated 5.0.17
|
|
15
|
-
*/
|
|
16
|
-
import ElementEnum from "../../enumerators/element.enum";
|
|
17
|
-
import SmoothScrollEnum from "../../enumerators/smooth-scroll.enum";
|
|
18
|
-
|
|
19
|
-
export class HcSmoothScroll {
|
|
20
|
-
constructor(triggerAttribute = ElementEnum.scrollSmooth, durationAnimation = 1000) {
|
|
21
|
-
document.querySelectorAll(triggerAttribute).forEach(trigger => {
|
|
22
|
-
trigger.addEventListener('click', (e) => {
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
const target = (e.currentTarget.getAttribute('href') != null) ? document.querySelector(e.currentTarget.getAttribute('href')) : document.querySelector(e.currentTarget.dataset.hcSmoothScrollHref);
|
|
25
|
-
const shift = (e.currentTarget.getAttribute(SmoothScrollEnum.attrShift) !== null) ? e.currentTarget.getAttribute(SmoothScrollEnum.attrShift) : 0;
|
|
26
|
-
const anim = requestAnimationFrame((timestamp) => {
|
|
27
|
-
const stamp = timestamp || new Date().getTime();
|
|
28
|
-
const start = stamp;
|
|
29
|
-
const startScrollOffset = window.pageYOffset;
|
|
30
|
-
const scrollEndElemTop = target.getBoundingClientRect().top - shift;
|
|
31
|
-
this.scrollToElem(start, stamp, durationAnimation, scrollEndElemTop, startScrollOffset);
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
easeInCubic(t) {
|
|
38
|
-
return t * t * t
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
scrollToElem(startTime, currentTime, duration, scrollEndElemTop, startScrollOffset) {
|
|
42
|
-
const runtime = currentTime - startTime;
|
|
43
|
-
let progress = runtime / duration;
|
|
44
|
-
progress = Math.min(progress, 1);
|
|
45
|
-
const ease = this.easeInCubic(progress);
|
|
46
|
-
window.scroll(0, startScrollOffset + (scrollEndElemTop * ease));
|
|
47
|
-
if (runtime < duration) {
|
|
48
|
-
requestAnimationFrame((timestamp) => {
|
|
49
|
-
const currentTime = timestamp || new Date().getTime();
|
|
50
|
-
this.scrollToElem(startTime, currentTime, duration, scrollEndElemTop, startScrollOffset);
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const hc_smooth_scroll = function (trigger, durationAnimation) {
|
|
57
|
-
new HcSmoothScroll(trigger, durationAnimation);
|
|
58
|
-
}
|
|
59
|
-
export default hc_smooth_scroll;
|
|
1
|
+
import e from"../../enumerators/element.enum";import t from"../../enumerators/smooth-scroll.enum";export class HcSmoothScroll{constructor(r=e.scrollSmooth,o=1e3){document.querySelectorAll(r).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault();let r=null!=e.currentTarget.getAttribute("href")?document.querySelector(e.currentTarget.getAttribute("href")):document.querySelector(e.currentTarget.dataset.hcSmoothScrollHref),l=null!==e.currentTarget.getAttribute(t.attrShift)?e.currentTarget.getAttribute(t.attrShift):0;requestAnimationFrame(e=>{let t=e||new Date().getTime(),c=window.pageYOffset,n=r.getBoundingClientRect().top-l;this.scrollToElem(t,t,o,n,c)})})})}easeInCubic(e){return e*e*e}scrollToElem(e,t,r,o,l){let c=t-e,n=c/r;n=Math.min(n,1);let u=this.easeInCubic(n);window.scroll(0,l+o*u),c<r&&requestAnimationFrame(t=>{let c=t||new Date().getTime();this.scrollToElem(e,c,r,o,l)})}}let hc_smooth_scroll=function(e,t){new HcSmoothScroll(e,t)};export default hc_smooth_scroll;
|
|
@@ -1,82 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* IRIS Interactive
|
|
3
|
-
*
|
|
4
|
-
* NOTICE OF LICENSE
|
|
5
|
-
*
|
|
6
|
-
* This source file is no subject to a specific license
|
|
7
|
-
* but it belongs to the company IRIS Interactive.
|
|
8
|
-
* You can contact IRIS Interactive at the following
|
|
9
|
-
* address: contact@iris-interactive.fr
|
|
10
|
-
*
|
|
11
|
-
* @author Lucas ROCHE
|
|
12
|
-
* @date 22/02/2022 14:34
|
|
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 "./tab.component.scss";
|
|
18
|
-
import Tab from "bootstrap/js/src/tab";
|
|
19
|
-
|
|
20
|
-
export class HcTab {
|
|
21
|
-
|
|
22
|
-
showEvent;
|
|
23
|
-
shownEvent;
|
|
24
|
-
hideEvent;
|
|
25
|
-
hiddenEvent;
|
|
26
|
-
|
|
27
|
-
constructor(elements = ElementEnum.tab) {
|
|
28
|
-
this.createEvent();
|
|
29
|
-
this.buildDOM();
|
|
30
|
-
const triggerTabList = [].slice.call(document.querySelectorAll(elements))
|
|
31
|
-
triggerTabList.forEach(function (triggerEl) {
|
|
32
|
-
const tabTrigger = new Tab(triggerEl);
|
|
33
|
-
|
|
34
|
-
triggerEl.addEventListener('click', function (event) {
|
|
35
|
-
event.preventDefault()
|
|
36
|
-
tabTrigger.show()
|
|
37
|
-
})
|
|
38
|
-
});
|
|
39
|
-
document.querySelectorAll(elements).forEach(trigger => {
|
|
40
|
-
trigger.addEventListener('hide.bs.tab', (e) => {
|
|
41
|
-
trigger.dispatchEvent(this.hideEvent);
|
|
42
|
-
});
|
|
43
|
-
trigger.addEventListener('show.bs.tab', (e) => {
|
|
44
|
-
trigger.dispatchEvent(this.showEvent);
|
|
45
|
-
});
|
|
46
|
-
trigger.addEventListener('shown.bs.tab', (e) => {
|
|
47
|
-
trigger.dispatchEvent(this.shownEvent);
|
|
48
|
-
});
|
|
49
|
-
trigger.addEventListener('hidden.bs.tab', (e) => {
|
|
50
|
-
trigger.dispatchEvent(this.hiddenEvent);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
buildDOM() {
|
|
56
|
-
document.querySelectorAll("[data-hc-tab-wrapper]").forEach(wrapper => {
|
|
57
|
-
if (!wrapper.classList.contains("nav")) {
|
|
58
|
-
wrapper.classList.add("nav")
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
createEvent() {
|
|
64
|
-
this.showEvent = new Event("show.hc.tab");
|
|
65
|
-
this.shownEvent = new Event("shown.hc.tab");
|
|
66
|
-
this.hideEvent = new Event("hide.hc.tab");
|
|
67
|
-
this.hiddenEvent = new Event("hidden.hc.tab");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static show(trigger) {
|
|
71
|
-
var triggerTabList = [].slice.call(document.querySelectorAll(trigger));
|
|
72
|
-
triggerTabList.forEach(function (triggerEl) {
|
|
73
|
-
var tabTrigger = new Tab(triggerEl)
|
|
74
|
-
tabTrigger.show();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const hc_tab = function (trigger) {
|
|
80
|
-
return new HcTab(trigger);
|
|
81
|
-
}
|
|
82
|
-
export default hc_tab;
|
|
1
|
+
import t from"../../enumerators/element.enum";import"./tab.component.scss";import e from"bootstrap/js/src/tab";export class HcTab{showEvent;shownEvent;hideEvent;hiddenEvent;constructor(n=t.tab){this.createEvent(),this.buildDOM(),[].slice.call(document.querySelectorAll(n)).forEach(function(t){let n=new e(t);t.addEventListener("click",function(t){t.preventDefault(),n.show()})}),document.querySelectorAll(n).forEach(t=>{t.addEventListener("hide.bs.tab",e=>{t.dispatchEvent(this.hideEvent)}),t.addEventListener("show.bs.tab",e=>{t.dispatchEvent(this.showEvent)}),t.addEventListener("shown.bs.tab",e=>{t.dispatchEvent(this.shownEvent)}),t.addEventListener("hidden.bs.tab",e=>{t.dispatchEvent(this.hiddenEvent)})})}buildDOM(){document.querySelectorAll("[data-hc-tab-wrapper]").forEach(t=>{!t.classList.contains("nav")&&t.classList.add("nav")})}createEvent(){this.showEvent=new Event("show.hc.tab"),this.shownEvent=new Event("shown.hc.tab"),this.hideEvent=new Event("hide.hc.tab"),this.hiddenEvent=new Event("hidden.hc.tab")}static show(t){[].slice.call(document.querySelectorAll(t)).forEach(function(t){new e(t).show()})}}let hc_tab=function(t){return new HcTab(t)};export default hc_tab;
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* IRIS Interactive
|
|
3
|
-
*
|
|
4
|
-
* NOTICE OF LICENSE
|
|
5
|
-
*
|
|
6
|
-
* This source file is no subject to a specific license
|
|
7
|
-
* but it belongs to the company IRIS Interactive.
|
|
8
|
-
* You can contact IRIS Interactive at the following
|
|
9
|
-
* address: contact@iris-interactive.fr
|
|
10
|
-
*
|
|
11
|
-
* @author Lucas ROCHE
|
|
12
|
-
* @date 22/02/2022 16:50
|
|
13
|
-
* @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import ElementEnum from "../../enumerators/element.enum";
|
|
18
|
-
|
|
19
|
-
export class HcToggle {
|
|
20
|
-
|
|
21
|
-
constructor(elements = ElementEnum.toggle) {
|
|
22
|
-
document.querySelectorAll(elements).forEach(element => {
|
|
23
|
-
element.addEventListener('click', (e) => {
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
const attribute = e.currentTarget.dataset.hcToggleAttribute;
|
|
26
|
-
const value = e.currentTarget.dataset.hcToggleValue;
|
|
27
|
-
const targets = e.currentTarget.getAttribute("href") ? e.currentTarget.getAttribute("href") : e.currentTarget.dataset.hcToggleTarget;
|
|
28
|
-
document.querySelectorAll(targets).forEach(target => {
|
|
29
|
-
if (target.getAttribute(attribute) !== null && target.getAttribute(attribute).indexOf(value) !== -1) {
|
|
30
|
-
if (attribute === "class") {
|
|
31
|
-
target.classList.remove(value);
|
|
32
|
-
} else {
|
|
33
|
-
target.removeAttribute(attribute);
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
if (attribute === "class") {
|
|
37
|
-
target.classList.add(value);
|
|
38
|
-
} else {
|
|
39
|
-
target.setAttribute(attribute, value);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const hc_toggle = function (trigger) {
|
|
49
|
-
return new HcToggle(trigger);
|
|
50
|
-
}
|
|
51
|
-
export default hc_toggle;
|
|
1
|
+
import e from"../../enumerators/element.enum";export class HcToggle{constructor(t=e.toggle){document.querySelectorAll(t).forEach(e=>{e.addEventListener("click",e=>{e.preventDefault();let t=e.currentTarget.dataset.hcToggleAttribute,r=e.currentTarget.dataset.hcToggleValue,c=e.currentTarget.getAttribute("href")?e.currentTarget.getAttribute("href"):e.currentTarget.dataset.hcToggleTarget;document.querySelectorAll(c).forEach(e=>{null!==e.getAttribute(t)&&-1!==e.getAttribute(t).indexOf(r)?"class"===t?e.classList.remove(r):e.removeAttribute(t):"class"===t?e.classList.add(r):e.setAttribute(t,r)})})})}}let hc_toggle=function(e){return new HcToggle(e)};export default hc_toggle;
|
|
@@ -1,119 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* IRIS Interactive
|
|
3
|
-
*
|
|
4
|
-
* NOTICE OF LICENSE
|
|
5
|
-
*
|
|
6
|
-
* This source file is no subject to a specific license
|
|
7
|
-
* but it belongs to the company IRIS Interactive.
|
|
8
|
-
* You can contact IRIS Interactive at the following
|
|
9
|
-
* address: contact@iris-interactive.fr
|
|
10
|
-
*
|
|
11
|
-
* @author Lucas ROCHE
|
|
12
|
-
* @date 28/01/2022 14:52
|
|
13
|
-
* @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import tippy from "tippy.js";
|
|
18
|
-
import "tippy.js/dist/tippy.css"
|
|
19
|
-
import ElementEnum from "../../enumerators/element.enum";
|
|
20
|
-
import TooltipEnum from "../../enumerators/tooltip.enum";
|
|
21
|
-
|
|
22
|
-
export class HcTooltip {
|
|
23
|
-
|
|
24
|
-
showEvent;
|
|
25
|
-
shownEvent;
|
|
26
|
-
hideEvent;
|
|
27
|
-
hiddenEvent;
|
|
28
|
-
|
|
29
|
-
instances = [];
|
|
30
|
-
defaultOptions = {
|
|
31
|
-
placement: '',
|
|
32
|
-
content: '',
|
|
33
|
-
trigger: '',
|
|
34
|
-
interactive: false,
|
|
35
|
-
allowHTML: true
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
constructor(elements = ElementEnum.tooltip, overrideOptions = {}) {
|
|
39
|
-
this.createEvent();
|
|
40
|
-
document.querySelectorAll(elements).forEach(element => {
|
|
41
|
-
let options = {};
|
|
42
|
-
Object.assign(options, this.defaultOptions, overrideOptions);
|
|
43
|
-
options.trigger = options.trigger != '' ? options.trigger : (element.hasAttribute(TooltipEnum.attrPopover) ? "click focus" : "mouseenter focus");
|
|
44
|
-
options.content = options.content != '' ? options.content : (element.hasAttribute(TooltipEnum.attrContent) ? element.getAttribute(TooltipEnum.attrContent) : '');
|
|
45
|
-
options.placement = options.placement != '' ? options.placement : (element.hasAttribute(TooltipEnum.attrPlacement) ? element.getAttribute(TooltipEnum.attrPlacement) : 'bottom');
|
|
46
|
-
options.interactive = options.interactive != '' ? options.interactive : (element.hasAttribute(TooltipEnum.attrInteractive) ? element.getAttribute(TooltipEnum.attrInteractive) : false);
|
|
47
|
-
let backgroundColor = element.hasAttribute(TooltipEnum.attrBackgroundColor) ? element.getAttribute(TooltipEnum.attrBackgroundColor) : '';
|
|
48
|
-
let color = element.hasAttribute(TooltipEnum.attrColor) ? element.getAttribute(TooltipEnum.attrColor) : '';
|
|
49
|
-
let fontSize = element.hasAttribute(TooltipEnum.attrFontSize) ? element.getAttribute(TooltipEnum.attrFontSize) : '';
|
|
50
|
-
if (options.trigger.indexOf('click') !== -1) {
|
|
51
|
-
element.addEventListener('click', (e) => {
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
});
|
|
54
|
-
} else {
|
|
55
|
-
options.touch = false;
|
|
56
|
-
}
|
|
57
|
-
options.onShow = (instance) => {
|
|
58
|
-
if (backgroundColor) {
|
|
59
|
-
instance.popper.querySelector('.tippy-box').style.setProperty('--iris--tooltip--background-color', backgroundColor);
|
|
60
|
-
}
|
|
61
|
-
if (color) {
|
|
62
|
-
instance.popper.querySelector('.tippy-box').style.setProperty('--iris--tooltip--color', color);
|
|
63
|
-
}
|
|
64
|
-
if (fontSize) {
|
|
65
|
-
instance.popper.querySelector('.tippy-box').style.setProperty('--iris--tooltip--font-size', fontSize);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
instance.reference.dispatchEvent(this.showEvent);
|
|
69
|
-
}
|
|
70
|
-
options.onShown = (instance) => {
|
|
71
|
-
instance.reference.dispatchEvent(this.shownEvent);
|
|
72
|
-
}
|
|
73
|
-
options.onHide = (instance) => {
|
|
74
|
-
instance.reference.dispatchEvent(this.hideEvent);
|
|
75
|
-
}
|
|
76
|
-
options.onHidden = (instance) => {
|
|
77
|
-
instance.reference.dispatchEvent(this.hiddenEvent);
|
|
78
|
-
}
|
|
79
|
-
const instance = tippy(element, options);
|
|
80
|
-
this.instances.push(instance);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
createEvent() {
|
|
85
|
-
this.showEvent = new Event('show.hc.tooltip');
|
|
86
|
-
this.shownEvent = new Event('shown.hc.tooltip');
|
|
87
|
-
this.hideEvent = new Event('hide.hc.tooltip');
|
|
88
|
-
this.hiddenEvent = new Event('hidden.hc.tooltip');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
show() {
|
|
92
|
-
this.instances.forEach(instance => {
|
|
93
|
-
instance.show();
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
hide() {
|
|
98
|
-
this.instances.forEach(instance => {
|
|
99
|
-
instance.hide();
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
disable() {
|
|
104
|
-
this.instances.forEach(instance => {
|
|
105
|
-
instance.disable();
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
enable() {
|
|
110
|
-
this.instances.forEach(instance => {
|
|
111
|
-
instance.enable();
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const hc_tooltip = function (trigger, options) {
|
|
117
|
-
return new HcTooltip(trigger, options);
|
|
118
|
-
}
|
|
119
|
-
export default hc_tooltip;
|
|
1
|
+
import t from"tippy.js";import"tippy.js/dist/tippy.css";import e from"../../enumerators/element.enum";import i from"../../enumerators/tooltip.enum";export class HcTooltip{showEvent;shownEvent;hideEvent;hiddenEvent;instances=[];defaultOptions={placement:"",content:"",trigger:"",interactive:!1,allowHTML:!0};constructor(o=e.tooltip,r={}){this.createEvent(),document.querySelectorAll(o).forEach(e=>{let o={};Object.assign(o,this.defaultOptions,r),o.trigger=""!=o.trigger?o.trigger:e.hasAttribute(i.attrPopover)?"click":"mouseenter",o.content=""!=o.content?o.content:e.hasAttribute(i.attrContent)?e.getAttribute(i.attrContent):"",o.placement=""!=o.placement?o.placement:e.hasAttribute(i.attrPlacement)?e.getAttribute(i.attrPlacement):"bottom",o.interactive=""!=o.interactive?o.interactive:!!e.hasAttribute(i.attrInteractive)&&e.getAttribute(i.attrInteractive);let n=e.hasAttribute(i.attrBackgroundColor)?e.getAttribute(i.attrBackgroundColor):"",s=e.hasAttribute(i.attrColor)?e.getAttribute(i.attrColor):"",c=e.hasAttribute(i.attrFontSize)?e.getAttribute(i.attrFontSize):"";"click"===o.trigger?e.addEventListener("click",t=>{t.preventDefault()}):o.touch=!1,o.onShow=t=>{n&&t.popper.querySelector(".tippy-box").style.setProperty("--iris--tooltip--background-color",n),s&&t.popper.querySelector(".tippy-box").style.setProperty("--iris--tooltip--color",s),c&&t.popper.querySelector(".tippy-box").style.setProperty("--iris--tooltip--font-size",c),t.reference.dispatchEvent(this.showEvent)},o.onShown=t=>{t.reference.dispatchEvent(this.shownEvent)},o.onHide=t=>{t.reference.dispatchEvent(this.hideEvent)},o.onHidden=t=>{t.reference.dispatchEvent(this.hiddenEvent)};let a=t(e,o);this.instances.push(a)})}createEvent(){this.showEvent=new Event("show.hc.tooltip"),this.shownEvent=new Event("shown.hc.tooltip"),this.hideEvent=new Event("hide.hc.tooltip"),this.hiddenEvent=new Event("hidden.hc.tooltip")}show(){this.instances.forEach(t=>{t.show()})}hide(){this.instances.forEach(t=>{t.hide()})}disable(){this.instances.forEach(t=>{t.disable()})}enable(){this.instances.forEach(t=>{t.enable()})}}let hc_tooltip=function(t,e){return new HcTooltip(t,e)};export default hc_tooltip;
|