PluginProbe
Property Hive / 2.4.0
Property Hive v2.4.0
2.4.0 2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 All 262 releases
propertyhive / assets / js / flexslider / jquery.flexslider.init.js

jquery.flexslider.init.js in Property Hive 2.4.0, at assets/js/flexslider/jquery.flexslider.init.js

116 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(window).on('load', function() {
2 ph_init_slideshow();
3
4 // Ensure images are fully loaded before resizing
5 jQuery('#carousel.thumbnails .slides img').each(function() {
6 jQuery(this).on('load', function() {
7 setTimeout(function() { jQuery(window).trigger('resize'); }, 500);
8 });
9 // Trigger the load event for cached images
10 if (this.complete) jQuery(this).trigger('load');
11 });
12 });
13
14 jQuery(window).on('resize', function() {
15 // Set height of all thumbnails to be the same (i.e., height of the first one)
16 jQuery('#carousel.thumbnails .slides img').css('height', 'auto');
17 var thumbnail_height = jQuery('#carousel.thumbnails .slides img:eq(0)').height();
18
19 // Apply the height to all thumbnails if it's greater than 0
20 if (thumbnail_height > 0) {
21 jQuery('#carousel.thumbnails .slides img').each(function() {
22 jQuery(this).height(thumbnail_height);
23 });
24 } else {
25 // Force redraw if height is 0
26 jQuery('#carousel.thumbnails .slides img').hide().show();
27 }
28 });
29
30 jQuery(function ($) {
31 document.addEventListener('click', function (e) {
32 var link = e.target.closest('#slider .slides li a[data-fancybox]');
33 if (!link) return;
34
35 var $link = $(link);
36 var $li = $link.closest('li');
37 var $slider = $link.closest('.flexslider');
38 var group = $link.attr('data-fancybox');
39 var href = $link.attr('href') || '';
40
41 // Only handle actual image links
42 if (!href.match(/\.(jpg|jpeg|png|gif|webp)(\?.*)?$/i)) {
43 return;
44 }
45
46 // Stop Fancybox's default delegated handler from seeing this click
47 e.preventDefault();
48 e.stopPropagation();
49 e.stopImmediatePropagation();
50
51 var $realItems = $slider.find('.slides li:not(.clone) a[data-fancybox="' + group + '"]');
52
53 var startIndex;
54 if ($li.hasClass('clone')) {
55 startIndex = $realItems.filter(function () {
56 return $(this).attr('href') === href;
57 }).first().parent().index();
58 } else {
59 startIndex = $realItems.index(link);
60 }
61
62 if (startIndex < 0) {
63 startIndex = 0;
64 }
65
66 $.fancybox.open(
67 $realItems.map(function () {
68 return {
69 src: $(this).attr('href'),
70 opts: {
71 caption: $(this).attr('title') || ''
72 }
73 };
74 }).get(),
75 {
76 loop: true
77 },
78 startIndex
79 );
80 }, true); // <- capture phase
81 });
82
83 function ph_init_slideshow()
84 {
85 // Get all carousel elements on the page
86 jQuery('[id="slider"]').each(function()
87 {
88 var slider = jQuery(this);
89
90 // Get the parent container of this carousel
91 var parentContainer = slider.parent();
92
93 // Find the related slider within the same parent container
94 var carousel = parentContainer.find('#carousel');
95
96 // Initialize the carousel and slider within this parent container
97 carousel.flexslider({
98 animation: "slide",
99 controlNav: false,
100 animationLoop: true,
101 slideshow: false,
102 itemWidth: 150,
103 itemMargin: 5,
104 asNavFor: slider
105 });
106
107 slider.flexslider({
108 animation: "slide",
109 controlNav: false,
110 animationLoop: true,
111 slideshow: false,
112 sync: carousel,
113 smoothHeight: true
114 });
115 });
116 }