PageSourceSearch

https://saviti.eu/catalog/view/theme/journal2/lib/magnific-popup/jquery.magnific-popup.js?j2v=32.16.8

js saviti.eu collected 2026-10-06 12:51:54 UTC 45,942 bytes, 2,048 lines download raw bytes

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

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.