PageSourceSearch

https://www.instruktornaukijazdy.pl/wp-content/plugins/custom-face…/assets/js/cff-scripts.js?ver=4.0.7

js instruktornaukijazdy.pl collected 2026-10-02 01:08:29 UTC 346,548 bytes, 5,467 lines download raw bytes

vendor: 40,521 bytes, lines 1-845
1var cff_js_exists = (typeof cff_js_exists !== 'undefined') ? true : false;
2if(!cff_js_exists){
3    if (typeof window.cff_block_editor !== 'undefined') {
4        cffmetatrans = false;
5        cffajaxurl = window.cff_block_editor.cffajaxurl;
6    }
7
8    /*! Hammer.JS - v2.0.8 - 2016-04-23
9        * http://hammerjs.github.io/
10        *
11        * Copyright (c) 2016 Jorik Tangelder;
12        * Licensed under the MIT license
13        * */
14    if (typeof cffnomobileswipe === 'undefined') {
15        !function (a, b, c, d) {
16            "use strict";
17
18            function e(a, b, c) {
19                return setTimeout(j(a, c), b)
20            }
21
22            function f(a, b, c) {
23                return Array.isArray(a) ? (g(a, c[b], c), !0) : !1
24            }
25
26            function g(a, b, c) {
27                var e;
28                if (a) if (a.forEach) a.forEach(b, c); else if (a.length !== d) for (e = 0; e < a.length;) b.call(c, a[e], e, a), e++; else for (e in a) a.hasOwnProperty(e) && b.call(c, a[e], e, a)
29            }
30
31            function h(b, c, d) {
32                var e = "DEPRECATED METHOD: " + c + "\n" + d + " AT \n";
33                return function () {
34                    var c = new Error("get-stack-trace"),
35                        d = c && c.stack ? c.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace",
36                        f = a.console && (a.console.warn || a.console.log);
37                    return f && f.call(a.console, e, d), b.apply(this, arguments)
38                }
39            }
40
41            function i(a, b, c) {
42                var d, e = b.prototype;
43                d = a.prototype = Object.create(e), d.constructor = a, d._super = e, c && la(d, c)
44            }
45
46            function j(a, b) {
47                return function () {
48                    return a.apply(b, arguments)
49                }
50            }
51
52            function k(a, b) {
53                return typeof a == oa ? a.apply(b ? b[0] || d : d, b) : a
54            }
55
56            function l(a, b) {
57                return a === d ? b : a
58            }
59
60            function m(a, b, c) {
61                g(q(b), function (b) {
62                    a.addEventListener(b, c, !1)
63                })
64            }
65
66            function n(a, b, c) {
67                g(q(b), function (b) {
68                    a.removeEventListener(b, c, !1)
69                })
70            }
71
72            function o(a, b) {
73                for (; a;) {
74                    if (a == b) return !0;
75                    a = a.parentNode
76                }
77                return !1
78            }
79
80            function p(a, b) {
81                return a.indexOf(b) > -1
82            }
83
84            function q(a) {
85                return a.trim().split(/\s+/g)
86            }
87
88            function r(a, b, c) {
89                if (a.indexOf && !c) return a.indexOf(b);
90                for (var d = 0; d < a.length;) {
91                    if (c && a[d][c] == b || !c && a[d] === b) return d;
92                    d++
93                }
94                return -1
95            }
96
97            function s(a) {
98                return Array.prototype.slice.call(a, 0)
99            }
100
101            function t(a, b, c) {
102                for (var d = [], e = [], f = 0; f < a.length;) {
103                    var g = b ? a[f][b] : a[f];
104                    r(e, g) < 0 && d.push(a[f]), e[f] = g, f++
105                }
106                return c && (d = b ? d.sort(function (a, c) {
107                    return a[b] > c[b]
108                }) : d.sort()), d
109            }
110
111            function u(a, b) {
112                for (var c, e, f = b[0].toUpperCase() + b.slice(1), g = 0; g < ma.length;) {
113                    if (c = ma[g], e = c ? c + f : b, e in a) return e;
114                    g++
115                }
116                return d
117            }
118
119            function v() {
120                return ua++
121            }
122
123            function w(b) {
124                var c = b.ownerDocument || b;
125                return c.defaultView || c.parentWindow || a
126            }
127
128            function x(a, b) {
129                var c = this;
130                this.manager = a, this.callback = b, this.element = a.element, this.target = a.options.inputTarget, this.domHandler = function (b) {
131                    k(a.options.enable, [a]) && c.handler(b)
132                }, this.init()
133            }
134
135            function y(a) {
136                var b, c = a.options.inputClass;
137                return new (b = c ? c : xa ? M : ya ? P : wa ? R : L)(a, z)
138            }
139
140            function z(a, b, c) {
141                var d = c.pointers.length, e = c.changedPointers.length, f = b & Ea && d - e === 0,
142                    g = b & (Ga | Ha) && d - e === 0;
143                c.isFirst = !!f, c.isFinal = !!g, f && (a.session = {}), c.eventType = b, A(a, c), a.emit("hammer.input", c), a.recognize(c), a.session.prevInput = c
144            }
145
146            function A(a, b) {
147                var c = a.session, d = b.pointers, e = d.length;
148                c.firstInput || (c.firstInput = D(b)), e > 1 && !c.firstMultiple ? c.firstMultiple = D(b) : 1 === e && (c.firstMultiple = !1);
149                var f = c.firstInput, g = c.firstMultiple, h = g ? g.center : f.center, i = b.center = E(d);
150                b.timeStamp = ra(), b.deltaTime = b.timeStamp - f.timeStamp, b.angle = I(h, i), b.distance = H(h, i), B(c, b), b.offsetDirection = G(b.deltaX, b.deltaY);
151                var j = F(b.deltaTime, b.deltaX, b.deltaY);
152                b.overallVelocityX = j.x, b.overallVelocityY = j.y, b.overallVelocity = qa(j.x) > qa(j.y) ? j.x : j.y, b.scale = g ? K(g.pointers, d) : 1, b.rotation = g ? J(g.pointers, d) : 0, b.maxPointers = c.prevInput ? b.pointers.length > c.prevInput.maxPointers ? b.pointers.length : c.prevInput.maxPointers : b.pointers.length, C(c, b);
153                var k = a.element;
154                o(b.srcEvent.target, k) && (k = b.srcEvent.target), b.target = k
155            }
156
157            function B(a, b) {
158                var c = b.center, d = a.offsetDelta || {}, e = a.prevDelta || {}, f = a.prevInput || {};
159                b.eventType !== Ea && f.eventType !== Ga || (e = a.prevDelta = {
160                    x: f.deltaX || 0,
161                    y: f.deltaY || 0
162                }, d = a.offsetDelta = {x: c.x, y: c.y}), b.deltaX = e.x + (c.x - d.x), b.deltaY = e.y + (c.y - d.y)
163            }
164
165            function C(a, b) {
166                var c, e, f, g, h = a.lastInterval || b, i = b.timeStamp - h.timeStamp;
167                if (b.eventType != Ha && (i > Da || h.velocity === d)) {
168                    var j = b.deltaX - h.deltaX, k = b.deltaY - h.deltaY, l = F(i, j, k);
169                    e = l.x, f = l.y, c = qa(l.x) > qa(l.y) ? l.x : l.y, g = G(j, k), a.lastInterval = b
170                } else c = h.velocity, e = h.velocityX, f = h.velocityY, g = h.direction;
171                b.velocity = c, b.velocityX = e, b.velocityY = f, b.direction = g
172            }
173
174            function D(a) {
175                for (var b = [], c = 0; c < a.pointers.length;) b[c] = {
176                    clientX: pa(a.pointers[c].clientX),
177                    clientY: pa(a.pointers[c].clientY)
178                }, c++;
179                return {timeStamp: ra(), pointers: b, center: E(b), deltaX: a.deltaX, deltaY: a.deltaY}
180            }
181
182            function E(a) {
183                var b = a.length;
184                if (1 === b) return {x: pa(a[0].clientX), y: pa(a[0].clientY)};
185                for (var c = 0, d = 0, e = 0; b > e;) c += a[e].clientX, d += a[e].clientY, e++;
186                return {x: pa(c / b), y: pa(d / b)}
187            }
188
189            function F(a, b, c) {
190                return {x: b / a || 0, y: c / a || 0}
191            }
192
193            function G(a, b) {
194                return a === b ? Ia : qa(a) >= qa(b) ? 0 > a ? Ja : Ka : 0 > b ? La : Ma
195            }
196
197            function H(a, b, c) {
198                c || (c = Qa);
199                var d = b[c[0]] - a[c[0]], e = b[c[1]] - a[c[1]];
200                return Math.sqrt(d * d + e * e)
201            }
202
203            function I(a, b, c) {
204                c || (c = Qa);
205                var d = b[c[0]] - a[c[0]], e = b[c[1]] - a[c[1]];
206                return 180 * Math.atan2(e, d) / Math.PI
207            }
208
209            function J(a, b) {
210                return I(b[1], b[0], Ra) + I(a[1], a[0], Ra)
211            }
212
213            function K(a, b) {
214                return H(b[0], b[1], Ra) / H(a[0], a[1], Ra)
215            }
216
217            function L() {
218                this.evEl = Ta, this.evWin = Ua, this.pressed = !1, x.apply(this, arguments)
219            }
220
221            function M() {
222                this.evEl = Xa, this.evWin = Ya, x.apply(this, arguments), this.store = this.manager.session.pointerEvents = []
223            }
224
225            function N() {
226                this.evTarget = $a, this.evWin = _a, this.started = !1, x.apply(this, arguments)
227            }
228
229            function O(a, b) {
230                var c = s(a.touches), d = s(a.changedTouches);
231                return b & (Ga | Ha) && (c = t(c.concat(d), "identifier", !0)), [c, d]
232            }
233
234            function P() {
235                this.evTarget = bb, this.targetIds = {}, x.apply(this, arguments)
236            }
237
238            function Q(a, b) {
239                var c = s(a.touches), d = this.targetIds;
240                if (b & (Ea | Fa) && 1 === c.length) return d[c[0].identifier] = !0, [c, c];
241                var e, f, g = s(a.changedTouches), h = [], i = this.target;
242                if (f = c.filter(function (a) {
243                    return o(a.target, i)
244                }), b === Ea) for (e = 0; e < f.length;) d[f[e].identifier] = !0, e++;
245                for (e = 0; e < g.length;) d[g[e].identifier] && h.push(g[e]), b & (Ga | Ha) && delete d[g[e].identifier], e++;
246                return h.length ? [t(f.concat(h), "identifier", !0), h] : void 0
247            }
248
249            function R() {
250                x.apply(this, arguments);
251                var a = j(this.handler, this);
252                this.touch = new P(this.manager, a), this.mouse = new L(this.manager, a), this.primaryTouch = null, this.lastTouches = []
253            }
254
255            function S(a, b) {
256                a & Ea ? (this.primaryTouch = b.changedPointers[0].identifier, T.call(this, b)) : a & (Ga | Ha) && T.call(this, b)
257            }
258
259            function T(a) {
260                var b = a.changedPointers[0];
261                if (b.identifier === this.primaryTouch) {
262                    var c = {x: b.clientX, y: b.clientY};
263                    this.lastTouches.push(c);
264                    var d = this.lastTouches, e = function () {
265                        var a = d.indexOf(c);
266                        a > -1 && d.splice(a, 1)
267                    };
268                    setTimeout(e, cb)
269                }
270            }
271
272            function U(a) {
273                for (var b = a.srcEvent.clientX, c = a.srcEvent.clientY, d = 0; d < this.lastTouches.length; d++) {
274                    var e = this.lastTouches[d], f = Math.abs(b - e.x), g = Math.abs(c - e.y);
275                    if (db >= f && db >= g) return !0
276                }
277                return !1
278            }
279
280            function V(a, b) {
281                this.manager = a, this.set(b)
282            }
283
284            function W(a) {
285                if (p(a, jb)) return jb;
286                var b = p(a, kb), c = p(a, lb);
287                return b && c ? jb : b || c ? b ? kb : lb : p(a, ib) ? ib : hb
288            }
289
290            function X() {
291                if (!fb) return !1;
292                var b = {}, c = a.CSS && a.CSS.supports;
293                return ["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach(function (d) {
294                    b[d] = c ? a.CSS.supports("touch-action", d) : !0
295                }), b
296            }
297
298            function Y(a) {
299                this.options = la({}, this.defaults, a || {}), this.id = v(), this.manager = null, this.options.enable = l(this.options.enable, !0), this.state = nb, this.simultaneous = {}, this.requireFail = []
300            }
301
302            function Z(a) {
303                return a & sb ? "cancel" : a & qb ? "end" : a & pb ? "move" : a & ob ? "start" : ""
304            }
305
306            function $(a) {
307                return a == Ma ? "down" : a == La ? "up" : a == Ja ? "left" : a == Ka ? "right" : ""
308            }
309
310            function _(a, b) {
311                var c = b.manager;
312                return c ? c.get(a) : a
313            }
314
315            function aa() {
316                Y.apply(this, arguments)
317            }
318
319            function ba() {
320                aa.apply(this, arguments), this.pX = null, this.pY = null
321            }
322
323            function ca() {
324                aa.apply(this, arguments)
325            }
326
327            function da() {
328                Y.apply(this, arguments), this._timer = null, this._input = null
329            }
330
331            function ea() {
332                aa.apply(this, arguments)
333            }
334
335            function fa() {
336                aa.apply(this, arguments)
337            }
338
339            function ga() {
340                Y.apply(this, arguments), this.pTime = !1, this.pCenter = !1, this._timer = null, this._input = null, this.count = 0
341            }
342
343            function ha(a, b) {
344                return b = b || {}, b.recognizers = l(b.recognizers, ha.defaults.preset), new ia(a, b)
345            }
346
347            function ia(a, b) {
348                this.options = la({}, ha.defaults, b || {}), this.options.inputTarget = this.options.inputTarget || a, this.handlers = {}, this.session = {}, this.recognizers = [], this.oldCssProps = {}, this.element = a, this.input = y(this), this.touchAction = new V(this, this.options.touchAction), ja(this, !0), g(this.options.recognizers, function (a) {
349                    var b = this.add(new a[0](a[1]));
350                    a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3])
351                }, this)
352            }
353
354            function ja(a, b) {
355                var c = a.element;
356                if (c.style) {
357                    var d;
358                    g(a.options.cssProps, function (e, f) {
359                        d = u(c.style, f), b ? (a.oldCssProps[d] = c.style[d], c.style[d] = e) : c.style[d] = a.oldCssProps[d] || ""
360                    }), b || (a.oldCssProps = {})
361                }
362            }
363
364            function ka(a, c) {
365                var d = b.createEvent("Event");
366                d.initEvent(a, !0, !0), d.gesture = c, c.target.dispatchEvent(d)
367            }
368
369            var la, ma = ["", "webkit", "Moz", "MS", "ms", "o"], na = b.createElement("div"), oa = "function",
370                pa = Math.round, qa = Math.abs, ra = Date.now;
371            la = "function" != typeof Object.assign ? function (a) {
372                if (a === d || null === a) throw new TypeError("Cannot convert undefined or null to object");
373                for (var b = Object(a), c = 1; c < arguments.length; c++) {
374                    var e = arguments[c];
375                    if (e !== d && null !== e) for (var f in e) e.hasOwnProperty(f) && (b[f] = e[f])
376                }
377                return b
378            } : Object.assign;
379            var sa = h(function (a, b, c) {
380                    for (var e = Object.keys(b), f = 0; f < e.length;) (!c || c && a[e[f]] === d) && (a[e[f]] = b[e[f]]), f++;
381                    return a
382                }, "extend", "Use `assign`."), ta = h(function (a, b) {
383                    return sa(a, b, !0)
384                }, "merge", "Use `assign`."), ua = 1, va = /mobile|tablet|ip(ad|hone|od)|android/i,
385                wa = "ontouchstart" in a, xa = u(a, "PointerEvent") !== d, ya = wa && va.test(navigator.userAgent),
386                za = "touch", Aa = "pen", Ba = "mouse", Ca = "kinect", Da = 25, Ea = 1, Fa = 2, Ga = 4, Ha = 8, Ia = 1,
387                Ja = 2, Ka = 4, La = 8, Ma = 16, Na = Ja | Ka, Oa = La | Ma, Pa = Na | Oa, Qa = ["x", "y"],
388                Ra = ["clientX", "clientY"];
389            x.prototype = {
390                handler: function () {
391                }, init: function () {
392                    this.evEl && m(this.element, this.evEl, this.domHandler), this.evTarget && m(this.target, this.evTarget, this.domHandler), this.evWin && m(w(this.element), this.evWin, this.domHandler)
393                }, destroy: function () {
394                    this.evEl && n(this.element, this.evEl, this.domHandler), this.evTarget && n(this.target, this.evTarget, this.domHandler), this.evWin && n(w(this.element), this.evWin, this.domHandler)
395                }
396            };
397            var Sa = {mousedown: Ea, mousemove: Fa, mouseup: Ga}, Ta = "mousedown", Ua = "mousemove mouseup";
398            i(L, x, {
399                handler: function (a) {
400                    var b = Sa[a.type];
401                    b & Ea && 0 === a.button && (this.pressed = !0), b & Fa && 1 !== a.which && (b = Ga), this.pressed && (b & Ga && (this.pressed = !1), this.callback(this.manager, b, {
402                        pointers: [a],
403                        changedPointers: [a],
404                        pointerType: Ba,
405                        srcEvent: a
406                    }))
407                }
408            });
409            var Va = {pointerdown: Ea, pointermove: Fa, pointerup: Ga, pointercancel: Ha, pointerout: Ha},
410                Wa = {2: za, 3: Aa, 4: Ba, 5: Ca}, Xa = "pointerdown", Ya = "pointermove pointerup pointercancel";
411            a.MSPointerEvent && !a.PointerEvent && (Xa = "MSPointerDown", Ya = "MSPointerMove MSPointerUp MSPointerCancel"), i(M, x, {
412                handler: function (a) {
413                    var b = this.store, c = !1, d = a.type.toLowerCase().replace("ms", ""), e = Va[d],
414                        f = Wa[a.pointerType] || a.pointerType, g = f == za, h = r(b, a.pointerId, "pointerId");
415                    e & Ea && (0 === a.button || g) ? 0 > h && (b.push(a), h = b.length - 1) : e & (Ga | Ha) && (c = !0), 0 > h || (b[h] = a, this.callback(this.manager, e, {
416                        pointers: b,
417                        changedPointers: [a],
418                        pointerType: f,
419                        srcEvent: a
420                    }), c && b.splice(h, 1))
421                }
422            });
423            var Za = {touchstart: Ea, touchmove: Fa, touchend: Ga, touchcancel: Ha}, $a = "touchstart",
424                _a = "touchstart touchmove touchend touchcancel";
425            i(N, x, {
426                handler: function (a) {
427                    var b = Za[a.type];
428                    if (b === Ea && (this.started = !0), this.started) {
429                        var c = O.call(this, a, b);
430                        b & (Ga | Ha) && c[0].length - c[1].length === 0 && (this.started = !1), this.callback(this.manager, b, {
431                            pointers: c[0],
432                            changedPointers: c[1],
433                            pointerType: za,
434                            srcEvent: a
435                        })
436                    }
437                }
438            });
439            var ab = {touchstart: Ea, touchmove: Fa, touchend: Ga, touchcancel: Ha},
440                bb = "touchstart touchmove touchend touchcancel";
441            i(P, x, {
442                handler: function (a) {
443                    var b = ab[a.type], c = Q.call(this, a, b);
444                    c && this.callback(this.manager, b, {
445                        pointers: c[0],
446                        changedPointers: c[1],
447                        pointerType: za,
448                        srcEvent: a
449                    })
450                }
451            });
452            var cb = 2500, db = 25;
453            i(R, x, {
454                handler: function (a, b, c) {
455                    var d = c.pointerType == za, e = c.pointerType == Ba;
456                    if (!(e && c.sourceCapabilities && c.sourceCapabilities.firesTouchEvents)) {
457                        if (d) S.call(this, b, c); else if (e && U.call(this, c)) return;
458                        this.callback(a, b, c)
459                    }
460                }, destroy: function () {
461                    this.touch.destroy(), this.mouse.destroy()
462                }
463            });
464            var eb = u(na.style, "touchAction"), fb = eb !== d, gb = "compute", hb = "auto", ib = "manipulation",
465                jb = "none", kb = "pan-x", lb = "pan-y", mb = X();
466            V.prototype = {
467                set: function (a) {
468                    a == gb && (a = this.compute()), fb && this.manager.element.style && mb[a] && (this.manager.element.style[eb] = a), this.actions = a.toLowerCase().trim()
469                }, update: function () {
470                    this.set(this.manager.options.touchAction)
471                }, compute: function () {
472                    var a = [];
473                    return g(this.manager.recognizers, function (b) {
474                        k(b.options.enable, [b]) && (a = a.concat(b.getTouchAction()))
475                    }), W(a.join(" "))
476                }, preventDefaults: function (a) {
477                    var b = a.srcEvent, c = a.offsetDirection;
478                    if (this.manager.session.prevented) return void b.preventDefault();
479                    var d = this.actions, e = p(d, jb) && !mb[jb], f = p(d, lb) && !mb[lb], g = p(d, kb) && !mb[kb];
480                    if (e) {
481                        var h = 1 === a.pointers.length, i = a.distance < 2, j = a.deltaTime < 250;
482                        if (h && i && j) return
483                    }
484                    return g && f ? void 0 : e || f && c & Na || g && c & Oa ? this.preventSrc(b) : void 0
485                }, preventSrc: function (a) {
486                    this.manager.session.prevented = !0, a.preventDefault()
487                }
488            };
489            var nb = 1, ob = 2, pb = 4, qb = 8, rb = qb, sb = 16, tb = 32;
490            Y.prototype = {
491                defaults: {}, set: function (a) {
492                    return la(this.options, a), this.manager && this.manager.touchAction.update(), this
493                }, recognizeWith: function (a) {
494                    if (f(a, "recognizeWith", this)) return this;
495                    var b = this.simultaneous;
496                    return a = _(a, this), b[a.id] || (b[a.id] = a, a.recognizeWith(this)), this
497                }, dropRecognizeWith: function (a) {
498                    return f(a, "dropRecognizeWith", this) ? this : (a = _(a, this), delete this.simultaneous[a.id], this)
499                }, requireFailure: function (a) {
500                    if (f(a, "requireFailure", this)) return this;
501                    var b = this.requireFail;
502                    return a = _(a, this), -1 === r(b, a) && (b.push(a), a.requireFailure(this)), this
503                }, dropRequireFailure: function (a) {
504                    if (f(a, "dropRequireFailure", this)) return this;
505                    a = _(a, this);
506                    var b = r(this.requireFail, a);
507                    return b > -1 && this.requireFail.splice(b, 1), this
508                }, hasRequireFailures: function () {
509                    return this.requireFail.length > 0
510                }, canRecognizeWith: function (a) {
511                    return !!this.simultaneous[a.id]
512                }, emit: function (a) {
513                    function b(b) {
514                        c.manager.emit(b, a)
515                    }
516
517                    var c = this, d = this.state;
518                    qb > d && b(c.options.event + Z(d)), b(c.options.event), a.additionalEvent && b(a.additionalEvent), d >= qb && b(c.options.event + Z(d))
519                }, tryEmit: function (a) {
520                    return this.canEmit() ? this.emit(a) : void (this.state = tb)
521                }, canEmit: function () {
522                    for (var a = 0; a < this.requireFail.length;) {
523                        if (!(this.requireFail[a].state & (tb | nb))) return !1;
524                        a++
525                    }
526                    return !0
527                }, recognize: function (a) {
528                    var b = la({}, a);
529                    return k(this.options.enable, [this, b]) ? (this.state & (rb | sb | tb) && (this.state = nb), this.state = this.process(b), void (this.state & (ob | pb | qb | sb) && this.tryEmit(b))) : (this.reset(), void (this.state = tb))
530                }, process: function (a) {
531                }, getTouchAction: function () {
532                }, reset: function () {
533                }
534            }, i(aa, Y, {
535                defaults: {pointers: 1}, attrTest: function (a) {
536                    var b = this.options.pointers;
537                    return 0 === b || a.pointers.length === b
538                }, process: function (a) {
539                    var b = this.state, c = a.eventType, d = b & (ob | pb), e = this.attrTest(a);
540                    return d && (c & Ha || !e) ? b | sb : d || e ? c & Ga ? b | qb : b & ob ? b | pb : ob : tb
541                }
542            }), i(ba, aa, {
543                defaults: {event: "pan", threshold: 10, pointers: 1, direction: Pa},
544                getTouchAction: function () {
545                    var a = this.options.direction, b = [];
546                    return a & Na && b.push(lb), a & Oa && b.push(kb), b
547                },
548                directionTest: function (a) {
549                    var b = this.options, c = !0, d = a.distance, e = a.direction, f = a.deltaX, g = a.deltaY;
550                    return e & b.direction || (b.direction & Na ? (e = 0 === f ? Ia : 0 > f ? Ja : Ka, c = f != this.pX, d = Math.abs(a.deltaX)) : (e = 0 === g ? Ia : 0 > g ? La : Ma, c = g != this.pY, d = Math.abs(a.deltaY))), a.direction = e, c && d > b.threshold && e & b.direction
551                },
552                attrTest: function (a) {
553                    return aa.prototype.attrTest.call(this, a) && (this.state & ob || !(this.state & ob) && this.directionTest(a))
554                },
555                emit: function (a) {
556                    this.pX = a.deltaX, this.pY = a.deltaY;
557                    var b = $(a.direction);
558                    b && (a.additionalEvent = this.options.event + b), this._super.emit.call(this, a)
559                }
560            }), i(ca, aa, {
561                defaults: {event: "pinch", threshold: 0, pointers: 2}, getTouchAction: function () {
562                    return [jb]
563                }, attrTest: function (a) {
564                    return this._super.attrTest.call(this, a) && (Math.abs(a.scale - 1) > this.options.threshold || this.state & ob)
565                }, emit: function (a) {
566                    if (1 !== a.scale) {
567                        var b = a.scale < 1 ? "in" : "out";
568                        a.additionalEvent = this.options.event + b
569                    }
570                    this._super.emit.call(this, a)
571                }
572            }), i(da, Y, {
573                defaults: {event: "press", pointers: 1, time: 251, threshold: 9},
574                getTouchAction: function () {
575                    return [hb]
576                },
577                process: function (a) {
578                    var b = this.options, c = a.pointers.length === b.pointers, d = a.distance < b.threshold,
579                        f = a.deltaTime > b.time;
580                    if (this._input = a, !d || !c || a.eventType & (Ga | Ha) && !f) this.reset(); else if (a.eventType & Ea) this.reset(), this._timer = e(function () {
581                        this.state = rb, this.tryEmit()
582                    }, b.time, this); else if (a.eventType & Ga) return rb;
583                    return tb
584                },
585                reset: function () {
586                    clearTimeout(this._timer)
587                },
588                emit: function (a) {
589                    this.state === rb && (a && a.eventType & Ga ? this.manager.emit(this.options.event + "up", a) : (this._input.timeStamp = ra(), this.manager.emit(this.options.event, this._input)))
590                }
591            }), i(ea, aa, {
592                defaults: {event: "rotate", threshold: 0, pointers: 2}, getTouchAction: function () {
593                    return [jb]
594                }, attrTest: function (a) {
595                    return this._super.attrTest.call(this, a) && (Math.abs(a.rotation) > this.options.threshold || this.state & ob)
596                }
597            }), i(fa, aa, {
598                defaults: {event: "swipe", threshold: 10, velocity: .3, direction: Na | Oa, pointers: 1},
599                getTouchAction: function () {
600                    return ba.prototype.getTouchAction.call(this)
601                },
602                attrTest: function (a) {
603                    var b, c = this.options.direction;
604                    return c & (Na | Oa) ? b = a.overallVelocity : c & Na ? b = a.overallVelocityX : c & Oa && (b = a.overallVelocityY), this._super.attrTest.call(this, a) && c & a.offsetDirection && a.distance > this.options.threshold && a.maxPointers == this.options.pointers && qa(b) > this.options.velocity && a.eventType & Ga
605                },
606                emit: function (a) {
607                    var b = $(a.offsetDirection);
608                    b && this.manager.emit(this.options.event + b, a), this.manager.emit(this.options.event, a)
609                }
610            }), i(ga, Y, {
611                defaults: {
612                    event: "tap",
613                    pointers: 1,
614                    taps: 1,
615                    interval: 300,
616                    time: 250,
617                    threshold: 9,
618                    posThreshold: 10
619                }, getTouchAction: function () {
620                    return [ib]
621                }, process: function (a) {
622                    var b = this.options, c = a.pointers.length === b.pointers, d = a.distance < b.threshold,
623                        f = a.deltaTime < b.time;
624                    if (this.reset(), a.eventType & Ea && 0 === this.count) return this.failTimeout();
625                    if (d && f && c) {
626                        if (a.eventType != Ga) return this.failTimeout();
627                        var g = this.pTime ? a.timeStamp - this.pTime < b.interval : !0,
628                            h = !this.pCenter || H(this.pCenter, a.center) < b.posThreshold;
629                        this.pTime = a.timeStamp, this.pCenter = a.center, h && g ? this.count += 1 : this.count = 1, this._input = a;
630                        var i = this.count % b.taps;
631                        if (0 === i) return this.hasRequireFailures() ? (this._timer = e(function () {
632                            this.state = rb, this.tryEmit()
633                        }, b.interval, this), ob) : rb
634                    }
635                    return tb
636                }, failTimeout: function () {
637                    return this._timer = e(function () {
638                        this.state = tb
639                    }, this.options.interval, this), tb
640                }, reset: function () {
641                    clearTimeout(this._timer)
642                }, emit: function () {
643                    this.state == rb && (this._input.tapCount = this.count, this.manager.emit(this.options.event, this._input))
644                }
645            }), ha.VERSION = "2.0.8", ha.defaults = {
646                domEvents: !1,
647                touchAction: gb,
648                enable: !0,
649                inputTarget: null,
650                inputClass: null,
651                preset: [[ea, {enable: !1}], [ca, {enable: !1}, ["rotate"]], [fa, {direction: Na}], [ba, {direction: Na}, ["swipe"]], [ga], [ga, {
652                    event: "doubletap",
653                    taps: 2
654                }, ["tap"]], [da]],
655                cssProps: {
656                    userSelect: "none",
657                    touchSelect: "none",
658                    touchCallout: "none",
659                    contentZooming: "none",
660                    userDrag: "none",
661                    tapHighlightColor: "rgba(0,0,0,0)"
662                }
663            };
664            var ub = 1, vb = 2;
665            ia.prototype = {
666                set: function (a) {
667                    return la(this.options, a), a.touchAction && this.touchAction.update(), a.inputTarget && (this.input.destroy(), this.input.target = a.inputTarget, this.input.init()), this
668                }, stop: function (a) {
669                    this.session.stopped = a ? vb : ub
670                }, recognize: function (a) {
671                    var b = this.session;
672                    if (!b.stopped) {
673                        this.touchAction.preventDefaults(a);
674                        var c, d = this.recognizers, e = b.curRecognizer;
675                        (!e || e && e.state & rb) && (e = b.curRecognizer = null);
676                        for (var f = 0; f < d.length;) c = d[f], b.stopped === vb || e && c != e && !c.canRecognizeWith(e) ? c.reset() : c.recognize(a), !e && c.state & (ob | pb | qb) && (e = b.curRecognizer = c), f++
677                    }
678                }, get: function (a) {
679                    if (a instanceof Y) return a;
680                    for (var b = this.recognizers, c = 0; c < b.length; c++) if (b[c].options.event == a) return b[c];
681                    return null
682                }, add: function (a) {
683                    if (f(a, "add", this)) return this;
684                    var b = this.get(a.options.event);
685                    return b && this.remove(b), this.recognizers.push(a), a.manager = this, this.touchAction.update(), a
686                }, remove: function (a) {
687                    if (f(a, "remove", this)) return this;
688                    if (a = this.get(a)) {
689                        var b = this.recognizers, c = r(b, a);
690                        -1 !== c && (b.splice(c, 1), this.touchAction.update())
691                    }
692                    return this
693                }, on: function (a, b) {
694                    if (a !== d && b !== d) {
695                        var c = this.handlers;
696                        return g(q(a), function (a) {
697                            c[a] = c[a] || [], c[a].push(b)
698                        }), this
699                    }
700                }, off: function (a, b) {
701                    if (a !== d) {
702                        var c = this.handlers;
703                        return g(q(a), function (a) {
704                            b ? c[a] && c[a].splice(r(c[a], b), 1) : delete c[a]
705                        }), this
706                    }
707                }, emit: function (a, b) {
708                    this.options.domEvents && ka(a, b);
709                    var c = this.handlers[a] && this.handlers[a].slice();
710                    if (c && c.length) {
711                        b.type = a, b.preventDefault = function () {
712                            b.srcEvent.preventDefault()
713                        };
714                        for (var d = 0; d < c.length;) c[d](b), d++
715                    }
716                }, destroy: function () {
717                    this.element && ja(this, !1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null
718                }
719            }, la(ha, {
720                INPUT_START: Ea,
721                INPUT_MOVE: Fa,
722                INPUT_END: Ga,
723                INPUT_CANCEL: Ha,
724                STATE_POSSIBLE: nb,
725                STATE_BEGAN: ob,
726                STATE_CHANGED: pb,
727                STATE_ENDED: qb,
728                STATE_RECOGNIZED: rb,
729                STATE_CANCELLED: sb,
730                STATE_FAILED: tb,
731                DIRECTION_NONE: Ia,
732                DIRECTION_LEFT: Ja,
733                DIRECTION_RIGHT: Ka,
734                DIRECTION_UP: La,
735                DIRECTION_DOWN: Ma,
736                DIRECTION_HORIZONTAL: Na,
737                DIRECTION_VERTICAL: Oa,
738                DIRECTION_ALL: Pa,
739                Manager: ia,
740                Input: x,
741                TouchAction: V,
742                TouchInput: P,
743                MouseInput: L,
744                PointerEventInput: M,
745                TouchMouseInput: R,
746                SingleTouchInput: N,
747                Recognizer: Y,
748                AttrRecognizer: aa,
749                Tap: ga,
750                Pan: ba,
751                Swipe: fa,
752                Pinch: ca,
753                Rotate: ea,
754                Press: da,
755                on: m,
756                off: n,
757                each: g,
758                merge: ta,
759                extend: sa,
760                assign: la,
761                inherit: i,
762                bindFn: j,
763                prefixed: u
764            });
765            var wb = "undefined" != typeof a ? a : "undefined" != typeof self ? self : {};
766            wb.Hammer = ha, "function" == typeof define && define.amd ? define(function () {
767                return ha
768            }) : "undefined" != typeof module && module.exports ? module.exports = ha : a[c] = ha
769        }(window, document, "Hammer");
770        (function (factory) {
771            if (typeof define === 'function' && define.amd) {
772                define(['jquery', 'hammerjs'], factory);
773            } else if (typeof exports === 'object') {
774                factory(require('jquery'), require('hammerjs'));
775            } else {
776                factory(jQuery, Hammer);
777            }
778        }(function (jQuery, Hammer) {
779            function hammerify(el, options) {
780                var $el = jQuery(el);
781                if (!$el.data("hammer")) {
782                    $el.data("hammer", new Hammer($el[0], options));
783                }
784            }
785
786            jQuery.fn.hammer = function (options) {
787                return this.each(function () {
788                    hammerify(this, options);
789                });
790            };
791
792            // extend the emit method to also trigger jQuery events
793            Hammer.Manager.prototype.emit = (function (originalEmit) {
794                return function (type, data) {
795                    originalEmit.call(this, type, data);
796                    jQuery(this.element).trigger({
797                        type: type,
798                        gesture: data
799                    });
800                };
801            })(Hammer.Manager.prototype.emit);
802        }));
803
804    } else {
805        var Hammer = {
806            Manager: {
807                prototype: {}
808            }
809        };
810        (function (factory) {
811            if (typeof define === 'function' && define.amd) {
812                define(['jquery', 'hammerjs'], factory);
813            } else if (typeof exports === 'object') {
814                factory(require('jquery'), require('hammerjs'));
815            } else {
816                factory(jQuery, Hammer);
817            }
818        }(function (jQuery, Hammer) {
819            function hammerify(el, options) {
820            }
821
822            jQuery.fn.hammer = function (options) {
823                return this.each(function () {
824                    hammerify(this, options);
825                });
826            };
827            // extend the emit method to also trigger jQuery events
828            Hammer.Manager.prototype.emit = (function (originalEmit) {
829                return function (type, data) {
830                    originalEmit.call(this, type, data);
831                    jQuery(this.element).trigger({
832                        type: type,
833                        gesture: data
834                    });
835                };
836            })(Hammer.Manager.prototype.emit);
837        }));
838    }
839
840//Only load the Masonry code if there's a masonry feed on the page
841    if( jQuery('#cff.cff-masonry-js').length || typeof window.cff_block_editor !== 'undefined'){
842        //Masonry
843        !function(a){function b(){}
844            function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}
845                function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.c
845all(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}
846                    return this}
847                    return this.each(function(){var d=a.data(this,b);d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d))})}}
848                if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}
849            var d=Array.prototype.slice;"function"==typeof define&&define.amd?define("jquery-bridget/jquery.bridget",["jquery"],c):c("object"==typeof exports?require("jquery"):a.jQuery)}(window),function(a){function b(b){var c=a.event;return c.target=c.target||c.srcElement||b,c}
850            var c=document.documentElement,d=function(){};c.addEventListener?d=function(a,b,c){a.addEventListener(b,c,!1)}:c.attachEvent&&(d=function(a,c,d){a[c+d]=d.handleEvent?function(){var c=b(a);d.handleEvent.call(d,c)}:function(){var c=b(a);d.call(a,c)},a.attachEvent("on"+c,a[c+d])});var e=function(){};c.removeEventListener?e=function(a,b,c){a.removeEventListener(b,c,!1)}:c.detachEvent&&(e=function(a,b,c){a.detachEvent("on"+b,a[b+c]);try{delete a[b+c]}catch(d){a[b+c]=void 0}});var f={bind:d,unbind:e};"function"==typeof define&&define.amd?define("eventie/eventie",f):"object"==typeof exports?module.exports=f:a.eventie=f}(window),function(){function a(){}
851            function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}
852            function c(a){return function(){return this[a].apply(this,arguments)}}
853            var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this),function(a){function b(a){if(a){if("string"==typeof d[a])return a;a=a.charAt(0).toUpperCase()+a.slice(1);for(var b,e=0,f=c.length;f>e;e++)if(b=c[e]+a,"string"==typeof d[b])return b}}
854            var c="Webkit Moz ms Ms O".split(" "),d=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return b}):"object"==typeof exports?module.exports=b:a.getStyleProperty=b}(window),function(a){function b(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}
855            function c(){}
856            function d(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=g.length;c>b;b++){var d=g[b];a[d]=0}
857                return a}
858            function e(c){function e(){if(!m){m=!0;var d=a.getComputedStyle;if(j=function(){var a=d?function(a){return d(a,null)}:function(a){return a.currentStyle};return function(b){var c=a(b);return c||f("Style returned "+c+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),c}}(),k=c("boxSizing")){var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style[k]="border-box";var g=document.body||document.documentElement;g.appendChild(e);var h=j(e);l=200===b(h.width),g.removeChild(e)}}}
859                function h(a){if(e(),"string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var c=j(a);if("none"===c.display)return d();var f={};f.width=a.offsetWidth,f.height=a.offsetHeight;for(var h=f.isBorderBox=!(!k||!c[k]||"border-box"!==c[k]),m=0,n=g.length;n>m;m++){var o=g[m],p=c[o];p=i(a,p);var q=parseFloat(p);f[o]=isNaN(q)?0:q}
860                    var r=f.paddingLeft+f.paddingRight,s=f.paddingTop+f.paddingBottom,t=f.marginLeft+f.marginRight,u=f.marginTop+f.marginBottom,v=f.borderLeftWidth+f.borderRightWidth,w=f.borderTopWidth+f.borderBottomWidth,x=h&&l,y=b(c.width);y!==!1&&(f.width=y+(x?0:r+v));var z=b(c.height);return z!==!1&&(f.height=z+(x?0:s+w)),f.innerWidth=f.width-(r+v),f.innerHeight=f.height-(s+w),f.outerWidth=f.width+t,f.outerHeight=f.height+u,f}}
861                function i(b,c){if(a.getComputedStyle||-1===c.indexOf("%"))return c;var d=b.style,e=d.left,f=b.runtimeStyle,g=f&&f.left;return g&&(f.left=b.currentStyle.left),d.left=c,c=d.pixelLeft,d.left=e,g&&(f.left=g),c}
862                var j,k,l,m=!1;return h}
863            var f="undefined"==typeof console?c:function(a){console.error(a)},g=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],e):"object"==typeof exports?module.exports=e(require("desandro-get-style-property")):a.getSize=e(a.getStyleProperty)}(window),function(a){function b(a){"function"==typeof a&&(b.isReady?a():g.push(a))}
864            function c(a){var c="readystatechange"===a.type&&"complete"!==f.readyState;b.isReady||c||d()}
865            function d(){b.isReady=!0;for(var a=0,c=g.length;c>a;a++){var d=g[a];d()}}
866            function e(e){return"complete"===f.readyState?d():(e.bind(f,"DOMContentLoaded",c),e.bind(f,"readystatechange",c),e.bind(a,"load",c)),b}
867            var f=a.document,g=[];b.isReady=!1,"function"==typeof define&&define.amd?define("doc-ready/doc-ready",["eventie/eventie"],e):"object"==typeof exports?module.exports=e(require("eventie")):a.docReady=e(a.eventie)}(window),function(a){function b(a,b){return a[g](b)}
868            function c(a){if(!a.parentNode){var b=document.createDocumentFragment();b.appendChild(a)}}
869            function d(a,b){c(a);for(var d=a.parentNode.querySelectorAll(b),e=0,f=d.length;f>e;e++)if(d[e]===a)return!0;return!1}
870            function e(a,d){return c(a),b(a,d)}
871            var f,g=function(){if(a.matches)return"matches";if(a.matchesSelector)return"matchesSelector";for(var b=["webkit","moz","ms","o"],c=0,d=b.length;d>c;c++){var e=b[c],f=e+"MatchesSelector";if(a[f])return f}}();if(g){var h=document.createElement("div"),i=b(h,"div");f=i?b:e}else f=d;"function"==typeof define&&define.amd?define("matches-selector/matches-selector",[],function(){return f}):"object"==typeof exports?module.exports=f:window.matchesSelector=f}(Element.prototype),function(a,b){"function"==typeof define&&define.amd?define("fizzy-ui-utils/utils",["doc-ready/doc-ready","matches-selector/matches-selector"],function(c,d){return b(a,c,d)}):"object"==typeof exports?module.exports=b(a,require("doc-ready"),require("desandro-matches-selector")):a.fizzyUIUtils=b(a,a.docReady,a.matchesSelector)}(window,function(a,b,c){var d={};d.extend=function(a,b){for(var c in b)a[c]=b[c];return a},d.modulo=function(a,b){return(a%b+b)%b};var e=Object.prototype.toString;d.isArray=function(a){return"[object Array]"==e.call(a)},d.makeArray=function(a){var b=[];if(d.isArray(a))b=a;else if(a&&"number"==typeof a.length)for(var c=0,e=a.length;e>c;c++)b.push(a[c]);else b.push(a);return b},d.indexOf=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},d.removeFrom=function(a,b){var c=d.indexOf(a,b);-1!=c&&a.splice(c,1)},d.isElement="function"==typeof HTMLElement||"object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1==a.nodeType&&"string"==typeof a.nodeName},d.setText=function(){function a(a,c){b=b||(void 0!==document.documentElement.textContent?"textContent":"innerText"),a[b]=c}
872            var b;return a}(),d.getParent=function(a,b){for(;a!=document.body;)if(a=a.parentNode,c(a,b))return a},d.getQueryElement=function(a){return"string"==typeof a?document.querySelector(a):a},d.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},d.filterFindElements=function(a,b){a=d.makeArray(a);for(var e=[],f=0,g=a.length;g>f;f++){var h=a[f];if(d.isElement(h))if(b){c(h,b)&&e.push(h);for(var i=h.querySelectorAll(b),j=0,k=i.length;k>j;j++)e.push(i[j])}else e.push(h)}
873            return e},d.debounceMethod=function(a,b,c){var d=a.prototype[b],e=b+"Timeout";a.prototype[b]=function(){var a=this[e];a&&clearTimeout(a);var b=arguments,f=this;this[e]=setTimeout(function(){d.apply(f,b),delete f[e]},c||100)}},d.toDashed=function(a){return a.replace(/(.)([A-Z])/g,function(a,b,c){return b+"-"+c}).toLowerCase()};var f=a.console;return d.htmlInit=function(c,e){b(function(){for(var b=d.toDashed(e),g=document.querySelectorAll(".js-"+b),h="data-"+b+"-options",i=0,j=g.length;j>i;i++){var k,l=g[i],m=l.getAttribute(h);try{k=m&&JSON.parse(m)}catch(n){f&&f.error("Error parsing "+h+" on "+l.nodeName.toLowerCase()+(l.id?"#"+l.id:"")+": "+n);continue}
874            var o=new c(l,k),p=a.jQuery;p&&p.data(l,e,o)}})},d}),function(a,b){"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property","fizzy-ui-utils/utils"],function(c,d,e,f){return b(a,c,d,e,f)}):"object"==typeof exports?module.exports=b(a,require("wolfy87-eventemitter"),require("get-size"),require("desandro-get-style-property"),require("fizzy-ui-utils")):(a.Outlayer={}
874,a.Outlayer.Item=b(a,a.EventEmitter,a.getSize,a.getStyleProperty,a.fizzyUIUtils))}(window,function(a,b,c,d,e){function f(a){for(var b in a)return!1;return b=null,!0}
875            function g(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}
876            var h=a.getComputedStyle,i=h?function(a){return h(a,null)}:function(a){return a.currentStyle},j=d("transition"),k=d("transform"),l=j&&k,m=!!d("perspective"),n={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[j],o=["transform","transition","transitionDuration","transitionProperty"],p=function(){for(var a={},b=0,c=o.length;c>b;b++){var e=o[b],f=d(e);f&&f!==e&&(a[e]=f)}
877                return a}();e.extend(g.prototype,b.prototype),g.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},g.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},g.prototype.getSize=function(){this.size=c(this.element)},g.prototype.css=function(a){var b=this.element.style;for(var c in a){var d=p[c]||c;b[d]=a[c]}},g.prototype.getPosition=function(){var a=i(this.element),b=this.layout.options,c=b.isOriginLeft,d=b.isOriginTop,e=parseInt(a[c?"left":"right"],10),f=parseInt(a[d?"top":"bottom"],10);e=isNaN(e)?0:e,f=isNaN(f)?0:f;var g=this.layout.size;e-=c?g.paddingLeft:g.paddingRight,f-=d?g.paddingTop:g.paddingBottom,this.position.x=e,this.position.y=f},g.prototype.layoutPosition=function(){var a=this.layout.size,b=this.layout.options,c={},d=b.isOriginLeft?"paddingLeft":"paddingRight",e=b.isOriginLeft?"left":"right",f=b.isOriginLeft?"right":"left",g=this.position.x+a[d];g=b.percentPosition&&!b.isHorizontal?g/a.width*100+"%":g+"px",c[e]=g,c[f]="";var h=b.isOriginTop?"paddingTop":"paddingBottom",i=b.isOriginTop?"top":"bottom",j=b.isOriginTop?"bottom":"top",k=this.position.y+a[h];k=b.percentPosition&&b.isHorizontal?k/a.height*100+"%":k+"px",c[i]=k,c[j]="",this.css(c),this.emitEvent("layout",[this])};var q=m?function(a,b){return"translate3d("+a+"px, "+b+"px, 0)"}:function(a,b){return"translate("+a+"px, "+b+"px)"};g.prototype._transitionTo=function(a,b){this.getPosition();var c=this.position.x,d=this.position.y,e=parseInt(a,10),f=parseInt(b,10),g=e===this.position.x&&f===this.position.y;if(this.setPosition(a,b),g&&!this.isTransitioning)return void this.layoutPosition();var h=a-c,i=b-d,j={},k=this.layout.options;h=k.isOriginLeft?h:-h,i=k.isOriginTop?i:-i,j.transform=q(h,i),this.transition({to:j,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},g.prototype.goTo=function(a,b){this.setPosition(a,b),this.layoutPosition()},g.prototype.moveTo=l?g.prototype._transitionTo:g.prototype.goTo,g.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10),this.position.y=parseInt(b,10)},g.prototype._nonTransition=function(a){this.css(a.to),a.isCleaning&&this._removeStyles(a.to);for(var b in a.onTransitionEnd)a.onTransitionEnd[b].call(this)},g.prototype._transition=function(a){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(a);var b=this._transn;for(var c in a.onTransitionEnd)b.onEnd[c]=a.onTransitionEnd[c];for(c in a.to)b.ingProperties[c]=!0,a.isCleaning&&(b.clean[c]=!0);if(a.from){this.css(a.from);var d=this.element.offsetHeight;d=null}
878                this.enableTransition(a.to),this.css(a.to),this.isTransitioning=!0};var r=k&&e.toDashed(k)+",opacity";g.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:r,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(n,this,!1))},g.prototype.transition=g.prototype[j?"_transition":"_nonTransition"],g.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)},g.prototype.onotransitionend=function(a){this.ontransitionend(a)};var s={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};g.prototype.ontransitionend=function(a){if(a.target===this.element){var b=this._transn,c=s[a.propertyName]||a.propertyName;if(delete b.ingProperties[c],f(b.ingProperties)&&this.disableTransition(),c in b.clean&&(this.element.style[a.propertyName]="",delete b.clean[c]),c in b.onEnd){var d=b.onEnd[c];d.call(this),delete b.onEnd[c]}
879                this.emitEvent("transitionEnd",[this])}},g.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(n,this,!1),this.isTransitioning=!1},g.prototype._removeStyles=function(a){var b={};for(var c in a)b[c]="";this.css(b)};var t={transitionProperty:"",transitionDuration:""};return g.prototype.removeTransitionStyles=function(){this.css(t)},g.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.css({display:""}),this.emitEvent("remove",[this])},g.prototype.remove=function(){if(!j||!parseFloat(this.layout.options.transitionDuration))return void this.removeElem();var a=this;this.once("transitionEnd",function(){a.removeElem()}),this.hide()},g.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var a=this.layout.options,b={}
879,c=this.getHideRevealTransitionEndProperty("visibleStyle");b[c]=this.onRevealTransitionEnd,this.transition({from:a.hiddenStyle,to:a.visibleStyle,isCleaning:!0,onTransitionEnd:b})},g.prototype.onRevealTransitionEnd=function(){this.isHidden||this.emitEvent("reveal")},g.prototype.getHideRevealTransitionEndProperty=function(a){var b=this.layout.options[a];if(b.opacity)return"opacity";for(var c in b)return c},g.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var a=this.layout.options,b={},c=this.getHideRevealTransitionEndProperty("hiddenStyle");b[c]=this.onHideTransitionEnd,this.transition({from:a.visibleStyle,to:a.hiddenStyle,isCleaning:!0,onTransitionEnd:b})},g.prototype.onHideTransitionEnd=function(){this.isHidden&&(this.css({display:"none"}),this.emitEvent("hide"))},g.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},g}),function(a,b){"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","eventEmitter/EventEmitter","get-size/get-size","fizzy-ui-utils/utils","./item"],function(c,d,e,f,g){return b(a,c,d,e,f,g)}):"object"==typeof exports?module.exports=b(a,require("eventie"),require("wolfy87-eventemitter"),require("get-size"),require("fizzy-ui-utils"),require("./item")):a.Outlayer=b(a,a.eventie,a.EventEmitter,a.getSize,a.fizzyUIUtils,a.Outlayer.Item)}(window,function(a,b,c,d,e,f){function g(a,b){var c=e.getQueryElement(a);if(!c)return void(h&&h.error("Bad element for "+this.constructor.namespace+": "+(c||a)));this.element=c,i&&(this.$element=i(this.element)),this.options=e.extend({},this.constructor.defaults),this.option(b);var d=++k;this.element.outlayerGUID=d,l[d]=this,this._create(),this.options.isInitLayout&&this.layout()}
880            var h=a.console,i=a.jQuery,j=function(){},k=0,l={};return g.namespace="outlayer",g.Item=f,g.defaults={containerStyle:{position:"relative"},isInitLayout:!0,isOriginLeft:!0,isOriginTop:!0,isResizeBound:!0,isResizingContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}},e.extend(g.prototype,c.prototype),g.prototype.option=function(a){e.extend(this.options,a)},g.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),e.extend(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},g.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},g.prototype._itemize=function(a){for(var b=this._filterFindItemElements(a),c=this.constructor.Item,d=[],e=0,f=b.length;f>e;e++){var g=b[e],h=new c(g,this);d.push(h)}
881                return d},g.prototype._filterFindItemElements=function(a){return e.filterFindElements(a,this.options.itemSelector)},g.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;c>b;b++)a.push(this.items[b].element);return a},g.prototype.layout=function(){this._resetLayout(),this._manageStamps();var a=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;this.layoutItems(this.items,a),this._isLayoutInited=!0},g.prototype._init=g.prototype.layout,g.prototype._resetLayout=function(){this.getSize()},g.prototype.getSize=function(){this.size=d(this.element)},g.prototype._getMeasurement=function(a,b){var c,f=this.options[a];f?("string"==typeof f?c=this.element.querySelector(f):e.isElement(f)&&(c=f),this[a]=c?d(c)[b]:f):this[a]=0},g.prototype.layoutItems=function(a,b){a=this._getItemsForLayout(a),this._layoutItems(a,b),this._postLayout()},g.prototype._getItemsForLayout=function(a){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c];e.isIgnored||b.push(e)}
882                return b},g.prototype._layoutItems=function(a,b){if(this._emitCompleteOnItems("layout",a),a&&a.length){for(var c=[],d=0,e=a.length;e>d;d++){var f=a[d],g=this._getItemLayoutPosition(f);g.item=f,g.isInstant=b||f.isLayoutInstant,c.push(g)}
883                this._processLayoutQueue(c)}},g.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},g.prototype._processLayoutQueue=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];this._positionItem(d.item,d.x,d.y,d.isInstant)}},g.prototype._positionItem=function(a,b,c,d){d?a.goTo(b,c):a.moveTo(b,c)},g.prototype._postLayout=function(){this.resizeContainer()},g.prototype.resizeContainer=function(){if(this.options.isResizingContainer){var a=this._getContainerSize();a&&(this._setContainerMeasure(a.width,!0),this._setContainerMeasure(a.height,!1))}},g.prototype._getContainerSize=j,g.prototype._setContainerMeasure=function(a,b){if(void 0!==a){var c=this.size;c.isBorderBox&&(a+=b?c.paddingLeft+c.paddingRight+c.borderLeftWidth+c.borderRightWidth:c.paddingBottom+c.paddingTop+c.borderTopWidth+c.borderBottomWidth),a=Math.max(a,0),this.element.style[b?"width":"height"]=a+"px"}},g.prototype._emitCompleteOnItems=function(a,b){function c(){e.emitEvent(a+"Complete",[b])}
884                function d(){g++,g===f&&c()}
885                var e=this,f=b.length;if(!b||!f)return void c();for(var g=0,h=0,i=b.length;i>h;h++){var j=b[h];j.once(a,d)}},g.prototype.ignore=function(a){var b=this.getItem(a);b&&(b.isIgnored=!0)},g.prototype.unignore=function(a){var b=this.getItem(a);b&&delete b.isIgnored}
885,g.prototype.stamp=function(a){if(a=this._find(a)){this.stamps=this.stamps.concat(a);for(var b=0,c=a.length;c>b;b++){var d=a[b];this.ignore(d)}}},g.prototype.unstamp=function(a){if(a=this._find(a))for(var b=0,c=a.length;c>b;b++){var d=a[b];e.removeFrom(this.stamps,d),this.unignore(d)}},g.prototype._find=function(a){return a?("string"==typeof a&&(a=this.element.querySelectorAll(a)),a=e.makeArray(a)):void 0},g.prototype._manageStamps=function(){if(this.stamps&&this.stamps.length){this._getBoundingRect();for(var a=0,b=this.stamps.length;b>a;a++){var c=this.stamps[a];this._manageStamp(c)}}},g.prototype._getBoundingRect=function(){var a=this.element.getBoundingClientRect(),b=this.size;this._boundingRect={left:a.left+b.paddingLeft+b.borderLeftWidth,top:a.top+b.paddingTop+b.borderTopWidth,right:a.right-(b.paddingRight+b.borderRightWidth),bottom:a.bottom-(b.paddingBottom+b.borderBottomWidth)}},g.prototype._manageStamp=j,g.prototype._getElementOffset=function(a){var b=a.getBoundingClientRect(),c=this._boundingRect,e=d(a),f={left:b.left-c.left-e.marginLeft,top:b.top-c.top-e.marginTop,right:c.right-b.right-e.marginRight,bottom:c.bottom-b.bottom-e.marginBottom};return f},g.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},g.prototype.bindResize=function(){this.isResizeBound||(b.bind(a,"resize",this),this.isResizeBound=!0)},g.prototype.unbindResize=function(){this.isResizeBound&&b.unbind(a,"resize",this),this.isResizeBound=!1},g.prototype.onresize=function(){function a(){b.resize(),delete b.resizeTimeout}
886                this.resizeTimeout&&clearTimeout(this.resizeTimeout);var b=this;this.resizeTimeout=setTimeout(a,100)},g.prototype.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},g.prototype.needsResizeLayout=function(){var a=d(this.element),b=this.size&&a;return b&&a.innerWidth!==this.size.innerWidth},g.prototype.addItems=function(a){var b=this._itemize(a);return b.length&&(this.items=this.items.concat(b)),b},g.prototype.appended=function(a){var b=this.addItems(a);b.length&&(this.layoutItems(b,!0),this.reveal(b))},g.prototype.prepended=function(a){var b=this._itemize(a);if(b.length){var c=this.items.slice(0);this.items=b.concat(c),this._resetLayout(),this._manageStamps(),this.layoutItems(b,!0),this.reveal(b),this.layoutItems(c)}},g.prototype.reveal=function(a){this._emitCompleteOnItems("reveal",a);for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.reveal()}},g.prototype.hide=function(a){this._emitCompleteOnItems("hide",a);for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.hide()}},g.prototype.revealItemElements=function(a){var b=this.getItems(a);this.reveal(b)},g.prototype.hideItemElements=function(a){var b=this.getItems(a);this.hide(b)},g.prototype.getItem=function(a){for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];if(d.element===a)return d}},g.prototype.getItems=function(a){a=e.makeArray(a);for(var b=[],c=0,d=a.length;d>c;c++){var f=a[c],g=this.getItem(f);g&&b.push(g)}
887                return b},g.prototype.remove=function(a){var b=this.getItems(a);if(this._emitCompleteOnItems("remove",b),b&&b.length)for(var c=0,d=b.length;d>c;c++){var f=b[c];f.remove(),e.removeFrom(this.items,f)}},g.prototype.destroy=function(){var a=this.element.style;a.height="",a.position="",a.width="";for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];d.destroy()}
888                this.unbindResize();var e=this.element.outlayerGUID;delete l[e],delete this.element.outlayerGUID,i&&i.removeData(this.element,this.constructor.namespace)},g.data=function(a){a=e.getQueryElement(a);var b=a&&a.outlayerGUID;return b&&l[b]}
888,g.create=function(a,b){function c(){g.apply(this,arguments)}
889                return Object.create?c.prototype=Object.create(g.prototype):e.extend(c.prototype,g.prototype),c.prototype.constructor=c,c.defaults=e.extend({},g.defaults),e.extend(c.defaults,b),c.prototype.settings={},c.namespace=a,c.data=g.data,c.Item=function(){f.apply(this,arguments)},c.Item.prototype=new f,e.htmlInit(c,a),i&&i.bridget&&i.bridget(a,c),c},g.Item=f,g}),function(a,b){"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size","fizzy-ui-utils/utils"],b):"object"==typeof exports?module.exports=b(require("outlayer"),require("get-size"),require("fizzy-ui-utils")):a.Masonry=b(a.Outlayer,a.getSize,a.fizzyUIUtils)}(window,function(a,b,c){var d=a.create("masonry");return d.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns();var a=this.cols;for(this.colYs=[];a--;)this.colYs.push(0);this.maxY=0},d.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var a=this.items[0],c=a&&a.element;this.columnWidth=c&&b(c).outerWidth||this.containerWidth}
890            var d=this.columnWidth+=this.gutter,e=this.containerWidth+this.gutter,f=e/d,g=d-e%d,h=g&&1>g?"round":"floor";f=Math[h](f),this.cols=Math.max(f,1)},d.prototype.getContainerWidth=function(){var a=this.options.isFitWidth?this.element.parentNode:this.element,c=b(a);this.containerWidth=c&&c.innerWidth},d.prototype._getItemLayoutPosition=function(a){a.getSize();var b=a.size.outerWidth%this.columnWidth,d=b&&1>b?"round":"ceil",e=Math[d](a.size.outerWidth/this.columnWidth);e=Math.min(e,this.cols);for(var f=this._getColGroup(e),g=Math.min.apply(Math,f),h=c.indexOf(f,g),i={x:this.columnWidth*h,y:g},j=g+a.size.outerHeight,k=this.cols+1-f.length,l=0;k>l;l++)this.colYs[h+l]=j;return i},d.prototype._getColGroup=function(a){if(2>a)return this.colYs;for(var b=[],c=this.cols+1-a,d=0;c>d;d++){var e=this.colYs.slice(d,d+a);b[d]=Math.max.apply(Math,e)}
891            return b},d.prototype._manageStamp=function(a){var c=b(a),d=this._getElementOffset(a),e=this.options.isOriginLeft?d.left:d.right,f=e+c.outerWidth,g=Math.floor(e/this.columnWidth);g=Math.max(0,g);var h=Math.floor(f/this.columnWidth);h-=f%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var i=(this.options.isOriginTop?d.top:d.bottom)+c.outerHeight,j=g;h>=j;j++)this.colYs[j]=Math.max(i,this.colYs[j])},d.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var a={height:this.maxY};return this.options.isFitWidth&&(a.width=this._getContainerFitWidth()),a},d.prototype._getContainerFitWidth=function(){for(var a=0,b=this.cols;--b&&0===this.colYs[b];)a++;return(this.cols-a)*this.columnWidth-this.gutter},d.prototype.needsResizeLayout=function(){var a=this.containerWidth;return this.getContainerWidth(),a!==this.containerWidth},d})
892
893        function cffAddMasonry($self) {
894
895            var evt = jQuery.Event('cffbeforemasonry');
896            evt.$self = $self;
897            jQuery(window).trigger(evt);
898
899            if (typeof $self.masonry !== 'function') {
900                return;
901            }
902            var windowWidth = jQuery(window).width(),
903                masonryEnabled = false;
904
905            if (windowWidth > 800) {
906                if ($self.hasClass('masonry-1-desktop')) {
907                    $self.addClass('cff-disable-masonry');
908                } else {
909                    masonryEnabled = true;
910                    $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
911                }
912            } else if (windowWidth > 400) {
913                if ($self.hasClass('masonry-2-tablet')
914                    || $self.hasClass('masonry-3-tablet')
915                    || $self.hasClass('masonry-4-tablet')
916                    || $self.hasClass('masonry-5-tablet')
917                    || $self.hasClass('masonry-6-tablet')) {
918                    masonryEnabled = true;
919                    $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
920                } else {
921                    $self.addClass('cff-disable-masonry');
922                }
923            } else {
924                if ($self.hasClass('masonry-2-mobile')
925                    || $self.hasClass('masonry-3-mobile')) {
926                    masonryEnabled = true;
927                    $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
928                } else {
929                    $self.addClass('cff-disable-masonry');
930                }
931            }
932
933            if ($self.hasClass('cff-masonry')) {
934                $self.find('.cff-album-item a').removeAttr('style');
935            }
936
937            if (masonryEnabled) {
938                if($self.find('.cff-item').length) {
939                    window.cffMasonrySettings.itemSelector = '.cff-new, .cff
939-item, .cff-likebox';
940                    $self.masonry(window.cffMasonrySettings);
941                    // Add margin to the bottom of each post to give some space
942                    $self.find('.cff-item').each( function() {
943                        jQuery(this).css('margin-bottom', '15px');
944                    });
945                } else if($self.find('.cff-album-item').length) {
946                    window.cffMasonrySettings.itemSelector = '.cff-album-item, .cff-likebox';
947                    $self.masonry(window.cffMasonrySettings);
948                }
949            }
950        }
951
952    } //End Masonry code
953
954    window.cffMasonrySettings = {itemSelector: '.cff-album-item' };
955
956    function Cff() {
957        this.feeds = {};
958        this.options = {};
959    }
960
961    Cff.prototype = {
962        createPage: function (createFeeds, createFeedsArgs) {
963
964            if (typeof window.cffOptions === 'undefined'
965                || typeof window.cffOptions.resized_url === 'undefined') {
966                window.cffOptions = {
967                    resized_url: location.protocol + '//' + window.location.hostname + "/wp-content/uploads/sb-facebook-feed-images/",
968                    placeholder: location.protocol + '//' + window.location.hostname + "/wp-content/plugins/custom-facebook-feed-pro/assets/img/placeholder.png",
969                }
970            }
971
972            createFeeds(createFeedsArgs);
973        },
974        createFeeds: function (args) {
975            jQuery('.cff').each(function (index) {
976                jQuery(this).attr('data-cff-index', index + 1);
977                var $self = jQuery(this),
978                    flags = typeof $self.attr('data-cff-flags') !== 'undefined' ? $self.attr('data-cff-flags').split(',') : [];
979                var feedOptions = {
980                    feedID : $self.find('.cff_resized_image_data').attr('data-feedid'),
981                    shortCodeAtts : $self.attr('data-cff-shortcode'),
982                    resizingEnabled : $self.find('.cff_resized_image_data').length,
983                    page: 1,
984                    pag_url : '',
985                    gdpr : (flags.indexOf('gdpr') > -1),
986                    overrideBlockCDN : (flags.indexOf('overrideBlockCDN') > -1),
987                    consentGiven : false,
988                    locator : (flags.indexOf('locator') > -1),
989                    postID : typeof $self.attr( 'data-postid' ) !== 'undefind' ? $self.attr( 'data-postid' ) : 'unknown',
990                };
991
992                window.cff.feeds[index] = new CffFeed(this, index, feedOptions);
993                if (typeof window.cff.feeds[index].setResizedImages !== 'undefined') {
994                    window.cff.feeds[index].setResizedImages();
995                }
996                if (typeof window.cff.feeds[index].setResizedImages !== 'undefined') {
997                    window.cff.feeds[index].init();
998                }
999            });
1000        },
1001
1002    };
1003
1004    function CffFeed(el, index, settings) {
1005        this.el = el;
1006        this.index = index;
1007        this.settings = settings;
1008        this.resizedImages = {};
1009        this.needsResizing = [];
1010        this.imagesWaiting = 0;
1011    }
1012
1013    CffFeed.prototype = {
1014        init: function() {
1015            var feed = this;
1016            feed.settings.consentGiven = feed.checkConsent();
1017            if (!feed.settings.consentGiven) {
1018                if (jQuery(this.el).find('.cff-load-more').is(':visible')) {
1019                    jQuery(this.el).find('.cff-load-more').hide().addClass('cff-no-consent-hide');
1020                }
1021                var $wrapper = jQuery(this.el).closest('.cff-wrapper');
1022                if ($wrapper.find('.cff-visual-header').length) {
1023                    $wrapper.find('.cff-header-text').closest('.cff-visual-header').addClass('cff-no-consent');
1024                }
1025                $wrapper.find('.fb-video').addClass('cff-no-consent');
1026
1027                setTimeout(function() {
1028                    feed.settings.consentGiven = feed.checkConsent();
1029                    if (feed.settings.consentGiven) {
1030                        feed.addFullFeatures();
1031                    }
1032                },1000);
1033            }
1034
1035            var cff_delay = (function () {
1036                var cff_timer = 0;
1037                return function (cff_callback, cff_ms) {
1038                    clearTimeout(cff_timer);
1039                    cff_timer = setTimeout(cff_callback, cff_ms);
1040                };
1041            })();
1042            this.afterInitialImagesLoaded();
1043            jQuery(window).on('resize', function () {
1044                cff_delay(function () {
1045                    feed.afterResize();
1046                }, 500);
1047            });
1048
1049            jQuery(this.el).find('.cff-item').each(function() {
1050                feed.lazyLoadCheck(jQuery(this));
1051            });
1052
1053        },
1054        addFullFeatures: function() {
1055            var $ = jQuery,
1056                $self = jQuery(this.el);
1057            jQuery('.cff-gdpr-notice').remove();
1058
1059            jQuery(this.el).find('.cff-author-img').each(function() {
1060                $(this).find('img').attr('src',$(this).attr('data-avatar'));
1061                $(this).removeClass('cff-no-consent');
1062            });
1063            jQuery('.fb-video.cff-no-consent').removeClass('cff-no-consent');
1064
1065            if (jQuery('.cff-visual-header').length) {
1066                jQuery('.cff-visual-header').each(function() {
1067                    jQuery(this).removeClass('cff-no-consent');
1068                    if (jQuery(this).find('.cff-header-hero').length) {
1069                        jQuery(this).find('.cff-header-hero').find('img').attr('src',jQuery(this).find('.cff-header-hero').find('img').attr('data-cover-url'))
1070                    }
1071                    if (jQuery(this).find('.cff-header-img').length) {
1072                        jQuery(this).find('.cff-header-img').find('img').attr('src',jQuery(this).find('.cff-header-img').find('img').attr('data-avatar'))
1073                    }
1074                });
1075
1076
1077            }
1078            jQuery('.cff-comment:visible').each(function() {
1079                var $thisComment = jQuery(this); // here
1080                var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
1081                if (consentGiven) {
1082                    $thisComment.find('.cff-comment-img:not(.cff-comment-reply-img) a, .cff-comment-img:not(.cff-comment-reply-img) span').html('<img src="' + $thisComment.attr("data-avatar") + '" alt="Avatar" onerror="this.style.display=\'none\'" />');
1083                }
1084            });
1085
1086            //cff-comment-image-placeholder, <img src="'+commentItem.attachment.media.image.src+'" alt=""/>
1087            jQuery('.cff-comment-image-placeholder').each(function() {
1088                jQuery(this).replaceWith('<img src="'+jQuery(this).attr('data-src')+'" alt="Attachement"/>');
1089            });
1090            //
1091            jQuery('.cff-likebox iframe').each(function(){
1092                var $likebox = $(this),
1093                    likeboxWidth = $likebox.attr('data-likebox-width'),
1094                    cffFeedWidth = $likebox.parent().width();
1095
1096                //Default width is 340
1097                if( likeboxWidth == '' ) likeboxWidth = 340;
1098                //Change the width dynamically so it's responsive
1099                if( cffFeedWidth < likeboxWidth ) likeboxWidth = cffFeedWidth;
1100
1101                $likebox.attr('src', 'https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2F'+$likebox.attr('data-likebox-id')+'%2F&tabs&width='+Math.floor(likeboxWidth)+'&small_header='+$likebox.attr('data-likebox-header')+'&adapt_container_width=true&hide_cover='+$likebox.attr('data-hide-cover')+'&hide_cta='+$likebox.attr('data-hide-cta')+'&show_facepile='+$likebox.attr('data-likebox-faces')+'&locale='+$likebox.attr('data-locale'));
1102            });
1103            jQuery('.cff-iframe-placeholder').each(function(){
1104                var $placeholder = jQuery(this),
1105                    src = $placeholder.attr('data-src'),
1106                    type = $placeholder.attr('data-type');
1107                switch (type) {
1108                    case 'facebook':
1109                        $placeholder.replaceWith('<iframe src="'+src+'" title="Facebook video player" allowfullscreen frameborder="0" webkitallowfullscreen mozallowfullscreen></iframe>');
1110                        break;
1111                    case 'youtube':
1112                        $placeholder.replaceWith('<iframe class="youtube-player" type="text/html" src="'+src+'" allowfullscreen title="YouTube video"></iframe>');
1113                        break;
1114                    case 'vimeo':
1115                        $placeholder.replaceWith('<iframe src="'+src+'" webkitAllowFullScreen mozallowfullscreen allowFullScreen title="Vimeo video"></iframe>');
1116                        break;
1117                    case 'soundcloud':
1118                        $placeholder.replaceWith('<iframe class="cff-soundcloud" width="100%" height="100" scrolling="no" title="Music player" frameborder="no" src="'+src+'"></iframe>');
1119                        break;
1120                    case 'spotify':
1121                        $placeholder.replaceWith('<iframe class="cff-spotify" src="'+src+'" width="100%" height="80" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>');
1122                        break;
1123                    case 'video':
1124                        var posterSrc = $placeholder.attr('data-poster-src');
1125                        $placeholder.replaceWith('<video src="'+src+'" poster="'+posterSrc+'" preload="none"></video>');
1126                        break;
1127                }
1128            });
1129
1130            jQuery('a[data-x-cff-lightbox]').each(function() {
1131                jQuery(this).attr('data-cff-lightbox',jQuery(this).attr('data-x-cff-lightbox'));
1132                jQuery(this).removeAttr('data-x-cff-lightbox');
1133            });
1134
1135            jQuery(this.el).find('.cff-load-more.cff-no-consent-hide').show();
1136
1137            this.afterResize();
1138        },
1139        setResizedImages: function() {
1140            if (jQuery(this.el).find('.cff_resized_image_data').length
1141                && typeof jQuery(this.el).find('.cff_resized_image_data').attr('data-resized') !== 'undefined'
1142                && (jQuery(this.el).find('.cff_resized_image_data').attr('data-resized').indexOf('{"') === 0 || jQuery(this.el).find('.cff_resized_image_data').attr('data-resized').indexOf('[') === 0)) {
1143                var rawResized = JSON.parse(jQuery(this.el).find('.cff_resized_image_data').attr('data-resized')),
1144                    organizedResized = {};
1145
1146                jQuery.each(rawResized,function(index,value) {
1147                    organizedResized[value.facebook_id] = {
1148                        id: value.media_id,
1149                        sizes: JSON.parse(value.sizes),
1150                        aspect: value.aspect_ratio
1151                    }
1152
1153                });
1154
1155                this.resizedImages = organizedResized;
1156            }
1157            jQuery(this.el).find('.cff_resized_image_data').remove();
1158        },
1159        sendNeedsResizingToServer: function() {
1160            var feed = this;
1161
1162            if (feed.needsResizing.length > 0 && feed.settings.resizingEnabled) {
1163                var itemOffset = jQuery(this.el).find('.cff-item').length;
1164                if (!feed.settings.consentGiven
1165                    && !feed.settings.overrideBlockCDN) {
1166                    if (typeof jQuery(this.el).find('.cff-lightbox-link').attr('data-cff-lightbox') !== 'undefined') {
1167                        jQuery(this.el).find('.cff-lightbox-link').attr('data-x-cff-lightbox',jQuery(this.el).find('.cff-lightbox-link').attr('data-cff-lightbox'));
1168                        jQuery(this.el).find('.cff-lightbox-link').removeAttr('data-cff-lightbox');
1169                    }
1170                }
1171
1172                var submitData = {
1173                    action: 'cff_resized_images_submit',
1174                    needs_resizing: feed.needsResizing,
1175                    offset: itemOffset,
1176                    feed_id: feed.settings.feedID,
1177                    atts: feed.settings.shortCodeAtts,
1178                    pag_url: feed.pag_url,
1179                    location: feed.locationGuess(),
1180                    post_id: feed.settings.postID,
1181                };
1182                var onSuccess = function(data) {
1183                    feed.needsResizing = [];
1184                    if (data.trim().indexOf('{') === 0) {
1185                        var response = JSON.parse(data);
1186                        if (feed.settings.debugEnabled) {
1187                            console.log(response);
1188                        }
1189
1190                        if (typeof response.resizing !== 'undefined') {
1191                            var resized = response.resizing;
1192                            for (var property in resized) {
1193                                if (resized.hasOwnProperty(property)) {
1194                                    feed.resizedImages[property] = resized[property];
1195                                }
1196                            }
1197                            feed.maybeRaiseImageResolution();
1198
1199                            if (typeof jQuery(feed.el).find('.cff-lightbox-link').attr('data-x-cff-lightbox') !== 'undefined') {
1200                                jQuery(feed.el).find('.cff-lightbox-link').attr('data-cff-lightbox',jQuery(feed.el).find('.cff-lightbox-link').attr('data-x-cff-lightbox'));
1201                                jQuery(feed.el).find('.cff-lightbox-link').removeAttr('data-x-cff-lightbox');
1202                            }
1203
1204                            setTimeout(function() {
1205                                feed.afterResize();
1206                            },500);
1207                        }
1208                    }
1209                };
1210                cffAjax(submitData,onSuccess);
1211            } else if (feed.settings.locator) {
1212                    var submitData = {
1213                        action: 'cff_do_locator',
1214                        feed_id: feed.settings.feedID,
1215                        atts: feed.settings.shortCodeAtts,
1216                        location: feed.locationGuess(),
1217                        post_id: feed.settings.postID
1218                    };
1219                    var onSuccess = function(data) {
1220
1221                    };
1222                    cffAjax(submitData,onSuccess);
1223            }
1224        },
1225        hasTargetElement: function($cffItem) {
1226            var $target = $cffItem;
1227            if ($cffItem.find('.cff-photo').length) {
1228                $target = $cffItem.find('.cff-photo');
1229            } else if ($cffItem.find('.cff-poster').length) {
1230                $target = $cffItem.find('.cff-poster');
1231            } else if ($cffItem.find('.cff-link-slider-slides').length) {
1232                $target = $cffItem.find('.cff-link-slider-slides');
1233            } else if ($cffItem.find('.cff-img-wrap').length) {
1234                $target = $cffItem.find('.cff-img-wrap');
1235            } else if ($cffItem.find('.cff-album-cover').length) {
1236                $target = $cffItem.find('.cff-album-cover');
1237            } else if ($cffItem.find('.cff-link').length) {
1238                $target = $cffItem.find('.cff-link');
1239            }
1240
1241            return typeof $target.attr('data-img-src-set') !== 'undefined';
1242        },
1243        getTargetElement: function($cffItem) {
1244            var $target = $cffItem.find('.cff-photo');
1245
1246            if ($cffItem.find('.cff-poster').length) {
1247                $target = $cffItem.find('.cff-poster');
1248            } else if ($cffItem.find('.cff-link-slider-slides').length) {
1249                $target = $cffItem.find('.cff-link-slider-item');
1250            } else if ($cffItem.find('.cff-img-wrap').length) {
1251                $target = $cffItem.find('.cff-img-wrap');
1252            } else if ($cffItem.find('.cff-album-cover').length) {
1253                $target = $cffItem.find('.cff-album-cover');
1254            } else if ($cffItem.find('.cff-link').length) {
1255                $target = $cffItem.find('.cff-link');
1256            }
1257
1258            return $target;
1259        },
1260        getTargetElementImage: function($targetItem) {�
1260
1261            if ($targetItem.find('img').length) {
1262                return $targetItem.find('img');
1263            } else {
1264                return $targetItem;
1265            }
1266        },
1267        getTargetWidth: function($imgWrapItem,$item,index) {
1268            var width = 50,
1269                newWidth = 0;
1270
1271            if ($item.find('.cff-multi-image').length > 2 && index > 0) {
1272                newWidth = $item.innerWidth() / 3;
1273            } else if ($item.closest('.cff-masonry').length) {
1274                newWidth = $item.innerWidth();
1275            } else if ($imgWrapItem.closest('.cff-item').find('.cff-link-slider').length) {
1276                newWidth = $imgWrapItem.closest('.cff-item').find('.cff-link-slider').width();
1277            } else if ($imgWrapItem.closest('.cff-media-wrap').length
1278                && !$imgWrapItem.closest('.cff-thumb-layout').length
1279                && !$imgWrapItem.closest('.cff-half-layout').length) {
1280                newWidth = $imgWrapItem.closest('.cff-media-wrap').width();
1281            } else {
1282                newWidth = $imgWrapItem.innerWidth();
1283            }
1284
1285            return Math.max(width,newWidth);
1286        },
1287        maybeRaiseSingleImageResolution: function ($item, index, forceChange) {
1288            var feed = this,
1289                $target = feed.getTargetElement($item),
1290                imgSrcSet = feed.getImageUrls($item,$target);
1291
1292            $target.each(function(i) {
1293                var $imgWrapItem = jQuery(this),
1294                    $targetImageElement = feed.getTargetElementImage($imgWrapItem),
1295                    currentUrl = $targetImageElement.attr('src'),
1296                    currentRes = typeof $imgWrapItem.attr('data-current') === 'undefined' ? 0 : parseInt($imgWrapItem.attr('data-current')),
1297                    neededRes = feed.getTargetWidth($imgWrapItem,$item,i),
1298                    changeToRes = false;
1299
1300                if (currentRes < neededRes && typeof imgSrcSet[i] !== 'undefined') {
1301                    var foundBestRes = false;
1302                    jQuery.each(imgSrcSet[i], function (ii, value) {
1303
1304                        if (! foundBestRes && ii > currentRes) {
1305                            changeToRes = ii;
1306                            if (ii >= neededRes) {
1307                                foundBestRes = true;
1308                            }
1309                        }
1310                    });
1311                }
1312
1313                if (!feed.settings.consentGiven) {
1314                    //'a[data-cff-lightbox], area[data-cff-lightbox]'
1315                    var $lightboxAnchor = false;
1316                    if ($imgWrapItem.find('a[data-cff-lightbox]').length) {
1317                        $lightboxAnchor = $imgWrapItem.find('a[data-cff-lightbox]');
1318
1319                    } else if ($imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]').length) {
1320                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]');
1321
1322                    }
1323
1324                    if ($imgWrapItem.find('area[data-cff-lightbox]').length) {
1325                        $lightboxAnchor = $imgWrapItem.find('area[data-cff-lightbox]');
1326
1327                    } else if ($imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]').length) {
1328                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]');
1329
1330                    }
1331                    if ($lightboxAnchor) {
1332                        if($lightboxAnchor.parent('div').hasClass('cff-html5-video')){
1333                            //$lightboxAnchor.attr('href',$lightboxAnchor.parent('.cff-html5-video').attr('data-cff-video-link'));
1334                        }else{
1335                            $lightboxAnchor.attr('href',feed.getMaxResImage(imgSrcSet,i));
1336                        }
1337                    }
1338
1339                    //getMaxResImage: function(imgSrcSet,index)
1340
1341                } else {
1342                    $lightboxAnchor = false;
1343                    if ($imgWrapItem.find('a[data-cff-lightbox]').length) {
1344                        $lightboxAnchor = $imgWrapItem.find('a[data-cff-lightbox]');
1345                    } else if ($imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]').length) {
1346                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]');
1347                    } else if ($imgWrapItem.closest('.cff-album-item').find('a[data-cff-lightbox]').length) {
1348                        $lightboxAnchor = $imgWrapItem.closest('.cff-album-item').find('a[data-cff-lightbox]');
1349                    }
1350
1351                    if ($imgWrapItem.find('area[data-cff-lightbox]').length) {
1352                        $lightboxAnchor = $imgWrapItem.find('area[data-cff-lightbox]');
1353                    } else if ($imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]').length) {
1354                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]');
1355                    }
1356
1357                    if ($lightboxAnchor && typeof($lightboxAnchor) !== "boolean") {
1358                        if($lightboxAnchor.parent('div').hasClass('cff-html5-video')){
1359                            // $lightboxAnchor.attr('href',$lightboxAnchor.parent('.cff-html5-video').attr('data-cff-video-link'));
1360                        }else{
1361                            $lightboxAnchor.attr('href',feed.getMaxResImage(imgSrcSet,i));
1362                        }
1363                    }
1364                }
1365
1366                if (changeToRes) {
1367                    currentRes = changeToRes;
1368                    if (feed.settings.debugEnabled) {
1369                        var reason = currentUrl === feed.placeholderURL ? 'was placeholder' : 'too small';
1370                    }
1371                    $imgWrapItem.attr('data-current',changeToRes);
1372                    var newUrl = imgSrcSet[i][changeToRes];
1373                    if (newUrl !== currentUrl) {
1374                        $targetImageElement.attr('src', newUrl);
1375                        if ($imgWrapItem.hasClass('imgLiquid_ready')) {
1376                            $imgWrapItem.css('background-image', 'url("' + newUrl + '")');
1377                            $imgWrapItem.imgLiquid({fill:true});
1378                        }
1379
1380                        feed.processNewImage($imgWrapItem);
1381
1382                        if (currentRes < 720 && $item.hasClass('cff-album-item') && ! $targetImageElement.hasClass('cff-secondary-check')) {
1383                            $targetImageElement.addClass('cff-secondary-check');
1384                            $targetImageElement.on('load',function() {
1385                                if (!jQuery(this).hasClass('cff-secondary-checked')) {
1386                                    jQuery(this).addClass('cff-secondary-checked');
1387                                    var imagEl = $targetImageElement.get(0),
1388                                        height = imagEl.naturalHeight,
1389                                        aspectRatio = imagEl.naturalWi
1389dth/imagEl.naturalHeight;
1390
1391                                    if ($targetImageElement.innerWidth() > height) {
1392                                        neededRes = feed.getTargetWidth($imgWrapItem,$item,i) * aspectRatio;
1393                                        if (parseInt(currentRes) < neededRes) {
1394                                            foundBestRes = false;
1395                                            jQuery.each(imgSrcSet[i], function (ii, value) {
1396
1397                                                if (! foundBestRes && ii > currentRes) {
1398                                                    changeToRes = ii;
1399                                                    if (ii >= neededRes) {
1400                                                        foundBestRes = true;
1401                                                    }
1402                                                }
1403                                            });
1404
1405                                            if (changeToRes) {
1406                                                $imgWrapItem.attr('data-current', changeToRes);
1407                                                var newUrl = imgSrcSet[i][changeToRes];
1408                                                if (newUrl !== currentUrl) {
1409                                                    $targetImageElement.attr('src', newUrl);
1410                                                    if ($imgWrapItem.hasClass('imgLiquid_ready')) {
1411                                                        $imgWrapItem.css('background-image', 'url("' + newUrl + '")');
1412                                                        $imgWrapItem.imgLiquid({fill:true});
1413                                                    }
1414
1415                                                    feed.processNewImage($imgWrapItem);
1416                                                }
1417                                            }
1418                                        }
1419                                    }
1420                                }
1421
1422                            });
1423                        }
1424
1425                    }
1426
1427                }
1428
1429                $targetImageElement.on('error', function () {
1430                    if (!jQuery(this).hasClass('cff-img-error')) {
1431                        jQuery(this).addClass('cff-img-error');
1432                        var newUrl = typeof jQuery(this).attr('data-orig-source') !== 'undefined' ? jQuery(this).attr('data-orig-source') : false;
1433                        if (newUrl && newUrl !== currentUrl) {
1434                            $targetImageElement.attr('src', newUrl);
1435                            if ($imgWrapItem.hasClass('imgLiquid_ready')) {
1436                                $imgWrapItem.css('background-image', 'url("' + newUrl + '")');
1437                            }
1438                        }
1439                        setTimeout(function() {
1440                            feed.afterResize();
1441                        }, 1500)
1442                    } else {
1443                        console.log('unfixed error ' + jQuery(this).attr('src'));
1444                    }
1445                });
1446            });
1447
1448
1449        },
1450        maybeRaiseImageResolution: function (justNew) {
1451            var feed = this,
1452                itemsSelector = typeof justNew !== 'undefined' && justNew === true ? '.cff-item.cff-new, .cff-album-item.cff-new' : '.cff-item, .cff-album-item';
1453            jQuery(feed.el).find(itemsSelector).each(function (index) {
1454                if (!jQuery(this).hasClass('cff-num-diff-hide')
1455                    && feed.hasTargetElement(jQuery(this))) {
1456                    feed.maybeRaiseSingleImageResolution(jQuery(this),index);
1457                }
1458            }); //End .cff-item each
1459        },
1460        getImageUrls: function ($item,$target) {
1461            var feed = this,
1462                srcSet = {},
1463                $srcSetItem = false,
1464                id = $item.attr('id').replace('cff_', '');
1465
1466            if (typeof $target.attr('data-img-src-set') !== 'undefined') {
1467                $srcSetItem = $target;
1468            } else if (typeof $item.find('.cff-photo').attr('data-img-src-set') !== 'undefined') {
1469                $srcSetItem = $item.find('.cff-photo');
1470            } else if (typeof $item.find('.cff-link-slider-slides').attr('data-img-src-set') !== 'undefined') {
1471                $srcSetItem = $item.find('.cff-link-slider-slides');
1472            } else if (typeof $item.find('.cff-album-cover').attr('data-img-src-set') !== 'undefined') {
1473                $srcSetItem = $item.find('.cff-album-cover');
1474            }
1475
1476            if ($srcSetItem) {
1477                srcSet = JSON.parse($srcSetItem.attr('data-img-src-set').replace(/\\\//g, '/'))
1478            }
1479
1480            if (!this.settings.consentGiven && !this.settings.overrideBlockCDN) {
1481                jQuery.each(srcSet,function(index,value) {
1482                    srcSet[index] = {};
1483                });
1484            }
1485
1486            var returnSrcSet = srcSet;
1487            if (typeof feed.resizedImages[id] === 'undefined' && id.indexOf('_') === -1) {
1488                id = $item.attr('data-page-id') + '_' + id;
1489            }
1490            if (typeof feed.resizedImages[id] !== 'undefined'
1491                && feed.resizedImages[id].id !== 'pending'
1492                && feed.resizedImages[id].id !== 'error') {
1493                jQuery.each(srcSet,function(index,value) {
1494
1495                    if (feed.settings.consentGiven) {
1496                        returnSrcSet[index] = {};
1497                        var apiSourceSet = JSON.parse($srcSetItem.attr('data-img-src-set').replace(/\\\//g, '/'));
1498
1499                        jQuery.each(apiSourceSet[index],function(index2,value2) {
1500                            if (index2 > 700
1501                                || index2 < 220) {
1502                                returnSrcSet[index][index2] = value2;
1503                            }
1504                        });
1505                    }
1506
1507
1508                    jQuery.each(feed.resizedImages[id].sizes,function(index2,value2) {
1509                        returnSrcSet[index][value2] = window.cffOptions.resized_url+feed.resizedImages[id].id+'-'+index+'-'+value2+'.jpg';
1510                    });
1511                });
1512            } else if (typeof this.resizedImages[id] === 'undefined'
1513                || (typeof this.resizedImages[id]['id'] !== 'undefined' && this.resizedImages[id]['id'] !== 'pending' && this.resizedImages[id]['id'] !== 'error')) {
1514                var hasMediumSize = false;
1515
1516                jQuery.each(returnSrcSet[0],function(resolution) {
1517                    if (parseInt(resolution) > 150 && parseInt(resolution) < 500) {
1518                        hasMediumSize = true;
1519                    }
1520                });
1521                if (feed.settings.gdpr) {
1522                    hasMediumSize = false;
1523                }
1524                if (!hasMediumSize) {
1525                    this.addToNeedsResizing(id);
1526                }
1527            }
1528
1529            return returnSrcSet;
1530        },
1531        addToNeedsResizing: function (id) {
1532            if (this.needsResizing.indexOf(id) === -1) {
1533                this.needsResizing.push(id);
1534            }
1535        },
1536        processNewImage: function($item) {
1537            var feed = this;
1538            $item.find('img').each(function() {
1539                if (!jQuery(this).prop('complete')) {
1540                    feed.imagesWaiting++;
1541                    jQuery(this).addClass('cff-image-loading').on('load',function() {
1542                        jQuery(this).removeClass('cff-image-loading');
1543                        feed.imagesWaiting--;
1544                        if (feed.imagesWaiting < 1) {
1545                            feed.afterResize();
1546                        }
1547                    });
1548                    jQuery(this).on('error',function() {
1549                        jQuery(this).removeClass('cff-image-loading');
1550                        feed.imagesWaiting--;
1551                        if (feed.imagesWaiting < 1) {
1552                            feed.afterResize();
1553                        }
1554                    });
1555                }
1556            });
1557        },
1558        getMaxResImage: function(imgSrcSet,index) {
1559            if (typeof imgSrcSet[index] === 'undefined') {
1560                return false;
1561            }
1562            var largest = 0,
1563                largestImage = false;
1564            jQuery.each(imgSrcSet[index], function (index, value) {
1565                if (index > largest) {
1566                    largest = index;
1567                    largestImage = value.toString();
1568                }
1569            });
1570
1571            return largestImage;
1572        },
1573        lazyLoadCheck: function($item){
1574            var feed = this,
1575                $target = feed.getTargetElement($item),
1576                imgSrcSet = feed.getImageUrls($item,$target);
1577            if (!$item.closest('.cff').hasClass('cff-no-ll-check')) {
1578                $item.find('img').each(function(index) {
1579                    if (typeof jQuery(this).attr('data-src') !== 'undefined') {
1580                        jQuery(this).attr('data-src',jQuery(this).attr('data-orig-source'));
1581                    }
1582                    if (typeof jQuery(this).attr('data-orig-src') !== 'undefined') {
1583                        jQuery(this).attr('data-orig-src',jQuery(this).attr('data-orig-source'));
1584                    }
1585
1586                    if (!feed.settings.consentGiven) {
1587                        jQuery(this).removeAttr('data-orig-source');
1588                        maxResImage = feed.getMaxResImage(imgSrcSet,index);
1589                        if (maxResImage && maxResImage.indexOf('scontent') === -1) {
1590                            jQuery(this).attr('data-orig-source',maxResImage);
1591                        }
1592                    }
1593
1594                    jQuery(this).on('load',function() {
1595                        if (!jQuery(this).hasClass('cff-replaced')
1596                            && jQuery(this).attr('src').indexOf('placeholder') > -1) {
1597                            jQuery(this).addClass('cff-replaced');
1598                            var origSource = typeof jQuery(this).attr('data-orig-source') !== 'undefined' ? jQuery(this).attr('data-orig-source') : false;
1599                            if (origSource) {
1600                                jQuery(this).attr('src',jQuery(this).attr('data-orig-source'));
1601                                if (jQuery(this).closest('.imgLiquid_bgSize').length) {
1602                                    jQuery(this).closest('.imgLiquid_bgSize').css('background-image', 'url(' + origSource + ')');
1603                                }
1604                            }
1605                        }
1606                    });
1607                });
1608            }
1609        },
1610        maybeRelayoutMasonry: function() {
1611            var $cff = jQuery(this.el);
1612            if ($cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css')){
1613                var cff_delay = (function () {
1614                    var cff_timer = 0;
1615                    return function (cff_callback, cff_ms) {
1616                        clearTimeout(cff_timer);
1617                        cff_timer = setTimeout(cff_callback, cff_ms);
1618                    };
1619                })();
1620                cff_delay(function () {
1621                    cffAddMasonry($cff);
1622                }, 500);
1623            }
1624        },
1625        afterInitialImagesLoaded: function(){
1626            this.maybeRaiseImageResolution();
1627            this.sendNeedsResizingToServer();
1628            this.maybeCleanUpNew();
1629            if (this.settings.consentGiven) {
1630                this.addFullFeatures();
1631            }else{
1632                jQuery('.cff-gdpr-notice').css({'display':'inline-block'});
1633            }
1634        },
1635        afterResize: function () {
1636            this.maybeRaiseImageResolution();
1637            this.maybeRelayoutMasonry();
1638        },
1639        afterLoadMoreClicked: function() {
1640            this.maybeRaiseImageResolution();
1641            this.addFullFeatures();
1642        },
1643        maybeCleanUpNew: function() {
1644            var feed = this,
1645                $cff = jQuery(this.el);
1646            setTimeout(function() {
1647                if  (feed.index > 0) {
1648                    $cff.find('.cff-new').removeClass('cff-new');
1649                }
1650                $cff.find('img').each(function() {
1651                    if (feed.settings.consentGiven && !jQuery(this).hasClass('cff-image-loading')
1652                    && ( jQuery(this).attr('src') != null && jQuery(this).attr('src') != undefined ) && jQuery(this).attr('src').indexOf('placeholder.png') > -1) {
1653                        console.log('lazy load correction');
1654                        var $self = jQuery(this),
1655                            currentSrc = $self.attr('src'),
1656                            originalSrc = $self.attr('data-orig-source');
1657
1658                        // Check if the img source has been changed by lazy loading
1659                        if(originalSrc != currentSrc){
1660                            $self.attr('src', originalSrc);
1661                        }
1662
1663                        // Timeline album posts need the background source reset
1664                        if($self.hasClass('cff-multi-image')){
1665                            $self.css('background-image', 'url(' + originalSrc + ')');
1666                        }
1667                    }
1668                });
1669            },1250);
1670        },
1671        checkConsent: function() {
1672            if (this.settings.consentGiven || !this.settings.gdpr) {
1673                return true;
1674            }
1675            if (typeof CLI_Cookie !== "undefined") { // GDPR Cookie Consent by WebToffee
1676                if (CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) !== null)  {
1677
1678                    // WebToffee no longer uses this cookie but being left here to maintain backwards compatibility
1679                    if (CLI_Cookie.read('cookielawinfo-checkbox-non-necessary') !== 'null') {
1680                        this.settings.consentGiven = CLI_Cookie.read('cookielawinfo-checkbox-non-necessary') === 'yes';
1681                    }
1682
1683                    if (CLI_Cookie.read('cookielawinfo-checkbox-necessary') !== 'null') {
1684                        this.settings.consentGiven = CLI_Cookie.read('cookielawinfo-checkbox-necessary') === 'yes';
1685                    }
1686                }
1687
1688            } else if (typeof window.cnArgs !== "undefined") { // Cookie Notice by dFactory
1689                var value = "; " + document.cookie,
1690                    parts = value.split( '; cookie_notice_accepted=' );
1691
1692                if ( parts.length === 2 ) {
1693                    var val = parts.pop().split( ';' ).shift();
1694
1695                    this.settings.consentGiven = (val === 'true');
1696                }
1697            } else if (typeof window.cookieconsent !== 'undefined') { // Complianz by Really Simple Plugins
1698                this.settings.consentGiven = cffCmplzGetCookie('cmplz_consent_status') === 'allow';
1699            } else if (typeof window.Cookiebot !== "undefined") { // Cookiebot by Cybot A/S
1700                this.settings.consentGiven = Cookiebot.consented;
1701            } else if (typeof window.BorlabsCookie !== 'undefined') { // Borlabs Cookie by Borlabs
1702                this.settings.consentGiven = window.BorlabsCookie.checkCookieConsent('facebook');
1703            }
1704
1705            var evt = jQuery.Event('cffcheckconsent');
1706            evt.feed = this;
1707            jQuery(window).trigger(evt);
1708
1709            return this.settings.consentGiven; // GDPR not enabled
1710        },
1711        afterConsentToggled: function() {
1712            if (this.checkConsent()) {
1713                var feed = this;
1714                feed.maybeRaiseImageResolution();
1715                this.addFullFeatures();
1716                setTimeout(function() {
1717                    feed.afterResize();
1718                },500);
1719            }
1720        },
1721        locationGuess: function($cff = false) {
1722                var $feed = ($cff == false) ? jQuery(this.el) : $cff,
1723                    location = 'content';
1724
1725                if ($feed.closest('footer').length) {
1726                    location = 'footer';
1727                } else if ($feed.closest('.header').length
1728                    || $feed.closest('header').length) {
1729                    location = 'header';
1730                } else if ($feed.closest('.sidebar').length
1731                    || $feed.closest('aside').length) {
1732                    location = 'sidebar';
1733                }
1734
1735                return location;
1736            }
1737    };
1738
1739    function cffAjax(submitData, onSuccess) {
1740        jQuery.ajax({
1741            url: cffajaxurl,
1742            type: 'post',
1743            data: submitData,
1744            success: onSuccess
1745        });
1746    }
1747    function cffCmplzGetCookie(cname) {
1748        var name = cname + "="; //Create the cookie name variable with cookie name concatenate with = sign
1749        var cArr = window.document.cookie.split(';'); //Create cookie array by split the cookie by ';'
1750
1751        //Loop through the cookies and return the cookie value if it find the cookie name
1752        for (var i = 0; i < cArr.length; i++) {
1753            var c = cArr[i].trim();
1754            //If the name is the cookie string at position 0, we found the cookie and return the cookie value
1755            if (c.indexOf(name) == 0)
1756                return c.substring(name.length, c.length);
1757        }
1758
1759        return "";
1760    }
1761
1762    function cff_init( $cff ){
1763        //JS is running
1764        jQuery('.cff-nojs').removeClass('cff-nojs');
1765
1766        //Check whether it's a touch device
1767        var cffTouchDevice = false;
1768        if (cffIsTouchDevice() === true) cffTouchDevice = true;
1769        function cffIsTouchDevice() {
1770            return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
1771        }
1772
1773        //If a feed selector isn't passed in then default to using selector for all feeds
1774        var firsttime = false;
1775        if(typeof $cff === 'undefined'){
1776            $cff = jQuery('.cff');
1777            firsttime = true;
1778        }
1779
1780        (function($){
1781
1782            //Toggle comments
1783            jQuery(document).off('click', '#cff a.cff-view-comments').on('click', '#cff a.cff-view-comments', function(){
1784                var $self = jQuery(this),
1785                    $commentsBox = $self.closest('.cff-item').find('.cff-comments-box');
1786                $self.toggleClass('cff-open');
1787
1788                $commentsBox.slideToggle(300);
1789
1790                //Masonry - overlap comments box when open
1791                var $feed = $self.closest('#cff'),
1792                    $item = $(this).closest('.cff-item');
1793                if( $feed.hasClass('cff-masonry-js') && !$feed.hasClass('cff-opaque-comments') ){
1794                    setTimeout(function(){
1795                        cffAddMasonry($feed);
1796                    }, 500);
1797                }
1798
1799                //Add comment avatars
1800                $commentsBox.find('.cff-comment:visible').each(function(){
1801                    var $thisComment = jQuery(this); // here
1802                    var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
1803                    if (consentGiven) {
1804                        $thisComment.find('.cff-comment-img:not(.cff-comment-reply-img) a, .cff-comment-img:not(.cff-comment-reply-img) span').html( '<img src="'+$thisComment.attr("data-avatar")+'" alt="Avatar" onerror="this.style.display=\'none\'" />' );
1805                    }
1806                });
1807
1808            });
1809
1810            //Comments box hover
1811            var cffAnimateIconColorVar,
1812                stopAnimate = false;
1813            $cff.find('.cff-view-comments').on('mouseenter',  function(){
1814                var $self = $(this),
1815                    time = 50;
1816                if( $self.hasClass('cff-open') ) return;
1817
1818                $self.find('.cff-icon').each(function() {
1819                    var $cffIcon = jQuery(this);
1820                    cffAnimateIconColor($cffIcon, time);
1821                    time += 50;
1822                });
1823            }).on('mouseleave',  function(){
1824                cffStopAnimateIconColor();
1825                $(this).find('.cff-icon').removeClass('cff-animate');
1826            });
1827            function cffAnimateIconColor($cffIcon, time){
1828                stopAnimate = false;
1829                cffAnimateIconColorVar = setTimeout( function(){
1830                    if( !stopAnimate ) $cffIcon.addClass('cff-animate');
1831                }, time);
1832            }
1833            function cffStopAnimateIconColor() {
1834                clearTimeout(cffAnimateIconColorVar);
1835                stopAnimate = true;
1836            }
1837
1838            //Set paths for query.php
1839            if (typeof cffsiteurl === 'undefined' || cffsiteurl == '') cffsiteurl = window.location.host + '/wp-content/plugins';
1840            var locatefile = true;
1841
1842            //Create meta data array for caching likes and comments
1843            var metaArr = {},
1844                newMetaArr = {}, metaArray = []; //For caching only new posts that are loaded
1845
1846            //Loop through the feeds on the page and add a unique attribute to each to use for lightbox groups
1847            var lb = 0;
1848            jQuery('#cff.cff-lb').each(function(){
1849                lb++;
1850                $(this).attr('data-cff-lb', lb);
1851            });
1852
1853
1854            //If it's the first load then loop through all .cff-items on the page, otherwise, only loop through the feed where the load more button is clicked
1855            var $cff_post_selector = $cff.find('.cff-item.cff-new, .cff-album-item.cff-new');
1856            if( firsttime ){
1857                $cff_post_selector = jQuery('#cff .cff-item.cff-new, #cff .cff-album-item.cff-new');
1858            }
1859
1860            //Loop through each item
1861            $cff_post_selector.each(function(){
1862
1863                var $self = jQuery(this);
1864
1865                //Wpautop fix
1866                if( $self.find('.cff-viewpost-link, .cff-viewpost-facebook, .cff-viewpost').parent('p').length ){
1867                    //Don't unwrap event only viewpost link
1868                    if( !$self.hasClass('event') ) $self.find('.cff-viewpost-link, .cff-viewpost-facebook, .cff-viewpost').unwrap('p');
1869                }
1870                if( $self.find('.cff-photo').parent('p').length ){
1871                    $self.find('p .cff-photo').unwrap('p');
1872                    $self.find('.cff-album-icon').appendTo('.cff-photo:last');
1873                }
1874                if( $self.find('.cff-event-thumb').parent('p').length ){
1875                    $self.find('.cff-event-thumb').unwrap('p');
1876                }
1877                if( $self.find('.cff-vidLink').parent('p').length ){
1878                    $self.find('.cff-vidLink').unwrap('p');
1879                }
1880                if( $self.find('.cff-link').parent('p').length ){
1881                    $self.find('.cff-link').unwrap('p');
1882                }
1883                if( $self.find('.cff-viewpost-link').parent('p').length ){
1884                    $self.find('.cff-viewpost-link').unwrap('p');
1885                }
1886                if( $self.find('.cff-viewpost-facebook').parent('p').length ){
1887                    $self.find('.cff-viewpost-facebook').unwrap('p');
1888                }
1889
1890                if( $self.find('iframe').parent('p').length ){
1891                    $self.find('iframe').unwrap('p');
1892                }
1893                if( $self.find('.cff-author').parent('p').length ){
1894                    $self.find('.cff-author').eq(1).unwrap('p');
1895                    $self.find('.cff-author').eq(1).remove();
1896                }
1897                if( $self.find('.cff-view-comments').parent('p').length ){
1898                    $self.find('.cff-meta-wrap > p').remove();
1899                    $self.find('.cff-view-comments').eq(1).remove();
1900                    //Move meta ul inside the link element
1901                    var $cffMeta = $self.find('.cff-meta'),
1902                        cffMetaClasses = $cffMeta.attr('class');
1903                    $cffMeta.find('.cff-view-comments').unwrap().wrapInner('<ul class="'+cffMetaClasses+'">');
1904                }
1905                if( $self.find('.cff-photo').siblings('.cff-photo').length ){
1906                    $self.find('.cff-photo').slice(0,2).remove();
1907                }
1908                //Fix the formatting issue that pushes avatar to the left
1909                if( $('.cff-author-img').parent().is('p') ) $('.cff-author-img').unwrap('p');
1910                //Remove empty p tags
1911                $self.find('p:empty').not('.cff-comments-box p').remove();
1912
1913                //Expand post
1914                var expanded = false;
1915                if( $self.hasClass('cff-event') ){
1916                    var $post_text = $self.find('.cff-desc .cff-desc-text'),
1917                        text_limit = $post_text.parent().attr('data-char');
1918                } else {
1919                    var $post_text = $self.find('.cff-post-text .cff-text'),
1920                        text_limit = $self.closest('#cff').attr('data-char');
1921                }
1922
1923                if (typeof text_limit === 'undefined' || text_limit == '') text_limit = 99999;
1924
1925                //If the text is linked then use the text within the link
1926                if ( $post_text.find('a.cff-post-text-link').length ) $post_text = $self.find('.cff-post-text .cff-text a');
1927                var full_text = $post_text.html();
1928                if(full_text == undefined) full_text = '';
1929
1930
1931                //Truncate text taking HTML tags into account
1932                var cff_trunc_regx = new RegExp(/(<[^>]*>)/g);
1933                var cff_trunc_counter = 0;
1934
1935                //convert the string to array using the HTML tags as delimiter and keeping them as array elements
1936                full_text_arr = full_text.split(cff_trunc_regx);
1937
1938                for (var i = 0, len = full_text_arr.length; i < len; i++) {
1939                    //ignore the array elements that are HTML tags
1940                    if ( !(cff_trunc_regx.test(full_text_arr[i])) ) {
1941                        //if the counter is 100, remove this element with text
1942                        if (cff_trunc_counter == text_limit) {
1943                            full_text_arr.splice(i, 1);
1944                            continue; //ignore next commands and continue the for loop
1945                        }
1946                        //if the counter != 100, increase the counter with this element length
1947                        cff_trunc_counter = cff_trunc_counter + full_text_arr[i].length;
1948                        //if is over 100, slice the text of this element to match the total of 100 chars and set the counter to 100
1949                        if (cff_trunc_counter > text_limit) {
1950                            var diff = cff_trunc_counter - text_limit;
1951                            full_text_arr[i] = full_text_arr[i].slice(0, -diff);
1952                            cff_trunc_counter = text_limit;
1953
1954                            //Show the 'See More' link if needed
1955                            if (full_text.length > text_limit) $self.find('.cff-expand').show();
1956                        }
1957                    }
1958                }
1959
1960                //new string from the array
1961                var short_text = full_text_arr.join('');
1962
1963                //remove empty html tags from the array
1964                short_text = short_text.replace(/(<(?!\/)[^>]+>)+(<\/[^>]+>)/g, "");
1965
1966                //If the short text cuts off in the middle of a <br> tag then remove the stray '<' which is displayed
1967                var lastChar = short_text.substr(short_text.length - 1);
1968                if(lastChar == '<') short_text = short_text.substring(0, short_text.length - 1);
1969
1970                //Remove any <br> tags from the end of the short_text
1971                short_text = short_text.replace(/(<br>\s*)+$/,'');
1972                short_text = short_text.replace(/(<img class="cff-linebreak">\s*)+$/,'');
1973
1974                //Cut the text based on limits set
1975                $post_text.html( short_text );
1976
1977
1978                //Click function
1979                $self.find('.cff-expand a').off('click').on('click', function(e){
1980                    e.preventDefault();
1981                    var $expand = jQuery(this),
1982                        $more = $expand.find('.cff-more'),
1983                        $less = $expand.find('.cff-less');
1984                    if (expanded == false){
1985                        $post_text.html( full_text );
1986                        expanded = true;
1987                        $more.hide();
1988                        $less.show();
1989                    } else {
1990                        $post_text.html( short_text );
1991                        expanded = false;
1992                        $more.show();
1993                        $less.hide();
1994                    }
1995                    cffLinkHashtags();
1996                    //Add target to links in text when expanded
1997                    $post_text.find('a').attr('target', '_blank');
1998
1999                    //Re-init masonry for JS
2000                    if( $self.closest('.cff').hasClass('cff-masonry-js') && !$self.closest('.cff').hasClass('cff-masonry-css') ){
2001                        cffAddMasonry($cff);
2002                    }
2003
2004                });
2005                //Add target attr to post text links via JS so aren't included in char count
2006                $post_text.find('a').add( $self.find('.cff-post-desc a') ).attr({
2007                    'target' : '_blank',
2008                    'rel' : 'nofollow noopener noreferrer'
2009                });
2010
2011
2012                //This is the modified Post ID - so if the post is an album post then this could be the album ID which is used to get the lightbox thumbs
2013                var post_id = $self.attr('id').substring(4),
2014                    //This is the original post ID which is used to get the number of likes and comments for the timeline post
2015                    post_id_orig = $self.find('.cff-view-comments').attr('id');
2016
2017                if( locatefile != true ) $self.find('.cff-lightbox-thumbs-holder').css('min-height', 0);
2018
2019
2020                //Show all comments on click
2021                jQuery(document).off('click', '#cff .cff-show-more-comments, .cff-lightbox-sidebar .cff-show-more-comments').on('click', '#cff .cff-show-more-comments, .cff-lightbox-sidebar .cff-show-more-comments', function(){
2022
2023                    var $cffMoreCommentsLink = jQuery(this),
2024                        thisCommentsTotal = parseInt($cffMoreCommentsLink.attr('data-cff-comments-total'));
2025
2026                    //If there's more than 25 comments then link the "View more comments" link to post on Facebook
2027                    if( $cffMoreCommentsLink.hasClass('cff-clicked') && thisCommentsTotal > 25 ){
2028                        //Link to Facebook
2029                        $cffMoreCommentsLink.find('a').attr({
2030                            'href' : $cffMoreCommentsLink.closest('.cff-comments-box').find('.cff-comment-on-facebook a').attr('href'),
2031                            'target' : '_blank'
2032                        });
2033                    }
2034                    //Hide 'View more comments' link
2035                    if( thisCommentsTotal <= 25 ) $cffMoreCommentsLink.hide();
2036
2037                    //Add class so we can only trigger the above on the second click
2038                    $cffMoreCommentsLink.addClass('cff-clicked');
2039
2040                    //Show comments and add comment avatars
2041                    $cffMoreCommentsLink.parent().find('.cff-comment').show().each(function(){
2042                        var $thisComment = jQuery(this);
2043                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
2044                        if (consentGiven) {
2045                            $thisComment.find('.cff-comment-img:not(.cff-comment-reply-img) a, .cff-comment-img:not(.cff-comment-reply-img) span').html( '<img src="'+$thisComment.attr("data-avatar")+'" alt="Avatar" onerror="this.style.display=\'none\'" />' );
2046                        }
2047
2048                    });
2049
2050                    //Re-init masonry when more comments loaded
2051                    var $closestCff = $cffMoreCommentsLink.closest('.cff');
2052                    if( $closestCff.hasClass('cff-masonry-js') && !$closestCff.hasClass('cff-opaque-comments') ){
2053                        setTimeout(function(){
2054                            cffAddMasonry( $closestCff );
2055                        }, 500);
2056                    }
2057                });
2058
2059
2060                //Remove event end date day if the same as the start date
2061                if( $self.hasClass('cff-timeline-event') || $self.hasClass('cff-event') ){
2062                    if( $(this).find('.cff-date .cff-start-date k').text() !== $(this).find('.cff-date .cff-end-date k').text() ) $(this).find('.cff-date .cff-end-date k').show();
2063                }
2064
2065
2066                //Replace Photon (Jetpack CDN) images with the originals again
2067                var $cffPhotoImg = $self.find('.cff-photo img, .cff-event-thumb img, .cff-poster, .cff-album-cover img'),
2068                    cffPhotoImgSrc = $cffPhotoImg.attr('src'),
2069                    cffImgStringAttr = $cffPhotoImg.attr('data-querystring');
2070
2071                if( typeof cffPhotoImgSrc == 'undefined' ) cffPhotoImgSrc = '';
2072
2073                if( cffPhotoImgSrc.indexOf('i0.wp.com') > -1 || cffPhotoImgSrc.indexOf('i1.wp.com') > -1 || cffPhotoImgSrc.indexOf('i2.wp.com') > -1 || cffPhotoImgSrc.indexOf('i3.wp.com') > -1 || cffPhotoImgSrc.indexOf('i4.wp.com') > -1 || cffPhotoImgSrc.indexOf('i5.wp.com') > -1 ){
2074
2075                    //Create new src. Single slash in https is intentional as one is left over from removing i_.wp.com
2076                    var photonSrc = $cffPhotoImg.attr('src').substring(0, $cffPhotoImg.attr('src').indexOf('?')),
2077                        newSrc = photonSrc.replace('http://', 'https:/').replace(/i0.wp.com|i1.wp.com|i2.wp.com|i3.wp.com|i4.wp.com|i5.wp.com/gi, '') + '?' + cffImgStringAttr;
2078
2079                    $cffPhotoImg.attr('src', newSrc);
2080                }
2081
2082                function cffLinkHashtags(){
2083                    //Link hashtags
2084                    var cffTextStr = $self.find('.cff-text').html(),
2085                        cffDescStr = $self.find('.cff-post-desc').html(),
2086                        regex = /(^|\s)#(\w*[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
2086D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]+\w*)/gi,
2087                        linkcolor = $self.find('.cff-text').attr('data-color'),
2088                        linkcolorHTML = '';
2089
2090                    function replacer(hash){
2091                        //Remove white space at beginning of hash
2092                        var replacementString = jQuery.trim(hash);
2093                        //If the hash is a hex code then don't replace it with a link as it's likely in the style attr, eg: "color: #ff0000"
2094                        if ( /^#[0-9A-F]{6}$/i.test( replacementString ) ){
2095                            return replacementString;
2096                        } else {
2097                            if( typeof linkcolor !== 'undefined' ){
2098                                if( linkcolor.length > 1 ) linkcolorHTML = 'style="color:#' + linkcolor + '"';
2099                            }
2100                            return ' <a href="https://www.facebook.com/hashtag/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener" '+linkcolorHTML+'>' + replacementString + '</a>';
2101                        }
2102                    }
2103
2104                    //If it's not defined in the source code then set it to be true
2105                    if (typeof cfflinkhashtags == 'undefined') cfflinkhashtags = 'true';
2106
2107                    if(cfflinkhashtags == 'true'){
2108                        //Replace hashtags in text
2109                        var $cffText = $self.find('.cff-text');
2110
2111                        if($cffText.length > 0){
2112                            //Add a space after all <br> tags so that #hashtags immediately after them are also converted to hashtag links. Without the space they aren't captured by the regex.
2113                            cffTextStr = cffTextStr.replace(/<br>/g, "<br> ");
2114                            $cffText.html( cffTextStr.replace( regex , replacer ) );
2115                        }
2116                    }
2117
2118                    //Replace hashtags in desc
2119                    if( $self.find('.cff-post-desc').length > 0 ) $self.find('.cff-post-desc').html( cffDescStr.replace( regex , replacer ) );
2120                }
2121                cffLinkHashtags();
2122
2123                //Add target attr to post text links via JS so aren't included in char count
2124                $self.find('.cff-text a').attr('target', '_blank');
2125
2126
2127                //Add lightbox tile link to photos
2128                if( $self.closest('#cff').hasClass('cff-lb') ){
2129                    $self.find('.cff-photo, .cff-album-cover, .cff-event-thumb, .cff-html5-video, .cff-iframe-wrap').each(function(){
2130                        var $photo = $(this),
2131                            postId = post_id,
2132                            cffLightboxTitle = '',
2133                            cffShowThumbs = false,
2134                            postType = '',
2135                            cffgroupalbums = '';
2136
2137
2138                        // if( $self.hasClass('cff-album') || $self.hasClass('cff-albums-only') ) cffShowThumbs = true;
2139                        cffShowThumbs = true;
2140
2141                        function cffFormatCaption(text){
2142                            return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
2143                        }
2144
2145                        //Set the caption/title
2146                        if( $self.hasClass('cff-albums-only') ){
2147                            postType = 'albumsonly';
2148                            cffLightboxTitle = cffFormatCaption( $self.find('img').attr('alt') );
2149
2150                            //Check whether there's an absolute path attr and if there is then add it to the query
2151                            var dataGroup = $self.closest('#cff').attr('data-group');
2152                            if( typeof dataGroup !== 'undefined' ) cffgroupalbums = 'data-cffgroupalbums="true"';
2153
2154                        } else if( $self.hasClass('cff-timeline-event') ) {
2155                            var capText = '';
2156                            if( $self.find('.cff-author-text .cff-page-name').length ) capText += $self.find('.cff-author-text .cff-page-name').text() + '<br /><br />';
2157                            //Display the full event details but the info is hidden in CSS as it's too long in some cases
2158                            if( full_text.length > 5 ) capText += full_text;
2159                            cffLightboxTitle = cffFormatCaption( capText );
2160
2161                        } else if ( $self.hasClass('cff-event') ) {
2162                            //Events feed
2163                            if( $self.find('.cff-details').length ){
2164                                // if( $self.find('.cff-event-title').length ) cffLightboxTitle = cffFormatCaption( $self.find('.cff-event-title')[0].outerHTML );
2165                                // if( $self.find('.cff-date').length ) cffLightboxTitle += cffFormatCaption( $self.find('.cff-date')[0].outerHTML );
2166                                // if( $self.find('.cff-location').length ) cffLightboxTitle += cffFormatCaption( $self.find('.cff-location')[0].outerHTML );
2167
2168                                if( $self.find('.cff-event-title').length ) cffLightboxTitle = '<span class="cff-event-title" style="font-weight:bold;">' + cffFormatCaption( $self.find('.cff-event-title').html() + '</span>' );
2169                                if( $self.find('.cff-date').length ) cffLightboxTitle += '<span class="cff-date">' + cffFormatCaption( $self.find('.cff-date').html() + '</span>' );
2170                                if( $self.find('.cff-location').length ) cffLightboxTitle += '<span class="cff-location">' + cffFormatCaption( $self.find('.cff-location').html() + '</span>' );
2171
2172                                cffLightboxTitle += '<span class="cff-desc">' + full_text + '</span>';
2173                            }
2174
2175                        } else if( $self.hasClass('cff-album-item') ) {
2176                            cffLightboxTitle = cffFormatCaption( $self.find('img').attr('alt') );
2177                        } else {
2178                            var lb_title = full_text;
2179                            //If there's no post text then use the description
2180                            if( full_text.trim() == '' ) lb_title = $self.find('.cff-post-desc').text();
2181
2182                            //If there's no post text or desc then use the story
2183                            if( lb_title == '' && $self.find('.cff-author .cff-story').length ) lb_title = $self.find('.cff-author .cff-page-name').text();
2184
2185                            //If there's no text at all then just set it to be a space so that it renders as blank, otherwise it will use the caption from the post before
2186                            if( lb_title == '' ) lb_title = '&nbsp;';
2187
2188                            cffLightboxTitle = cffFormatCaption( lb_title );
2189                        }
2190
2191                        if(cffLightboxTitle.length > 1) cffLightboxTitle = cffLightboxTitle.replace(/"/g, '&quot;');
2192
2193
2194                        //Create the lightbox link
2195                        //Add the hover tile
2196                        var cffLightboxTile = '<a class="cff-lightbox-link nofancybox" rel="nofollow" ';
2197
2198                        //If it's a YouTube or Vimeo then set the poster image to use in the lightbox
2199                        if( $photo.hasClass('cff-iframe-wrap') ){
2200                            //Add the image to the video lightbox placeholder as a query string so that the href value is unique and is added to the lightbox order. Otherwise, if it doesn't contain the query string then all videos that use the placeholder have the same URL and so they aren't added to the lightbox order. The actual video image is very small and so we need to use the placeholder to have the video display larger in the lightbox:
2201                            var iframeSrc = '';
2202                            if ($photo.find('iframe').length) {
2203                                iframeSrc = $photo.find('iframe').attr('src');
2204                            } if ($photo.find('.cff-iframe-placeholder').length ) {
2205                                iframeSrc = $photo.find('.cff-iframe-placeholder').attr('data-src');
2206                            }
2207                            cffLightboxTile += 'href="'+cffsiteurl+'/custom-facebook-feed-pro/assets/img/video-lightbox.png?'+postId+'" data-iframe="'+iframeSrc+'" ';
2208                            //If it's a swf then display it in an iframe
2209                        } else if( $photo.hasClass('cff-swf') ) {
2210                            cffLightboxTile += 'href="'+cffsiteurl+'/custom-facebook-feed-pro/assets/img/video-lightbox.png" data-iframe="'+$photo.find('video').attr('src')+'" ';
2211                        } else {
2212                            var lb_href = $photo.find('img').attr('src').indexOf('placeholder') === -1 ? $photo.find('img').attr('src') : $photo.find('img').attr('data-orig-source');
2213                            if( $photo.find('img').attr('data-cff-no-event-img-large') ) lb_href = $photo.find('img').attr('data-cff-no-event-img-large');
2214                            if( $photo.find('img').attr('data-cff-full-img') ) lb_href = $photo.find('img').attr('data-cff-full-img');
2215                            cffLightboxTile += 'href="'+lb_href+'" data-iframe="" ';
2216                        }
2217                        //No nav
2218                        // cffLightboxTile += 'data-cff-lightbox="'+postId+'" data-title="'+cffLightboxTitle+'" data-id="'+postId+'" data-thumbs="'+cffShowThumbs+'" ';
2219                        cffLightboxTile += 'data-cff-lightbox="cff-lightbox-'+$self.closest("#cff").attr("data-cff-lb")+'" data-title="'+cffLightboxTitle+'" data-id="'+postId+'" data-thumbs="'+cffShowThumbs+'" '+cffgroupalbums+' ';
2220
2221                        //If it's an HTML5 video then set the data-video attr
2222                        if( $photo.hasClass('cff-html5-video') ){
2223
2224                            if($photo.hasClass('cff-swf')){
2225                                cffLightboxTile += 'data-url="'+$photo.find('.cff-html5-play').attr('href')+'" data-video="';
2226                            } else {
2227                                cffLightboxTile += 'data-url="'+$photo.find('.cff-html5-play').attr('href')+'" data-video="'+$photo.find('img').attr('data-cff-video');
2228                            }
2229
2230                            //Videos only:
2231                        } else if( $photo.hasClass('cff-video') ) {
2232                            cffLightboxTile += 'data-url="http://facebook.com/'+$photo.attr('id')+'" data-video="'+$photo.attr('data-source');
2233                        } else if( $photo.hasClass('cff-iframe-wrap') ) {
2234                            cffLightboxTile += 'data-url="http://facebook.com/'+post_id+'" data-video="';
2235                        } else {
2236                            cffLightboxTile += 'data-url="'+$photo.attr('href')+'" data-video="';
2237                        }
2238
2239                        cffLightboxTile += '" data-type="'+postType+'" data-lb-comments="'+$photo.closest('.cff-lb').attr('data-lb-comments')+'"><div class="cff-photo-hover"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="search-plus" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-search-plus fa-w-16 fa-2x"><path fill="currentColor" d="M304 192v32c0 6.6-5.4 12-12 12h-56v56c0 6.6-5.4 12-12 12h-32c-6.6 0-12-5.4-12-12v-56h-56c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h56v-56c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v56h56c6.6 0 12 5.4 12 12zm201 284.7L476.7 505c-9.4 9.4-24.6 9.4-33.9 0L343 405.3c-4.5-4.5-7-10.6-7-17V372c-35.3 27.6-79.7 44-128 44C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208c0 48.3-16.4 92.7-44 128h16.3c6.4 0 12.5 2.5 17 7l99.7 99.7c9.3 9.4 9.3 24.6 0 34zM344 208c0-75.2-60.8-136-136-136S72 132.8 72 208s60.8 136 136 136 136-60.8 136-136z" class=""></path></svg><span class="cff-screenreader">View</span></div></a>';
2240
2241                        //Add the link to the photos/videos in the feed
2242                        $photo.prepend(cffLightboxTile);
2243
2244                        if( !cffTouchDevice ){ //Only apply hover effect if not touch screen device
2245                            //Fade in links on hover
2246                            $photo.on('mouseenter', function(){
2247                                $self.find('.cff-photo-hover').fadeIn(150);
2248                            }).on('mouseleave', function(){
2249                                $self.find('.cff-photo-hover').stop().fadeOut(500);
2250                            });
2251                        }
2252
2253                    });
2254                }
2255
2256                //Share tooltip function
2257                $self.find('.cff-share-link').off('click').on('click', function(e){
2258                    e.preventDefault();
2259                    var $cffShareTooltip = $self.find('.cff-share-tooltip')
2260
2261                    //Hide tooltip
2262                    if( $cffShareTooltip.is(':visible') ){
2263                        $cffShareTooltip.hide().find('a').removeClass('cff-show');
2264                    } else {
2265                        //Show tooltip
2266                        $cffShareTooltip.show();
2267
2268                        var time = 0;
2269                        $cffShareTooltip.find('a').each(function() {
2270                            var $cffShareIcon = jQuery(this);
2271                            setTimeout( function(){
2272                                $cffShareIcon.addClass('cff-show');
2273                            }, time);
2274                            time += 20;
2275                        });
2276                    }
2277                });
2278
2279                //If it's a restricted page then use the lightbox src for the photo feed images
2280                if( typeof $cff.attr('data-restricted') !== 'undefined' ){
2281                    var cff_restricted_page = true;
2282                } else {
2283                    var cff_restricted_page = false;
2284                }
2285
2286                //Photos only
2287                if( $self.hasClass('cff-album-item') ){
2288                    var cff_data_full_size = $self.attr('data-cff-full-size');
2289
2290                    if( typeof cff_data_full_size !== 'undefined' && cff_data_full_size != '' ){
2291
2292                        if( cff_restricted_page ){
2293                            $self.find('.cff-lightbox-link').attr('href', cff_data_full_size).closest('.cff-album-cover').css('background-image', 'url('+cff_data_full_size+')');
2294                            $self.find('img').attr('src', cff_data_full_size);
2295                        } else {
2296                            $self.find('.cff-lightbox-link').attr('href', cff_data_full_size);
2297                        }
2298
2299                    }
2300                }
2301
2302
2303                //Add the HD video player
2304                //If it's a video post then add the video link to the video element so it can be used in the lightbox
2305                if( ( $self.find('.cff-html5-video').length || $self.hasClass('cff-video') ) ){
2306
2307                    var cff_live_video = false;
2308
2309                    //Set the selector based on whether it's a timeline vid or videos only
2310                    if( $self.find('.cff-html5-video').length ){
2311                        var $vid_sel = $self.find('.cff-html5-video');
2312                        if( $vid_sel.attr('data-cff-live') == 'true' ) cff_live_video = true;
2313                    }
2314                    if( $self.hasClass('cff-video') ) var $vid_sel = $self;
2315
2316                    if( cff_live_video && $(window).width() <= 640 ){
2317                        //If it's live video and on mobile then use HTMl5 player as live video doesn't work on mobile using Facebook player
2318                    } else {
2319
2320                        if( !$self.closest('.cff').hasClass('cff-private-group') ){
2321                            //If the Facebook Player is selected then pass the iframe URL into the lightbox.
2322                            if( $vid_sel.attr('data-cff-video-player') != 'standard' ){
2323                                $self.find('.cff-lightbox-link').attr({
2324                                    'data-iframe' : 'https://www.facebook.com/v2.3/plugins/video.php?href=' + $vid_sel.attr('data-cff-video-link'),
2325                                    'data-video' : ''
2326                                });
2327                            }
2328                        }
2329
2330                    }
2331
2332                }
2333
2334                //Try to fix any video wrapper formatting issues
2335                setTimeout(function(){
2336                    $self.find('.cff-iframe-wrap .fluid-width-video-wrapper iframe').unwrap().wrap('<div style="float: left; width: 100%;"></div>');
2337                    $self.find('.cff-iframe-wrap .iframe-embed iframe').unwrap('iframe-embed');
2338                }, 500);
2339
2340
2341                //Open lightbox when clicking album or video title
2342                $self.find('.cff-album-info a').on('click', function(e){
2343                    e.preventDefault();
2344                    $self.find('.cff-lightbox-link').trigger('click');
2345                });
2346
2347
2348            }); //End $cff_post_selector.each loop
2349
2350
2351            //Load comment replies
2352            jQuery(document).off('click', '.cff-comment-replies a').on('click', '.cff-comment-replies a', function(){
2353                cffLoadCommentReplies( $(this) );
2354            });
2355
2356
2357            $('.cff-wrapper').each(function(){
2358                var $cff = $(this).find('#cff'),
2359                    cff_grid_pag = $cff.attr('data-grid-pag');
2360
2361                //Get the Access Token from the shortcode so it can be used in the connect file
2362                var shortcode_token_param = cffGetShortcodeToken($cff);
2363
2364                var $cffNumDiffHide = $(this).find('.cff');
2365                //maybe hide
2366                if (typeof $cffNumDiffHide.attr('data-nummobile') !== 'undefined') {
2367                    var num = typeof $cffNumDiffHide.attr('data-pag-num') !== 'undefined' && $cffNumDiffHide.attr('data-pag-num') !== '' ? parseInt($cffNumDiffHide.attr('data-pag-num')) : 1,
2368                        nummobile = typeof $cffNumDiffHide.attr('data-nummobile') !== 'undefined' && $cffNumDiffHide.attr('data-nummobile') !== '' ? parseInt($cffNumDiffHide.attr('data-nummobile')) : num,
2369                        itemSelector = $cffNumDiffHide.find('.cff-item').length ? '.cff-item' : '.cff-album-item';
2370                    if ($(window).width() < 480) {
2371                        if (nummobile < $cffNumDiffHide.find(itemSelector).length) {
2372                            $cffNumDiffHide.find(itemSelector).slice(nummobile - $cffNumDiffHide.find(itemSelector).length).addClass('cff-num-diff-hide');
2373                        }
2374                    } else {
2375                        if (num < $cffNumDiffHide.find(itemSelector).length) {
2376                            $cffNumDiffHide.find(itemSelector).slice(num - $cffNumDiffHide.find(itemSelector).length).addClass('cff-num-diff-hide');
2377                        }
2378                    }
2379                    $cffNumDiffHide.removeAttr('data-nummobile');
2380                }
2381
2382                //Masonry
2383                if( $cff.hasClass('cff-masonry-js' && ! $cff.hasClass('cff-all-reviews') ) ){
2384
2385                    if( $cff.find('.cff-album-item').length ){
2386                        $cff.removeClass('cff-masonry-js');
2387                        return;
2388                    }
2389
2390                    cffAddMasonry($cff);
2391                    //Call it again in case images aren't fully loaded
2392                    setTimeout(function(){ cffAddMasonry($cff); }, 1000);
2393
2394                    // Resizing the window can affect the masonry feed so it is reset on resize
2395                    $(window).on('resize', function () {
2396                        setTimeout(function(){
2397                            cffAddMasonry($cff);
2398                        }, 500);
2399                    });
2400
2401                    if( $cff.find('.cff-credit').length ) $cff.css('padding-bottom', 30);
2402                }
2403
2404                //Allow us to make some tweaks when the feed is narrow
2405                function cffCheckWidth(){
2406
2407                    if( $cff.hasClass('cff-album-items-feed') ){
2408                        var $cffElement = $cff;
2409                    } else {
2410                        var $cffElement = $cff.find('.cff-item').first();
2411                    }
2412
2413                    if( $cffElement.innerWidth() < 400 ){
2414                        if( !$cff.hasClass('cff-disable-narrow') ){
2415                            $cff.addClass('narrow');
2416                        }
2417                    } else {
2418                        $cff.removeClass('narrow');
2419                    }
2420                    if( $cffElement.innerWidth() < 250 ){
2421                        $cff.addClass('cff-super-narrow');
2422                    }
2423                }
2424                cffCheckWidth();
2425
2426                function cffActionLinksPos(){
2427                    if( $cff.find('.cff-item').first().innerWidth() < (190 + $('.cff-post-links').innerWidth() ) ){
2428                        $cff.find('.cff-post-links').addClass('cff-left')
2429                    } else {
2430                        $cff.find('.cff-post-links').removeClass('cff-left');
2431                    }
2432                }
2433                cffActionLinksPos();
2434
2435                //Only check the width once the resize event is over
2436                var cffdelay = (function(){
2437                    var cfftimer = 0;
2438                    return function(cffcallback, cffms){
2439                        clearTimeout (cfftimer);
2440                        cfftimer = setTimeout(cffcallback, cffms);
2441                    };
2442                })();
2443                window.addEventListener('resize', function(event){
2444                    cffdelay(function(){
2445                        cffCheckWidth();
2446                        cffActionLinksPos();
2447                        cffResizeAlbum();
2448                    }, 500);
2449                });
2450
2451                //Albums only
2452                //Resize image height
2453                function cffResizeAlbum(last){
2454                    var cffAlbumWidth = $cff.find('.cff-album-item').eq(0).find('a').innerWidth();
2455                    if ( !$cff.hasClass('cff-masonry')) {
2456                        $cff.find('.cff-album-item a').css('height', cffAlbumWidth);
2457                    }
2458                    //Crops event images when selected
2459                    $cff.find('.cff-photo.cff-crop').css( 'height', $cff.find('.cff-photo.cff-crop').width() );
2460
2461                    //Sets crop height of main post image to be 60% (or the height of the thumbs - whichever is larger - so it's never shorter than the thumbs) to make room for the thumbs beneath
2462                    $cff.find('.cff-item.cff-album .cff-photo.cff-multiple, .cff-video-post .cff-html5-video.cff-multiple').each(function(){
2463                        var $cffPhotoEl = $(this);
2464
2465                        //Crop image attachments in posts
2466                        var cffPhotoImgWidth = $cffPhotoEl.find('img').first().width();
2467                        if( cffPhotoImgWidth < 10 ) cffPhotoImgWidth = 300;
2468
2469                        if($cffPhotoEl.hasClass('cff-img-layout-3')) $cffPhotoEl.find('.cff-img-attachments .cff-crop').css( 'height', cffPhotoImgWidth/2 );
2470                        if($cffPhotoEl.hasClass('cff-img-layout-4')) $cffPhotoEl.find('.cff-img-attachments .cff-crop').css( 'height', cffPhotoImgWidth/3 );
2471
2472                        //Crop main image
2473                        if( $cffPhotoEl.is('.cff-img-layout-3, .cff-img-layout-4') ){
2474                            var $cffMainImage = $cffPhotoEl.find('.cff-main-image'),
2475                                cropPercentage = 0.6;
2476                            if( $cffPhotoEl.hasClass('cff-img-layout-4') ) cropPercentage = 0.8;
2477
2478                            //Set the height based on ratio
2479                            var cffImageHeight = Math.round( cffPhotoImgWidth / $cffMainImage.find('img').attr('data-ratio') );
2480                            $cffMainImage.css( 'height', Math.round( Math.max(cffImageHeight*cropPercentage, $cffPhotoEl.find('.cff-img-attachments').height() ) ) );
2481                        } else if( $cffPhotoEl.is('.cff-img-layout-2') ) {
2482                            var $cffCrop = $cffPhotoEl.find('.cff-img-wrap.cff-crop');
2483                            if( $cffPhotoEl.hasClass('cff-portrait') ){
2484                                $cffPhotoEl.find('.cff-img-wrap.cff-crop').css('height', $cffPhotoEl.width()*0.8 );
2485                            } else {
2486                                $cffPhotoEl.find('.cff-img-wrap.cff-crop').css('height', $cffPhotoEl.width()/2 );
2487                            }
2488                        }
2489
2490                        //If the main image is being cropped to zero then remove the crop so the full image is shown
2491                        if( last == true && ( $cffPhotoEl.is('.cff-img-layout-3') || $cffPhotoEl.is('.cff-img-layout-4') ) && $cffPhotoEl.find('.cff-main-image').height() < 10 ) $cffPhotoEl.find('.cff-img-layout-3 .cff-main-image img, .cff-img-layout-4 .cff-main-image img').css({
2492                            'display' : 'block',
2493                            'visibility' : 'visible'
2494                        })
2495
2496                        //Make "+6" text small if the images are small
2497                        if( cffPhotoImgWidth < 200 ){
2498                            $cffPhotoEl.addClass('cff-small-layout');
2499                        } else {
2500                            $cffPhotoEl.removeClass('cff-small-layout');
2501                        }
2502                    });
2503
2504                }
2505                cffResizeAlbum(false);
2506                setTimeout(function(){ cffResizeAlbum(false); }, 50);
2507                setTimeout(function(){ cffResizeAlbum(true); }, 500);
2508                setTimeout(function(){ cffResizeAlbum(true); }, 1500);
2509
2510
2511                //PAGINATION
2512                //Events JS pagination
2513                var num_events = parseInt( $cff.attr('data-pag-num') ),
2514                    show_events = num_events; //Iterated for each set
2515                //Show first set of events
2516                $cff.find('.cff-event').slice(0, num_events).css('display', 'inline-block');
2517                //cffResizeAlbum(); //Correctly recalcs height of event images when using eventimage=cropped
2518
2519                //Review JS pagination
2520                if( $cff.hasClass('cff-all-reviews') ){
2521                    var num_reviews = parseInt( $cff.attr('data-pag-num') ),
2522                        show_reviews = num_reviews;
2523
2524                    //Offset
2525                    var review_offset = parseInt($cff.attr('data-offset'));
2526                    if( typeof review_offset == 'undefined' || isNaN(review_offset) ) review_offset = 0;
2527
2528                    //Only show the required number of reviews
2529                    $cff.find('.cff-review').slice(0, num_reviews + review_offset ).css('display', 'inline-block');
2530
2531                    //Hide some reviews if using offset setting
2532                    if( review_offset > 0 ) $cff.find('.cff-review').slice(0, review_offset ).remove();
2533
2534                    //If using masonry then run it here
2535                    if( $cff.hasClass('cff-masonry-js') ) {
2536
2537                        cffAddMasonry($cff);
2538                        //Call it again in case images aren't fully loaded
2539                        setTimeout(function(){ cffAddMasonry($cff); }, 1000);
2540
2541                        // Resizing the window can affect the masonry feed so it is reset on resize
2542                        $(window).on('resize', function () {
2543                            setTimeout(function(){
2544                                cffAddMasonry($cff);
2545                            }, 500);
2546                        });
2547
2548                        if( $cff.find('.cff-credit').length ) $cff.css('padding-bottom', 30);
2549                    }
2550
2551                }
2552
2553                //Set a data attr that lets us know whether no posts were loaded into the feed so that we can change the "until" value in the next request
2554                var $cffLoadMore = $cff.find('#cff-load-more'),
2555                    cff_no_posts_added = $cff.find('.cff-load-more').attr('data-cff-no-posts-added');
2556                if (typeof cff_no_posts_added == typeof undefined || cff_no_posts_added == false) {
2557                    $cffLoadMore.attr('data-cff-no-posts-added', 'false');
2558                }
2559
2560                //If there's no posts in the feed initially then set the data-attr to be true
2561                if( $cff.find('.cff-item, .cff-album-item').length < 1 ) $cffLoadMore.attr('data-cff-no-posts-added', 'true');
2562
2563                // add the load more button and input to simulate a dynamic json file call
2564                $cffLoadMore.off().on('click', function() {
2565                    // reveal any hidden posts due to difference in desktop vs mobile devices
2566                    // read the json that is in the cff-data-shortcode that contains all of the shortcode arguments
2567                    var shortcodeData = $cff.attr('data-cff-shortcode'),
2568                        $paginationURL = $cff.find('.cff-pag-url'),
2569                        pag_url = $paginationURL.attr('data-cff-pag-url'),
2570                        feed_id = $paginationURL.attr('data-transient-name'),
2571                        post_id = $paginationURL.attr('data-post-id'),
2572                        location = CffFeed.prototype.locationGuess($cff);
2573                    //Upmcoming events JS pagination
2574                    var events_count = $cff.find('.cff-upcoming-event').length;
2575                    //If it's an event feed
2576                    if( events_count > 0 ){
2577                        show_events = show_events + num_events;
2578                        //Show the next set of events
2579                        $cff.find('.cff-upcoming-event').slice(0, show_events).css('display', 'inline-block');
2580                        if( show_events > events_count ){
2581                            $cff.find('#cff-load-more').hide();
2582                            cff_no_more_posts($cff, $cffLoadMore);
2583                        }
2584
2585                        //Re-init masonry for JS
2586                        if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
2587                            cffAddMasonry($cff);
2588                        }
2589                        return;
2590                    }
2591
2592                    //Reviews JS pagination
2593                    if( $cff.hasClass('cff-all-reviews') ){
2594                        var reviews_count = $cff.find('.cff-review').length;
2595                        //If it's an reviews feed
2596                        if( reviews_count > 0 ){
2597                            show_reviews = show_reviews + num_reviews;
2598                            //Show the next set of reviews
2599                            $cff.find('.cff-review').slice(0, show_reviews).css('display', 'inline-block');
2600                            if( show_reviews > reviews_count ){
2601                                $cff.find('#cff-load-more').hide();
2602                                cff_no_more_posts($cff, $cffLoadMore);
2603                            }
2604
2605                            //Re-init masonry for JS
2606                            if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
2607                                cffAddMasonry($cff);
2608                            }
2609                            return;
2610                        }
2611                    }
2612
2613
2614                    //Remove the ID so it can't be clicked twice before the posts are loaded
2615                    $cffLoadMore.off().removeAttr('id').addClass('cff-disabled');
2616
2617                    // remove the hidden field since it will be replaced with new before token and after token next url data
2618                    $paginationURL.remove();
2619
2620
2621                    //If it's a photo/vid/album feed then change the selector
2622                    if( $cff.hasClass('cff-album-items-feed') ){
2623                        var item_sel = '.cff-album-item';
2624                    } else {
2625                        var item_sel = '.cff-item';
2626                    }
2627
2628                    if( item_sel == '.cff-album-item' ){
2629                        //If the next_url is empty then use the prev_url
2630                        if( (pag_url == '' || pag_url == '{}') ) pag_url = $paginationURL.attr('data-cff-prev-url');
2631
2632                        //Loop through the previous URLs and if the next URL is empty for an ID then add it in
2633                        var prev_urls = $paginationURL.attr('data-cff-prev-url');
2634
2635                        //Convert the JSON string into an object so we can loop through it
2636                        var prev_urls_arr = ( typeof prev_urls == 'undefined' ) ? '' : JSON.parse( prev_urls );
2637                    }
2638
2639                    //Parse the urls string into an array so we can loop through it
2640                    var pag_url_arr = ( typeof pag_url == 'undefined' ) ? '' : JSON.parse( pag_url );
2641
2642                    if( item_sel == '.cff-album-item' ){
2643                        //Add the URL to the next_urls if it doesn't exist in the array
2644                        for (var key in prev_urls_arr) {
2645                            if (prev_urls_arr.hasOwnProperty(key)) {
2646                                if( typeof pag_url_arr[key] == 'undefined' ) pag_url_arr[key] = prev_urls_arr[key];
2647                            }
2648                        }
2649                    }
2650                    if( (pag_url == '' || pag_url == '{}' || pag_url == 0 || pag_url == '0' ) && item_sel == '.cff-item' ){
2651                        $cffLoadMore.hide();
2652                        cff_no_more_posts($cff, $cffLoadMore);
2653                    } else {
2654                        //Display loader
2655                        $cffLoadMore.addClass('cff-loading').append('<div class="cff-loader"></div>');
2656                        $cffLoadMore.find('.cff-loader').css('background-color', $cffLoadMore.css('color'));
2657                    }
2658
2659
2660                    //Check which pagination method to use
2661                    var cff_timeline_api_paging = false;
2662                    if( $cff.attr('data-timeline-pag') ) cff_timeline_api_paging = true;
2663
2664                    if( cff_timeline_api_paging == true ){
2665                        //Use the raw "next" URL with the "paging_token" in it, as using the "until" method can cause a problem with groups due to the fact that the recent activity ordering method of groups can cause the last post in a feed to have an older date than those in the next batch, and so some are missed when paginating using the date.
2666                    } else {
2667                        //Loop through the pag array. Replace the until params for each id. Stringify to send in the ajax request
2668                        for (var key in pag_url_arr) {
2669                            if (pag_url_arr.hasOwnProperty(key) && key != 'latest_record_date') {
2670
2671                                var this_url = pag_url_arr[key],
2672                                    until_old = cffGetParameterByName('until', this_url),
2673                                    $last_item = $cff.find(item_sel+'.cff-' + key).last(),
2674                                    until_new = (parseInt( $last_item.attr('data-cff-timestamp') ) - 1).toString(),
2675                                    backdated_new = false;
2676
2677                                //If the post is backdated then use that instead as the API orders posts by backdate
2678                                if( typeof $last_item.attr('data-cff-backdated') != 'undefined' ){
2679                                    until_new = (parseInt( $last_item.attr('data-cff-backdated') ) - 1).toString();
2680                                }
2681
2682                                //If there's no posts in the feed for a specific author then use the timestamp from the last post in the feed from any author
2683                                if( isNaN(parseFloat(until_new)) ){
2684                                    $last_item = $cff.find(item_sel).last();
2685                                    until_new = (parseInt( $last_item.attr('data-cff-timestamp') ) - 1).toString();
2686
2687                                    //If the post is backdated then use that instead as the API orders posts by backdate
2688                                    if( typeof $last_item.attr('data-cff-backdated') != 'undefined' ){
2689                                        until_new = (parseInt( $last_item.attr('data-cff-backdated') ) - 1).toString();
2690                                    }
2691                                }
2692
2693                                var new_url = this_url;
2694
2695                                if( $cffLoadMore.attr('data-cff-no-posts-added') == 'true' ){
2696                                    //If there were no posts added to the feed from the previous response then don't replace the until_old with the until_new in the next request
2697                                } else {
2698                                    //If it's a regular timeline feed then add the "until" param
2699                                    if( item_sel !== '.cff-album-item' ){
2700
2701                                        //V2.9+ of the API don't include "until" in the next url so only replace it if it exists
2702                                        if( this_url.indexOf("until=") !== -1 ){
2703                                            //Replace old until value with new one in the URL
2704                                            var new_url = this_url.replace("until="+until_old,"until="+until_new);
2705                                        } else {
2706                                            //If "until" doesn't exist then add it to the end of the URL
2707                                            var new_url = this_url + "&until="+until_new;
2708                                        }
2709
2710                                        //Remove the "after" param as it overrides the "until" param
2711                                        if( new_url.indexOf('&after=') > -1 ) new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
2712
2713                                    }
2714
2715                                }
2716
2717                                //USE OFFSET PAGINATION METHOD
2718                                if( cff_grid_pag == 'offset' ){
2719                                    if( item_sel == '.cff-album-item' ){
2720                                        //If it's an album item then remove the "after" param as it overrides the "until" param
2721                                        if( new_url.indexOf('&after=') > -1 ) new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
2722
2723                                        //Add the offset param for pagination as time based doesn't work with albums due to the albums not always being in date order, and the other type of paging doesn't work due to filtering/higher post limits
2724                                        key = key.replace( /(:|\.|\[|\]|,|=)/g, "\\$1" );
2725                                        var albumItemCount = $cff.find('.cff-album-item.cff-' + key).length + $cff.find('.cff-empty-album.cff
2725-' + key).length;
2726                                        if( new_url.indexOf('&offset=') > -1 ){
2727                                            new_url = new_url.replace("&offset="+cffGetParameterByName('offset', new_url), "&offset="+albumItemCount);
2728                                        } else {
2729                                            new_url = new_url + "&offset=" + albumItemCount;
2730                                        }
2731                                        key = key.replace(/\\/g, '');
2732                                    }
2733                                }
2734                                //END USE OFFSET PAGINATION METHOD
2735
2736
2737                                //If it's an events only URL then remove the "after" param as we're using the "until" value instead
2738                                if( (this_url.indexOf('/events') > -1 && this_url.indexOf('&after=') > -1) || (this_url.indexOf('/ratings') > -1 && this_url.indexOf('&after=') > -1 && $cff.hasClass('cff-all-reviews') ) ){
2739                                    new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
2740                                }
2741
2742                                //Remove the "__paging_token" parameter from the URL as it causes some posts to be missing and it isn't needed as we're using "until"
2743                                if( new_url.indexOf('&__paging_token') > -1 ){
2744                                    new_url = new_url.replace("&__paging_token="+cffGetParameterByName('__paging_token', new_url),"");
2745                                }
2746
2747                                pag_url_arr[key] = new_url;
2748                            }
2749                        } // End pag_url_arr loop
2750                    } // End cff_timeline_api_paging if/else
2751
2752                    var pageAtt = typeof $cff.attr('data-page') !== 'undefined' ? $cff.attr('data-page') : 1,
2753                        page = parseInt(pageAtt) + 1;
2754                    $cff.attr('data-page', page);
2755                    //Convert the array back into a string
2756                    pag_url = JSON.stringify( pag_url_arr );
2757                    jQuery.ajax({
2758                        url : cffajaxurl,
2759                        type : 'post',
2760                        data : {
2761                            action : 'cff_get_new_posts',
2762                            shortcode_data : shortcodeData,
2763                            pag_url : pag_url,
2764                            feed_id : feed_id,
2765                            post_id : post_id,
2766                            location : location,
2767                            page: page
2768                        },
2769                        success : function(data) {
2770                            $cff.find('.cff-num-diff-hide').removeClass('cff-num-diff-hide');
2771                            //If there's no posts added to the feed then set a data attr on the button so that we can change the "until" value to get a new batch next time
2772                            //Check by seeing if the data contains a div (ie. post)
2773                            if( data.indexOf('<div class=') == -1 && data.indexOf('<span class=') == -1 ){
2774                                $cffLoadMore.attr('data-cff-no-posts-added', 'true');
2775                            } else {
2776                                $cffLoadMore.attr('data-cff-no-posts-added', 'false');
2777                            }
2778
2779                            //Appends the html echoed out in cff_get_new_posts() to the last existing post element
2780                            if( $cff.find('.cff-item, .cff-album-item').length ){
2781                                $cff.find('.cff-item, .cff-album-item').addClass('cff-masonry-new').removeClass('cff-new').last().after(data);
2782                            } else {
2783                                //If there's no posts yet then just add it into the posts container
2784                                $cff.find('.cff-posts-wrap').append(data);
2785                            }
2786                            /*
2787                            if($cff.find('.cff-pag-url').attr('data-cff-pag-url') == 0){
2788                                $cffLoadMore.hide();
2789                                cff_no_more_posts($cff, $cffLoadMore);
2790                            }
2791                            */
2792
2793                            //Replace any duplicate album items with empty items so doesn't affect offset pagination
2794                            $cff.find('.cff-album-item').each(function (i) {
2795                                var $el = $('[id="' + this.id + '"]').eq(1);
2796                                if($el.length){
2797                                    this_classes = $el.attr('class');
2798                                    this_classes = this_classes.replace("cff-album-item","");
2799                                }
2800                            });
2801
2802                            //Remove loader
2803                            $cffLoadMore.removeClass('cff-loading').find('.cff-loader').remove();
2804                            //Re-add the ID so it can be clicked again
2805                            $cffLoadMore.attr('id', 'cff-load-more').removeClass('cff-disabled');
2806
2807                            //Rerun JS (only runs on new items - .cff-new)
2808                            cff_init( $cff );
2809
2810                            // rerun image resolution code for new images
2811                            var feedIndex = parseInt($cffLoadMore.closest('.cff').attr('data-cff-index')) - 1;
2812                            if (typeof window.cff !== 'undefined' && window.cff.feeds[feedIndex] !== 'undefined') {
2813                                window.cff.feeds[feedIndex].afterLoadMoreClicked($cffLoadMore);
2814                            }
2815                            /*
2816                            if( $cff.hasClass('cff-album-items-feed')){
2817                                cffAddMasonry($cff);
2818                            }
2819                            */
2820                            //Re-init masonry
2821                            var albumOverride = $cff.find('.cff-album-item').length && $cff.hasClass('cff-disable-liquid');
2822                            if( albumOverride || ($cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css')) ){
2823                                $cff.masonry('appended', $cff.find('.cff-new'));
2824                                $cff.find('.cff-view-comments, .cff-comment-replies a, .cff-show-more-comments a').off().on('click', function() {
2825                                    if( !$cff.hasClass('cff-opaque-comments') ){
2826                                        setTimeout(function(){
2827                                            cffAddMasonry($cff);
2828                                        }, 500);
2829                                    }
2830                                });
2831                            }
2832
2833                            //If there's no more API URLs to hit then hide the load more button
2834                            var next_urls = $cff.find('.cff-pag-url').attr('data-cff-pag-url');
2835                            if( item_sel == '.cff-item' || cff_grid_pag == 'cursor' ){
2836                                if( next_urls == '{}' ) cff_no_more_posts($cff, $cffLoadMore);
2837                            } else {
2838                                if( data.indexOf('class="cff-album-item') < 0 && data.indexOf('class="cff-empty-album') < 0 ){
2839                                    cff_no_more_posts($cff, $cffLoadMore);
2840                                }
2841                            }
2842
2843                            // Call Custom JS if it exists
2844                            // if (typeof cff_custom_js == 'function') setTimeout(function(){ cff_custom_js(jQuery); }, 100);
2845                            if (typeof cff_custom_js == 'function') cff_custom_js(jQuery);
2846
2847                        } // End success
2848                    }); // End Ajax call
2849                //Hover on Load More button
2850                }).on('mouseenter',  function() {
2851                        $(this).css('background', $(this).attr('data-cff-hover') );
2852                }).on('mouseleave', function() {
2853                        $(this).css('background', $(this).attr('data-cff-bg') );
2854                });
2855
2856                function cff_no_more_posts($cff, $cffLoadMore){
2857                    var no_more_posts_text = ( $cffLoadMore.attr('data-no-more') == '' ) ? 'No more posts' : $cffLoadMore.attr('data-no-more').replace(/\\'/g,"'");
2858                    if( $cff.find('.cff-no-more-posts').length < 1 ) $cffLoadMore.hide().after('<p class="cff-no-more-posts">'+no_more_posts_text+'</p>');
2859                }
2860
2861                //Remove the masonry css class if it's a grid feed
2862                if( $cff.find('.cff-album-item').length ){
2863                    $cff.removeClass('cff-masonry cff-masonry-js cff-masonry-css');
2864                }
2865
2866                //Multiple event dates toggle
2867                $cff.find('.cff-more-dates').on('click', function(){
2868                    $(this).siblings('.cff-multiple-dates').slideToggle(100);
2869                });
2870
2871
2872            }); // End .$('.cff-wrapper').each
2873
2874             function cffGetCommentsIDArray(){
2875                    var commentsArrayIDs = [];
2876                    $('.cff-posts-wrap').each(function(){
2877                        var wrapper = $(this);
2878                        wrapper.find('.cff-item.cff-new:not(.cff-event)').each(function(){
2879                            var $self = $(this),
2880                            post_id_orig = $self.find('.cff-view-comments').attr('id'),
2881                            object_id = $self.closest('.cff-item').attr('data-object-id');
2882                            commentsArrayIDs.push(post_id_orig);
2883                        });
2884
2885                    });
2886                    return commentsArrayIDs;
2887                }
2888
2889                function cffGetFeedLocatorDataArray(){
2890                    var feedLocatorData = [];
2891                    $('.cff-timeline-feed').each(function(){
2892                        $cffPagUrl = $(this).find('.cff-pag-url');
2893                        var singleFeedLocatorData = {
2894                            feedID : $cffPagUrl.attr('data-feed-id'),
2895                            postID : $cffPagUrl.attr('data-post-id'),
2896                            shortCodeAtts : $(this).attr('data-cff-shortcode').trim() == '' ? {} : JSON.parse($(this).attr('data-cff-shortcode')),
2897                            location : CffFeed.prototype.locationGuess($(this))
2898                        };
2899                        feedLocatorData.push(singleFeedLocatorData);
2900                    });
2901                    return feedLocatorData;
2902                }
2903            //GET/CACHE COMMENTS
2904            //Check if the meta transient exists (set in head JS vars) and that a timeline feed exists on the page
2905            if($('.cff-timeline-feed').length && (typeof cffdisablecommentcaching == 'undefined') ){
2906                var commentsArrayIDs = cffGetCommentsIDArray(),
2907                feedLocatorData =  cffGetFeedLocatorDataArray();
2908
2909                //If the comments data is cached then get it from the transient in the DB
2910                var atts = typeof $cff.attr('data-cff-shortcode') !== 'undefined' && $cff.attr('data-cff-shortcode').indexOf('{') === 0 ? JSON.parse($cff.attr('data-cff-shortcode')) : {};
2911                var page = typeof $cff.attr('data-page') !== 'undefined' ? parseInt($cff.attr('data-page')) : 1;
2912
2913                $.ajax({
2914                    url: cffajaxurl,
2915                    type: 'POST',
2916                    async: true,
2917                    cache: false,
2918                    data:{
2919                        action: 'get_meta',
2920                        comments_array_ids : commentsArrayIDs,
2921                        feedLocatorData : feedLocatorData,
2922                        atts: atts,
2923                        page: page
2924                    },
2925                    success: function(data) {
2926                        //If there's no data then set the array to be empty so that it hits the API for the data
2927                        if( data == '' || data.length < 1 ){
2928                            metaArr = [];
2929                        } else {
2930                            //Decode the JSON to that it can be used again
2931                            //Replace any escaped single quotes as it results in invalid JSON
2932                            data = data.replace(/\\'/g, "'");
2933                            //Convert the cached JSON string back to a JSON object
2934                            metaArr = JSON.parse( data );
2935                        }
2936                        // $cff.find('.cff-item.cff-new').each(function(){
2937                        $cff.each(function(){
2938                            $(this).find('.cff-item.cff-new:not(.cff-event)').each(function(){
2939                                var $self = $(this),
2940                                    post_id_orig = $self.find('.cff-view-comments').attr('id'),
2941                                    object_id = $self.closest('.cff-item').attr('data-object-id');
2942                                //If the post ID doesn't exist in the array then use the API to get the data
2943                                if( metaArr.hasOwnProperty(post_id_orig) && metaArr[post_id_orig] != ""){
2944                                    cffCreateComments($self, JSON.parse(metaArr[post_id_orig])['content']);
2945                                    cffAddFullsizeImageURLs($self, JSON.parse(metaArr[post_id_orig])['content']);
2946                                } else {
2947                                    cffGetMetaAPI($self, post_id_orig, object_id);
2948                                }
2949                            });
2950                        });
2951                    },
2952                    error: function(xhr,textStatus,e) {
2953                        return;
2954                    }
2955
2956                }); //End ajax
2957
2958            } else {
2959                $('#cff .cff-item.cff-new:not(.cff-event)').each(function(){
2960                    var $self = $(this),
2961                    post_id_orig = $self.find('.cff-view-comments').attr('id'),
2962                    object_id = $self.closest('.cff-item').attr('data-object-id');
2963                    cffGetMetaAPI($self, post_id_orig, object_id);
2964                });
2965            } //END GET/CACHE COMMENTS
2966
2967            function cffGetMetaAPI($self, post_id_orig, object_id){
2968
2969                //If there's no comments box on the page then return so we don't hit the API to get the data
2970                if( $self.find('.cff-view-comments').length == 0 ) return;
2971
2972                if( typeof object_id == 'undefined' || object_id.length < 2 ) object_id = '';
2973
2974                var object_id_query = ''+object_id,
2975                    post_id_query = '?post_id='+post_id_orig,
2976                    use_id = 'object',
2977                    post_comment_count = $self.find('.cff-comments .cff-count').text(),
2978                    post_likes_count = $self.find('.cff-likes .cff-count').text(),
2979                    cff_page_id = $self.attr('data-page-id');
2980
2981                if( typeof post_comment_count == 'undefined' || post_comment_count == '' ) post_comment_count = 0;
2982                //Load comment counts via JS
2983                if( typeof $self.attr('data-comments-js') !== 'undefined' ){
2984                    if( typeof post_comment_count == 'undefined' || post_comment_count == '' ) post_comment_count = 1;
2985                }
2986                if( typeof post_likes_count == 'undefined' || post_likes_count == '' ) post_like
2986s_count = 0;
2987
2988                //If it's a video post or there's no object ID then use the post ID (video posts don't have "images" field)
2989                // if( typeof object_id == 'undefined' || object_id.length < 2 || $self.hasClass('cff-video-post') ) use_id = 'post';
2990                if( typeof object_id == 'undefined' || object_id.length < 2 || $self.find('.cff-comments-box').hasClass('cff-shared-story') || $self.hasClass('cff-timeline-event') ) use_id = 'post';
2991
2992                var timeline_event = '';
2993                if( $self.hasClass('cff-timeline-event') ) timeline_event = '&timeline_event=true';
2994
2995                var usegrouptoken = '',
2996                    useowntoken = '';
2997                if( $self.closest('#cff').hasClass('cff-group') ) usegrouptoken = '&usegrouptoken=true';
2998                if( $self.closest('#cff').attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
2999
3000                shortcode_token_param = cffGetShortcodeToken( $self.closest('#cff') );
3001
3002                //Is it a video post? If so, then we may be able to use the object ID to get the embeddable video object
3003                var cff_is_video_post = $self.hasClass('cff-video-post') ? '&isvideo=true' : '';
3004
3005                var url = cffsiteurl + "/custom-facebook-feed-pro/query.php?o_id=" + object_id + '&post_id='+post_id_orig + '&use_id=' + use_id + timeline_event + usegrouptoken + useowntoken + '&comments_num=' + post_comment_count + '&likes_num=' + post_likes_count + '&type=meta' + cff_is_video_post + '&pageid=' + cff_page_id + shortcode_token_param;
3006
3007                if( $self.hasClass('cff-album') ) url += '&timelinealbum=true';
3008
3009                //Get comments, reactions, and full size images data from the API
3010                if( locatefile == true && typeof window.cff_block_editor === 'undefined' ){
3011                    var submitData = {
3012                        action: 'cff_query',
3013                        o_id: object_id,
3014                        post_id: post_id_orig,
3015                        use_id: use_id,
3016                        comments_num: post_comment_count,
3017                        likes_num: post_likes_count,
3018                        type: 'meta',
3019                        pageid: cff_page_id,
3020                    };
3021                    if( $self.hasClass('cff-video-post') ) {
3022                        submitData.isvideo = true;
3023                    }
3024                    if( $self.hasClass('cff-timeline-event') ) {
3025                        submitData.timeline_event = true;
3026                    }
3027                    if( $self.closest('#cff').hasClass('cff-group') ) {
3028                        submitData.usegrouptoken = true;
3029                    }
3030                    if( $self.closest('#cff').attr('data-own-token') == 'true' ) {
3031                        submitData.useowntoken = true;
3032                    }
3033                    if( shortcode_token_param !== '' ){
3034                        var token = shortcode_token_param.split('=');
3035
3036                        submitData.at = token[1];
3037                    }
3038
3039                    var onSuccess = function(data) {
3040                        metaArray.push( {'id_post' : post_id_orig, 'content' : data} );
3041                        //Cache the comments by adding to the cache array
3042                        metaArr[ post_id_orig ] = data;
3043                        newMetaArr[ post_id_orig ] = data; //This is cached. Only the new comments.
3044                        //Add the comments HTML
3045                        cffCreateComments($self, data);
3046
3047                        //Replace images URLs with full size ones
3048                        cffAddFullsizeImageURLs($self, data);
3049                        //Set the cache
3050                        cffSetMetaCache(metaArray);
3051
3052                    };
3053                    cffAjax(submitData,onSuccess);
3054                }
3055
3056            } //End cffGetMetaAPI()
3057
3058            //Only allow this function to run once every time new posts are loaded so that a load of ajax requests aren't all fired off at once. It's called once and then runs 3 times in total to cache all comments on the page into the cff_meta transient.
3059            var cffSetMetaCache_executed = false;
3060            function cffSetMetaCache(newMetaArr){
3061                if( typeof cffdisablecommentcaching != 'undefined' ) return;
3062                if( !cffSetMetaCache_executed ){
3063
3064                    //Cache the comments data
3065                    var cffTimesCached = 0,
3066                        cffCacheDelay = setTimeout(function() {
3067                            //Try to cache it multiple times so that if the comments data isn't finished returning the first time then the subsequent attempts gets it
3068                            var cffCacheInterval = setInterval(function(){
3069
3070                                cffCacheMeta(newMetaArr);
3071
3072                                cffTimesCached++;
3073                                if(cffTimesCached == 2) clearInterval(cffCacheInterval);
3074                            }, 3000);
3075
3076                            //Send the data to DB initially via ajax after a 0.5 second delay
3077                            cffCacheMeta(newMetaArr);
3078                        }, 500);
3079
3080                    cffSetMetaCache_executed = true;
3081
3082                } // End cffRunFunction check
3083
3084
3085
3086
3087                //Cache the likes and comments counts by sending an array via ajax to the main plugin file which then stores it in a transient
3088                function cffCacheMeta(newMetaArr){
3089                    //Convert the JSON object to a string
3090                    var jsonstring = JSON.stringify( newMetaArr );
3091
3092                    //If the comments data is cached then get it from the transient in the DB
3093                    var atts = typeof $cff.attr('data-cff-shortcode') !== 'undefined' && $cff.attr('data-cff-shortcode').indexOf('{') === 0 ? JSON.parse($cff.attr('data-cff-shortcode')) : {};
3094                    var page = typeof $cff.attr('data-page') !== 'undefined' ? parseInt($cff.attr('data-page')) : 1;
3095
3096                    //Encode the JSON string so that it can be stored in the database
3097                    //Cache the data
3098                    var opts = {
3099                        url: cffajaxurl,
3100                        type: 'POST',
3101                        async: true,
3102                        cache: false,
3103                        data:{
3104                            action: 'cache_meta',
3105                            metadata: jsonstring, // Passes array of meta data to WP to cache
3106                            atts: atts,
3107                            page: page
3108                        },
3109                        success: function(response) {
3110                            return;
3111                        },
3112                        error: function(xhr,textStatus,e) {
3113                            return;
3114                        }
3115                    };
3116                    $.ajax(opts);
3117
3118                } // End cffCacheMeta()
3119
3120            } // End cffSetMetaCache()
3121
3122
3123            function cffGetParameterByName(name, url) {
3124                name = name.replace(/[\[\]]/g, "\\$&");
3125                var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
3126                    results = regex.exec(url);
3127                if (!results) return null;
3128                if (!results[2]) return '';
3129                return decodeURIComponent(results[2].replace(/\+/g, " "));
3130            }
3131
3132            function cffLinkify(inputText) {
3133                var replacedText, replacePattern1, replacePattern2, replacePattern3;
3134
3135                //URLs starting with http://, https://, or ftp://
3136                replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
3137                replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank" rel="nofollow noopener noreferrer">$1</a>');
3138
3139                //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
3140                replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
3141                replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank" rel="nofollow noopener noreferrer">$2</a>');
3142
3143                //Change email addresses to mailto:: links.
3144                replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
3145                replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
3146
3147                return replacedText;
3148            }
3149
3150
3151            //HTML5 Video play button
3152            $(document).off('click', '#cff .cff-html5-video .cff-html5-play').on('click', '#cff .cff-html5-video .cff-html5-play', function(e){
3153                e.preventDefault();
3154
3155                var $self = $(this),
3156                    $videoWrapper = $self.closest('.cff-html5-video'),
3157                    video = $self.siblings('video')[0];
3158                video.play();
3159                $self.hide();
3160                $self.siblings('.cff-poster').hide();
3161
3162                //Show controls when the play button is clicked
3163                if (video.hasAttribute("controls")) {
3164                    video.removeAttribute("controls")
3165                } else {
3166                    video.setAttribute("controls","controls")
3167                }
3168
3169                if($videoWrapper.innerWidth() < 150 && !$videoWrapper.hasClass('cff-no-video-expand')) {
3170                    $videoWrapper.css('width','100%').closest('.cff-item').find('.cff-text-wrapper').css('width','100%');
3171                }
3172            });
3173
3174
3175            //Replace the lightbox image with the full size image which is retrieved in the meta API request
3176            function cffAddFullsizeImageURLs($self, data){
3177                var data = JSON.parse( data );
3178
3179                if( typeof data.images !== 'undefined' && data.images !== null ) $self.find('.cff-lightbox-link').attr('href', data.images[0].source);
3180
3181                //Removed in v3.7 as shouldn't be needed any longer. Commenting out in case needs to be re-added.
3182                //Add the full size video image which is retrieved from query.php to fix the Facebook video image size API bug
3183                // if( $self.find('.cff-html5-video').length && typeof data.attachments !== 'undefined' && data.attachments !== null ){
3184                //  $self.find('.cff-poster').attr('src', data.attachments.data[0].media.image.src);
3185                //  console.log( data.attachments.data[0] );
3186                //  $self.find('.cff-lightbox-link').attr('href', data.attachments.data[0].media.image.src);
3187                // }
3188            }
3189
3190
3191            //Create comments
3192            function cffCreateComments($self, data){
3193
3194                if (data.substring(0, 1) == "<") return false;
3195
3196                //Convert string of data received from comments.php to a JSON object
3197                var data = JSON.parse( data ),
3198                    cff_comments = '',
3199                    cff_likes_this = '',
3200                    commentShow = parseInt( $self.find('.cff-comments-box').attr('data-num') ),
3201                    like_count = ( typeof data.likes !== 'undefined' ) ? data.likes.summary.total_count : 0,
3202                    $cffCommentsBox = $self.find('.cff-comments-box'),
3203                    $cffCommentLikes = $cffCommentsBox.find('.cff-comment-likes'),
3204                    cff_hide_comment_avatars = Boolean($self.find('.cff-comments-box').attr('data-cff-hide-avatars')),
3205                    cff_expand_comments = Boolean($self.find('.cff-comments-box').attr('data-cff-expand-comments')),
3206                    cff_translate_like_this_text = $cffCommentsBox.attr('data-cff-like-text'),
3207                    cff_translate_likes_this_text = $cffCommentsBox.attr('data-cff-likes-text'),
3208                    cff_translate_reacted_to_this_text = $cffCommentsBox.attr('data-cff-reacted-text'),
3209                    cff_translate_and_text = $cffCommentsBox.attr('data-cff-and-text'),
3210                    cff_translate_other_text = $cffCommentsBox.attr('data-cff-other-text'),
3211                    cff_translate_others_text = $cffCommentsBox.attr('data-cff-others-text'),
3212                    cff_translate_reply_text = $cffCommentsBox.attr('data-cff-reply-text'),
3213                    cff_translate_replies_text = $cffCommentsBox.attr('data-cff-replies-text'),
3214                    cff_total_comments_count = ( typeof data.comments !== 'undefined' ) ? data.comments.summary.total_count : 0,
3215                    cff_meta_link_color = $self.find('.cff-comments-box').attr('data-cff-meta-link-color'),
3216                    cff_post_tags = Boolean( $self.find('.cff-comments-box').attr('data-cff-post-tags') );
3217
3218                //Load comment counts via JS
3219                if( typeof $self.attr('data-comments-js') !== 'undefined' ){
3220                    var comment_count = ( typeof data.comments !== 'undefined' ) ? data.comments.summary.total_count : 0;
3221                    $self.find('.cff-comments .cff-count').text(comment_count);
3222                }
3223
3224                //ADD REACTIONS
3225                var cff_haha_count = ( typeof data.haha !== 'undefined' ) ? data.haha.summary.total_count : 0;
3226                var cff_love_count = ( typeof data.love !== 'undefined' ) ? data.love.summary.total_count : 0;
3227                var cff_wow_count = ( typeof data.wow !== 'undefined' ) ? data.wow.summary.total_count : 0;
3228                var cff_sad_count = ( typeof data.sad !== 'undefined' ) ? data.sad.summary.total_count : 0;
3229                var cff_angry_count = ( typeof data.angry !== 'undefined' ) ? data.angry.summary.total_count : 0;
3230
3231                var reactions_arr = [cff_haha_count, cff_love_count, cff_wow_count, cff_sad_count, cff_angry_count];
3232                var reaction_first_num = reactions_arr.sort(sortNumber)[0];
3233                var reaction_second_num = reactions_arr.sort(sortNumber)[1];
3234
3235                //Sort array highest to lowest
3236                function sortNumber(a,b) {
3237                    return b - a;
3238                }
3239
3240                var reactions_html = '',
3241                    love_added = false,
3242                    haha_added = false,
3243                    wow_added = false,
3244                    sad_added = false,
3245                    angry_added = false,
3246                    love_svg = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M462.3 62.7c-54.5-46.4-136-38.7-186.6 13.5L256 96.6l-19.7-20.3C195.5 34.1 113.2 8.7 49.7 62.7c-62.8 53.6-66.1 149.8-9.9 207.8l193.5 199.8c6.2 6.4 14.4 9.7 22.6 9.7 8.2 0 16.4-3.2 22.6-9.7L472 270.5c56.4-58 53.1-154.2-9.7-207.8zm-13.1 185.6L256.4 448.1 62.8 248.3c-38.4-39.6-46.4-115.1 7.7-161.2 54.8-46.8 119.2-12.9 142.8 11.5l42.7 44.1 42.7-44.1c23.2-24 88.2-58 142.8-11.5 54 46 46.1 121.5 7.7 161.2z"></path></svg>'+'<span class="cff-svg-bg-dark"><svg class="cff-svg-bg" role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"></path></svg></span>',
3247                    haha_svg = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm152.7 400.7c-19.8 19.8-43 35.4-68.7 46.3-26.6 11.3-54.9 17-84.1 17s-57.5-5.7-84.1-17c-25.7-10.9-48.8-26.5-68.7-46.3-19.8-19.8-35.4-43-46.3-68.7-11.3-26.6-17-54.9-17-84.1s5.7-57.5 17-84.1c10.9-25.7 26.5-48.8 46.3-68.7 19.8-19.8 43-35.4 68.7-46.3 26.6-11.3 54.9-17 84.1-17s57.5 5.7 84.1 17c25.7 10.9 48.8 26.5 68.7 46.3 19.8 19.8 35.4 43 46.3 68.7 11.3 26.6 17 54.9 17 84.1s-5.7 57.5-17 84.1c-10.8 25.8-26.4 48.9-46.3 68.7zM281.8 206.3l80 48c11.5 6.8 24
3247-7.6 15.4-18L343.6 196l33.6-40.3c8.6-10.3-3.8-24.8-15.4-18l-80 48c-7.7 4.7-7.7 15.9 0 20.6zm-147.6 48l80-48c7.8-4.7 7.8-15.9 0-20.6l-80-48c-11.6-6.9-24 7.7-15.4 18l33.6 40.3-33.6 40.3c-8.7 10.4 3.8 24.8 15.4 18zM383 288H113c-9.6 0-17.1 8.4-15.9 18 8.8 71 69.4 126 142.9 126h16c73.4 0 134-55 142.9-126 1.2-9.6-6.3-18-15.9-18zM256 400h-16c-50.2 0-93.5-33.3-107.4-80h230.8c-13.9 46.7-57.2 80-107.4 80z"></path></svg>'+'<svg class="cff-svg-bg" role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 152c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm88 272h-16c-73.4 0-134-55-142.9-126-1.2-9.5 6.3-18 15.9-18h270c9.6 0 17.1 8.4 15.9 18-8.9 71-69.5 126-142.9 126z"></path></svg>',
3248                    wow_svg = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 464c-119.1 0-216-96.9-216-216S128.9 40 248 40s216 96.9 216 216-96.9 216-216 216zm0-184c-35.3 0-64 28.7-64 64s28.7 64 64 64 64-28.7 64-64-28.7-64-64-64zm0 96c-17.6 0-32-14.4-32-32s14.4-32 32-32 32 14.4 32 32-14.4 32-32 32zm-48-176c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32zm128-32c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32z"></path></svg>'+'<svg class="cff-svg-bg" role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zM136 208c0-17.7 14.3-32 32-32s32 14.3 32 32-14.3 32-32 32-32-14.3-32-32zm112 208c-35.3 0-64-28.7-64-64s28.7-64 64-64 64 28.7 64 64-28.7 64-64 64zm80-176c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"></path></svg>',
3249                    sad_svg = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 464c-119.1 0-216-96.9-216-216S128.9 40 248 40s216 96.9 216 216-96.9 216-216 216zm0-152c-44.4 0-86.2 19.6-114.8 53.8-5.7 6.8-4.8 16.9 2 22.5 6.8 5.7 16.9 4.8 22.5-2 22.4-26.8 55.3-42.2 90.2-42.2s67.8 15.4 90.2 42.2c5.3 6.4 15.4 8 22.5 2 6.8-5.7 7.7-15.8 2-22.5C334.2 339.6 292.4 320 248 320zm-80-80c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z"></path></svg>'+'<svg class="cff-svg-bg" role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm170.2 218.2C315.8 367.4 282.9 352 248 352s-67.8 15.4-90.2 42.2c-13.5 16.3-38.1-4.2-24.6-20.5C161.7 339.6 203.6 320 248 320s86.3 19.6 114.7 53.8c13.6 16.2-11 36.7-24.5 20.4z"></path></svg>',
3250                    angry_svg = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 464c-119.1 0-216-96.9-216-216S128.9 40 248 40s216 96.9 216 216-96.9 216-216 216zm0-136c-31.2 0-60.6 13.8-80.6 37.8-5.7 6.8-4.8 16.9 2 22.5s16.9 4.8 22.5-2c27.9-33.4 84.2-33.4 112.1 0 5.3 6.4 15.4 8 22.5 2 6.8-5.7 7.7-15.8 2-22.5-19.9-24-49.3-37.8-80.5-37.8zm-48-96c0-2.9-.9-5.6-1.7-8.2.6.1 1.1.2 1.7.2 6.9 0 13.2-4.5 15.3-11.4 2.6-8.5-2.2-17.4-10.7-19.9l-80-24c-8.4-2.5-17.4 2.3-19.9 10.7-2.6 8.5 2.2 17.4 10.7 19.9l31 9.3c-6.3 5.8-10.5 14.1-10.5 23.4 0 17.7 14.3 32 32 32s32.1-14.3 32.1-32zm171.4-63.3l-80 24c-8.5 2.5-13.3 11.5-10.7 19.9 2.1 6.9 8.4 11.4 15.3 11.4.6 0 1.1-.2 1.7-.2-.7 2.7-1.7 5.3-1.7 8.2 0 17.7 14.3 32 32 32s32-14.3 32-32c0-9.3-4.1-17.5-10.5-23.4l31-9.3c8.5-2.5 13.3-11.5 10.7-19.9-2.4-8.5-11.4-13.2-19.8-10.7z"></path></svg><span class="cff-svg-bg-dark"><svg class="cff-svg-bg" role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zM136 240c0-9.3 4.1-17.5 10.5-23.4l-31-9.3c-8.5-2.5-13.3-11.5-10.7-19.9 2.5-8.5 11.4-13.2 19.9-10.7l80 24c8.5 2.5 13.3 11.5 10.7 19.9-2.1 6.9-8.4 11.4-15.3 11.4-.5 0-1.1-.2-1.7-.2.7 2.7 1.7 5.3 1.7 8.2 0 17.7-14.3 32-32 32S136 257.7 136 240zm168 154.2c-27.8-33.4-84.2-33.4-112.1 0-13.5 16.3-38.2-4.2-24.6-20.5 20-24 49.4-37.8 80.6-37.8s60.6 13.8 80.6 37.8c13.8 16.5-11.1 36.6-24.5 20.5zm76.6-186.9l-31 9.3c6.3 5.8 10.5 14.1 10.5 23.4 0 17.7-14.3 32-32 32s-32-14.3-32-32c0-2.9.9-5.6 1.7-8.2-.6.1-1.1.2-1.7.2-6.9 0-13.2-4.5-15.3-11.4-2.5-8.5 2.3-17.4 10.7-19.9l80-24c8.4-2.5 17.4 2.3 19.9 10.7 2.5 8.5-2.3 17.4-10.8 19.9z"></path></svg></span>',
3251                    like_svg = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496.656 285.683C506.583 272.809 512 256 512 235.468c-.001-37.674-32.073-72.571-72.727-72.571h-70.15c8.72-17.368 20.695-38.911 20.695-69.817C389.819 34.672 366.518 0 306.91 0c-29.995 0-41.126 37.918-46.829 67.228-3.407 17.511-6.626 34.052-16.525 43.951C219.986 134.75 184 
3251192 162.382 203.625c-2.189.922-4.986 1.648-8.032 2.223C148.577 197.484 138.931 192 128 192H32c-17.673 0-32 14.327-32 32v256c0 17.673 14.327 32 32 32h96c17.673 0 32-14.327 32-32v-8.74c32.495 0 100.687 40.747 177.455 40.726 5.505.003 37.65.03 41.013 0 59.282.014 92.255-35.887 90.335-89.793 15.127-17.727 22.539-43.337 18.225-67.105 12.456-19.526 15.126-47.07 9.628-69.405zM32 480V224h96v256H32zm424.017-203.648C472 288 472 336 450.41 347.017c13.522 22.76 1.352 53.216-15.015 61.996 8.293 52.54-18.961 70.606-57.212 70.974-3.312.03-37.247 0-40.727 0-72.929 0-134.742-40.727-177.455-40.727V235.625c37.708 0 72.305-67.939 106.183-101.818 30.545-30.545 20.363-81.454 40.727-101.817 50.909 0 50.909 35.517 50.909 61.091 0 42.189-30.545 61.09-30.545 101.817h111.999c22.73 0 40.627 20.364 40.727 40.727.099 20.363-8.001 36.375-23.984 40.727zM104 432c0 13.255-10.745 24-24 24s-24-10.745-24-24 10.745-24 24-24 24 10.745 24 24z"></path></svg>'+'<svg class="cff-svg-bg" role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M104 224H24c-13.255 0-24 10.745-24 24v240c0 13.255 10.745 24 24 24h80c13.255 0 24-10.745 24-24V248c0-13.255-10.745-24-24-24zM64 472c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zM384 81.452c0 42.416-25.97 66.208-33.277 94.548h101.723c33.397 0 59.397 27.746 59.553 58.098.084 17.938-7.546 37.249-19.439 49.197l-.11.11c9.836 23.337 8.237 56.037-9.308 79.469 8.681 25.895-.069 57.704-16.382 74.757 4.298 17.598 2.244 32.575-6.148 44.632C440.202 511.587 389.616 512 346.839 512l-2.845-.001c-48.287-.017-87.806-17.598-119.56-31.725-15.957-7.099-36.821-15.887-52.651-16.178-6.54-.12-11.783-5.457-11.783-11.998v-213.77c0-3.2 1.282-6.271 3.558-8.521 39.614-39.144 56.648-80.587 89.117-113.111 14.804-14.832 20.188-37.236 25.393-58.902C282.515 39.293 291.817 0 312 0c24 0 72 8 72 81.452z"></path></svg>',
3252                    like_svg_2 = '<svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M466.27 286.69C475.04 271.84 480 256 480 236.85c0-44.015-37.218-85.58-85.82-85.58H357.7c4.92-12.81 8.85-28.13 8.85-46.54C366.55 31.936 328.86 0 271.28 0c-61.607 0-58.093 94.933-71.76 108.6-22.747 22.747-49.615 66.447-68.76 83.4H32c-17.673 0-32 14.327-32 32v240c0 17.673 14.327 32 32 32h64c14.893 0 27.408-10.174 30.978-23.95 44.509 1.001 75.06 39.94 177.802 39.94 7.22 0 15.22.01 22.22.01 77.117 0 111.986-39.423 112.94-95.33 13.319-18.425 20.299-43.122 17.34-66.99 9.854-18.452 13.664-40.343 8.99-62.99zm-61.75 53.83c12.56 21.13 1.26 49.41-13.94 57.57 7.7 48.78-17.608 65.9-53.12 65.9h-37.82c-71.639 0-118.029-37.82-171.64-37.82V240h10.92c28.36 0 67.98-70.89 94.54-97.46 28.36-28.36 18.91-75.63 37.82-94.54 47.27 0 47.27 32.98 47.27 56.73 0 39.17-28.36 56.72-28.36 94.54h103.99c21.11 0 37.73 18.91 37.82 37.82.09 18.9-12.82 37.81-22.27 37.81 13.489 14.555 16.371 45.236-5.21 65.62zM88 432c0 13.255-10.745 24-24 24s-24-10.745-24-24 10.745-24 24-24 24 10.745 24 24z"></path></svg>';
3253
3254
3255                //Add first reaction
3256                var reaction_one_html = '';
3257                if( reaction_first_num > 0 ){
3258                    if(data.love.summary.total_count == reaction_first_num){
3259                        reaction_one_html += '<span class="cff-love cff-reaction-one cff-icon">'+love_svg+'</span>';
3260                        love_added = true;
3261                    }
3262                    if(data.haha.summary.total_count == reaction_first_num){
3263                        reaction_one_html += '<span class="cff-haha cff-reaction-one cff-icon">'+haha_svg+'</span>';
3264                        haha_added = true;
3265                    }
3266                    if(data.wow.summary.total_count == reaction_first_num){
3267                        reaction_one_html += '<span class="cff-wow cff-reaction-one cff-icon">'+wow_svg+'</span>';
3268                        wow_added = true;
3269                    }
3270                    if(data.sad.summary.total_count == reaction_first_num){
3271                        reaction_one_html += '<span class="cff-sad cff-reaction-one cff-icon">'+sad_svg+'</span>';
3272                        sad_added = true;
3273                    }
3274                    if(data.angry.summary.total_count == reaction_first_num){
3275                        reaction_one_html += '<span class="cff-angry cff-reaction-one cff-icon">'+angry_svg+'</span>';
3276                        angry_added = true;
3277                    }
3278                    reactions_html += reaction_one_html;
3279                }
3280
3281                //If reaction one doesn't already contain two reactions (eg: if the two reaction_one
3281s are the same number) then don't include a reaction_two
3282                if( reaction_one_html.split('cff-reaction-one').length < 3 ){
3283                    //Add second reaction
3284                    if( reaction_second_num > 0 ){
3285                        var reaction_two_html = '';
3286
3287                        if(data.love.summary.total_count == reaction_second_num && !love_added){
3288                            reaction_two_html = '<span class="cff-love cff-reaction-two cff-icon">'+love_svg+'</span>';
3289                        }
3290                        if(data.haha.summary.total_count == reaction_second_num && !haha_added){
3291                            reaction_two_html = '<span class="cff-haha cff-reaction-two cff-icon">'+haha_svg+'</span>';
3292                        }
3293                        if(data.wow.summary.total_count == reaction_second_num && !wow_added){
3294                            reaction_two_html = '<span class="cff-wow cff-reaction-two cff-icon">'+wow_svg+'</span>';
3295                        }
3296                        if(data.sad.summary.total_count == reaction_second_num && !sad_added){
3297                            reaction_two_html = '<span class="cff-sad cff-reaction-two cff-icon">'+sad_svg+'</span>';
3298                        }
3299                        if(data.angry.summary.total_count == reaction_second_num && !angry_added){
3300                            reaction_two_html = '<span class="cff-angry cff-reaction-two cff-icon">'+angry_svg+'</span>';
3301                        }
3302                        reactions_html += reaction_two_html;
3303                    }
3304                }
3305
3306                //Add the reaction icons
3307                if( $self.find('.cff-meta .cff-likes').find('.cff-icon').length < 2 ) $self.find('.cff-meta .cff-likes .cff-icon').after( reactions_html );
3308
3309                //If there's no likes but there's a reacton then don't show the like icon - show the reaction icon instead
3310                if( parseInt(like_count) == 0 && ( parseInt(cff_love_count) > 0 || parseInt(cff_haha_count) > 0 || parseInt(cff_wow_count) > 0 || parseInt(cff_sad_count) > 0 || parseInt(cff_angry_count) > 0 ) ){
3311                    $self.find('.cff-meta .cff-likes .cff-like').remove();
3312                    $self.find('.cff-meta .cff-likes span').addClass('cff-no-animate');
3313                }
3314
3315                //Add reactions to like count
3316                var cff_reactions_count = parseInt(like_count) + parseInt(cff_love_count) + parseInt(cff_haha_count) + parseInt(cff_wow_count) + parseInt(cff_sad_count) + parseInt(cff_angry_count);
3317                if( cff_reactions_count > 0 ) $self.find('.cff-meta .cff-likes .cff-count').text( cff_reactions_count );
3318
3319
3320                //ADDS REACTIONS TO COMMENTS BOX
3321                var cff_no_reactions = false;
3322                if( cff_love_count == 0 && cff_haha_count == 0 && cff_wow_count == 0 && cff_sad_count == 0 && cff_angry_count == 0 ) cff_no_reactions = true;
3323
3324                var reactions_count_html = '<span class="cff-reactions-count">';
3325
3326                if( parseInt(like_count) > 0){
3327                    reactions_count_html += '<span class="cff-like cff-icon">'+like_svg+'</span>';
3328
3329                    if( !cff_no_reactions ){
3330                        if( parseInt(like_count) > 0 ) reactions_count_html += '<span class="cff-like-count">
3330'+like_count+'</span>';
3331                        if( cff_love_count > 0 ) reactions_count_html += '<span class="cff-reaction-wrap"><span class="cff-love cff-icon">'+love_svg+'</span><span class="cff-love-count">'+cff_love_count+'</span></span>';
3332                        if( cff_haha_count > 0 ) reactions_count_html += '<span class="cff-reaction-wrap"><span class="cff-haha cff-icon">'+haha_svg+'</span><span class="cff-haha-count">'+cff_haha_count+'</span></span>';
3333                        if( cff_wow_count > 0 ) reactions_count_html += '<span class="cff-reaction-wrap"><span class="cff-wow cff-icon">'+wow_svg+'</span><span class="cff-wow-count">'+cff_wow_count+'</span></span>';
3334                        if( cff_sad_count > 0 ) reactions_count_html += '<span class="cff-reaction-wrap"><span class="cff-sad cff-icon">'+sad_svg+'</span><span class="cff-sad-count">'+cff_sad_count+'</span></span>';
3335                        if( cff_angry_count > 0 ) reactions_count_html += '<span class="cff-reaction-wrap"><span class="cff-angry cff-icon">'+angry_svg+'</span><span class="cff-angry-count">'+cff_angry_count+'</span></span>';
3336                    }
3337                }
3338                reactions_count_html += '</span>';
3339
3340                //CREATE LIKES PART AT TOP OF COMMENTS BOX
3341                if( typeof data.likes !== 'undefined' ){
3342                    if( data.likes.data.length ){
3343
3344                        cff_likes_this += '<span class="cff-likes-this-text">';
3345
3346                        var liker_one = '',
3347                            liker_two = '';
3348
3349                        if ( like_count > 0 && typeof data.likes.data[0] !== 'undefined' ){
3350
3351                            //Only link the name if a legit link is available for this user
3352                            var userHasLink = false;
3353                            if( typeof data.likes.data[0].link !== 'undefined' ){
3354                                if( data.likes.data[0].link.indexOf('/app_scoped_user_id/') == -1 ) userHasLink = true;
3355                            }
3356
3357                            //Creat link or span
3358                            userHasLink ? liker_one += '<a href="'+data.likes.data[0].link+'" target="_blank" rel="nofollow noopener" class="cff-liker-one-name" style="color:'+cff_meta_link_color+';' : liker_one = '<span class="cff-liker-one-name" style="';
3359                            if (cff_no_reactions) liker_one += ' margin-left: 5px';
3360                            liker_one += '">'+data.likes.data[0].name;
3361
3362                            userHasLink ? liker_one += '</a>' : liker_one += '</span>';
3363                        }
3364
3365                        if ( like_count > 1 && typeof data.likes.data[1] !== 'undefined' ){
3366
3367                            //Only link the name if a legit link is available for this user
3368                            var userHasLink = false;
3369                            if( typeof data.likes.data[1].link !== 'undefined' ){
3370                                if( data.likes.data[1].link.indexOf('/app_scoped_user_id/') == -1 ) userHasLink = true;
3371                            }
3372
3373                            //Creat link or span
3374                            userHasLink ? liker_two += '<a href="'+data.likes.data[1].link+'" target="_blank" rel="nofollow noopener" style="color:'+cff_meta_link_color+'">' : liker_two = '<span>';
3375                            liker_two += data.likes.data[1].name;
3376
3377                            userHasLink ? liker_two += '</a>' : liker_two += '</span>';
3378                        }
3379
3380                        if (like_count == 1){
3381                            cff_likes_this += liker_one+' '+cff_translate_likes_this_text;
3382                        } else if (like_count == 2){
3383                            cff_likes_this += liker_one+' '+cff_translate_and_text+' '+liker_two+' '+cff_translate_like_this_text;
3384                        } else if (like_count == 3){
3385                            cff_likes_this += liker_one+', '+liker_two+' '+cff_translate_and_text+' 1 '+cff_translate_other_text+' '+cff_translate_like_this_text;
3386                        } else {
3387                            cff_likes_this += liker_one+', '+liker_two+' '+cff_translate_and_text+' ';
3388                            if (like_count == 25) cff_likes_this += '<span class="cff-comment-likes-count">';
3389                            cff_likes_this += parseInt(cff_reactions_count)-2;
3390                            if (like_count == 25) cff_likes_this += '</span>';
3391                            cff_likes_this += ' '+cff_translate_others_text;
3392
3393                            if( parseInt(cff_reactions_count) == parseInt(like_count) ){
3394                                cff_likes_this += ' '+cff_translate_like_this_text;
3395                            } else {
3396                                cff_likes_this += ' '+cff_translate_reacted_to_this_text;
3397                            }
3398
3399                        }
3400
3401                        cff_likes_this += '</span>';
3402
3403                        if( $cffCommentLikes.find('.cff-reactions-count').length < 1 ) $cffCommentLikes.append('<span class="cff-likes-info-wrap">' + reactions_count_html + cff_likes_this + '</span>');
3404
3405                    } else {
3406                        //If there's no likes data then hide the top of the comments box that shows the "likes this" section
3407                        if( cff_no_reactions ){
3408                            $cffCommentLikes.hide();
3409                        } else {
3410                            if( $cffCommentLikes.find('.cff-reactions-count').length < 1 ) $cffCommentLikes.append('<span class="cff-likes-info-wrap">' + reactions_count_html + '</span>');
3411                        }
3412                    }
3413
3414                }
3415
3416
3417                if( typeof data.comments !== 'undefined' ){
3418                    $.each(data.comments.data, function(i, commentItem) {
3419                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
3420
3421                        //Do a final encode of the comment message
3422                        var comment_message = cffEncodeHTML(commentItem.message),
3423                            comment_message = cffLinkify(comment_message),
3424                            cff_comment_author_info = true,
3425                            cff_hide_comment_avatars = Boolean($self.find('.cff-comments-box').attr('data-cff-hide-avatars'));
3426
3427                        //Check whether comment author info exists - only accessible with page access token from the page now
3428                        if( typeof commentItem.from !== 'undefined' ){
3429                            cff_comment_from_id = commentItem.from.id;
3430                        } else {
3431                            cff_hide_comment_avatars = true;
3432                            cff_comment_author_info = false;
3433                            cff_comment_from_id = '';
3434                        }
3435
3436                        cff_comments += '<div class="cff-comment" id="cff_'+commentItem.id+'" data-id="'+cff_comment_from_id+'"';
3437                        cff_comments += ' style="';
3438                        ( i >= commentShow ) ? cff_comments += 'display: none;' : cff_comments += 'display: block;';
3439                        if( typeof $self.find('#cff_'+commentItem.id).attr('style') !== 'undefined' ) cff_comments += $self.find('#cff_'+commentItem.id).attr('style');
3440                        cff_comments += '"';
3441                        if( typeof commentItem.from !== 'undefined' ){
3442                            if( typeof commentItem.from.picture !== 'undefined' ){
3443                                cff_comments += 'data-avatar="'+commentItem.from.picture.data.url+'"';
3444                            }
3445                        }
3446                        cff_comments += '>';
3447                        cff_comments += '<div class="cff-comment-text-wrapper">';
3448                        cff_comments += '<div class="cff-comment-text';
3449                        if( cff_hide_comment_avatars ) cff_comments += ' cff-no-image';
3450                        cff_comments += '"><p>';
3451                        if( cff_comment_author_info ){
3452                            if( typeof commentItem.from.link !== 'undefined' ){
3453                                cff_comments += '<a href="'+commentItem.from.link+'" class="cff-name" target="_blank" rel="nofollow noopener" style="color:' + cff_meta_link_color + '">
3453'+commentItem.from.name+'</a>';
3454                            } else {
3455                                cff_comments += '<span class="cff-name">'+commentItem.from.name+'</span>';
3456                            }
3457                        }
3458
3459                        //MESSAGE TAGS
3460                        if( cff_post_tags && commentItem.hasOwnProperty('message_tags') ){
3461
3462                            //Loop through the tags and use the name to replace them
3463                            $.each(commentItem.message_tags, function(i, message_tag) {
3464                                tag_name = message_tag.name;
3465                                tag_link = '<a href="http://facebook.com/'+message_tag.id+'" target="_blank" rel="nofollow noopener" style="color:'+cff_meta_link_color+'">'+message_tag.name+'</a>';
3466
3467                                comment_message = comment_message.replace(tag_name, tag_link);
3468                            });
3469
3470                        } //END MESSAGE TAGS
3471
3472                        cff_comments += comment_message+'</p>';
3473
3474
3475                        //Add image attachment if exists
3476                        if( commentItem.hasOwnProperty('attachment') ){
3477                            if( commentItem.attachment.hasOwnProperty('media') ){
3478                                if (consentGiven) {
3479                                    cff_comments += '<a class="cff-comment-attachment" href="https://facebook.com/'+commentItem.id+'" target="_blank" rel="nofollow noopener"><img src="'+commentItem.attachment.media.image.src+'" alt="';
3480                                } else {
3481                                    cff_comments += '<a class="cff-comment-attachment" href="https://facebook.com/'+commentItem.id+'" target="_blank" rel="nofollow noopener"><span class="cff-comment-image-placeholder" data-src="'+commentItem.attachment.media.image.src+'"></span>';
3482                                }
3483
3484                                if (consentGiven) {
3485                                    if( commentItem.attachment.hasOwnProperty('title') ){
3486                                        cff_comments += commentItem.attachment.title;
3487                                    } else {
3488                                        cff_comments += 'Attachment';
3489                                    }
3490                                    cff_comments += '" /></a>';
3491                                } else {
3492                                    cff_comments += '</a>';
3493
3494                                }
3495
3496                            }
3497                        }
3498
3499                        cff_comments += '<span class="cff-time">';
3500                        var cff_middot = '',
3501                            cff_comment_time = $self.find('#cff_'+commentItem.id).attr('data-cff-comment-date');
3502                        //If the time is undefined then don't show it
3503                        if( typeof cff_comment_time !== 'undefined' ){
3504                            cff_comments += '<span class="cff-comment-date">'+cff_comment_time+'</span>';
3505                            cff_middot = '&nbsp; &middot; &nbsp;';
3506                        }
3507                        if ( commentItem.like_count > 0 ) cff_comments += '<span class="cff-comment-likes"><span class="cff-comment-likes-bg"><b>'+like_svg_2+'</b>
3507'+commentItem.like_count+'</span></span>';
3508                        cff_comments += '</span>';
3509
3510                        //Comment replies
3511                        var cff_comment_count = parseInt(commentItem.comment_count);
3512                        if( cff_comment_count > 0 ){
3513                            //Get this from a data attr on the comments box container
3514                            var cff_replies_text_string = '';
3515                            (cff_comment_count == 1) ? cff_replies_text_string = cff_translate_reply_text : cff_replies_text_string = cff_translate_replies_text;
3516                            cff_comments += '<p class="cff-comment-replies" data-id="'+commentItem.id+'"><a class="cff-comment-replies-a" href="javascript:void(0);" style="color:' + cff_meta_link_color + '"><span class="cff-replies-icon"></span>'+cff_comment_count+' '+cff_replies_text_string+'</a></p><div class="cff-comment-replies-box cff-empty"></div>';
3517                        }
3518
3519                        cff_comments += '</div>'; //End .cff-comment-text
3520                        cff_comments += '</div>'; //End .cff-comment-text-wrapper
3521
3522                        //Only load the comment avatars if they're being displayed initially, otherwise load via JS on click to save all the HTTP requests on page load
3523                        if( !cff_hide_comment_avatars && cff_comment_author_info ){
3524                            cff_comments += '<div class="cff-comment-img cff-avatar-fallback">';
3525                            if( typeof commentItem.from.link !== 'undefined' ) cff_comments += '<a href="https://facebook.com/'+commentItem.from.link+'" target="_blank" rel="noopener">';
3526                            if( cff_expand_comments && (i < commentShow) ) {
3527                                if (consentGiven) {
3528                                    cff_comments += '<img src="'+commentItem.from.picture.data.url+'" width=32 height=32 alt="'+commentItem.from.name+'" onerror="this.style.display=\'none\'">';
3529                                } else {
3530                                    cff_comments += '<span class="cff-comment-avatar-placeholder" data-src="'+commentItem.from.picture.data.url+'">';
3531                                }
3532                            } else {
3533                                cff_comments += '<span class="cff-comment-avatar"></span>';
3534                            }
3535                            if( typeof commentItem.from.link !== 'undefined' ) cff_comments += '</a>';
3536                            cff_comments += '</div>';
3537                        }
3538
3539                        cff_comments += '</div>'; //End .cff-comment
3540
3541                    }); //End data.comments.data loop
3542
3543                } //End if
3544
3545                //Remove the comments added for SEO in PHP
3546                $self.find('.cff-comments-wrap .cff-comment').remove();
3547                //Add the comments to the page
3548                $self.find('.cff-comments-wrap').prepend( cff_comments );
3549                $self.find('.cff-show-more-comments').attr('data-cff-comments-total', cff_total_comments_count);
3550
3551                //Add border radius
3552                if( $self.find('.cff-comment-likes span').length > 0 ) $self.find('.cff-comment-on-facebook').css({'border-top-left-radius':"0",'border-top-right-radius':"0"});
3553                if( $self.find('.cff-comments-wrap .cff-comment').length > 0 ) $self.find('.cff-comment-on-facebook').css({'border-bottom-left-radius':"0",'border-bottom-right-radius':"0"});
3554                //Add a little more padding if there's no comments
3555                if( $self.find('.cff-comments-wrap .cff-comment').length < 1 ) $self.find('.cff-comment-on-facebook').css('padding','8px 15px 8px 10px');
3556
3557                setTimeout(function(){
3558                    if( $self.closest('.cff').hasClass('cff-masonry-js') && !$self.closest('.cff').hasClass('cff-masonry-css') ) cffAddMasonry( $self.closest('.cff') );
3559                }, 200);
3560
3561            } //End cffCreateComments()
3562
3563
3564            //Check if any lazy loading plugins have changed the image src
3565            function cff_lazy_load_correction(){
3566
3567                var $ = jQuery;
3568
3569                // The lightbox link needs to be reset to the original source
3570                $('.cff-lightbox-link').each(function(){
3571                    var $lbLink = $(this);
3572
3573                    if( $lbLink.closest('.cff-album-item').attr('data-cff-full-size') ){
3574                        lborigSrc = $lbLink.attr('data-cff-full-size');
3575                    } else {
3576                        lborigSrc = $lbLink.parent().find('img').attr('data-orig-source');
3577                    }
3578                    $lbLink.attr('href', lborigSrc);
3579                })
3580
3581                // Check if lazy load placeholder image is being used
3582                $('img[data-orig-source]').each(function(){
3583                    var $self = $(this),
3584                        currentSrc = $self.attr('src'),
3585                        originalSrc = $self.attr('data-orig-source');
3586
3587                    // Check if the img source has been changed by lazy loading
3588                    if(originalSrc != currentSrc){
3589                        $self.attr('src', originalSrc);
3590                    }
3591
3592                    // Timeline album posts need the background source reset
3593                    if($self.hasClass('cff-multi-image')){
3594                        $self.css('background-image', 'url(' + originalSrc + ')');
3595                    }
3596                });
3597
3598                // Need to set a default value for the link slider in shared links otherwise it gets a 1px width
3599                $('.cff-link-slider').each(function(){
3600                    $(this).find('.cff-link-slider-slides').css('width', '2500px')
3601                });
3602            }
3603
3604            if (typeof window.cff === 'undefined' || typeof window.cff.feeds === 'undefined') {
3605                if (!$cff.find('.cff_resized_image_data').length) {
3606                    cff_lazy_load_correction();
3607                }
3608            } else if (typeof window.cff.feeds[0] !== 'undefined') {
3609                if (!window.cff.feeds[0].settings.resizingEnabled) {
3610                    cff_lazy_load_correction();
3611                }
3612            }
3613
3614            //Create shared link multi-image slider
3615            setTimeout(function(){
3616
3617                $cff.find('.cff-link-slider').each(function(){
3618
3619                    var $cffLinkSlider = $(this),
3620                        $cffLinkSliderSlides = $cffLinkSlider.find('.cff-link-slider-slides'),
3621                        $cffLinkSliderItem = $cffLinkSliderSlides.find('.cff-link-slider-item'),
3622                        cffLinkSliderCount = $cffLinkSliderItem.length,
3623                        cffLinkSliderWidth = $cffLinkSlider.width(),
3624                        cffCurSlide = 0;
3625                    $cffLinkSliderSlides.css({ width: cffLinkSliderWidth * cffLinkSliderCount });
3626                    $cffLinkSliderItem.css({ width: cffLinkSliderWidth });
3627
3628                    function cffMoveSlide(dir) {
3629                        //Change slides
3630                        dir == 'prev' ? cffCurSlide-- : cffCurSlide++;
3631                        $cffLinkSliderSlides.css('left', -cffCurSlide*cffLinkSliderWidth);
3632
3633                        //Hide the nav arrows at beginning/end
3634                        cffCurSlide == cffLinkSliderCount-1 ? $cffLinkSlider.find('a.cff-slider-next').hide() : $cffLinkSlider.find('a.cff-slider-next').show();
3635                        cffCurSlide > 0 ? $cffLinkSlider.find('a.cff-slider-prev').show() : $cffLinkSlider.find('a.cff-slider-prev').hide();
3636                    };
3637                    //Nav arrows click
3638                    $cffLinkSlider.find('a.cff-slider-prev, a.cff-slider-next').on('click', function(e){
3639                        e.preventDefault();
3640                        $(this).hasClass('cff-slider-prev') ? cffMoveSlide('prev') : cffMoveSlide('next');
3641                    });
3642                    //Vertically center last image in slider
3643                    setTimeout(function(){
3644                        var cffLastSlideHeight = $cffLinkSliderSlides.find('.cff-link-slider-item').first().height();
3645                        $cffLinkSliderSlides.find('.cff-final-item').css('height', cffLastSlideHeight).find('img').css('margin-top', (cffLastSlideHeight/2)-100 );
3646                    }, 1500);
3647
3648                    //Show all slides (initially hidden in CSS)
3649                    $cffLinkSliderSlides.find('.cff-link-slider-item').show();
3650
3651                });
3652
3653            }, 200);
3654
3655
3656        })(jQuery); //End (function($){
3657
3658        /*!
3659        imgLiquid v0.9.944 / 03-05-2013
3660        https://github.com/karacas/imgLiquid
3661        */
3662
3663        var imgLiquid = imgLiquid || {VER: '0.9.944'};
3664        imgLiquid.bgs_Available = false;
3665        imgLiquid.bgs_CheckRunned = false;
3666        //Add the CSS using CSS as then it's only used when the JS file runs, otherwise with Ajax themes it's hiding the images but then the JS isn't running. This way still allows the images to display even if the JS doesn't run.
3667        jQuery('.cff').each(function() {
3668            if (!jQuery(this).hasClass('cff-disable-liquid')) {
3669                $cff.find('.cff-new .cff-album-cover img').css('visibility', 'hidden');
3670            }
3671        });
3672        $cff.find('.cff-new .cff-crop img').css('visibility', 'hidden');
3673        jQuery('#cff .cff-img-attachments .cff-crop img').css('opacity', 0);
3674
3675
3676        (function ($) {
3677
3678            // ___________________________________________________________________
3679
3680            function checkBgsIsavailable() {
3681                if (imgLiquid.bgs_CheckRunned) return;
3682                else imgLiquid.bgs_CheckRunned = true;
3683
3684                var spanBgs = $('<span style="background-size:cover" />');
3685                $('body').append(spanBgs);
3686
3687                !function () {
3688                    var bgs_Check = spanBgs[0];
3689                    if (!bgs_Check || !window.getComputedStyle) return;
3690                    var compStyle = window.getComputedStyle(bgs_Check, null);
3691                    if (!compStyle || !compStyle.backgroundSize) return;
3692                    imgLiquid.bgs_Available = (compStyle.backgroundSize === 'cover');
3693                }();
3694
3695                spanBgs.remove();
3696            }
3697
3698
3699            // ___________________________________________________________________
3700
3701            $.fn.extend({
3702                imgLiquid: function (options) {
3703
3704                    this.defaults = {
3705                        fill: true,
3706                        verticalAlign: 'center',            //  'top'   //  'bottom' // '50%'  // '10%'
3707                        horizontalAlign: 'center',          //  'left'  //  'right'  // '50%'  // '10%'
3708                        useBackgroundSize: false,
3709                        useDataHtmlAttr: true,
3710
3711                        responsive: true,                   /* Only for use with BackgroundSize false (or old browsers) */
3712                        delay: false,                           /* Only for use with BackgroundSize false (or old browsers) */
3713                        fadeInTime: false,                      /* Only for use with BackgroundSize false (or old browsers) */
3714                        removeBoxBackground: true,          /* Only for use with Backgroun
3714dSize false (or old browsers) */
3715                        hardPixels: true,                   /* Only for use with BackgroundSize false (or old browsers) */
3716                        responsiveCheckTime: 500,           /* Only for use with BackgroundSize false (or old browsers) */ /* time to check div resize */
3717                        timecheckvisibility: 500,           /* Only for use with BackgroundSize false (or old browsers) */ /* time to recheck if visible/loaded */
3718
3719                        // CALLBACKS
3720                        onStart: null,                      // no-params
3721                        onFinish: null,                     // no-params
3722                        onItemStart: null,                  // params: (index, container, img )
3723                        onItemFinish: function(index, container, img){  // params: (index, container, img )
3724                            img.addClass('cffFadeIn');
3725                        },
3726                        onItemError: null                   // params: (index, container, img )
3727                    };
3728
3729                    checkBgsIsavailable();
3730                    var imgLiquidRoot = this;
3731
3732                    // Extend global settings
3733                    this.options = options;
3734                    this.settings = $.extend({}, this.defaults, this.options);
3735
3736                    // CallBack
3737                    if (this.settings.onStart) this.settings.onStart();
3738
3739
3740                    // ___________________________________________________________________
3741
3742                    return this.each(function ($i) {
3743
3744                        // MAIN >> each for image
3745
3746                        var settings = imgLiquidRoot.settings,
3747                            $imgBoxCont = $(this),
3748                            $img = $('img:first',$imgBoxCont);
3749                        if (!$img.length) {onError(); return;}
3750
3751
3752                        // Extend settings
3753                        if (!$img.data('imgLiquid_settings')) {
3754                            // First time
3755                            settings = $.extend({}, imgLiquidRoot.settings, getSettingsOverwrite());
3756                        } else {
3757                            // Recall
3758                            // Remove Classes
3759                            $imgBoxCont.removeClass('imgLiquid_error').removeClass('imgLiquid_ready');
3760                            settings = $.extend({}, $img.data('imgLiquid_settings'), imgLiquidRoot.options);
3761                        }
3762                        $img.data('imgLiquid_settings', settings);
3763
3764
3765                        // Start CallBack
3766                        if (settings.onItemStart) settings.onItemStart($i, $imgBoxCont, $img); /* << CallBack */
3767
3768
3769                        // Process
3770                        if (imgLiquid.bgs_Available && settings.useBackgroundSize)
3771                            processBgSize();
3772                        else
3773                            processOldMethod();
3774
3775
3776                        // END MAIN <<
3777
3778                        // ___________________________________________________________________
3779
3780                        function processBgSize() {
3781
3782                            // Check change img src
3783                            if ($imgBoxCont.css('background-image').indexOf(encodeURI($img.attr('src'))) === -1) {
3784                                // Change
3785                                $imgBoxCont.css({'background-image': 'url("' + encodeURI($img.attr('src')) + '")'});
3786                            }
3787
3788                            $imgBoxCont.css({
3789                                'background-size':      (settings.fill) ? 'cover' : 'contain',
3790                                'background-position':  (settings.horizontalAlign + ' ' + settings.verticalAlign).toLowerCase(),
3791                                'background-repeat':    'no-repeat'
3792                            });
3793
3794                            $('a:first', $imgBoxCont).css({
3795                                'display':  'block',
3796                                'width':    '100%',
3797                                'height':   '100%'
3798                            });
3799
3800                            $('img', $imgBoxCont).css({'display': 'none'});
3801
3802                            if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
3803
3804                            $imgBoxCont.addClass('imgLiquid_bgSize');
3805                            $imgBoxCont.addClass('imgLiquid_ready');
3806                            checkFinish();
3807                        }
3808
3809                        // ___________________________________________________________________
3810
3811                        function processOldMethod() {
3812
3813                            // Check change img src
3814                            if ($img.data('oldSrc') && $img.data('oldSrc') !== $img.attr('src')) {
3815
3816                                /* Clone & Reset img */
3817                                var $imgCopy = $img.clone().removeAttr('style');
3818                                $imgCopy.data('imgLiquid_settings', $img.data('imgLiquid_settings'));
3819                                $img.parent().prepend($imgCopy);
3820                                $img.remove();
3821                                $img = $imgCopy;
3822                                $img[0].width = 0;
3823
3824                                // Bug ie with > if (!$img[0].complete && $img[0].width) onError();
3825                                setTimeout(processOldMethod, 10);
3826                                return;
3827                            }
3828
3829
3830                            // Reproceess?
3831                            if ($img.data('imgLiquid_oldProcessed')) {
3832                                makeOldProcess(); return;
3833                            }
3834
3835
3836                            // Set data
3837                            $img.data('imgLiquid_oldProcessed', false);
3838                            $img.data('oldSrc', $img.attr('src'));
3839
3840
3841                            // Hide others images
3842                            $('img:not(:first)', $imgBoxCont).css('display', 'none');
3843
3844
3845                            // CSSs
3846                            $imgBoxCont.css({'overflow': 'hidden'});
3847                            $img.fadeTo(0, 0).removeAttr('width').removeAttr('height').css({
3848                                'visibility': 'visible',
3849                                'max-width': 'none',
3850                                'max-height': 'none',
3851                                'width': 'auto',
3852                                'height': 'auto',
3853                                'display': 'block'
3854                            });
3855
3856
3857                            // CheckErrors
3858                            $img.on('error', onError);
3859                            $img[0].onerror = onError;
3860
3861
3862                            // loop until load
3863                            function onLoad() {
3864                                if ($img.data('imgLiquid_error') || $img.data('imgLiquid_loaded') || $img.data('imgLiquid_oldProcessed')) return;
3865                                if ($imgBoxCont.is(':visible') && $img[0].complete && $img[0].width > 0 && $img[0].height > 0) {
3866                                    $img.data('imgLiquid_loaded', true);
3867                                    setTimeout(makeOldProcess, $i * settings.delay);
3868                                } else {
3869                                    setTimeout(onLoad, settings.timecheckvisibility);
3870                                }
3871                            }
3872
3873
3874                            onLoad();
3875                            checkResponsive();
3876                        }
3877
3878                        // ___________________________________________________________________
3879
3880                        function checkResponsive() {
3881
3882                            /* Only for oldProcessed method (background-size dont need) */
3883
3884                            if (!settings.responsive && !$img.data('imgLiquid_oldProcessed')) return;
3885                            if (!$img.data('imgLiquid_settings')) return;
3886
3887                            settings = $img.data('imgLiquid_settings');
3888
3889                            $imgBoxCont.actualSize = $imgBoxCont.get(0).offsetWidth + ($imgBoxCont.get(0).offsetHeight / 10000);
3890                            if ($imgBoxCont.sizeOld && $imgBoxCont.actualSize !== $imgBoxCont.sizeOld) makeOldProcess();
3891
3892                            $imgBoxCont.sizeOld = $imgBoxCont.actualSize;
3893                            setTimeout(checkResponsive, settings.responsiveCheckTime);
3894                        }
3895
3896                        // ___________________________________________________________________
3897
3898                        function onError() {
3899                            $img.data('imgLiquid_error', true);
3900                            $imgBoxCont.addClass('imgLiquid_error');
3901                            if (settings.onItemError) settings.onItemError($i, $imgBoxCont, $img); /* << CallBack */
3902                            checkFinish();
3903                        }
3904
3905                        // ___________________________________________________________________
3906
3907                        function getSettingsOverwrite() {
3908                            var SettingsOverwrite = {};
3909
3910                            if (imgLiquidRoot.settings.useDataHtmlAttr) {
3911                                var dif = $imgBoxCont.attr('data-imgLiquid-fill'),
3912                                    ha =  $imgBoxCont.attr('data-imgLiquid-horizontalAlign'),
3913                                    va =  $imgBoxCont.attr('data-imgLiquid-verticalAlign');
3914
3915                                if (dif === 'true' || dif === 'false') SettingsOverwrite.fill = Boolean (dif === 'true');
3916                                if (ha !== undefined && (ha === 'left' || ha === 'center' || ha === 'right' || ha.indexOf('%') !== -1)) SettingsOverwrite.horizontalAlign = ha;
3917                                if (va !== undefined && (va === 'top' ||  va === 'bottom' || va === 'center' || va.indexOf('%') !== -1)) SettingsOverwrite.verticalAlign = va;
3918                            }
3919
3920                            if (imgLiquid.isIE && imgLiquidRoot.settings.ieFadeInDisabled) SettingsOverwrite.fadeInTime = 0; //ie no anims
3921                            return SettingsOverwrite;
3922                        }
3923
3924                        // ___________________________________________________________________
3925
3926                        function makeOldProcess() { /* Only for old browsers, or useBackgroun
3926dSize seted false */
3927
3928                            // Calculate size
3929                            var w, h, wn, hn, ha, va, hdif, vdif,
3930                                margT = 0,
3931                                margL = 0,
3932                                $imgCW = $imgBoxCont.width(),
3933                                $imgCH = $imgBoxCont.height();
3934
3935
3936                            // Save original sizes
3937                            if ($img.data('owidth') === undefined) $img.data('owidth',  $img[0].width);
3938                            if ($img.data('oheight') === undefined) $img.data('oheight', $img[0].height);
3939
3940
3941                            // Compare ratio
3942                            if (settings.fill === ($imgCW / $imgCH) >= ($img.data('owidth') / $img.data('oheight'))) {
3943                                w = '100%';
3944                                h = 'auto';
3945                                wn = Math.floor($imgCW);
3946                                hn = Math.floor($imgCW * ($img.data('oheight') / $img.data('owidth')));
3947                            } else {
3948                                w = 'auto';
3949                                h = '100%';
3950                                wn = Math.floor($imgCH * ($img.data('owidth') / $img.data('oheight')));
3951                                hn = Math.floor($imgCH);
3952                            }
3953
3954                            // Align X
3955                            ha = settings.horizontalAlign.toLowerCase();
3956                            hdif = $imgCW - wn;
3957                            if (ha === 'left') margL = 0;
3958                            if (ha === 'center') margL = hdif * 0.5;
3959                            if (ha === 'right') margL = hdif;
3960                            if (ha.indexOf('%') !== -1){
3961                                ha = parseInt (ha.replace('%',''), 10);
3962                                if (ha > 0) margL = hdif * ha * 0.01;
3963                            }
3964
3965
3966                            // Align Y
3967                            va = settings.verticalAlign.toLowerCase();
3968                            vdif = $imgCH - hn;
3969                            if (va === 'left') margT = 0;
3970                            if (va === 'center') margT = vdif * 0.5;
3971                            if (va === 'bottom') margT = vdif;
3972                            if (va.indexOf('%') !== -1){
3973                                va = parseInt (va.replace('%',''), 10);
3974                                if (va > 0) margT = vdif * va * 0.01;
3975                            }
3976
3977
3978                            // Add Css
3979                            if (settings.hardPixels) {w = wn; h = hn;}
3980                            $img.css({
3981                                'width': w,
3982                                'height': h,
3983                                'margin-left': Math.floor(margL),
3984                                'margin-top': Math.floor(margT)
3985                            });
3986
3987
3988                            // FadeIn > Only first time
3989                            if (!$img.data('imgLiquid_oldProcessed')) {
3990                                $img.fadeTo(settings.fadeInTime, 1);
3991                                $img.data('imgLiquid_oldProcessed', true);
3992                                if (settings.removeBoxBackground) $imgBoxCont.css('background-image', 'none');
3993                                $imgBoxCont.addClass('imgLiquid_nobgSize');
3994                                $imgBoxCont.addClass('imgLiquid_ready');
3995                            }
3996
3997
3998                            if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
3999                            checkFinish();
4000                        }
4001
4002                        // ___________________________________________________________________
4003
4004                        function checkFinish() { /* Check callBack */
4005                            if ($i === imgLiquidRoot.length - 1) if (img
4005LiquidRoot.settings.onFinish) imgLiquidRoot.settings.onFinish();
4006                        }
4007
4008
4009                    });
4010                } //End imgLiquid: function
4011            }); //End $.fn.extend
4012
4013        })(jQuery);
4014
4015        if (typeof window.cff === 'undefined' || typeof window.cff.feeds === 'undefined') {
4016            window.cff = new Cff();
4017            window.cff.createPage(window.cff.createFeeds, {});
4018        }
4019        jQuery(document).ready(function() {
4020            var allInitiated = true;
4021            jQuery('.cff').each(function(index) {
4022                if (typeof window.cff !== 'undefined'
4023                    && typeof window.cff.feeds !== 'undefined'
4024                    && typeof window.cff.feeds[index] === 'undefined' ) {
4025                    allInitiated = false;
4026
4027                }
4028            });
4029
4030            if (!allInitiated) {
4031                window.cff.createPage(window.cff.createFeeds, {});
4032            }
4033
4034            var $ = jQuery;
4035            $('#cookie-notice a').on('click', function() {
4036                setTimeout(function() {
4037                    $.each(window.cff.feeds,function(index){
4038                        window.cff.feeds[ index ].afterConsentToggled();
4039                    });
4040                },1000);
4041            });
4042
4043            // Cookie Notice by dFactory
4044            $('#cookie-law-info-bar a').on('click', function() {
4045                setTimeout(function() {
4046                    $.each(window.cff.feeds,function(index){
4047                        window.cff.feeds[ index ].afterConsentToggled();
4048                    });
4049                },1000);
4050            });
4051
4052            // GDPR Cookie Consent by WebToffee
4053            $('.cli-user-preference-checkbox').on('click', function(){
4054                setTimeout(function() {
4055                    $.each(window.cff.feeds,function(index){
4056                        window.cff.feeds[ index ].settings.consentGiven = false;
4057                        window.cff.feeds[ index ].afterConsentToggled();
4058                    });
4059                },1000);
4060            });
4061
4062            // Cookiebot
4063            $(window).on('CookiebotOnAccept', function (event) {
4064                $.each(window.cff.feeds,function(index){
4065                    window.cff.feeds[ index ].settings.consentGiven = true;
4066                    window.cff.feeds[ index ].afterConsentToggled();
4067                });
4068            });
4069
4070            // Complianz by Really Simple Plugins
4071            $(document).on('cmplzEnableScripts', function (event) {
4072                if ( event.detail === 'marketing' ) {
4073                    $.each(window.cff.feeds,function(index){
4074                        window.cff.feeds[ index ].settings.consentGiven = true;
4075                        window.cff.feeds[ index ].afterConsentToggled();
4076                    });
4077                }
4078            });
4079
4080            // Complianz by Really Simple Plugins
4081            $(document).on('cmplzFireCategories', function (event) {
4082                if ( event.detail.category === 'marketing' ) {
4083                    $.each(window.cff.feeds,function(index){
4084                        window.cff.feeds[ index ].settings.consentGiven = true;
4085                        window.cff.feeds[ index ].afterConsentToggled();
4086                    });
4087                }
4088            });
4089
4090            // Complianz by Really Simple Plugins
4091            $(document).on('cmplzRevoke', function (event) {
4092                $.each(window.cff.feeds,function(index){
4093                    window.cff.feeds[ index ].settings.consentGiven = false;
4094                    window.cff.feeds[ index ].afterConsentToggled();
4095                });
4096            });
4097
4098            // Borlabs Cookie by Borlabs
4099            $(document).on('borlabs-cookie-consent-saved', function (event) {
4100                $.each(window.cff.feeds,function(index){
4101                    window.cff.feeds[ index ].settings.consentGiven = false;
4102                    window.cff.feeds[ index ].afterConsentToggled();
4103                });
4104            });
4105
4106        });
4107
4108        //If a video is wrapped in this element then remove it as it causes an issue with some themes
4109        setTimeout(function(){
4110            jQuery('#cff .embed-responsive video, #cff .embed-responsive iframe').unwrap();
4111        }, 500);
4112
4113
4114        // Inject css styles ______________________________________________________
4115        !function () {
4116            var css = imgLiquid.injectCss,
4117                head = document.getElementsByTagName('head')[0],
4118                style = document.createElement('style');
4119            style.type = 'text/css';
4120            if (style.styleSheet) {
4121                style.styleSheet.cssText = css;
4122            } else {
4123                style.appendChild(document.createTextNode(css));
4124            }
4125            head.appendChild(style);
4126        }();
4127        jQuery('.cff').each(function() {
4128           if (!jQuery(this).hasClass('cff-disable-liquid')) {
4129               jQuery(this).find(".cff-new .cff-album-cover").imgLiquid({fill:true});
4130           }
4131        });
4132        jQuery(".cff-new .cff-crop").imgLiquid({fill:true, useBackgroundSize:true});
4133        jQuery(".cff-header-hero").imgLiquid({fill:true});
4134
4135    } //********* END cff_init() FUNCTION ************//
4136
4137
4138    cff_init();
4139
4140
4141//Get the Access Token from the shortcode so it can be used in the connect file
4142    function cffGetShortcodeToken($cff){
4143        var shortcode_token_param = '';
4144        if ( $cff.attr('data-cff-shortcode') ){
4145            if( $cff.attr('data-cff-shortcode').indexOf('accesstoken') !== -1 ){
4146                var shortcode_att = $cff.attr('data-cff-shortcode'),
4147                    shortcode_att_arr = JSON.parse( shortcode_att );
4148                shortcode_token_param = encodeURI('&at=' + shortcode_att_arr['accesstoken']);
4149            }
4150        }
4151        return shortcode_token_param;
4152    }
4153
4154// Used for linking text in captions
4155    /* JavaScript Linkify - v0.3 - 6/27/2009 - http://benalman.com/projects/javascript-linkify/ */
4156    window.cffLinkify=(function(){var k="[a-z\\d.-]+://",h="(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",c="(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",n="(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",f="(?:"+c+n+"|"+h+")",o="(?:[;/][^#?<>\\s]*)?",e="(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",d="\\b"+k+"[^<>\\s]+",a="\\b"+f+o+e+"(?!\\w)",m="mailto:",j="(?:"+m+")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+f+e+"(?!\\w)",l=new RegExp("(?:"+d+"|"+a+"|"+j+")","ig"),g=new RegExp("^"+k,"i"),b={"'":"`",">":"<",")":"(","]":"[","}":"{","B;":"B+","b:":"b9"},i={callback:function(q,p){return p?'<a href="'+p+'" title="'+p+'" target="_blank" rel="nofollow noopener noreferrer">'+q+"</a>":q},punct_regexp:/(?:[!?.,:;'"]|(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/};return function(u,z){z=z||{};var w,v,A,p,x="",t=[],s,E,C,y,q,D,B,r;for(v in i){if(z[v]===undefined){z[v]=i[v]}}while(w=l.exec(u)){A=w[0];E=l.lastIndex;C=E-A.length;if(/[\/:]/.test(u.charAt(C-1))){continue}do{y=A;r=A.substr(-1);B=b[r];if(B){q=A.match(new RegExp("\\"+B+"(?!$)","g"));D=A.match(new RegExp("\\"+r,"g"));if((q?q.length:0)<(D?D.length:0)){A=A.substr(0,A.length-1);E--}}if(z.punct_regexp){A=A.replace(z.punct_regexp,function(F){E-=F.length;return""})}}while(A.length&&A!==y);p=A;if(!g.test(p)){p=(p.indexOf("@")!==-1?(!p.indexOf(m)?"":m):!p.indexOf("irc.")?"irc://":!p.indexOf("ftp.")?"ftp://":"http://")+p}if(s!=C){t.push([u.slice(s,C)]);s=E}t.push([A,p])}t.push([u.substr(s)]);for(v=0;v<t.length;v++){x+=z.callback.apply(window,t[v])}return x||u}})();
4157
4158//Link #hashtags
4159    function cffReplaceHashtags(hash){
4160        //Remove white space at beginning of hash
4161        var replacementString = jQuery.trim(hash);
4162        //If the hash is a hex code then don't replace it with a link as it's likely in the style attr, eg: "color: #ff0000"
4163        if ( /^#[0-9A-F]{6}$/i.test( replacementString ) ){
4164            return replacementString;
4165        } else {
4166            return '<a href="https://www.facebook.com/hashtag/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener">' + replacementString + '</a>';
4167        }
4168    }
4169//Link @tags
4170    function cffReplaceTags(tag){
4171        var replacementString = jQuery.trim(tag);
4172        return '<a href="https://www.facebook.com/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener">' + replacementString + '</a>';
4173    }
4174    var hashRegex = /[#]+[A-Za-z0-9-_]+/g,
4175        tagRegex = /[@]+[A-Za-z0-9-_]+/g;
4176// End caption linking functions
4177
4178//Encoding comments
4179    function cffEncodeHTML(raw) {
4180        // make sure passed variable is defined
4181        if (typeof raw === 'undefined') {
4182            return '';
4183        }
4184        // replace greater than and less than symbols with html entity to disallow html in comments
4185        var encoded = raw.replace(/(>)/g,'&gt;'),
4186            encoded = encoded.replace(/(<)/g,'&lt;');
4187        encoded = encoded.replace(/(&lt;br\/&gt;)/g,'<br>');
4188        encoded = encoded.replace(/(&lt;br&gt;)/g,'<br>');
4189
4190        return encoded;
4191    }
4192
4193
4194//Load comment replies using Ajax
4195    function cffLoadCommentReplies( $this ){
4196
4197        var usegrouptoken = '',
4198            useowntoken = '',
4199            $cffClosestContainer = jQuery('#cff_'+$this.parent().attr('data-id')).closest('#cff');
4200        if( $cffClosestContainer.hasClass('cff-group') ) usegrouptoken = '&usegrouptoken=true';
4201        if( $cffClosestContainer.attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
4202
4203        //Get the token from the shortcode
4204        var cff_page_id = $this.closest('.cff-item').attr('data-page-id'),
4205            shortcode_token_param = cffGetShortcodeToken( $cffClosestContainer ),
4206            $commentReplies = $this.parent(),
4207            $commentRepliesBox = $commentReplies.siblings('.cff-comment-replies-box'),
4208            comments_url = cffsiteurl + "/custom-facebook-feed-pro/comments.php?id=" + $commentReplies.attr('data-id') + usegrouptoken + useowntoken + '&pageid=' + cff_page_id + shortcode_token_param;
4209
4210        if( $commentReplies.hasClass('cff-hide') ){
4211
4212            $commentRepliesBox.hide();
4213            $commentReplies.removeClass('cff-hide');
4214
4215        } else {
4216
4217            $commentRepliesBox.show();
4218            $commentReplies.addClass('cff-hide');
4219
4220            //If the replies haven't been retrieved yet then get them, otherwise just show the existing ones again
4221            if( $commentRepliesBox.hasClass('cff-empty') ){
4222
4223                //Display loader
4224                var $commentRepliesA = $commentReplies.find('a');
4225                $commentRepliesA.append('<div class="cff-loader"></div>');
4226                $commentReplies.find('.cff-loader').css('background-color', $commentRepliesA.css('color'));
4227
4228                var submitData = {
4229                    action: 'cff_comments',
4230                    id: $commentReplies.attr('data-id'),
4231                    pageid: cff_page_id,
4232                };
4233                if( $cffClosestContainer.hasClass('cff-group') ){
4234                    submitData.usegrouptoken = true;
4235                }
4236                if( $cffClosestContainer.attr('data-own-token') == 'true' ) {
4237                    submitData.useowntoken = true;
4238                }
4239                if( shortcode_token_param !== '' ){
4240                    var token = shortcode_token_param.split('=');
4241                    submitData.at = token[1];
4242                }
4243
4244                var onSuccess = function(data) {
4245
4246                    //Remove loader
4247                    $commentReplies.find('.cff-loader').remove();
4248
4249                    //Convert string of data received from comments.php to a JSON object
4250                    var data = JSON.parse( data ),
4251                        allComments = '';
4252
4253                    if( typeof data.comments !== 'undefined' ){
4254                        jQuery.each(data.comments.data, function(i, commentItem) {
4255                            var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4256
4257                            //Check whether comment author info exists - only accessible with page access token from the page now
4258                            var cff_comment_author_info = true;
4259                            if( typeof commentItem.from !== 'undefined' ){
4260                                cff_comment_from_id = commentItem.from.id;
4261                            } else {
4262                                cff_comment_author_info = false;
4263                                cff_comment_from_id = '';
4264                            }
4265
4266
4267                            allComments += '<div class="cff-comment-reply" id="cff_'+commentItem.id+'"><div class="cff-comment-text-wrapper"><div class="cff-comment-text';
4268                            if(!cff_comment_author_info) allComments += ' cff-no-name';
4269                            allComments += '"><p>';
4270
4271
4272                            if(cff_comment_author_info){
4273                                if( typeof commentItem.from.link != 'undefined' ){
4274                                    allComments += '<a href="http://facebook.com/'+commentItem.from.id+'" class="cff-name" target="_blank" rel="nofollow noopener">
4274'+commentItem.from.name+'</a>';
4275                                } else {
4276                                    allComments += '<span class="cff-name">'+commentItem.from.name+'</span>';
4277                                }
4278                            }
4279
4280
4281                            var cffCommentMessage = cffEncodeHTML(commentItem.message);
4282                            allComments += cffCommentMessage;
4283
4284                            //Show like count if exists
4285                            if(parseInt(commentItem.like_count) > 0) allComments += '<span class="cff-comment-likes"><span class="cff-comment-likes-bg"><b style="padding-top: 3px;"><svg role="img" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M466.27 286.69C475.04 271.84 480 256 480 236.85c0-44.015-37.218-85.58-85.82-85.58H357.7c4.92-12.81 8.85-28.13 8.85-46.54C366.55 31.936 328.86 0 271.28 0c-61.607 0-58.093 94.933-71.76 108.6-22.747 22.747-49.615 66.447-68.76 83.4H32c-17.673 0-32 14.327-32 32v240c0 17.673 14.327 32 32 32h64c14.893 0 27.408-10.174 30.978-23.95 44.509 1.001 75.06 39.94 177.802 39.94 7.22 0 15.22.01 22.22.01 77.117 0 111.986-39.423 112.94-95.33 13.319-18.425 20.299-43.122 17.34-66.99 9.854-18.452 13.664-40.343 8.99-62.99zm-61.75 53.83c12.56 21.13 1.26 49.41-13.94 57.57 7.7 48.78-17.608 65.9-53.12 65.9h-37.82c-71.639 0-118.029-37.82-171.64-37.82V240h10.92c28.36 0 67.98-70.89 94.54-97.46 28.36-28.36 18.91-75.63 37.82-94.54 47.27 0 47.27 32.98 47.27 56.73 0 39.17-28.36 56.72-28.36 94.54h103.99c21.11 0 37.73 18.91 37.82 37.82.09 18.9-12.82 37.81-22.27 37.81 13.489 14.555 16.371 45.236-5.21 65.62zM88 432c0 13.255-10.745 24-24 24s-24-10.745-24-24 10.745-24 24-24 24 10.745 24 24z"></path></svg></b>
4285'+commentItem.like_count+'</span></span>';
4286
4287                            allComments += '</p>';
4288
4289                            //Add image attachment if exists
4290                            if( typeof commentItem.attachment !== 'undefined' ) {
4291                                if (consentGiven) {
4292                                    allComments += '<a class="cff-comment-attachment" href="'+commentItem.attachment.url+'" target="_blank" rel="nofollow noopener"><img src="'+commentItem.attachment.media.image.src+'" alt="'+commentItem.attachment.title+'" /></a>';
4293                                } else {
4294                                    allComments += '<a class="cff-comment-attachment" href="'+commentItem.attachment.url+'" target="_blank" rel="nofollow noopener"><span class="cff-comment-image-placeholder" data-src="'+commentItem.attachment.media.image.src+'" data-alt="'+commentItem.attachment.title+'"></span></a>';
4295                                }
4296                            }
4297
4298                            allComments += '</div></div>';
4299                            if(cff_comment_author_info) {
4300                                if (consentGiven) {
4301                                    allComments += '<div class="cff-comment-img cff-comment-reply-img"><a href="http://facebook.com/'+commentItem.from.id+'" target="_blank" rel="nofollow noopener"><img src="'+commentItem.from.picture.data.url+'" width="20" height="20" alt="Avatar" onerror="this.style.display=\'none\'"></a></div>';
4302                                } else {
4303                                    allComments += '<div class="cff-comment-img cff-comment-reply-img"><a href="http://facebook.com/'+commentItem.from.id+'" target="_blank" rel="nofollow noopener"><span data-src="'+commentItem.from.picture.data.url+'"></span></a></div>';
4304                                }
4305                            }
4306                            allComments += '</div>';
4307                        });
4308                    }
4309
4310                    $commentRepliesBox.html(allComments).removeClass('cff-empty');
4311
4312                    //Re-init masonry layout when loading comment replies
4313                    if( $this.closest('#cff').hasClass('cff-masonry-js') && !$this.closest('#cff').hasClass('cff-masonry-css') && !$this.closest('#cff').hasClass('cff-opaque-comments') ){
4314                        cffAddMasonry( $this.closest('#cff') );
4315                    }
4316
4317                };
4318                cffAjax(submitData,onSuccess);
4319
4320            } //End if
4321
4322        } //End if/else
4323
4324    } // End cffLoadCommentReplies()
4325
4326
4327
4328
4329    function cffLightbox(){
4330        /**
4331         * Lightbox v2.7.1
4332         * by Lokesh Dhakar - http://lokeshdhakar.com/projects/lightbox2/
4333         *
4334         * @license http://creativecommons.org/licenses/by/2.5/
4335         * - Free for use in both personal and commercial projects
4336         * - Attribution requires leaving author name, author link, and the license info intact
4337         */
4338
4339        (function() {
4340            // Use local alias
4341            var $ = jQuery;
4342
4343            var LightboxOptions = (function() {
4344                function LightboxOptions() {
4345                    this.fadeDuration                = 300;
4346                    this.fitImagesInViewport         = true;
4347                    this.resizeDuration              = 400;
4348                    this.positionFromTop             = 50;
4349                    this.showImageNumberLabel        = true;
4350                    this.alwaysShowNavOnTouchDevices = false;
4351                    this.wrapAround                  = false;
4352                }
4353
4354                // Change to localize to non-english language
4355                LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
4356                    return curImageNum + " / " + albumSize;
4357                };
4358
4359                return LightboxOptions;
4360            })();
4361
4362
4363            var Lightbox = (function() {
4364                function Lightbox(options) {
4365                    this.options           = options;
4366                    this.album             = [];
4367                    this.currentImageIndex = void 0;
4368                    this.init();
4369                }
4370
4371                Lightbox.prototype.init = function() {
4372                    this.enable();
4373                    this.build();
4374                };
4375
4376                // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
4377                // that contain 'cff-lightbox'. When these are clicked, start lightbox.
4378                Lightbox.prototype.enable = function() {
4379                    var self = this;
4380                    $('body').on('click', 'a[data-cff-lightbox], area[data-cff-lightbox]', function(event) {
4381                        self.start($(event.currentTarget));
4382                        return false;
4383                    });
4384                };
4385
4386                // Build html for the lightbox and the overlay.
4387                // Attach event handlers to the new DOM elements.
4388                Lightbox.prototype.build = function() {
4389                    //Disable SVG icons?
4390                    var cff_lightbox_svg_class = '';
4391                    if( $('.cff.cff-no-svgs').length ) cff_lightbox_svg_class = 'cff-no-svgs';
4392
4393                    var self = this;
4394                    $("<div id='cff-lightbox-overlay' class='cff-lightbox-overlay'></div><div id='cff-lightbox-wrapper' class='cff-lightbox-wrapper "+cff_lightbox_svg_class+"'><div class='cff-lightbox-outerContainer'><div class='cff-lightbox-container'><iframe type='text/html' src='' allowfullscreen frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen title='Video'></iframe><img class='cff-lightbox-image' src='' alt='"+$('#cff').attr('data-fb-text')+"' /><div class='cff-lightbox-nav'><a class='cff-lightbox-prev' href=''><span>Previous</span></a><a class='cff-lightbox-next' href=''><span>Next</span></a></div><div class='cff-lightbox-loader'><a class='cff-lightbox-cancel'></a></div><div class='cff-lightbox-sidebar'></div></div></div><div class='cff-lightbox-dataContainer'><div class='cff-lightbox-data'><div class='cff-lightbox-details'><p class='cff-lightbox-caption'><span class='cff-lightbox-caption-text'></span><a class='cff-lightbox-facebook' href=''><svg aria-hidden='true' focusable='false' data-prefix='fab' data-icon='facebook-square' role='img' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512' class='svg-inline--fa fa-facebook-square fa-w-14'><path fill='currentColor' d='M400 32H48A48 48 0 0 0 0 80v352a48 48 0 0 0 48 48h137.25V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48 27.14 0 55.52 4.84 55.52 4.84v61h-31.27c-30.81 0-40.42 19.12-40.42 38.73V256h68.78l-11 71.69h-57.78V480H400a48 48 0 0 0 48-48V80a48 48 0 0 0-48-48z'></path></svg>"+$('#cff').attr('data-fb-text')+"</a></p><div class='cff-lightbox-thumbs'><div class='cff-lightbox-thumbs-holder'></div></div></div><div class='cff-lightbox-closeContainer'><a class='cff-lightbox-close'><svg aria-hidden='true' focusable='false' data-prefix='fas' data-icon='times' role='img' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 352 512' class='svg-inline--fa fa-times fa-w-11'><path fill='currentColor' d='M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z' class=''></path></svg></a></div></div></div></div>").appendTo($('body'));
4395
4396                    // Make sure hammer is defined somehow
4397                    if (typeof jQuery("#cff-lightbox-wrapper").find(".cff
4397-lightbox-dataContainer").hammer !== 'function') {
4398                        var Hammer = {
4399                            Manager: {
4400                                prototype: {}
4401                            }
4402                        };
4403                        (function (factory) {
4404                            if (typeof define === 'function' && define.amd) {
4405                                define(['jquery', 'hammerjs'], factory);
4406                            } else if (typeof exports === 'object') {
4407                                factory(require('jquery'), require('hammerjs'));
4408                            } else {
4409                                factory(jQuery, Hammer);
4410                            }
4411                        }(function (jQuery, Hammer) {
4412                            function hammerify(el, options) {
4413                            }
4414
4415                            jQuery.fn.hammer = function (options) {
4416                                return this.each(function () {
4417                                    hammerify(this, options);
4418                                });
4419                            };
4420                            // extend the emit method to also trigger jQuery events
4421                            Hammer.Manager.prototype.emit = (function (originalEmit) {
4422                                return function (type, data) {
4423                                    originalEmit.call(this, type, data);
4424                                    jQuery(this.element).trigger({
4425                                        type: type,
4426                                        gesture: data
4427                                    });
4428                                };
4429                            })(Hammer.Manager.prototype.emit);
4430                        }));
4431                    }
4432
4433                    // Cache jQuery objects
4434                    this.$lightbox       = $('#cff-lightbox-wrapper');
4435                    this.$overlay        = $('#cff-lightbox-overlay');
4436                    this.$outerContainer = this.$lightbox.find('.cff-lightbox-outerContainer');
4437                    this.$container      = this.$lightbox.find('.cff-lightbox-container');
4438
4439                    // Store css values for future lookup
4440                    this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10);
4441                    this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10);
4442                    this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10);
4443                    this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10);
4444
4445                    // Attach event handlers to the newly minted DOM elements
4446                    this.$overlay.hide().on('click', function() {
4447                        self.end();
4448                        if( cff_supports_video() && $('#cff-lightbox-wrapper video.cff-lightbox-video').length ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4449                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4450                        if ($('body').length) {
4451                            $('body').removeClass('cff_no_scroll');
4452                        }
4453                        return false;
4454                    });
4455
4456
4457                    this.$lightbox.hide().on('click', function(event) {
4458                        if ($(event.target).attr('id') === 'cff-lightbox-wrapper') {
4459                            self.end();
4460                            if( cff_supports_video() && $('#cff-lightbox-wrapper video.cff-lightbox-video').length ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4461                            $('#cff-lightbox-wrapper iframe').attr('src', '');
4462                            if ($('body').length) {
4463                                $('body').removeClass('cff_no_scroll');
4464                            }
4465                        }
4466                        return false;
4467                    });
4468                    this.$outerContainer.on('click', function(event) {
4469                        if ($(event.target).attr('id') === 'cff-lightbox-wrapper') {
4470                            self.end();
4471                            if( cff_supports_video() && $('#cff-lightbox-wrapper video.cff-lightbox-video').length ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4472                            $('#cff-lightbox-wrapper iframe').attr('src', '');
4473                        }
4474                        return false;
4475                    });
4476
4477
4478                    this.$lightbox.find('.cff-lightbox-prev').on('click', function() {
4479                        if (self.currentImageIndex === 0) {
4480                            self.changeImage(self.album.length - 1);
4481                        } else {
4482                            self.changeImage(self.currentImageIndex - 1);
4483                        }
4484                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4485                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4486                        return false;
4487                    });
4488
4489                    this.$lightbox.find('.cff-lightbox-next').on('click', function() {
4490                        if (self.currentImageIndex === self.album.length - 1) {
4491                            self.changeImage(0);
4492                        } else {
4493                            self.changeImage(self.currentImageIndex + 1);
4494                        }
4495                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4496                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4497                        return false;
4498                    });
4499
4500                    this.$lightbox.find('.cff-lightbox-outerContainer').hammer().on("swipeleft", function() {
4501                        if (self.currentImageIndex === self.album.length - 1) {
4502                            self.changeImage(0);
4503                        } else {
4504                            self.changeImage(self.currentImageIndex + 1);
4505                        }
4506                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4507                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4508                        return false;
4509                    });
4510
4511                    this.$lightbox.find('.cff-lightbox-outerContainer').hammer().on("swiperight", function() {
4512                        if (self.currentImageIndex === 0) {
4513                            self.changeImage(self.album.length - 1);
4514                        } else {
4515                            self.changeImage(self.currentImageIndex - 1);
4516                        }
4517                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4518                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4519                        return false;
4520                    });
4521
4522                    //CHANGE IMAGE ON THUMB CLICK
4523                    $('.cff-lightbox-thumbs').on('click', '.cff-lightbox-attachment', function (){
4524                        var $thumb = $(this),
4525                            $thumbImg = $thumb.find('img'),
4526                            captionText = $thumb.attr('data-caption');
4527
4528                        if(captionText == '' || captionText == 'undefined') captionText = $thumb.attr('orig-caption');
4529
4530                        //Pass image URL, width and height to the change image function
4531                        self.changeImage(parseInt( $thumb.attr('data-cff-lightbox-order') ), $thumb.attr('href'), $thumbImg.attr('width'), $thumbImg.attr('height'), $thumb.attr('data-facebook'), captionText);
4532                        return false;
4533                    });
4534
4535
4536                    this.$lightbox.find('.cff-lightbox-loader, .cff-lightbox-close').on('click', function() {
4537                        self.end();
4538                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4539                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4540                        if ($('body').length) {
4541                            $('body').removeClass('cff_no_scroll');
4542                        }
4543                        return false;
4544                    });
4545
4546                }; //End build()
4547
4548                // Show overlay and lightbox. If the image is part of a set, add siblings to album array.
4549                Lightbox.prototype.start = function($link) {
4550                    var self    = this;
4551                    var $window = $(window);
4552
4553                    $window.on('resize', $.proxy(this.sizeOverlay, this));
4554
4555                    if ($('body').length) {
4556                        $('body').addClass('cff_no_scroll');
4557                    }
4558
4559                    $('select, object, embed').css({
4560                        visibility: "hidden"
4561                    });
4562
4563                    this.sizeOverlay();
4564
4565                    //Only set the album to be empty when the page first loads, otherwise don't empty it otherwise it's rebuilt using the "push" method below and it pushes the lightbox thumbnails onto the end of the array instead of them being spliced in at their correct location
4566                    if(this.album.length == 0) this.album = [];
4567                    var imageNumber = 0;
4568
4569                    function addToAlbum($link) {
4570
4571                        if( !$link.closest('.cff-posts-wrap').hasClass('cff_owl-carousel') ) {
4572                            var albumClassName = $link.closest('.cff-posts-wrap').children('div').attr('class');
4573                        } else {
4574                            var albumClassName = $link.closest('.cff-posts-wrap .cff_owl-item').children('div').attr('class');
4575                        }
4576
4577                        linkParentPostID = '';
4578
4579                        if ( typeof albumClassName !== 'undefined' ) {
4580                            linkParentPostID = $link.closest('.'+albumClassName.split(' ')[0]).attr('id');
4581                            linkParentPostID = linkParentPostID.replace('cff_','')
4582                        }
4583
4584                        //If an image with the same href has already been added then don't add it to the lightbox order again
4585                        var found = false;
4586                        $.each(self.album, function(i, imageitem) {
4587                            if( ( imageitem.link == $link.attr('href') ) && ( imageitem.postid == linkParentPostID ) ){
4588                                found = true;
4589                                return;
4590                            }
4591                        });
4592                        //Some videos may legitimately use the exact same thumbnail images. If so, adding this class to the shortcode will allow them to be added to the lightbox order.
4593                        if( !$('.cff-duplicate-video-thumbnails').length ) if(found == true) return;
4594                        var closestFeedIndex = parseInt($link.closest('.cff').attr('data-cff-index')-1);
4595
4596                        var video = $link.attr("data-video"),
4597                            iframe = $link.attr('data-iframe'),
4598                            link = $link.attr("href"),
4599                            count = 0;
4600                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4601                        if (!consentGiven) {
4602                            if (iframe !== '') {
4603                                iframe = 'link';
4604                            }
4605                            if (video !== '') {
4606                                video = 'link';
4607                            }
4608                            if ($link.closest('.cff-album-item').length
4609                                && typeof $link.closest('.cff-album-item').attr('data-count') !== 'undefined') {
4610                                count = $link.closest('.cff-album-item').attr('data-count');
4611                            }
4612                        }
4613                        self.album.push({
4614                            link: link,
4615                            title: $link.attr('data-title') || $link.attr('title'),
4616                            postid: $link.attr('data-id'),
4617                            showthumbs: $link.attr('data-thumbs'),
4618                            facebookurl: $link.attr('data-url'),
4619                            video: video,
4620                            iframe: iframe,
4621                            type: $link.attr('data-type'),
4622                            cffgroupalbums: $link.attr('data-cffgroupalbums'),
4623                            isthumbnail: $link.attr('data-cff-isthumbnail'),
4624                            pagename: $link.parent().attr('data-cff-page-name'),
4625                            posttime: $link.parent().attr('data-cff-post-time'),
4626                            lbcomments: $link.attr('data-lb-comments'),
4627                            feedIndex: closestFeedIndex,
4628                            count: count
4629                        });
4630                    }
4631
4632                    // Support both data-lightbox attribute and rel attribute implementations
4633                    var dataLightboxValue = $link.attr('data-cff-lightbox');
4634                    var $links;
4635
4636                    if (dataLightboxValue) {
4637                        $links = $($link.prop("tagName") + '[data-cff-lightbox="' + dataLightboxValue + '"]');
4638                        for (var i = 0; i < $links.length; i = ++i) {
4639                            addToAlbum($($links[i]));
4640                            if ($links[i] === $link[0]) {
4641                                imageNumber = i;
4642
4643                                //Loop through the album array and try to match the ID of the image that was clicked on with an image within the album array. We can then use that to set the lightbox order for that image, as otherwise it's incorrect if there have been thumbs added into the album array which aren't physically present on the page as they're loaded dynamically from the thumbs array within the lightbox. Only do this for post images and not thumbnails.
4644                                $.each(self.album, function(i, image) {
4645                                    if( (image.postid == $link.attr('data-id')) && image.isthumbnail != true ) imageNumber = i;
4646                                });
4647                            }
4648                        }
4649                    } else {
4650                        if ($link.attr('rel') === 'lightbox') {
4651                            // If image is not part of a set
4652                            addToAlbum($link);
4653                        } else {
4654                            // If image is part of a set
4655                            $links = $($link.prop("tagName") + '[rel="' + $link.attr('rel') + '"]');
4656                            for (var j = 0; j < $links.length; j = ++j) {
4657                                addToAlbum($($links[j]));
4658                                if ($links[j] === $link[0]) {
4659                                    imageNumber = j;
4660                                }
4661                            }
4662                        }
4663                    }
4664
4665                    // Position Lightbox
4666                    var top  = $window.scrollTop() + this.options.positionFromTop;
4667                    var left = $window.scrollLeft();
4668                    this.$lightbox.css({
4669                        top: top + 'px',
4670                        left: left + 'px'
4671                    }).fadeIn(this.options.fadeDuration);
4672
4673                    this.changeImage(imageNumber);
4674                };
4675
4676                // Hide most UI elements in preparation for the animated resizing of the lightbox.
4677                Lightbox.prototype.changeImage = function(imageNumberVal, imageUrl, imgWidth, imgHeight, facebookLink, captionText) {
4678                    var self = this,
4679                        isThumb = false,
4680                        bottomPadding = 120;
4681
4682                    imageNumber = imageNumberVal;
4683
4684                    //Is this a thumb being clicked?
4685                    if(typeof imageUrl !== 'undefined') isThumb = true;
4686
4687                    this.disableKeyboardNav();
4688                    var $image = this.$lightbox.find('.cff-lightbox-image');
4689
4690                    this.$overlay.fadeIn(this.options.fadeDuration);
4691
4692                    $('.cff-lightbox-loader').fadeIn('slow');
4693                    this.$lightbox.find('.cff-lightbox-image, .cff-lightbox-nav, .cff-lightbox-prev, .cff-lightbox-next, .cff-lightbox-dataContainer, .cff-lightbox-numbers, .cff-lightbox-caption').hide();
4694
4695                    this.$outerContainer.addClass('animating');
4696
4697
4698                    // When image to show is preloaded, we send the width and height to sizeContainer()
4699                    var preloader = new Image();
4700                    preloader.onload = function() {
4701                        var $preloader, imageHeight, imageWidth, maxImageHeight, maxImageWidth, windowHeight, windowWidth;
4702
4703                        $image.attr('src', self.album[imageNumber].link);
4704
4705                        /*** THUMBS ***/
4706                        //Change the main image when it's a thumb that's being clicked
4707                        if(isThumb){
4708                            $image.attr('src', imageUrl);
4709                            $('.cff-lightbox-facebook').attr('href', facebookLink);
4710                            $('.cff-lightbox-caption .cff-lightbox-caption-text').html(captionText);
4711
4712                            //Set width and height of image when thumb is clicked
4713                            preloader.width = imgWidth;
4714                            preloader.height = imgHeight;
4715
4716                            //Increase bottom padding to make room for at least one row of thumbs
4717                            bottomPadding = 180;
4718                        }
4719                        /*** THUMBS ***/
4720
4721                        $preloader = $(preloader);
4722
4723                        $image.width(preloader.width);
4724                        $image.height(preloader.height);
4725
4726                        if (self.options.fitImagesInViewport) {
4727                            // Fit image inside the viewport.
4728                            // Take into account the border around the image and an additional 10px gutter on each side.
4729                            windowWidth    = $(window).width();
4730                            windowHeight   = $(window).height();
4731
4732                            //If this feed has lightbox comments enabled then add room for the sidebar
4733                            var cff_lb_comments_width = 0,
4734                                cffNavArrowsWidth = 80;
4735
4736                            if( $('#cff_' + self.album[0].postid).closest('#cff').attr('data-lb-comments') == 'true' && windowWidth > 640 ) cff_lb_comments_width = 300;
4737
4738                            //Use narrower arrows on mobile
4739                            if(window.innerWidth < 640) cffNavArrowsWidth = 40;
4740
4741                            maxImageWidth  = windowWidth - self.containerLeftPadding - self.containerRightPadding - 20 - cff_lb_comments_width - cffNavArrowsWidth;
4742                            maxImageHeight = windowHeight - self.containerTopPadding - self.containerBottomPadding - bottomPadding;
4743
4744                            // Is there a fitting issue?
4745                            if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) {
4746                                if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) {
4747                                    imageWidth  = maxImageWidth;
4748                                    imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10);
4749                                    $image.width(imageWidth);
4750                                    $image.height(imageHeight);
4751                                } else {
4752                                    imageHeight = maxImageHeight;
4753                                    imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10);
4754                                    $image.width(imageWidth);
4755                                    $image.height(imageHeight);
4756                                }
4757                            }
4758                        }
4759
4760                        //Pass the width and height of the main image
4761                        self.sizeContainer($image.width(), $image.height());
4762
4763                    };
4764
4765                    preloader.src          = this.album[imageNumber].link;
4766                    this.currentImageIndex = imageNumber;
4767                };
4768
4769                // Stretch overlay to fit the viewport
4770                Lightbox.prototype.sizeOverlay = function() {
4771                    this.$overlay
4772                        .width($(window).width())
4773                        .height($(document).height());
4774                };
4775
4776                // Animate the size of the lightbox to fit the image we are showing
4777                Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
4778                    var self = this;
4779
4780                    var oldWidth  = this.$outerContainer.outerWidth();
4781                    var oldHeight = this.$outerContainer.outerHeight();
4782                    var newWidth  = imageWidth + this.containerLeftPadding + this.containerRightPadding;
4783                    var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding;
4784
4785                    function postResize() {
4786                        self.$lightbox.find('.cff-lightbox-dataContainer').width(newWidth);
4787                        self.$lightbox.find('.cff-lightbox-prevLink').height(newHeight);
4788                        self.$lightbox.find('.cff-lightbox-nextLink').height(newHeight);
4789                        self.showImage();
4790                    }
4791
4792                    if (oldWidth !== newWidth || oldHeight !== newHeight) {
4793                        this.$outerContainer.animate({
4794                            width: newWidth,
4795                            height: newHeight
4796                        }, this.options.resizeDuration, 'swing', function() {
4797                            postResize();
4798                        });
4799                    } else {
4800                        postResize();
4801                    }
4802                };
4803
4804                // Display the image and it's details and begin preload neighboring images.
4805                Lightbox.prototype.showImage = function() {
4806                    this.$lightbox.find('.cff-lightbox-loader').hide();
4807                    this.$lightbox.find('.cff-lightbox-image').fadeIn('slow');
4808
4809                    this.updateNav();
4810                    this.updateDetails();
4811                    this.preloadNeighboringImages();
4812                    this.enableKeyboardNav();
4813                };
4814
4815                // Display previous and next navigation if appropriate.
4816                Lightbox.prototype.updateNav = function() {
4817                    // Check to see if the browser supports touch events. If so, we take the conservative approach
4818                    // and assume that mouse hover events are not supported and always show prev/next navigation
4819                    // arrows in image sets.
4820                    var alwaysShowNav = false;
4821                    try {
4822                        document.createEvent("TouchEvent");
4823                        alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices)? true: false;
4824                    } catch (e) {}
4825
4826                    this.$lightbox.find('.cff-lightbox-nav').show();
4827
4828                    if (this.album.length > 1) {
4829                        if (this.options.wrapAround) {
4830                            if (alwaysShowNav) {
4831                                this.$lightbox.find('.cff-lightbox-prev, .cff-lightbox-next').css('opacity', '1');
4832                            }
4833                            this.$lightbox.find('.cff-lightbox-prev, .cff-lightbox-next').show();
4834                        } else {
4835                            if (this.currentImageIndex > 0) {
4836                                this.$lightbox.find('.cff-lightbox-prev').show();
4837                                if (alwaysShowNav) {
4838                                    this.$lightbox.find('.cff-lightbox-prev').css('opacity', '1');
4839                                }
4840                            }
4841                            if (this.currentImageIndex < this.album.length - 1) {
4842                                this.$lightbox.find('.cff-lightbox-next').show();
4843                                if (alwaysShowNav) {
4844                                    this.$lightbox.find('.cff-lightbox-next').css('opacity', '1');
4845                                }
4846                            }
4847                        }
4848                    }
4849                };
4850
4851                var thumbsArr = {};
4852
4853                // Display caption, image number, and closing button.
4854                Lightbox.prototype.updateDetails = function() {
4855                    var self = this;
4856                    var origCaption = '';
4857
4858                    this.$lightbox.find('.cff-lightbox-nav, .cff-lightbox-nav a').show();
4859
4860                    /** NEW PHOTO ACTION **/
4861
4862                    //Add the video element to the lightbox dynamically (as it causes issues with some themes if an empty tag is in there on page load
4862)
4863                    if( $('.cff-lightbox-video').length == 0 ) $('.cff-lightbox-container').prepend("<video class='cff-lightbox-video' src='' poster='' controls></video>");
4864
4865                    //Switch video when either a new popup or navigating to new one
4866                    if( cff_supports_video() ){
4867                        $('#cff-lightbox-wrapper').removeClass('cff-has-video');
4868
4869                        if (typeof this.album[this.currentImageIndex].video !== 'undefined'
4870                            && this.album[this.currentImageIndex].video !== 'link'){
4871                            if( this.album[this.currentImageIndex].video.length ){
4872
4873                                $('#cff-lightbox-wrapper').addClass('cff-has-video');
4874                                $('.cff-lightbox-video').attr({
4875                                    'src' : this.album[this.currentImageIndex].video,
4876                                    'poster' : this.album[this.currentImageIndex].link,
4877                                    'autoplay' : 'true'
4878                                });
4879                            }
4880                        }
4881
4882                    }
4883
4884                    var iframeIsLink = false;
4885                    if (this.album[this.currentImageIndex].iframe === 'link') {
4886                        iframeIsLink = true;
4887                    }
4888                    if ((this.album[this.currentImageIndex].video === 'link' || iframeIsLink)
4889                        && ! jQuery(".cff-lightbox-container .cff_gdpr_notice").length) {
4890                        jQuery(".cff-lightbox-container").prepend('<a href="'+this.album[this.currentImageIndex].facebookurl+'" target="_blank" rel="noopener noreferrer" class="cff_gdpr_notice"><svg style="color: rgba(255,255,255,1)" class="svg-inline--fa fa-play fa-w-14" aria-label="Play" aria-hidden="true" data-fa-processed="" data-prefix="fa" data-icon="play" role="presentation" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg></a>')
4891                    } else if (this.album[this.currentImageIndex].video !== 'link' && !iframeIsLink) {
4892                        jQuery('.cff_gdpr_notice').remove();
4893                    } else if (jQuery(".cff-lightbox-container .cff_gdpr_notice").length) {
4894                        jQuery(".cff-lightbox-container .cff_gdpr_notice").attr('href',this.album[this.currentImageIndex].facebookurl);
4895                    }
4896
4897                    //***LIGHTBOX COMMENTS***
4898                    //Enable/disable lightbox comments. If it's a lightbox thumbnail then check whether the parent post has lb_comments enabled/disabled.
4899                    var cff_lb_comments = (this.album[this.currentImageIndex].lbcomments == 'true' && $('#cff_'+this.album[this.currentImageIndex].postid+' .cff-lightbox-link').attr('data-lb-comments') != 'false') ? true : false;
4900
4901                    if( $(window).width() <= 640 ) cff_lb_comments = false;
4902
4903                    //Add lightbox sidebar
4904                    if( cff_lb_comments ){
4905                        var lb_post_id = this.album[this.currentImageIndex].postid,
4906                            page_id = lb_post_id.split('_')[0],
4907                            author_name = this.album[this.currentImageIndex].pagename,
4908                            date_in_correct_format = this.album[this.currentImageIndex].posttime,
4909                            $lightbox_sidebar = $('.cff-lightbox-container .cff-lightbox-sidebar'),
4910                            $lightbox_thumbs_holder = $('.cff-lightbox-thumbs-holder'),
4911                            from_id = $( '#cff_'+this.album[this.currentImageIndex].postid ).attr('data-cff-from');
4912
4913                        //Add class to the lightbox container
4914                        $('.cff-lightbox-wrapper').addClass('cff-enable-lb-comments');
4915
4916                        //Adjust width to make room for the sidebar
4917                        $('.cff-lightbox-dataContainer').css( 'width', $('.cff-lightbox-dataContainer').innerWidth() + 300 );
4918                        $lightbox_sidebar.css('display', 'block');
4919
4920                        //If the from info isn't available then dis
4920play a placeholder avatar and the date
4921                        var cff_post_author = "";
4922                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4923                        if( consentGiven && typeof from_id !== 'undefined' ){
4924                            cff_post_author =  "<div class='cff-author'><div class='cff-author-text'><p class='cff-page-name cff-author-date'><a href='https://facebook.com/"+from_id+"' target='_blank' rel='nofollow'>"+author_name+"</a><span class='cff-story'> </span></p><p class='cff-date'>"+date_in_correct_format+"</p></div><a href='https://facebook.com/"+from_id+"' target='_blank' rel='nofollow noopener' class='cff-author-img'><img src='https://graph.facebook.com/"+from_id+"/picture?type=square' title='"+author_name+"' alt='"+author_name+"' width='40' height='40'></a></div>";
4925                        } else {
4926                            cff_post_author =  "<div class='cff-author cff-no-author-info'><div class='cff-author-text'><p class='cff-date'>"+date_in_correct_format+"</p></div><div class='cff-author-img'></div></div>";
4927                        }
4928
4929                        //Remove the close button from the bottom of lightbox as it's added to the top of the sidebar
4930                        $('.cff-lightbox-dataContainer .cff-lightbox-close').remove();
4931
4932                        $lightbox_sidebar.html("<div class='cff-lightbox-closeContainer'><div class='cff-lightbox-close'><svg aria-hidden='true' focusable='false' data-prefix='fas' data-icon='times' role='img' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 352 512' class='svg-inline--fa fa-times fa-w-11'><path fill='currentColor' d='M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z' class=''></path></svg></div></div><div class='cff-lightbox-sidebar-content'>" + cff_post_author + "<p class='cff-lightbox-caption'><span class='cff-lightbox-caption-text'>" + $('.cff-lightbox-caption-text').html() + '</span></p></div>' + $('#cff_'+this.album[this.currentImageIndex].postid+' .cff-comments-box')[0].outerHTML );
4933
4934                        this.$lightbox.find('.cff-lightbox-close').on('click', function() {
4935                            self.end();
4936                            if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4937                            $('#cff-lightbox-wrapper iframe').attr('src', '');
4938                            if ($('body').length) {
4939                                $('body').removeClass('cff_no_scroll');
4940                            }
4941                            return false;
4942                        });
4943
4944                        //Use a timeout to delay this as the thumbs aren't added till further down
4945                        setTimeout(function(){
4946                            if( $lightbox_thumbs_holder.find('a').length > 1 ){
4947                                $lightbox_sidebar.find('.cff-page-name a').text( $lightbox_thumbs_holder.find('a.cff-selected').attr('data-page-name') );
4948                                $lightbox_sidebar.find('.cff-date').text( $lightbox_thumbs_holder.find('a.cff-selected').attr('data-post-date') );
4949                            }
4950                        }, 0);
4951
4952                        //Bump the thumbs section up if the sidebar section is enabled as there's no caption under the photo
4953                        $lightbox_thumbs_holder.css('margin-top', -10);
4954
4955                        //If the "__ likes this" text is too long then bump it onto the next line
4956                        if( $lightbox_sidebar.find('.cff-reactions-count').innerWidth() > 150 ){
4957                            $lightbox_sidebar.find('.cff-likes-this-text').addClass('cff-long');
4958                        }
4959
4960                        //Add comment avatars
4961                        $lightbox_sidebar.find('.cff-comment:visible').each(function(){
4962                            var $thisComment = jQuery(this);
4963                            var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4964                            if (consentGiven) {
4965                                $thisComment.find('.cff-comment-img:not(.cff-comment-reply-img) a, .cff-comment-img:not(.cff-comment-reply-img) span').html( '<img src="'+$thisComment.attr("data-avatar")+'" alt="Avatar" onerror="this.style.display=\'none\'" />' );
4966                            }
4967
4968                        });
4969
4970                        //Load comment replies
4971                        $lightbox_sidebar.find('.cff-comment-replies a').on('click', function(){
4972                            cffLoadCommentReplies( $(this) );
4973                        });
4974
4975                        $lightbox_sidebar.find('.cff-show-more-comments a').attr('href', $lightbox_sidebar.find('.cff-comment-on-facebook a').attr('href') );
4976
4977                    } else { //End add lightbox sidebar
4978
4979                        //Disable lightbox
4980                        $('.cff-lightbox-wrapper .cff-lightbox-sidebar').html('');
4981                        $('.cff-lightbox-wrapper').removeClass('cff-enable-lb-comments');
4982
4983                    }
4984                    //***END LIGHTBOX COMMENTS***
4985
4986
4987
4988                    $('#cff-lightbox-wrapper').removeClass('cff-has-iframe cff-fb-player cff-has-thumbs');
4989
4990                    //If it's an iframe video (embed or FB video player)
4991                    if( typeof this.album[this.currentImageIndex].iframe !== 'undefined' ){
4992                        if( this.album[this.currentImageIndex].iframe.length && this.album[this.currentImageIndex].iframe !== 'link'){
4993                            var videoURL = this.album[this.currentImageIndex].iframe;
4994                            $('#cff-lightbox-wrapper').addClass('cff-has-iframe');
4995
4996                            if( videoURL.indexOf("https://www.facebook.com/v2.3/plugins/video.php?") !=-1 ) $('#cff
4996-lightbox-wrapper').addClass('cff-fb-player');
4997
4998                            //If it's a swf then don't add the autoplay parameter. This is only for embedded videos like YouTube or Vimeo.
4999                            if( videoURL.indexOf(".swf") > -1 || videoURL.indexOf("&autoplay=1") !=-1 ){
5000                                var autoplayParam = '';
5001                            } else {
5002                                var autoplayParam = '?autoplay=1';
5003                            }
5004
5005                            //Add a slight delay before adding the URL else it doesn't autoplay on Firefox
5006                            var vInt = setTimeout(function() {
5007                                $('#cff-lightbox-wrapper iframe').attr({
5008                                    'src' : videoURL + autoplayParam + "&mute=0"
5009                                });
5010                            }, 500);
5011                        }
5012                    }
5013
5014                    //Check whether it's a thumbnail image that's currently being shown in the lightbox
5015                    var isThumbnail = false;
5016                    if( this.album[this.currentImageIndex].isthumbnail ) isThumbnail = true;
5017
5018                    //Remove existing thumbs unless it's a thumbnail image which is being navigated through in which case keep the existing thumbnails
5019                    if( !isThumbnail ) $('.cff-lightbox-thumbs-holder').empty().removeClass('cff-animate');
5020
5021                    //Change the link on the Facebook icon to be the link to the Facebook post only if it's the first image in the lightbox and one of the thumbs hasn't been clicked
5022                    if( this.album[this.currentImageIndex].link == $('.cff-lightbox-image').attr('src') ){
5023                        $('.cff-lightbox-facebook').attr('href', this.album[this.currentImageIndex].facebookurl);
5024                    }
5025
5026                    //Show thumbs area if there are thumbs
5027                    if( this.album[this.currentImageIndex].showthumbs == 'true' ){
5028                        $('.cff-lightbox-thumbs').show();
5029
5030                        //Get the post ID
5031                        var thisPostId = this.album[this.currentImageIndex].postid,
5032                            albumInfo = '',
5033                            albumThumbs = '',
5034                            albumsonly = false;
5035                        if( this.album[this.currentImageIndex].type == 'albumsonly' ) albumsonly = true;
5036
5037
5038                        if( typeof thumbsArr[thisPostId] !== 'undefined' ){
5039
5040                            //load them in from array in local var
5041                            $.each(thumbsArr[thisPostId], function(i, thumb) {
5042                                var origCaption = thumb[5].replace(/"/g, '&quot;');
5043
5044                                //Loop through the album array and find the imageindex of the item with this post ID. Then set the current image index to be this. Otherwise when going backwards through the lightbox the imageindex is set to be the current thumb index and then once i is added the index is too high.
5045                                var albumIndex = 0;
5046                                $.each(self.album, function(i, albumItem) {
5047                                    if( albumItem.postid == thisPostId ){
5048                                        albumIndex = i;
5049                                        //Once found the first match exit the loop
5050                                        return false;
5051                                    }
5052                                });
5053
5054                                var lightboxImageOrder = (parseInt(albumIndex)+parseInt(i));
5055
5056                                //If the small thumb isn't defined (like in regular posts) then use the full image instead
5057                                if( typeof thumb[8] == 'undefined' ) thumb[8] = thumb[0];
5058                                albumThumbs += '<a href="'+thumb[0]+'" class="cff-lightbox-attachment" data-cff-lightbox="cff-lightbox-1" data-facebook="'+thumb[3]+'" data-caption="'+thumb[4]+'" orig-caption="'+origCaption+'" data-page-name="'+thumb[6]+'" data-post-date="'+thumb[7]+'" data-cff-lightbox-order="'+lightboxImageOrder+'" lbcomments="true" data-thumbs="true" data-url="'+thumb[3]+'" data-iframe data-video ';
5059
5060                                (albumsonly) ? albumThumbs += 'data-type="albumsonly" ' : albumThumbs += 'data-type ';
5061                                albumThumbs += 'data-cff-isthumbnail="true"><img src="'+thumb[8]+'" width="'+thumb[1]+'" height="'+thumb[2]+'" /></a>';
5062
5063                                //Add all of the thumbs (apart from the first thumb) to the lightbox order
5064                                if( i > 0 ){
5065                                    cffInsertLightboxImage(lightboxImageOrder, thumb[0], thumb[4], thumb[3], thisPostId, albumsonly, true, thumb[6], thumb[7], thumb[8]);
5066                                }
5067                            });
5068
5069                            //Add thumbs to the page
5070                            $('.cff-lightbox-thumbs-holder').html( '<div class="cff-lightbox-thumbs-wrap">' + albumThumbs + '</div>' ).addClass('cff-animate');
5071                            $('.cff-lightbox-wrapper').addClass('cff-has-thumbs');
5072
5073                            //Liquidfill the thumbs
5074                            jQuery(".cff-lightbox-thumbs-holder a").imgLiquid({fill:true, useBackgroun
5074dSize:true});
5075
5076                            //Hide the loader
5077                            $('.cff-loader').hide();
5078                            $('.cff-lightbox-thumbs-holder').css('min-height', 0);
5079
5080                        } else {
5081                            //Use ajax to get them from Facebook API
5082
5083                            //Set paths for thumbs.php
5084                            if (typeof cffsiteurl === 'undefined' || cffsiteurl == '') cffsiteurl = window.location.host + '/wp-content/plugins';
5085
5086                            //Get the token from the shortcode
5087                            var $cffClosest = $('#cff_'+thisPostId).closest('.cff'),
5088                                cff_page_id = $('#cff_'+thisPostId).attr('data-page-id'),
5089                                shortcode_token_param = cffGetShortcodeToken( $cffClosest ),
5090                                useowntoken = '';
5091                            if( $cffClosest.attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
5092
5093                            //AJAX
5094                            var cffAttachmentsUrl = cffsiteurl + "/custom-facebook-feed-pro/thumbs.php?id=" + thisPostId + '&pageid=' + cff_page_id + useowntoken + shortcode_token_param,
5095                                thumbsData = [];
5096
5097                            //If this is an albums only item and the thumbs will
5098                            if( albumsonly ){
5099                                cffAttachmentsUrl = cffAttachmentsUrl + '&albumsonly=true';
5100                                var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
5101                                if (consentGiven) {
5102                                    $('.cff-lightbox-thumbs-holder').css('min-height', 45).after('<div class="cff-loader"></div>');
5103                                }
5104                            }
5105
5106                            //If it's a group album then add the absolute path so we can get the User Access Token from the DB
5107                            var cffgroupalbums = this.album[this.currentImageIndex].cffgroupalbums;
5108                            if( cffgroupalbums ) cffAttachmentsUrl = cffAttachmentsUrl + '&usegrouptoken=' + cffgroupalbums;
5109
5110                            var submitData = {
5111                                action: 'cff_thumbs',
5112                                id: thisPostId,
5113                                pageid: cff_page_id,
5114                            };
5115                            if( shortcode_token_param !== '' ){
5116                                var token = shortcode_token_param.split('=');
5117                                submitData.at = token[1];
5118                            }
5119                            if( $cffClosest.attr('data-own-token') == 'true' ) {
5120                                submitData.useowntoken = true;
5121                            }
5122                            if( cffgroupalbums ){
5123                                submitData.usegrouptoken = cffgroupalbums;
5124                            }
5125                            if( albumsonly ){
5126                                submitData.albumsonly = true;
5127                            }
5128
5129                            var onSuccess = function(data) {
5130                                //Convert string of data received from thumbs.php to a JSON object
5131                                data = JSON.parse( data );
5132
5133                                if(albumsonly){
5134                                    //Compile the thumbs
5135                                    $.each(data.data, function(i, photoItem) {
5136                                        var dataCaption = '';
5137                                        if( photoItem.name ) dataCaption = photoItem.name;
5138                                        // origCaption = String(origCaption).replace(/"/g, '&quot;');
5139
5140                                        //Format the caption and add links
5141                                        dataCaption = cffLinkify(dataCaption);
5142                                        dataCaption = dataCaption.replace( hashRegex , cffReplaceHashtags );
5143
5144                                        // dataCaption = dataCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
5145                                        dataCaption = String(dataCaption).replace(/& /g, '&amp; ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
5146
5147                                        origCaption = String(origCaption).replace(/& /g, '&amp; ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
5148
5149                                        var lightboxImageOrder = (parseInt(self.currentImageIndex)+parseInt(i));
5150
5151                                        //If it's a group then use the source otherwise it displays as question marks
5152                                        var cffThumbHref = photoItem.source,
5153                                            cffPhotoItemWidth = photoItem.width,
5154                                            cffPhotoItemHeight = photoItem.height;
5155
5156                                        //Use the full size image if available
5157                                        if( typeof photoItem.images[0] !== 'undefined' ){
5158                                            cffThumbHref = photoItem.images[0].source;
5159                                            cffPhotoItemWidth = photoItem.images[0].width;
5160                                            cffPhotoItemHeight = photoItem.images[0].height;
5161                                        }
5162
5163                                        //Set the thumbnail image to be the smallest size available, which is the second from last in images arr
5164                                        if( typeof photoItem.images[ photoItem.images.length-2 ] !== 'undefined' ){
5165                                            var cffThumbImg = photoItem.images[ photoItem.images.length-2 ].source;
5166                                        } else {
5167                                            var cffThumbImg = cffThumbHref;
5168                                        }
5169
5170                                        albumThumbs += '<a href="'+cffThumbHref+'" class="cff-lightbox-attachment" data-facebook="http://facebook.com/'+photoItem.id+'" data-caption="'+dataCaption+'" orig-caption="'+origCaption+'" data-cff-lightbox-order="'+lightboxImageOrder+'" data-thumbs="true" data-url="http://facebook.com/'+photoItem.id+'" data-iframe data-video data-type="albumsonly" data-cff-isthumbnail="true"><img src="'+cffThumbImg+'" lbcomments="false" width="'+cffPhotoItemWidth+'" height="'+cffPhotoItemHeight+'" /></a>';
5171
5172                                        thumbsData.push([cffThumbHref, cffPhotoItemWidth, cffPhotoItemHeight, 'http://facebook.com/'+photoItem.id, dataCaption, origCaption, undefined, undefined, cffThumbImg]);
5173
5174                                        //Add all of the thumbs (apart from the first thumb) to the lightbox order
5175                                        if( i > 0 ){
5176                                            cffInsertLightboxImage(lightboxImageOrder, cffThumbHref, dataCaption, 'http://facebook.com/'+photoItem.id, thisPostId, albumsonly, true, cffThumbImg);
5177                                        }
5178
5179                                    }); //End each
5180
5181                                } else {
5182                                    //Check whether there's data..
5183                                    if (typeof data.attachments !== 'undefined') {
5184
5185                                        //..Then compile the thumbs
5186                                        $.each(data.attachments.data[0].subattachments.data, function(i, subattachment) {
5187                                            var dataCaption = '';
5188                                            if( subattachment.description ) dataCaption = subattachment.description;
5189                                            origCaption = String(origCaption).replace(/"/g, '&quot;');
5190
5191                                            //Format the caption and add links
5192                                            dataCaption = cffLinkify(dataCaption);
5193                                            dataCaption = dataCaption.replace( hashRegex , cffReplaceHashtags );
5194                                            // dataCaption = dataCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
5195                                            dataCaption = String(dataCaption).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
5196
5197                                            var lightboxImageOrder = (parseInt(self.currentImageIndex)+parseInt(i));
5198
5199                                            albumThumbs += '<a href="'+subattachment.media.image.src+'" class="cff-lightbox-attachment" data-facebook="'+subattachment.url+'" data-caption="'+dataCaption+'" orig-caption="'+origCaption+'" lbcomments="true" data-page-name="'+author_name+'" data-post-date="'+date_in_correct_format
5199+'" data-cff-lightbox-order="'+lightboxImageOrder+'" data-thumbs="true" data-url="'+subattachment.url+'" data-iframe data-video data-type data-cff-isthumbnail="true"><img src="'+subattachment.media.image.src+'" width="'+subattachment.media.image.width+'" height="'+subattachment.media.image.height+'" /></a>';
5200
5201                                            thumbsData.push([subattachment.media.image.src, subattachment.media.image.width, subattachment.media.image.height, subattachment.url, dataCaption, origCaption, author_name, date_in_correct_format]);
5202
5203                                            //Add all of the thumbs (apart from the first thumb) to the lightbox order
5204                                            if( i > 0 ){
5205                                                cffInsertLightboxImage(lightboxImageOrder, subattachment.media.image.src, dataCaption, subattachment.url, thisPostId, albumsonly, true, author_name, date_in_correct_format, subattachment.media.image.src);
5206                                            }
5207
5208                                        });
5209
5210                                    } //End undefined check
5211
5212                                } //End if/else
5213
5214                                //Add thumbs to the page
5215                                if( albumThumbs.length > 0 ){
5216                                    $('.cff-lightbox-thumbs-holder').html( '<div class="cff-lightbox-thumbs-wrap">' + albumThumbs + '</div>' ).addClass('cff-animate');
5217                                    $('.cff-lightbox-wrapper').addClass('cff-has-thumbs');
5218                                }
5219
5220                                //Liquidfill the thumbs
5221                                jQuery(".cff-lightbox-thumbs-holder .cff-lightbox-attachment").imgLiquid({fill:true, useBackgroundSize:true});
5222
5223                                //Hide the loader
5224                                $('.cff-loader').hide();
5225
5226                                $('.cff-lightbox-thumbs-holder').css('min-height', 0);
5227
5228                                //Add the thumbs to the thumbs array to store them
5229                                thumbsArr[ thisPostId ] = thumbsData;
5230
5231                                //album done loading, can change items now
5232                                if (albumsonly) {
5233                                    jQuery('.cff-lightbox-container').removeClass('cff-album-loading');
5234                                    jQuery('.cff-lightbox-prev, .cff-lightbox-next').show();
5235                                }
5236                            }; // end success
5237                            $('.cff-gdpr-more-link').remove();
5238                            if (window.cff.feeds[ this.album[this.currentImageIndex].feedIndex ].settings.consentGiven) {
5239                                // disable navigation while albums load
5240                                if (albumsonly) {
5241                                    jQuery('.cff-lightbox-container').addClass('cff-album-loading');
5242                                    jQuery('.cff-lightbox-prev, .cff-lightbox-next').hide();
5243                                }
5244                                cffAjax(submitData,onSuccess);
5245                            } else {
5246                                if (parseInt(this.album[this.currentImageIndex].count) > 0) {
5247                                    $('.cff-lightbox-facebook').after('<a href="' + $('.cff-lightbox-facebook').attr('href') + '"  class="cff-gdpr-more-link cff-lightbox-attachment"><div class="cff-gdpr-overlay"></div><span>+' + this.album[this.currentImageIndex].count + '</span><img src="'+jQuery('.cff-lightbox-image').attr('src')+'"></a>');
5248                                    $('.cff-gdpr-more-link').imgLiquid({fill:true, useBackgroundSize:true});
5249                                    setTimeout(function () {
5250                                        $('.cff-gdpr-more-link span').css({
5251                                            'margin-top': '-' + ($('.cff-gdpr-more-link span').height() / 2) + 'px',
5252                                            'margin-right': '-' + ($('.cff-gdpr-more-link span').width() / 2) + 'px',
5253                                            'display': 'block'
5254                                        });
5255                                    }, 200);
5256                                }
5257                            }
5258
5259                        } //End if/else
5260
5261                    } else {
5262                        //If there are no thumbs then hide the thumbs area
5263                        $('.cff-lightbox-thumbs').hide();
5264                    }
5265
5266                    //Add a class to the selected thumb
5267                    $(".cff-lightbox-attachment").removeClass('cff-selected');
5268                    $(".cff-lightbox-attachment[href='"+$('.cff-lightbox-image').attr('src')+"']").addClass('cff-selected');
5269
5270
5271                    function cffInsertLightboxImage(currentImageIndex, link, title, facebookurl, postid, albumsonly, isThumbnail, 
5271cffThumbImg){
5272
5273                        //Make sure the thumbs aren't added to the lightbox order more than once
5274                        var found = false;
5275                        $.each(self.album, function(i, thumbitem) {
5276                            if( ( thumbitem.link == link ) && ( thumbitem.postid == postid ) ){
5277                                found = true;
5278                                return;
5279                            }
5280                        });
5281                        if(found == true) return;
5282
5283                        ( albumsonly ) ? postType = 'albumsonly' : postType = '';
5284                        ( albumsonly ) ? lbcomments = 'false' : lbcomments = 'true';
5285
5286                        //Push the image into the album array at the correct location so it's included in the lightbox order
5287                        self.album.splice(currentImageIndex, 0, {
5288                            link: link,
5289                            title: title,
5290                            postid: postid,
5291                            showthumbs: 'true',
5292                            facebookurl: facebookurl,
5293                            video: '',
5294                            iframe: '',
5295                            type: postType,
5296                            cffgroupalbums: undefined,
5297                            isthumbnail: isThumbnail,
5298                            lbcomments: lbcomments,
5299                            thumbimg: cffThumbImg
5300                        });
5301
5302                    } //End cffInsertLightboxImage()
5303
5304                    /** END NEW PHOTO ACTION **/
5305
5306
5307                    //Still show the caption section even if there's not a caption as it contains the View on Facebook link
5308                    this.$lightbox.find('.cff-lightbox-caption').fadeIn('fast');
5309
5310
5311                    // Enable anchor clicks in the injected caption html.
5312                    if (typeof this.album[this.currentImageIndex].title !== 'undefined' && this.album[this.currentImageIndex].title !== "") {
5313
5314                        //If it's the first image in the lightbox then set the caption to be the text from the post. For all subsequent images the caption is changed on the fly based elsehwere in the code based on an attr from the thumb that's clicked
5315                        var origCaption = this.album[this.currentImageIndex].title;
5316                        //Add hashtag and tag links
5317                        // origCaption = cffLinkify(origCaption); - Caused issues with @tag links in regular lightbox popup
5318                        origCaption = origCaption.replace( hashRegex , cffReplaceHashtags );
5319                        // origCaption = origCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
5320                        //Decode the caption back so that the tags are rendered as HTML:
5321                        origCaption = String(origCaption).replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"');
5322
5323                        var $lightboxCaption = this.$lightbox.find('.cff-lightbox-caption'),
5324                            $lightboxCaptionText = $lightboxCaption.find('.cff-lightbox-caption-text');
5325                        if( this.album[this.currentImageIndex].link == $('.cff-lightbox-image').attr('src') ) $lightboxCaptionText.html( origCaption );
5326
5327                        //If there's no caption then remove the border and margin from the View on Facebook link
5328                        if( $lightboxCaptionText.text() == ' ' || $lightboxCaptionText.text() == '' ){
5329                            $lightboxCaption.addClass('cff-no-caption');
5330                        } else {
5331                            $lightboxCaption.removeClass('cff-no-caption');
5332                        }
5333
5334                    } else {
5335                        if(albumsonly || this.album[this.currentImageIndex].title === undefined) this.$lightbox.find('.cff-lightbox-caption-text').html('');
5336
5337                        //If there's no caption then add a class
5338                        if( this.$lightbox.find('.cff-lightbox-caption .cff-lightbox-caption-text').text().length < 1 ) this.$lightbox.find('.cff-lightbox-caption').addClass('cff-no-caption').find('.cff-lightbox-caption-text').html('');
5339                    }
5340
5341                    this.$lightbox.find('.cff-lightbox-facebook, .cff-lightbox-caption-text a, .cff-lightbox-sidebar a:not(.cff-comment-replies-a), .cff_gdpr_notice, .cff-gdpr-more-link').off('click').on('click', function(event){
5342                            window.open(
5343                                $(this).attr('href'),
5344                                '_blank'
5345                            )
5346                        }
5347                    );
5348
5349                    if (this.album.length > 1 && this.options.showImageNumberLabel) {
5350                        this.$lightbox.find('.cff-lightbox-number').text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn('fast');
5351                    } else {
5352                        this.$lightbox.find('.cff-lightbox-number').hide();
5353                    }
5354
5355                    if (typeof cffLightboxAction === 'function') {
5356                        setTimeout(function() {
5357                            cffLightboxAction();
5358                        },100);
5359                    }
5360
5361                    this.$outerContainer.removeClass('animating');
5362
5363                    this.$lightbox.find('.cff-lightbox-dataContainer').fadeIn(this.options.resizeDuration, function() {
5364                        return self.sizeOverlay();
5365                    });
5366
5367                }; //End Lightbox.prototype.updateDetails
5368
5369                // Preload previous and next images in set.
5370                Lightbox.prototype.preloadNeighboringImages = function() {
5371                    if (this.album.length > this.currentImageIndex + 1) {
5372                        var preloadNext = new Image();
5373                        preloadNext.src = this.album[this.currentImageIndex + 1].link;
5374                    }
5375                    if (this.currentImageIndex > 0) {
5376                        var preloadPrev = new Image();
5377                        preloadPrev.src = this.album[this.currentImageIndex - 1].link;
5378                    }
5379                };
5380
5381                Lightbox.prototype.enableKeyboardNav = function() {
5382                    $(document).on('keyup.keyboard', $.proxy(this.keyboardAction, this));
5383                };
5384
5385                Lightbox.prototype.disableKeyboardNav = function() {
5386                    $(document).off('.keyboard');
5387                };
5388
5389                Lightbox.prototype.keyboardAction = function(event) {
5390                    var KEYCODE_ESC        = 27;
5391                    var KEYCODE_LEFTARROW  = 37;
5392                    var KEYCODE_RIGHTARROW = 39;
5393
5394                    var keycode = event.keyCode;
5395                    var key     = String.fromCharCode(keycode).toLowerCase();
5396                    if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
5397                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
5398                        $('#cff-lightbox-wrapper iframe').attr('src', '');
5399
5400                        this.end();
5401                    } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
5402                        if (jQuery('.cff-lightbox-container').hasClass('cff-album-loading')) {
5403                            // disable navigation while albums load
5404                            return;
5405                        }
5406                        if (this.currentImageIndex !== 0) {
5407                            this.changeImage(this.currentImageIndex - 1);
5408                        } else if (this.options.wrapAround && this.album.length > 1) {
5409                            this.changeImage(this.album.length - 1);
5410                        }
5411
5412                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
5413                        $('#cff-lightbox-wrapper iframe').attr('src', '');
5414
5415                    } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
5416                        if (jQuery('.cff-lightbox-container').hasClass('cff-album-loading')) {
5417                            // disable navigation while albums load
5418                            return;
5419                        }
5420                        if (this.currentImageIndex !== this.album.length - 1) {
5421                            this.changeImage(this.currentImageIndex + 1);
5422                        } else if (this.options.wrapAround && this.album.length > 1) {
5423                            this.changeImage(0);
5424                        }
5425
5426                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
5427                        $('#cff-lightbox-wrapper iframe').attr('src', '');
5428
5429                    }
5430                };
5431
5432                // Closing time
5433                Lightbox.prototype.end = function() {
5434                    this.disableKeyboardNav();
5435                    $(window).off("resize", this.sizeOverlay);
5436                    this.$lightbox.fadeOut(this.options.fadeDuration);
5437                    this.$overlay.fadeOut(this.options.fadeDuration);
5438                    $('select, object, embed').css({
5439                        visibility: "visible"
5440                    });
5441                };
5442
5443                return Lightbox;
5444
5445            })(); //End Lightbox = (function()
5446
5447            $(function() {
5448                var options  = new LightboxOptions();
5449                var lightbox = new Lightbox(options);
5450            });
5451
5452        }).call(this); //End (function() {
5453
5454        //Checks whether browser support HTML5 video element
5455        function cff_supports_video() {
5456            return !!document.createElement('video').canPlayType;
5457        }
5458
5459
5460    } //End cffLightbox function
5461
5462//Only call the lightbox if the class is on at least one feed on the page
5463    if( jQuery('#cff.cff-lb').length ) cffLightbox();
5464
5465
5466
5467} //End cff_js_exists check

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.