minimal-mistakes-jekyll 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/LICENSE.txt +20 -20
  4. data/README.md +160 -160
  5. data/_includes/analytics-providers/custom.html +2 -2
  6. data/_includes/analytics-providers/google-universal.html +9 -9
  7. data/_includes/analytics-providers/google.html +10 -10
  8. data/_includes/analytics.html +11 -11
  9. data/_includes/archive-single.html +37 -37
  10. data/_includes/author-profile-custom-links.html +6 -6
  11. data/_includes/author-profile.html +249 -241
  12. data/_includes/base_path +4 -4
  13. data/_includes/breadcrumbs.html +39 -39
  14. data/_includes/browser-upgrade.html +2 -2
  15. data/_includes/category-list.html +25 -25
  16. data/_includes/comment.html +21 -21
  17. data/_includes/comments-providers/custom.html +2 -2
  18. data/_includes/comments-providers/discourse.html +13 -13
  19. data/_includes/comments-providers/disqus.html +21 -21
  20. data/_includes/comments-providers/facebook.html +7 -7
  21. data/_includes/comments-providers/google-plus.html +1 -1
  22. data/_includes/comments-providers/scripts.html +15 -17
  23. data/_includes/comments-providers/staticman.html +41 -41
  24. data/_includes/comments.html +95 -83
  25. data/_includes/feature_row +49 -49
  26. data/_includes/figure +12 -12
  27. data/_includes/footer.html +25 -22
  28. data/_includes/footer/custom.html +2 -2
  29. data/_includes/gallery +46 -46
  30. data/_includes/group-by-array +46 -46
  31. data/_includes/head.html +33 -33
  32. data/_includes/head/custom.html +4 -4
  33. data/_includes/masthead.html +20 -20
  34. data/_includes/nav_list +46 -46
  35. data/_includes/page__hero.html +53 -53
  36. data/_includes/page__hero_video.html +4 -4
  37. data/_includes/page__taxonomy.html +6 -6
  38. data/_includes/paginator.html +69 -69
  39. data/_includes/post_pagination.html +13 -13
  40. data/_includes/read-time.html +14 -14
  41. data/_includes/scripts.html +4 -4
  42. data/_includes/seo.html +147 -147
  43. data/_includes/sidebar.html +22 -22
  44. data/_includes/social-share.html +13 -13
  45. data/_includes/tag-list.html +25 -25
  46. data/_includes/toc +6 -6
  47. data/_includes/video +11 -11
  48. data/_layouts/archive-taxonomy.html +14 -14
  49. data/_layouts/archive.html +25 -25
  50. data/_layouts/compress.html +10 -10
  51. data/_layouts/default.html +34 -34
  52. data/_layouts/home.html +11 -11
  53. data/_layouts/single.html +74 -74
  54. data/_layouts/splash.html +21 -21
  55. data/_sass/minimal-mistakes.scss +39 -39
  56. data/_sass/minimal-mistakes/_animations.scss +20 -20
  57. data/_sass/minimal-mistakes/_archive.scss +237 -237
  58. data/_sass/minimal-mistakes/_base.scss +314 -314
  59. data/_sass/minimal-mistakes/_buttons.scss +152 -152
  60. data/_sass/minimal-mistakes/_footer.scss +79 -79
  61. data/_sass/minimal-mistakes/_forms.scss +390 -390
  62. data/_sass/minimal-mistakes/_masthead.scss +76 -76
  63. data/_sass/minimal-mistakes/_mixins.scss +52 -52
  64. data/_sass/minimal-mistakes/_navigation.scss +551 -558
  65. data/_sass/minimal-mistakes/_notices.scss +98 -98
  66. data/_sass/minimal-mistakes/_page.scss +407 -407
  67. data/_sass/minimal-mistakes/_print.scss +237 -237
  68. data/_sass/minimal-mistakes/_reset.scss +186 -186
  69. data/_sass/minimal-mistakes/_sidebar.scss +230 -230
  70. data/_sass/minimal-mistakes/_syntax.scss +145 -145
  71. data/_sass/minimal-mistakes/_tables.scss +37 -37
  72. data/_sass/minimal-mistakes/_utilities.scss +517 -512
  73. data/_sass/minimal-mistakes/_variables.scss +129 -128
  74. data/_sass/minimal-mistakes/vendor/breakpoint/_breakpoint.scss +114 -114
  75. data/_sass/minimal-mistakes/vendor/breakpoint/_context.scss +94 -94
  76. data/_sass/minimal-mistakes/vendor/breakpoint/_helpers.scss +151 -151
  77. data/_sass/minimal-mistakes/vendor/breakpoint/_legacy-settings.scss +49 -49
  78. data/_sass/minimal-mistakes/vendor/breakpoint/_no-query.scss +15 -15
  79. data/_sass/minimal-mistakes/vendor/breakpoint/_parsers.scss +215 -215
  80. data/_sass/minimal-mistakes/vendor/breakpoint/_respond-to.scss +82 -82
  81. data/_sass/minimal-mistakes/vendor/breakpoint/_settings.scss +70 -70
  82. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_double.scss +33 -33
  83. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_query.scss +82 -82
  84. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_resolution.scss +31 -31
  85. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_single.scss +26 -26
  86. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/_triple.scss +36 -36
  87. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/double/_default-pair.scss +21 -21
  88. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/double/_default.scss +22 -22
  89. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/double/_double-string.scss +21 -21
  90. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/resolution/_resolution.scss +60 -60
  91. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/single/_default.scss +13 -13
  92. data/_sass/minimal-mistakes/vendor/breakpoint/parsers/triple/_default.scss +18 -18
  93. data/_sass/minimal-mistakes/vendor/font-awesome/_animated.scss +34 -34
  94. data/_sass/minimal-mistakes/vendor/font-awesome/_bordered-pulled.scss +25 -25
  95. data/_sass/minimal-mistakes/vendor/font-awesome/_core.scss +12 -12
  96. data/_sass/minimal-mistakes/vendor/font-awesome/_fixed-width.scss +6 -6
  97. data/_sass/minimal-mistakes/vendor/font-awesome/_font-awesome.scss +18 -18
  98. data/_sass/minimal-mistakes/vendor/font-awesome/_icons.scss +789 -789
  99. data/_sass/minimal-mistakes/vendor/font-awesome/_larger.scss +13 -13
  100. data/_sass/minimal-mistakes/vendor/font-awesome/_list.scss +19 -19
  101. data/_sass/minimal-mistakes/vendor/font-awesome/_mixins.scss +60 -60
  102. data/_sass/minimal-mistakes/vendor/font-awesome/_path.scss +15 -15
  103. data/_sass/minimal-mistakes/vendor/font-awesome/_rotated-flipped.scss +20 -20
  104. data/_sass/minimal-mistakes/vendor/font-awesome/_screen-reader.scss +5 -5
  105. data/_sass/minimal-mistakes/vendor/font-awesome/_stacked.scss +20 -20
  106. data/_sass/minimal-mistakes/vendor/font-awesome/_variables.scss +800 -800
  107. data/_sass/minimal-mistakes/vendor/magnific-popup/_magnific-popup.scss +649 -649
  108. data/_sass/minimal-mistakes/vendor/magnific-popup/_settings.scss +45 -45
  109. data/_sass/minimal-mistakes/vendor/susy/_su.scss +4 -4
  110. data/_sass/minimal-mistakes/vendor/susy/_susy.scss +4 -4
  111. data/_sass/minimal-mistakes/vendor/susy/_susyone.scss +4 -4
  112. data/_sass/minimal-mistakes/vendor/susy/susy/_su.scss +7 -7
  113. data/_sass/minimal-mistakes/vendor/susy/susy/language/_susy.scss +24 -24
  114. data/_sass/minimal-mistakes/vendor/susy/susy/language/_susyone.scss +13 -13
  115. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_background.scss +385 -385
  116. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_bleed.scss +200 -200
  117. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_box-sizing.scss +47 -47
  118. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_breakpoint-plugin.scss +185 -185
  119. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_container.scss +81 -81
  120. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_context.scss +36 -36
  121. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_gallery.scss +94 -94
  122. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_grids.scss +64 -64
  123. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_gutters.scss +154 -154
  124. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_isolate.scss +77 -77
  125. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_margins.scss +94 -94
  126. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_padding.scss +74 -74
  127. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_rows.scss +138 -138
  128. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_settings.scss +216 -216
  129. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_span.scss +163 -163
  130. data/_sass/minimal-mistakes/vendor/susy/susy/language/susy/_validation.scss +16 -16
  131. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_background.scss +18 -18
  132. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_functions.scss +377 -377
  133. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_grid.scss +312 -312
  134. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_isolation.scss +51 -51
  135. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_margin.scss +93 -93
  136. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_media.scss +105 -105
  137. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_padding.scss +92 -92
  138. data/_sass/minimal-mistakes/vendor/susy/susy/language/susyone/_settings.scss +60 -60
  139. data/_sass/minimal-mistakes/vendor/susy/susy/output/_float.scss +9 -9
  140. data/_sass/minimal-mistakes/vendor/susy/susy/output/_shared.scss +15 -15
  141. data/_sass/minimal-mistakes/vendor/susy/susy/output/_support.scss +9 -9
  142. data/_sass/minimal-mistakes/vendor/susy/susy/output/float/_container.scss +16 -16
  143. data/_sass/minimal-mistakes/vendor/susy/susy/output/float/_end.scss +40 -40
  144. data/_sass/minimal-mistakes/vendor/susy/susy/output/float/_isolate.scss +22 -22
  145. data/_sass/minimal-mistakes/vendor/susy/susy/output/float/_span.scss +35 -35
  146. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_background.scss +26 -26
  147. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_container.scss +21 -21
  148. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_direction.scss +42 -42
  149. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_inspect.scss +25 -25
  150. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_margins.scss +23 -23
  151. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_output.scss +14 -14
  152. data/_sass/minimal-mistakes/vendor/susy/susy/output/shared/_padding.scss +23 -23
  153. data/_sass/minimal-mistakes/vendor/susy/susy/output/support/_background.scss +58 -58
  154. data/_sass/minimal-mistakes/vendor/susy/susy/output/support/_box-sizing.scss +19 -19
  155. data/_sass/minimal-mistakes/vendor/susy/susy/output/support/_clearfix.scss +18 -18
  156. data/_sass/minimal-mistakes/vendor/susy/susy/output/support/_prefix.scss +19 -19
  157. data/_sass/minimal-mistakes/vendor/susy/susy/output/support/_rem.scss +22 -22
  158. data/_sass/minimal-mistakes/vendor/susy/susy/output/support/_support.scss +85 -85
  159. data/_sass/minimal-mistakes/vendor/susy/susy/su/_grid.scss +103 -103
  160. data/_sass/minimal-mistakes/vendor/susy/susy/su/_settings.scss +73 -73
  161. data/_sass/minimal-mistakes/vendor/susy/susy/su/_utilities.scss +111 -111
  162. data/_sass/minimal-mistakes/vendor/susy/susy/su/_validation.scss +57 -57
  163. data/assets/css/main.scss +6 -6
  164. data/assets/fonts/fontawesome-webfont.svg +2671 -2671
  165. data/assets/js/_main.js +72 -72
  166. data/assets/js/main.min.js +13 -13
  167. data/assets/js/plugins/jquery.fitvids.js +81 -81
  168. data/assets/js/plugins/jquery.greedy-navigation.js +77 -74
  169. data/assets/js/plugins/jquery.magnific-popup.js +2049 -2049
  170. data/assets/js/plugins/jquery.smooth-scroll.min.js +8 -8
  171. data/assets/js/vendor/jquery/jquery-1.12.4.min.js +4 -4
  172. metadata +7 -7
