ns-styleguide 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/style-guide/_style-guide.scss +4 -0
  3. data/style-guide/global/_base.scss +33 -0
  4. data/style-guide/global/_colors.scss +24 -0
  5. data/style-guide/global/_extendables.scss +16 -0
  6. data/style-guide/global/_functions.scss +5 -0
  7. data/style-guide/global/_mixins.scss +5 -0
  8. data/style-guide/global/_variables.scss +15 -0
  9. data/templates/project/assets/6.jpg +0 -0
  10. data/templates/project/assets/_nsfont/_comment.svg +8 -0
  11. data/templates/project/assets/_nsfont/_default-user.svg +12 -0
  12. data/templates/project/assets/_nsfont/_home.svg +12 -0
  13. data/templates/project/assets/_nsfont/_notify.svg +13 -0
  14. data/templates/project/assets/_nsfont/_pillbox.svg +27 -0
  15. data/templates/project/assets/_nsfont/_search.svg +12 -0
  16. data/templates/project/assets/_nsfont/bs-circulatory.svg +26 -0
  17. data/templates/project/assets/_nsfont/bs-digestive.svg +28 -0
  18. data/templates/project/assets/_nsfont/bs-endocrine.svg +33 -0
  19. data/templates/project/assets/_nsfont/bs-immune.svg +31 -0
  20. data/templates/project/assets/_nsfont/bs-muscular-skeletal.svg +119 -0
  21. data/templates/project/assets/_nsfont/bs-nervous.svg +31 -0
  22. data/templates/project/assets/_nsfont/bs-reprodutive.svg +29 -0
  23. data/templates/project/assets/_nsfont/bs-respiratory.svg +17 -0
  24. data/templates/project/assets/_nsfont/ls-athletic.svg +17 -0
  25. data/templates/project/assets/_nsfont/ls-diet.svg +21 -0
  26. data/templates/project/assets/_nsfont/ls-energyvitality.svg +14 -0
  27. data/templates/project/assets/_nsfont/ls-mentalacuity.svg +34 -0
  28. data/templates/project/assets/_nsfont/ls-sexual.svg +42 -0
  29. data/templates/project/assets/_nsfont/ls-weightcontrol.svg +17 -0
  30. data/templates/project/assets/_nsfont/nsa-check.svg +7 -0
  31. data/templates/project/assets/_nsfont/nsa-questionmark.svg +15 -0
  32. data/templates/project/assets/_nsfont/nsa-xmark.svg +10 -0
  33. data/templates/project/assets/_nsfont/st-botanical.svg +18 -0
  34. data/templates/project/assets/_nsfont/st-food.svg +24 -0
  35. data/templates/project/assets/_nsfont/st-mineral.svg +15 -0
  36. data/templates/project/assets/_nsfont/st-other.svg +9 -0
  37. data/templates/project/assets/_nsfont/st-vitamin.svg +25 -0
  38. data/templates/project/assets/_nsfont/vote-down.svg +10 -0
  39. data/templates/project/assets/_nsfont/vote-up.svg +10 -0
  40. data/templates/project/assets/_nsfont/yp-age.svg +22 -0
  41. data/templates/project/assets/_nsfont/yp-gender.svg +16 -0
  42. data/templates/project/assets/_nsfont/yp-preventiontherapy.svg +109 -0
  43. data/templates/project/assets/aloe-vera.jpg +0 -0
  44. data/templates/project/assets/alzheimers-brainpuzzle-512.jpg +0 -0
  45. data/templates/project/assets/blurred1.jpg +0 -0
  46. data/templates/project/assets/blurred5.jpg +0 -0
  47. data/templates/project/assets/blurred6.jpg +0 -0
  48. data/templates/project/assets/botanical.svg +18 -0
  49. data/templates/project/assets/capsule.jpg +0 -0
  50. data/templates/project/assets/clouds.jpg +0 -0
  51. data/templates/project/assets/clouds.png +0 -0
  52. data/templates/project/assets/factorfiction-s3d0b80354a.png +0 -0
  53. data/templates/project/assets/factorfiction/factorfiction.png +0 -0
  54. data/templates/project/assets/factorfiction/factorfiction.svg +420 -0
  55. data/templates/project/assets/fff.png +0 -0
  56. data/templates/project/assets/food.svg +24 -0
  57. data/templates/project/assets/foundation/orbit/bullets.jpg +0 -0
  58. data/templates/project/assets/foundation/orbit/left-arrow-small.png +0 -0
  59. data/templates/project/assets/foundation/orbit/left-arrow.png +0 -0
  60. data/templates/project/assets/foundation/orbit/loading.gif +0 -0
  61. data/templates/project/assets/foundation/orbit/mask-black.png +0 -0
  62. data/templates/project/assets/foundation/orbit/pause-black.png +0 -0
  63. data/templates/project/assets/foundation/orbit/right-arrow-small.png +0 -0
  64. data/templates/project/assets/foundation/orbit/right-arrow.png +0 -0
  65. data/templates/project/assets/foundation/orbit/rotator-black.png +0 -0
  66. data/templates/project/assets/foundation/orbit/timer-black.png +0 -0
  67. data/templates/project/assets/glyphicons-halflings-white.png +0 -0
  68. data/templates/project/assets/glyphicons-halflings.png +0 -0
  69. data/templates/project/assets/hero.jpg +0 -0
  70. data/templates/project/assets/hero2.jpg +0 -0
  71. data/templates/project/assets/hero3.jpg +0 -0
  72. data/templates/project/assets/ice.jpg +0 -0
  73. data/templates/project/assets/iceberg.jpg +0 -0
  74. data/templates/project/assets/landing.jpg +0 -0
  75. data/templates/project/assets/mineral.svg +15 -0
  76. data/templates/project/assets/moon.jpg +0 -0
  77. data/templates/project/assets/ns-logo.svg +177 -0
  78. data/templates/project/assets/nslogo-s56b550b473.png +0 -0
  79. data/templates/project/assets/nslogo/nslogo.png +0 -0
  80. data/templates/project/assets/nslogo/nslogo.svg +177 -0
  81. data/templates/project/assets/other.svg +9 -0
  82. data/templates/project/assets/pillbox-hover.svg +33 -0
  83. data/templates/project/assets/pillbox-image.png +0 -0
  84. data/templates/project/assets/pillbox-image.svg +7880 -0
  85. data/templates/project/assets/pillbox.svg +27 -0
  86. data/templates/project/assets/rocket.jpg +0 -0
  87. data/templates/project/assets/shuttle.jpeg +0 -0
  88. data/templates/project/assets/svg/community-clear.svg +82 -0
  89. data/templates/project/assets/svg/community.svg +64 -0
  90. data/templates/project/assets/svg/conditions.svg +18 -0
  91. data/templates/project/assets/svg/experts.svg +32 -0
  92. data/templates/project/assets/svg/fact-or-fiction.svg +420 -0
  93. data/templates/project/assets/svg/lifestyle.svg +22 -0
  94. data/templates/project/assets/svg/perspective.svg +22 -0
  95. data/templates/project/assets/svg/supplements.svg +19 -0
  96. data/templates/project/assets/svgicons-s95620826ea.png +0 -0
  97. data/templates/project/assets/svgicons/community.png +0 -0
  98. data/templates/project/assets/svgicons/community.svg +55 -0
  99. data/templates/project/assets/svgicons/conditions.png +0 -0
  100. data/templates/project/assets/svgicons/conditions.svg +16 -0
  101. data/templates/project/assets/svgicons/experts.png +0 -0
  102. data/templates/project/assets/svgicons/experts.svg +30 -0
  103. data/templates/project/assets/svgicons/lifestyle.png +0 -0
  104. data/templates/project/assets/svgicons/lifestyle.svg +20 -0
  105. data/templates/project/assets/svgicons/supplements.png +0 -0
  106. data/templates/project/assets/svgicons/supplements.svg +17 -0
  107. data/templates/project/assets/svgicons/your-perspective.png +0 -0
  108. data/templates/project/assets/svgicons/your-perspective.svg +20 -0
  109. data/templates/project/assets/users/kp.jpg +0 -0
  110. data/templates/project/assets/video_placeholder.jpg +0 -0
  111. data/templates/project/assets/vitamin.svg +25 -0
  112. data/templates/project/component.json +9 -0
  113. data/templates/project/libs/bootstrap-modal.js +374 -0
  114. data/templates/project/libs/bootstrap/README.md +106 -0
  115. data/templates/project/libs/bootstrap/application.js +156 -0
  116. data/templates/project/libs/bootstrap/bootstrap-affix.js +117 -0
  117. data/templates/project/libs/bootstrap/bootstrap-alert.js +99 -0
  118. data/templates/project/libs/bootstrap/bootstrap-button.js +105 -0
  119. data/templates/project/libs/bootstrap/bootstrap-carousel.js +207 -0
  120. data/templates/project/libs/bootstrap/bootstrap-collapse.js +167 -0
  121. data/templates/project/libs/bootstrap/bootstrap-dropdown.js +165 -0
  122. data/templates/project/libs/bootstrap/bootstrap-modal.js +251 -0
  123. data/templates/project/libs/bootstrap/bootstrap-popover.js +114 -0
  124. data/templates/project/libs/bootstrap/bootstrap-scrollspy.js +162 -0
  125. data/templates/project/libs/bootstrap/bootstrap-tab.js +144 -0
  126. data/templates/project/libs/bootstrap/bootstrap-tooltip.js +361 -0
  127. data/templates/project/libs/bootstrap/bootstrap-transition.js +60 -0
  128. data/templates/project/libs/bootstrap/bootstrap-typeahead.js +335 -0
  129. data/templates/project/libs/bootstrap/bootstrap.js +2280 -0
  130. data/templates/project/libs/bootstrap/bootstrap.min.js +6 -0
  131. data/templates/project/libs/bootstrap/holder/holder.js +401 -0
  132. data/templates/project/libs/bootstrap/html5shiv.js +8 -0
  133. data/templates/project/libs/bootstrap/jquery.js +5 -0
  134. data/templates/project/libs/bootstrap/respond/respond.min.js +6 -0
  135. data/templates/project/libs/equalheights.js +46 -0
  136. data/templates/project/libs/foundation/foundation.alerts.js +50 -0
  137. data/templates/project/libs/foundation/foundation.clearing.js +516 -0
  138. data/templates/project/libs/foundation/foundation.cookie.js +74 -0
  139. data/templates/project/libs/foundation/foundation.dropdown.js +175 -0
  140. data/templates/project/libs/foundation/foundation.forms.js +513 -0
  141. data/templates/project/libs/foundation/foundation.joyride.js +831 -0
  142. data/templates/project/libs/foundation/foundation.js +401 -0
  143. data/templates/project/libs/foundation/foundation.magellan.js +130 -0
  144. data/templates/project/libs/foundation/foundation.orbit.js +373 -0
  145. data/templates/project/libs/foundation/foundation.placeholder.js +159 -0
  146. data/templates/project/libs/foundation/foundation.reveal.js +277 -0
  147. data/templates/project/libs/foundation/foundation.section.js +407 -0
  148. data/templates/project/libs/foundation/foundation.tooltips.js +200 -0
  149. data/templates/project/libs/foundation/foundation.topbar.js +245 -0
  150. data/templates/project/libs/hello.coffee +1 -0
  151. data/templates/project/libs/helper.js +385 -0
  152. data/templates/project/libs/jquery.magnific-popup.js +1783 -0
  153. data/templates/project/libs/jquery.magnific-popup.min.js +4 -0
  154. data/templates/project/libs/jquery.mixitup.min.js +43 -0
  155. data/templates/project/libs/main.js +1 -0
  156. data/templates/project/libs/ns.js +128 -0
  157. data/templates/project/libs/select2-3.4.0/README.md +83 -0
  158. data/templates/project/libs/select2-3.4.0/component.json +8 -0
  159. data/templates/project/libs/select2-3.4.0/release.sh +69 -0
  160. data/templates/project/libs/select2-3.4.0/select2-spinner.gif +0 -0
  161. data/templates/project/libs/select2-3.4.0/select2.css +652 -0
  162. data/templates/project/libs/select2-3.4.0/select2.jquery.json +36 -0
  163. data/templates/project/libs/select2-3.4.0/select2.js +3054 -0
  164. data/templates/project/libs/select2-3.4.0/select2.min.js +22 -0
  165. data/templates/project/libs/select2-3.4.0/select2.png +0 -0
  166. data/templates/project/libs/select2-3.4.0/select2_locale_ca.js +17 -0
  167. data/templates/project/libs/select2-3.4.0/select2_locale_cs.js +49 -0
  168. data/templates/project/libs/select2-3.4.0/select2_locale_da.js +17 -0
  169. data/templates/project/libs/select2-3.4.0/select2_locale_de.js +15 -0
  170. data/templates/project/libs/select2-3.4.0/select2_locale_en.js.template +17 -0
  171. data/templates/project/libs/select2-3.4.0/select2_locale_es.js +15 -0
  172. data/templates/project/libs/select2-3.4.0/select2_locale_et.js +17 -0
  173. data/templates/project/libs/select2-3.4.0/select2_locale_eu.js +43 -0
  174. data/templates/project/libs/select2-3.4.0/select2_locale_fr.js +15 -0
  175. data/templates/project/libs/select2-3.4.0/select2_locale_gl.js +43 -0
  176. data/templates/project/libs/select2-3.4.0/select2_locale_he.js +17 -0
  177. data/templates/project/libs/select2-3.4.0/select2_locale_hr.js +42 -0
  178. data/templates/project/libs/select2-3.4.0/select2_locale_hu.js +15 -0
  179. data/templates/project/libs/select2-3.4.0/select2_locale_is.js +16 -0
  180. data/templates/project/libs/select2-3.4.0/select2_locale_it.js +15 -0
  181. data/templates/project/libs/select2-3.4.0/select2_locale_ja.js +15 -0
  182. data/templates/project/libs/select2-3.4.0/select2_locale_lt.js +29 -0
  183. data/templates/project/libs/select2-3.4.0/select2_locale_lv.js +16 -0
  184. data/templates/project/libs/select2-3.4.0/select2_locale_mk.js +17 -0
  185. data/templates/project/libs/select2-3.4.0/select2_locale_nl.js +15 -0
  186. data/templates/project/libs/select2-3.4.0/select2_locale_no.js +18 -0
  187. data/templates/project/libs/select2-3.4.0/select2_locale_pl.js +37 -0
  188. data/templates/project/libs/select2-3.4.0/select2_locale_pt-BR.js +15 -0
  189. data/templates/project/libs/select2-3.4.0/select2_locale_pt-PT.js +15 -0
  190. data/templates/project/libs/select2-3.4.0/select2_locale_ro.js +15 -0
  191. data/templates/project/libs/select2-3.4.0/select2_locale_ru.js +15 -0
  192. data/templates/project/libs/select2-3.4.0/select2_locale_sk.js +48 -0
  193. data/templates/project/libs/select2-3.4.0/select2_locale_sv.js +17 -0
  194. data/templates/project/libs/select2-3.4.0/select2_locale_tr.js +17 -0
  195. data/templates/project/libs/select2-3.4.0/select2_locale_ua.js +17 -0
  196. data/templates/project/libs/select2-3.4.0/select2_locale_vi.js +18 -0
  197. data/templates/project/libs/select2-3.4.0/select2_locale_zh-CN.js +14 -0
  198. data/templates/project/libs/select2-3.4.0/select2_locale_zh-TW.js +14 -0
  199. data/templates/project/libs/select2-3.4.0/select2x2.png +0 -0
  200. data/templates/project/libs/vendor/modernizr-2.6.2.min.js +4 -0
  201. data/templates/project/libs/vendor/zepto.js +1884 -0
  202. data/templates/project/libs/vendor/zepto.min.js +2 -0
  203. data/templates/project/manifest.rb +9 -0
  204. data/templates/project/style.scss.erb +2 -0
  205. metadata +288 -0
