Passed
Push — master ( e95921...ddbd1b )
by Dimas
13:28 queued 05:15
created

assets/mdb-dashboard/js/modules/lightbox.js   F

Complexity

Total Complexity 555
Complexity/F 2.19

Size

Lines of Code 1605
Function Count 253

Duplication

Duplicated Lines 2
Ratio 0.12 %

Importance

Changes 0
Metric Value
eloc 1229
dl 2
loc 1605
rs 0.8
c 0
b 0
f 0
wmc 555
mnd 302
bc 302
fnc 253
bpm 1.1936
cpm 2.1936
noi 72

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complexity

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like assets/mdb-dashboard/js/modules/lightbox.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
/*! PhotoSwipe - v4.1.1 - 2015-12-24
2
 * http://photoswipe.com
3
 * Copyright (c) 2015 Dmitry Semenov; */
4
! function (a, b) {
5
    "function" == typeof define && define.amd ? define(b) : "object" == typeof exports ? module.exports = b() : a.PhotoSwipe = b()
6
}(this, function () {
7
    "use strict";
8
    var a = function (a, b, c, d) {
9
        var e = {
10
            features: null,
11
            bind: function (a, b, c, d) {
12
                var e = (d ? "remove" : "add") + "EventListener";
13
                b = b.split(" ");
14
                for (var f = 0; f < b.length; f++) b[f] && a[e](b[f], c, !1)
15
            },
16
            isArray: function (a) {
17
                return a instanceof Array
18
            },
19
            createEl: function (a, b) {
20
                var c = document.createElement(b || "div");
21
                return a && (c.className = a), c
22
            },
23
            getScrollY: function () {
24
                var a = window.pageYOffset;
25
                return void 0 !== a ? a : document.documentElement.scrollTop
26
            },
27
            unbind: function (a, b, c) {
28
                e.bind(a, b, c, !0)
29
            },
30
            removeClass: function (a, b) {
31
                var c = new RegExp("(\\s|^)" + b + "(\\s|$)");
32
                a.className = a.className.replace(c, " ").replace(/^\s\s*/, "").replace(/\s\s*$/, "")
33
            },
34
            addClass: function (a, b) {
35
                e.hasClass(a, b) || (a.className += (a.className ? " " : "") + b)
36
            },
37
            hasClass: function (a, b) {
38
                return a.className && new RegExp("(^|\\s)" + b + "(\\s|$)").test(a.className)
39
            },
40
            getChildByClass: function (a, b) {
41
                for (var c = a.firstChild; c;) {
42
                    if (e.hasClass(c, b)) return c;
43
                    c = c.nextSibling
44
                }
45
            },
46
            arraySearch: function (a, b, c) {
47
                for (var d = a.length; d--;)
48
                    if (a[d][c] === b) return d;
49
                return -1
50
            },
51
            extend: function (a, b, c) {
52
                for (var d in b)
53
                    if (b.hasOwnProperty(d)) {
54
                        if (c && a.hasOwnProperty(d)) continue;
55
                        a[d] = b[d]
56
                    }
57
            },
58
            easing: {
59
                sine: {
60
                    out: function (a) {
61
                        return Math.sin(a * (Math.PI / 2))
62
                    },
63
                    inOut: function (a) {
64
                        return -(Math.cos(Math.PI * a) - 1) / 2
65
                    }
66
                },
67
                cubic: {
68
                    out: function (a) {
69
                        return --a * a * a + 1
70
                    }
71
                }
72
            },
73
            detectFeatures: function () {
74
                if (e.features) return e.features;
75
                var a = e.createEl(),
76
                    b = a.style,
77
                    c = "",
78
                    d = {};
79
                if (d.oldIE = document.all && !document.addEventListener, d.touch = "ontouchstart" in window, window.requestAnimationFrame && (d.raf = window.requestAnimationFrame, d.caf = window.cancelAnimationFrame), d.pointerEvent = navigator.pointerEnabled || navigator.msPointerEnabled, !d.pointerEvent) {
80
                    var f = navigator.userAgent;
81
                    if (/iP(hone|od)/.test(navigator.platform)) {
82
                        var g = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
83
                        g && g.length > 0 && (g = parseInt(g[1], 10), g >= 1 && 8 > g && (d.isOldIOSPhone = !0))
84
                    }
85
                    var h = f.match(/Android\s([0-9\.]*)/),
86
                        i = h ? h[1] : 0;
87
                    i = parseFloat(i), i >= 1 && (4.4 > i && (d.isOldAndroid = !0), d.androidVersion = i), d.isMobileOpera = /opera mini|opera mobi/i.test(f)
88
                }
89
                for (var j, k, l = ["transform", "perspective", "animationName"], m = ["", "webkit", "Moz", "ms", "O"], n = 0; 4 > n; n++) {
90
                    c = m[n];
91
                    for (var o = 0; 3 > o; o++) j = l[o], k = c + (c ? j.charAt(0).toUpperCase() + j.slice(1) : j), !d[j] && k in b && (d[j] = k);
92
                    c && !d.raf && (c = c.toLowerCase(), d.raf = window[c + "RequestAnimationFrame"], d.raf && (d.caf = window[c + "CancelAnimationFrame"] || window[c + "CancelRequestAnimationFrame"]))
93
                }
94
                if (!d.raf) {
95
                    var p = 0;
96
                    d.raf = function (a) {
97
                        var b = (new Date).getTime(),
98
                            c = Math.max(0, 16 - (b - p)),
99
                            d = window.setTimeout(function () {
100
                                a(b + c)
101
                            }, c);
102
                        return p = b + c, d
103
                    }, d.caf = function (a) {
104
                        clearTimeout(a)
105
                    }
106
                }
107
                return d.svg = !!document.createElementNS && !!document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect, e.features = d, d
108
            }
109
        };
110
        e.detectFeatures(), e.features.oldIE && (e.bind = function (a, b, c, d) {
111
            b = b.split(" ");
112
            for (var e, f = (d ? "detach" : "attach") + "Event", g = function () {
113
                    c.handleEvent.call(c)
114
                }, h = 0; h < b.length; h++)
115
                if (e = b[h])
116
                    if ("object" == typeof c && c.handleEvent) {
117
                        if (d) {
118
                            if (!c["oldIE" + e]) return !1
119
                        } else c["oldIE" + e] = g;
120
                        a[f]("on" + e, c["oldIE" + e])
121
                    } else a[f]("on" + e, c)
122
        });
123
        var f = this,
124
            g = 25,
125
            h = 3,
126
            i = {
127
                allowPanToNext: !0,
128
                spacing: .12,
129
                bgOpacity: 1,
130
                mouseUsed: !1,
131
                loop: !0,
132
                pinchToClose: !0,
133
                closeOnScroll: !0,
134
                closeOnVerticalDrag: !0,
135
                verticalDragRange: .75,
136
                hideAnimationDuration: 333,
137
                showAnimationDuration: 333,
138
                showHideOpacity: !1,
139
                focus: !0,
140
                escKey: !0,
141
                arrowKeys: !0,
142
                mainScrollEndFriction: .35,
143
                panEndFriction: .35,
144
                isClickableElement: function (a) {
145
                    return "A" === a.tagName
146
                },
147
                getDoubleTapZoom: function (a, b) {
148
                    return a ? 1 : b.initialZoomLevel < .7 ? 1 : 1.33
149
                },
150
                maxSpreadZoom: 1.33,
151
                modal: !0,
152
                scaleMode: "fit"
153
            };
154
        e.extend(i, d);
155
        var j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, $, _, aa, ba, ca, da, ea, fa, ga, ha, ia, ja, ka, la = function () {
156
                return {
157
                    x: 0,
158
                    y: 0
159
                }
160
            },
161
            ma = la(),
162
            na = la(),
163
            oa = la(),
164
            pa = {},
165
            qa = 0,
166
            ra = {},
167
            sa = la(),
168
            ta = 0,
169
            ua = !0,
170
            va = [],
171
            wa = {},
172
            xa = !1,
173
            ya = function (a, b) {
174
                e.extend(f, b.publicMethods), va.push(a)
175
            },
176
            za = function (a) {
177
                var b = _b();
178
                return a > b - 1 ? a - b : 0 > a ? b + a : a
179
            },
180
            Aa = {},
181
            Ba = function (a, b) {
182
                return Aa[a] || (Aa[a] = []), Aa[a].push(b)
183
            },
184
            Ca = function (a) {
185
                var b = Aa[a];
186
                if (b) {
187
                    var c = Array.prototype.slice.call(arguments);
188
                    c.shift();
189
                    for (var d = 0; d < b.length; d++) b[d].apply(f, c)
190
                }
191
            },
192
            Da = function () {
193
                return (new Date).getTime()
194
            },
195
            Ea = function (a) {
196
                ia = a, f.bg.style.opacity = a * i.bgOpacity
197
            },
198
            Fa = function (a, b, c, d, e) {
199
                (!xa || e && e !== f.currItem) && (d /= e ? e.fitRatio : f.currItem.fitRatio), a[E] = u + b + "px, " + c + "px" + v + " scale(" + d + ")"
200
            },
201
            Ga = function (a) {
202
                da && (a && (s > f.currItem.fitRatio ? xa || (lc(f.currItem, !1, !0), xa = !0) : xa && (lc(f.currItem), xa = !1)), Fa(da, oa.x, oa.y, s))
203
            },
204
            Ha = function (a) {
205
                a.container && Fa(a.container.style, a.initialPosition.x, a.initialPosition.y, a.initialZoomLevel, a)
206
            },
207
            Ia = function (a, b) {
208
                b[E] = u + a + "px, 0px" + v
209
            },
210
            Ja = function (a, b) {
211
                if (!i.loop && b) {
212
                    var c = m + (sa.x * qa - a) / sa.x,
213
                        d = Math.round(a - sb.x);
214
                    (0 > c && d > 0 || c >= _b() - 1 && 0 > d) && (a = sb.x + d * i.mainScrollEndFriction)
215
                }
216
                sb.x = a, Ia(a, n)
217
            },
218
            Ka = function (a, b) {
219
                var c = tb[a] - ra[a];
220
                return na[a] + ma[a] + c - c * (b / t)
221
            },
222
            La = function (a, b) {
223
                a.x = b.x, a.y = b.y, b.id && (a.id = b.id)
224
            },
225
            Ma = function (a) {
226
                a.x = Math.round(a.x), a.y = Math.round(a.y)
227
            },
228
            Na = null,
229
            Oa = function () {
230
                Na && (e.unbind(document, "mousemove", Oa), e.addClass(a, "pswp--has_mouse"), i.mouseUsed = !0, Ca("mouseUsed")), Na = setTimeout(function () {
231
                    Na = null
232
                }, 100)
233
            },
234
            Pa = function () {
235
                e.bind(document, "keydown", f), N.transform && e.bind(f.scrollWrap, "click", f), i.mouseUsed || e.bind(document, "mousemove", Oa), e.bind(window, "resize scroll", f), Ca("bindEvents")
236
            },
237
            Qa = function () {
238
                e.unbind(window, "resize", f), e.unbind(window, "scroll", r.scroll), e.unbind(document, "keydown", f), e.unbind(document, "mousemove", Oa), N.transform && e.unbind(f.scrollWrap, "click", f), U && e.unbind(window, p, f), Ca("unbindEvents")
239
            },
240
            Ra = function (a, b) {
241
                var c = hc(f.currItem, pa, a);
242
                return b && (ca = c), c
243
            },
244
            Sa = function (a) {
245
                return a || (a = f.currItem), a.initialZoomLevel
246
            },
247
            Ta = function (a) {
248
                return a || (a = f.currItem), a.w > 0 ? i.maxSpreadZoom : 1
249
            },
250
            Ua = function (a, b, c, d) {
251
                return d === f.currItem.initialZoomLevel ? (c[a] = f.currItem.initialPosition[a], !0) : (c[a] = Ka(a, d), c[a] > b.min[a] ? (c[a] = b.min[a], !0) : c[a] < b.max[a] ? (c[a] = b.max[a], !0) : !1)
252
            },
253
            Va = function () {
254
                if (E) {
255
                    var b = N.perspective && !G;
256
                    return u = "translate" + (b ? "3d(" : "("), void(v = N.perspective ? ", 0px)" : ")")
257
                }
258
                E = "left", e.addClass(a, "pswp--ie"), Ia = function (a, b) {
259
                    b.left = a + "px"
260
                }, Ha = function (a) {
261
                    var b = a.fitRatio > 1 ? 1 : a.fitRatio,
262
                        c = a.container.style,
263
                        d = b * a.w,
264
                        e = b * a.h;
265
                    c.width = d + "px", c.height = e + "px", c.left = a.initialPosition.x + "px", c.top = a.initialPosition.y + "px"
266
                }, Ga = function () {
267
                    if (da) {
268
                        var a = da,
269
                            b = f.currItem,
270
                            c = b.fitRatio > 1 ? 1 : b.fitRatio,
271
                            d = c * b.w,
272
                            e = c * b.h;
273
                        a.width = d + "px", a.height = e + "px", a.left = oa.x + "px", a.top = oa.y + "px"
274
                    }
275
                }
276
            },
277
            Wa = function (a) {
278
                var b = "";
279
                i.escKey && 27 === a.keyCode ? b = "close" : i.arrowKeys && (37 === a.keyCode ? b = "prev" : 39 === a.keyCode && (b = "next")), b && (a.ctrlKey || a.altKey || a.shiftKey || a.metaKey || (a.preventDefault ? a.preventDefault() : a.returnValue = !1, f[b]()))
280
            },
281
            Xa = function (a) {
282
                a && (X || W || ea || S) && (a.preventDefault(), a.stopPropagation())
283
            },
284
            Ya = function () {
285
                f.setScrollOffset(0, e.getScrollY())
286
            },
287
            Za = {},
288
            $a = 0,
289
            _a = function (a) {
290
                Za[a] && (Za[a].raf && I(Za[a].raf), $a--, delete Za[a])
291
            },
292
            ab = function (a) {
293
                Za[a] && _a(a), Za[a] || ($a++, Za[a] = {})
294
            },
295
            bb = function () {
296
                for (var a in Za) Za.hasOwnProperty(a) && _a(a)
297
            },
298
            cb = function (a, b, c, d, e, f, g) {
299
                var h, i = Da();
300
                ab(a);
301
                var j = function () {
302
                    if (Za[a]) {
303
                        if (h = Da() - i, h >= d) return _a(a), f(c), void(g && g());
304
                        f((c - b) * e(h / d) + b), Za[a].raf = H(j)
305
                    }
306
                };
307
                j()
308
            },
309
            db = {
310
                shout: Ca,
311
                listen: Ba,
312
                viewportSize: pa,
313
                options: i,
314
                isMainScrollAnimating: function () {
315
                    return ea
316
                },
317
                getZoomLevel: function () {
318
                    return s
319
                },
320
                getCurrentIndex: function () {
321
                    return m
322
                },
323
                isDragging: function () {
324
                    return U
325
                },
326
                isZooming: function () {
327
                    return _
328
                },
329
                setScrollOffset: function (a, b) {
330
                    ra.x = a, M = ra.y = b, Ca("updateScrollOffset", ra)
331
                },
332
                applyZoomPan: function (a, b, c, d) {
333
                    oa.x = b, oa.y = c, s = a, Ga(d)
334
                },
335
                init: function () {
336
                    if (!j && !k) {
337
                        var c;
338
                        f.framework = e, f.template = a, f.bg = e.getChildByClass(a, "pswp__bg"), J = a.className, j = !0, N = e.detectFeatures(), H = N.raf, I = N.caf, E = N.transform, L = N.oldIE, f.scrollWrap = e.getChildByClass(a, "pswp__scroll-wrap"), f.container = e.getChildByClass(f.scrollWrap, "pswp__container"), n = f.container.style, f.itemHolders = y = [{
339
                            el: f.container.children[0],
340
                            wrap: 0,
341
                            index: -1
342
                        }, {
343
                            el: f.container.children[1],
344
                            wrap: 0,
345
                            index: -1
346
                        }, {
347
                            el: f.container.children[2],
348
                            wrap: 0,
349
                            index: -1
350
                        }], y[0].el.style.display = y[2].el.style.display = "none", Va(), r = {
351
                            resize: f.updateSize,
352
                            scroll: Ya,
353
                            keydown: Wa,
354
                            click: Xa
355
                        };
356
                        var d = N.isOldIOSPhone || N.isOldAndroid || N.isMobileOpera;
357
                        for (N.animationName && N.transform && !d || (i.showAnimationDuration = i.hideAnimationDuration = 0), c = 0; c < va.length; c++) f["init" + va[c]]();
358
                        if (b) {
359
                            var g = f.ui = new b(f, e);
360
                            g.init()
361
                        }
362
                        Ca("firstUpdate"), m = m || i.index || 0, (isNaN(m) || 0 > m || m >= _b()) && (m = 0), f.currItem = $b(m), (N.isOldIOSPhone || N.isOldAndroid) && (ua = !1), a.setAttribute("aria-hidden", "false"), i.modal && (ua ? a.style.position = "fixed" : (a.style.position = "absolute", a.style.top = e.getScrollY() + "px")), void 0 === M && (Ca("initialLayout"), M = K = e.getScrollY());
363
                        var l = "pswp--open ";
364
                        for (i.mainClass && (l += i.mainClass + " "), i.showHideOpacity && (l += "pswp--animate_opacity "), l += G ? "pswp--touch" : "pswp--notouch", l += N.animationName ? " pswp--css_animation" : "", l += N.svg ? " pswp--svg" : "", e.addClass(a, l), f.updateSize(), o = -1, ta = null, c = 0; h > c; c++) Ia((c + o) * sa.x, y[c].el.style);
365
                        L || e.bind(f.scrollWrap, q, f), Ba("initialZoomInEnd", function () {
366
                            f.setContent(y[0], m - 1), f.setContent(y[2], m + 1), y[0].el.style.display = y[2].el.style.display = "block", i.focus && a.focus(), Pa()
367
                        }), f.setContent(y[1], m), f.updateCurrItem(), Ca("afterInit"), ua || (w = setInterval(function () {
368
                            $a || U || _ || s !== f.currItem.initialZoomLevel || f.updateSize()
369
                        }, 1e3)), e.addClass(a, "pswp--visible")
370
                    }
371
                },
372
                close: function () {
373
                    j && (j = !1, k = !0, Ca("close"), Qa(), bc(f.currItem, null, !0, f.destroy))
374
                },
375
                destroy: function () {
376
                    Ca("destroy"), Wb && clearTimeout(Wb), a.setAttribute("aria-hidden", "true"), a.className = J, w && clearInterval(w), e.unbind(f.scrollWrap, q, f), e.unbind(window, "scroll", f), yb(), bb(), Aa = null
377
                },
378
                panTo: function (a, b, c) {
379
                    c || (a > ca.min.x ? a = ca.min.x : a < ca.max.x && (a = ca.max.x), b > ca.min.y ? b = ca.min.y : b < ca.max.y && (b = ca.max.y)), oa.x = a, oa.y = b, Ga()
380
                },
381
                handleEvent: function (a) {
382
                    a = a || window.event, r[a.type] && r[a.type](a)
383
                },
384
                goTo: function (a) {
385
                    a = za(a);
386
                    var b = a - m;
387
                    ta = b, m = a, f.currItem = $b(m), qa -= b, Ja(sa.x * qa), bb(), ea = !1, f.updateCurrItem()
388
                },
389
                next: function () {
390
                    f.goTo(m + 1)
391
                },
392
                prev: function () {
393
                    f.goTo(m - 1)
394
                },
395
                updateCurrZoomItem: function (a) {
396
                    if (a && Ca("beforeChange", 0), y[1].el.children.length) {
397
                        var b = y[1].el.children[0];
398
                        da = e.hasClass(b, "pswp__zoom-wrap") ? b.style : null
399
                    } else da = null;
400
                    ca = f.currItem.bounds, t = s = f.currItem.initialZoomLevel, oa.x = ca.center.x, oa.y = ca.center.y, a && Ca("afterChange")
401
                },
402
                invalidateCurrItems: function () {
403
                    x = !0;
404
                    for (var a = 0; h > a; a++) y[a].item && (y[a].item.needsUpdate = !0)
405
                },
406
                updateCurrItem: function (a) {
407
                    if (0 !== ta) {
408
                        var b, c = Math.abs(ta);
409
                        if (!(a && 2 > c)) {
410
                            f.currItem = $b(m), xa = !1, Ca("beforeChange", ta), c >= h && (o += ta + (ta > 0 ? -h : h), c = h);
411
                            for (var d = 0; c > d; d++) ta > 0 ? (b = y.shift(), y[h - 1] = b, o++, Ia((o + 2) * sa.x, b.el.style), f.setContent(b, m - c + d + 1 + 1)) : (b = y.pop(), y.unshift(b), o--, Ia(o * sa.x, b.el.style), f.setContent(b, m + c - d - 1 - 1));
412
                            if (da && 1 === Math.abs(ta)) {
413
                                var e = $b(z);
414
                                e.initialZoomLevel !== s && (hc(e, pa), lc(e), Ha(e))
415
                            }
416
                            ta = 0, f.updateCurrZoomItem(), z = m, Ca("afterChange")
417
                        }
418
                    }
419
                },
420
                updateSize: function (b) {
421
                    if (!ua && i.modal) {
422
                        var c = e.getScrollY();
423
                        if (M !== c && (a.style.top = c + "px", M = c), !b && wa.x === window.innerWidth && wa.y === window.innerHeight) return;
424
                        wa.x = window.innerWidth, wa.y = window.innerHeight, a.style.height = wa.y + "px"
425
                    }
426
                    if (pa.x = f.scrollWrap.clientWidth, pa.y = f.scrollWrap.clientHeight, Ya(), sa.x = pa.x + Math.round(pa.x * i.spacing), sa.y = pa.y, Ja(sa.x * qa), Ca("beforeResize"), void 0 !== o) {
427
                        for (var d, g, j, k = 0; h > k; k++) d = y[k], Ia((k + o) * sa.x, d.el.style), j = m + k - 1, i.loop && _b() > 2 && (j = za(j)), g = $b(j), g && (x || g.needsUpdate || !g.bounds) ? (f.cleanSlide(g), f.setContent(d, j), 1 === k && (f.currItem = g, f.updateCurrZoomItem(!0)), g.needsUpdate = !1) : -1 === d.index && j >= 0 && f.setContent(d, j), g && g.container && (hc(g, pa), lc(g), Ha(g));
428
                        x = !1
429
                    }
430
                    t = s = f.currItem.initialZoomLevel, ca = f.currItem.bounds, ca && (oa.x = ca.center.x, oa.y = ca.center.y, Ga(!0)), Ca("resize")
431
                },
432
                zoomTo: function (a, b, c, d, f) {
433
                    b && (t = s, tb.x = Math.abs(b.x) - oa.x, tb.y = Math.abs(b.y) - oa.y, La(na, oa));
434
                    var g = Ra(a, !1),
435
                        h = {};
436
                    Ua("x", g, h, a), Ua("y", g, h, a);
437
                    var i = s,
438
                        j = {
439
                            x: oa.x,
440
                            y: oa.y
441
                        };
442
                    Ma(h);
443
                    var k = function (b) {
444
                        1 === b ? (s = a, oa.x = h.x, oa.y = h.y) : (s = (a - i) * b + i, oa.x = (h.x - j.x) * b + j.x, oa.y = (h.y - j.y) * b + j.y), f && f(b), Ga(1 === b)
445
                    };
446
                    c ? cb("customZoomTo", 0, 1, c, d || e.easing.sine.inOut, k) : k(1)
447
                }
448
            },
449
            eb = 30,
450
            fb = 10,
451
            gb = {},
452
            hb = {},
453
            ib = {},
454
            jb = {},
455
            kb = {},
456
            lb = [],
457
            mb = {},
458
            nb = [],
459
            ob = {},
460
            pb = 0,
461
            qb = la(),
462
            rb = 0,
463
            sb = la(),
464
            tb = la(),
465
            ub = la(),
466
            vb = function (a, b) {
467
                return a.x === b.x && a.y === b.y
468
            },
469
            wb = function (a, b) {
470
                return Math.abs(a.x - b.x) < g && Math.abs(a.y - b.y) < g
471
            },
472
            xb = function (a, b) {
473
                return ob.x = Math.abs(a.x - b.x), ob.y = Math.abs(a.y - b.y), Math.sqrt(ob.x * ob.x + ob.y * ob.y)
474
            },
475
            yb = function () {
476
                Y && (I(Y), Y = null)
477
            },
478
            zb = function () {
479
                U && (Y = H(zb), Pb())
480
            },
481
            Ab = function () {
482
                return !("fit" === i.scaleMode && s === f.currItem.initialZoomLevel)
483
            },
484
            Bb = function (a, b) {
485
                return a && a !== document ? a.getAttribute("class") && a.getAttribute("class").indexOf("pswp__scroll-wrap") > -1 ? !1 : b(a) ? a : Bb(a.parentNode, b) : !1
486
            },
487
            Cb = {},
488
            Db = function (a, b) {
489
                return Cb.prevent = !Bb(a.target, i.isClickableElement), Ca("preventDragEvent", a, b, Cb), Cb.prevent
490
            },
491
            Eb = function (a, b) {
492
                return b.x = a.pageX, b.y = a.pageY, b.id = a.identifier, b
493
            },
494
            Fb = function (a, b, c) {
495
                c.x = .5 * (a.x + b.x), c.y = .5 * (a.y + b.y)
496
            },
497
            Gb = function (a, b, c) {
498
                if (a - P > 50) {
499
                    var d = nb.length > 2 ? nb.shift() : {};
500
                    d.x = b, d.y = c, nb.push(d), P = a
501
                }
502
            },
503
            Hb = function () {
504
                var a = oa.y - f.currItem.initialPosition.y;
505
                return 1 - Math.abs(a / (pa.y / 2))
506
            },
507
            Ib = {},
508
            Jb = {},
509
            Kb = [],
510
            Lb = function (a) {
511
                for (; Kb.length > 0;) Kb.pop();
512
                return F ? (ka = 0, lb.forEach(function (a) {
513
                    0 === ka ? Kb[0] = a : 1 === ka && (Kb[1] = a), ka++
514
                })) : a.type.indexOf("touch") > -1 ? a.touches && a.touches.length > 0 && (Kb[0] = Eb(a.touches[0], Ib), a.touches.length > 1 && (Kb[1] = Eb(a.touches[1], Jb))) : (Ib.x = a.pageX, Ib.y = a.pageY, Ib.id = "", Kb[0] = Ib), Kb
515
            },
516
            Mb = function (a, b) {
517
                var c, d, e, g, h = 0,
518
                    j = oa[a] + b[a],
519
                    k = b[a] > 0,
520
                    l = sb.x + b.x,
521
                    m = sb.x - mb.x;
522
                return c = j > ca.min[a] || j < ca.max[a] ? i.panEndFriction : 1, j = oa[a] + b[a] * c, !i.allowPanToNext && s !== f.currItem.initialZoomLevel || (da ? "h" !== fa || "x" !== a || W || (k ? (j > ca.min[a] && (c = i.panEndFriction, h = ca.min[a] - j, d = ca.min[a] - na[a]), (0 >= d || 0 > m) && _b() > 1 ? (g = l, 0 > m && l > mb.x && (g = mb.x)) : ca.min.x !== ca.max.x && (e = j)) : (j < ca.max[a] && (c = i.panEndFriction, h = j - ca.max[a], d = na[a] - ca.max[a]), (0 >= d || m > 0) && _b() > 1 ? (g = l, m > 0 && l < mb.x && (g = mb.x)) : ca.min.x !== ca.max.x && (e = j))) : g = l, "x" !== a) ? void(ea || Z || s > f.currItem.fitRatio && (oa[a] += b[a] * c)) : (void 0 !== g && (Ja(g, !0), Z = g === mb.x ? !1 : !0), ca.min.x !== ca.max.x && (void 0 !== e ? oa.x = e : Z || (oa.x += b.x * c)), void 0 !== g)
523
            },
524
            Nb = function (a) {
525
                if (!("mousedown" === a.type && a.button > 0)) {
526
                    if (Zb) return void a.preventDefault();
527
                    if (!T || "mousedown" !== a.type) {
528
                        if (Db(a, !0) && a.preventDefault(), Ca("pointerDown"), F) {
529
                            var b = e.arraySearch(lb, a.pointerId, "id");
530
                            0 > b && (b = lb.length), lb[b] = {
531
                                x: a.pageX,
532
                                y: a.pageY,
533
                                id: a.pointerId
534
                            }
535
                        }
536
                        var c = Lb(a),
537
                            d = c.length;
538
                        $ = null, bb(), U && 1 !== d || (U = ga = !0, e.bind(window, p, f), R = ja = ha = S = Z = X = V = W = !1, fa = null, Ca("firstTouchStart", c), La(na, oa), ma.x = ma.y = 0, La(jb, c[0]), La(kb, jb), mb.x = sa.x * qa, nb = [{
539
                            x: jb.x,
540
                            y: jb.y
541
                        }], P = O = Da(), Ra(s, !0), yb(), zb()), !_ && d > 1 && !ea && !Z && (t = s, W = !1, _ = V = !0, ma.y = ma.x = 0, La(na, oa), La(gb, c[0]), La(hb, c[1]), Fb(gb, hb, ub), tb.x = Math.abs(ub.x) - oa.x, tb.y = Math.abs(ub.y) - oa.y, aa = ba = xb(gb, hb))
542
                    }
543
                }
544
            },
545
            Ob = function (a) {
546
                if (a.preventDefault(), F) {
547
                    var b = e.arraySearch(lb, a.pointerId, "id");
548
                    if (b > -1) {
549
                        var c = lb[b];
550
                        c.x = a.pageX, c.y = a.pageY
551
                    }
552
                }
553
                if (U) {
554
                    var d = Lb(a);
555
                    if (fa || X || _) $ = d;
556
                    else if (sb.x !== sa.x * qa) fa = "h";
557
                    else {
558
                        var f = Math.abs(d[0].x - jb.x) - Math.abs(d[0].y - jb.y);
559
                        Math.abs(f) >= fb && (fa = f > 0 ? "h" : "v", $ = d)
560
                    }
561
                }
562
            },
563
            Pb = function () {
564
                if ($) {
565
                    var a = $.length;
566
                    if (0 !== a)
567
                        if (La(gb, $[0]), ib.x = gb.x - jb.x, ib.y = gb.y - jb.y, _ && a > 1) {
568
                            if (jb.x = gb.x, jb.y = gb.y, !ib.x && !ib.y && vb($[1], hb)) return;
569
                            La(hb, $[1]), W || (W = !0, Ca("zoomGestureStarted"));
570
                            var b = xb(gb, hb),
571
                                c = Ub(b);
572
                            c > f.currItem.initialZoomLevel + f.currItem.initialZoomLevel / 15 && (ja = !0);
573
                            var d = 1,
574
                                e = Sa(),
575
                                g = Ta();
576
                            if (e > c)
577
                                if (i.pinchToClose && !ja && t <= f.currItem.initialZoomLevel) {
578
                                    var h = e - c,
579
                                        j = 1 - h / (e / 1.2);
580
                                    Ea(j), Ca("onPinchClose", j), ha = !0
581
                                } else d = (e - c) / e, d > 1 && (d = 1), c = e - d * (e / 3);
582
                            else c > g && (d = (c - g) / (6 * e), d > 1 && (d = 1), c = g + d * e);
583
                            0 > d && (d = 0), aa = b, Fb(gb, hb, qb), ma.x += qb.x - ub.x, ma.y += qb.y - ub.y, La(ub, qb), oa.x = Ka("x", c), oa.y = Ka("y", c), R = c > s, s = c, Ga()
584
                        } else {
585
                            if (!fa) return;
586
                            if (ga && (ga = !1, Math.abs(ib.x) >= fb && (ib.x -= $[0].x - kb.x), Math.abs(ib.y) >= fb && (ib.y -= $[0].y - kb.y)), jb.x = gb.x, jb.y = gb.y, 0 === ib.x && 0 === ib.y) return;
587
                            if ("v" === fa && i.closeOnVerticalDrag && !Ab()) {
588
                                ma.y += ib.y, oa.y += ib.y;
589
                                var k = Hb();
590
                                return S = !0, Ca("onVerticalDrag", k), Ea(k), void Ga()
591
                            }
592
                            Gb(Da(), gb.x, gb.y), X = !0, ca = f.currItem.bounds;
593
                            var l = Mb("x", ib);
594
                            l || (Mb("y", ib), Ma(oa), Ga())
595
                        }
596
                }
597
            },
598
            Qb = function (a) {
599
                if (N.isOldAndroid) {
600
                    if (T && "mouseup" === a.type) return;
601
                    a.type.indexOf("touch") > -1 && (clearTimeout(T), T = setTimeout(function () {
602
                        T = 0
603
                    }, 600))
604
                }
605
                Ca("pointerUp"), Db(a, !1) && a.preventDefault();
606
                var b;
607
                if (F) {
608
                    var c = e.arraySearch(lb, a.pointerId, "id");
609
                    if (c > -1)
610
                        if (b = lb.splice(c, 1)[0], navigator.pointerEnabled) b.type = a.pointerType || "mouse";
611
                        else {
612
                            var d = {
613
                                4: "mouse",
614
                                2: "touch",
615
                                3: "pen"
616
                            };
617
                            b.type = d[a.pointerType], b.type || (b.type = a.pointerType || "mouse")
618
                        }
619
                }
620
                var g, h = Lb(a),
621
                    j = h.length;
622
                if ("mouseup" === a.type && (j = 0), 2 === j) return $ = null, !0;
623
                1 === j && La(kb, h[0]), 0 !== j || fa || ea || (b || ("mouseup" === a.type ? b = {
624
                    x: a.pageX,
625
                    y: a.pageY,
626
                    type: "mouse"
627
                } : a.changedTouches && a.changedTouches[0] && (b = {
628
                    x: a.changedTouches[0].pageX,
629
                    y: a.changedTouches[0].pageY,
630
                    type: "touch"
631
                })), Ca("touchRelease", a, b));
632
                var k = -1;
633
                if (0 === j && (U = !1, e.unbind(window, p, f), yb(), _ ? k = 0 : -1 !== rb && (k = Da() - rb)), rb = 1 === j ? Da() : -1, g = -1 !== k && 150 > k ? "zoom" : "swipe", _ && 2 > j && (_ = !1, 1 === j && (g = "zoomPointerUp"), Ca("zoomGestureEnded")), $ = null, X || W || ea || S)
634
                    if (bb(), Q || (Q = Rb()), Q.calculateSwipeSpeed("x"), S) {
635
                        var l = Hb();
636
                        if (l < i.verticalDragRange) f.close();
637
                        else {
638
                            var m = oa.y,
639
                                n = ia;
640
                            cb("verticalDrag", 0, 1, 300, e.easing.cubic.out, function (a) {
641
                                oa.y = (f.currItem.initialPosition.y - m) * a + m, Ea((1 - n) * a + n), Ga()
642
                            }), Ca("onVerticalDrag", 1)
643
                        }
644
                    } else {
645
                        if ((Z || ea) && 0 === j) {
646
                            var o = Tb(g, Q);
647
                            if (o) return;
648
                            g = "zoomPointerUp"
649
                        }
650
                        if (!ea) return "swipe" !== g ? void Vb() : void(!Z && s > f.currItem.fitRatio && Sb(Q))
651
                    }
652
            },
653
            Rb = function () {
654
                var a, b, c = {
655
                    lastFlickOffset: {},
656
                    lastFlickDist: {},
657
                    lastFlickSpeed: {},
658
                    slowDownRatio: {},
659
                    slowDownRatioReverse: {},
660
                    speedDecelerationRatio: {},
661
                    speedDecelerationRatioAbs: {},
662
                    distanceOffset: {},
663
                    backAnimDestination: {},
664
                    backAnimStarted: {},
665
                    calculateSwipeSpeed: function (d) {
666
                        nb.length > 1 ? (a = Da() - P + 50, b = nb[nb.length - 2][d]) : (a = Da() - O, b = kb[d]), c.lastFlickOffset[d] = jb[d] - b, c.lastFlickDist[d] = Math.abs(c.lastFlickOffset[d]), c.lastFlickDist[d] > 20 ? c.lastFlickSpeed[d] = c.lastFlickOffset[d] / a : c.lastFlickSpeed[d] = 0, Math.abs(c.lastFlickSpeed[d]) < .1 && (c.lastFlickSpeed[d] = 0), c.slowDownRatio[d] = .95, c.slowDownRatioReverse[d] = 1 - c.slowDownRatio[d], c.speedDecelerationRatio[d] = 1
667
                    },
668
                    calculateOverBoundsAnimOffset: function (a, b) {
669
                        c.backAnimStarted[a] || (oa[a] > ca.min[a] ? c.backAnimDestination[a] = ca.min[a] : oa[a] < ca.max[a] && (c.backAnimDestination[a] = ca.max[a]), void 0 !== c.backAnimDestination[a] && (c.slowDownRatio[a] = .7, c.slowDownRatioReverse[a] = 1 - c.slowDownRatio[a], c.speedDecelerationRatioAbs[a] < .05 && (c.lastFlickSpeed[a] = 0, c.backAnimStarted[a] = !0, cb("bounceZoomPan" + a, oa[a], c.backAnimDestination[a], b || 300, e.easing.sine.out, function (b) {
670
                            oa[a] = b, Ga()
671
                        }))))
672
                    },
673
                    calculateAnimOffset: function (a) {
674
                        c.backAnimStarted[a] || (c.speedDecelerationRatio[a] = c.speedDecelerationRatio[a] * (c.slowDownRatio[a] + c.slowDownRatioReverse[a] - c.slowDownRatioReverse[a] * c.timeDiff / 10), c.speedDecelerationRatioAbs[a] = Math.abs(c.lastFlickSpeed[a] * c.speedDecelerationRatio[a]), c.distanceOffset[a] = c.lastFlickSpeed[a] * c.speedDecelerationRatio[a] * c.timeDiff, oa[a] += c.distanceOffset[a])
675
                    },
676
                    panAnimLoop: function () {
677
                        return Za.zoomPan && (Za.zoomPan.raf = H(c.panAnimLoop), c.now = Da(), c.timeDiff = c.now - c.lastNow, c.lastNow = c.now, c.calculateAnimOffset("x"), c.calculateAnimOffset("y"), Ga(), c.calculateOverBoundsAnimOffset("x"), c.calculateOverBoundsAnimOffset("y"), c.speedDecelerationRatioAbs.x < .05 && c.speedDecelerationRatioAbs.y < .05) ? (oa.x = Math.round(oa.x), oa.y = Math.round(oa.y), Ga(), void _a("zoomPan")) : void 0
678
                    }
679
                };
680
                return c
681
            },
682
            Sb = function (a) {
683
                return a.calculateSwipeSpeed("y"), ca = f.currItem.bounds, a.backAnimDestination = {}, a.backAnimStarted = {}, Math.abs(a.lastFlickSpeed.x) <= .05 && Math.abs(a.lastFlickSpeed.y) <= .05 ? (a.speedDecelerationRatioAbs.x = a.speedDecelerationRatioAbs.y = 0, a.calculateOverBoundsAnimOffset("x"), a.calculateOverBoundsAnimOffset("y"), !0) : (ab("zoomPan"), a.lastNow = Da(), void a.panAnimLoop())
684
            },
685
            Tb = function (a, b) {
686
                var c;
687
                ea || (pb = m);
688
                var d;
689
                if ("swipe" === a) {
690
                    var g = jb.x - kb.x,
691
                        h = b.lastFlickDist.x < 10;
692
                    g > eb && (h || b.lastFlickOffset.x > 20) ? d = -1 : -eb > g && (h || b.lastFlickOffset.x < -20) && (d = 1)
693
                }
694
                var j;
695
                d && (m += d, 0 > m ? (m = i.loop ? _b() - 1 : 0, j = !0) : m >= _b() && (m = i.loop ? 0 : _b() - 1, j = !0), (!j || i.loop) && (ta += d, qa -= d, c = !0));
696
                var k, l = sa.x * qa,
697
                    n = Math.abs(l - sb.x);
698
                return c || l > sb.x == b.lastFlickSpeed.x > 0 ? (k = Math.abs(b.lastFlickSpeed.x) > 0 ? n / Math.abs(b.lastFlickSpeed.x) : 333, k = Math.min(k, 400), k = Math.max(k, 250)) : k = 333, pb === m && (c = !1), ea = !0, Ca("mainScrollAnimStart"), cb("mainScroll", sb.x, l, k, e.easing.cubic.out, Ja, function () {
699
                    bb(), ea = !1, pb = -1, (c || pb !== m) && f.updateCurrItem(), Ca("mainScrollAnimComplete")
700
                }), c && f.updateCurrItem(!0), c
701
            },
702
            Ub = function (a) {
703
                return 1 / ba * a * t
704
            },
705
            Vb = function () {
706
                var a = s,
707
                    b = Sa(),
708
                    c = Ta();
709
                b > s ? a = b : s > c && (a = c);
710
                var d, g = 1,
711
                    h = ia;
712
                return ha && !R && !ja && b > s ? (f.close(), !0) : (ha && (d = function (a) {
713
                    Ea((g - h) * a + h)
714
                }), f.zoomTo(a, 0, 200, e.easing.cubic.out, d), !0)
715
            };
716
        ya("Gestures", {
717
            publicMethods: {
718
                initGestures: function () {
719
                    var a = function (a, b, c, d, e) {
720
                        A = a + b, B = a + c, C = a + d, D = e ? a + e : ""
721
                    };
722
                    F = N.pointerEvent, F && N.touch && (N.touch = !1), F ? navigator.pointerEnabled ? a("pointer", "down", "move", "up", "cancel") : a("MSPointer", "Down", "Move", "Up", "Cancel") : N.touch ? (a("touch", "start", "move", "end", "cancel"), G = !0) : a("mouse", "down", "move", "up"), p = B + " " + C + " " + D, q = A, F && !G && (G = navigator.maxTouchPoints > 1 || navigator.msMaxTouchPoints > 1), f.likelyTouchDevice = G, r[A] = Nb, r[B] = Ob, r[C] = Qb, D && (r[D] = r[C]), N.touch && (q += " mousedown", p += " mousemove mouseup", r.mousedown = r[A], r.mousemove = r[B], r.mouseup = r[C]), G || (i.allowPanToNext = !1)
723
                }
724
            }
725
        });
726
        var Wb, Xb, Yb, Zb, $b, _b, ac, bc = function (b, c, d, g) {
727
                Wb && clearTimeout(Wb), Zb = !0, Yb = !0;
728
                var h;
729
                b.initialLayout ? (h = b.initialLayout, b.initialLayout = null) : h = i.getThumbBoundsFn && i.getThumbBoundsFn(m);
730
                var j = d ? i.hideAnimationDuration : i.showAnimationDuration,
731
                    k = function () {
732
                        _a("initialZoom"), d ? (f.template.removeAttribute("style"), f.bg.removeAttribute("style")) : (Ea(1), c && (c.style.display = "block"), e.addClass(a, "pswp--animated-in"), Ca("initialZoom" + (d ? "OutEnd" : "InEnd"))), g && g(), Zb = !1
733
                    };
734
                if (!j || !h || void 0 === h.x) return Ca("initialZoom" + (d ? "Out" : "In")), s = b.initialZoomLevel, La(oa, b.initialPosition), Ga(), a.style.opacity = d ? 0 : 1, Ea(1), void(j ? setTimeout(function () {
735
                    k()
736
                }, j) : k());
737
                var n = function () {
738
                    var c = l,
739
                        g = !f.currItem.src || f.currItem.loadError || i.showHideOpacity;
740
                    b.miniImg && (b.miniImg.style.webkitBackfaceVisibility = "hidden"), d || (s = h.w / b.w, oa.x = h.x, oa.y = h.y - K, f[g ? "template" : "bg"].style.opacity = .001, Ga()), ab("initialZoom"), d && !c && e.removeClass(a, "pswp--animated-in"), g && (d ? e[(c ? "remove" : "add") + "Class"](a, "pswp--animate_opacity") : setTimeout(function () {
741
                        e.addClass(a, "pswp--animate_opacity")
742
                    }, 30)), Wb = setTimeout(function () {
743
                        if (Ca("initialZoom" + (d ? "Out" : "In")), d) {
744
                            var f = h.w / b.w,
745
                                i = {
746
                                    x: oa.x,
747
                                    y: oa.y
748
                                },
749
                                l = s,
750
                                m = ia,
751
                                n = function (b) {
752
                                    1 === b ? (s = f, oa.x = h.x, oa.y = h.y - M) : (s = (f - l) * b + l, oa.x = (h.x - i.x) * b + i.x, oa.y = (h.y - M - i.y) * b + i.y), Ga(), g ? a.style.opacity = 1 - b : Ea(m - b * m)
753
                                };
754
                            c ? cb("initialZoom", 0, 1, j, e.easing.cubic.out, n, k) : (n(1), Wb = setTimeout(k, j + 20))
755
                        } else s = b.initialZoomLevel, La(oa, b.initialPosition), Ga(), Ea(1), g ? a.style.opacity = 1 : Ea(1), Wb = setTimeout(k, j + 20)
756
                    }, d ? 25 : 90)
757
                };
758
                n()
759
            },
760
            cc = {},
761
            dc = [],
762
            ec = {
763
                index: 0,
764
                errorMsg: '<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',
765
                forceProgressiveLoading: !1,
766
                preload: [1, 1],
767
                getNumItemsFn: function () {
768
                    return Xb.length
769
                }
770
            },
771
            fc = function () {
772
                return {
773
                    center: {
774
                        x: 0,
775
                        y: 0
776
                    },
777
                    max: {
778
                        x: 0,
779
                        y: 0
780
                    },
781
                    min: {
782
                        x: 0,
783
                        y: 0
784
                    }
785
                }
786
            },
787
            gc = function (a, b, c) {
788
                var d = a.bounds;
789
                d.center.x = Math.round((cc.x - b) / 2), d.center.y = Math.round((cc.y - c) / 2) + a.vGap.top, d.max.x = b > cc.x ? Math.round(cc.x - b) : d.center.x, d.max.y = c > cc.y ? Math.round(cc.y - c) + a.vGap.top : d.center.y, d.min.x = b > cc.x ? 0 : d.center.x, d.min.y = c > cc.y ? a.vGap.top : d.center.y
790
            },
791
            hc = function (a, b, c) {
792
                if (a.src && !a.loadError) {
793
                    var d = !c;
794
                    if (d && (a.vGap || (a.vGap = {
795
                            top: 0,
796
                            bottom: 0
797
                        }), Ca("parseVerticalMargin", a)), cc.x = b.x, cc.y = b.y - a.vGap.top - a.vGap.bottom, d) {
798
                        var e = cc.x / a.w,
799
                            f = cc.y / a.h;
800
                        a.fitRatio = f > e ? e : f;
801
                        var g = i.scaleMode;
802
                        "orig" === g ? c = 1 : "fit" === g && (c = a.fitRatio), c > 1 && (c = 1), a.initialZoomLevel = c, a.bounds || (a.bounds = fc())
803
                    }
804
                    if (!c) return;
805
                    return gc(a, a.w * c, a.h * c), d && c === a.initialZoomLevel && (a.initialPosition = a.bounds.center), a.bounds
806
                }
807
                return a.w = a.h = 0, a.initialZoomLevel = a.fitRatio = 1, a.bounds = fc(), a.initialPosition = a.bounds.center, a.bounds
808
            },
809
            ic = function (a, b, c, d, e, g) {
810
                b.loadError || d && (b.imageAppended = !0, lc(b, d, b === f.currItem && xa), c.appendChild(d), g && setTimeout(function () {
811
                    b && b.loaded && b.placeholder && (b.placeholder.style.display = "none", b.placeholder = null)
812
                }, 500))
813
            },
814
            jc = function (a) {
815
                a.loading = !0, a.loaded = !1;
816
                var b = a.img = e.createEl("pswp__img", "img"),
817
                    c = function () {
818
                        a.loading = !1, a.loaded = !0, a.loadComplete ? a.loadComplete(a) : a.img = null, b.onload = b.onerror = null, b = null
819
                    };
820
                return b.onload = c, b.onerror = function () {
821
                    a.loadError = !0, c()
822
                }, b.src = a.src, b
823
            },
824
            kc = function (a, b) {
825
                return a.src && a.loadError && a.container ? (b && (a.container.innerHTML = ""), a.container.innerHTML = i.errorMsg.replace("%url%", a.src), !0) : void 0
826
            },
827
            lc = function (a, b, c) {
828
                if (a.src) {
829
                    b || (b = a.container.lastChild);
830
                    var d = c ? a.w : Math.round(a.w * a.fitRatio),
831
                        e = c ? a.h : Math.round(a.h * a.fitRatio);
832
                    a.placeholder && !a.loaded && (a.placeholder.style.width = d + "px", a.placeholder.style.height = e + "px"), b.style.width = d + "px", b.style.height = e + "px"
833
                }
834
            },
835
            mc = function () {
836
                if (dc.length) {
837
                    for (var a, b = 0; b < dc.length; b++) a = dc[b], a.holder.index === a.index && ic(a.index, a.item, a.baseDiv, a.img, !1, a.clearPlaceholder);
838
                    dc = []
839
                }
840
            };
841
        ya("Controller", {
842
            publicMethods: {
843
                lazyLoadItem: function (a) {
844
                    a = za(a);
845
                    var b = $b(a);
846
                    b && (!b.loaded && !b.loading || x) && (Ca("gettingData", a, b), b.src && jc(b))
847
                },
848
                initController: function () {
849
                    e.extend(i, ec, !0), f.items = Xb = c, $b = f.getItemAt, _b = i.getNumItemsFn, ac = i.loop, _b() < 3 && (i.loop = !1), Ba("beforeChange", function (a) {
850
                        var b, c = i.preload,
851
                            d = null === a ? !0 : a >= 0,
852
                            e = Math.min(c[0], _b()),
853
                            g = Math.min(c[1], _b());
854
                        for (b = 1;
855
                            (d ? g : e) >= b; b++) f.lazyLoadItem(m + b);
856
                        for (b = 1;
857
                            (d ? e : g) >= b; b++) f.lazyLoadItem(m - b)
858
                    }), Ba("initialLayout", function () {
859
                        f.currItem.initialLayout = i.getThumbBoundsFn && i.getThumbBoundsFn(m)
860
                    }), Ba("mainScrollAnimComplete", mc), Ba("initialZoomInEnd", mc), Ba("destroy", function () {
861
                        for (var a, b = 0; b < Xb.length; b++) a = Xb[b], a.container && (a.container = null), a.placeholder && (a.placeholder = null), a.img && (a.img = null), a.preloader && (a.preloader = null), a.loadError && (a.loaded = a.loadError = !1);
862
                        dc = null
863
                    })
864
                },
865
                getItemAt: function (a) {
866
                    return a >= 0 && void 0 !== Xb[a] ? Xb[a] : !1
867
                },
868
                allowProgressiveImg: function () {
869
                    return i.forceProgressiveLoading || !G || i.mouseUsed || screen.width > 1200
870
                },
871
                setContent: function (a, b) {
872
                    i.loop && (b = za(b));
873
                    var c = f.getItemAt(a.index);
874
                    c && (c.container = null);
875
                    var d, g = f.getItemAt(b);
876
                    if (!g) return void(a.el.innerHTML = "");
877
                    Ca("gettingData", b, g), a.index = b, a.item = g;
878
                    var h = g.container = e.createEl("pswp__zoom-wrap");
879
                    if (!g.src && g.html && (g.html.tagName ? h.appendChild(g.html) : h.innerHTML = g.html), kc(g), hc(g, pa), !g.src || g.loadError || g.loaded) g.src && !g.loadError && (d = e.createEl("pswp__img", "img"), d.style.opacity = 1, d.src = g.src, lc(g, d), ic(b, g, h, d, !0));
880
                    else {
881
                        if (g.loadComplete = function (c) {
882
                                if (j) {
883
                                    if (a && a.index === b) {
884
                                        if (kc(c, !0)) return c.loadComplete = c.img = null, hc(c, pa), Ha(c), void(a.index === m && f.updateCurrZoomItem());
885
                                        c.imageAppended ? !Zb && c.placeholder && (c.placeholder.style.display = "none", c.placeholder = null) : N.transform && (ea || Zb) ? dc.push({
886
                                            item: c,
887
                                            baseDiv: h,
888
                                            img: c.img,
889
                                            index: b,
890
                                            holder: a,
891
                                            clearPlaceholder: !0
892
                                        }) : ic(b, c, h, c.img, ea || Zb, !0)
893
                                    }
894
                                    c.loadComplete = null, c.img = null, Ca("imageLoadComplete", b, c)
895
                                }
896
                            }, e.features.transform) {
897
                            var k = "pswp__img pswp__img--placeholder";
898
                            k += g.msrc ? "" : " pswp__img--placeholder--blank";
899
                            var l = e.createEl(k, g.msrc ? "img" : "");
900
                            g.msrc && (l.src = g.msrc), lc(g, l), h.appendChild(l), g.placeholder = l
901
                        }
902
                        g.loading || jc(g), f.allowProgressiveImg() && (!Yb && N.transform ? dc.push({
903
                            item: g,
904
                            baseDiv: h,
905
                            img: g.img,
906
                            index: b,
907
                            holder: a
908
                        }) : ic(b, g, h, g.img, !0, !0))
909
                    }
910
                    Yb || b !== m ? Ha(g) : (da = h.style, bc(g, d || g.img)), a.el.innerHTML = "", a.el.appendChild(h)
911
                },
912
                cleanSlide: function (a) {
913
                    a.img && (a.img.onload = a.img.onerror = null), a.loaded = a.loading = a.img = a.imageAppended = !1
914
                }
915
            }
916
        });
917
        var nc, oc = {},
918
            pc = function (a, b, c) {
919
                var d = document.createEvent("CustomEvent"),
920
                    e = {
921
                        origEvent: a,
922
                        target: a.target,
923
                        releasePoint: b,
924
                        pointerType: c || "touch"
925
                    };
926
                d.initCustomEvent("pswpTap", !0, !0, e), a.target.dispatchEvent(d)
927
            };
928
        ya("Tap", {
929
            publicMethods: {
930
                initTap: function () {
931
                    Ba("firstTouchStart", f.onTapStart), Ba("touchRelease", f.onTapRelease), Ba("destroy", function () {
932
                        oc = {}, nc = null
933
                    })
934
                },
935
                onTapStart: function (a) {
936
                    a.length > 1 && (clearTimeout(nc), nc = null)
937
                },
938
                onTapRelease: function (a, b) {
939
                    if (b && !X && !V && !$a) {
940
                        var c = b;
941
                        if (nc && (clearTimeout(nc), nc = null, wb(c, oc))) return void Ca("doubleTap", c);
942
                        if ("mouse" === b.type) return void pc(a, b, "mouse");
943
                        var d = a.target.tagName.toUpperCase();
944
                        if ("BUTTON" === d || e.hasClass(a.target, "pswp__single-tap")) return void pc(a, b);
945
                        La(oc, c), nc = setTimeout(function () {
946
                            pc(a, b), nc = null
947
                        }, 300)
948
                    }
949
                }
950
            }
951
        });
952
        var qc;
953
        ya("DesktopZoom", {
954
            publicMethods: {
955
                initDesktopZoom: function () {
956
                    L || (G ? Ba("mouseUsed", function () {
957
                        f.setupDesktopZoom()
958
                    }) : f.setupDesktopZoom(!0))
959
                },
960
                setupDesktopZoom: function (b) {
961
                    qc = {};
962
                    var c = "wheel mousewheel DOMMouseScroll";
963
                    Ba("bindEvents", function () {
964
                        e.bind(a, c, f.handleMouseWheel)
965
                    }), Ba("unbindEvents", function () {
966
                        qc && e.unbind(a, c, f.handleMouseWheel)
967
                    }), f.mouseZoomedIn = !1;
968
                    var d, g = function () {
969
                            f.mouseZoomedIn && (e.removeClass(a, "pswp--zoomed-in"), f.mouseZoomedIn = !1), 1 > s ? e.addClass(a, "pswp--zoom-allowed") : e.removeClass(a, "pswp--zoom-allowed"), h()
970
                        },
971
                        h = function () {
972
                            d && (e.removeClass(a, "pswp--dragging"), d = !1)
973
                        };
974
                    Ba("resize", g), Ba("afterChange", g), Ba("pointerDown", function () {
975
                        f.mouseZoomedIn && (d = !0, e.addClass(a, "pswp--dragging"))
976
                    }), Ba("pointerUp", h), b || g()
977
                },
978
                handleMouseWheel: function (a) {
979
                    if (s <= f.currItem.fitRatio) return i.modal && (!i.closeOnScroll || $a || U ? a.preventDefault() : E && Math.abs(a.deltaY) > 2 && (l = !0, f.close())), !0;
980
                    if (a.stopPropagation(), qc.x = 0, "deltaX" in a) 1 === a.deltaMode ? (qc.x = 18 * a.deltaX, qc.y = 18 * a.deltaY) : (qc.x = a.deltaX, qc.y = a.deltaY);
981
                    else if ("wheelDelta" in a) a.wheelDeltaX && (qc.x = -.16 * a.wheelDeltaX), a.wheelDeltaY ? qc.y = -.16 * a.wheelDeltaY : qc.y = -.16 * a.wheelDelta;
982
                    else {
983
                        if (!("detail" in a)) return;
984
                        qc.y = a.detail
985
                    }
986
                    Ra(s, !0);
987
                    var b = oa.x - qc.x,
988
                        c = oa.y - qc.y;
989
                    (i.modal || b <= ca.min.x && b >= ca.max.x && c <= ca.min.y && c >= ca.max.y) && a.preventDefault(), f.panTo(b, c)
990
                },
991
                toggleDesktopZoom: function (b) {
992
                    b = b || {
993
                        x: pa.x / 2 + ra.x,
994
                        y: pa.y / 2 + ra.y
995
                    };
996
                    var c = i.getDoubleTapZoom(!0, f.currItem),
997
                        d = s === c;
998
                    f.mouseZoomedIn = !d, f.zoomTo(d ? f.currItem.initialZoomLevel : c, b, 333), e[(d ? "remove" : "add") + "Class"](a, "pswp--zoomed-in")
999
                }
1000
            }
1001
        });
1002
        var rc, sc, tc, uc, vc, wc, xc, yc, zc, Ac, Bc, Cc, Dc = {
1003
                history: !0,
1004
                galleryUID: 1
1005
            },
1006
            Ec = function () {
1007
                return Bc.hash.substring(1)
1008
            },
1009
            Fc = function () {
1010
                rc && clearTimeout(rc), tc && clearTimeout(tc)
1011
            },
1012
            Gc = function () {
1013
                var a = Ec(),
1014
                    b = {};
1015
                if (a.length < 5) return b;
1016
                var c, d = a.split("&");
1017
                for (c = 0; c < d.length; c++)
1018
                    if (d[c]) {
1019
                        var e = d[c].split("=");
1020
                        e.length < 2 || (b[e[0]] = e[1])
1021
                    }
1022
                if (i.galleryPIDs) {
1023
                    var f = b.pid;
1024
                    for (b.pid = 0, c = 0; c < Xb.length; c++)
1025
                        if (Xb[c].pid === f) {
1026
                            b.pid = c;
1027
                            break
1028
                        }
1029
                } else b.pid = parseInt(b.pid, 10) - 1;
1030
                return b.pid < 0 && (b.pid = 0), b
1031
            },
1032
            Hc = function () {
1033
                if (tc && clearTimeout(tc), $a || U) return void(tc = setTimeout(Hc, 500));
1034
                uc ? clearTimeout(sc) : uc = !0;
1035
                var a = m + 1,
1036
                    b = $b(m);
1037
                b.hasOwnProperty("pid") && (a = b.pid);
1038
                var c = xc + "&gid=" + i.galleryUID + "&pid=" + a;
1039
                yc || -1 === Bc.hash.indexOf(c) && (Ac = !0);
1040
                var d = Bc.href.split("#")[0] + "#" + c;
1041
                Cc ? "#" + c !== window.location.hash && history[yc ? "replaceState" : "pushState"]("", document.title, d) : yc ? Bc.replace(d) : Bc.hash = c, yc = !0, sc = setTimeout(function () {
1042
                    uc = !1
1043
                }, 60)
1044
            };
1045
        ya("History", {
1046
            publicMethods: {
1047
                initHistory: function () {
1048
                    if (e.extend(i, Dc, !0), i.history) {
1049
                        Bc = window.location, Ac = !1, zc = !1, yc = !1, xc = Ec(), Cc = "pushState" in history, xc.indexOf("gid=") > -1 && (xc = xc.split("&gid=")[0], xc = xc.split("?gid=")[0]), Ba("afterChange", f.updateURL), Ba("unbindEvents", function () {
1050
                            e.unbind(window, "hashchange", f.onHashChange)
1051
                        });
1052
                        var a = function () {
1053
                            wc = !0, zc || (Ac ? history.back() : xc ? Bc.hash = xc : Cc ? history.pushState("", document.title, Bc.pathname + Bc.search) : Bc.hash = ""), Fc()
1054
                        };
1055
                        Ba("unbindEvents", function () {
1056
                            l && a()
1057
                        }), Ba("destroy", function () {
1058
                            wc || a()
1059
                        }), Ba("firstUpdate", function () {
1060
                            m = Gc().pid
1061
                        });
1062
                        var b = xc.indexOf("pid=");
1063
                        b > -1 && (xc = xc.substring(0, b), "&" === xc.slice(-1) && (xc = xc.slice(0, -1))), setTimeout(function () {
1064
                            j && e.bind(window, "hashchange", f.onHashChange)
1065
                        }, 40)
1066
                    }
1067
                },
1068
                onHashChange: function () {
1069
                    return Ec() === xc ? (zc = !0, void f.close()) : void(uc || (vc = !0, f.goTo(Gc().pid), vc = !1))
1070
                },
1071
                updateURL: function () {
1072
                    Fc(), vc || (yc ? rc = setTimeout(Hc, 800) : Hc())
1073
                }
1074
            }
1075
        }), e.extend(f, db)
1076
    };
1077
    return a
1078
});
1079
1080
/*! PhotoSwipe Default UI - 4.1.1 - 2015-12-24
1081
 * http://photoswipe.com
1082
 * Copyright (c) 2015 Dmitry Semenov; */
