@iris.interactive/handcook 2.6.5 → 2.6.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iris.interactive/handcook",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "description": "The web cooking by IRIS Interactive",
5
5
  "main": "./public/scripts/index.js",
6
6
  "scripts": {
@@ -20,20 +20,18 @@ import './modal.component.scss';
20
20
 
21
21
  export class HcModal {
22
22
 
23
- defaultOptions = {
24
- src: '',
25
- type: 'inline'
26
- }
23
+ options = {};
27
24
 
28
25
  constructor(elements = ElementEnum.modal, overrideOptions = {}) {
29
- let options = {};
30
- Object.assign(options, this.defaultOptions, overrideOptions);
31
26
  document.querySelectorAll(elements).forEach(element => {
32
27
  Fancybox.bind(element);
33
28
  element.addEventListener('click', (e) => {
34
29
  e.preventDefault();
35
- options.src = options.src != '' ? options.src : (e.currentTarget.hasAttribute('href') ? e.currentTarget.getAttribute('href') : (e.currentTarget.hasAttribute('data-hc-src') ? e.currentTarget.dataset.hcSrc : ''));
36
- Fancybox.show([options]);
30
+ this.initOptions();
31
+ Object.assign(this.options, overrideOptions);
32
+ this.options.src = this.options.src != '' ? this.options.src : (e.currentTarget.hasAttribute('href') ? e.currentTarget.getAttribute('href') : (e.currentTarget.hasAttribute('data-hc-src') ? e.currentTarget.dataset.hcSrc : ''));
33
+ this.options.parentEl = this.options.parentEl !== null ? document.querySelector(this.options.parentEl) : (e.currentTarget.hasAttribute('data-hc-modal-parent') ? document.querySelector(e.currentTarget.getAttribute('data-hc-modal-parent')) : '');
34
+ Fancybox.show([this.options]);
37
35
  });
38
36
  });
39
37
  }
@@ -45,6 +43,14 @@ export class HcModal {
45
43
  static close(all) {
46
44
  Fancybox.close(all);
47
45
  }
46
+
47
+ initOptions() {
48
+ this.options = {
49
+ src: '',
50
+ type: 'inline',
51
+ parentEl: null
52
+ };
53
+ }
48
54
  }
49
55
 
50
56
  const hc_modal = function (trigger, options) {
@@ -38,22 +38,55 @@ export class HcSlider {
38
38
  }
39
39
 
40
40
  setOptions() {
41
- for (const option in this.options) {
42
- const attr = this.slider.getAttribute('data-hc-' + option);
43
- if (attr !== null) {
44
- if (typeof option === "boolean") {
45
- this.options[option] = attr !== false;
46
- } else {
47
- this.options[option] = attr;
48
- }
49
- }
50
- }
51
- const attr = this.slider.getAttribute('data-hc-autoplay');
41
+ const attr = this.slider.getAttribute('data-hc-slider-autoplay');
52
42
  if (attr !== null) {
53
43
  this.options['autoplay'] = {
54
44
  delay: attr
55
45
  }
56
46
  }
47
+
48
+ const gap = this.slider.getAttribute('data-hc-slider-gap');
49
+ const slidesPerView = this.slider.getAttribute('data-hc-slider-slides-per-view');
50
+ if (gap !== null) {
51
+ this.options['spaceBetween'] = parseFloat(gap);
52
+ }
53
+ if (slidesPerView !== null) {
54
+ this.options['slidesPerView'] = parseFloat(slidesPerView);
55
+ }
56
+
57
+ const gapMedium = this.slider.getAttribute('data-hc-slider-gap-medium');
58
+ const slidesPerViewMedium = this.slider.getAttribute('data-hc-slider-slides-per-view-medium');
59
+ if (gapMedium !== null) {
60
+ this.options['breakpoints'][650]['spaceBetween'] = parseFloat(gapMedium);
61
+ }
62
+ if (slidesPerViewMedium !== null) {
63
+ this.options['breakpoints'][650]['slidesPerView'] = parseFloat(slidesPerViewMedium);
64
+ }
65
+
66
+ const gapLarge = this.slider.getAttribute('data-hc-slider-gap-large');
67
+ const slidesPerViewLarge = this.slider.getAttribute('data-hc-slider-slides-per-view-large');
68
+ if (gapLarge !== null) {
69
+ this.options['breakpoints']['1000']['spaceBetween'] = parseFloat(gapLarge);
70
+ }
71
+ if (slidesPerViewLarge !== null) {
72
+ this.options['breakpoints']['1000']['slidesPerView'] = parseFloat(slidesPerViewLarge);
73
+ }
74
+
75
+ const gapXlarge = this.slider.getAttribute('data-hc-slider-gap-xlarge');
76
+ const slidesPerViewXlarge = this.slider.getAttribute('data-hc-slider-slides-per-view-xlarge');
77
+ if (gapXlarge !== null) {
78
+ this.options['breakpoints']['1453']['spaceBetween'] = parseFloat(gapXlarge);
79
+ }
80
+ if (slidesPerViewXlarge !== null) {
81
+ this.options['breakpoints']['1453']['slidesPerView'] = parseFloat(slidesPerViewXlarge);
82
+ }
83
+
84
+ const freeMode = this.slider.getAttribute('data-hc-slider-free-mode');
85
+ if (freeMode !== null) {
86
+ this.options['freeMode'] = {
87
+ enabled: true
88
+ }
89
+ }
57
90
  }
58
91
 
59
92
  buildDom() {
@@ -66,7 +99,6 @@ export class HcSlider {
66
99
 
67
100
  // On ajoute la classe swiper a notre slider,
68
101
  // on crée la div wrapper et on insére les slider item dedans
69
- this.slider.classList.add('swiper');
70
102
  const wrapperElement = document.createElement("div");
71
103
  wrapperElement.classList.add("swiper-wrapper");
72
104
  this.slider.appendChild(wrapperElement);
@@ -114,7 +146,7 @@ export class HcSlider {
114
146
 
115
147
  initOptions() {
116
148
  this.options = {
117
- slidesPerView: 'auto',
149
+ slidesPerView: 4,
118
150
  pagination: false,
119
151
  navigation: false,
120
152
  mousewheel: {
@@ -145,6 +177,11 @@ export class HcSlider {
145
177
  swiper.$el.find('.swiper-slide-next').addClass('hc-slider-slide-next');
146
178
  swiper.$el.find('.swiper-slide-prev').addClass('hc-slider-slide-prev');
147
179
  }
180
+ },
181
+ breakpoints: {
182
+ 650: {},
183
+ 1000: {},
184
+ 1453: {},
148
185
  }
149
186
  };
150
187
  }