@@ -0,0 +1,1783 @@
1
+ /*! Magnific Popup - v0.8.9 - 2013-06-04
2
+ * http://dimsemenov.com/plugins/magnific-popup/
3
+ * Copyright (c) 2013 Dmitry Semenov; */
4
+ ;(function($) {
5
+
6
+ /*>>core*/
7
+ /**
8
+ *
9
+ * Magnific Popup Core JS file
10
+ *
11
+ */
12
+
13
+
14
+ /**
15
+ * Private static constants
16
+ */
17
+ var CLOSE_EVENT = 'Close',
18
+ AFTER_CLOSE_EVENT = 'AfterClose',
19
+ BEFORE_APPEND_EVENT = 'BeforeAppend',
20
+ MARKUP_PARSE_EVENT = 'MarkupParse',
21
+ OPEN_EVENT = 'Open',
22
+ CHANGE_EVENT = 'Change',
23
+ NS = 'mfp',
24
+ EVENT_NS = '.' + NS,
25
+ READY_CLASS = 'mfp-ready',
26
+ REMOVING_CLASS = 'mfp-removing',
27
+ PREVENT_CLOSE_CLASS = 'mfp-prevent-close';
28
+
29
+
30
+ /**
31
+ * Private vars
32
+ */
33
+ var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this'
34
+ MagnificPopup = function(){},
35
+ _isJQ = !!(window.jQuery),
36
+ _prevStatus,
37
+ _window = $(window),
38
+ _body,
39
+ _document,
40
+ _prevContentType,
41
+ _wrapClasses,
42
+ _currPopupType;
43
+
44
+
45
+ /**
46
+ * Private functions
47
+ */
48
+ var _mfpOn = function(name, f) {
49
+ mfp.ev.on(NS + name + EVENT_NS, f);
50
+ },
51
+ _getEl = function(className, appendTo, html, raw) {
52
+ var el = document.createElement('div');
53
+ el.className = 'mfp-'+className;
54
+ if(html) {
55
+ el.innerHTML = html;
56
+ }
57
+ if(!raw) {
58
+ el = $(el);
59
+ if(appendTo) {
60
+ el.appendTo(appendTo);
61
+ }
62
+ } else if(appendTo) {
63
+ appendTo.appendChild(el);
64
+ }
65
+ return el;
66
+ },
67
+ _mfpTrigger = function(e, data) {
68
+ mfp.ev.triggerHandler(NS + e, data);
69
+
70
+ if(mfp.st.callbacks) {
71
+ // converts "mfpEventName" to "eventName" callback and triggers it if it's present
72
+ e = e.charAt(0).toLowerCase() + e.slice(1);
73
+ if(mfp.st.callbacks[e]) {
74
+ mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]);
75
+ }
76
+ }
77
+ },
78
+ _setFocus = function() {
79
+ (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
80
+ },
81
+ _getCloseBtn = function(type) {
82
+ if(type !== _currPopupType || !mfp.currTemplate.closeBtn) {
83
+ mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) );
84
+ _currPopupType = type;
85
+ }
86
+ return mfp.currTemplate.closeBtn;
87
+ },
88
+ // Initialize Magnific Popup only when called at least once
89
+ _checkInstance = function() {
90
+ if(!$.magnificPopup.instance) {
91
+ mfp = new MagnificPopup();
92
+ mfp.init();
93
+ $.magnificPopup.instance = mfp;
94
+ }
95
+ },
96
+ // Check to close popup or not
97
+ // "target" is an element that was clicked
98
+ _checkIfClose = function(target) {
99
+
100
+ if($(target).hasClass(PREVENT_CLOSE_CLASS)) {
101
+ return;
102
+ }
103
+
104
+ var closeOnContent = mfp.st.closeOnContentClick;
105
+ var closeOnBg = mfp.st.closeOnBgClick;
106
+
107
+ if(closeOnContent && closeOnBg) {
108
+ return true;
109
+ } else {
110
+
111
+ // We close the popup if click is on close button or on preloader. Or if there is no content.
112
+ if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) {
113
+ return true;
114
+ }
115
+
116
+ // if click is outside the content
117
+ if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) {
118
+ if(closeOnBg) {
119
+ return true;
120
+ }
121
+ } else if(closeOnContent) {
122
+ return true;
123
+ }
124
+
125
+ }
126
+ return false;
127
+ };
128
+
129
+
130
+
131
+ /**
132
+ * Public functions
133
+ */
134
+ MagnificPopup.prototype = {
135
+
136
+ constructor: MagnificPopup,
137
+
138
+ /**
139
+ * Initializes Magnific Popup plugin.
140
+ * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed
141
+ */
142
+ init: function() {
143
+ var appVersion = navigator.appVersion;
144
+ mfp.isIE7 = appVersion.indexOf("MSIE 7.") !== -1;
145
+ mfp.isIE8 = appVersion.indexOf("MSIE 8.") !== -1;
146
+ mfp.isLowIE = mfp.isIE7 || mfp.isIE8;
147
+ mfp.isAndroid = (/android/gi).test(appVersion);
148
+ mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion);
149
+ // We disable fixed positioned lightbox on devices that don't handle it nicely.
150
+ // If you know a better way of detecting this - let me know.
151
+ mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) );
152
+ _body = $(document.body);
153
+ _document = $(document);
154
+
155
+ mfp.popupsCache = {};
156
+ },
157
+
158
+ /**
159
+ * Opens popup
160
+ * @param data [description]
161
+ */
162
+ open: function(data) {
163
+
164
+ var i;
165
+
166
+ if(data.isObj === false) {
167
+ // convert jQuery collection to array to avoid conflicts later
168
+ mfp.items = data.items.toArray();
169
+
170
+ mfp.index = 0;
171
+ var items = data.items,
172
+ item;
173
+ for(i = 0; i < items.length; i++) {
174
+ item = items[i];
175
+ if(item.parsed) {
176
+ item = item.el[0];
177
+ }
178
+ if(item === data.el[0]) {
179
+ mfp.index = i;
180
+ break;
181
+ }
182
+ }
183
+ } else {
184
+ mfp.items = $.isArray(data.items) ? data.items : [data.items];
185
+ mfp.index = data.index || 0;
186
+ }
187
+
188
+ // if popup is already opened - we just update the content
189
+ if(mfp.isOpen) {
190
+ mfp.updateItemHTML();
191
+ return;
192
+ }
193
+
194
+ mfp.types = [];
195
+ _wrapClasses = '';
196
+ mfp.ev = data.mainEl || _document;
197
+
198
+ if(data.key) {
199
+ if(!mfp.popupsCache[data.key]) {
200
+ mfp.popupsCache[data.key] = {};
201
+ }
202
+ mfp.currTemplate = mfp.popupsCache[data.key];
203
+ } else {
204
+ mfp.currTemplate = {};
205
+ }
206
+
207
+
208
+
209
+ mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data );
210
+ mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos;
211
+
212
+
213
+
214
+ // Building markup
215
+ // main containers are created only once
216
+ if(!mfp.bgOverlay) {
217
+
218
+ // Dark overlay
219
+ mfp.bgOverlay = _getEl('bg').on('click'+EVENT_NS, function() {
220
+ mfp.close();
221
+ });
222
+
223
+ mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) {
224
+ if(_checkIfClose(e.target)) {
225
+ mfp.close();
226
+ }
227
+ });
228
+
229
+ mfp.container = _getEl('container', mfp.wrap);
230
+ }
231
+
232
+ mfp.contentContainer = _getEl('content');
233
+ if(mfp.st.preloader) {
234
+ mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading);
235
+ }
236
+
237
+
238
+ // Initializing modules
239
+ var modules = $.magnificPopup.modules;
240
+ for(i = 0; i < modules.length; i++) {
241
+ var n = modules[i];
242
+ n = n.charAt(0).toUpperCase() + n.slice(1);
243
+ mfp['init'+n].call(mfp);
244
+ }
245
+ _mfpTrigger('BeforeOpen');
246
+
247
+
248
+ // Close button
249
+ if(!mfp.st.closeBtnInside) {
250
+ mfp.wrap.append( _getCloseBtn() );
251
+ } else {
252
+ _mfpOn(MARKUP_PARSE_EVENT, function(e, template, values, item) {
253
+ values.close_replaceWith = _getCloseBtn(item.type);
254
+ });
255
+ _wrapClasses += ' mfp-close-btn-in';
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
+ // Close on ESC key
286
+ _document.on('keyup' + EVENT_NS, function(e) {
287
+ if(e.keyCode === 27) {
288
+ mfp.close();
289
+ }
290
+ });
291
+
292
+ _window.on('resize' + EVENT_NS, function() {
293
+ mfp.updateSize();
294
+ });
295
+
296
+
297
+ if(!mfp.st.closeOnContentClick) {
298
+ _wrapClasses += ' mfp-auto-cursor';
299
+ }
300
+
301
+ if(_wrapClasses)
302
+ mfp.wrap.addClass(_wrapClasses);
303
+
304
+
305
+ // this triggers recalculation of layout, so we get it once to not to trigger twice
306
+ var windowHeight = mfp.wH = _window.height();
307
+
308
+
309
+ var bodyStyles = {};
310
+
311
+ if( mfp.fixedContentPos ) {
312
+ if(mfp._hasScrollBar(windowHeight)){
313
+ var s = mfp._getScrollbarSize();
314
+ if(s) {
315
+ bodyStyles.paddingRight = s;
316
+ }
317
+ }
318
+ }
319
+
320
+ if(mfp.fixedContentPos) {
321
+ if(!mfp.isIE7) {
322
+ bodyStyles.overflow = 'hidden';
323
+ } else {
324
+ // ie7 double-scroll bug
325
+ $('body, html').css('overflow', 'hidden');
326
+ }
327
+ }
328
+
329
+
330
+
331
+ var classesToadd = mfp.st.mainClass;
332
+ if(mfp.isIE7) {
333
+ classesToadd += ' mfp-ie7';
334
+ }
335
+ if(classesToadd) {
336
+ mfp._addClassToMFP( classesToadd );
337
+ }
338
+
339
+ // add content
340
+ mfp.updateItemHTML();
341
+
342
+ _mfpTrigger('BuildControls');
343
+
344
+
345
+ // remove scrollbar, add padding e.t.c
346
+ _body.css(bodyStyles);
347
+
348
+ // add everything to DOM
349
+ mfp.bgOverlay.add(mfp.wrap).prependTo( document.body );
350
+
351
+
352
+
353
+ // Save last focused element
354
+ mfp._lastFocusedEl = document.activeElement;
355
+
356
+ // Wait for next cycle to allow CSS transition
357
+ setTimeout(function() {
358
+
359
+ if(mfp.content) {
360
+ mfp._addClassToMFP(READY_CLASS);
361
+ _setFocus();
362
+ } else {
363
+ // if content is not defined (not loaded e.t.c) we add class only for BG
364
+ mfp.bgOverlay.addClass(READY_CLASS);
365
+ }
366
+
367
+ // Trap the focus in popup
368
+ _document.on('focusin' + EVENT_NS, function (e) {
369
+ if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) {
370
+ _setFocus();
371
+ return false;
372
+ }
373
+ });
374
+
375
+ }, 16);
376
+
377
+ mfp.isOpen = true;
378
+ mfp.updateSize(windowHeight);
379
+ _mfpTrigger(OPEN_EVENT);
380
+ },
381
+
382
+ /**
383
+ * Closes the popup
384
+ */
385
+ close: function() {
386
+ if(!mfp.isOpen) return;
387
+
388
+ mfp.isOpen = false;
389
+ // for CSS3 animation
390
+ if(mfp.st.removalDelay && !mfp.isLowIE) {
391
+ mfp._addClassToMFP(REMOVING_CLASS);
392
+ setTimeout(function() {
393
+ mfp._close();
394
+ }, mfp.st.removalDelay);
395
+ } else {
396
+ mfp._close();
397
+ }
398
+ },
399
+
400
+ /**
401
+ * Helper for close() function
402
+ */
403
+ _close: function() {
404
+ _mfpTrigger(CLOSE_EVENT);
405
+
406
+ var classesToRemove = REMOVING_CLASS + ' ' + READY_CLASS + ' ';
407
+
408
+ mfp.bgOverlay.detach();
409
+ mfp.wrap.detach();
410
+ mfp.container.empty();
411
+
412
+ if(mfp.st.mainClass) {
413
+ classesToRemove += mfp.st.mainClass + ' ';
414
+ }
415
+
416
+ mfp._removeClassFromMFP(classesToRemove);
417
+
418
+ if(mfp.fixedContentPos) {
419
+ var bodyStyles = {paddingRight: ''};
420
+ if(mfp.isIE7) {
421
+ $('body, html').css('overflow', '');
422
+ } else {
423
+ bodyStyles.overflow = '';
424
+ }
425
+ _body.css(bodyStyles);
426
+ }
427
+
428
+ _document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS);
429
+ mfp.ev.off(EVENT_NS);
430
+
431
+ // clean up DOM elements that aren't removed
432
+ mfp.wrap.attr('class', 'mfp-wrap').removeAttr('style');
433
+ mfp.bgOverlay.attr('class', 'mfp-bg');
434
+ mfp.container.attr('class', 'mfp-container');
435
+
436
+ // remove close button from target element
437
+ if(!mfp.st.closeBtnInside || mfp.currTemplate[mfp.currItem.type] === true ) {
438
+ if(mfp.currTemplate.closeBtn)
439
+ mfp.currTemplate.closeBtn.detach();
440
+ }
441
+
442
+
443
+ if(mfp._lastFocusedEl) {
444
+ $(mfp._lastFocusedEl).focus(); // put tab focus back
445
+ }
446
+ mfp.currItem = null;
447
+ mfp.content = null;
448
+ mfp.currTemplate = null;
449
+ mfp.prevHeight = 0;
450
+
451
+ _mfpTrigger(AFTER_CLOSE_EVENT);
452
+ },
453
+
454
+ updateSize: function(winHeight) {
455
+
456
+ if(mfp.isIOS) {
457
+ // fixes iOS nav bars https://github.com/dimsemenov/Magnific-Popup/issues/2
458
+ var zoomLevel = document.documentElement.clientWidth / window.innerWidth;
459
+ var height = window.innerHeight * zoomLevel;
460
+ mfp.wrap.css('height', height);
461
+ mfp.wH = height;
462
+ } else {
463
+ mfp.wH = winHeight || _window.height();
464
+ }
465
+ // Fixes #84: popup incorrectly positioned with position:relative on body
466
+ if(!mfp.fixedContentPos) {
467
+ mfp.wrap.css('height', mfp.wH);
468
+ }
469
+
470
+ _mfpTrigger('Resize');
471
+
472
+ },
473
+
474
+ /**
475
+ * Set content of popup based on current index
476
+ */
477
+ updateItemHTML: function() {
478
+ var item = mfp.items[mfp.index];
479
+
480
+ // Detach and perform modifications
481
+ mfp.contentContainer.detach();
482
+
483
+ if(mfp.content)
484
+ mfp.content.detach();
485
+
486
+ if(!item.parsed) {
487
+ item = mfp.parseEl( mfp.index );
488
+ }
489
+
490
+ var type = item.type;
491
+
492
+ _mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : '', type]);
493
+ // BeforeChange event works like so:
494
+ // _mfpOn('BeforeChange', function(e, prevType, newType) { });
495
+
496
+ mfp.currItem = item;
497
+
498
+
499
+
500
+
501
+
502
+ if(!mfp.currTemplate[type]) {
503
+ var markup = mfp.st[type] ? mfp.st[type].markup : false;
504
+
505
+ // allows to modify markup
506
+ _mfpTrigger('FirstMarkupParse', markup);
507
+
508
+ if(markup) {
509
+ mfp.currTemplate[type] = $(markup);
510
+ } else {
511
+ // if there is no markup found we just define that template is parsed
512
+ mfp.currTemplate[type] = true;
513
+ }
514
+ }
515
+
516
+ if(_prevContentType && _prevContentType !== item.type) {
517
+ mfp.container.removeClass('mfp-'+_prevContentType+'-holder');
518
+ }
519
+
520
+ var newContent = mfp['get' + type.charAt(0).toUpperCase() + type.slice(1)](item, mfp.currTemplate[type]);
521
+ mfp.appendContent(newContent, type);
522
+
523
+ item.preloaded = true;
524
+
525
+ _mfpTrigger(CHANGE_EVENT, item);
526
+ _prevContentType = item.type;
527
+
528
+ // Append container back after its content changed
529
+ mfp.container.prepend(mfp.contentContainer);
530
+
531
+ _mfpTrigger('AfterChange');
532
+ },
533
+
534
+
535
+ /**
536
+ * Set HTML content of popup
537
+ */
538
+ appendContent: function(newContent, type) {
539
+ mfp.content = newContent;
540
+
541
+ if(newContent) {
542
+ if(mfp.st.closeBtnInside && mfp.currTemplate[type] === true) {
543
+ // if there is no markup, we just append close button element inside
544
+ if(!mfp.content.find('.mfp-close').length) {
545
+ mfp.content.append(_getCloseBtn());
546
+ }
547
+ } else {
548
+ mfp.content = newContent;
549
+ }
550
+ } else {
551
+ mfp.content = '';
552
+ }
553
+
554
+ _mfpTrigger(BEFORE_APPEND_EVENT);
555
+ mfp.container.addClass('mfp-'+type+'-holder');
556
+
557
+ mfp.contentContainer.append(mfp.content);
558
+ },
559
+
560
+
561
+
562
+
563
+ /**
564
+ * Creates Magnific Popup data object based on given data
565
+ * @param {int} index Index of item to parse
566
+ */
567
+ parseEl: function(index) {
568
+ var item = mfp.items[index],
569
+ type = item.type;
570
+
571
+ if(item.tagName) {
572
+ item = { el: $(item) };
573
+ } else {
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
+ if( midClick || e.which !== 2 ) {
636
+ var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
637
+
638
+ if(disableOn) {
639
+ if($.isFunction(disableOn)) {
640
+ if( !disableOn.call(mfp) ) {
641
+ return true;
642
+ }
643
+ } else { // else it's number
644
+ if( _window.width() < disableOn ) {
645
+ return true;
646
+ }
647
+ }
648
+ }
649
+
650
+ if(e.type) {
651
+ e.preventDefault();
652
+
653
+ // This will prevent popup from closing if element is inside and popup is already opened
654
+ if(mfp.isOpen) {
655
+ e.stopPropagation();
656
+ }
657
+ }
658
+
659
+
660
+ options.el = $(e.mfpEl);
661
+ if(options.delegate) {
662
+ options.items = el.find(options.delegate);
663
+ }
664
+ mfp.open(options);
665
+ }
666
+ },
667
+
668
+
669
+ /**
670
+ * Updates text on preloader
671
+ */
672
+ updateStatus: function(status, text) {
673
+
674
+ if(mfp.preloader) {
675
+ if(_prevStatus !== status) {
676
+ mfp.container.removeClass('mfp-s-'+_prevStatus);
677
+ }
678
+
679
+ if(!text && status === 'loading') {
680
+ text = mfp.st.tLoading;
681
+ }
682
+
683
+ var data = {
684
+ status: status,
685
+ text: text
686
+ };
687
+ // allows to modify status
688
+ _mfpTrigger('UpdateStatus', data);
689
+
690
+ status = data.status;
691
+ text = data.text;
692
+
693
+ mfp.preloader.html(text);
694
+
695
+ mfp.preloader.find('a').click(function(e) {
696
+ e.stopImmediatePropagation();
697
+ });
698
+
699
+ mfp.container.addClass('mfp-s-'+status);
700
+ _prevStatus = status;
701
+ }
702
+ },
703
+
704
+
705
+ /*
706
+ "Private" helpers that aren't private at all
707
+ */
708
+ _addClassToMFP: function(cName) {
709
+ mfp.bgOverlay.addClass(cName);
710
+ mfp.wrap.addClass(cName);
711
+ },
712
+ _removeClassFromMFP: function(cName) {
713
+ this.bgOverlay.removeClass(cName);
714
+ mfp.wrap.removeClass(cName);
715
+ },
716
+ _hasScrollBar: function(winHeight) {
717
+ return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) )
718
+ },
719
+ _parseMarkup: function(template, values, item) {
720
+ var arr;
721
+ if(item.data) {
722
+ values = $.extend(item.data, values);
723
+ }
724
+ _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] );
725
+
726
+ $.each(values, function(key, value) {
727
+ if(value === undefined || value === false) {
728
+ return true;
729
+ }
730
+ arr = key.split('_');
731
+ if(arr.length > 1) {
732
+ var el = template.find(EVENT_NS + '-'+arr[0]);
733
+
734
+ if(el.length > 0) {
735
+ var attr = arr[1];
736
+ if(attr === 'replaceWith') {
737
+ if(el[0] !== value[0]) {
738
+ el.replaceWith(value);
739
+ }
740
+ } else if(attr === 'img') {
741
+ if(el.is('img')) {
742
+ el.attr('src', value);
743
+ } else {
744
+ el.replaceWith( '<img src="'+value+'" class="' + el.attr('class') + '" />' );
745
+ }
746
+ } else {
747
+ el.attr(arr[1], value);
748
+ }
749
+ }
750
+
751
+ } else {
752
+ template.find(EVENT_NS + '-'+key).html(value);
753
+ }
754
+ });
755
+ },
756
+
757
+ _getScrollbarSize: function() {
758
+ // thx David
759
+ if(mfp.scrollbarSize === undefined) {
760
+ var scrollDiv = document.createElement("div");
761
+ scrollDiv.id = "mfp-sbm";
762
+ scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;';
763
+ document.body.appendChild(scrollDiv);
764
+ mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth;
765
+ document.body.removeChild(scrollDiv);
766
+ }
767
+ return mfp.scrollbarSize;
768
+ }
769
+
770
+ }; /* MagnificPopup core prototype end */
771
+
772
+
773
+
774
+
775
+ /**
776
+ * Public static functions
777
+ */
778
+ $.magnificPopup = {
779
+ instance: null,
780
+ proto: MagnificPopup.prototype,
781
+ modules: [],
782
+
783
+ open: function(options, index) {
784
+ _checkInstance();
785
+
786
+ if(!options)
787
+ options = {};
788
+
789
+ options.isObj = true;
790
+ options.index = index || 0;
791
+ return this.instance.open(options);
792
+ },
793
+
794
+ close: function() {
795
+ return $.magnificPopup.instance.close();
796
+ },
797
+
798
+ registerModule: function(name, module) {
799
+ if(module.options) {
800
+ $.magnificPopup.defaults[name] = module.options;
801
+ }
802
+ $.extend(this.proto, module.proto);
803
+ this.modules.push(name);
804
+ },
805
+
806
+ defaults: {
807
+
808
+ // Info about options is in docs:
809
+ // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
810
+
811
+ disableOn: 0,
812
+
813
+ key: null,
814
+
815
+ midClick: false,
816
+
817
+ mainClass: '',
818
+
819
+ preloader: true,
820
+
821
+ focus: '', // CSS selector of input to focus after popup is opened
822
+
823
+ closeOnContentClick: false,
824
+
825
+ closeOnBgClick: true,
826
+
827
+ closeBtnInside: true,
828
+
829
+ alignTop: false,
830
+
831
+ removalDelay: 0,
832
+
833
+ fixedContentPos: 'auto',
834
+
835
+ fixedBgPos: 'auto',
836
+
837
+ overflowY: 'auto',
838
+
839
+ closeMarkup: '<button title="%title%" type="button" class="mfp-close">&times;</button>',
840
+
841
+ tClose: 'Close (Esc)',
842
+
843
+ tLoading: 'Loading...'
844
+
845
+ }
846
+ };
847
+
848
+
849
+
850
+ $.fn.magnificPopup = function(options) {
851
+ _checkInstance();
852
+
853
+ var jqEl = $(this);
854
+
855
+ // We call some API method of first param is a string
856
+ if (typeof options === "string" ) {
857
+
858
+ if(options === 'open') {
859
+ var items,
860
+ itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
861
+ index = parseInt(arguments[1], 10) || 0;
862
+
863
+ if(itemOpts.items) {
864
+ items = itemOpts.items[index];
865
+ } else {
866
+ items = jqEl;
867
+ if(itemOpts.delegate) {
868
+ items = items.find(itemOpts.delegate);
869
+ }
870
+ items = items.eq( index );
871
+ }
872
+ mfp._openClick({mfpEl:items}, jqEl, itemOpts);
873
+ } else {
874
+ if(mfp.isOpen)
875
+ mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
876
+ }
877
+
878
+ } else {
879
+
880
+ /*
881
+ * As Zepto doesn't support .data() method for objects
882
+ * and it works only in normal browsers
883
+ * we assign "options" object directly to the DOM element. FTW!
884
+ */
885
+ if(_isJQ) {
886
+ jqEl.data('magnificPopup', options);
887
+ } else {
888
+ jqEl[0].magnificPopup = options;
889
+ }
890
+
891
+ mfp.addGroup(jqEl, options);
892
+
893
+ }
894
+ return jqEl;
895
+ };
896
+
897
+
898
+ //Quick benchmark
899
+ /*
900
+ var start = performance.now(),
901
+ i,
902
+ rounds = 1000;
903
+
904
+ for(i = 0; i < rounds; i++) {
905
+
906
+ }
907
+ console.log('Test #1:', performance.now() - start);
908
+
909
+ start = performance.now();
910
+ for(i = 0; i < rounds; i++) {
911
+
912
+ }
913
+ console.log('Test #2:', performance.now() - start);
914
+ */
915
+
916
+
917
+ /*>>core*/
918
+
919
+ /*>>inline*/
920
+
921
+ var INLINE_NS = 'inline',
922
+ _hiddenClass,
923
+ _inlinePlaceholder,
924
+ _lastInlineElement,
925
+ _putInlineElementsBack = function() {
926
+ if(_lastInlineElement) {
927
+ _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
928
+ _lastInlineElement = null;
929
+ }
930
+ };
931
+
932
+ $.magnificPopup.registerModule(INLINE_NS, {
933
+ options: {
934
+ hiddenClass: 'hide', // will be appended with `mfp-` prefix
935
+ markup: '',
936
+ tNotFound: 'Content not found'
937
+ },
938
+ proto: {
939
+
940
+ initInline: function() {
941
+ mfp.types.push(INLINE_NS);
942
+
943
+ _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
944
+ _putInlineElementsBack();
945
+ });
946
+ },
947
+
948
+ getInline: function(item, template) {
949
+
950
+ _putInlineElementsBack();
951
+
952
+ if(item.src) {
953
+ var inlineSt = mfp.st.inline,
954
+ el = $(item.src);
955
+
956
+ if(el.length) {
957
+
958
+ // If target element has parent - we replace it with placeholder and put it back after popup is closed
959
+ var parent = el[0].parentNode;
960
+ if(parent && parent.tagName) {
961
+ if(!_inlinePlaceholder) {
962
+ _hiddenClass = inlineSt.hiddenClass;
963
+ _inlinePlaceholder = _getEl(_hiddenClass);
964
+ _hiddenClass = 'mfp-'+_hiddenClass;
965
+ }
966
+ // replace target inline element with placeholder
967
+ _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
968
+ }
969
+
970
+ mfp.updateStatus('ready');
971
+ } else {
972
+ mfp.updateStatus('error', inlineSt.tNotFound);
973
+ el = $('<div>');
974
+ }
975
+
976
+ item.inlineElement = el;
977
+ return el;
978
+ }
979
+
980
+ mfp.updateStatus('ready');
981
+ mfp._parseMarkup(template, {}, item);
982
+ return template;
983
+ }
984
+ }
985
+ });
986
+
987
+ /*>>inline*/
988
+
989
+ /*>>ajax*/
990
+ var AJAX_NS = 'ajax',
991
+ _ajaxCur,
992
+ _removeAjaxCursor = function() {
993
+ if(_ajaxCur) {
994
+ _body.removeClass(_ajaxCur);
995
+ }
996
+ };
997
+
998
+ $.magnificPopup.registerModule(AJAX_NS, {
999
+
1000
+ options: {
1001
+ settings: null,
1002
+ cursor: 'mfp-ajax-cur',
1003
+ tError: '<a href="%url%">The content</a> could not be loaded.'
1004
+ },
1005
+
1006
+ proto: {
1007
+ initAjax: function() {
1008
+ mfp.types.push(AJAX_NS);
1009
+ _ajaxCur = mfp.st.ajax.cursor;
1010
+
1011
+ _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, function() {
1012
+ _removeAjaxCursor();
1013
+ if(mfp.req) {
1014
+ mfp.req.abort();
1015
+ }
1016
+ });
1017
+ },
1018
+
1019
+ getAjax: function(item) {
1020
+
1021
+ if(_ajaxCur)
1022
+ _body.addClass(_ajaxCur);
1023
+
1024
+ mfp.updateStatus('loading');
1025
+
1026
+ var opts = $.extend({
1027
+ url: item.src,
1028
+ success: function(data, textStatus, jqXHR) {
1029
+ var temp = {
1030
+ data:data,
1031
+ xhr:jqXHR
1032
+ };
1033
+
1034
+ _mfpTrigger('ParseAjax', temp);
1035
+
1036
+ mfp.appendContent( $(temp.data), AJAX_NS );
1037
+
1038
+ item.finished = true;
1039
+
1040
+ _removeAjaxCursor();
1041
+
1042
+ _setFocus();
1043
+
1044
+ setTimeout(function() {
1045
+ mfp.wrap.addClass(READY_CLASS);
1046
+ }, 16);
1047
+
1048
+ mfp.updateStatus('ready');
1049
+
1050
+ _mfpTrigger('AjaxContentAdded');
1051
+ },
1052
+ error: function() {
1053
+ _removeAjaxCursor();
1054
+ item.finished = item.loadError = true;
1055
+ mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src));
1056
+ }
1057
+ }, mfp.st.ajax.settings);
1058
+
1059
+ mfp.req = $.ajax(opts);
1060
+
1061
+ return '';
1062
+ }
1063
+ }
1064
+ });
1065
+
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+ /*>>ajax*/
1073
+
1074
+ /*>>image*/
1075
+ var _imgInterval,
1076
+ _getTitle = function(item) {
1077
+ if(item.data && item.data.title !== undefined)
1078
+ return item.data.title;
1079
+
1080
+ var src = mfp.st.image.titleSrc;
1081
+
1082
+ if(src) {
1083
+ if($.isFunction(src)) {
1084
+ return src.call(mfp, item);
1085
+ } else if(item.el) {
1086
+ return item.el.attr(src) || '';
1087
+ }
1088
+ }
1089
+ return '';
1090
+ };
1091
+
1092
+ $.magnificPopup.registerModule('image', {
1093
+
1094
+ options: {
1095
+ markup: '<div class="mfp-figure">'+
1096
+ '<div class="mfp-close"></div>'+
1097
+ '<div class="mfp-img"></div>'+
1098
+ '<div class="mfp-bottom-bar">'+
1099
+ '<div class="mfp-title"></div>'+
1100
+ '<div class="mfp-counter"></div>'+
1101
+ '</div>'+
1102
+ '</div>',
1103
+ cursor: 'mfp-zoom-out-cur',
1104
+ titleSrc: 'title',
1105
+ verticalFit: true,
1106
+ tError: '<a href="%url%">The image</a> could not be loaded.'
1107
+ },
1108
+
1109
+ proto: {
1110
+ initImage: function() {
1111
+ var imgSt = mfp.st.image,
1112
+ ns = '.image';
1113
+
1114
+ mfp.types.push('image');
1115
+
1116
+ _mfpOn(OPEN_EVENT+ns, function() {
1117
+ if(mfp.currItem.type === 'image' && imgSt.cursor) {
1118
+ _body.addClass(imgSt.cursor);
1119
+ }
1120
+ });
1121
+
1122
+ _mfpOn(CLOSE_EVENT+ns, function() {
1123
+ if(imgSt.cursor) {
1124
+ _body.removeClass(imgSt.cursor);
1125
+ }
1126
+ _window.off('resize' + EVENT_NS);
1127
+ });
1128
+
1129
+ _mfpOn('Resize'+ns, mfp.resizeImage);
1130
+ if(mfp.isLowIE) {
1131
+ _mfpOn('AfterChange', mfp.resizeImage);
1132
+ }
1133
+ },
1134
+ resizeImage: function() {
1135
+ var item = mfp.currItem;
1136
+ if(!item.img) return;
1137
+
1138
+ if(mfp.st.image.verticalFit) {
1139
+ var decr = 0;
1140
+ // fix box-sizing in ie7/8
1141
+ if(mfp.isLowIE) {
1142
+ decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10);
1143
+ }
1144
+ item.img.css('max-height', mfp.wH-decr);
1145
+ }
1146
+ },
1147
+ _onImageHasSize: function(item) {
1148
+ if(item.img) {
1149
+
1150
+ item.hasSize = true;
1151
+
1152
+ if(_imgInterval) {
1153
+ clearInterval(_imgInterval);
1154
+ }
1155
+
1156
+ item.isCheckingImgSize = false;
1157
+
1158
+ _mfpTrigger('ImageHasSize', item);
1159
+
1160
+ if(item.imgHidden) {
1161
+ if(mfp.content)
1162
+ mfp.content.removeClass('mfp-loading');
1163
+
1164
+ item.imgHidden = false;
1165
+ }
1166
+
1167
+ }
1168
+ },
1169
+
1170
+ /**
1171
+ * Function that loops until the image has size to display elements that rely on it asap
1172
+ */
1173
+ findImageSize: function(item) {
1174
+
1175
+ var counter = 0,
1176
+ img = item.img[0],
1177
+ mfpSetInterval = function(delay) {
1178
+
1179
+ if(_imgInterval) {
1180
+ clearInterval(_imgInterval);
1181
+ }
1182
+ // decelerating interval that checks for size of an image
1183
+ _imgInterval = setInterval(function() {
1184
+ if(img.naturalWidth > 0) {
1185
+ mfp._onImageHasSize(item);
1186
+ return;
1187
+ }
1188
+
1189
+ if(counter > 200) {
1190
+ clearInterval(_imgInterval);
1191
+ }
1192
+
1193
+ counter++;
1194
+ if(counter === 3) {
1195
+ mfpSetInterval(10);
1196
+ } else if(counter === 40) {
1197
+ mfpSetInterval(50);
1198
+ } else if(counter === 100) {
1199
+ mfpSetInterval(500);
1200
+ }
1201
+ }, delay);
1202
+ };
1203
+
1204
+ mfpSetInterval(1);
1205
+ },
1206
+
1207
+ getImage: function(item, template) {
1208
+
1209
+ var guard = 0,
1210
+
1211
+ // image load complete handler
1212
+ onLoadComplete = function() {
1213
+ if(item) {
1214
+ if (item.img[0].complete) {
1215
+ item.img.off('.mfploader');
1216
+
1217
+ if(item === mfp.currItem){
1218
+ mfp._onImageHasSize(item);
1219
+
1220
+ mfp.updateStatus('ready');
1221
+ }
1222
+
1223
+ item.hasSize = true;
1224
+ item.loaded = true;
1225
+
1226
+ }
1227
+ else {
1228
+ // if image complete check fails 200 times (20 sec), we assume that there was an error.
1229
+ guard++;
1230
+ if(guard < 200) {
1231
+ setTimeout(onLoadComplete,100);
1232
+ } else {
1233
+ onLoadError();
1234
+ }
1235
+ }
1236
+ }
1237
+ },
1238
+
1239
+ // image error handler
1240
+ onLoadError = function() {
1241
+ if(item) {
1242
+ item.img.off('.mfploader');
1243
+ if(item === mfp.currItem){
1244
+ mfp._onImageHasSize(item);
1245
+ mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1246
+ }
1247
+
1248
+ item.hasSize = true;
1249
+ item.loaded = true;
1250
+ item.loadError = true;
1251
+ }
1252
+ },
1253
+ imgSt = mfp.st.image;
1254
+
1255
+
1256
+ var el = template.find('.mfp-img');
1257
+ if(el.length) {
1258
+ var img = new Image();
1259
+ img.className = 'mfp-img';
1260
+ item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError);
1261
+ img.src = item.src;
1262
+
1263
+ // without clone() "error" event is not firing when IMG is replaced by new IMG
1264
+ // TODO: find a way to avoid such cloning
1265
+ if(el.is('img')) {
1266
+ item.img = item.img.clone();
1267
+ }
1268
+ }
1269
+
1270
+ mfp._parseMarkup(template, {
1271
+ title: _getTitle(item),
1272
+ img_replaceWith: item.img
1273
+ }, item);
1274
+
1275
+ mfp.resizeImage();
1276
+
1277
+ if(item.hasSize) {
1278
+ if(_imgInterval) clearInterval(_imgInterval);
1279
+
1280
+ if(item.loadError) {
1281
+ template.addClass('mfp-loading');
1282
+ mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) );
1283
+ } else {
1284
+ template.removeClass('mfp-loading');
1285
+ mfp.updateStatus('ready');
1286
+ }
1287
+ return template;
1288
+ }
1289
+
1290
+ mfp.updateStatus('loading');
1291
+ item.loading = true;
1292
+
1293
+ if(!item.hasSize) {
1294
+ item.imgHidden = true;
1295
+ template.addClass('mfp-loading');
1296
+ mfp.findImageSize(item);
1297
+ }
1298
+
1299
+ return template;
1300
+ }
1301
+ }
1302
+ });
1303
+
1304
+
1305
+
1306
+ /*>>image*/
1307
+
1308
+ /*>>iframe*/
1309
+
1310
+ var IFRAME_NS = 'iframe',
1311
+ _emptyPage = '//about:blank',
1312
+
1313
+ _fixIframeBugs = function(isShowing) {
1314
+ if(mfp.currTemplate[IFRAME_NS]) {
1315
+ var el = mfp.currTemplate[IFRAME_NS].find('iframe');
1316
+ if(el.length) {
1317
+ // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug
1318
+ if(!isShowing) {
1319
+ el[0].src = _emptyPage;
1320
+ }
1321
+
1322
+ // IE8 black screen bug fix
1323
+ if(mfp.isIE8) {
1324
+ el.css('display', isShowing ? 'block' : 'none');
1325
+ }
1326
+ }
1327
+ }
1328
+ };
1329
+
1330
+ $.magnificPopup.registerModule(IFRAME_NS, {
1331
+
1332
+ options: {
1333
+ markup: '<div class="mfp-iframe-scaler">'+
1334
+ '<div class="mfp-close"></div>'+
1335
+ '<iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe>'+
1336
+ '</div>',
1337
+
1338
+ srcAction: 'iframe_src',
1339
+
1340
+ // we don't care and support only one default type of URL by default
1341
+ patterns: {
1342
+ youtube: {
1343
+ index: 'youtube.com',
1344
+ id: 'v=',
1345
+ src: '//www.youtube.com/embed/%id%?autoplay=1'
1346
+ },
1347
+ vimeo: {
1348
+ index: 'vimeo.com/',
1349
+ id: '/',
1350
+ src: '//player.vimeo.com/video/%id%?autoplay=1'
1351
+ },
1352
+ gmaps: {
1353
+ index: '//maps.google.',
1354
+ src: '%id%&output=embed'
1355
+ }
1356
+ }
1357
+ },
1358
+
1359
+ proto: {
1360
+ initIframe: function() {
1361
+ mfp.types.push(IFRAME_NS);
1362
+
1363
+ _mfpOn('BeforeChange', function(e, prevType, newType) {
1364
+ if(prevType !== newType) {
1365
+ if(prevType === IFRAME_NS) {
1366
+ _fixIframeBugs(); // iframe if removed
1367
+ } else if(newType === IFRAME_NS) {
1368
+ _fixIframeBugs(true); // iframe is showing
1369
+ }
1370
+ }// else {
1371
+ // iframe source is switched, don't do anything
1372
+ //}
1373
+ });
1374
+
1375
+ _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() {
1376
+ _fixIframeBugs();
1377
+ });
1378
+ },
1379
+
1380
+ getIframe: function(item, template) {
1381
+ var embedSrc = item.src;
1382
+ var iframeSt = mfp.st.iframe;
1383
+
1384
+ $.each(iframeSt.patterns, function() {
1385
+ if(embedSrc.indexOf( this.index ) > -1) {
1386
+ if(this.id) {
1387
+ if(typeof this.id === 'string') {
1388
+ embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length);
1389
+ } else {
1390
+ embedSrc = this.id.call( this, embedSrc );
1391
+ }
1392
+ }
1393
+ embedSrc = this.src.replace('%id%', embedSrc );
1394
+ return false; // break;
1395
+ }
1396
+ });
1397
+
1398
+ var dataObj = {};
1399
+ if(iframeSt.srcAction) {
1400
+ dataObj[iframeSt.srcAction] = embedSrc;
1401
+ }
1402
+ mfp._parseMarkup(template, dataObj, item);
1403
+
1404
+ mfp.updateStatus('ready');
1405
+
1406
+ return template;
1407
+ }
1408
+ }
1409
+ });
1410
+
1411
+
1412
+
1413
+ /*>>iframe*/
1414
+
1415
+ /*>>gallery*/
1416
+ /**
1417
+ * Get looped index depending on number of slides
1418
+ */
1419
+ var _getLoopedId = function(index) {
1420
+ var numSlides = mfp.items.length;
1421
+ if(index > numSlides - 1) {
1422
+ return index - numSlides;
1423
+ } else if(index < 0) {
1424
+ return numSlides + index;
1425
+ }
1426
+ return index;
1427
+ },
1428
+ _replaceCurrTotal = function(text, curr, total) {
1429
+ return text.replace('%curr%', curr + 1).replace('%total%', total);
1430
+ };
1431
+
1432
+ $.magnificPopup.registerModule('gallery', {
1433
+
1434
+ options: {
1435
+ enabled: false,
1436
+ arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',
1437
+ preload: [0,2],
1438
+ navigateByImgClick: true,
1439
+ arrows: true,
1440
+
1441
+ tPrev: 'Previous (Left arrow key)',
1442
+ tNext: 'Next (Right arrow key)',
1443
+ tCounter: '%curr% of %total%'
1444
+ },
1445
+
1446
+ proto: {
1447
+ initGallery: function() {
1448
+
1449
+ var gSt = mfp.st.gallery,
1450
+ ns = '.mfp-gallery',
1451
+ supportsFastClick = Boolean($.fn.mfpFastClick);
1452
+
1453
+ mfp.direction = true; // true - next, false - prev
1454
+
1455
+ if(!gSt || !gSt.enabled ) return false;
1456
+
1457
+ _wrapClasses += ' mfp-gallery';
1458
+
1459
+ _mfpOn(OPEN_EVENT+ns, function() {
1460
+
1461
+ if(gSt.navigateByImgClick) {
1462
+ mfp.wrap.on('click'+ns, '.mfp-img', function() {
1463
+ if(mfp.items.length > 1) {
1464
+ mfp.next();
1465
+ return false;
1466
+ }
1467
+ });
1468
+ }
1469
+
1470
+ _document.on('keydown'+ns, function(e) {
1471
+ if (e.keyCode === 37) {
1472
+ mfp.prev();
1473
+ } else if (e.keyCode === 39) {
1474
+ mfp.next();
1475
+ }
1476
+ });
1477
+ });
1478
+
1479
+ _mfpOn('UpdateStatus'+ns, function(e, data) {
1480
+ if(data.text) {
1481
+ data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length);
1482
+ }
1483
+ });
1484
+
1485
+ _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) {
1486
+ var l = mfp.items.length;
1487
+ values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : '';
1488
+ });
1489
+
1490
+ _mfpOn('BuildControls' + ns, function() {
1491
+ if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) {
1492
+ var markup = gSt.arrowMarkup,
1493
+ arrowLeft = mfp.arrowLeft = $( markup.replace('%title%', gSt.tPrev).replace('%dir%', 'left') ).addClass(PREVENT_CLOSE_CLASS),
1494
+ arrowRight = mfp.arrowRight = $( markup.replace('%title%', gSt.tNext).replace('%dir%', 'right') ).addClass(PREVENT_CLOSE_CLASS);
1495
+
1496
+ var eName = supportsFastClick ? 'mfpFastClick' : 'click';
1497
+ arrowLeft[eName](function() {
1498
+ mfp.prev();
1499
+ });
1500
+ arrowRight[eName](function() {
1501
+ mfp.next();
1502
+ });
1503
+
1504
+ // Polyfill for :before and :after (adds elements with classes mfp-a and mfp-b)
1505
+ if(mfp.isIE7) {
1506
+ _getEl('b', arrowLeft[0], false, true);
1507
+ _getEl('a', arrowLeft[0], false, true);
1508
+ _getEl('b', arrowRight[0], false, true);
1509
+ _getEl('a', arrowRight[0], false, true);
1510
+ }
1511
+
1512
+ mfp.container.append(arrowLeft.add(arrowRight));
1513
+ }
1514
+ });
1515
+
1516
+ _mfpOn(CHANGE_EVENT+ns, function() {
1517
+ if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout);
1518
+
1519
+ mfp._preloadTimeout = setTimeout(function() {
1520
+ mfp.preloadNearbyImages();
1521
+ mfp._preloadTimeout = null;
1522
+ }, 16);
1523
+ });
1524
+
1525
+
1526
+ _mfpOn(CLOSE_EVENT+ns, function() {
1527
+ _document.off(ns);
1528
+ mfp.wrap.off('click'+ns);
1529
+
1530
+ if(mfp.arrowLeft && supportsFastClick) {
1531
+ mfp.arrowLeft.add(mfp.arrowRight).destroyMfpFastClick();
1532
+ }
1533
+ mfp.arrowRight = mfp.arrowLeft = null;
1534
+ });
1535
+
1536
+ },
1537
+ next: function() {
1538
+ mfp.direction = true;
1539
+ mfp.index = _getLoopedId(mfp.index + 1);
1540
+ mfp.updateItemHTML();
1541
+ },
1542
+ prev: function() {
1543
+ mfp.direction = false;
1544
+ mfp.index = _getLoopedId(mfp.index - 1);
1545
+ mfp.updateItemHTML();
1546
+ },
1547
+ goTo: function(newIndex) {
1548
+ mfp.direction = (newIndex >= mfp.index);
1549
+ mfp.index = newIndex;
1550
+ mfp.updateItemHTML();
1551
+ },
1552
+ preloadNearbyImages: function() {
1553
+ var p = mfp.st.gallery.preload,
1554
+ preloadBefore = Math.min(p[0], mfp.items.length),
1555
+ preloadAfter = Math.min(p[1], mfp.items.length),
1556
+ i;
1557
+
1558
+ for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) {
1559
+ mfp._preloadItem(mfp.index+i);
1560
+ }
1561
+ for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) {
1562
+ mfp._preloadItem(mfp.index-i);
1563
+ }
1564
+ },
1565
+ _preloadItem: function(index) {
1566
+ index = _getLoopedId(index);
1567
+
1568
+ if(mfp.items[index].preloaded) {
1569
+ return;
1570
+ }
1571
+
1572
+ var item = mfp.items[index];
1573
+ if(!item.parsed) {
1574
+ item = mfp.parseEl( index );
1575
+ }
1576
+
1577
+ _mfpTrigger('LazyLoad', item);
1578
+
1579
+ if(item.type === 'image') {
1580
+ item.img = $('<img class="mfp-img" />').on('load.mfploader', function() {
1581
+ item.hasSize = true;
1582
+ }).on('error.mfploader', function() {
1583
+ item.hasSize = true;
1584
+ item.loadError = true;
1585
+ }).attr('src', item.src);
1586
+ }
1587
+
1588
+
1589
+ item.preloaded = true;
1590
+ }
1591
+ }
1592
+ });
1593
+
1594
+ /*
1595
+ Touch Support that might be implemented some day
1596
+
1597
+ addSwipeGesture: function() {
1598
+ var startX,
1599
+ moved,
1600
+ multipleTouches;
1601
+
1602
+ return;
1603
+
1604
+ var namespace = '.mfp',
1605
+ addEventNames = function(pref, down, move, up, cancel) {
1606
+ mfp._tStart = pref + down + namespace;
1607
+ mfp._tMove = pref + move + namespace;
1608
+ mfp._tEnd = pref + up + namespace;
1609
+ mfp._tCancel = pref + cancel + namespace;
1610
+ };
1611
+
1612
+ if(window.navigator.msPointerEnabled) {
1613
+ addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
1614
+ } else if('ontouchstart' in window) {
1615
+ addEventNames('touch', 'start', 'move', 'end', 'cancel');
1616
+ } else {
1617
+ return;
1618
+ }
1619
+ _window.on(mfp._tStart, function(e) {
1620
+ var oE = e.originalEvent;
1621
+ multipleTouches = moved = false;
1622
+ startX = oE.pageX || oE.changedTouches[0].pageX;
1623
+ }).on(mfp._tMove, function(e) {
1624
+ if(e.originalEvent.touches.length > 1) {
1625
+ multipleTouches = e.originalEvent.touches.length;
1626
+ } else {
1627
+ //e.preventDefault();
1628
+ moved = true;
1629
+ }
1630
+ }).on(mfp._tEnd + ' ' + mfp._tCancel, function(e) {
1631
+ if(moved && !multipleTouches) {
1632
+ var oE = e.originalEvent,
1633
+ diff = startX - (oE.pageX || oE.changedTouches[0].pageX);
1634
+
1635
+ if(diff > 20) {
1636
+ mfp.next();
1637
+ } else if(diff < -20) {
1638
+ mfp.prev();
1639
+ }
1640
+ }
1641
+ });
1642
+ },
1643
+ */
1644
+
1645
+
1646
+ /*>>gallery*/
1647
+
1648
+ /*>>retina*/
1649
+
1650
+ var RETINA_NS = 'retina';
1651
+
1652
+ $.magnificPopup.registerModule(RETINA_NS, {
1653
+ options: {
1654
+ replaceSrc: function(item) {
1655
+ return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; });
1656
+ },
1657
+ ratio: 1 // Function or number. Set to 1 to disable.
1658
+ },
1659
+ proto: {
1660
+ initRetina: function() {
1661
+ if(window.devicePixelRatio > 1) {
1662
+
1663
+ var st = mfp.st.retina,
1664
+ ratio = st.ratio;
1665
+
1666
+ ratio = !isNaN(ratio) ? ratio : ratio();
1667
+
1668
+ if(ratio > 1) {
1669
+ _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) {
1670
+ item.img.css({
1671
+ 'max-width': item.img[0].naturalWidth / ratio,
1672
+ 'width': '100%'
1673
+ });
1674
+ });
1675
+ _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) {
1676
+ item.src = st.replaceSrc(item, ratio);
1677
+ });
1678
+ }
1679
+ }
1680
+
1681
+ }
1682
+ }
1683
+ });
1684
+
1685
+ /*>>retina*/
1686
+
1687
+ /*>>fastclick*/
1688
+ /**
1689
+ * FastClick event implementation. (removes 300ms delay on touch devices)
1690
+ * Based on https://developers.google.com/mobile/articles/fast_buttons
1691
+ *
1692
+ * You may use it outside the Magnific Popup by calling just:
1693
+ *
1694
+ * $('.your-el').mfpFastClick(function() {
1695
+ * console.log('Clicked!');
1696
+ * });
1697
+ *
1698
+ * To unbind:
1699
+ * $('.your-el').destroyMfpFastClick();
1700
+ *
1701
+ *
1702
+ * Note that it's a very basic and simple implementation, it blocks ghost click on the same element where it was bound.
1703
+ * If you need something more advanced, use plugin by FT Labs https://github.com/ftlabs/fastclick
1704
+ *
1705
+ */
1706
+
1707
+ (function() {
1708
+ var ghostClickDelay = 1000,
1709
+ supportsTouch = 'ontouchstart' in window,
1710
+ unbindTouchMove = function() {
1711
+ _window.off('touchmove'+ns+' touchend'+ns);
1712
+ },
1713
+ eName = 'mfpFastClick',
1714
+ ns = '.'+eName;
1715
+
1716
+
1717
+ // As Zepto.js doesn't have an easy way to add custom events (like jQuery), so we implement it in this way
1718
+ $.fn.mfpFastClick = function(callback) {
1719
+
1720
+ return $(this).each(function() {
1721
+
1722
+ var elem = $(this),
1723
+ lock;
1724
+
1725
+ if( supportsTouch ) {
1726
+
1727
+ var timeout,
1728
+ startX,
1729
+ startY,
1730
+ pointerMoved,
1731
+ point,
1732
+ numPointers;
1733
+
1734
+ elem.on('touchstart' + ns, function(e) {
1735
+ pointerMoved = false;
1736
+ numPointers = 1;
1737
+
1738
+ point = e.originalEvent ? e.originalEvent.touches[0] : e.touches[0];
1739
+ startX = point.clientX;
1740
+ startY = point.clientY;
1741
+
1742
+ _window.on('touchmove'+ns, function(e) {
1743
+ point = e.originalEvent ? e.originalEvent.touches : e.touches;
1744
+ numPointers = point.length;
1745
+ point = point[0];
1746
+ if (Math.abs(point.clientX - startX) > 10 ||
1747
+ Math.abs(point.clientY - startY) > 10) {
1748
+ pointerMoved = true;
1749
+ unbindTouchMove();
1750
+ }
1751
+ }).on('touchend'+ns, function(e) {
1752
+ unbindTouchMove();
1753
+ if(pointerMoved || numPointers > 1) {
1754
+ return;
1755
+ }
1756
+ lock = true;
1757
+ e.preventDefault();
1758
+ clearTimeout(timeout);
1759
+ timeout = setTimeout(function() {
1760
+ lock = false;
1761
+ }, ghostClickDelay);
1762
+ callback();
1763
+ });
1764
+ });
1765
+
1766
+ }
1767
+
1768
+ elem.on('click' + ns, function() {
1769
+ if(!lock) {
1770
+ callback();
1771
+ }
1772
+ });
1773
+ });
1774
+ };
1775
+
1776
+ $.fn.destroyMfpFastClick = function() {
1777
+ $(this).off('touchstart' + ns + ' click' + ns);
1778
+ if(supportsTouch) _window.off('touchmove'+ns+' touchend'+ns);
1779
+ };
1780
+ })();
1781
+
1782
+ /*>>fastclick*/
1783
+ })(window.jQuery || window.Zepto);