PageSourceSearch

https://www.agriturismo-lequerciole.it/wp-content/themes/maxima-v1…/jquery.fancybox-thumbs.js?ver=1.0

js agriturismo-lequerciole.it collected 2026-10-06 12:17:41 UTC 3,726 bytes, 157 lines download raw bytes

1 /*!
2 * Thumbnail helper for fancyBox
3 * version: 1.0.4
4 * @requires fancyBox v2.0 or later
5 *
6 * Usage:
7 *     $(".fancybox").fancybox({
8 *         thumbs: {
9 *             width  : 50,
10 *             height : 50
11 *         }
12 *     });
13 *
14 * Options:
15 *     width - thumbnail width
16 *     height - thumbnail height
17 *     source - function to obtain the URL of the thumbnail image
18 *     position - 'top' or 'bottom'
19 *
20 */
21(function ($) {
22	//Shortcut for fancyBox object
23	var F = $.fancybox;
24
25	//Add helper object
26	F.helpers.thumbs = {
27		wrap: null,
28		list: null,
29		width: 0,
30
31		//Default function to obtain the URL of the thumbnail image
32		source: function (el) {
33			var img;
34
35			if ($.type(el) === 'string') {
36				return el;
37			}
38
39			img = $(el).find('img');
40
41			return img.length ? img.attr('src') : el.href;
42		},
43
44		init: function (opts) {
45			var that = this,
46				list,
47				thumbWidth = opts.width || 50,
48				thumbHeight = opts.height || 50,
49				thumbSource = opts.source || this.source;
50
51			//Build list structure
52			list = '';
53
54			for (var n = 0; n < F.group.length; n++) {
55				list += '<li><a style="width:' + thumbWidth + 'px;height:' + thumbHeight + 'px;" href="javascript:jQuery.fancybox.jumpto(' + n + ');"></a></li>';
56			}
57
58			this.wrap = $('<div id="fancybox-thumbs"></div>').addClass(opts.position || 'bottom').appendTo('body');
59			this.list = $('<ul>' + list + '</ul>').appendTo(this.wrap);
60
61			//Load each thumbnail
62			$.each(F.group, function (i) {
63				$("<img />").load(function () {
64					var width = this.width,
65						height = this.height,
66						widthRatio, heightRatio, parent;
67
68					if (!that.list || !width || !height) {
69						return;
70					}
71
72					//Calculate thumbnail width/height and center it
73					widthRatio = width / thumbWidth;
74					heightRatio = height / thumbHeight;
75					parent = that.list.children().eq(i).find('a');
76
77					if (widthRatio >= 1 && heightRatio >= 1) {
78						if (widthRatio > heightRatio) {
79							width = Math.floor(width / heightRatio);
80							height = thumbHeight;
81
82						} else {
83							width = thumbWidth;
84							height = Math.floor(height / widthRatio);
85						}
86					}
87
88					$(this).css({
89						width: width,
90						height: height,
91						top: Math.floor(thumbHeight / 2 - height / 2),
92						left: Math.floor(thumbWidth / 2 - width / 2)
93					});
94
95					parent.width(thumbWidth).height(thumbHeight);
96
97					$(this).hide().appendTo(parent).fadeIn(300);
98
99				}).attr('src', thumbSource( F.group[ i ] ));
100			});
101
102			//Set initial width
103			this.width = this.list.children().eq(0).outerWidth(true);
104
105			this.list.width(this.width * (F.group.length + 1)).css('left', Math.floor($(window).width() * 0.5 - (F.current.index * this.width + this.width * 0.5)));
106		},
107
108		//Center list
109		update: function (opts) {
110			if (this.list) {
111				this.list.stop(true).animate({
112					'left': Math.floor($(window).width() * 0.5 - (F.current.index * this.width + this.width * 0.5))
113				}, 150);
114			}
115		},
116
117		beforeLoad: function (opts) {
118			//Remove self if gallery do not have at least two items
119			if (F.group.length < 2) {
120				F.coming.helpers.thumbs = false;
121
122				return;
123			}
124
125			//Increase bottom margin to give space for thumbs
126			F.coming.margin[ opts.position === 'top' ? 0 : 2 ] = opts.height + 30;
127		},
128
129		afterShow: function (opts) {
130			//Check if exists and create or update list
131			if (this.list) {
132				this.update(opts);
133
134			} else {
135				this.init(opts);
136			}
137
138			//Set active element
139			this.list.children().removeClass('active').eq(F.current.index).addClass('active');
140		},
141
142		onUpdate: function () {
143			this.update();
144		},
145
146		beforeClose: function () {
147			if (this.wrap) {
148				this.wrap.remove();
149			}
150
151			this.wrap = null;
152			this.list = null;
153			this.width = 0;
154		}
155	}
156
157}(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.