PageSourceSearch

https://electriccityroasting.com/wp-content/plugins/upsell-order-b…/public/js/zoom-script.js?ver=3.1.5

js electriccityroasting.com collected 2026-09-26 12:10:21 UTC 6,164 bytes, 235 lines download raw bytes

vendor: 5,917 bytes, lines 1-221
1/*!
2	Zoom 1.7.20
3	license: MIT
4	http://www.jacklmoore.com/zoom
5*/
6(function ($) {
7	var defaults = {
8		url: false,
9		callback: false,
10		target: false,
11		duration: 120,
12		on: 'mouseover', // other options: grab, click, toggle
13		touch: true, // enables a touch fallback
14		onZoomIn: false,
15		onZoomOut: false,
16		magnify: 1
17	};
18
19	// Core Zoom Logic, independent of event listeners.
20	$.zoom = function(target, source, img, magnify) {
21		var targetHeight,
22			targetWidth,
23			sourceHeight,
24			sourceWidth,
25			xRatio,
26			yRatio,
27			offset,
28			$target = $(target),
29			position = $target.css('position'),
30			$source = $(source);
31
32		// The parent element needs positioning so that the zoomed element can be correctly positioned within.
33		target.style.position = /(absolute|fixed)/.test(position) ? position : 'relative';
34		target.style.overflow = 'hidden';
35		img.style.width = img.style.height = '';
36
37		$(img)
38			.addClass('zoomImg')
39			.css({
40				position: 'absolute',
41				top: 0,
42				left: 0,
43				opacity: 0,
44				width: img.width * magnify,
45				height: img.height * magnify,
46				border: 'none',
47				maxWidth: 'none',
48				maxHeight: 'none'
49			})
50			.appendTo(target);
51
52		return {
53			init: function() {
54				targetWidth = $target.outerWidth();
55				targetHeight = $target.outerHeight();
56
57				if (source === target) {
58					sourceWidth = targetWidth;
59					sourceHeight = targetHeight;
60				} else {
61					sourceWidth = $source.outerWidth();
62					sourceHeight = $source.outerHeight();
63				}
64
65				xRatio = (img.width - targetWidth) / sourceWidth;
66				yRatio = (img.height - targetHeight) / sourceHeight;
67
68				offset = $source.offset();
69			},
70			move: function (e) {
71				var left = (e.pageX - offset.left),
72					top = (e.pageY - offset.top);
73
74				top = Math.max(Math.min(top, sourceHeight), 0);
75				left = Math.max(Math.min(left, sourceWidth), 0);
76
77				img.style.left = (left * -xRatio) + 'px';
78				img.style.top = (top * -yRatio) + 'px';
79			}
80		};
81	};
82
83	$.fn.zoom = function (options) {
84		return this.each(function () {
85			var
86			settings = $.extend({}, defaults, options || {}),
87			//target will display the zoomed image
88			target = settings.target && $(settings.target)[0] || this,
89			//source will provide zoom location info (thumbnail)
90			source = this,
91			$source = $(source),
92			img = document.createElement('img'),
93			$img = $(img),
94			mousemove = 'mousemove.zoom',
95			clicked = false,
96			touched = false;
97
98			// If a url wasn't specified, look for an image element.
99			if (!settings.url) {
100				var srcElement = source.querySelector('img');
101				if (srcElement) {
102					settings.url = srcElement.getAttribute('data-src') || srcElement.currentSrc || srcElement.src;
103				}
104				if (!settings.url) {
105					return;
106				}
107			}
108
109			$source.one('zoom.destroy', function(position, overflow){
110				$source.off(".zoom");
111				target.style.position = position;
112				target.style.overflow = overflow;
113				img.onload = null;
114				$img.remove();
115			}.bind(this, target.style.position, target.style.overflow));
116
117			img.onload = function () {
118				var zoom = $.zoom(target, source, img, settings.magnify);
119
120				function start(e) {
121					zoom.init();
122					zoom.move(e);
123
124					// Skip the fade-in for IE8 and lower since it chokes on fading-in
125					// and changing position based on mousemovement at the same time.
126					$img.stop()
127					.fadeTo($.support.opacity ? settings.duration : 0, 1, $.isFunction(settings.onZoomIn) ? settings.onZoomIn.call(img) : false);
128				}
129
130				function stop() {
131					$img.stop()
132					.fadeTo(settings.duration, 0, $.isFunction(settings.onZoomOut) ? settings.onZoomOut.call(img) : false);
133				}
134
135				// Mouse events
136				if (settings.on === 'grab') {
137					$source
138						.on('mousedown.zoom',
139							function (e) {
140								if (e.which === 1) {
141									$(document).one('mouseup.zoom',
142										function () {
143											stop();
144
145											$(document).off(mousemove, zoom.move);
146										}
147									);
148
149									start(e);
150
151									$(document).on(mousemove, zoom.move);
152
153									e.preventDefault();
154								}
155							}
156						);
157				} else if (settings.on === 'click') {
158					$source.on('click.zoom',
159						function (e) {
160							if (clicked) {
161								// bubble the event up to the document to trigger the unbind.
162								return;
163							} else {
164								clicked = true;
165								start(e);
166								$(document).on(mousemove, zoom.move);
167								$(document).one('click.zoom',
168									function () {
169										stop();
170										clicked = false;
171										$(document).off(mousemove, zoom.move);
172									}
173								);
174								return false;
175							}
176						}
177					);
178				} else if (settings.on === 'toggle') {
179					$source.on('click.zoom',
180						function (e) {
181							if (clicked) {
182								stop();
183							} else {
184								start(e);
185							}
186							clicked = !clicked;
187						}
188					);
189				} else if (settings.on === 'mouseover') {
190					zoom.init(); // Preemptively call init because IE7 will fire the mousemove handler before the hover handler.
191
192					$source
193						.on('mouseenter.zoom', start)
194						.on('mouseleave.zoom', stop)
195						.on(mousemove, zoom.move);
196				}
197
198				// Touch fallback
199				if (settings.touch) {
200					$source
201						.on('touchstart.zoom', function (e) {
202							e.preventDefault();
203							if (touched) {
204								touched = false;
205								stop();
206							} else {
207								touched = true;
208								start( e.originalEvent.touches[0] || e.originalEvent.changedTouches[0] );
209							}
210						})
211						.on('touchmove.zoom', function (e) {
212							e.preventDefault();
213							zoom.move( e.originalEvent.touches[0] || e.originalEvent.changedTouches[0] );
214						})
215						.on('touchend.zoom', function (e) {
216							e.preventDefault();
217							if (touched) {
218								touched = false;
219								stop();
220							}
221						});
222				}
223				
224				if ($.isFunction(settings.callback)) {
225					settings.callback.call(img);
226				}
227			};
228
229			img.setAttribute('role', 'presentation');
230			img.src = settings.url;
231		});
232	};
233
234	$.fn.zoom.defaults = defaults;
235}(window.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.