PageSourceSearch

https://cdsckenya.com/wp-content/themes/consultio/assets/js/magnific-popup.min.js?ver=1.0.0

js cdsckenya.com collected 2026-10-03 22:39:21 UTC 45,972 bytes, 2,041 lines download raw bytes

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