1083
! function (a, b) {
1084
    "function" == typeof define && define.amd ? define(b) : "object" == typeof exports ? module.exports = b() : a.PhotoSwipeUI_Default = b()
1085
}(this, function () {
1086
    "use strict";
1087
    var a = function (a, b) {
1088
        var c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v = this,
1089
            w = !1,
1090
            x = !0,
1091
            y = !0,
1092
            z = {
1093
                barsSize: {
1094
                    top: 44,
1095
                    bottom: "auto"
1096
                },
1097
                closeElClasses: ["item", "caption", "zoom-wrap", "ui", "top-bar"],
1098
                timeToIdle: 4e3,
1099
                timeToIdleOutside: 1e3,
1100
                loadingIndicatorDelay: 1e3,
1101
                addCaptionHTMLFn: function (a, b) {
1102
                    return a.title ? (b.children[0].innerHTML = a.title, !0) : (b.children[0].innerHTML = "", !1)
1103
                },
1104
                closeEl: !0,
1105
                captionEl: !0,
1106
                fullscreenEl: !0,
1107
                zoomEl: !0,
1108
                shareEl: !0,
1109
                counterEl: !0,
1110
                arrowEl: !0,
1111
                preloaderEl: !0,
1112
                tapToClose: !1,
1113
                tapToToggleControls: !0,
1114
                clickToCloseNonZoomable: !0,
1115
                shareButtons: [{
1116
                    id: "facebook",
1117
                    label: "Share on Facebook",
1118
                    url: "https://www.facebook.com/sharer/sharer.php?u={{url}}"
1119
                }, {
1120
                    id: "twitter",
1121
                    label: "Tweet",
1122
                    url: "https://twitter.com/intent/tweet?text={{text}}&url={{url}}"
1123
                }, {
1124
                    id: "pinterest",
1125
                    label: "Pin it",
1126
                    url: "http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}"
1127
                }, {
1128
                    id: "download",
1129
                    label: "Download image",
1130
                    url: "{{raw_image_url}}",
1131
                    download: !0
1132
                }],
1133
                getImageURLForShare: function () {
1134
                    return a.currItem.src || ""
1135
                },
1136
                getPageURLForShare: function () {
1137
                    return window.location.href
1138
                },
1139
                getTextForShare: function () {
1140
                    return a.currItem.title || ""
1141
                },
1142
                indexIndicatorSep: " / ",
1143
                fitControlsWidth: 1200
1144
            },
1145
            A = function (a) {
1146
                if (r) return !0;
1147
                a = a || window.event, q.timeToIdle && q.mouseUsed && !k && K();
1148
                for (var c, d, e = a.target || a.srcElement, f = e.getAttribute("class") || "", g = 0; g < S.length; g++) c = S[g], c.onTap && f.indexOf("pswp__" + c.name) > -1 && (c.onTap(), d = !0);
1149
                if (d) {
1150
                    a.stopPropagation && a.stopPropagation(), r = !0;
1151
                    var h = b.features.isOldAndroid ? 600 : 30;
1152
                    s = setTimeout(function () {
1153
                        r = !1
1154
                    }, h)
1155
                }
1156
            },
1157
            B = function () {
1158
                return !a.likelyTouchDevice || q.mouseUsed || screen.width > q.fitControlsWidth
1159
            },
1160
            C = function (a, c, d) {
1161
                b[(d ? "add" : "remove") + "Class"](a, "pswp__" + c)
1162
            },
1163
            D = function () {
1164
                var a = 1 === q.getNumItemsFn();
1165
                a !== p && (C(d, "ui--one-slide", a), p = a)
1166
            },
1167
            E = function () {
1168
                C(i, "share-modal--hidden", y)
1169
            },
1170
            F = function () {
1171
                return y = !y, y ? (b.removeClass(i, "pswp__share-modal--fade-in"), setTimeout(function () {
1172
                    y && E()
1173
                }, 300)) : (E(), setTimeout(function () {
1174
                    y || b.addClass(i, "pswp__share-modal--fade-in")
1175
                }, 30)), y || H(), !1
1176
            },
1177
            G = function (b) {
1178
                b = b || window.event;
1179
                var c = b.target || b.srcElement;
1180
                return a.shout("shareLinkClick", b, c), c.href ? c.hasAttribute("download") ? !0 : (window.open(c.href, "pswp_share", "scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,top=100,left=" + (window.screen ? Math.round(screen.width / 2 - 275) : 100)), y || F(), !1) : !1
1181
            },
1182
            H = function () {
1183
                for (var a, b, c, d, e, f = "", g = 0; g < q.shareButtons.length; g++) a = q.shareButtons[g], c = q.getImageURLForShare(a), d = q.getPageURLForShare(a), e = q.getTextForShare(a), b = a.url.replace("{{url}}", encodeURIComponent(d)).replace("{{image_url}}", encodeURIComponent(c)).replace("{{raw_image_url}}", c).replace("{{text}}", encodeURIComponent(e)), f += '<a href="' + b + '" target="_blank" class="pswp__share--' + a.id + '"' + (a.download ? "download" : "") + ">" + a.label + "</a>", q.parseShareButtonOut && (f = q.parseShareButtonOut(a, f));
1184
                i.children[0].innerHTML = f, i.children[0].onclick = G
1185
            },
1186
            I = function (a) {
1187
                for (var c = 0; c < q.closeElClasses.length; c++)
1188
                    if (b.hasClass(a, "pswp__" + q.closeElClasses[c])) return !0
1189
            },
1190
            J = 0,
1191
            K = function () {
1192
                clearTimeout(u), J = 0, k && v.setIdle(!1)
1193
            },
1194
            L = function (a) {
1195
                a = a ? a : window.event;
1196
                var b = a.relatedTarget || a.toElement;
1197
                b && "HTML" !== b.nodeName || (clearTimeout(u), u = setTimeout(function () {
1198
                    v.setIdle(!0)
1199
                }, q.timeToIdleOutside))
1200
            },
1201
            M = function () {
1202
                q.fullscreenEl && !b.features.isOldAndroid && (c || (c = v.getFullscreenAPI()), c ? (b.bind(document, c.eventK, v.updateFullscreen), v.updateFullscreen(), b.addClass(a.template, "pswp--supports-fs")) : b.removeClass(a.template, "pswp--supports-fs"))
1203
            },
1204
            N = function () {
1205
                q.preloaderEl && (O(!0), l("beforeChange", function () {
1206
                    clearTimeout(o), o = setTimeout(function () {
1207
                        a.currItem && a.currItem.loading ? (!a.allowProgressiveImg() || a.currItem.img && !a.currItem.img.naturalWidth) && O(!1) : O(!0)
1208
                    }, q.loadingIndicatorDelay)
1209
                }), l("imageLoadComplete", function (b, c) {
1210
                    a.currItem === c && O(!0)
1211
                }))
1212
            },
1213
            O = function (a) {
1214
                n !== a && (C(m, "preloader--active", !a), n = a)
1215
            },
1216
            P = function (a) {
1217
                var c = a.vGap;
1218
                if (B()) {
1219
                    var g = q.barsSize;
1220
                    if (q.captionEl && "auto" === g.bottom)
1221
                        if (f || (f = b.createEl("pswp__caption pswp__caption--fake"), f.appendChild(b.createEl("pswp__caption__center")), d.insertBefore(f, e), b.addClass(d, "pswp__ui--fit")), q.addCaptionHTMLFn(a, f, !0)) {
1222
                            var h = f.clientHeight;
1223
                            c.bottom = parseInt(h, 10) || 44
1224
                        } else c.bottom = g.top;
1225
                    else c.bottom = "auto" === g.bottom ? 0 : g.bottom;
1226
                    c.top = g.top
1227
                } else c.top = c.bottom = 0
1228
            },
1229
            Q = function () {
1230
                q.timeToIdle && l("mouseUsed", function () {
1231
                    b.bind(document, "mousemove", K), b.bind(document, "mouseout", L), t = setInterval(function () {
1232
                        J++, 2 === J && v.setIdle(!0)
1233
                    }, q.timeToIdle / 2)
1234
                })
1235
            },
1236
            R = function () {
1237
                l("onVerticalDrag", function (a) {
1238
                    x && .95 > a ? v.hideControls() : !x && a >= .95 && v.showControls()
1239
                });
1240
                var a;
1241
                l("onPinchClose", function (b) {
1242
                    x && .9 > b ? (v.hideControls(), a = !0) : a && !x && b > .9 && v.showControls()
1243
                }), l("zoomGestureEnded", function () {
1244
                    a = !1, a && !x && v.showControls()
1245
                })
1246
            },
1247
            S = [{
1248
                name: "caption",
1249
                option: "captionEl",
1250
                onInit: function (a) {
1251
                    e = a
1252
                }
1253
            }, {
1254
                name: "share-modal",
1255
                option: "shareEl",
1256
                onInit: function (a) {
1257
                    i = a
1258
                },
1259
                onTap: function () {
1260
                    F()
1261
                }
1262
            }, {
1263
                name: "button--share",
1264
                option: "shareEl",
1265
                onInit: function (a) {
1266
                    h = a
1267
                },
1268
                onTap: function () {
1269
                    F()
1270
                }
1271
            }, {
1272
                name: "button--zoom",
1273
                option: "zoomEl",
1274
                onTap: a.toggleDesktopZoom
1275
            }, {
1276
                name: "counter",
1277
                option: "counterEl",
1278
                onInit: function (a) {
1279
                    g = a
1280
                }
1281
            }, {
1282
                name: "button--close",
1283
                option: "closeEl",
1284
                onTap: a.close
1285
            }, {
1286
                name: "button--arrow--left",
1287
                option: "arrowEl",
1288
                onTap: a.prev
1289
            }, {
1290
                name: "button--arrow--right",
1291
                option: "arrowEl",
1292
                onTap: a.next
1293
            }, {
1294
                name: "button--fs",
1295
                option: "fullscreenEl",
1296
                onTap: function () {
1297
                    c.isFullscreen() ? c.exit() : c.enter()
1298
                }
1299
            }, {
1300
                name: "preloader",
1301
                option: "preloaderEl",
1302
                onInit: function (a) {
1303
                    m = a
1304
                }
1305
            }],
1306
            T = function () {
1307
                var a, c, e, f = function (d) {
1308
                    if (d)
1309
                        for (var f = d.length, g = 0; f > g; g++) {
1310
                            a = d[g], c = a.className;
1311
                            for (var h = 0; h < S.length; h++) e = S[h], c.indexOf("pswp__" + e.name) > -1 && (q[e.option] ? (b.removeClass(a, "pswp__element--disabled"), e.onInit && e.onInit(a)) : b.addClass(a, "pswp__element--disabled"))
1312
                        }
1313
                };
1314
                f(d.children);
1315
                var g = b.getChildByClass(d, "pswp__top-bar");
1316
                g && f(g.children)
1317
            };
1318
        v.init = function () {
1319
            b.extend(a.options, z, !0), q = a.options, d = b.getChildByClass(a.scrollWrap, "pswp__ui"), l = a.listen, R(), l("beforeChange", v.update), l("doubleTap", function (b) {
1320
                var c = a.currItem.initialZoomLevel;
1321
                a.getZoomLevel() !== c ? a.zoomTo(c, b, 333) : a.zoomTo(q.getDoubleTapZoom(!1, a.currItem), b, 333)
1322
            }), l("preventDragEvent", function (a, b, c) {
1323
                var d = a.target || a.srcElement;
1324
                d && d.getAttribute("class") && a.type.indexOf("mouse") > -1 && (d.getAttribute("class").indexOf("__caption") > 0 || /(SMALL|STRONG|EM)/i.test(d.tagName)) && (c.prevent = !1)
1325
            }), l("bindEvents", function () {
1326
                b.bind(d, "pswpTap click", A), b.bind(a.scrollWrap, "pswpTap", v.onGlobalTap), a.likelyTouchDevice || b.bind(a.scrollWrap, "mouseover", v.onMouseOver)
1327
            }), l("unbindEvents", function () {
1328
                y || F(), t && clearInterval(t), b.unbind(document, "mouseout", L), b.unbind(document, "mousemove", K), b.unbind(d, "pswpTap click", A), b.unbind(a.scrollWrap, "pswpTap", v.onGlobalTap), b.unbind(a.scrollWrap, "mouseover", v.onMouseOver), c && (b.unbind(document, c.eventK, v.updateFullscreen), c.isFullscreen() && (q.hideAnimationDuration = 0, c.exit()), c = null)
1329
            }), l("destroy", function () {
1330
                q.captionEl && (f && d.removeChild(f), b.removeClass(e, "pswp__caption--empty")), i && (i.children[0].onclick = null), b.removeClass(d, "pswp__ui--over-close"), b.addClass(d, "pswp__ui--hidden"), v.setIdle(!1)
1331
            }), q.showAnimationDuration || b.removeClass(d, "pswp__ui--hidden"), l("initialZoomIn", function () {
1332
                q.showAnimationDuration && b.removeClass(d, "pswp__ui--hidden")
1333
            }), l("initialZoomOut", function () {
1334
                b.addClass(d, "pswp__ui--hidden")
1335
            }), l("parseVerticalMargin", P), T(), q.shareEl && h && i && (y = !0), D(), Q(), M(), N()
1336
        }, v.setIdle = function (a) {
1337
            k = a, C(d, "ui--idle", a)
1338
        }, v.update = function () {
1339
            x && a.currItem ? (v.updateIndexIndicator(), q.captionEl && (q.addCaptionHTMLFn(a.currItem, e), C(e, "caption--empty", !a.currItem.title)), w = !0) : w = !1, y || F(), D()
1340
        }, v.updateFullscreen = function (d) {
1341
            d && setTimeout(function () {
1342
                a.setScrollOffset(0, b.getScrollY())
1343
            }, 50), b[(c.isFullscreen() ? "add" : "remove") + "Class"](a.template, "pswp--fs")
1344
        }, v.updateIndexIndicator = function () {
1345
            q.counterEl && (g.innerHTML = a.getCurrentIndex() + 1 + q.indexIndicatorSep + q.getNumItemsFn())
1346
        }, v.onGlobalTap = function (c) {
1347
            c = c || window.event;
1348
            var d = c.target || c.srcElement;
1349
            if (!r)
1350
                if (c.detail && "mouse" === c.detail.pointerType) {
1351
                    if (I(d)) return void a.close();
1352
                    b.hasClass(d, "pswp__img") && (1 === a.getZoomLevel() && a.getZoomLevel() <= a.currItem.fitRatio ? q.clickToCloseNonZoomable && a.close() : a.toggleDesktopZoom(c.detail.releasePoint))
1353
                } else if (q.tapToToggleControls && (x ? v.hideControls() : v.showControls()), q.tapToClose && (b.hasClass(d, "pswp__img") || I(d))) return void a.close()
1354
        }, v.onMouseOver = function (a) {
1355
            a = a || window.event;
1356
            var b = a.target || a.srcElement;
1357
            C(d, "ui--over-close", I(b))
1358
        }, v.hideControls = function () {
1359
            b.addClass(d, "pswp__ui--hidden"), x = !1
1360
        }, v.showControls = function () {
1361
            x = !0, w || v.update(), b.removeClass(d, "pswp__ui--hidden")
1362
        }, v.supportsFullscreen = function () {
1363
            var a = document;
1364
            return !!(a.exitFullscreen || a.mozCancelFullScreen || a.webkitExitFullscreen || a.msExitFullscreen)
1365
        }, v.getFullscreenAPI = function () {
1366
            var b, c = document.documentElement,
1367
                d = "fullscreenchange";
1368
            return c.requestFullscreen ? b = {
1369
                enterK: "requestFullscreen",
1370
                exitK: "exitFullscreen",
1371
                elementK: "fullscreenElement",
1372
                eventK: d
1373
            } : c.mozRequestFullScreen ? b = {
1374
                enterK: "mozRequestFullScreen",
1375
                exitK: "mozCancelFullScreen",
1376
                elementK: "mozFullScreenElement",
1377
                eventK: "moz" + d
1378
            } : c.webkitRequestFullscreen ? b = {
1379
                enterK: "webkitRequestFullscreen",
1380
                exitK: "webkitExitFullscreen",
1381
                elementK: "webkitFullscreenElement",
1382
                eventK: "webkit" + d
1383
            } : c.msRequestFullscreen && (b = {
1384
                enterK: "msRequestFullscreen",
1385
                exitK: "msExitFullscreen",
1386
                elementK: "msFullscreenElement",
1387
                eventK: "MSFullscreenChange"
1388
            }), b && (b.enter = function () {
1389
                return j = q.closeOnScroll, q.closeOnScroll = !1, "webkitRequestFullscreen" !== this.enterK ? a.template[this.enterK]() : void a.template[this.enterK](Element.ALLOW_KEYBOARD_INPUT)
1390
            }, b.exit = function () {
1391
                return q.closeOnScroll = j, document[this.exitK]()
1392
            }, b.isFullscreen = function () {
1393
                return document[this.elementK]
1394
            }), b
1395
        }
1396
    };
1397
    return a
1398
});
1399
1400
var initPhotoSwipeFromDOM = function (gallerySelector) {
1401
1402
    // parse slide data (url, title, size ...) from DOM elements 
1403
    // (children of gallerySelector)
1404
    var parseThumbnailElements = function (el) {
1405
        var thumbElements = el.childNodes,
1406
            numNodes = thumbElements.length,
1407
            items = [],
1408
            figureEl,
1409
            linkEl,
1410
            size,
1411
            item;
1412
1413
        for (var i = 0; i < numNodes; i++) {
1414
1415
            figureEl = thumbElements[i]; // <figure> element
1416
1417
            // include only element nodes 
1418
            if (figureEl.nodeType !== 1) {
1419
                continue;
1420
            }
1421
1422
            linkEl = figureEl.children[0]; // <a> element
1423
1424
            size = linkEl.getAttribute('data-size').split('x');
1425
1426
            // create slide object
1427
            item = {
1428
                src: linkEl.getAttribute('href'),
1429
                w: parseInt(size[0], 10),
1430
                h: parseInt(size[1], 10)
1431
            };
1432
1433
1434
1435
            if (figureEl.children.length > 1) {
1436
                // <figcaption> content
1437
                item.title = figureEl.children[1].innerHTML;
1438
            }
1439
1440
            if (linkEl.children.length > 0) {
1441
                // <img> thumbnail element, retrieving thumbnail url
1442
                item.msrc = linkEl.children[0].getAttribute('src');
1443
            }
1444
1445
            item.el = figureEl; // save link to element for getThumbBoundsFn
1446
            items.push(item);
1447
        }
1448
1449
        return items;
1450
    };
1451
1452
    // find nearest parent element
1453
    var closest = function closest(el, fn) {
1454
        return el && (fn(el) ? el : closest(el.parentNode, fn));
1455
    };
1456
1457
    // triggers when user clicks on thumbnail
1458
    var onThumbnailsClick = function (e) {
1459
        e = e || window.event;
1460
        e.preventDefault ? e.preventDefault() : e.returnValue = false;
1461
1462
        var eTarget = e.target || e.srcElement;
1463
1464
        // find root element of slide
1465
        var clickedListItem = closest(eTarget, function (el) {
1466
            return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
1467
        });
1468
1469
        if (!clickedListItem) {
1470
            return;
1471
        }
1472
1473
        // find index of clicked item by looping through all child nodes
1474
        // alternatively, you may define index via data- attribute
1475
        var clickedGallery = clickedListItem.parentNode,
1476
            childNodes = clickedListItem.parentNode.childNodes,
1477
            numChildNodes = childNodes.length,
1478
            nodeIndex = 0,
1479
            index;
1480
1481
        for (var i = 0; i < numChildNodes; i++) {
1482
            if (childNodes[i].nodeType !== 1) {
1483
                continue;
1484
            }
1485
1486
            if (childNodes[i] === clickedListItem) {
1487
                index = nodeIndex;
1488
                break;
1489
            }
1490
            nodeIndex++;
1491
        }
1492
1493
1494
1495
        if (index >= 0) {
1496
            // open PhotoSwipe if valid index found
1497
            openPhotoSwipe(index, clickedGallery);
1498
        }
1499
        return false;
1500
    };
1501
1502
    // parse picture index and gallery index from URL (#&pid=1&gid=2)
1503
    var photoswipeParseHash = function () {
1504
        var hash = window.location.hash.substring(1),
1505
            params = {};
1506
1507
        if (hash.length < 5) {
1508
            return params;
1509
        }
1510
1511
        var vars = hash.split('&');
1512
        for (var i = 0; i < vars.length; i++) {
1513
            if (!vars[i]) {
1514
                continue;
1515
            }
1516
            var pair = vars[i].split('=');
1517
            if (pair.length < 2) {
1518
                continue;
1519
            }
1520
            params[pair[0]] = pair[1];
1521
        }
1522
1523
        if (params.gid) {
1524
            params.gid = parseInt(params.gid, 10);
1525
        }
1526
1527
        return params;
1528
    };
1529
1530
    var openPhotoSwipe = function (index, galleryElement, disableAnimation, fromURL) {
1531
        var pswpElement = document.querySelectorAll('.pswp')[0],
1532
            gallery,
1533
            options,
1534
            items;
1535
1536
        items = parseThumbnailElements(galleryElement);
1537
1538
        // define options (if needed)
1539
        options = {
1540
1541
            // define gallery index (for URL)
1542
            galleryUID: galleryElement.getAttribute('data-pswp-uid'),
1543
1544
            getThumbBoundsFn: function (index) {
1545
                // See Options -> getThumbBoundsFn section of documentation for more info
1546
                var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
1547
                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
1548
                    rect = thumbnail.getBoundingClientRect();
1549
1550
                return {
1551
                    x: rect.left,
1552
                    y: rect.top + pageYScroll,
1553
                    w: rect.width
1554
                };
1555
            }
1556
1557
        };
1558
1559
        // PhotoSwipe opened from URL
1560
        if (fromURL) {
1561
            if (options.galleryPIDs) {
1562
                // parse real index when custom PIDs are used 
1563
                // http://photoswipe.com/documentation/faq.html#custom-pid-in-url
1564
                for (var j = 0; j < items.length; j++) {
1565
                    if (items[j].pid == index) {
1566
                        options.index = j;
1567
                        break;
1568
                    }
1569
                }
1570
            } else {
1571
                // in URL indexes start from 1
1572
                options.index = parseInt(index, 10) - 1;
1573
            }
1574
        } else {
1575
            options.index = parseInt(index, 10);
1576
        }
1577
1578
        // exit if index not found
1579
        if (isNaN(options.index)) {
1580
            return;
1581
        }
1582
1583
        if (disableAnimation) {
1584
            options.showAnimationDuration = 0;
1585
        }
1586
1587
        // Pass data to PhotoSwipe and initialize it
1588
        gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
1589
        gallery.init();
1590
    };
1591
1592
    // loop through all gallery elements and bind events
1593
    var galleryElements = document.querySelectorAll(gallerySelector);
1594
1595
    for (var i = 0, l = galleryElements.length; i < l; i++) {
1596
        galleryElements[i].setAttribute('data-pswp-uid', i + 1);
1597
        galleryElements[i].onclick = onThumbnailsClick;
1598
    }
1599
1600
    // Parse URL and open gallery if it contains #&pid=3&gid=1
1601
    var hashData = photoswipeParseHash();
1602
    if (hashData.pid && hashData.gid) {
1603
        openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true);
1604
    }
1605
};
1606
1607
// execute above function
1608
initPhotoSwipeFromDOM('.mdb-lightbox');