PageSourceSearch

https://www.kontron.com/static/kontron/vendor/jquery.ajaxZoom_ver_…/jquery.axZm.openAjaxZoomInFancyBox.js

js kontron.com collected 2026-10-02 02:41:38 UTC 12,476 bytes, 416 lines download raw bytes

1/*!
2* Extension: jQuery AJAX-ZOOM, jquery.axZm.openAjaxZoomInFancyBox.js
3* Copyright: Copyright (c) 2010-2018 Vadim Jacobi
4* License Agreement: http://www.ajax-zoom.com/index.php?cid=download
5* Extension Version: 1.20
6* Extension Date: 2018-03-25
7* URL: http://www.ajax-zoom.com
8* Documentation: http://www.ajax-zoom.com/index.php?cid=docs
9* Extension usage: http://www.ajax-zoom.com/examples/example27.php
10*/
11
12/*
13$(selector).openAjaxZoomInFancyBox(
14axZmPath: "../axZm/",
15queryString: "example=23&zoomData=/pic/zoom/boutique/bag_0.jpg|/pic/zoom/boutique/bag_6.jpg",
16fullScreenApi: false
17);
18
19or
20
21<a href="javascript: void(0)" onclick="$.openAjaxZoomInFancyBox('example=23&zoomData=/pic/zoom/boutique/bag_0.jpg|/pic/zoom/boutique/bag_6.jpg')">
22*/
23
24;(function($) {
25
26	$.openAjaxZoomInFancyBox = function(options) {
27
28		// Defaults
29		var defaults = {
30			axZmPath: 'auto', // Path to AJAX-ZOOM, e.g. /zoomTest/axZm/
31			queryString: null, // Single string which determines which images will be loaded
32			loadingMsg: 'Loading, please wait...',
33			fullScreenCloseBox: false, // when closing fullscreen close fancybox as well 
34			fullScreenApi: false, // use browsers fullscreen api when maximizing AJAX-ZOOM
35			ajaxZoomCallbacks: {}, // AJAX-ZOOM callbacks, some are set in this plugin and are merged
36			iframeMode: false,
37			iframe: false,
38			scrolling: 'no',
39			href: false,
40			fromOpened: false,
41			postMode: null,
42			ref: false,
43			escTxt: false,
44
45			// Fancybox translated parameters
46			boxMargin: 30,
47			boxPadding: 10,
48			boxCenterOnScroll: true,
49			boxOverlayShow: true,
50			boxOverlayOpacity: 0.75,
51			boxOverlayColor: '#777',
52			boxTransitionIn: 'fade', // 'elastic', 'fade' or 'none'
53			boxTransitionOut: 'fade', // 'elastic', 'fade' or 'none'
54			boxSpeedIn: 300,
55			boxSpeedOut: 300,
56			boxEasingIn: 'swing',
57			boxEasingOut: 'swing',
58			boxShowCloseButton: true, // close button
59			boxEnableEscapeButton: true,
60			boxOnClosed: function() {},
61			boxOnComplete: function() {},
62			boxOnCleanup: function() {}
63		};
64
65		if (!$.fancybox) {
66			window.alert('AJAX-ZOOM: $.fancybox 1 or 2 javscript is not present');
67			return;
68		}
69
70		if (typeof options == 'object') {
71			var op = $.extend(true, {}, defaults, options);
72		} else {
73			var op = defaults;
74			op.queryString = options;
75		}
76
77		// Override defaults by user setting
78		var op = $.extend(true, {}, defaults, options);
79
80		if (op.href) {
81			op.queryString = op.href;
82		}
83
84		if (op.iframe) {
85			op.iframeMode = true;
86		}
87
88		if (op.fromOpened) {
89			op.queryString = 'fakeString';
90		}
91
92		op.queryString = op.queryString.replace(/\s+/, '%20');
93		if (op.fromOpened) {
94			op.fullScreenCloseBox = false;
95		}
96
97		// Some checks
98		if (!op.queryString) {
99			alert('Please define queryString that you want to pass to AJAX-ZOOM');
100			return;
101		}
102
103		// iframe?
104		var ifReg = new RegExp('(iframe:)', 'gi');
105		var iframeMode = op.iframeMode || ifReg.test(op.queryString);
106		var hrefIframe = op.queryString.replace(ifReg, '');
107		if (iframeMode) {
108			if (hrefIframe.indexOf('?') != -1) {
109				hrefIframe += '&';
110			} else {
111				hrefIframe += '?';
112			}
113
114			hrefIframe += 'iframeID=fancybox-frame';
115		}
116
117		if (!iframeMode && !$.isFunction($.fn.axZm)) {
118			alert('AJAX-ZOOM JavaScript file is not included');
119			return;
120		}
121
122		// Define the path to the axZm folder, adjust the path if needed! Best of all set absolute path to axZm
123		// Try to get /axZm path instantly
124		if (!iframeMode && op.axZmPath == 'auto') {
125			op.axZmPath = $.fn.axZm.installPath();
126		}
127
128		// Patch fancybox 2.x, 3.x
129		var newFancybox = $.isFunction($.fancybox) && $.type($.fancybox.defaults) == "object";
130		if ($.fancybox.version && parseInt($.fancybox.version) > 2) {
131			var consoleLog = function(a) {
132				if (typeof console != 'undefined') {
133					console.log(a);
134				}
135			};
136
137			consoleLog('Fancybox 3 is not supported. Apparently Fancybox 3 files are present at this page.');
138
139			if (!iframeMode) {
140				consoleLog('AJAX-ZOOM is opened at fullscreen');
141				$.fn.axZm.openFullScreen(
142					op.axZmPath,
143					op.queryString,
144					op.ajaxZoomCallbacks,
145					'window',
146					false
147				);
148			} else {
149				consoleLog('AJAX-ZOOM is not opened');
150			}
151
152			return;
153		}
154
155		var fancyEll = {};
156		if (!newFancybox) {
157			fancyEll = { 
158				content: '#fancybox-content',
159				outer: '#fancybox-outer',
160				wrap: '#fancybox-wrap'
161			};
162		} else {
163			fancyEll = {
164				content: '.fancybox-inner',
165				outer: '.fancybox-outer',
166				wrap: '.fancybox-wrap'
167			};
168		}
169
170		// Scrollbar fix for fancybox
171		var scrollBarFixFancybox = function() {
172			var root = document.compatMode == 'BackCompat' ? document.body : document.documentElement;
173			if (root.scrollWidth > root.clientWidth) {
174				$(window).trigger('resize');
175				$.fn.axZm.resizeStart(100);
176			} else {
177				$(window).trigger('resize');
178				$.fn.axZm.resizeStart(100);
179			}
180		};
181
182		if (!iframeMode) {
183			op.ajaxZoomCallbacks = $.fn.axZm.mergeCallBackObj(op.ajaxZoomCallbacks, {
184				onFullScreenCloseEndFromRel: function() {
185					if (op.fullScreenCloseBox) {
186						$.fancybox.close();
187						return;
188					}
189
190					scrollBarFixFancybox();
191				}
192			});
193		}
194
195		if (op.ref) {
196			$('#'+op.ref).data('axZmrespFancyBox', op);
197		}
198
199		// Calculations of the width and hight passed to fancybox
200		var boxW = $(window).width() - op.boxPadding*2 - op.boxMargin*2;
201		var boxH = (window.innerHeight ? window.innerHeight : $(window).height()) - op.boxPadding*2 - op.boxMargin*2;
202
203		// Helper object to adjust fancybox width and height when browser window resizes
204		var fanyDim = {};
205
206		var cBoxOnWinResize = function() {
207			var difW = $(window).width() - fanyDim.wW;
208			var difH = (window.innerHeight ? window.innerHeight : $(window).height()) - fanyDim.wH;
209
210			$(fancyEll.content).css({
211				width: fanyDim.fCw + difW,
212				height: fanyDim.fCh + difH,
213				opacity: ''
214			});
215
216			$(fancyEll.wrap).css({
217				width: fanyDim.fWrw + difW,
218				height: fanyDim.fWrh + difH
219			});
220		};
221
222		var getFancyDim = function() {
223			// Save initial dimensions of the fancybox when it is opened
224			// Needed to recalculate the width when window resizes with cBoxOnWinResize function
225			fanyDim = {
226				fCw: $(fancyEll.content).width(),
227				fCh: $(fancyEll.content).height(),
228				fWrw: $(fancyEll.wrap).width(),
229				fWrh: $(fancyEll.wrap).height(),
230				fOw: $(fancyEll.outer).width(),
231				fOh: $(fancyEll.outer).height(),
232				wW: $(window).width(),
233				wH: (window.innerHeight ? window.innerHeight : $(window).height())
234			};
235		};
236
237		var afterFancyLoad = function() {
238			window.az_touchPageNoScroll = true;
239
240			// Fancybox callback passed over openAjaxZoomInFancyBox
241			op.boxOnComplete();
242
243			if (newFancybox) {
244				$(fancyEll.content).attr('id', 'fancybox-content-az');
245			} else {
246				getFancyDim();
247				// Bind custom window resize function (cBoxOnWinResize) to enable size adjustments for the fancybox
248				$(window).unbind('resize', cBoxOnWinResize).bind('resize', cBoxOnWinResize);
249			}
250
251			// Init AJAX-ZOOM
252			if (!iframeMode) {
253
254				if (op.fromOpened) {
255					if ($.axZm) {
256						$('#tempLoadingMassage').remove();
257						$.axZm.ovrFsInitPause = true;
258						$.fn.axZm.fullScreenRelChange(newFancybox ? 'fancybox-content-az' : 'fancybox-content', function() {
259							$.fn.axZm.addCallback('onFullScreenCloseEndFromRel', {scrollBarFixFancybox: scrollBarFixFancybox});
260						});
261					}
262				} else {
263					if (!window.fullScreenStartSplash) {
264						window.fullScreenStartSplash = {'enable': true, 'className': false, 'opacity': 0.75}; 
265					}
266
267					$.fn.axZm.openFullScreen(
268						op.axZmPath, 
269						op.queryString, 
270						op.ajaxZoomCallbacks,
271						newFancybox ? 'fancybox-content-az' : 'fancybox-content',
272						op.fullScreenApi,
273						op.escTxt ? false : true,
274						op.postMode
275					);
276				}
277			} else {
278				if (newFancybox) {
279					$(fancyEll.content).find('iframe').css({width: '100%', height: '100%'});
280				}
281			}
282		};
283
284		var afterFancyClose = function() {
285			window.az_touchPageNoScroll = false;
286			// Fancybox callback passed over openAjaxZoomInFancyBox
287			op.boxOnClosed();
288			$('body>.fancybox-inline-tmp').remove();
289			if (!iframeMode) {
290				if (op.fromOpened) {
291					return;
292				}
293
294				// If 360/3D loaded into the fancybox
295				$.fn.axZm.spinStop();
296
297				// Completly remove AJAX-ZOOM from DOM
298				$.fn.axZm.remove();
299				$('#axZmTempBody').axZmRemove(true);
300				$('#axZmTempLoading').axZmRemove(true);
301			}
302
303			if (op.ref) {
304				$('#'+op.ref).removeData('axZmrespFancyBox');
305			}
306		};
307
308		var beforeFancyClose = function() {
309			op.boxOnCleanup();
310
311			if (!iframeMode) {
312				if (op.fromOpened && $.axZm) {
313					$.fn.axZm.fullScreenRelRestore(function() {
314						$.axZm.ovrFsInitPause = false;
315						try {
316							delete ($.axZm.userFunc.onFullScreenCloseEndFromRel.scrollBarFixFancybox);
317						} catch(err) {
318							return false;
319						}
320					});
321				}
322			}
323		};
324
325		// Create an html element to pretend there is something to load into fancybox
326		$('#tempLoadingMassage').remove(); // if present :-)
327
328		if (!iframeMode) {
329			$('<div />').html(op.loadingMsg).attr('id', 'tempLoadingMassage').css('display', 'none').appendTo('body');
330		}
331
332		// Trigger fancybox
333		$.fancybox({
334			padding: op.boxPadding, // boxPadding defined at very beginning
335			margin: op.boxMargin, // boxMargin defined at very beginning
336			overlayShow: op.boxOverlayShow, // optional, show overlay
337			overlayOpacity: op.boxOverlayOpacity, // optional, overlay opacity
338			centerOnScroll: op.boxCenterOnScroll, // optional
339			overlayColor : op.boxOverlayColor, // optional
340			transitionIn: op.boxTransitionIn, // 'elastic', 'fade' or 'none'
341			transitionOut: op.boxTransitionOut, // 'elastic', 'fade' or 'none'
342			speedIn: op.boxSpeedIn,
343			speedOut: op.boxSpeedOut,
344			easingIn: op.boxEasingIn,
345			easingOut: op.boxEasingOut,
346			showCloseButton: op.boxShowCloseButton,
347			enableEscapeButton: op.boxEnableEscapeButton,
348			showNavArrows: false, // required, false
349			enableKeyboardNav: false, // required, false
350			hideOnContentClick: false, // required, do not hide when clicked inside fancybox (AJAX-ZOOM is there)
351			scrolling: op.scrolling, // required, no scrolling
352			width: boxW, // required, boxW is calculated at very beginning
353			height: boxH, // required, boxH is calculated at very beginning
354			autoScale: false, // required
355			autoDimensions: false, // required
356			href: iframeMode ? hrefIframe : '#tempLoadingMassage', // required, pretend there is something to load :-)
357			type: iframeMode ? 'iframe' : null,
358			tpl: {
359				iframe: '<iframe id="fancybox-frame" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" allowtransparency="true" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>',
360			},
361			// disable auto* for fancybox 2.x
362			autoSize: false,
363			autoResize: false,
364			autoCenter: false,
365			fitToView: false,
366			autoWidth: false,
367			autoHeight: false,
368			iframe: {
369				scrolling: op.scrolling,
370				preload: false
371			},
372			onComplete: function() { // fancybox 1.3.4
373				$('body').addClass('az_fancybox');
374				afterFancyLoad();
375			},
376			afterLoad: function() { // fancybox 2.x
377				$('body').addClass('az_fancybox');
378				afterFancyLoad();
379			},
380			onClosed: function() { // fancybox 1.3.4
381				afterFancyClose();
382			},
383			afterClose: function() { // fancybox 2.x
384				afterFancyClose();
385			},
386			onCleanup: function() { // fancybox 1.3.4
387				$('body').removeClass('axZmLock az_fancybox');
388				beforeFancyClose();
389			},
390			beforeClose: function() { // fancybox 2.x
391				$('body').removeClass('axZmLock az_fancybox');
392				beforeFancyClose();
393			},
394			afterShow: function() { // fancybox 2.x
395				$(window).unbind('.fb');
396				getFancyDim();
397				$(window).unbind('resize', cBoxOnWinResize).bind('resize', cBoxOnWinResize);
398				$('#tempLoadingMassage').remove();
399			},
400		});
401	};
402
403	$.fn.unbindAjaxZoomInFancyBox = function() {
404		return this.each(function() {
405			$(this).unbind('click.axZmFb');
406		});
407	};
408
409	$.fn.openAjaxZoomInFancyBox = function(options) {
410		return this.each(function() {
411			$(this).unbindAjaxZoomInFancyBox().bind('click.axZmFb', function() {
412				$.openAjaxZoomInFancyBox(options);
413			});
414		});
415	}
416})(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.