@@ -1,2049 +1,2049 @@
1
- /*! Magnific Popup - v0.9.9 - 2013-12-27
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
- */
17
- var 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
- */
34
- var 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
- */
49
- var _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
- */
117
- MagnificPopup.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;
569
-
570
- if(item.tagName) {
571
- item = { el: $(item) };
572
- } else {
573
- type = item.type;
574
- item = { data: item, src: item.src };
575
- }
576
-
577
- if(item.el) {
578
- var types = mfp.types;
579
-
580
- // check for 'mfp-TYPE' class
581
- for(var i = 0; i < types.length; i++) {
582
- if( item.el.hasClass('mfp-'+types[i]) ) {
583
- type = types[i];
584
- break;
585
- }
586
- }
587
-
588
- item.src = item.el.attr('data-mfp-src');
589
- if(!item.src) {
590
- item.src = item.el.attr('href');
591
- }
592
- }
593
-
594
- item.type = type || mfp.st.type || 'inline';
595
- item.index = index;
596
- item.parsed = true;
597
- mfp.items[index] = item;
598
- _mfpTrigger('ElementParse', item);
599
-
600
- return mfp.items[index];
601
- },
602
-
603
-
604
- /**
605
- * Initializes single popup or a group of popups
606
- */
607
- addGroup: function(el, options) {
608
- var eHandler = function(e) {
609
- e.mfpEl = this;
610
- mfp._openClick(e, el, options);
611
- };
612
-
613
- if(!options) {
614
- options = {};
615
- }
616
-
617
- var eName = 'click.magnificPopup';
618
- options.mainEl = el;
619
-
620
- if(options.items) {
621
- options.isObj = true;
622
- el.off(eName).on(eName, eHandler);
623
- } else {
624
- options.isObj = false;
625
- if(options.delegate) {
626
- el.off(eName).on(eName, options.delegate , eHandler);
627
- } else {
628
- options.items = el;
629
- el.off(eName).on(eName, eHandler);
630
- }
631
- }
632
- },
633
- _openClick: function(e, el, options) {
634
- var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick;
635
-
636
-
637
- if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey ) ) {
638
- return;
639
- }
640
-
641
- var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
642
-
643
- if(disableOn) {
644
- if($.isFunction(disableOn)) {
645
- if( !disableOn.call(mfp) ) {
646
- return true;
647
- }
648
- } else { // else it's number
649
- if( _window.width() < disableOn ) {
650
- return true;
651
- }
652
- }
653
- }
654
-
655
- if(e.type) {
656
- e.preventDefault();
657
-
658
- // This will prevent popup from closing if element is inside and popup is already opened
659
- if(mfp.isOpen) {
660
- e.stopPropagation();
661
- }
662
- }
663
-
664
-
665
- options.el = $(e.mfpEl);
666
- if(options.delegate) {
667
- options.items = el.find(options.delegate);
668
- }
669
- mfp.open(options);
670
- },
671
-
672
-
673
- /**
674
- * Updates text on preloader
675
- */
676
- updateStatus: function(status, text) {
677
-
678
- if(mfp.preloader) {
679
- if(_prevStatus !== status) {
680
- mfp.container.removeClass('mfp-s-'+_prevStatus);
681
- }
682
-
683
- if(!text && status === 'loading') {
684
- text = mfp.st.tLoading;
685
- }
686
-
687
- var data = {
688
- status: status,
689
- text: text
690
- };
691
- // allows to modify status
692
- _mfpTrigger('UpdateStatus', data);
693
-
694
- status = data.status;
695
- text = data.text;
696
-
697
- mfp.preloader.html(text);
698
-
699
- mfp.preloader.find('a').on('click', function(e) {
700
- e.stopImmediatePropagation();
701
- });
702
-
703
- mfp.container.addClass('mfp-s-'+status);
704
- _prevStatus = status;
705
- }
706
- },
707
-
708
-
709
- /*
710
- "Private" helpers that aren't private at all
711
- */
712
- // Check to close popup or not
713
- // "target" is an element that was clicked
714
- _checkIfClose: function(target) {
715
-
716
- if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
717
- return;
718
- }
719
-
720
- var closeOnContent = mfp.st.closeOnContentClick;
721
- var closeOnBg = mfp.st.closeOnBgClick;
722
-
723
- if(closeOnContent && closeOnBg) {
724
- return true;
725
- } else {
726
-
727
- // We close the popup if click is on close button or on preloader. Or if there is no content.
728
- if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
729
- return true;
730
- }
731
-
732
- // if click is outside the content
733
- if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
734
- if(closeOnBg) {
735
- // last check, if the clicked element is in DOM, (in case it's removed onclick)
736
- if( $.contains(document, target) ) {
737
- return true;
738
- }
739
- }
740
- } else if(closeOnContent) {
741
- return true;
742
- }
743
-
744
- }
745
- return false;
746
- },
747
- _addClassToMFP: function(cName) {
748
- mfp.bgOverlay.addClass(cName);
749
- mfp.wrap.addClass(cName);
750
- },
751
- _removeClassFromMFP: function(cName) {
752
- this.bgOverlay.removeClass(cName);
753
- mfp.wrap.removeClass(cName);
754
- },
755
- _hasScrollBar: function(winHeight) {
756
- return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) );
757
- },
758
- _setFocus: function() {
759
- (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
760
- },
761
- _onFocusIn: function(e) {
762
- if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
763
- mfp._setFocus();
764
- return false;
765
- }
766
- },
767
- _parseMarkup: function(template, values, item) {
768
- var arr;
769
- if(item.data) {
770
- values = $.extend(item.data, values);
771
- }
772
- _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] );
773
-
774
- $.each(values, function(key, value) {
775
- if(value === undefined || value === false) {
776
- return true;
777
- }
778
- arr = key.split('_');
779
- if(arr.length > 1) {
780
- var el = template.find(EVENT_NS + '-'+arr[0]);
781
-
782
- if(el.length > 0) {
783
- var attr = arr[1];
784
- if(attr === 'replaceWith') {
785
- if(el[0] !== value[0]) {
786
- el.replaceWith(value);
787
- }
788
- } else if(attr === 'img') {
789
- if(el.is('img')) {
790
- el.attr('src', value);
791
- } else {
792
- el.replaceWith( '<img src="'+value+'" class="' + el.attr('class') + '" />' );
793
- }
794
- } else {
795
- el.attr(arr[1], value);
796
- }
797
- }
798
-
799
- } else {
800
- template.find(EVENT_NS + '-'+key).html(value);
801
- }
802
- });
803
- },
804
-
805
- _getScrollbarSize: function() {
806
- // thx David
807
- if(mfp.scrollbarSize === undefined) {
808
- var scrollDiv = document.createElement("div");
809
- scrollDiv.id = "mfp-sbm";
810
- scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
811
- document.body.appendChild(scrollDiv);
812
- mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
813
- document.body.removeChild(scrollDiv);
814
- }
815
- return mfp.scrollbarSize;
816
- }
817
-
818
- }; /* MagnificPopup core prototype end */
819
-
820
-
821
-
822
-
823
- /**
824
- * Public static functions
825
- */
826
- $.magnificPopup = {
827
- instance: null,
828
- proto: MagnificPopup.prototype,
829
- modules: [],
830
-
831
- open: function(options, index) {
832
- _checkInstance();
833
-
834
- if(!options) {
835
- options = {};
836
- } else {
837
- options = $.extend(true, {}, options);
838
- }
839
-
840
-
841
- options.isObj = true;
842
- options.index = index || 0;
843
- return this.instance.open(options);
844
- },
845
-
846
- close: function() {
847
- return $.magnificPopup.instance && $.magnificPopup.instance.close();
848
- },
849
-
850
- registerModule: function(name, module) {
851
- if(module.options) {
852
- $.magnificPopup.defaults[name] = module.options;
853
- }
854
- $.extend(this.proto, module.proto);
855
- this.modules.push(name);
856
- },
857
-
858
- defaults: {
859
-
860
- // Info about options is in docs:
861
- // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
862
-
863
- disableOn: 0,
864
-
865
- key: null,
866
-
867
- midClick: false,
868
-
869
- mainClass: '',
870
-
871
- preloader: true,
872
-
873
- focus: '', // CSS selector of input to focus after popup is opened
874
-
875
- closeOnContentClick: false,
876
-
877
- closeOnBgClick: true,
878
-
879
- closeBtnInside: true,
880
-
881
- showCloseBtn: true,
882
-
883
- enableEscapeKey: true,
884
-
885
- modal: false,
886
-
887
- alignTop: false,
888
-
889
- removalDelay: 0,
890
-
891
- prependTo: null,
892
-
893
- fixedContentPos: 'auto',
894
-
895
- fixedBgPos: 'auto',
896
-
897
- overflowY: 'auto',
898
-
899
- closeMarkup: '<button title="%title%" type="button" class="mfp-close">&times;</button>',
900
-
901
- tClose: 'Close (Esc)',
902
-
903
- tLoading: 'Loading...'
904
-
905
- }
906
- };
907
-
908
-
909
-
910
- $.fn.magnificPopup = function(options) {
911
- _checkInstance();
912
-
913
- var jqEl = $(this);
914
-
915
- // We call some API method of first param is a string
916
- if (typeof options === "string" ) {
917
-
918
- if(options === 'open') {
919
- var items,
920
- itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
921
- index = parseInt(arguments[1], 10) || 0;
922
-
923
- if(itemOpts.items) {
924
- items = itemOpts.items[index];
925
- } else {
926
- items = jqEl;
927
- if(itemOpts.delegate) {
928
- items = items.find(itemOpts.delegate);
929
- }
930
- items = items.eq( index );
931
- }
932
- mfp._openClick({mfpEl:items}, jqEl, itemOpts);
933
- } else {
934
- if(mfp.isOpen)
935
- mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
936
- }
937
-
938
- } else {
939
- // clone options obj
940
- options = $.extend(true, {}, options);
941
-
942
- /*
943
- * As Zepto doesn't support .data() method for objects
944
- * and it works only in normal browsers
945
- * we assign "options" object directly to the DOM element. FTW!
946
- */
947
- if(_isJQ) {
948
- jqEl.data('magnificPopup', options);
949
- } else {
950
- jqEl[0].magnificPopup = options;
951
- }
952
-
953
- mfp.addGroup(jqEl, options);
954
-
955
- }
956
- return jqEl;
957
- };
958
-
959
-
960
- //Quick benchmark
961
- /*
962
- var start = performance.now(),
963
- i,
964
- rounds = 1000;
965
-
966
- for(i = 0; i < rounds; i++) {
967
-
968
- }
969
- console.log('Test #1:', performance.now() - start);
970
-
971
- start = performance.now();
972
- for(i = 0; i < rounds; i++) {
973
-
974
- }
975
- console.log('Test #2:', performance.now() - start);
976
- */
977
-
978
-
979
- /*>>core*/
980
-
981
- /*>>inline*/
982
-
983
- var INLINE_NS = 'inline',
984
- _hiddenClass,
985
- _inlinePlaceholder,
986
- _lastInlineElement,
987
- _putInlineElementsBack = function() {
988
- if(_lastInlineElement) {
989
- _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
990
- _lastInlineElement = null;
991
- }
992
- };
993
-
994
- $.magnificPopup.registerModule(INLINE_NS, {
995
- options: {
996
- hiddenClass: 'hide', // will be appended with `mfp-` prefix
997
- markup: '',
998
- tNotFound: 'Content not found'
999
- },
1000
- proto: {
1001
-
1002
- initInline: function() {
1003
- mfp.types.push(INLINE_NS);
1004
-
1005
- _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
1006
- _putInlineElementsBack();
1007
- });
1008
- },
1009
-
1010
- getInline: function(item, template) {
1011
-
1012
- _putInlineElementsBack();
1013
-
1014
- if(item.src) {
1015
- var inlineSt = mfp.st.inline,
1016
- el = $(item.src);
1017
-
1018
- if(el.length) {
1019
-
1020
- // If target element has parent - we replace it with placeholder and put it back after popup is closed
1021
- var parent = el[0].parentNode;
1022
- if(parent && parent.tagName) {
1023
- if(!_inlinePlaceholder) {
1024
- _hiddenClass = inlineSt.hiddenClass;
1025
- _inlinePlaceholder = _getEl(_hiddenClass);
1026
- _hiddenClass = 'mfp-'+_hiddenClass;
1027
- }
1028
- // replace target inline element with placeholder
1029
- _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
1030
- }
1031
-
1032
- mfp.updateStatus('ready');
1033
- } else {
1034
- mfp.updateStatus('error', inlineSt.tNotFound);
1035
- el = $('<div>');
1036
- }
1037
-
1038
- item.inlineElement = el;
1039
- return el;
1040
- }
1041
-
1042
- mfp.updateStatus('ready');
1043
- mfp._parseMarkup(template, {}, item);
1044
- return template;
1045
- }
1046
- }
1047
- });
1048
-
1049
- /*>>inline*/
1050
-
1051
- /*>>ajax*/
1052
- var AJAX_NS = 'ajax',
1053
- _ajaxCur,
1054
- _removeAjaxCursor = function() {
1055
- if(_ajaxCur) {
1056
- _body.removeClass(_ajaxCur);
1057
- }
1058
- },
1059
- _destroyAjaxRequest = function() {
1060
- _removeAjaxCursor();
1061
- if(mfp.req) {
1062
- mfp.req.abort();
1063
- }
1064
- };
1065
-
1066
- $.magnificPopup.registerModule(AJAX_NS, {
1067
-
1068
- options: {
1069
- settings: null,
1070
- cursor: 'mfp-ajax-cur',
1071
- tError: '<a href="%url%">The content</a> could not be loaded.'
1072
- },
1073
-
1074
- proto: {
1075
- initAjax: function() {
1076
- mfp.types.push(AJAX_NS);
1077
- _ajaxCur = mfp.st.ajax.cursor;
1078
-
1079
- _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest);
1080
- _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest);
1081
- },
1082
- getAjax: function(item) {
1083
-
1084
- if(_ajaxCur)
1085
- _body.addClass(_ajaxCur);
1086
-
1087
- mfp.updateStatus('loading');
1088
-
1089
- var opts = $.extend({
1090
- url: item.src,
1091
- success: function(data, textStatus, jqXHR) {
1092
- var temp = {
1093
- data:data,
1094
- xhr:jqXHR
1095
- };
1096
-
1097
- _mfpTrigger('ParseAjax', temp);
1098
-
1099
- mfp.appendContent( $(temp.data), AJAX_NS );
1100
-
1101
- item.finished = true;
1102
-
1103
- _removeAjaxCursor();
1104
-
1105
- mfp._setFocus();
1106
-
1107
- setTimeout(function() {
1108
- mfp.wrap.addClass(READY_CLASS);
1109
- }, 16);
1110
-
1111
- mfp.updateStatus('ready');
1112
-
1113
- _mfpTrigger('AjaxContentAdded');
1114
- },
1115
- error: function() {
1116
- _removeAjaxCursor();
1117
- item.finished = item.loadError = true;
1118
- mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src));
1119
- }
1120
- }, mfp.st.ajax.settings);
1121
-
1122
- mfp.req = $.ajax(opts);
1123
-
1124
- return '';
1125
- }
1126
- }
1127
- });
1128
-
1129
-
1130
-
1131
-
1132
-
1133
-
1134
-
1135
- /*>>ajax*/
1136
-
1137
- /*>>image*/
1138
- var _imgInterval,
1139
- _getTitle = function(item) {
1140
- if(item.data && item.data.title !== undefined)
1141
- return item.data.title;
1142
-
1143
- var src = mfp.st.image.titleSrc;
1144
-
1145
- if(src) {
1146
- if($.isFunction(src)) {
1147
- return src.call(mfp, item);
1148
- } else if(item.el) {
1149
- return item.el.attr(src) || '';
1150
- }
1151
- }
1152
- return '';
1153
- };
1154
-
1155
- $.magnificPopup.registerModule('image', {
1156
-
1157
- options: {
1158
- markup: '<div class="mfp-figure">'+
1159
- '<div class="mfp-close"></div>'+
1160
- '<figure>'+
1161
- '<div class="mfp-img"></div>'+
1162
- '<figcaption>'+
1163
- '<div class="mfp-bottom-bar">'+
1164
- '<div class="mfp-title"></div>'+
1165
- '<div class="mfp-counter"></div>'+
1166
- '</div>'+
1167
- '</figcaption>'+
1168
- '</figure>'+
1169
- '</div>',
1170
- cursor: 'mfp-zoom-out-cur',
1171
- titleSrc: 'title',
1172
- verticalFit: true,
1173
- tError: '<a href="%url%">The image</a> could not be loaded.'
1174
- },
1175
-
1176
- proto: {
1177
- initImage: function() {
1178
- var imgSt = mfp.st.image,
1179
- ns = '.image';
1180
-
1181
- mfp.types.push('image');
1182
-
1183
- _mfpOn(OPEN_EVENT+ns, function() {
1184
- if(mfp.currItem.type === 'image' && imgSt.cursor) {
1185
- _body.addClass(imgSt.cursor);
1186
- }
1187
- });
1188
-
1189
- _mfpOn(CLOSE_EVENT+ns, function() {
1190
- if(imgSt.cursor) {
1191
- _body.removeClass(imgSt.cursor);
1192
- }
1193
- _window.off('resize' + EVENT_NS);
1194
- });
1195
-
1196
- _mfpOn('Resize'+ns, mfp.resizeImage);
1197
- if(mfp.isLowIE) {
1198
- _mfpOn('AfterChange', mfp.resizeImage);
1199
- }
1200
- },
1201
- resizeImage: function() {
1202
- var item = mfp.currItem;
1203
- if(!item || !item.img) return;
1204
-
1205
- if(mfp.st.image.verticalFit) {
1206
- var decr = 0;
1207
- // fix box-sizing in ie7/8
1208
- if(mfp.isLowIE) {
1209
- decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10);
1210
- }
1211
- item.img.css('max-height', mfp.wH-decr);
1212
- }
1213
- },
1214
- _onImageHasSize: function(item) {
1215
- if(item.img) {
1216
-
1217
- item.hasSize = true;
1218
-
1219
- if(_imgInterval) {
1220
- clearInterval(_imgInterval);
1221
- }
1222
-
1223
- item.isCheckingImgSize = false;
1224
-
1225
- _mfpTrigger('ImageHasSize', item);
1226
-
1227
- if(item.imgHidden) {
1228
- if(mfp.content)
1229
- mfp.content.removeClass('mfp-loading');
1230
-
1231
- item.imgHidden = false;
1232
- }
1233
-
1234
- }
1235
- },
1236
-
1237
- /**
1238
- * Function that loops until the image has size to display elements that rely on it asap
1239
- */
1240
- findImageSize: function(item) {
1241
-
1242
- var counter = 0,
1243
- img = item.img[0],
1244
- mfpSetInterval = function(delay) {
1245
-
1246
- if(_imgInterval) {
1247
- clearInterval(_imgInterval);
1248
- }
1249
- // decelerating interval that checks for size of an image
1250
- _imgInterval = setInterval(function() {
1251
- if(img.naturalWidth > 0) {
1252
- mfp._onImageHasSize(item);
1253
- return;
1254
- }
1255
-
1256
- if(counter > 200) {
1257
- clearInterval(_imgInterval);
1258
- }
1259
-
1260
- counter++;
1261
- if(counter === 3) {
1262
- mfpSetInterval(10);
1263
- } else if(counter === 40) {
1264
- mfpSetInterval(50);
1265
- } else if(counter === 100) {
1266
- mfpSetInterval(500);
1267
- }
1268
- }, delay);
1269
- };
1270
-
1271
- mfpSetInterval(1);
1272
- },
1273
-
1274
- getImage: function(item, template) {
1275
-
1276
- var guard = 0,
1277
-
1278
- // image load complete handler
1279
- onLoadComplete = function() {
1280
- if(item) {
1281
- if (item.img[0].complete) {
1282
- item.img.off('.mfploader');
1283
-
1284
- if(item === mfp.currItem){
1285
- mfp._onImageHasSize(item);
1286
-
1287
- mfp.updateStatus('ready');
1288
- }
1289
-
1290
- item.hasSize = true;
1291
- item.loaded = true;
1292
-
1293
- _mfpTrigger('ImageLoadComplete');
1294
-
1295
- }
1296
- else {
1297
- // if image complete check fails 200 times (20 sec), we assume that there was an error.
1298
- guard++;
1299
- if(guard < 200) {
1300
- setTimeout(onLoadComplete,100);
1301
- } else {
1302
- onLoadError();
1303
- }
1304
- }
1305
- }
1306
- },
1307
-
1308
- // image error handler
1309
- onLoadError = function() {
1310
- if(item) {
1311
- item.img.off('.mfploader');
1312
- if(item === mfp.currItem){
1313
- mfp._onImageHasSize(item);
1314
- mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1315
- }
1316
-
1317
- item.hasSize = true;
1318
- item.loaded = true;
1319
- item.loadError = true;
1320
- }
1321
- },
1322
- imgSt = mfp.st.image;
1323
-
1324
-
1325
- var el = template.find('.mfp-img');
1326
- if(el.length) {
1327
- var img = document.createElement('img');
1328
- img.className = 'mfp-img';
1329
- item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError);
1330
- img.src = item.src;
1331
-
1332
- // without clone() "error" event is not firing when IMG is replaced by new IMG
1333
- // TODO: find a way to avoid such cloning
1334
- if(el.is('img')) {
1335
- item.img = item.img.clone();
1336
- }
1337
-
1338
- img = item.img[0];
1339
- if(img.naturalWidth > 0) {
1340
- item.hasSize = true;
1341
- } else if(!img.width) {
1342
- item.hasSize = false;
1343
- }
1344
- }
1345
-
1346
- mfp._parseMarkup(template, {
1347
- title: _getTitle(item),
1348
- img_replaceWith: item.img
1349
- }, item);
1350
-
1351
- mfp.resizeImage();
1352
-
1353
- if(item.hasSize) {
1354
- if(_imgInterval) clearInterval(_imgInterval);
1355
-
1356
- if(item.loadError) {
1357
- template.addClass('mfp-loading');
1358
- mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1359
- } else {
1360
- template.removeClass('mfp-loading');
1361
- mfp.updateStatus('ready');
1362
- }
1363
- return template;
1364
- }
1365
-
1366
- mfp.updateStatus('loading');
1367
- item.loading = true;
1368
-
1369
- if(!item.hasSize) {
1370
- item.imgHidden = true;
1371
- template.addClass('mfp-loading');
1372
- mfp.findImageSize(item);
1373
- }
1374
-
1375
- return template;
1376
- }
1377
- }
1378
- });
1379
-
1380
-
1381
-
1382
- /*>>image*/
1383
-
1384
- /*>>zoom*/
1385
- var hasMozTransform,
1386
- getHasMozTransform = function() {
1387
- if(hasMozTransform === undefined) {
1388
- hasMozTransform = document.createElement('p').style.MozTransform !== undefined;
1389
- }
1390
- return hasMozTransform;
1391
- };
1392
-
1393
- $.magnificPopup.registerModule('zoom', {
1394
-
1395
- options: {
1396
- enabled: false,
1397
- easing: 'ease-in-out',
1398
- duration: 300,
1399
- opener: function(element) {
1400
- return element.is('img') ? element : element.find('img');
1401
- }
1402
- },
1403
-
1404
- proto: {
1405
-
1406
- initZoom: function() {
1407
- var zoomSt = mfp.st.zoom,
1408
- ns = '.zoom',
1409
- image;
1410
-
1411
- if(!zoomSt.enabled || !mfp.supportsTransition) {
1412
- return;
1413
- }
1414
-
1415
- var duration = zoomSt.duration,
1416
- getElToAnimate = function(image) {
1417
- var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'),
1418
- transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing,
1419
- cssObj = {
1420
- position: 'fixed',
1421
- zIndex: 9999,
1422
- left: 0,
1423
- top: 0,
1424
- '-webkit-backface-visibility': 'hidden'
1425
- },
1426
- t = 'transition';
1427
-
1428
- cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition;
1429
-
1430
- newImg.css(cssObj);
1431
- return newImg;
1432
- },
1433
- showMainContent = function() {
1434
- mfp.content.css('visibility', 'visible');
1435
- },
1436
- openTimeout,
1437
- animatedImg;
1438
-
1439
- _mfpOn('BuildControls'+ns, function() {
1440
- if(mfp._allowZoom()) {
1441
-
1442
- clearTimeout(openTimeout);
1443
- mfp.content.css('visibility', 'hidden');
1444
-
1445
- // Basically, all code below does is clones existing image, puts in on top of the current one and animated it
1446
-
1447
- image = mfp._getItemToZoom();
1448
-
1449
- if(!image) {
1450
- showMainContent();
1451
- return;
1452
- }
1453
-
1454
- animatedImg = getElToAnimate(image);
1455
-
1456
- animatedImg.css( mfp._getOffset() );
1457
-
1458
- mfp.wrap.append(animatedImg);
1459
-
1460
- openTimeout = setTimeout(function() {
1461
- animatedImg.css( mfp._getOffset( true ) );
1462
- openTimeout = setTimeout(function() {
1463
-
1464
- showMainContent();
1465
-
1466
- setTimeout(function() {
1467
- animatedImg.remove();
1468
- image = animatedImg = null;
1469
- _mfpTrigger('ZoomAnimationEnded');
1470
- }, 16); // avoid blink when switching images
1471
-
1472
- }, duration); // this timeout equals animation duration
1473
-
1474
- }, 16); // by adding this timeout we avoid short glitch at the beginning of animation
1475
-
1476
-
1477
- // Lots of timeouts...
1478
- }
1479
- });
1480
- _mfpOn(BEFORE_CLOSE_EVENT+ns, function() {
1481
- if(mfp._allowZoom()) {
1482
-
1483
- clearTimeout(openTimeout);
1484
-
1485
- mfp.st.removalDelay = duration;
1486
-
1487
- if(!image) {
1488
- image = mfp._getItemToZoom();
1489
- if(!image) {
1490
- return;
1491
- }
1492
- animatedImg = getElToAnimate(image);
1493
- }
1494
-
1495
-
1496
- animatedImg.css( mfp._getOffset(true) );
1497
- mfp.wrap.append(animatedImg);
1498
- mfp.content.css('visibility', 'hidden');
1499
-
1500
- setTimeout(function() {
1501
- animatedImg.css( mfp._getOffset() );
1502
- }, 16);
1503
- }
1504
-
1505
- });
1506
-
1507
- _mfpOn(CLOSE_EVENT+ns, function() {
1508
- if(mfp._allowZoom()) {
1509
- showMainContent();
1510
- if(animatedImg) {
1511
- animatedImg.remove();
1512
- }
1513
- image = null;
1514
- }
1515
- });
1516
- },
1517
-
1518
- _allowZoom: function() {
1519
- return mfp.currItem.type === 'image';
1520
- },
1521
-
1522
- _getItemToZoom: function() {
1523
- if(mfp.currItem.hasSize) {
1524
- return mfp.currItem.img;
1525
- } else {
1526
- return false;
1527
- }
1528
- },
1529
-
1530
- // Get element postion relative to viewport
1531
- _getOffset: function(isLarge) {
1532
- var el;
1533
- if(isLarge) {
1534
- el = mfp.currItem.img;
1535
- } else {
1536
- el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
1537
- }
1538
-
1539
- var offset = el.offset();
1540
- var paddingTop = parseInt(el.css('padding-top'),10);
1541
- var paddingBottom = parseInt(el.css('padding-bottom'),10);
1542
- offset.top -= ( $(window).scrollTop() - paddingTop );
1543
-
1544
-
1545
- /*
1546
-
1547
- Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
1548
-
1549
- */
1550
- var obj = {
1551
- width: el.width(),
1552
- // fix Zepto height+padding issue
1553
- height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
1554
- };
1555
-
1556
- // I hate to do this, but there is no another option
1557
- if( getHasMozTransform() ) {
1558
- obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
1559
- } else {
1560
- obj.left = offset.left;
1561
- obj.top = offset.top;
1562
- }
1563
- return obj;
1564
- }
1565
-
1566
- }
1567
- });
1568
-
1569
-
1570
-
1571
- /*>>zoom*/
1572
-
1573
- /*>>iframe*/
1574
-
1575
- var IFRAME_NS = 'iframe',
1576
- _emptyPage = '//about:blank',
1577
-
1578
- _fixIframeBugs = function(isShowing) {
1579
- if(mfp.currTemplate[IFRAME_NS]) {
1580
- var el = mfp.currTemplate[IFRAME_NS].find('iframe');
1581
- if(el.length) {
1582
- // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug
1583
- if(!isShowing) {
1584
- el[0].src = _emptyPage;
1585
- }
1586
-
1587
- // IE8 black screen bug fix
1588
- if(mfp.isIE8) {
1589
- el.css('display', isShowing ? 'block' : 'none');
1590
- }
1591
- }
1592
- }
1593
- };
1594
-
1595
- $.magnificPopup.registerModule(IFRAME_NS, {
1596
-
1597
- options: {
1598
- markup: '<div class="mfp-iframe-scaler">'+
1599
- '<div class="mfp-close"></div>'+
1600
- '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
1601
- '</div>',
1602
-
1603
- srcAction: 'iframe_src',
1604
-
1605
- // we don't care and support only one default type of URL by default
1606
- patterns: {
1607
- youtube: {
1608
- index: 'youtube.com',
1609
- id: 'v=',
1610
- src: '//www.youtube.com/embed/%id%?autoplay=1'
1611
- },
1612
- vimeo: {
1613
- index: 'vimeo.com/',
1614
- id: '/',
1615
- src: '//player.vimeo.com/video/%id%?autoplay=1'
1616
- },
1617
- gmaps: {
1618
- index: '//maps.google.',
1619
- src: '%id%&output=embed'
1620
- }
1621
- }
1622
- },
1623
-
1624
- proto: {
1625
- initIframe: function() {
1626
- mfp.types.push(IFRAME_NS);
1627
-
1628
- _mfpOn('BeforeChange', function(e, prevType, newType) {
1629
- if(prevType !== newType) {
1630
- if(prevType === IFRAME_NS) {
1631
- _fixIframeBugs(); // iframe if removed
1632
- } else if(newType === IFRAME_NS) {
1633
- _fixIframeBugs(true); // iframe is showing
1634
- }
1635
- }// else {
1636
- // iframe source is switched, don't do anything
1637
- //}
1638
- });
1639
-
1640
- _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
1641
- _fixIframeBugs();
1642
- });
1643
- },
1644
-
1645
- getIframe: function(item, template) {
1646
- var embedSrc = item.src;
1647
- var iframeSt = mfp.st.iframe;
1648
-
1649
- $.each(iframeSt.patterns, function() {
1650
- if(embedSrc.indexOf( this.index ) > -1) {
1651
- if(this.id) {
1652
- if(typeof this.id === 'string') {
1653
- embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);
1654
- } else {
1655
- embedSrc = this.id.call( this, embedSrc );
1656
- }
1657
- }
1658
- embedSrc = this.src.replace('%id%', embedSrc );
1659
- return false; // break;
1660
- }
1661
- });
1662
-
1663
- var dataObj = {};
1664
- if(iframeSt.srcAction) {
1665
- dataObj[iframeSt.srcAction] = embedSrc;
1666
- }
1667
- mfp._parseMarkup(template, dataObj, item);
1668
-
1669
- mfp.updateStatus('ready');
1670
-
1671
- return template;
1672
- }
1673
- }
1674
- });
1675
-
1676
-
1677
-
1678
- /*>>iframe*/
1679
-
1680
- /*>>gallery*/
1681
- /**
1682
- * Get looped index depending on number of slides
1683
- */
1684
- var _getLoopedId = function(index) {
1685
- var numSlides = mfp.items.length;
1686
- if(index > numSlides - 1) {
1687
- return index - numSlides;
1688
- } else if(index < 0) {
1689
- return numSlides + index;
1690
- }
1691
- return index;
1692
- },
1693
- _replaceCurrTotal = function(text, curr, total) {
1694
- return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total);
1695
- };
1696
-
1697
- $.magnificPopup.registerModule('gallery', {
1698
-
1699
- options: {
1700
- enabled: false,
1701
- arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
1702
- preload: [0,2],
1703
- navigateByImgClick: true,
1704
- arrows: true,
1705
-
1706
- tPrev: 'Previous (Left arrow key)',
1707
- tNext: 'Next (Right arrow key)',
1708
- tCounter: '%curr% of %total%'
1709
- },
1710
-
1711
- proto: {
1712
- initGallery: function() {
1713
-
1714
- var gSt = mfp.st.gallery,
1715
- ns = '.mfp-gallery',
1716
- supportsFastClick = Boolean($.fn.mfpFastClick);
1717
-
1718
- mfp.direction = true; // true - next, false - prev
1719
-
1720
- if(!gSt || !gSt.enabled ) return false;
1721
-
1722
- _wrapClasses += ' mfp-gallery';
1723
-
1724
- _mfpOn(OPEN_EVENT+ns, function() {
1725
-
1726
- if(gSt.navigateByImgClick) {
1727
- mfp.wrap.on('click'+ns, '.mfp-img', function() {
1728
- if(mfp.items.length > 1) {
1729
- mfp.next();
1730
- return false;
1731
- }
1732
- });
1733
- }
1734
-
1735
- _document.on('keydown'+ns, function(e) {
1736
- if (e.keyCode === 37) {
1737
- mfp.prev();
1738
- } else if (e.keyCode === 39) {
1739
- mfp.next();
1740
- }
1741
- });
1742
- });
1743
-
1744
- _mfpOn('UpdateStatus'+ns, function(e, data) {
1745
- if(data.text) {
1746
- data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length);
1747
- }
1748
- });
1749
-
1750
- _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
1751
- var l = mfp.items.length;
1752
- values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
1753
- });
1754
-
1755
- _mfpOn('BuildControls' + ns, function() {
1756
- if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
1757
- var markup = gSt.arrowMarkup,
1758
- arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS),
1759
- arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS);
1760
-
1761
- var eName = supportsFastClick ? 'mfpFastClick' : 'click';
1762
- arrowLeft[eName](function() {
1763
- mfp.prev();
1764
- });
1765
- arrowRight[eName](function() {
1766
- mfp.next();
1767
- });
1768
-
1769
- // Polyfill for :before and :after (adds elements with classes mfp-a and mfp-b)
1770
- if(mfp.isIE7) {
1771
- _getEl('b', arrowLeft[0], false, true);
1772
- _getEl('a', arrowLeft[0], false, true);
1773
- _getEl('b', arrowRight[0], false, true);
1774
- _getEl('a', arrowRight[0], false, true);
1775
- }
1776
-
1777
- mfp.container.append(arrowLeft.add(arrowRight));
1778
- }
1779
- });
1780
-
1781
- _mfpOn(CHANGE_EVENT+ns, function() {
1782
- if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout);
1783
-
1784
- mfp._preloadTimeout = setTimeout(function() {
1785
- mfp.preloadNearbyImages();
1786
- mfp._preloadTimeout = null;
1787
- }, 16);
1788
- });
1789
-
1790
-
1791
- _mfpOn(CLOSE_EVENT+ns, function() {
1792
- _document.off(ns);
1793
- mfp.wrap.off('click'+ns);
1794
-
1795
- if(mfp.arrowLeft && supportsFastClick) {
1796
- mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
1797
- }
1798
- mfp.arrowRight = mfp.arrowLeft = null;
1799
- });
1800
-
1801
- },
1802
- next: function() {
1803
- mfp.direction = true;
1804
- mfp.index = _getLoopedId(mfp.index + 1);
1805
- mfp.updateItemHTML();
1806
- },
1807
- prev: function() {
1808
- mfp.direction = false;
1809
- mfp.index = _getLoopedId(mfp.index - 1);
1810
- mfp.updateItemHTML();
1811
- },
1812
- goTo: function(newIndex) {
1813
- mfp.direction = (newIndex >= mfp.index);
1814
- mfp.index = newIndex;
1815
- mfp.updateItemHTML();
1816
- },
1817
- preloadNearbyImages: function() {
1818
- var p = mfp.st.gallery.preload,
1819
- preloadBefore = Math.min(p[0], mfp.items.length),
1820
- preloadAfter = Math.min(p[1], mfp.items.length),
1821
- i;
1822
-
1823
- for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) {
1824
- mfp._preloadItem(mfp.index+i);
1825
- }
1826
- for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) {
1827
- mfp._preloadItem(mfp.index-i);
1828
- }
1829
- },
1830
- _preloadItem: function(index) {
1831
- index = _getLoopedId(index);
1832
-
1833
- if(mfp.items[index].preloaded) {
1834
- return;
1835
- }
1836
-
1837
- var item = mfp.items[index];
1838
- if(!item.parsed) {
1839
- item = mfp.parseEl( index );
1840
- }
1841
-
1842
- _mfpTrigger('LazyLoad', item);
1843
-
1844
- if(item.type === 'image') {
1845
- item.img = $('<img class="mfp-img" />').on('load.mfploader', function() {
1846
- item.hasSize = true;
1847
- }).on('error.mfploader', function() {
1848
- item.hasSize = true;
1849
- item.loadError = true;
1850
- _mfpTrigger('LazyLoadError', item);
1851
- }).attr('src', item.src);
1852
- }
1853
-
1854
-
1855
- item.preloaded = true;
1856
- }
1857
- }
1858
- });
1859
-
1860
- /*
1861
- Touch Support that might be implemented some day
1862
-
1863
- addSwipeGesture: function() {
1864
- var startX,
1865
- moved,
1866
- multipleTouches;
1867
-
1868
- return;
1869
-
1870
- var namespace = '.mfp',
1871
- addEventNames = function(pref, down, move, up, cancel) {
1872
- mfp._tStart = pref + down + namespace;
1873
- mfp._tMove = pref + move + namespace;
1874
- mfp._tEnd = pref + up + namespace;
1875
- mfp._tCancel = pref + cancel + namespace;
1876
- };
1877
-
1878
- if(window.navigator.msPointerEnabled) {
1879
- addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
1880
- } else if('ontouchstart' in window) {
1881
- addEventNames('touch', 'start', 'move', 'end', 'cancel');
1882
- } else {
1883
- return;
1884
- }
1885
- _window.on(mfp._tStart, function(e) {
1886
- var oE = e.originalEvent;
1887
- multipleTouches = moved = false;
1888
- startX = oE.pageX || oE.changedTouches[0].pageX;
1889
- }).on(mfp._tMove, function(e) {
1890
- if(e.originalEvent.touches.length > 1) {
1891
- multipleTouches = e.originalEvent.touches.length;
1892
- } else {
1893
- //e.preventDefault();
1894
- moved = true;
1895
- }
1896
- }).on(mfp._tEnd + ' ' + mfp._tCancel, function(e) {
1897
- if(moved && !multipleTouches) {
1898
- var oE = e.originalEvent,
1899
- diff = startX - (oE.pageX || oE.changedTouches[0].pageX);
1900
-
1901
- if(diff > 20) {
1902
- mfp.next();
1903
- } else if(diff < -20) {
1904
- mfp.prev();
1905
- }
1906
- }
1907
- });
1908
- },
1909
- */
1910
-
1911
-
1912
- /*>>gallery*/
1913
-
1914
- /*>>retina*/
1915
-
1916
- var RETINA_NS = 'retina';
1917
-
1918
- $.magnificPopup.registerModule(RETINA_NS, {
1919
- options: {
1920
- replaceSrc: function(item) {
1921
- return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; });
1922
- },
1923
- ratio: 1 // Function or number. Set to 1 to disable.
1924
- },
1925
- proto: {
1926
- initRetina: function() {
1927
- if(window.devicePixelRatio > 1) {
1928
-
1929
- var st = mfp.st.retina,
1930
- ratio = st.ratio;
1931
-
1932
- ratio = !isNaN(ratio) ? ratio : ratio();
1933
-
1934
- if(ratio > 1) {
1935
- _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
1936
- item.img.css({
1937
- 'max-width': item.img[0].naturalWidth / ratio,
1938
- 'width': '100%'
1939
- });
1940
- });
1941
- _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
1942
- item.src = st.replaceSrc(item, ratio);
1943
- });
1944
- }
1945
- }
1946
-
1947
- }
1948
- }
1949
- });
1950
-
1951
- /*>>retina*/
1952
-
1953
- /*>>fastclick*/
1954
- /**
1955
- * FastClick event implementation. (removes 300ms delay on touch devices)
1956
- * Based on https://developers.google.com/mobile/articles/fast_buttons
1957
- *
1958
- * You may use it outside the Magnific Popup by calling just:
1959
- *
1960
- * $('.your-el').mfpFastClick(function() {
1961
- * console.log('Clicked!');
1962
- * });
1963
- *
1964
- * To unbind:
1965
- * $('.your-el').destroyMfpFastClick();
1966
- *
1967
- *
1968
- * Note that it's a very basic and simple implementation, it blocks ghost click on the same element where it was bound.
1969
- * If you need something more advanced, use plugin by FT Labs https://github.com/ftlabs/fastclick
1970
- *
1971
- */
1972
-
1973
- (function() {
1974
- var ghostClickDelay = 1000,
1975
- supportsTouch = 'ontouchstart' in window,
1976
- unbindTouchMove = function() {
1977
- _window.off('touchmove'+ns+' touchend'+ns);
1978
- },
1979
- eName = 'mfpFastClick',
1980
- ns = '.'+eName;
1981
-
1982
-
1983
- // As Zepto.js doesn't have an easy way to add custom events (like jQuery), so we implement it in this way
1984
- $.fn.mfpFastClick = function(callback) {
1985
-
1986
- return $(this).each(function() {
1987
-
1988
- var elem = $(this),
1989
- lock;
1990
-
1991
- if( supportsTouch ) {
1992
-
1993
- var timeout,
1994
- startX,
1995
- startY,
1996
- pointerMoved,
1997
- point,
1998
- numPointers;
1999
-
2000
- elem.on('touchstart' + ns, function(e) {
2001
- pointerMoved = false;
2002
- numPointers = 1;
2003
-
2004
- point = e.originalEvent ? e.originalEvent.touches[0] : e.touches[0];
2005
- startX = point.clientX;
2006
- startY = point.clientY;
2007
-
2008
- _window.on('touchmove'+ns, function(e) {
2009
- point = e.originalEvent ? e.originalEvent.touches : e.touches;
2010
- numPointers = point.length;
2011
- point = point[0];
2012
- if (Math.abs(point.clientX - startX) > 10 ||
2013
- Math.abs(point.clientY - startY) > 10) {
2014
- pointerMoved = true;
2015
- unbindTouchMove();
2016
- }
2017
- }).on('touchend'+ns, function(e) {
2018
- unbindTouchMove();
2019
- if(pointerMoved || numPointers > 1) {
2020
- return;
2021
- }
2022
- lock = true;
2023
- e.preventDefault();
2024
- clearTimeout(timeout);
2025
- timeout = setTimeout(function() {
2026
- lock = false;
2027
- }, ghostClickDelay);
2028
- callback();
2029
- });
2030
- });
2031
-
2032
- }
2033
-
2034
- elem.on('click' + ns, function() {
2035
- if(!lock) {
2036
- callback();
2037
- }
2038
- });
2039
- });
2040
- };
2041
-
2042
- $.fn.destroyMfpFastClick = function() {
2043
- $(this).off('touchstart' + ns + ' click' + ns);
2044
- if(supportsTouch) _window.off('touchmove'+ns+' touchend'+ns);
2045
- };
2046
- })();
2047
-
2048
- /*>>fastclick*/
2049
- _checkInstance(); })(window.jQuery || window.Zepto);
1
+ /*! Magnific Popup - v0.9.9 - 2013-12-27
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
+ */
17
+ var 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
+ */
34
+ var 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
+ */
49
+ var _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
+ */
117
+ MagnificPopup.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;
569
+
570
+ if(item.tagName) {
571
+ item = { el: $(item) };
572
+ } else {
573
+ type = item.type;
574
+ item = { data: item, src: item.src };
575
+ }
576
+
577
+ if(item.el) {
578
+ var types = mfp.types;
579
+
580
+ // check for 'mfp-TYPE' class
581
+ for(var i = 0; i < types.length; i++) {
582
+ if( item.el.hasClass('mfp-'+types[i]) ) {
583
+ type = types[i];
584
+ break;
585
+ }
586
+ }
587
+
588
+ item.src = item.el.attr('data-mfp-src');
589
+ if(!item.src) {
590
+ item.src = item.el.attr('href');
591
+ }
592
+ }
593
+
594
+ item.type = type || mfp.st.type || 'inline';
595
+ item.index = index;
596
+ item.parsed = true;
597
+ mfp.items[index] = item;
598
+ _mfpTrigger('ElementParse', item);
599
+
600
+ return mfp.items[index];
601
+ },
602
+
603
+
604
+ /**
605
+ * Initializes single popup or a group of popups
606
+ */
607
+ addGroup: function(el, options) {
608
+ var eHandler = function(e) {
609
+ e.mfpEl = this;
610
+ mfp._openClick(e, el, options);
611
+ };
612
+
613
+ if(!options) {
614
+ options = {};
615
+ }
616
+
617
+ var eName = 'click.magnificPopup';
618
+ options.mainEl = el;
619
+
620
+ if(options.items) {
621
+ options.isObj = true;
622
+ el.off(eName).on(eName, eHandler);
623
+ } else {
624
+ options.isObj = false;
625
+ if(options.delegate) {
626
+ el.off(eName).on(eName, options.delegate , eHandler);
627
+ } else {
628
+ options.items = el;
629
+ el.off(eName).on(eName, eHandler);
630
+ }
631
+ }
632
+ },
633
+ _openClick: function(e, el, options) {
634
+ var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick;
635
+
636
+
637
+ if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey ) ) {
638
+ return;
639
+ }
640
+
641
+ var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
642
+
643
+ if(disableOn) {
644
+ if($.isFunction(disableOn)) {
645
+ if( !disableOn.call(mfp) ) {
646
+ return true;
647
+ }
648
+ } else { // else it's number
649
+ if( _window.width() < disableOn ) {
650
+ return true;
651
+ }
652
+ }
653
+ }
654
+
655
+ if(e.type) {
656
+ e.preventDefault();
657
+
658
+ // This will prevent popup from closing if element is inside and popup is already opened
659
+ if(mfp.isOpen) {
660
+ e.stopPropagation();
661
+ }
662
+ }
663
+
664
+
665
+ options.el = $(e.mfpEl);
666
+ if(options.delegate) {
667
+ options.items = el.find(options.delegate);
668
+ }
669
+ mfp.open(options);
670
+ },
671
+
672
+
673
+ /**
674
+ * Updates text on preloader
675
+ */
676
+ updateStatus: function(status, text) {
677
+
678
+ if(mfp.preloader) {
679
+ if(_prevStatus !== status) {
680
+ mfp.container.removeClass('mfp-s-'+_prevStatus);
681
+ }
682
+
683
+ if(!text && status === 'loading') {
684
+ text = mfp.st.tLoading;
685
+ }
686
+
687
+ var data = {
688
+ status: status,
689
+ text: text
690
+ };
691
+ // allows to modify status
692
+ _mfpTrigger('UpdateStatus', data);
693
+
694
+ status = data.status;
695
+ text = data.text;
696
+
697
+ mfp.preloader.html(text);
698
+
699
+ mfp.preloader.find('a').on('click', function(e) {
700
+ e.stopImmediatePropagation();
701
+ });
702
+
703
+ mfp.container.addClass('mfp-s-'+status);
704
+ _prevStatus = status;
705
+ }
706
+ },
707
+
708
+
709
+ /*
710
+ "Private" helpers that aren't private at all
711
+ */
712
+ // Check to close popup or not
713
+ // "target" is an element that was clicked
714
+ _checkIfClose: function(target) {
715
+
716
+ if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
717
+ return;
718
+ }
719
+
720
+ var closeOnContent = mfp.st.closeOnContentClick;
721
+ var closeOnBg = mfp.st.closeOnBgClick;
722
+
723
+ if(closeOnContent && closeOnBg) {
724
+ return true;
725
+ } else {
726
+
727
+ // We close the popup if click is on close button or on preloader. Or if there is no content.
728
+ if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
729
+ return true;
730
+ }
731
+
732
+ // if click is outside the content
733
+ if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
734
+ if(closeOnBg) {
735
+ // last check, if the clicked element is in DOM, (in case it's removed onclick)
736
+ if( $.contains(document, target) ) {
737
+ return true;
738
+ }
739
+ }
740
+ } else if(closeOnContent) {
741
+ return true;
742
+ }
743
+
744
+ }
745
+ return false;
746
+ },
747
+ _addClassToMFP: function(cName) {
748
+ mfp.bgOverlay.addClass(cName);
749
+ mfp.wrap.addClass(cName);
750
+ },
751
+ _removeClassFromMFP: function(cName) {
752
+ this.bgOverlay.removeClass(cName);
753
+ mfp.wrap.removeClass(cName);
754
+ },
755
+ _hasScrollBar: function(winHeight) {
756
+ return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) );
757
+ },
758
+ _setFocus: function() {
759
+ (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
760
+ },
761
+ _onFocusIn: function(e) {
762
+ if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
763
+ mfp._setFocus();
764
+ return false;
765
+ }
766
+ },
767
+ _parseMarkup: function(template, values, item) {
768
+ var arr;
769
+ if(item.data) {
770
+ values = $.extend(item.data, values);
771
+ }
772
+ _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] );
773
+
774
+ $.each(values, function(key, value) {
775
+ if(value === undefined || value === false) {
776
+ return true;
777
+ }
778
+ arr = key.split('_');
779
+ if(arr.length > 1) {
780
+ var el = template.find(EVENT_NS + '-'+arr[0]);
781
+
782
+ if(el.length > 0) {
783
+ var attr = arr[1];
784
+ if(attr === 'replaceWith') {
785
+ if(el[0] !== value[0]) {
786
+ el.replaceWith(value);
787
+ }
788
+ } else if(attr === 'img') {
789
+ if(el.is('img')) {
790
+ el.attr('src', value);
791
+ } else {
792
+ el.replaceWith( '<img src="'+value+'" class="' + el.attr('class') + '" />' );
793
+ }
794
+ } else {
795
+ el.attr(arr[1], value);
796
+ }
797
+ }
798
+
799
+ } else {
800
+ template.find(EVENT_NS + '-'+key).html(value);
801
+ }
802
+ });
803
+ },
804
+
805
+ _getScrollbarSize: function() {
806
+ // thx David
807
+ if(mfp.scrollbarSize === undefined) {
808
+ var scrollDiv = document.createElement("div");
809
+ scrollDiv.id = "mfp-sbm";
810
+ scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
811
+ document.body.appendChild(scrollDiv);
812
+ mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
813
+ document.body.removeChild(scrollDiv);
814
+ }
815
+ return mfp.scrollbarSize;
816
+ }
817
+
818
+ }; /* MagnificPopup core prototype end */
819
+
820
+
821
+
822
+
823
+ /**
824
+ * Public static functions
825
+ */
826
+ $.magnificPopup = {
827
+ instance: null,
828
+ proto: MagnificPopup.prototype,
829
+ modules: [],
830
+
831
+ open: function(options, index) {
832
+ _checkInstance();
833
+
834
+ if(!options) {
835
+ options = {};
836
+ } else {
837
+ options = $.extend(true, {}, options);
838
+ }
839
+
840
+
841
+ options.isObj = true;
842
+ options.index = index || 0;
843
+ return this.instance.open(options);
844
+ },
845
+
846
+ close: function() {
847
+ return $.magnificPopup.instance && $.magnificPopup.instance.close();
848
+ },
849
+
850
+ registerModule: function(name, module) {
851
+ if(module.options) {
852
+ $.magnificPopup.defaults[name] = module.options;
853
+ }
854
+ $.extend(this.proto, module.proto);
855
+ this.modules.push(name);
856
+ },
857
+
858
+ defaults: {
859
+
860
+ // Info about options is in docs:
861
+ // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
862
+
863
+ disableOn: 0,
864
+
865
+ key: null,
866
+
867
+ midClick: false,
868
+
869
+ mainClass: '',
870
+
871
+ preloader: true,
872
+
873
+ focus: '', // CSS selector of input to focus after popup is opened
874
+
875
+ closeOnContentClick: false,
876
+
877
+ closeOnBgClick: true,
878
+
879
+ closeBtnInside: true,
880
+
881
+ showCloseBtn: true,
882
+
883
+ enableEscapeKey: true,
884
+
885
+ modal: false,
886
+
887
+ alignTop: false,
888
+
889
+ removalDelay: 0,
890
+
891
+ prependTo: null,
892
+
893
+ fixedContentPos: 'auto',
894
+
895
+ fixedBgPos: 'auto',
896
+
897
+ overflowY: 'auto',
898
+
899
+ closeMarkup: '<button title="%title%" type="button" class="mfp-close">&times;</button>',
900
+
901
+ tClose: 'Close (Esc)',
902
+
903
+ tLoading: 'Loading...'
904
+
905
+ }
906
+ };
907
+
908
+
909
+
910
+ $.fn.magnificPopup = function(options) {
911
+ _checkInstance();
912
+
913
+ var jqEl = $(this);
914
+
915
+ // We call some API method of first param is a string
916
+ if (typeof options === "string" ) {
917
+
918
+ if(options === 'open') {
919
+ var items,
920
+ itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
921
+ index = parseInt(arguments[1], 10) || 0;
922
+
923
+ if(itemOpts.items) {
924
+ items = itemOpts.items[index];
925
+ } else {
926
+ items = jqEl;
927
+ if(itemOpts.delegate) {
928
+ items = items.find(itemOpts.delegate);
929
+ }
930
+ items = items.eq( index );
931
+ }
932
+ mfp._openClick({mfpEl:items}, jqEl, itemOpts);
933
+ } else {
934
+ if(mfp.isOpen)
935
+ mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
936
+ }
937
+
938
+ } else {
939
+ // clone options obj
940
+ options = $.extend(true, {}, options);
941
+
942
+ /*
943
+ * As Zepto doesn't support .data() method for objects
944
+ * and it works only in normal browsers
945
+ * we assign "options" object directly to the DOM element. FTW!
946
+ */
947
+ if(_isJQ) {
948
+ jqEl.data('magnificPopup', options);
949
+ } else {
950
+ jqEl[0].magnificPopup = options;
951
+ }
952
+
953
+ mfp.addGroup(jqEl, options);
954
+
955
+ }
956
+ return jqEl;
957
+ };
958
+
959
+
960
+ //Quick benchmark
961
+ /*
962
+ var start = performance.now(),
963
+ i,
964
+ rounds = 1000;
965
+
966
+ for(i = 0; i < rounds; i++) {
967
+
968
+ }
969
+ console.log('Test #1:', performance.now() - start);
970
+
971
+ start = performance.now();
972
+ for(i = 0; i < rounds; i++) {
973
+
974
+ }
975
+ console.log('Test #2:', performance.now() - start);
976
+ */
977
+
978
+
979
+ /*>>core*/
980
+
981
+ /*>>inline*/
982
+
983
+ var INLINE_NS = 'inline',
984
+ _hiddenClass,
985
+ _inlinePlaceholder,
986
+ _lastInlineElement,
987
+ _putInlineElementsBack = function() {
988
+ if(_lastInlineElement) {
989
+ _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
990
+ _lastInlineElement = null;
991
+ }
992
+ };
993
+
994
+ $.magnificPopup.registerModule(INLINE_NS, {
995
+ options: {
996
+ hiddenClass: 'hide', // will be appended with `mfp-` prefix
997
+ markup: '',
998
+ tNotFound: 'Content not found'
999
+ },
1000
+ proto: {
1001
+
1002
+ initInline: function() {
1003
+ mfp.types.push(INLINE_NS);
1004
+
1005
+ _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
1006
+ _putInlineElementsBack();
1007
+ });
1008
+ },
1009
+
1010
+ getInline: function(item, template) {
1011
+
1012
+ _putInlineElementsBack();
1013
+
1014
+ if(item.src) {
1015
+ var inlineSt = mfp.st.inline,
1016
+ el = $(item.src);
1017
+
1018
+ if(el.length) {
1019
+
1020
+ // If target element has parent - we replace it with placeholder and put it back after popup is closed
1021
+ var parent = el[0].parentNode;
1022
+ if(parent && parent.tagName) {
1023
+ if(!_inlinePlaceholder) {
1024
+ _hiddenClass = inlineSt.hiddenClass;
1025
+ _inlinePlaceholder = _getEl(_hiddenClass);
1026
+ _hiddenClass = 'mfp-'+_hiddenClass;
1027
+ }
1028
+ // replace target inline element with placeholder
1029
+ _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
1030
+ }
1031
+
1032
+ mfp.updateStatus('ready');
1033
+ } else {
1034
+ mfp.updateStatus('error', inlineSt.tNotFound);
1035
+ el = $('<div>');
1036
+ }
1037
+
1038
+ item.inlineElement = el;
1039
+ return el;
1040
+ }
1041
+
1042
+ mfp.updateStatus('ready');
1043
+ mfp._parseMarkup(template, {}, item);
1044
+ return template;
1045
+ }
1046
+ }
1047
+ });
1048
+
1049
+ /*>>inline*/
1050
+
1051
+ /*>>ajax*/
1052
+ var AJAX_NS = 'ajax',
1053
+ _ajaxCur,
1054
+ _removeAjaxCursor = function() {
1055
+ if(_ajaxCur) {
1056
+ _body.removeClass(_ajaxCur);
1057
+ }
1058
+ },
1059
+ _destroyAjaxRequest = function() {
1060
+ _removeAjaxCursor();
1061
+ if(mfp.req) {
1062
+ mfp.req.abort();
1063
+ }
1064
+ };
1065
+
1066
+ $.magnificPopup.registerModule(AJAX_NS, {
1067
+
1068
+ options: {
1069
+ settings: null,
1070
+ cursor: 'mfp-ajax-cur',
1071
+ tError: '<a href="%url%">The content</a> could not be loaded.'
1072
+ },
1073
+
1074
+ proto: {
1075
+ initAjax: function() {
1076
+ mfp.types.push(AJAX_NS);
1077
+ _ajaxCur = mfp.st.ajax.cursor;
1078
+
1079
+ _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest);
1080
+ _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest);
1081
+ },
1082
+ getAjax: function(item) {
1083
+
1084
+ if(_ajaxCur)
1085
+ _body.addClass(_ajaxCur);
1086
+
1087
+ mfp.updateStatus('loading');
1088
+
1089
+ var opts = $.extend({
1090
+ url: item.src,
1091
+ success: function(data, textStatus, jqXHR) {
1092
+ var temp = {
1093
+ data:data,
1094
+ xhr:jqXHR
1095
+ };
1096
+
1097
+ _mfpTrigger('ParseAjax', temp);
1098
+
1099
+ mfp.appendContent( $(temp.data), AJAX_NS );
1100
+
1101
+ item.finished = true;
1102
+
1103
+ _removeAjaxCursor();
1104
+
1105
+ mfp._setFocus();
1106
+
1107
+ setTimeout(function() {
1108
+ mfp.wrap.addClass(READY_CLASS);
1109
+ }, 16);
1110
+
1111
+ mfp.updateStatus('ready');
1112
+
1113
+ _mfpTrigger('AjaxContentAdded');
1114
+ },
1115
+ error: function() {
1116
+ _removeAjaxCursor();
1117
+ item.finished = item.loadError = true;
1118
+ mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src));
1119
+ }
1120
+ }, mfp.st.ajax.settings);
1121
+
1122
+ mfp.req = $.ajax(opts);
1123
+
1124
+ return '';
1125
+ }
1126
+ }
1127
+ });
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+ /*>>ajax*/
1136
+
1137
+ /*>>image*/
1138
+ var _imgInterval,
1139
+ _getTitle = function(item) {
1140
+ if(item.data && item.data.title !== undefined)
1141
+ return item.data.title;
1142
+
1143
+ var src = mfp.st.image.titleSrc;
1144
+
1145
+ if(src) {
1146
+ if($.isFunction(src)) {
1147
+ return src.call(mfp, item);
1148
+ } else if(item.el) {
1149
+ return item.el.attr(src) || '';
1150
+ }
1151
+ }
1152
+ return '';
1153
+ };
1154
+
1155
+ $.magnificPopup.registerModule('image', {
1156
+
1157
+ options: {
1158
+ markup: '<div class="mfp-figure">'+
1159
+ '<div class="mfp-close"></div>'+
1160
+ '<figure>'+
1161
+ '<div class="mfp-img"></div>'+
1162
+ '<figcaption>'+
1163
+ '<div class="mfp-bottom-bar">'+
1164
+ '<div class="mfp-title"></div>'+
1165
+ '<div class="mfp-counter"></div>'+
1166
+ '</div>'+
1167
+ '</figcaption>'+
1168
+ '</figure>'+
1169
+ '</div>',
1170
+ cursor: 'mfp-zoom-out-cur',
1171
+ titleSrc: 'title',
1172
+ verticalFit: true,
1173
+ tError: '<a href="%url%">The image</a> could not be loaded.'
1174
+ },
1175
+
1176
+ proto: {
1177
+ initImage: function() {
1178
+ var imgSt = mfp.st.image,
1179
+ ns = '.image';
1180
+
1181
+ mfp.types.push('image');
1182
+
1183
+ _mfpOn(OPEN_EVENT+ns, function() {
1184
+ if(mfp.currItem.type === 'image' && imgSt.cursor) {
1185
+ _body.addClass(imgSt.cursor);
1186
+ }
1187
+ });
1188
+
1189
+ _mfpOn(CLOSE_EVENT+ns, function() {
1190
+ if(imgSt.cursor) {
1191
+ _body.removeClass(imgSt.cursor);
1192
+ }
1193
+ _window.off('resize' + EVENT_NS);
1194
+ });
1195
+
1196
+ _mfpOn('Resize'+ns, mfp.resizeImage);
1197
+ if(mfp.isLowIE) {
1198
+ _mfpOn('AfterChange', mfp.resizeImage);
1199
+ }
1200
+ },
1201
+ resizeImage: function() {
1202
+ var item = mfp.currItem;
1203
+ if(!item || !item.img) return;
1204
+
1205
+ if(mfp.st.image.verticalFit) {
1206
+ var decr = 0;
1207
+ // fix box-sizing in ie7/8
1208
+ if(mfp.isLowIE) {
1209
+ decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10);
1210
+ }
1211
+ item.img.css('max-height', mfp.wH-decr);
1212
+ }
1213
+ },
1214
+ _onImageHasSize: function(item) {
1215
+ if(item.img) {
1216
+
1217
+ item.hasSize = true;
1218
+
1219
+ if(_imgInterval) {
1220
+ clearInterval(_imgInterval);
1221
+ }
1222
+
1223
+ item.isCheckingImgSize = false;
1224
+
1225
+ _mfpTrigger('ImageHasSize', item);
1226
+
1227
+ if(item.imgHidden) {
1228
+ if(mfp.content)
1229
+ mfp.content.removeClass('mfp-loading');
1230
+
1231
+ item.imgHidden = false;
1232
+ }
1233
+
1234
+ }
1235
+ },
1236
+
1237
+ /**
1238
+ * Function that loops until the image has size to display elements that rely on it asap
1239
+ */
1240
+ findImageSize: function(item) {
1241
+
1242
+ var counter = 0,
1243
+ img = item.img[0],
1244
+ mfpSetInterval = function(delay) {
1245
+
1246
+ if(_imgInterval) {
1247
+ clearInterval(_imgInterval);
1248
+ }
1249
+ // decelerating interval that checks for size of an image
1250
+ _imgInterval = setInterval(function() {
1251
+ if(img.naturalWidth > 0) {
1252
+ mfp._onImageHasSize(item);
1253
+ return;
1254
+ }
1255
+
1256
+ if(counter > 200) {
1257
+ clearInterval(_imgInterval);
1258
+ }
1259
+
1260
+ counter++;
1261
+ if(counter === 3) {
1262
+ mfpSetInterval(10);
1263
+ } else if(counter === 40) {
1264
+ mfpSetInterval(50);
1265
+ } else if(counter === 100) {
1266
+ mfpSetInterval(500);
1267
+ }
1268
+ }, delay);
1269
+ };
1270
+
1271
+ mfpSetInterval(1);
1272
+ },
1273
+
1274
+ getImage: function(item, template) {
1275
+
1276
+ var guard = 0,
1277
+
1278
+ // image load complete handler
1279
+ onLoadComplete = function() {
1280
+ if(item) {
1281
+ if (item.img[0].complete) {
1282
+ item.img.off('.mfploader');
1283
+
1284
+ if(item === mfp.currItem){
1285
+ mfp._onImageHasSize(item);
1286
+
1287
+ mfp.updateStatus('ready');
1288
+ }
1289
+
1290
+ item.hasSize = true;
1291
+ item.loaded = true;
1292
+
1293
+ _mfpTrigger('ImageLoadComplete');
1294
+
1295
+ }
1296
+ else {
1297
+ // if image complete check fails 200 times (20 sec), we assume that there was an error.
1298
+ guard++;
1299
+ if(guard < 200) {
1300
+ setTimeout(onLoadComplete,100);
1301
+ } else {
1302
+ onLoadError();
1303
+ }
1304
+ }
1305
+ }
1306
+ },
1307
+
1308
+ // image error handler
1309
+ onLoadError = function() {
1310
+ if(item) {
1311
+ item.img.off('.mfploader');
1312
+ if(item === mfp.currItem){
1313
+ mfp._onImageHasSize(item);
1314
+ mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1315
+ }
1316
+
1317
+ item.hasSize = true;
1318
+ item.loaded = true;
1319
+ item.loadError = true;
1320
+ }
1321
+ },
1322
+ imgSt = mfp.st.image;
1323
+
1324
+
1325
+ var el = template.find('.mfp-img');
1326
+ if(el.length) {
1327
+ var img = document.createElement('img');
1328
+ img.className = 'mfp-img';
1329
+ item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError);
1330
+ img.src = item.src;
1331
+
1332
+ // without clone() "error" event is not firing when IMG is replaced by new IMG
1333
+ // TODO: find a way to avoid such cloning
1334
+ if(el.is('img')) {
1335
+ item.img = item.img.clone();
1336
+ }
1337
+
1338
+ img = item.img[0];
1339
+ if(img.naturalWidth > 0) {
1340
+ item.hasSize = true;
1341
+ } else if(!img.width) {
1342
+ item.hasSize = false;
1343
+ }
1344
+ }
1345
+
1346
+ mfp._parseMarkup(template, {
1347
+ title: _getTitle(item),
1348
+ img_replaceWith: item.img
1349
+ }, item);
1350
+
1351
+ mfp.resizeImage();
1352
+
1353
+ if(item.hasSize) {
1354
+ if(_imgInterval) clearInterval(_imgInterval);
1355
+
1356
+ if(item.loadError) {
1357
+ template.addClass('mfp-loading');
1358
+ mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1359
+ } else {
1360
+ template.removeClass('mfp-loading');
1361
+ mfp.updateStatus('ready');
1362
+ }
1363
+ return template;
1364
+ }
1365
+
1366
+ mfp.updateStatus('loading');
1367
+ item.loading = true;
1368
+
1369
+ if(!item.hasSize) {
1370
+ item.imgHidden = true;
1371
+ template.addClass('mfp-loading');
1372
+ mfp.findImageSize(item);
1373
+ }
1374
+
1375
+ return template;
1376
+ }
1377
+ }
1378
+ });
1379
+
1380
+
1381
+
1382
+ /*>>image*/
1383
+
1384
+ /*>>zoom*/
1385
+ var hasMozTransform,
1386
+ getHasMozTransform = function() {
1387
+ if(hasMozTransform === undefined) {
1388
+ hasMozTransform = document.createElement('p').style.MozTransform !== undefined;
1389
+ }
1390
+ return hasMozTransform;
1391
+ };
1392
+
1393
+ $.magnificPopup.registerModule('zoom', {
1394
+
1395
+ options: {
1396
+ enabled: false,
1397
+ easing: 'ease-in-out',
1398
+ duration: 300,
1399
+ opener: function(element) {
1400
+ return element.is('img') ? element : element.find('img');
1401
+ }
1402
+ },
1403
+
1404
+ proto: {
1405
+
1406
+ initZoom: function() {
1407
+ var zoomSt = mfp.st.zoom,
1408
+ ns = '.zoom',
1409
+ image;
1410
+
1411
+ if(!zoomSt.enabled || !mfp.supportsTransition) {
1412
+ return;
1413
+ }
1414
+
1415
+ var duration = zoomSt.duration,
1416
+ getElToAnimate = function(image) {
1417
+ var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'),
1418
+ transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing,
1419
+ cssObj = {
1420
+ position: 'fixed',
1421
+ zIndex: 9999,
1422
+ left: 0,
1423
+ top: 0,
1424
+ '-webkit-backface-visibility': 'hidden'
1425
+ },
1426
+ t = 'transition';
1427
+
1428
+ cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition;
1429
+
1430
+ newImg.css(cssObj);
1431
+ return newImg;
1432
+ },
1433
+ showMainContent = function() {
1434
+ mfp.content.css('visibility', 'visible');
1435
+ },
1436
+ openTimeout,
1437
+ animatedImg;
1438
+
1439
+ _mfpOn('BuildControls'+ns, function() {
1440
+ if(mfp._allowZoom()) {
1441
+
1442
+ clearTimeout(openTimeout);
1443
+ mfp.content.css('visibility', 'hidden');
1444
+
1445
+ // Basically, all code below does is clones existing image, puts in on top of the current one and animated it
1446
+
1447
+ image = mfp._getItemToZoom();
1448
+
1449
+ if(!image) {
1450
+ showMainContent();
1451
+ return;
1452
+ }
1453
+
1454
+ animatedImg = getElToAnimate(image);
1455
+
1456
+ animatedImg.css( mfp._getOffset() );
1457
+
1458
+ mfp.wrap.append(animatedImg);
1459
+
1460
+ openTimeout = setTimeout(function() {
1461
+ animatedImg.css( mfp._getOffset( true ) );
1462
+ openTimeout = setTimeout(function() {
1463
+
1464
+ showMainContent();
1465
+
1466
+ setTimeout(function() {
1467
+ animatedImg.remove();
1468
+ image = animatedImg = null;
1469
+ _mfpTrigger('ZoomAnimationEnded');
1470
+ }, 16); // avoid blink when switching images
1471
+
1472
+ }, duration); // this timeout equals animation duration
1473
+
1474
+ }, 16); // by adding this timeout we avoid short glitch at the beginning of animation
1475
+
1476
+
1477
+ // Lots of timeouts...
1478
+ }
1479
+ });
1480
+ _mfpOn(BEFORE_CLOSE_EVENT+ns, function() {
1481
+ if(mfp._allowZoom()) {
1482
+
1483
+ clearTimeout(openTimeout);
1484
+
1485
+ mfp.st.removalDelay = duration;
1486
+
1487
+ if(!image) {
1488
+ image = mfp._getItemToZoom();
1489
+ if(!image) {
1490
+ return;
1491
+ }
1492
+ animatedImg = getElToAnimate(image);
1493
+ }
1494
+
1495
+
1496
+ animatedImg.css( mfp._getOffset(true) );
1497
+ mfp.wrap.append(animatedImg);
1498
+ mfp.content.css('visibility', 'hidden');
1499
+
1500
+ setTimeout(function() {
1501
+ animatedImg.css( mfp._getOffset() );
1502
+ }, 16);
1503
+ }
1504
+
1505
+ });
1506
+
1507
+ _mfpOn(CLOSE_EVENT+ns, function() {
1508
+ if(mfp._allowZoom()) {
1509
+ showMainContent();
1510
+ if(animatedImg) {
1511
+ animatedImg.remove();
1512
+ }
1513
+ image = null;
1514
+ }
1515
+ });
1516
+ },
1517
+
1518
+ _allowZoom: function() {
1519
+ return mfp.currItem.type === 'image';
1520
+ },
1521
+
1522
+ _getItemToZoom: function() {
1523
+ if(mfp.currItem.hasSize) {
1524
+ return mfp.currItem.img;
1525
+ } else {
1526
+ return false;
1527
+ }
1528
+ },
1529
+
1530
+ // Get element postion relative to viewport
1531
+ _getOffset: function(isLarge) {
1532
+ var el;
1533
+ if(isLarge) {
1534
+ el = mfp.currItem.img;
1535
+ } else {
1536
+ el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
1537
+ }
1538
+
1539
+ var offset = el.offset();
1540
+ var paddingTop = parseInt(el.css('padding-top'),10);
1541
+ var paddingBottom = parseInt(el.css('padding-bottom'),10);
1542
+ offset.top -= ( $(window).scrollTop() - paddingTop );
1543
+
1544
+
1545
+ /*
1546
+
1547
+ Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
1548
+
1549
+ */
1550
+ var obj = {
1551
+ width: el.width(),
1552
+ // fix Zepto height+padding issue
1553
+ height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
1554
+ };
1555
+
1556
+ // I hate to do this, but there is no another option
1557
+ if( getHasMozTransform() ) {
1558
+ obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
1559
+ } else {
1560
+ obj.left = offset.left;
1561
+ obj.top = offset.top;
1562
+ }
1563
+ return obj;
1564
+ }
1565
+
1566
+ }
1567
+ });
1568
+
1569
+
1570
+
1571
+ /*>>zoom*/
1572
+
1573
+ /*>>iframe*/
1574
+
1575
+ var IFRAME_NS = 'iframe',
1576
+ _emptyPage = '//about:blank',
1577
+
1578
+ _fixIframeBugs = function(isShowing) {
1579
+ if(mfp.currTemplate[IFRAME_NS]) {
1580
+ var el = mfp.currTemplate[IFRAME_NS].find('iframe');
1581
+ if(el.length) {
1582
+ // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug
1583
+ if(!isShowing) {
1584
+ el[0].src = _emptyPage;
1585
+ }
1586
+
1587
+ // IE8 black screen bug fix
1588
+ if(mfp.isIE8) {
1589
+ el.css('display', isShowing ? 'block' : 'none');
1590
+ }
1591
+ }
1592
+ }
1593
+ };
1594
+
1595
+ $.magnificPopup.registerModule(IFRAME_NS, {
1596
+
1597
+ options: {
1598
+ markup: '<div class="mfp-iframe-scaler">'+
1599
+ '<div class="mfp-close"></div>'+
1600
+ '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
1601
+ '</div>',
1602
+
1603
+ srcAction: 'iframe_src',
1604
+
1605
+ // we don't care and support only one default type of URL by default
1606
+ patterns: {
1607
+ youtube: {
1608
+ index: 'youtube.com',
1609
+ id: 'v=',
1610
+ src: '//www.youtube.com/embed/%id%?autoplay=1'
1611
+ },
1612
+ vimeo: {
1613
+ index: 'vimeo.com/',
1614
+ id: '/',
1615
+ src: '//player.vimeo.com/video/%id%?autoplay=1'
1616
+ },
1617
+ gmaps: {
1618
+ index: '//maps.google.',
1619
+ src: '%id%&output=embed'
1620
+ }
1621
+ }
1622
+ },
1623
+
1624
+ proto: {
1625
+ initIframe: function() {
1626
+ mfp.types.push(IFRAME_NS);
1627
+
1628
+ _mfpOn('BeforeChange', function(e, prevType, newType) {
1629
+ if(prevType !== newType) {
1630
+ if(prevType === IFRAME_NS) {
1631
+ _fixIframeBugs(); // iframe if removed
1632
+ } else if(newType === IFRAME_NS) {
1633
+ _fixIframeBugs(true); // iframe is showing
1634
+ }
1635
+ }// else {
1636
+ // iframe source is switched, don't do anything
1637
+ //}
1638
+ });
1639
+
1640
+ _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
1641
+ _fixIframeBugs();
1642
+ });
1643
+ },
1644
+
1645
+ getIframe: function(item, template) {
1646
+ var embedSrc = item.src;
1647
+ var iframeSt = mfp.st.iframe;
1648
+
1649
+ $.each(iframeSt.patterns, function() {
1650
+ if(embedSrc.indexOf( this.index ) > -1) {
1651
+ if(this.id) {
1652
+ if(typeof this.id === 'string') {
1653
+ embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);
1654
+ } else {
1655
+ embedSrc = this.id.call( this, embedSrc );
1656
+ }
1657
+ }
1658
+ embedSrc = this.src.replace('%id%', embedSrc );
1659
+ return false; // break;
1660
+ }
1661
+ });
1662
+
1663
+ var dataObj = {};
1664
+ if(iframeSt.srcAction) {
1665
+ dataObj[iframeSt.srcAction] = embedSrc;
1666
+ }
1667
+ mfp._parseMarkup(template, dataObj, item);
1668
+
1669
+ mfp.updateStatus('ready');
1670
+
1671
+ return template;
1672
+ }
1673
+ }
1674
+ });
1675
+
1676
+
1677
+
1678
+ /*>>iframe*/
1679
+
1680
+ /*>>gallery*/
1681
+ /**
1682
+ * Get looped index depending on number of slides
1683
+ */
1684
+ var _getLoopedId = function(index) {
1685
+ var numSlides = mfp.items.length;
1686
+ if(index > numSlides - 1) {
1687
+ return index - numSlides;
1688
+ } else if(index < 0) {
1689
+ return numSlides + index;
1690
+ }
1691
+ return index;
1692
+ },
1693
+ _replaceCurrTotal = function(text, curr, total) {
1694
+ return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total);
1695
+ };
1696
+
1697
+ $.magnificPopup.registerModule('gallery', {
1698
+
1699
+ options: {
1700
+ enabled: false,
1701
+ arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
1702
+ preload: [0,2],
1703
+ navigateByImgClick: true,
1704
+ arrows: true,
1705
+
1706
+ tPrev: 'Previous (Left arrow key)',
1707
+ tNext: 'Next (Right arrow key)',
1708
+ tCounter: '%curr% of %total%'
1709
+ },
1710
+
1711
+ proto: {
1712
+ initGallery: function() {
1713
+
1714
+ var gSt = mfp.st.gallery,
1715
+ ns = '.mfp-gallery',
1716
+ supportsFastClick = Boolean($.fn.mfpFastClick);
1717
+
1718
+ mfp.direction = true; // true - next, false - prev
1719
+
1720
+ if(!gSt || !gSt.enabled ) return false;
1721
+
1722
+ _wrapClasses += ' mfp-gallery';
1723
+
1724
+ _mfpOn(OPEN_EVENT+ns, function() {
1725
+
1726
+ if(gSt.navigateByImgClick) {
1727
+ mfp.wrap.on('click'+ns, '.mfp-img', function() {
1728
+ if(mfp.items.length > 1) {
1729
+ mfp.next();
1730
+ return false;
1731
+ }
1732
+ });
1733
+ }
1734
+
1735
+ _document.on('keydown'+ns, function(e) {
1736
+ if (e.keyCode === 37) {
1737
+ mfp.prev();
1738
+ } else if (e.keyCode === 39) {
1739
+ mfp.next();
1740
+ }
1741
+ });
1742
+ });
1743
+
1744
+ _mfpOn('UpdateStatus'+ns, function(e, data) {
1745
+ if(data.text) {
1746
+ data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length);
1747
+ }
1748
+ });
1749
+
1750
+ _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
1751
+ var l = mfp.items.length;
1752
+ values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
1753
+ });
1754
+
1755
+ _mfpOn('BuildControls' + ns, function() {
1756
+ if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
1757
+ var markup = gSt.arrowMarkup,
1758
+ arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS),
1759
+ arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS);
1760
+
1761
+ var eName = supportsFastClick ? 'mfpFastClick' : 'click';
1762
+ arrowLeft[eName](function() {
1763
+ mfp.prev();
1764
+ });
1765
+ arrowRight[eName](function() {
1766
+ mfp.next();
1767
+ });
1768
+
1769
+ // Polyfill for :before and :after (adds elements with classes mfp-a and mfp-b)
1770
+ if(mfp.isIE7) {
1771
+ _getEl('b', arrowLeft[0], false, true);
1772
+ _getEl('a', arrowLeft[0], false, true);
1773
+ _getEl('b', arrowRight[0], false, true);
1774
+ _getEl('a', arrowRight[0], false, true);
1775
+ }
1776
+
1777
+ mfp.container.append(arrowLeft.add(arrowRight));
1778
+ }
1779
+ });
1780
+
1781
+ _mfpOn(CHANGE_EVENT+ns, function() {
1782
+ if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout);
1783
+
1784
+ mfp._preloadTimeout = setTimeout(function() {
1785
+ mfp.preloadNearbyImages();
1786
+ mfp._preloadTimeout = null;
1787
+ }, 16);
1788
+ });
1789
+
1790
+
1791
+ _mfpOn(CLOSE_EVENT+ns, function() {
1792
+ _document.off(ns);
1793
+ mfp.wrap.off('click'+ns);
1794
+
1795
+ if(mfp.arrowLeft && supportsFastClick) {
1796
+ mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
1797
+ }
1798
+ mfp.arrowRight = mfp.arrowLeft = null;
1799
+ });
1800
+
1801
+ },
1802
+ next: function() {
1803
+ mfp.direction = true;
1804
+ mfp.index = _getLoopedId(mfp.index + 1);
1805
+ mfp.updateItemHTML();
1806
+ },
1807
+ prev: function() {
1808
+ mfp.direction = false;
1809
+ mfp.index = _getLoopedId(mfp.index - 1);
1810
+ mfp.updateItemHTML();
1811
+ },
1812
+ goTo: function(newIndex) {
1813
+ mfp.direction = (newIndex >= mfp.index);
1814
+ mfp.index = newIndex;
1815
+ mfp.updateItemHTML();
1816
+ },
1817
+ preloadNearbyImages: function() {
1818
+ var p = mfp.st.gallery.preload,
1819
+ preloadBefore = Math.min(p[0], mfp.items.length),
1820
+ preloadAfter = Math.min(p[1], mfp.items.length),
1821
+ i;
1822
+
1823
+ for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) {
1824
+ mfp._preloadItem(mfp.index+i);
1825
+ }
1826
+ for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) {
1827
+ mfp._preloadItem(mfp.index-i);
1828
+ }
1829
+ },
1830
+ _preloadItem: function(index) {
1831
+ index = _getLoopedId(index);
1832
+
1833
+ if(mfp.items[index].preloaded) {
1834
+ return;
1835
+ }
1836
+
1837
+ var item = mfp.items[index];
1838
+ if(!item.parsed) {
1839
+ item = mfp.parseEl( index );
1840
+ }
1841
+
1842
+ _mfpTrigger('LazyLoad', item);
1843
+
1844
+ if(item.type === 'image') {
1845
+ item.img = $('<img class="mfp-img" />').on('load.mfploader', function() {
1846
+ item.hasSize = true;
1847
+ }).on('error.mfploader', function() {
1848
+ item.hasSize = true;
1849
+ item.loadError = true;
1850
+ _mfpTrigger('LazyLoadError', item);
1851
+ }).attr('src', item.src);
1852
+ }
1853
+
1854
+
1855
+ item.preloaded = true;
1856
+ }
1857
+ }
1858
+ });
1859
+
1860
+ /*
1861
+ Touch Support that might be implemented some day
1862
+
1863
+ addSwipeGesture: function() {
1864
+ var startX,
1865
+ moved,
1866
+ multipleTouches;
1867
+
1868
+ return;
1869
+
1870
+ var namespace = '.mfp',
1871
+ addEventNames = function(pref, down, move, up, cancel) {
1872
+ mfp._tStart = pref + down + namespace;
1873
+ mfp._tMove = pref + move + namespace;
1874
+ mfp._tEnd = pref + up + namespace;
1875
+ mfp._tCancel = pref + cancel + namespace;
1876
+ };
1877
+
1878
+ if(window.navigator.msPointerEnabled) {
1879
+ addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
1880
+ } else if('ontouchstart' in window) {
1881
+ addEventNames('touch', 'start', 'move', 'end', 'cancel');
1882
+ } else {
1883
+ return;
1884
+ }
1885
+ _window.on(mfp._tStart, function(e) {
1886
+ var oE = e.originalEvent;
1887
+ multipleTouches = moved = false;
1888
+ startX = oE.pageX || oE.changedTouches[0].pageX;
1889
+ }).on(mfp._tMove, function(e) {
1890
+ if(e.originalEvent.touches.length > 1) {
1891
+ multipleTouches = e.originalEvent.touches.length;
1892
+ } else {
1893
+ //e.preventDefault();
1894
+ moved = true;
1895
+ }
1896
+ }).on(mfp._tEnd + ' ' + mfp._tCancel, function(e) {
1897
+ if(moved && !multipleTouches) {
1898
+ var oE = e.originalEvent,
1899
+ diff = startX - (oE.pageX || oE.changedTouches[0].pageX);
1900
+
1901
+ if(diff > 20) {
1902
+ mfp.next();
1903
+ } else if(diff < -20) {
1904
+ mfp.prev();
1905
+ }
1906
+ }
1907
+ });
1908
+ },
1909
+ */
1910
+
1911
+
1912
+ /*>>gallery*/
1913
+
1914
+ /*>>retina*/
1915
+
1916
+ var RETINA_NS = 'retina';
1917
+
1918
+ $.magnificPopup.registerModule(RETINA_NS, {
1919
+ options: {
1920
+ replaceSrc: function(item) {
1921
+ return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; });
1922
+ },
1923
+ ratio: 1 // Function or number. Set to 1 to disable.
1924
+ },
1925
+ proto: {
1926
+ initRetina: function() {
1927
+ if(window.devicePixelRatio > 1) {
1928
+
1929
+ var st = mfp.st.retina,
1930
+ ratio = st.ratio;
1931
+
1932
+ ratio = !isNaN(ratio) ? ratio : ratio();
1933
+
1934
+ if(ratio > 1) {
1935
+ _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
1936
+ item.img.css({
1937
+ 'max-width': item.img[0].naturalWidth / ratio,
1938
+ 'width': '100%'
1939
+ });
1940
+ });
1941
+ _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
1942
+ item.src = st.replaceSrc(item, ratio);
1943
+ });
1944
+ }
1945
+ }
1946
+
1947
+ }
1948
+ }
1949
+ });
1950
+
1951
+ /*>>retina*/
1952
+
1953
+ /*>>fastclick*/
1954
+ /**
1955
+ * FastClick event implementation. (removes 300ms delay on touch devices)
1956
+ * Based on https://developers.google.com/mobile/articles/fast_buttons
1957
+ *
1958
+ * You may use it outside the Magnific Popup by calling just:
1959
+ *
1960
+ * $('.your-el').mfpFastClick(function() {
1961
+ * console.log('Clicked!');
1962
+ * });
1963
+ *
1964
+ * To unbind:
1965
+ * $('.your-el').destroyMfpFastClick();
1966
+ *
1967
+ *
1968
+ * Note that it's a very basic and simple implementation, it blocks ghost click on the same element where it was bound.
1969
+ * If you need something more advanced, use plugin by FT Labs https://github.com/ftlabs/fastclick
1970
+ *
1971
+ */
1972
+
1973
+ (function() {
1974
+ var ghostClickDelay = 1000,
1975
+ supportsTouch = 'ontouchstart' in window,
1976
+ unbindTouchMove = function() {
1977
+ _window.off('touchmove'+ns+' touchend'+ns);
1978
+ },
1979
+ eName = 'mfpFastClick',
1980
+ ns = '.'+eName;
1981
+
1982
+
1983
+ // As Zepto.js doesn't have an easy way to add custom events (like jQuery), so we implement it in this way
1984
+ $.fn.mfpFastClick = function(callback) {
1985
+
1986
+ return $(this).each(function() {
1987
+
1988
+ var elem = $(this),
1989
+ lock;
1990
+
1991
+ if( supportsTouch ) {
1992
+
1993
+ var timeout,
1994
+ startX,
1995
+ startY,
1996
+ pointerMoved,
1997
+ point,
1998
+ numPointers;
1999
+
2000
+ elem.on('touchstart' + ns, function(e) {
2001
+ pointerMoved = false;
2002
+ numPointers = 1;
2003
+
2004
+ point = e.originalEvent ? e.originalEvent.touches[0] : e.touches[0];
2005
+ startX = point.clientX;
2006
+ startY = point.clientY;
2007
+
2008
+ _window.on('touchmove'+ns, function(e) {
2009
+ point = e.originalEvent ? e.originalEvent.touches : e.touches;
2010
+ numPointers = point.length;
2011
+ point = point[0];
2012
+ if (Math.abs(point.clientX - startX) > 10 ||
2013
+ Math.abs(point.clientY - startY) > 10) {
2014
+ pointerMoved = true;
2015
+ unbindTouchMove();
2016
+ }
2017
+ }).on('touchend'+ns, function(e) {
2018
+ unbindTouchMove();
2019
+ if(pointerMoved || numPointers > 1) {
2020
+ return;
2021
+ }
2022
+ lock = true;
2023
+ e.preventDefault();
2024
+ clearTimeout(timeout);
2025
+ timeout = setTimeout(function() {
2026
+ lock = false;
2027
+ }, ghostClickDelay);
2028
+ callback();
2029
+ });
2030
+ });
2031
+
2032
+ }
2033
+
2034
+ elem.on('click' + ns, function() {
2035
+ if(!lock) {
2036
+ callback();
2037
+ }
2038
+ });
2039
+ });
2040
+ };
2041
+
2042
+ $.fn.destroyMfpFastClick = function() {
2043
+ $(this).off('touchstart' + ns + ' click' + ns);
2044
+ if(supportsTouch) _window.off('touchmove'+ns+' touchend'+ns);
2045
+ };
2046
+ })();
2047
+
2048
+ /*>>fastclick*/
2049
+ _checkInstance(); })(window.jQuery || window.Zepto);