PageSourceSearch

https://www.meissenberg.ch/_assets/2c3e2d8b26b4141e3d20f07232ed8e83/js/jquery.magnific-popup.js?1733906442

js meissenberg.ch collected 2026-10-07 18:55:53 UTC 43,548 bytes, 1,859 lines download raw bytes

vendor: 43,548 bytes, lines 1-1859
1/*! Magnific Popup - v1.1.0 - 2016-02-20
2* http://dimsemenov.com/plugins/magnific-popup/
3* Copyright (c) 2016 Dmitry Semenov; */
4;(function (factory) { 
5if (typeof define === 'function' && define.amd) { 
6 // AMD. Register as an anonymous module. 
7 define(['jquery'], factory); 
8 } else if (typeof exports === 'object') { 
9 // Node/CommonJS 
10 factory(require('jquery')); 
11 } else { 
12 // Browser globals 
13 factory(window.jQuery || window.Zepto); 
14 } 
15 }(function($) { 
16
17/*>>core*/
18/**
19 * 
20 * Magnific Popup Core JS file
21 * 
22 */
23
24
25/**
26 * Private static constants
27 */
28var CLOSE_EVENT = 'Close',
29	BEFORE_CLOSE_EVENT = 'BeforeClose',
30	AFTER_CLOSE_EVENT = 'AfterClose',
31	BEFORE_APPEND_EVENT = 'BeforeAppend',
32	MARKUP_PARSE_EVENT = 'MarkupParse',
33	OPEN_EVENT = 'Open',
34	CHANGE_EVENT = 'Change',
35	NS = 'mfp',
36	EVENT_NS = '.' + NS,
37	READY_CLASS = 'mfp-ready',
38	REMOVING_CLASS = 'mfp-removing',
39	PREVENT_CLOSE_CLASS = 'mfp-prevent-close';
40
41
42/**
43 * Private vars 
44 */
45/*jshint -W079 */
46var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this'
47	MagnificPopup = function(){},
48	_isJQ = !!(window.jQuery),
49	_prevStatus,
50	_window = $(window),
51	_document,
52	_prevContentType,
53	_wrapClasses,
54	_currPopupType;
55
56
57/**
58 * Private functions
59 */
60var _mfpOn = function(name, f) {
61		mfp.ev.on(NS + name + EVENT_NS, f);
62	},
63	_getEl = function(className, appendTo, html, raw) {
64		var el = document.createElement('div');
65		el.className = 'mfp-'+className;
66		if(html) {
67			el.innerHTML = html;
68		}
69		if(!raw) {
70			el = $(el);
71			if(appendTo) {
72				el.appendTo(appendTo);
73			}
74		} else if(appendTo) {
75			appendTo.appendChild(el);
76		}
77		return el;
78	},
79	_mfpTrigger = function(e, data) {
80		mfp.ev.triggerHandler(NS + e, data);
81
82		if(mfp.st.callbacks) {
83			// converts "mfpEventName" to "eventName" callback and triggers it if it's present
84			e = e.charAt(0).toLowerCase() + e.slice(1);
85			if(mfp.st.callbacks[e]) {
86				mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]);
87			}
88		}
89	},
90	_getCloseBtn = function(type) {
91		if(type !== _currPopupType || !mfp.currTemplate.closeBtn) {
92			mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) );
93			_currPopupType = type;
94		}
95		return mfp.currTemplate.closeBtn;
96	},
97	// Initialize Magnific Popup only when called at least once
98	_checkInstance = function() {
99		if(!$.magnificPopup.instance) {
100			/*jshint -W020 */
101			mfp = new MagnificPopup();
102			mfp.init();
103			$.magnificPopup.instance = mfp;
104		}
105	},
106	// CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr
107	supportsTransitions = function() {
108		var s = document.createElement('p').style, // 's' for style. better to create an element if body yet to exist
109			v = ['ms','O','Moz','Webkit']; // 'v' for vendor
110
111		if( s['transition'] !== undefined ) {
112			return true; 
113		}
114			
115		while( v.length ) {
116			if( v.pop() + 'Transition' in s ) {
117				return true;
118			}
119		}
120				
121		return false;
122	};
123
124
125
126/**
127 * Public functions
128 */
129MagnificPopup.prototype = {
130
131	constructor: MagnificPopup,
132
133	/**
134	 * Initializes Magnific Popup plugin. 
135	 * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed
136	 */
137	init: function() {
138		var appVersion = navigator.appVersion;
139		mfp.isLowIE = mfp.isIE8 = document.all && !document.addEventListener;
140		mfp.isAndroid = (/android/gi).test(appVersion);
141		mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
142		mfp.supportsTransition = supportsTransitions();
143
144		// We disable fixed positioned lightbox on devices that don't handle it nicely.
145		// If you know a better way of detecting this - let me know.
146		mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) );
147		_document = $(document);
148
149		mfp.popupsCache = {};
150	},
151
152	/**
153	 * Opens popup
154	 * @param  data [description]
155	 */
156	open: function(data) {
157
158		var i;
159
160		if(data.isObj === false) { 
161			// convert jQuery collection to array to avoid conflicts later
162			mfp.items = data.items.toArray();
163
164			mfp.index = 0;
165			var items = data.items,
166				item;
167			for(i = 0; i < items.length; i++) {
168				item = items[i];
169				if(item.parsed) {
170					item = item.el[0];
171				}
172				if(item === data.el[0]) {
173					mfp.index = i;
174					break;
175				}
176			}
177		} else {
178			mfp.items = $.isArray(data.items) ? data.items : [data.items];
179			mfp.index = data.index || 0;
180		}
181
182		// if popup is already opened - we just update the content
183		if(mfp.isOpen) {
184			mfp.updateItemHTML();
185			return;
186		}
187		
188		mfp.types = []; 
189		_wrapClasses = '';
190		if(data.mainEl && data.mainEl.length) {
191			mfp.ev = data.mainEl.eq(0);
192		} else {
193			mfp.ev = _document;
194		}
195
196		if(data.key) {
197			if(!mfp.popupsCache[data.key]) {
198				mfp.popupsCache[data.key] = {};
199			}
200			mfp.currTemplate = mfp.popupsCache[data.key];
201		} else {
202			mfp.currTemplate = {};
203		}
204
205
206
207		mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data ); 
208		mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos;
209
210		if(mfp.st.modal) {
211			mfp.st.closeOnContentClick = false;
212			mfp.st.closeOnBgClick = false;
213			mfp.st.showCloseBtn = false;
214			mfp.st.enableEscapeKey = false;
215		}
216		
217
218		// Building markup
219		// main containers are created only once
220		if(!mfp.bgOverlay) {
221
222			// Dark overlay
223			mfp.bgOverlay = _getEl('bg').on('click'+EVENT_NS, function() {
224				mfp.close();
225			});
226
227			mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) {
228				if(mfp._checkIfClose(e.target)) {
229					mfp.close();
230				}
231			});
232
233			mfp.container = _getEl('container', mfp.wrap);
234		}
235
236		mfp.contentContainer = _getEl('content');
237		if(mfp.st.preloader) {
238			mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading);
239		}
240
241
242		// Initializing modules
243		var modules = $.magnificPopup.modules;
244		for(i = 0; i < modules.length; i++) {
245			var n = modules[i];
246			n = n.charAt(0).toUpperCase() + n.slice(1);
247			mfp['init'+n].call(mfp);
248		}
249		_mfpTrigger('BeforeOpen');
250
251
252		if(mfp.st.showCloseBtn) {
253			// Close button
254			if(!mfp.st.closeBtnInside) {
255				mfp.wrap.append( _getCloseBtn() );
256			} else {
257				_mfpOn(MARKUP_PARSE_EVENT, function(e, template, values, item) {
258					values.close_replaceWith = _getCloseBtn(item.type);
259				});
260				_wrapClasses += ' mfp-close-btn-in';
261			}
262		}
263
264		if(mfp.st.alignTop) {
265			_wrapClasses += ' mfp-align-top';
266		}
267
268	
269
270		if(mfp.fixedContentPos) {
271			mfp.wrap.css({
272				overflow: mfp.st.overflowY,
273				overflowX: 'hidden',
274				overflowY: mfp.st.overflowY
275			});
276		} else {
277			mfp.wrap.css({ 
278				top: _window.scrollTop(),
279				position: 'absolute'
280			});
281		}
282		if( mfp.st.fixedBgPos === false || (mfp.st.fixedBgPos === 'auto' && !mfp.fixedContentPos) ) {
283			mfp.bgOverlay.css({
284				height: _document.height(),
285				position: 'absolute'
286			});
287		}
288
289		
290
291		if(mfp.st.enableEscapeKey) {
292			// Close on ESC key
293			_document.on('keyup' + EVENT_NS, function(e) {
294				if(e.keyCode === 27) {
295					mfp.close();
296				}
297			});
298		}
299
300		_window.on('resize' + EVENT_NS, function() {
301			mfp.updateSize();
302		});
303
304
305		if(!mfp.st.closeOnContentClick) {
306			_wrapClasses += ' mfp-auto-cursor';
307		}
308		
309		if(_wrapClasses)
310			mfp.wrap.addClass(_wrapClasses);
311
312
313		// this triggers recalculation of layout, so we get it once to not to trigger twice
314		var windowHeight = mfp.wH = _window.height();
315
316		
317		var windowStyles = {};
318
319		if( mfp.fixedContentPos ) {
320            if(mfp._hasScrollBar(windowHeight)){
321                var s = mfp._getScrollbarSize();
322                if(s) {
323                    windowStyles.marginRight = s;
324                }
325            }
326        }
327
328		if(mfp.fixedContentPos) {
329			if(!mfp.isIE7) {
330				windowStyles.overflow = 'hidden';
331			} else {
332				// ie7 double-scroll bug
333				$('body, html').css('overflow', 'hidden');
334			}
335		}
336
337		
338		
339		var classesToadd = mfp.st.mainClass;
340		if(mfp.isIE7) {
341			classesToadd += ' mfp-ie7';
342		}
343		if(classesToadd) {
344			mfp._addClassToMFP( classesToadd );
345		}
346
347		// add content
348		mfp.updateItemHTML();
349
350		_mfpTrigger('BuildControls');
351
352		// remove scrollbar, add margin e.t.c
353		$('html').css(windowStyles);
354		
355		// add everything to DOM
356		mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) );
357
358		// Save last focused element
359		mfp._lastFocusedEl = document.activeElement;
360		
361		// Wait for next cycle to allow CSS transition
362		setTimeout(function() {
363			
364			if(mfp.content) {
365				mfp._addClassToMFP(READY_CLASS);
366				mfp._setFocus();
367			} else {
368				// if content is not defined (not loaded e.t.c) we add class only for BG
369				mfp.bgOverlay.addClass(READY_CLASS);
370			}
371			
372			// Trap the focus in popup
373			_document.on('focusin' + EVENT_NS, mfp._onFocusIn);
374
375		}, 16);
376
377		mfp.isOpen = true;
378		mfp.updateSize(windowHeight);
379		_mfpTrigger(OPEN_EVENT);
380
381		return data;
382	},
383
384	/**
385	 * Closes the popup
386	 */
387	close: function() {
388		if(!mfp.isOpen) return;
389		_mfpTrigger(BEFORE_CLOSE_EVENT);
390
391		mfp.isOpen = false;
392		// for CSS3 animation
393		if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition )  {
394			mfp._addClassToMFP(REMOVING_CLASS);
395			setTimeout(function() {
396				mfp._close();
397			}, mfp.st.removalDelay);
398		} else {
399			mfp._close();
400		}
401	},
402
403	/**
404	 * Helper for close() function
405	 */
406	_close: function() {
407		_mfpTrigger(CLOSE_EVENT);
408
409		var classesToRemove = REMOVING_CLASS + ' ' + READY_CLASS + ' ';
410
411		mfp.bgOverlay.detach();
412		mfp.wrap.detach();
413		mfp.container.empty();
414
415		if(mfp.st.mainClass) {
416			classesToRemove += mfp.st.mainClass + ' ';
417		}
418
419		mfp._removeClassFromMFP(classesToRemove);
420
421		if(mfp.fixedContentPos) {
422			var windowStyles = {marginRight: ''};
423			if(mfp.isIE7) {
424				$('body, html').css('overflow', '');
425			} else {
426				windowStyles.overflow = '';
427			}
428			$('html').css(windowStyles);
429		}
430		
431		_document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS);
432		mfp.ev.off(EVENT_NS);
433
434		// clean up DOM elements that aren't removed
435		mfp.wrap.attr('class', 'mfp-wrap').removeAttr('style');
436		mfp.bgOverlay.attr('class', 'mfp-bg');
437		mfp.container.attr('class', 'mfp-container');
438
439		// remove close button from target element
440		if(mfp.st.showCloseBtn &&
441		(!mfp.st.closeBtnInside || mfp.currTemplate[mfp.currItem.type] === true)) {
442			if(mfp.currTemplate.closeBtn)
443				mfp.currTemplate.closeBtn.detach();
444		}
445
446
447		if(mfp.st.autoFocusLast && mfp._lastFocusedEl) {
448			$(mfp._lastFocusedEl).focus(); // put tab focus back
449		}
450		mfp.currItem = null;	
451		mfp.content = null;
452		mfp.currTemplate = null;
453		mfp.prevHeight = 0;
454
455		_mfpTrigger(AFTER_CLOSE_EVENT);
456	},
457	
458	updateSize: function(winHeight) {
459
460		if(mfp.isIOS) {
461			// fixes iOS nav bars https://github.com/dimsemenov/Magnific-Popup/issues/2
462			var zoomLevel = document.documentElement.clientWidth / window.innerWidth;
463			var height = window.innerHeight * zoomLevel;
464			mfp.wrap.css('height', height);
465			mfp.wH = height;
466		} else {
467			mfp.wH = winHeight || _window.height();
468		}
469		// Fixes #84: popup incorrectly positioned with position:relative on body
470		if(!mfp.fixedContentPos) {
471			mfp.wrap.css('height', mfp.wH);
472		}
473
474		_mfpTrigger('Resize');
475
476	},
477
478	/**
479	 * Set content of popup based on current index
480	 */
481	updateItemHTML: function() {
482		var item = mfp.items[mfp.index];
483
484		// Detach and perform modifications
485		mfp.contentContainer.detach();
486
487		if(mfp.content)
488			mfp.content.detach();
489
490		if(!item.parsed) {
491			item = mfp.parseEl( mfp.index );
492		}
493
494		var type = item.type;
495
496		_mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : '', type]);
497		// BeforeChange event works like so:
498		// _mfpOn('BeforeChange', function(e, prevType, newType) { });
499
500		mfp.currItem = item;
501
502		if(!mfp.currTemplate[type]) {
503			var markup = mfp.st[type] ? mfp.st[type].markup : false;
504
505			// allows to modify markup
506			_mfpTrigger('FirstMarkupParse', markup);
507
508			if(markup) {
509				mfp.currTemplate[type] = $(markup);
510			} else {
511				// if there is no markup found we just define that template is parsed
512				mfp.currTemplate[type] = true;
513			}
514		}
515
516		if(_prevContentType && _prevContentType !== item.type) {
517			mfp.container.removeClass('mfp-'+_prevContentType+'-holder');
518		}
519
520		var newContent = mfp['get' + type.charAt(0).toUpperCase() + type.slice(1)](item, mfp.currTemplate[type]);
521		mfp.appendContent(newContent, type);
522
523		item.preloaded = true;
524
525		_mfpTrigger(CHANGE_EVENT, item);
526		_prevContentType = item.type;
527
528		// Append container back after its content changed
529		mfp.container.prepend(mfp.contentContainer);
530
531		_mfpTrigger('AfterChange');
532	},
533
534
535	/**
536	 * Set HTML content of popup
537	 */
538	appendContent: function(newContent, type) {
539		mfp.content = newContent;
540
541		if(newContent) {
542			if(mfp.st.showCloseBtn && mfp.st.closeBtnInside &&
543				mfp.currTemplate[type] === true) {
544				// if there is no markup, we just append close button element inside
545				if(!mfp.content.find('.mfp-close').length) {
546					mfp.content.append(_getCloseBtn());
547				}
548			} else {
549				mfp.content = newContent;
550			}
551		} else {
552			mfp.content = '';
553		}
554
555		_mfpTrigger(BEFORE_APPEND_EVENT);
556		mfp.container.addClass('mfp-'+type+'-holder');
557
558		mfp.contentContainer.append(mfp.content);
559	},
560
561
562	/**
563	 * Creates Magnific Popup data object based on given data
564	 * @param  {int} index Index of item to parse
565	 */
566	parseEl: function(index) {
567		var item = mfp.items[index],
568			type;
569
570		if(item.tagName) {
571			item = { el: $(item) };
572		} else {
573			type = item.type;
574			item = { data: item, src: item.src };
575		}
576
577		if(item.el) {
578			var types = mfp.types;
579
580			// check for 'mfp-TYPE' class
581			for(var i = 0; i < types.length; i++) {
582				if( item.el.hasClass('mfp-'+types[i]) ) {
583					type = types[i];
584					break;
585				}
586			}
587
588			item.src = item.el.attr('data-mfp-src');
589			if(!item.src) {
590				item.src = item.el.attr('href');
591			}
592		}
593
594		item.type = type || mfp.st.type || 'inline';
595		item.index = index;
596		item.parsed = true;
597		mfp.items[index] = item;
598		_mfpTrigger('ElementParse', item);
599
600		return mfp.items[index];
601	},
602
603
604	/**
605	 * Initializes single popup or a group of popups
606	 */
607	addGroup: function(el, options) {
608		var eHandler = function(e) {
609			e.mfpEl = this;
610			mfp._openClick(e, el, options);
611		};
612
613		if(!options) {
614			options = {};
615		}
616
617		var eName = 'click.magnificPopup';
618		options.mainEl = el;
619
620		if(options.items) {
621			options.isObj = true;
622			el.off(eName).on(eName, eHandler);
623		} else {
624			options.isObj = false;
625			if(options.delegate) {
626				el.off(eName).on(eName, options.delegate , eHandler);
627			} else {
628				options.items = el;
629				el.off(eName).on(eName, eHandler);
630			}
631		}
632	},
633	_openClick: function(e, el, options) {
634		var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick;
635
636
637		if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey ) ) {
638			return;
639		}
640
641		var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
642
643		if(disableOn) {
644			if($.isFunction(disableOn)) {
645				if( !disableOn.call(mfp) ) {
646					return true;
647				}
648			} else { // else it's number
649				if( _window.width() < disableOn ) {
650					return true;
651				}
652			}
653		}
654
655		if(e.type) {
656			e.preventDefault();
657
658			// This will prevent popup from closing if element is inside and popup is already opened
659			if(mfp.isOpen) {
660				e.stopPropagation();
661			}
662		}
663
664		options.el = $(e.mfpEl);
665		if(options.delegate) {
666			options.items = el.find(options.delegate);
667		}
668		mfp.open(options);
669	},
670
671
672	/**
673	 * Updates text on preloader
674	 */
675	updateStatus: function(status, text) {
676
677		if(mfp.preloader) {
678			if(_prevStatus !== status) {
679				mfp.container.removeClass('mfp-s-'+_prevStatus);
680			}
681
682			if(!text && status === 'loading') {
683				text = mfp.st.tLoading;
684			}
685
686			var data = {
687				status: status,
688				text: text
689			};
690			// allows to modify status
691			_mfpTrigger('UpdateStatus', data);
692
693			status = data.status;
694			text = data.text;
695
696			mfp.preloader.html(text);
697
698			mfp.preloader.find('a').on('click', function(e) {
699				e.stopImmediatePropagation();
700			});
701
702			mfp.container.addClass('mfp-s-'+status);
703			_prevStatus = status;
704		}
705	},
706
707
708	/*
709		"Private" helpers that aren't private at all
710	 */
711	// Check to close popup or not
712	// "target" is an element that was clicked
713	_checkIfClose: function(target) {
714
715		if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
716			return;
717		}
718
719		var closeOnContent = mfp.st.closeOnContentClick;
720		var closeOnBg = mfp.st.closeOnBgClick;
721
722		if(closeOnContent && closeOnBg) {
723			return true;
724		} else {
725
726			// We close the popup if click is on close button or on preloader. Or if there is no content.
727			if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
728				return true;
729			}
730
731			// if click is outside the content
732			if(  (target !== mfp.content[0] && !$.contains(mfp.content[0], target))  ) {
733				if(closeOnBg) {
734					// last check, if the clicked element is in DOM, (in case it's removed onclick)
735					if( $.contains(document, target) ) {
736						return true;
737					}
738				}
739			} else if(closeOnContent) {
740				return true;
741			}
742
743		}
744		return false;
745	},
746	_addClassToMFP: function(cName) {
747		mfp.bgOverlay.addClass(cName);
748		mfp.wrap.addClass(cName);
749	},
750	_removeClassFromMFP: function(cName) {
751		this.bgOverlay.removeClass(cName);
752		mfp.wrap.removeClass(cName);
753	},
754	_hasScrollBar: function(winHeight) {
755		return (  (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) );
756	},
757	_setFocus: function() {
758		(mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
759	},
760	_onFocusIn: function(e) {
761		if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
762			mfp._setFocus();
763			return false;
764		}
765	},
766	_parseMarkup: function(template, values, item) {
767		var arr;
768		if(item.data) {
769			values = $.extend(item.data, values);
770		}
771		_mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] );
772
773		$.each(values, function(key, value) {
774			if(value === undefined || value === false) {
775				return true;
776			}
777			arr = key.split('_');
778			if(arr.length > 1) {
779				var el = template.find(EVENT_NS + '-'+arr[0]);
780
781				if(el.length > 0) {
782					var attr = arr[1];
783					if(attr === 'replaceWith') {
784						if(el[0] !== value[0]) {
785							el.replaceWith(value);
786						}
787					} else if(attr === 'img') {
788						if(el.is('img')) {
789							el.attr('src', value);
790						} else {
791							el.replaceWith( $('<img>').attr('src', value).attr('class', el.attr('class')) );
792						}
793					} else {
794						el.attr(arr[1], value);
795					}
796				}
797
798			} else {
799				template.find(EVENT_NS + '-'+key).html(value);
800			}
801		});
802	},
803
804	_getScrollbarSize: function() {
805		// thx David
806		if(mfp.scrollbarSize === undefined) {
807			var scrollDiv = document.createElement("div");
808			scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
809			document.body.appendChild(scrollDiv);
810			mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
811			document.body.removeChild(scrollDiv);
812		}
813		return mfp.scrollbarSize;
814	}
815
816}; /* MagnificPopup core prototype end */
817
818
819
820
821/**
822 * Public static functions
823 */
824$.magnificPopup = {
825	instance: null,
826	proto: MagnificPopup.prototype,
827	modules: [],
828
829	open: function(options, index) {
830		_checkInstance();
831
832		if(!options) {
833			options = {};
834		} else {
835			options = $.extend(true, {}, options);
836		}
837
838		options.isObj = true;
839		options.index = index || 0;
840		return this.instance.open(options);
841	},
842
843	close: function() {
844		return $.magnificPopup.instance && $.magnificPopup.instance.close();
845	},
846
847	registerModule: function(name, module) {
848		if(module.options) {
849			$.magnificPopup.defaults[name] = module.options;
850		}
851		$.extend(this.proto, module.proto);
852		this.modules.push(name);
853	},
854
855	defaults: {
856
857		// Info about options is in docs:
858		// http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
859
860		disableOn: 0,
861
862		key: null,
863
864		midClick: false,
865
866		mainClass: '',
867
868		preloader: true,
869
870		focus: '', // CSS selector of input to focus after popup is opened
871
872		closeOnContentClick: false,
873
874		closeOnBgClick: true,
875
876		closeBtnInside: true,
877
878		showCloseBtn: true,
879
880		enableEscapeKey: true,
881
882		modal: false,
883
884		alignTop: false,
885
886		removalDelay: 0,
887
888		prependTo: null,
889
890		fixedContentPos: 'auto',
891
892		fixedBgPos: 'auto',
893
894		overflowY: 'auto',
895
896		closeMarkup: '<button title="%title%" type="button" class="mfp-close">&#215;</button>',
897
898		tClose: 'Close (Esc)',
899
900		tLoading: 'Loading...',
901
902		autoFocusLast: true
903
904	}
905};
906
907
908
909$.fn.magnificPopup = function(options) {
910	_checkInstance();
911
912	var jqEl = $(this);
913
914	// We call some API method of first param is a string
915	if (typeof options === "string" ) {
916
917		if(options === 'open') {
918			var items,
919				itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
920				index = parseInt(arguments[1], 10) || 0;
921
922			if(itemOpts.items) {
923				items = itemOpts.items[index];
924			} else {
925				items = jqEl;
926				if(itemOpts.delegate) {
927					items = items.find(itemOpts.delegate);
928				}
929				items = items.eq( index );
930			}
931			mfp._openClick({mfpEl:items}, jqEl, itemOpts);
932		} else {
933			if(mfp.isOpen)
934				mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
935		}
936
937	} else {
938		// clone options obj
939		options = $.extend(true, {}, options);
940
941		/*
942		 * As Zepto doesn't support .data() method for objects
943		 * and it works only in normal browsers
944		 * we assign "options" object directly to the DOM element. FTW!
945		 */
946		if(_isJQ) {
947			jqEl.data('magnificPopup', options);
948		} else {
949			jqEl[0].magnificPopup = options;
950		}
951
952		mfp.addGroup(jqEl, options);
953
954	}
955	return jqEl;
956};
957
958/*>>core*/
959
960/*>>inline*/
961
962var INLINE_NS = 'inline',
963	_hiddenClass,
964	_inlinePlaceholder,
965	_lastInlineElement,
966	_putInlineElementsBack = function() {
967		if(_lastInlineElement) {
968			_inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
969			_lastInlineElement = null;
970		}
971	};
972
973$.magnificPopup.registerModule(INLINE_NS, {
974	options: {
975		hiddenClass: 'hide', // will be appended with `mfp-` prefix
976		markup: '',
977		tNotFound: 'Content not found'
978	},
979	proto: {
980
981		initInline: function() {
982			mfp.types.push(INLINE_NS);
983
984			_mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
985				_putInlineElementsBack();
986			});
987		},
988
989		getInline: function(item, template) {
990
991			_putInlineElementsBack();
992
993			if(item.src) {
994				var inlineSt = mfp.st.inline,
995					el = $(item.src);
996
997				if(el.length) {
998
999					// If target element has parent - we replace it with placeholder and put it back after popup is closed
1000					var parent = el[0].parentNode;
1001					if(parent && parent.tagName) {
1002						if(!_inlinePlaceholder) {
1003							_hiddenClass = inlineSt.hiddenClass;
1004							_inlinePlaceholder = _getEl(_hiddenClass);
1005							_hiddenClass = 'mfp-'+_hiddenClass;
1006						}
1007						// replace target inline element with placeholder
1008						_lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
1009					}
1010
1011					mfp.updateStatus('ready');
1012				} else {
1013					mfp.updateStatus('error', inlineSt.tNotFound);
1014					el = $('<div>');
1015				}
1016
1017				item.inlineElement = el;
1018				return el;
1019			}
1020
1021			mfp.updateStatus('ready');
1022			mfp._parseMarkup(template, {}, item);
1023			return template;
1024		}
1025	}
1026});
1027
1028/*>>inline*/
1029
1030/*>>ajax*/
1031var AJAX_NS = 'ajax',
1032	_ajaxCur,
1033	_removeAjaxCursor = function() {
1034		if(_ajaxCur) {
1035			$(document.body).removeClass(_ajaxCur);
1036		}
1037	},
1038	_destroyAjaxRequest = function() {
1039		_removeAjaxCursor();
1040		if(mfp.req) {
1041			mfp.req.abort();
1042		}
1043	};
1044
1045$.magnificPopup.registerModule(AJAX_NS, {
1046
1047	options: {
1048		settings: null,
1049		cursor: 'mfp-ajax-cur',
1050		tError: '<a href="%url%">The content</a> could not be loaded.'
1051	},
1052
1053	proto: {
1054		initAjax: function() {
1055			mfp.types.push(AJAX_NS);
1056			_ajaxCur = mfp.st.ajax.cursor;
1057
1058			_mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest);
1059			_mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest);
1060		},
1061		getAjax: function(item) {
1062
1063			if(_ajaxCur) {
1064				$(document.body).addClass(_ajaxCur);
1065			}
1066
1067			mfp.updateStatus('loading');
1068
1069			var opts = $.extend({
1070				url: item.src,
1071				success: function(data, textStatus, jqXHR) {
1072					var temp = {
1073						data:data,
1074						xhr:jqXHR
1075					};
1076
1077					_mfpTrigger('ParseAjax', temp);
1078
1079					mfp.appendContent( $(temp.data), AJAX_NS );
1080
1081					item.finished = true;
1082
1083					_removeAjaxCursor();
1084
1085					mfp._setFocus();
1086
1087					setTimeout(function() {
1088						mfp.wrap.addClass(READY_CLASS);
1089					}, 16);
1090
1091					mfp.updateStatus('ready');
1092
1093					_mfpTrigger('AjaxContentAdded');
1094				},
1095				error: function() {
1096					_removeAjaxCursor();
1097					item.finished = item.loadError = true;
1098					mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src));
1099				}
1100			}, mfp.st.ajax.settings);
1101
1102			mfp.req = $.ajax(opts);
1103
1104			return '';
1105		}
1106	}
1107});
1108
1109/*>>ajax*/
1110
1111/*>>image*/
1112var _imgInterval,
1113	_getTitle = function(item) {
1114		if(item.data && item.data.title !== undefined)
1115			return item.data.title;
1116
1117		var src = mfp.st.image.titleSrc;
1118
1119		if(src) {
1120			if($.isFunction(src)) {
1121				return src.call(mfp, item);
1122			} else if(item.el) {
1123				return item.el.attr(src) || '';
1124			}
1125		}
1126		return '';
1127	};
1128
1129$.magnificPopup.registerModule('image', {
1130
1131	options: {
1132		markup: '<div class="mfp-figure">'+
1133					'<div class="container">'+
1134						'<div class="mfp-bottom-bar"> '+
1135							'<div class="mfp-close"></div>'+
1136							'<div class="mfp-counter"></div>'+
1137						'</div>'+
1138					'</div>'+
1139					'<figure>'+
1140						'<div class="mfp-img"></div>'+
1141					'</figure>'+
1142				'</div>',
1143		cursor: 'mfp-zoom-out-cur',
1144		titleSrc: 'title',
1145		verticalFit: true,
1146		tError: '<a href="%url%">The image</a> could not be loaded.'
1147	},
1148
1149	proto: {
1150		initImage: function() {
1151			var imgSt = mfp.st.image,
1152				ns = '.image';
1153
1154			mfp.types.push('image');
1155
1156			_mfpOn(OPEN_EVENT+ns, function() {
1157				if(mfp.currItem.type === 'image' && imgSt.cursor) {
1158					$(document.body).addClass(imgSt.cursor);
1159				}
1160			});
1161
1162			_mfpOn(CLOSE_EVENT+ns, function() {
1163				if(imgSt.cursor) {
1164					$(document.body).removeClass(imgSt.cursor);
1165				}
1166				_window.off('resize' + EVENT_NS);
1167			});
1168
1169			_mfpOn('Resize'+ns, mfp.resizeImage);
1170			if(mfp.isLowIE) {
1171				_mfpOn('AfterChange', mfp.resizeImage);
1172			}
1173		},
1174		resizeImage: function() {
1175			var item = mfp.currItem;
1176			if(!item || !item.img) return;
1177
1178			if(mfp.st.image.verticalFit) {
1179				var decr = 0;
1180				// fix box-sizing in ie7/8
1181				if(mfp.isLowIE) {
1182					decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10);
1183				}
1184				item.img.css('max-height', mfp.wH-decr);
1185			}
1186		},
1187		_onImageHasSize: function(item) {
1188			if(item.img) {
1189
1190				item.hasSize = true;
1191
1192				if(_imgInterval) {
1193					clearInterval(_imgInterval);
1194				}
1195
1196				item.isCheckingImgSize = false;
1197
1198				_mfpTrigger('ImageHasSize', item);
1199
1200				if(item.imgHidden) {
1201					if(mfp.content)
1202						mfp.content.removeClass('mfp-loading');
1203
1204					item.imgHidden = false;
1205				}
1206
1207			}
1208		},
1209
1210		/**
1211		 * Function that loops until the image has size to display elements that rely on it asap
1212		 */
1213		findImageSize: function(item) {
1214
1215			var counter = 0,
1216				img = item.img[0],
1217				mfpSetInterval = function(delay) {
1218
1219					if(_imgInterval) {
1220						clearInterval(_imgInterval);
1221					}
1222					// decelerating interval that checks for size of an image
1223					_imgInterval = setInterval(function() {
1224						if(img.naturalWidth > 0) {
1225							mfp._onImageHasSize(item);
1226							return;
1227						}
1228
1229						if(counter > 200) {
1230							clearInterval(_imgInterval);
1231						}
1232
1233						counter++;
1234						if(counter === 3) {
1235							mfpSetInterval(10);
1236						} else if(counter === 40) {
1237							mfpSetInterval(50);
1238						} else if(counter === 100) {
1239							mfpSetInterval(500);
1240						}
1241					}, delay);
1242				};
1243
1244			mfpSetInterval(1);
1245		},
1246
1247		getImage: function(item, template) {
1248
1249			var guard = 0,
1250
1251				// image load complete handler
1252				onLoadComplete = function() {
1253					if(item) {
1254						if (item.img[0].complete) {
1255							item.img.off('.mfploader');
1256
1257							if(item === mfp.currItem){
1258								mfp._onImageHasSize(item);
1259
1260								mfp.updateStatus('ready');
1261							}
1262
1263							item.hasSize = true;
1264							item.loaded = true;
1265
1266							_mfpTrigger('ImageLoadComplete');
1267
1268						}
1269						else {
1270							// if image complete check fails 200 times (20 sec), we assume that there was an error.
1271							guard++;
1272							if(guard < 200) {
1273								setTimeout(onLoadComplete,100);
1274							} else {
1275								onLoadError();
1276							}
1277						}
1278					}
1279				},
1280
1281				// image error handler
1282				onLoadError = function() {
1283					if(item) {
1284						item.img.off('.mfploader');
1285						if(item === mfp.currItem){
1286							mfp._onImageHasSize(item);
1287							mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1288						}
1289
1290						item.hasSize = true;
1291						item.loaded = true;
1292						item.loadError = true;
1293					}
1294				},
1295				imgSt = mfp.st.image;
1296
1297
1298			var el = template.find('.mfp-img');
1299			if(el.length) {
1300				var img = document.createElement('img');
1301				img.className = 'mfp-img';
1302				if(item.el && item.el.find('img').length) {
1303					img.alt = item.el.find('img').attr('alt');
1304				}
1305				item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError);
1306				img.src = item.src;
1307
1308				// without clone() "error" event is not firing when IMG is replaced by new IMG
1309				// TODO: find a way to avoid such cloning
1310				if(el.is('img')) {
1311					item.img = item.img.clone();
1312				}
1313
1314				img = item.img[0];
1315				if(img.naturalWidth > 0) {
1316					item.hasSize = true;
1317				} else if(!img.width) {
1318					item.hasSize = false;
1319				}
1320			}
1321
1322			mfp._parseMarkup(template, {
1323				title: _getTitle(item),
1324				img_replaceWith: item.img
1325			}, item);
1326
1327			mfp.resizeImage();
1328
1329			if(item.hasSize) {
1330				if(_imgInterval) clearInterval(_imgInterval);
1331
1332				if(item.loadError) {
1333					template.addClass('mfp-loading');
1334					mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1335				} else {
1336					template.removeClass('mfp-loading');
1337					mfp.updateStatus('ready');
1338				}
1339				return template;
1340			}
1341
1342			mfp.updateStatus('loading');
1343			item.loading = true;
1344
1345			if(!item.hasSize) {
1346				item.imgHidden = true;
1347				template.addClass('mfp-loading');
1348				mfp.findImageSize(item);
1349			}
1350
1351			return template;
1352		}
1353	}
1354});
1355
1356/*>>image*/
1357
1358/*>>zoom*/
1359var hasMozTransform,
1360	getHasMozTransform = function() {
1361		if(hasMozTransform === undefined) {
1362			hasMozTransform = document.createElement('p').style.MozTransform !== undefined;
1363		}
1364		return hasMozTransform;
1365	};
1366
1367$.magnificPopup.registerModule('zoom', {
1368
1369	options: {
1370		enabled: false,
1371		easing: 'ease-in-out',
1372		duration: 300,
1373		opener: function(element) {
1374			return element.is('img') ? element : element.find('img');
1375		}
1376	},
1377
1378	proto: {
1379
1380		initZoom: function() {
1381			var zoomSt = mfp.st.zoom,
1382				ns = '.zoom',
1383				image;
1384
1385			if(!zoomSt.enabled || !mfp.supportsTransition) {
1386				return;
1387			}
1388
1389			var duration = zoomSt.duration,
1390				getElToAnimate = function(image) {
1391					var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'),
1392						transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing,
1393						cssObj = {
1394							position: 'fixed',
1395							zIndex: 9999,
1396							left: 0,
1397							top: 0,
1398							'-webkit-backface-visibility': 'hidden'
1399						},
1400						t = 'transition';
1401
1402					cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition;
1403
1404					newImg.css(cssObj);
1405					return newImg;
1406				},
1407				showMainContent = function() {
1408					mfp.content.css('visibility', 'visible');
1409				},
1410				openTimeout,
1411				animatedImg;
1412
1413			_mfpOn('BuildControls'+ns, function() {
1414				if(mfp._allowZoom()) {
1415
1416					clearTimeout(openTimeout);
1417					mfp.content.css('visibility', 'hidden');
1418
1419					// Basically, all code below does is clones existing image, puts in on top of the current one and animated it
1420
1421					image = mfp._getItemToZoom();
1422
1423					if(!image) {
1424						showMainContent();
1425						return;
1426					}
1427
1428					animatedImg = getElToAnimate(image);
1429
1430					animatedImg.css( mfp._getOffset() );
1431
1432					mfp.wrap.append(animatedImg);
1433
1434					openTimeout = setTimeout(function() {
1435						animatedImg.css( mfp._getOffset( true ) );
1436						openTimeout = setTimeout(function() {
1437
1438							showMainContent();
1439
1440							setTimeout(function() {
1441								animatedImg.remove();
1442								image = animatedImg = null;
1443								_mfpTrigger('ZoomAnimationEnded');
1444							}, 16); // avoid blink when switching images
1445
1446						}, duration); // this timeout equals animation duration
1447
1448					}, 16); // by adding this timeout we avoid short glitch at the beginning of animation
1449
1450
1451					// Lots of timeouts...
1452				}
1453			});
1454			_mfpOn(BEFORE_CLOSE_EVENT+ns, function() {
1455				if(mfp._allowZoom()) {
1456
1457					clearTimeout(openTimeout);
1458
1459					mfp.st.removalDelay = duration;
1460
1461					if(!image) {
1462						image = mfp._getItemToZoom();
1463						if(!image) {
1464							return;
1465						}
1466						animatedImg = getElToAnimate(image);
1467					}
1468
1469					animatedImg.css( mfp._getOffset(true) );
1470					mfp.wrap.append(animatedImg);
1471					mfp.content.css('visibility', 'hidden');
1472
1473					setTimeout(function() {
1474						animatedImg.css( mfp._getOffset() );
1475					}, 16);
1476				}
1477
1478			});
1479
1480			_mfpOn(CLOSE_EVENT+ns, function() {
1481				if(mfp._allowZoom()) {
1482					showMainContent();
1483					if(animatedImg) {
1484						animatedImg.remove();
1485					}
1486					image = null;
1487				}
1488			});
1489		},
1490
1491		_allowZoom: function() {
1492			return mfp.currItem.type === 'image';
1493		},
1494
1495		_getItemToZoom: function() {
1496			if(mfp.currItem.hasSize) {
1497				return mfp.currItem.img;
1498			} else {
1499				return false;
1500			}
1501		},
1502
1503		// Get element postion relative to viewport
1504		_getOffset: function(isLarge) {
1505			var el;
1506			if(isLarge) {
1507				el = mfp.currItem.img;
1508			} else {
1509				el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
1510			}
1511
1512			var offset = el.offset();
1513			var paddingTop = parseInt(el.css('padding-top'),10);
1514			var paddingBottom = parseInt(el.css('padding-bottom'),10);
1515			offset.top -= ( $(window).scrollTop() - paddingTop );
1516
1517
1518			/*
1519
1520			Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
1521
1522			 */
1523			var obj = {
1524				width: el.width(),
1525				// fix Zepto height+padding issue
1526				height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
1527			};
1528
1529			// I hate to do this, but there is no another option
1530			if( getHasMozTransform() ) {
1531				obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
1532			} else {
1533				obj.left = offset.left;
1534				obj.top = offset.top;
1535			}
1536			return obj;
1537		}
1538
1539	}
1540});
1541
1542
1543
1544/*>>zoom*/
1545
1546/*>>iframe*/
1547
1548var IFRAME_NS = 'iframe',
1549	_emptyPage = '//about:blank',
1550
1551	_fixIframeBugs = function(isShowing) {
1552		if(mfp.currTemplate[IFRAME_NS]) {
1553			var el = mfp.currTemplate[IFRAME_NS].find('iframe');
1554			if(el.length) {
1555				// reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug
1556				if(!isShowing) {
1557					el[0].src = _emptyPage;
1558				}
1559
1560				// IE8 black screen bug fix
1561				if(mfp.isIE8) {
1562					el.css('display', isShowing ? 'block' : 'none');
1563				}
1564			}
1565		}
1566	};
1567
1568$.magnificPopup.registerModule(IFRAME_NS, {
1569
1570	options: {
1571		markup: '<div class="mfp-iframe-scaler">'+
1572					'<div class="mfp-close"></div>'+
1573					'<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
1574				'</div>',
1575
1576		srcAction: 'iframe_src',
1577
1578		// we don't care and support only one default type of URL by default
1579		patterns: {
1580			youtube: {
1581				index: 'youtube.com',
1582				id: 'v=',
1583				src: '//www.youtube.com/embed/%id%?autoplay=1'
1584			},
1585			vimeo: {
1586				index: 'vimeo.com/',
1587				id: '/',
1588				src: '//player.vimeo.com/video/%id%?autoplay=1'
1589			},
1590			gmaps: {
1591				index: '//maps.google.',
1592				src: '%id%&output=embed'
1593			}
1594		}
1595	},
1596
1597	proto: {
1598		initIframe: function() {
1599			mfp.types.push(IFRAME_NS);
1600
1601			_mfpOn('BeforeChange', function(e, prevType, newType) {
1602				if(prevType !== newType) {
1603					if(prevType === IFRAME_NS) {
1604						_fixIframeBugs(); // iframe if removed
1605					} else if(newType === IFRAME_NS) {
1606						_fixIframeBugs(true); // iframe is showing
1607					}
1608				}// else {
1609					// iframe source is switched, don't do anything
1610				//}
1611			});
1612
1613			_mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
1614				_fixIframeBugs();
1615			});
1616		},
1617
1618		getIframe: function(item, template) {
1619			var embedSrc = item.src;
1620			var iframeSt = mfp.st.iframe;
1621
1622			$.each(iframeSt.patterns, function() {
1623				if(embedSrc.indexOf( this.index ) > -1) {
1624					if(this.id) {
1625						if(typeof this.id === 'string') {
1626							embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);
1627						} else {
1628							embedSrc = this.id.call( this, embedSrc );
1629						}
1630					}
1631					embedSrc = this.src.replace('%id%', embedSrc );
1632					return false; // break;
1633				}
1634			});
1635
1636			var dataObj = {};
1637			if(iframeSt.srcAction) {
1638				dataObj[iframeSt.srcAction] = embedSrc;
1639			}
1640			mfp._parseMarkup(template, dataObj, item);
1641
1642			mfp.updateStatus('ready');
1643
1644			return template;
1645		}
1646	}
1647});
1648
1649
1650
1651/*>>iframe*/
1652
1653/*>>gallery*/
1654/**
1655 * Get looped index depending on number of slides
1656 */
1657var _getLoopedId = function(index) {
1658		var numSlides = mfp.items.length;
1659		if(index > numSlides - 1) {
1660			return index - numSlides;
1661		} else  if(index < 0) {
1662			return numSlides + index;
1663		}
1664		return index;
1665	},
1666	_replaceCurrTotal = function(text, curr, total) {
1667		return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total);
1668	};
1669
1670$.magnificPopup.registerModule('gallery', {
1671
1672	options: {
1673		enabled: false,
1674		arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
1675		preload: [0,2],
1676		navigateByImgClick: true,
1677		arrows: true,
1678
1679		tPrev: 'Previous (Left arrow key)',
1680		tNext: 'Next (Right arrow key)',
1681		tCounter: '%curr% / %total%'
1682	},
1683
1684	proto: {
1685		initGallery: function() {
1686
1687			var gSt = mfp.st.gallery,
1688				ns = '.mfp-gallery';
1689
1690			mfp.direction = true; // true - next, false - prev
1691
1692			if(!gSt || !gSt.enabled ) return false;
1693
1694			_wrapClasses += ' mfp-gallery';
1695
1696			_mfpOn(OPEN_EVENT+ns, function() {
1697
1698				if(gSt.navigateByImgClick) {
1699					mfp.wrap.on('click'+ns, '.mfp-img', function() {
1700						if(mfp.items.length > 1) {
1701							mfp.next();
1702							return false;
1703						}
1704					});
1705				}
1706
1707				_document.on('keydown'+ns, function(e) {
1708					if (e.keyCode === 37) {
1709						mfp.prev();
1710					} else if (e.keyCode === 39) {
1711						mfp.next();
1712					}
1713				});
1714			});
1715
1716			_mfpOn('UpdateStatus'+ns, function(e, data) {
1717				if(data.text) {
1718					data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length);
1719				}
1720			});
1721
1722			_mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
1723				var l = mfp.items.length;
1724				values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
1725			});
1726
1727			_mfpOn('BuildControls' + ns, function() {
1728				if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
1729					var markup = gSt.arrowMarkup,
1730						arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS),
1731						arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS);
1732
1733					arrowLeft.click(function() {
1734						mfp.prev();
1735					});
1736					arrowRight.click(function() {
1737						mfp.next();
1738					});
1739
1740					mfp.container.append(arrowLeft.add(arrowRight));
1741				}
1742			});
1743
1744			_mfpOn(CHANGE_EVENT+ns, function() {
1745				if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout);
1746
1747				mfp._preloadTimeout = setTimeout(function() {
1748					mfp.preloadNearbyImages();
1749					mfp._preloadTimeout = null;
1750				}, 16);
1751			});
1752
1753
1754			_mfpOn(CLOSE_EVENT+ns, function() {
1755				_document.off(ns);
1756				mfp.wrap.off('click'+ns);
1757				mfp.arrowRight = mfp.arrowLeft = null;
1758			});
1759
1760		},
1761		next: function() {
1762			mfp.direction = true;
1763			mfp.index = _getLoopedId(mfp.index + 1);
1764			mfp.updateItemHTML();
1765		},
1766		prev: function() {
1767			mfp.direction = false;
1768			mfp.index = _getLoopedId(mfp.index - 1);
1769			mfp.updateItemHTML();
1770		},
1771		goTo: function(newIndex) {
1772			mfp.direction = (newIndex >= mfp.index);
1773			mfp.index = newIndex;
1774			mfp.updateItemHTML();
1775		},
1776		preloadNearbyImages: function() {
1777			var p = mfp.st.gallery.preload,
1778				preloadBefore = Math.min(p[0], mfp.items.length),
1779				preloadAfter = Math.min(p[1], mfp.items.length),
1780				i;
1781
1782			for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) {
1783				mfp._preloadItem(mfp.index+i);
1784			}
1785			for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) {
1786				mfp._preloadItem(mfp.index-i);
1787			}
1788		},
1789		_preloadItem: function(index) {
1790			index = _getLoopedId(index);
1791
1792			if(mfp.items[index].preloaded) {
1793				return;
1794			}
1795
1796			var item = mfp.items[index];
1797			if(!item.parsed) {
1798				item = mfp.parseEl( index );
1799			}
1800
1801			_mfpTrigger('LazyLoad', item);
1802
1803			if(item.type === 'image') {
1804				item.img = $('<img class="mfp-img" />').on('load.mfploader', function() {
1805					item.hasSize = true;
1806				}).on('error.mfploader', function() {
1807					item.hasSize = true;
1808					item.loadError = true;
1809					_mfpTrigger('LazyLoadError', item);
1810				}).attr('src', item.src);
1811			}
1812
1813
1814			item.preloaded = true;
1815		}
1816	}
1817});
1818
1819/*>>gallery*/
1820
1821/*>>retina*/
1822
1823var RETINA_NS = 'retina';
1824
1825$.magnificPopup.registerModule(RETINA_NS, {
1826	options: {
1827		replaceSrc: function(item) {
1828			return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; });
1829		},
1830		ratio: 1 // Function or number.  Set to 1 to disable.
1831	},
1832	proto: {
1833		initRetina: function() {
1834			if(window.devicePixelRatio > 1) {
1835
1836				var st = mfp.st.retina,
1837					ratio = st.ratio;
1838
1839				ratio = !isNaN(ratio) ? ratio : ratio();
1840
1841				if(ratio > 1) {
1842					_mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
1843						item.img.css({
1844							'max-width': item.img[0].naturalWidth / ratio,
1845							'width': '100%'
1846						});
1847					});
1848					_mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
1849						item.src = st.replaceSrc(item, ratio);
1850					});
1851				}
1852			}
1853
1854		}
1855	}
1856});
1857
1858/*>>retina*/
1859 _checkInstance(); }));

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.