PageSourceSearch

https://oldofrediresidence.it/site/assets/unify/js/components/hs.carousel.js

js oldofrediresidence.it collected 2026-10-05 20:13:25 UTC 11,208 bytes, 373 lines download raw bytes

1/**
2 * Carousel wrapper.
3 * MIKE: setResponsive da problemi con lo la Gallery Slick Carousel commentato alla linea 98 e 206
4 * Senza quella dichiarazione funziona ma perdo il comportamento Responsive nella Gallery
5 */
6;
7(function($) {
8	'use strict';
9
10	$.HSCore.components.HSCarousel = {
11		/**
12		 *
13		 *
14		 * @var Object _baseConfig
15		 */
16		_baseConfig: {
17			autoplay: false,
18			infinite: true
19		},
20
21		/**
22		 *
23		 *
24		 * @var jQuery pageCollection
25		 */
26		pageCollection: $(),
27
28		/**
29		 * Initialization of Carousel wrapper.
30		 *
31		 * @param String selector (optional)
32		 * @param Object config (optional)
33		 *
34		 * @return jQuery pageCollection - collection of initialized items.
35		 */
36		init: function(selector, config) {
37			this.collection = selector && $(selector).length ? $(selector) : $();
38			if (!$(selector).length) return;
39
40			this.config = config && $.isPlainObject(config) ?
41				$.extend({}, this._baseConfig, config) : this._baseConfig;
42
43			this.config.itemSelector = selector;
44
45			this.initCarousel();
46
47			return this.pageCollection;
48		},
49
50		initCarousel: function() {
51			//Variables
52			var $self = this,
53				config = $self.config,
54				collection = $self.pageCollection;
55
56			//Actions
57			this.collection.each(function(i, el) {
58				//Variables
59				var $this = $(el),
60					id = $this.attr('id'),
61
62					//Markup elements
63					target = $this.data('nav-for'),
64					isThumb = $this.data('is-thumbs'),
65					arrowsClasses = $this.data('arrows-classes'),
66					arrowLeftClasses = $this.data('arrow-left-classes'),
67					arrowRightClasses = $this.data('arrow-right-classes'),
68					pagiClasses = $this.data('pagi-classes'),
69					pagiHelper = $this.data('pagi-helper'),
70					$pagiIcons = $this.data('pagi-icons'),
71					$prevMarkup = '<div class="js-prev ' + arrowsClasses + ' ' + arrowLeftClasses + '"></div>',
72					$nextMarkup = '<div class="js-next ' + arrowsClasses + ' ' + arrowRightClasses + '"></div>',
73
74					//Setters
75					setSlidesToShow = $this.data('slides-show'),
76					setSlidesToScroll = $this.data('slides-scroll'),
77					setAutoplay = $this.data('autoplay'),
78					setAnimation = $this.data('animation'),
79					setEasing = $this.data('easing'),
80					setFade = $this.data('fade'),
81					setSpeed = $this.data('speed'),
82					setSlidesRows = $this.data('rows'),
83					setCenterMode = $this.data('center-mode'),
84					setCenterPadding = $this.data('center-padding'),
85					setPauseOnHover = $this.data('pause-hover'),
86					setVariableWidth = $this.data('variable-width'),
87					setInitialSlide = $this.data('initial-slide'),
88					setVertical = $this.data('vertical'),
89					setRtl = $this.data('rtl'),
90					setInEffect = $this.data('in-effect'),
91					setOutEffect = $this.data('out-effect'),
92					setInfinite = $this.data('infinite'),
93					setDataTitlePosition = $this.data('title-pos-inside'),
94					setFocusOnSelect = $this.data('focus-on-select'),
95					setLazyLoad = $this.data('lazy-load'),
96					isAdaptiveHeight = $this.data('adaptive-height'),
97					numberedPaging = $this.data('numbered-pagination');
98//					setResponsive = JSON.parse(el.getAttribute('data-responsive'));
99
100				if ($this.find('[data-slide-type]').length) {
101					$self.videoSupport($this);
102				}
103
104				$this.on('init', function(event, slick) {
105					$(slick.$slides).css('height', 'auto');
106				});
107
108				if (setInEffect && setOutEffect) {
109					$this.on('init', function(event, slick) {
110						$(slick.$slides).addClass('single-slide');
111					});
112				}
113
114				if (pagiHelper) {
115					$this.on('init', function(event, slick) {
116						var $pagination = $this.find('.js-pagination');
117
118						if (!$pagination.length) return;
119
120						$pagination.append('<span class="u-dots-helper"></span>');
121					});
122				}
123
124				if (isThumb) {
125					$('#' + id).on('click', '.slick-slide', function(e) {
126						e.stopPropagation();
127
128						//Variables
129						var i = $(this).data('slick-index');
130
131						if ($('#' + id).slick('slickCurrentSlide') !== i) {
132							$('#' + id).slick('slickGoTo', i);
133						}
134					});
135				}
136
137				$this.on('init', function(event, slider) {
138					var $pagination = $this.find('.js-pagination');
139
140					if (!$pagination.length) return;
141
142					$($pagination[0].children[0]).addClass('slick-current');
143				});
144
145				$this.on('init', function(event, slick) {
146					var slide = $(slick.$slides)[0],
147						animatedElements = $(slide).find('[data-scs-animation-in]');
148
149					$(animatedElements).each(function() {
150						var animationIn = $(this).data('scs-animation-in');
151
152						$(this).addClass('animated ' + animationIn).css('opacity', 1);
153					});
154				});
155
156				if (numberedPaging) {
157					$this.on('init', function(event, slick) {
158						$(numberedPaging).text('1' + '/' + slick.slideCount);
159					});
160				}
161
162				$this.slick({
163					autoplay: setAutoplay ? true : false,
164					autoplaySpeed: setSpeed ? setSpeed : 3000,
165
166					cssEase: setAnimation ? setAnimation : 'ease',
167					easing: setEasing ? setEasing : 'linear',
168					fade: setFade ? true : false,
169
170					infinite: setInfinite ? true : false,
171					initialSlide: setInitialSlide ? setInitialSlide - 1 : 0,
172					slidesToShow: setSlidesToShow ? setSlidesToShow : 1,
173					slidesToScroll: setSlidesToScroll ? setSlidesToScroll : 1,
174					centerMode: setCenterMode ? true : false,
175					variableWidth: setVariableWidth ? true : false,
176					pauseOnHover: setPauseOnHover ? true : false,
177					rows: setSlidesRows ? setSlidesRows : 1,
178					vertical: setVertical ? true : false,
179					verticalSwiping: setVertical ? true : false,
180					rtl: setRtl ? true : false,
181					centerPadding: setCenterPadding ? setCenterPadding : 0,
182					focusOnSelect: setFocusOnSelect ? true : false,
183					lazyLoad: setLazyLoad ? setLazyLoad : false,
184
185					asNavFor: target ? target : false,
186					prevArrow: arrowsClasses ? $prevMarkup : false,
187					nextArrow: arrowsClasses ? $nextMarkup : false,
188					dots: pagiClasses ? true : false,
189					dotsClass: 'js-pagination ' + pagiClasses,
190					adaptiveHeight: !!isAdaptiveHeight,
191					customPaging: function(slider, i) {
192						var title = $(slider.$slides[i]).data('title');
193
194						if (title && $pagiIcons) {
195							return '<span>' + title + '</span>' + $pagiIcons;
196						} else if ($pagiIcons) {
197							return '<span></span>' + $pagiIcons;
198						} else if (title && setDataTitlePosition) {
199							return '<span>' + title + '</span>';
200						} else if (title && !setDataTitlePosition) {
201							return '<span></span>' + '<strong class="u-dot-title">' + title + '</strong>';
202						} else {
203							return '<span></span>';
204						}
205					},
206//					responsive: setResponsive
207				});
208
209				$this.on('beforeChange', function(event, slider, currentSlide, nextSlide) {
210					var nxtSlide = $(slider.$slides)[nextSlide],
211						slide = $(slider.$slides)[currentSlide],
212						$pagination = $this.find('.js-pagination'),
213						animatedElements = $(nxtSlide).find('[data-scs-animation-in]'),
214						otherElements = $(slide).find('[data-scs-animation-in]');
215
216					$(otherElements).each(function() {
217						var animationIn = $(this).data('scs-animation-in');
218
219						$(this).removeClass('animated ' + animationIn);
220					});
221
222					$(animatedElements).each(function() {
223						$(this).css('opacity', 0);
224					});
225
226					if (!$pagination.length) return;
227
228					if (currentSlide > nextSlide) {
229						$($pagination[0].children).removeClass('slick-active-right');
230
231						$($pagination[0].children[nextSlide]).addClass('slick-active-right');
232					} else {
233						$($pagination[0].children).removeClass('slick-active-right');
234					}
235
236					$($pagination[0].children).removeClass('slick-current');
237
238					setTimeout(function() {
239						$($pagination[0].children[nextSlide]).addClass('slick-current');
240					}, .25);
241				});
242
243				if (numberedPaging) {
244					$this.on('beforeChange', function(event, slick, currentSlide, nextSlide) {
245						var i = (nextSlide ? nextSlide : 0) + 1;
246
247						$(numberedPaging).text(i + '/' + slick.slideCount);
248					});
249				}
250
251				$this.on('afterChange', function(event, slick, currentSlide, nextSlide) {
252					var slide = $(slick.$slides)[currentSlide],
253						animatedElements = $(slide).find('[data-scs-animation-in]');
254
255					$(animatedElements).each(function() {
256						var animationIn = $(this).data('scs-animation-in'),
257							animationDelay = $(this).data('scs-animation-delay'),
258							animationDuration = $(this).data('scs-animation-duration');
259
260							console.log(animationDuration);
261
262						$(this).css({
263							'animation-delay': animationDelay + 'ms',
264							'animation-duration': animationDuration + 'ms'
265						});
266
267						$(this).addClass('animated ' + animationIn).css('opacity', 1);
268					});
269				});
270
271				if (setInEffect && setOutEffect) {
272					$this.on('afterChange', function(event, slick, currentSlide, nextSlide) {
273						$(slick.$slides).removeClass('animated set-position ' + setInEffect + ' ' + setOutEffect);
274					});
275
276					$this.on('beforeChange', function(event, slick, currentSlide) {
277						$(slick.$slides[currentSlide]).addClass('animated ' + setOutEffect);
278					});
279
280					$this.on('setPosition', function(event, slick) {
281						$(slick.$slides[slick.currentSlide]).addClass('animated set-position ' + setInEffect);
282					});
283				}
284
285				//Actions
286				collection = collection.add($this);
287			});
288		},
289
290		/**
291		 * Implementation of video support.
292		 *
293		 * @param jQuery carousel
294		 * @param String videoSupport
295		 *
296		 * @return undefined
297		 */
298		videoSupport: function(carousel) {
299			if (!carousel.length) return;
300
301			carousel.on('beforeChange', function(event, slick, currentSlide, nextSlide) {
302				var slideType = $(slick.$slides[currentSlide]).data('slide-type'),
303					player = $(slick.$slides[currentSlide]).find('iframe').get(0),
304					command;
305
306				if (slideType == 'vimeo') {
307					command = {
308						"method": "pause",
309						"value": "true"
310					}
311				} else if (slideType == 'youtube') {
312					command = {
313						"event": "command",
314						"func": "pauseVideo"
315					}
316				} else {
317					return false;
318				}
319
320				if (player != undefined) {
321					player.contentWindow.postMessage(JSON.stringify(command), '*');
322				}
323			});
324		},
325
326		/**
327		 * Implementation of text animation.
328		 *
329		 * @param jQuery carousel
330		 * @param String textAnimationSelector
331		 *
332		 * @requires charming.js, anime.js, textfx.js
333		 *
334		 * @return undefined
335		 */
336		initTextAnimation: function(carousel, textAnimationSelector) {
337			if (!window.TextFx || !window.anime || !carousel.length) return;
338
339			var $text = carousel.find(textAnimationSelector);
340
341			if (!$text.length) return;
342
343			$text.each(function(i, el) {
344				var $this = $(el);
345
346				if (!$this.data('TextFx')) {
347					$this.data('TextFx', new TextFx($this.get(0)));
348				}
349			});
350
351
352			carousel.on('beforeChange', function(event, slick, currentSlide, nextSlide) {
353				var targets = slick.$slider
354					.find('.slick-track')
355					.children();
356
357				var currentTarget = targets.eq(currentSlide),
358					nextTarget = targets.eq(nextSlide);
359
360				currentTarget = currentTarget.find(textAnimationSelector);
361				nextTarget = nextTarget.find(textAnimationSelector);
362
363				if (currentTarget.length) {
364					currentTarget.data('TextFx').hide(currentTarget.data('effect') ? currentTarget.data('effect') : 'fx1');
365				}
366
367				if (nextTarget.length) {
368					nextTarget.data('TextFx').show(nextTarget.data('effect') ? nextTarget.data('effect') : 'fx1');
369				}
370			});
371		}
372	}
373})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.