PageSourceSearch

https://dimedsol.com/wp-content/plugins/custom-facebook-feed-pro/assets/js/cff-scripts.js?ver=4.2.2

js dimedsol.com collected 2026-10-02 01:27:42 UTC 348,176 bytes, 5,492 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                  masonryEnabled = true;
908                  $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
909                }
910            } else if (windowWidth > 400) {
911                if ($self.hasClass('masonry-2-tablet')
912                    || $self.hasClass('masonry-3-tablet')
913                    || $self.hasClass('masonry-4-tablet')
914                    || $self.hasClass('masonry-5-tablet')
915                    || $self.hasClass('masonry-6-tablet')) {
916                    masonryEnabled = true;
917                    $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
918                }
919            } else {
920                if ($self.hasClass('masonry-2-mobile')
921                    || $self.hasClass('masonry-3-mobile')) {
922                    masonryEnabled = true;
923                    $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
924                }
925            }
926
927            if ($self.hasClass('cff-masonry')) {
928                $self.find('.cff-album-item a').removeAttr('style');
929            }
930
931            if (masonryEnabled) {
932                if($self.find('.cff-item').length) {
933                    window.cffMasonrySettings.itemSelector = '.cff-new, .cff
933-item, .cff-likebox';
934                    $self.masonry(window.cffMasonrySettings);
935                    // Add margin to the bottom of each post to give some space
936                    $self.find('.cff-item').each( function() {
937                        jQuery(this).css('margin-bottom', '15px');
938                    });
939                } else if($self.find('.cff-album-item').length) {
940                    window.cffMasonrySettings.itemSelector = '.cff-album-item, .cff-likebox';
941                    $self.masonry(window.cffMasonrySettings);
942                }
943            }
944        }
945
946    } //End Masonry code
947
948    window.cffMasonrySettings = {itemSelector: '.cff-album-item' };
949
950    function Cff() {
951        this.feeds = {};
952        this.options = {};
953    }
954
955    Cff.prototype = {
956        createPage: function (createFeeds, createFeedsArgs) {
957
958            if (typeof window.cffOptions === 'undefined'
959                || typeof window.cffOptions.resized_url === 'undefined') {
960                window.cffOptions = {
961                    resized_url: location.protocol + '//' + window.location.hostname + "/wp-content/uploads/sb-facebook-feed-images/",
962                    placeholder: location.protocol + '//' + window.location.hostname + "/wp-content/plugins/custom-facebook-feed-pro/assets/img/placeholder.png",
963                }
964            }
965
966            createFeeds(createFeedsArgs);
967        },
968        createFeeds: function (args) {
969            jQuery('.cff').each(function (index) {
970                jQuery(this).attr('data-cff-index', index + 1);
971                var $self = jQuery(this),
972                    flags = typeof $self.attr('data-cff-flags') !== 'undefined' ? $self.attr('data-cff-flags').split(',') : [];
973                var feedOptions = {
974                    feedID : $self.find('.cff_resized_image_data').attr('data-feedid'),
975                    shortCodeAtts : $self.attr('data-cff-shortcode'),
976                    resizingEnabled : $self.find('.cff_resized_image_data').length,
977                    page: 1,
978                    pag_url : '',
979                    gdpr : (flags.indexOf('gdpr') > -1),
980                    overrideBlockCDN : (flags.indexOf('overrideBlockCDN') > -1),
981                    consentGiven : false,
982                    locator : (flags.indexOf('locator') > -1),
983                    postID : typeof $self.attr( 'data-postid' ) !== 'undefind' ? $self.attr( 'data-postid' ) : 'unknown',
984                };
985
986                window.cff.feeds[index] = new CffFeed(this, index, feedOptions);
987                if (typeof window.cff.feeds[index].setResizedImages !== 'undefined') {
988                    window.cff.feeds[index].setResizedImages();
989                }
990                if (typeof window.cff.feeds[index].setResizedImages !== 'undefined') {
991                    window.cff.feeds[index].init();
992                }
993            });
994        },
995
996    };
997
998    function CffFeed(el, index, settings) {
999        this.el = el;
1000        this.index = index;
1001        this.settings = settings;
1002        this.resizedImages = {};
1003        this.needsResizing = [];
1004        this.imagesWaiting = 0;
1005    }
1006
1007    function CFFLocationGuess($cff = false) {
1008            var $feed = ($cff == false) ? jQuery(this.el) : $cff,
1009                location = 'content';
1010
1011            if ($feed.closest('footer').length) {
1012                location = 'footer';
1013            } else if ($feed.closest('.header').length
1014                || $feed.closest('header').length) {
1015                location = 'header';
1016            } else if ($feed.closest('.sidebar').length
1017                || $feed.closest('aside').length) {
1018                location = 'sidebar';
1019            }
1020
1021            return location;
1022        }
1023
1024    CffFeed.prototype = {
1025        init: function() {
1026            var feed = this;
1027            feed.settings.consentGiven = feed.checkConsent();
1028            if (!feed.settings.consentGiven) {
1029                if (jQuery(this.el).find('.cff-load-more').is(':visible')) {
1030                    jQuery(this.el).find('.cff-load-more').hide().addClass('cff-no-consent-hide');
1031                }
1032                var $wrapper = jQuery(this.el).closest('.cff-wrapper');
1033                if ($wrapper.find('.cff-visual-header').length) {
1034                    $wrapper.find('.cff-header-text').closest('.cff-visual-header').addClass('cff-no-consent');
1035                }
1036                $wrapper.find('.fb-video').addClass('cff-no-consent');
1037
1038                setTimeout(function() {
1039                    feed.settings.consentGiven = feed.checkConsent();
1040                    if (feed.settings.consentGiven) {
1041                        feed.addFullFeatures();
1042                    }
1043                },1000);
1044            }
1045
1046            var cff_delay = (function () {
1047                var cff_timer = 0;
1048                return function (cff_callback, cff_ms) {
1049                    clearTimeout(cff_timer);
1050                    cff_timer = setTimeout(cff_callback, cff_ms);
1051                };
1052            })();
1053            this.afterInitialImagesLoaded();
1054            jQuery(window).on('resize', function () {
1055                cff_delay(function () {
1056                    feed.afterResize();
1057                }, 500);
1058            });
1059
1060            jQuery(this.el).find('.cff-item').each(function() {
1061                feed.lazyLoadCheck(jQuery(this));
1062            });
1063
1064        },
1065        addFullFeatures: function() {
1066            var $ = jQuery,
1067                $self = jQuery(this.el);
1068            jQuery('.cff-gdpr-notice').remove();
1069
1070            jQuery(this.el).find('.cff-author-img').each(function() {
1071                $(this).find('img').attr('src',$(this).attr('data-avatar'));
1072                $(this).removeClass('cff-no-consent');
1073            });
1074            jQuery('.fb-video.cff-no-consent').removeClass('cff-no-consent');
1075
1076            if (jQuery('.cff-visual-header').length) {
1077                jQuery('.cff-visual-header').each(function() {
1078                    jQuery(this).removeClass('cff-no-consent');
1079                    if (jQuery(this).find('.cff-header-hero').length) {
1080                        jQuery(this).find('.cff-header-hero').find('img').attr('src',jQuery(this).find('.cff-header-hero').find('img').attr('data-cover-url'))
1081                    }
1082                    if (jQuery(this).find('.cff-header-img').length) {
1083                        jQuery(this).find('.cff-header-img').find('img').attr('src',jQuery(this).find('.cff-header-img').find('img').attr('data-avatar'))
1084                    }
1085                });
1086
1087
1088            }
1089            jQuery('.cff-comment:visible').each(function() {
1090                var $thisComment = jQuery(this); // here
1091                var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
1092                if (consentGiven) {
1093                    $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\'" />');
1094                }
1095            });
1096
1097            //cff-comment-image-placeholder, <img src="'+commentItem.attachment.media.image.src+'" alt=""/>
1098            jQuery('.cff-comment-image-placeholder').each(function() {
1099                jQuery(this).replaceWith('<img src="'+jQuery(this).attr('data-src')+'" alt="Attachement"/>');
1100            });
1101            //
1102            jQuery('.cff-likebox iframe').each(function(){
1103                var $likebox = $(this),
1104                    likeboxWidth = $likebox.attr('data-likebox-width'),
1105                    cffFeedWidth = $likebox.parent().width();
1106
1107                //Default width is 340
1108                if( likeboxWidth == '' ) likeboxWidth = 340;
1109                //Change the width dynamically so it's responsive
1110                if( cffFeedWidth < likeboxWidth ) likeboxWidth = cffFeedWidth;
1111
1112                $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'));
1113            });
1114            jQuery('.cff-iframe-placeholder').each(function(){
1115                var $placeholder = jQuery(this),
1116                    src = $placeholder.attr('data-src'),
1117                    type = $placeholder.attr('data-type');
1118                switch (type) {
1119                    case 'facebook':
1120                        $placeholder.replaceWith('<iframe src="'+src+'" title="Facebook video player" allowfullscreen frameborder="0" webkitallowfullscreen mozallowfullscreen></iframe>');
1121                        break;
1122                    case 'youtube':
1123                        $placeholder.replaceWith('<iframe class="youtube-player" type="text/html" src="'+src+'" allowfullscreen title="YouTube video"></iframe>');
1124                        break;
1125                    case 'vimeo':
1126                        $placeholder.replaceWith('<iframe src="'+src+'" webkitAllowFullScreen mozallowfullscreen allowFullScreen title="Vimeo video"></iframe>');
1127                        break;
1128                    case 'soundcloud':
1129                        $placeholder.replaceWith('<iframe class="cff-soundcloud" width="100%" height="100" scrolling="no" title="Music player" frameborder="no" src="'+src+'"></iframe>');
1130                        break;
1131                    case 'spotify':
1132                        $placeholder.replaceWith('<iframe class="cff-spotify" src="'+src+'" width="100%" height="80" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>');
1133                        break;
1134                    case 'video':
1135                        var posterSrc = $placeholder.attr('data-poster-src');
1136                        $placeholder.replaceWith('<video src="'+src+'" poster="'+posterSrc+'" preload="none"></video>');
1137                        break;
1138                }
1139            });
1140
1141            jQuery('a[data-x-cff-lightbox]').each(function() {
1142                jQuery(this).attr('data-cff-lightbox',jQuery(this).attr('data-x-cff-lightbox'));
1143                jQuery(this).removeAttr('data-x-cff-lightbox');
1144            });
1145
1146            jQuery(this.el).find('.cff-load-more.cff-no-consent-hide').show();
1147
1148            this.afterResize();
1149        },
1150        setResizedImages: function() {
1151            if (jQuery(this.el).find('.cff_resized_image_data').length
1152                && typeof jQuery(this.el).find('.cff_resized_image_data').attr('data-resized') !== 'undefined'
1153                && (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)) {
1154                var rawResized = JSON.parse(jQuery(this.el).find('.cff_resized_image_data').attr('data-resized')),
1155                    organizedResized = {};
1156
1157                jQuery.each(rawResized,function(index,value) {
1158                    organizedResized[value.facebook_id] = {
1159                        id: value.media_id,
1160                        sizes: JSON.parse(value.sizes),
1161                        aspect: value.aspect_ratio
1162                    }
1163
1164                });
1165
1166                this.resizedImages = organizedResized;
1167            }
1168            jQuery(this.el).find('.cff_resized_image_data').remove();
1169        },
1170        sendNeedsResizingToServer: function() {
1171            var feed = this;
1172
1173            if (feed.needsResizing.length > 0 && feed.settings.resizingEnabled) {
1174                var itemOffset = jQuery(this.el).find('.cff-item').length;
1175                if (!feed.settings.consentGiven
1176                    && !feed.settings.overrideBlockCDN) {
1177                    if (typeof jQuery(this.el).find('.cff-lightbox-link').attr('data-cff-lightbox') !== 'undefined') {
1178                        jQuery(this.el).find('.cff-lightbox-link').attr('data-x-cff-lightbox',jQuery(this.el).find('.cff-lightbox-link').attr('data-cff-lightbox'));
1179                        jQuery(this.el).find('.cff-lightbox-link').removeAttr('data-cff-lightbox');
1180                    }
1181                }
1182
1183                var submitData = {
1184                    action: 'cff_resized_images_submit',
1185                    needs_resizing: feed.needsResizing,
1186                    offset: itemOffset,
1187                    feed_id: feed.settings.feedID,
1188                    atts: feed.settings.shortCodeAtts,
1189                    pag_url: feed.pag_url,
1190                    location: CFFLocationGuess(),
1191                    post_id: feed.settings.postID,
1192                };
1193                var onSuccess = function(data) {
1194                    feed.needsResizing = [];
1195                    if (data.trim().indexOf('{') === 0) {
1196                        var response = JSON.parse(data);
1197                        if (feed.settings.debugEnabled) {
1198                            console.log(response);
1199                        }
1200
1201                        if (typeof response.resizing !== 'undefined') {
1202                            var resized = response.resizing;
1203                            for (var property in resized) {
1204                                if (resized.hasOwnProperty(property)) {
1205                                    feed.resizedImages[property] = resized[property];
1206                                }
1207                            }
1208                            feed.maybeRaiseImageResolution();
1209
1210                            if (typeof jQuery(feed.el).find('.cff-lightbox-link').attr('data-x-cff-lightbox') !== 'undefined') {
1211                                jQuery(feed.el).find('.cff-lightbox-link').attr('data-cff-lightbox',jQuery(feed.el).find('.cff-lightbox-link').attr('data-x-cff-lightbox'));
1212                                jQuery(feed.el).find('.cff-lightbox-link').removeAttr('data-x-cff-lightbox');
1213                            }
1214
1215                            setTimeout(function() {
1216                                feed.afterResize();
1217                            },500);
1218                        }
1219                    }
1220                };
1221                cffAjax(submitData,onSuccess);
1222            } else if (feed.settings.locator) {
1223                    var submitData = {
1224                        action: 'cff_do_locator',
1225                        feed_id: feed.settings.feedID,
1226                        atts: feed.settings.shortCodeAtts,
1227                        location: CFFLocationGuess(),
1228                        post_id: feed.settings.postID
1229                    };
1230                    var onSuccess = function(data) {
1231
1232                    };
1233                    cffAjax(submitData,onSuccess);
1234            }
1235        },
1236        hasTargetElement: function($cffItem) {
1237            var $target = $cffItem;
1238            if ($cffItem.find('.cff-photo').length) {
1239                $target = $cffItem.find('.cff-photo');
1240            } else if ($cffItem.find('.cff-poster').length) {
1241                $target = $cffItem.find('.cff-poster');
1242            } else if ($cffItem.find('.cff-link-slider-slides').length) {
1243                $target = $cffItem.find('.cff-link-slider-slides');
1244            } else if ($cffItem.find('.cff-img-wrap').length) {
1245                $target = $cffItem.find('.cff-img-wrap');
1246            } else if ($cffItem.find('.cff-album-cover').length) {
1247                $target = $cffItem.find('.cff-album-cover');
1248            } else if ($cffItem.find('.cff-link').length) {
1249                $target = $cffItem.find('.cff-link');
1250            }
1251
1252            return typeof $target.attr('data-img-src-set') !== 'undefined';
1253        },
1254        getTargetElement: function($cffItem) {
1255            var $target = $cffItem.find('.cff-photo');
1256
1257            if ($cffItem.find('.cff-poster').length) {
1258                $target = $cffItem.find('.cff-poster');
1259            } else if ($cffI
1259tem.find('.cff-link-slider-slides').length) {
1260                $target = $cffItem.find('.cff-link-slider-item');
1261            } else if ($cffItem.find('.cff-img-wrap').length) {
1262                $target = $cffItem.find('.cff-img-wrap');
1263            } else if ($cffItem.find('.cff-album-cover').length) {
1264                $target = $cffItem.find('.cff-album-cover');
1265            } else if ($cffItem.find('.cff-link').length) {
1266                $target = $cffItem.find('.cff-link');
1267            }
1268
1269            return $target;
1270        },
1271        getTargetElementImage: function($targetItem) {
1272            if ($targetItem.find('img').length) {
1273                return $targetItem.find('img');
1274            } else {
1275                return $targetItem;
1276            }
1277        },
1278        getTargetWidth: function($imgWrapItem,$item,index) {
1279            var width = 50,
1280                newWidth = 0;
1281
1282            if ($item.find('.cff-multi-image').length > 2 && index > 0) {
1283                newWidth = $item.innerWidth() / 3;
1284            } else if ($item.closest('.cff-masonry').length) {
1285                newWidth = $item.innerWidth();
1286            } else if ($imgWrapItem.closest('.cff-item').find('.cff-link-slider').length) {
1287                newWidth = $imgWrapItem.closest('.cff-item').find('.cff-link-slider').width();
1288            } else if ($imgWrapItem.closest('.cff-media-wrap').length
1289                && !$imgWrapItem.closest('.cff-thumb-layout').length
1290                && !$imgWrapItem.closest('.cff-half-layout').length) {
1291                newWidth = $imgWrapItem.closest('.cff-media-wrap').width();
1292            } else {
1293                newWidth = $imgWrapItem.innerWidth();
1294            }
1295
1296            return Math.max(width,newWidth);
1297        },
1298        maybeRaiseSingleImageResolution: function ($item, index, forceChange) {
1299            var feed = this,
1300                $target = feed.getTargetElement($item),
1301                imgSrcSet = feed.getImageUrls($item,$target);
1302
1303            $target.each(function(i) {
1304                var $imgWrapItem = jQuery(this),
1305                    $targetImageElement = feed.getTargetElementImage($imgWrapItem),
1306                    currentUrl = $targetImageElement.attr('src'),
1307                    currentRes = typeof $imgWrapItem.attr('data-current') === 'undefined' ? 0 : parseInt($imgWrapItem.attr('data-current')),
1308                    neededRes = feed.getTargetWidth($imgWrapItem,$item,i),
1309                    changeToRes = false;
1310                if (currentRes < neededRes && typeof imgSrcSet[i] !== 'undefined') {
1311                    var foundBestRes = false;
1312                    jQuery.each(imgSrcSet[i], function (ii, value) {
1313
1314                        if (! foundBestRes && ii > currentRes) {
1315                            changeToRes = ii;
1316                            if (ii >= neededRes) {
1317                                foundBestRes = true;
1318                            }
1319                        }
1320                    });
1321                }
1322
1323                if (!feed.settings.consentGiven) {
1324                    //'a[data-cff-lightbox], area[data-cff-lightbox]'
1325                    var $lightboxAnchor = false;
1326                    if ($imgWrapItem.find('a[data-cff-lightbox]').length) {
1327                        $lightboxAnchor = $imgWrapItem.find('a[data-cff-lightbox]');
1328
1329                    } else if ($imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]').length) {
1330                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]');
1331
1332                    }
1333
1334                    if ($imgWrapItem.find('area[data-cff-lightbox]').length) {
1335                        $lightboxAnchor = $imgWrapItem.find('area[data-cff-lightbox]');
1336
1337                    } else if ($imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]').length) {
1338                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]');
1339
1340                    }
1341                    if ($lightboxAnchor) {
1342                        if($lightboxAnchor.parent('div').hasClass('cff-html5-video')){
1343                            //$lightboxAnchor.attr('href',$lightboxAnchor.parent('.cff-html5-video').attr('data-cff-video-link'));
1344                        }else{
1345                            //$lightboxAnchor.attr('href',feed.getMaxResImage(imgSrcSet,i));
1346                        }
1347                    }
1348
1349                    //getMaxResImage: function(imgSrcSet,index)
1350
1351                } else {
1352                    $lightboxAnchor = false;
1353                    if ($imgWrapItem.find('a[data-cff-lightbox]').length) {
1354                        $lightboxAnchor = $imgWrapItem.find('a[data-cff-lightbox]');
1355                    } else if ($imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]').length) {
1356                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('a[data-cff-lightbox]');
1357                    } else if ($imgWrapItem.closest('.cff-album-item').find('a[data-cff-lightbox]').length) {
1358                        $lightboxAnchor = $imgWrapItem.closest('.cff-album-item').find('a[data-cff-lightbox]');
1359                    }
1360
1361                    if ($imgWrapItem.find('area[data-cff-lightbox]').length) {
1362                        $lightboxAnchor = $imgWrapItem.find('area[data-cff-lightbox]');
1363                    } else if ($imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]').length) {
1364                        $lightboxAnchor = $imgWrapItem.closest('.cff-item').find('area[data-cff-lightbox]');
1365                    }
1366
1367                    if ($lightboxAnchor && typeof($lightboxAnchor) !== "boolean") {
1368                        if($lightboxAnchor.parent('div').hasClass('cff-html5-video')){
1369                            // $lightboxAnchor.attr('href',$lightboxAnchor.parent('.cff-html5-video').attr('data-cff-video-link'));
1370                        }else{
1371                            //$lightboxAnchor.attr('href',feed.getMaxResImage(imgSrcSet,i));
1372                        }
1373                    }
1374                }
1375
1376                if (changeToRes) {
1377                    currentRes = changeToRes;
1378                    if (feed.settings.debugEnabled) {
1379                        var reason = currentUrl === feed.placeholderURL ? 'was placeholder' : 'too small';
1380                    }
1381                    $imgWrapItem.attr('data-current',changeToRes);
1382                    var newUrl = imgSrcSet[i][changeToRes];
1383                    if (newUrl !== currentUrl) {
1384                        $targetImageElement.attr('src', newUrl);
1385                        if ($imgWrapItem.hasClass('imgLiquid_ready')) {
1386                            $imgWrapItem.css('background-image', 'url("' + newUrl + '")');
1387                            $imgWrapItem.imgLiquid({fill:true});
1388                        }
1389
1390                        feed.processNewImage($imgWrapItem);
1391
1392                        if (currentRes < 720 && $item.hasClass('cff-album-item') && ! $targetImageElement.hasClass('cff-secondary-check')) {
1393                            $targetImageElement.addClass('cff-secondary-check');
1394                            $targetImageElement.on('load',function() {
1395                                if (!jQuery(this).hasClass('cff-secondary-checked')) {
1396                                    jQuery(this).addClass('cff-secondary-checked');
1397                                    var imagEl = $targetImageElement.get(0),
1398                                        height = imagEl.naturalHeight,
1399                                        aspectRatio = imagEl.naturalWi
1399dth/imagEl.naturalHeight;
1400
1401                                    if ($targetImageElement.innerWidth() > height) {
1402                                        neededRes = feed.getTargetWidth($imgWrapItem,$item,i) * aspectRatio;
1403                                        if (parseInt(currentRes) < neededRes) {
1404                                            foundBestRes = false;
1405                                            jQuery.each(imgSrcSet[i], function (ii, value) {
1406
1407                                                if (! foundBestRes && ii > currentRes) {
1408                                                    changeToRes = ii;
1409                                                    if (ii >= neededRes) {
1410                                                        foundBestRes = true;
1411                                                    }
1412                                                }
1413                                            });
1414
1415                                            if (changeToRes) {
1416                                                $imgWrapItem.attr('data-current', changeToRes);
1417                                                var newUrl = imgSrcSet[i][changeToRes];
1418                                                if (newUrl !== currentUrl) {
1419                                                    $targetImageElement.attr('src', newUrl);
1420                                                    if ($imgWrapItem.hasClass('imgLiquid_ready')) {
1421                                                        $imgWrapItem.css('background-image', 'url("' + newUrl + '")');
1422                                                        $imgWrapItem.imgLiquid({fill:true});
1423                                                    }
1424
1425                                                    feed.processNewImage($imgWrapItem);
1426                                                }
1427                                            }
1428                                        }
1429                                    }
1430                                }
1431
1432                            });
1433                        }
1434
1435                    }
1436
1437                }
1438
1439                $targetImageElement.on('error', function () {
1440                    if (!jQuery(this).hasClass('cff-img-error')) {
1441                        jQuery(this).addClass('cff-img-error');
1442                        var newUrl = typeof jQuery(this).attr('data-orig-source') !== 'undefined' ? jQuery(this).attr('data-orig-source') : false;
1443                        if (newUrl && newUrl !== currentUrl) {
1444                            $targetImageElement.attr('src', newUrl);
1445                            if ($imgWrapItem.hasClass('imgLiquid_ready')) {
1446                                $imgWrapItem.css('background-image', 'url("' + newUrl + '")');
1447                            }
1448                        }
1449                        setTimeout(function() {
1450                            feed.afterResize();
1451                        }, 1500)
1452                    } else {
1453                        console.log('unfixed error ' + jQuery(this).attr('src'));
1454                    }
1455                });
1456            });
1457
1458
1459        },
1460        maybeRaiseImageResolution: function (justNew) {
1461            var feed = this,
1462                itemsSelector = typeof justNew !== 'undefined' && justNew === true ? '.cff-item.cff-new, .cff-album-item.cff-new' : '.cff-item, .cff-album-item';
1463            jQuery(feed.el).find(itemsSelector).each(function (index) {
1464                if (!jQuery(this).hasClass('cff-num-diff-hide')
1465                    && feed.hasTargetElement(jQuery(this))) {
1466                    feed.maybeRaiseSingleImageResolution(jQuery(this),index);
1467                }
1468            }); //End .cff-item each
1469        },
1470        getImageUrls: function ($item,$target) {
1471            var feed = this,
1472                srcSet = {},
1473                $srcSetItem = false,
1474                id = $item.attr('id').replace('cff_', '');
1475
1476            if (typeof $target.attr('data-img-src-set') !== 'undefined') {
1477                $srcSetItem = $target;
1478            } else if (typeof $item.find('.cff-photo').attr('data-img-src-set') !== 'undefined') {
1479                $srcSetItem = $item.find('.cff-photo');
1480            } else if (typeof $item.find('.cff-link-slider-slides').attr('data-img-src-set') !== 'undefined') {
1481                $srcSetItem = $item.find('.cff-link-slider-slides');
1482            } else if (typeof $item.find('.cff-album-cover').attr('data-img-src-set') !== 'undefined') {
1483                $srcSetItem = $item.find('.cff-album-cover');
1484            }
1485
1486            if ($srcSetItem) {
1487                srcSet = JSON.parse($srcSetItem.attr('data-img-src-set').replace(/\\\//g, '/'))
1488            }
1489
1490            if (!this.settings.consentGiven && !this.settings.overrideBlockCDN) {
1491                jQuery.each(srcSet,function(index,value) {
1492                    srcSet[index] = {};
1493                });
1494            }
1495
1496            var returnSrcSet = srcSet;
1497            if (typeof feed.resizedImages[id] === 'undefined' && id.indexOf('_') === -1) {
1498              if ( typeof $item.attr('data-page-id') !== 'undefined') {
1499                id = $item.attr('data-page-id') + '_' + id;
1500              }
1501            }
1502            if (typeof feed.resizedImages[id] !== 'undefined'
1503                && feed.resizedImages[id].id !== 'pending'
1504                && feed.resizedImages[id].id !== 'error') {
1505                jQuery.each(srcSet,function(index,value) {
1506
1507                    if (feed.settings.consentGiven) {
1508                        returnSrcSet[index] = {};
1509                        var apiSourceSet = JSON.parse($srcSetItem.attr('data-img-src-set').replace(/\\\//g, '/'));
1510
1511                        jQuery.each(apiSourceSet[index],function(index2,value2) {
1512                            if (index2 > 700
1513                                || index2 < 220) {
1514                                returnSrcSet[index][index2] = value2;
1515                            }
1516                        });
1517                    }
1518
1519
1520                    jQuery.each(feed.resizedImages[id].sizes,function(index2,value2) {
1521                        returnSrcSet[index][value2] = window.cffOptions.resized_url+feed.resizedImages[id].id+'-'+index+'-'+value2+'.jpg';
1522                    });
1523                });
1524            } else if (typeof this.resizedImages[id] === 'undefined'
1525                || (typeof this.resizedImages[id]['id'] !== 'undefined' && this.resizedImages[id]['id'] !== 'pending' && this.resizedImages[id]['id'] !== 'error')) {
1526                var hasMediumSize = false;
1527
1528                jQuery.each(returnSrcSet[0],function(resolution) {
1529                    if (parseInt(resolution) > 150 && parseInt(resolution) < 500) {
1530                        hasMediumSize = true;
1531                    }
1532                });
1533                if (feed.settings.gdpr) {
1534                    hasMediumSize = false;
1535                }
1536                if (!hasMediumSize) {
1537                    this.addToNeedsResizing(id);
1538                }
1539            }
1540
1541            return returnSrcSet;
1542        },
1543        addToNeedsResizing: function (id) {
1544            if (this.needsResizing.indexOf(id) === -1) {
1545                this.needsResizing.push(id);
1546            }
1547        },
1548        processNewImage: function($item) {
1549            var feed = this;
1550            $item.find('img').each(function() {
1551                if (!jQuery(this).prop('complete')) {
1552                    feed.imagesWaiting++;
1553                    jQuery(this).addClass('cff-image-loading').on('load',function() {
1554                        jQuery(this).removeClass('cff-image-loading');
1555                        feed.imagesWaiting--;
1556                        if (feed.imagesWaiting < 1) {
1557                            feed.afterResize();
1558                        }
1559                    });
1560                    jQuery(this).on('error',function() {
1561                        jQuery(this).removeClass('cff-image-loading');
1562                        feed.imagesWaiting--;
1563                        if (feed.imagesWaiting < 1) {
1564                            feed.afterResize();
1565                        }
1566                    });
1567                }
1568            });
1569        },
1570        getMaxResImage: function(imgSrcSet,index) {
1571            if (typeof imgSrcSet[index] === 'undefined') {
1572                return false;
1573            }
1574            var largest = 0,
1575                largestImage = false;
1576            jQuery.each(imgSrcSet[index], function (index, value) {
1577                if (index > largest) {
1578                    largest = index;
1579                    largestImage = value.toString();
1580                }
1581            });
1582
1583            return largestImage;
1584        },
1585        lazyLoadCheck: function($item){
1586            var feed = this,
1587                $target = feed.getTargetElement($item),
1588                imgSrcSet = feed.getImageUrls($item,$target);
1589            if (!$item.closest('.cff').hasClass('cff-no-ll-check')) {
1590                $item.find('img').each(function(index) {
1591                    if (typeof jQuery(this).attr('data-src') !== 'undefined') {
1592                        jQuery(this).attr('data-src',jQuery(this).attr('data-orig-source'));
1593                    }
1594                    if (typeof jQuery(this).attr('data-orig-src') !== 'undefined') {
1595                        jQuery(this).attr('data-orig-src',jQuery(this).attr('data-orig-source'));
1596                    }
1597
1598                    if (!feed.settings.consentGiven) {
1599                        jQuery(this).removeAttr('data-orig-source');
1600                        maxResImage = feed.getMaxResImage(imgSrcSet,index);
1601                        if (maxResImage && maxResImage.indexOf('scontent') === -1) {
1602                            jQuery(this).attr('data-orig-source',maxResImage);
1603                        }
1604                    }
1605
1606                    jQuery(this).on('load',function() {
1607                        if (!jQuery(this).hasClass('cff-replaced')
1608                            && jQuery(this).attr('src').indexOf('placeholder') > -1) {
1609                            jQuery(this).addClass('cff-replaced');
1610                            var origSource = typeof jQuery(this).attr('data-orig-source') !== 'undefined' ? jQuery(this).attr('data-orig-source') : false;
1611                            if (origSource) {
1612                                jQuery(this).attr('src',jQuery(this).attr('data-orig-source'));
1613                                if (jQuery(this).closest('.imgLiquid_bgSize').length) {
1614                                    jQuery(this).closest('.imgLiquid_bgSize').css('background-image', 'url(' + origSource + ')');
1615                                }
1616                            }
1617                        }
1618                    });
1619                });
1620            }
1621        },
1622        maybeRelayoutMasonry: function() {
1623            var $cff = jQuery(this.el);
1624            if ($cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css')){
1625                var cff_delay = (function () {
1626                    var cff_timer = 0;
1627                    return function (cff_callback, cff_ms) {
1628                        clearTimeout(cff_timer);
1629                        cff_timer = setTimeout(cff_callback, cff_ms);
1630                    };
1631                })();
1632                cff_delay(function () {
1633                    cffAddMasonry($cff);
1634                }, 500);
1635            }
1636        },
1637        afterInitialImagesLoaded: function(){
1638            this.maybeRaiseImageResolution();
1639            this.sendNeedsResizingToServer();
1640            this.maybeCleanUpNew();
1641            if (this.settings.consentGiven) {
1642                this.addFullFeatures();
1643            }else{
1644                jQuery('.cff-gdpr-notice').css({'display':'inline-block'});
1645            }
1646        },
1647        afterResize: function () {
1648            this.maybeRaiseImageResolution();
1649            this.maybeRelayoutMasonry();
1650        },
1651        afterLoadMoreClicked: function() {
1652            this.maybeRaiseImageResolution();
1653            this.addFullFeatures();
1654        },
1655        maybeCleanUpNew: function() {
1656            var feed = this,
1657                $cff = jQuery(this.el);
1658            setTimeout(function() {
1659                if  (feed.index > 0) {
1660                    $cff.find('.cff-new').removeClass('cff-new');
1661                }
1662                $cff.find('img').each(function() {
1663                    if (feed.settings.consentGiven && !jQuery(this).hasClass('cff-image-loading')
1664                    && ( jQuery(this).attr('src') != null && jQuery(this).attr('src') != undefined ) && jQuery(this).attr('src').indexOf('placeholder.png') > -1) {
1665                        console.log('lazy load correction');
1666                        var $self = jQuery(this),
1667                            currentSrc = $self.attr('src'),
1668                            originalSrc = $self.attr('data-orig-source');
1669
1670                        // Check if the img source has been changed by lazy loading
1671                        if(originalSrc != currentSrc){
1672                            $self.attr('src', originalSrc);
1673                        }
1674
1675                        // Timeline album posts need the background source reset
1676                        if($self.hasClass('cff-multi-image')){
1677                            $self.css('background-image', 'url(' + originalSrc + ')');
1678                        }
1679                    }
1680                });
1681            },1250);
1682        },
1683        checkConsent: function() {
1684            if (this.settings.consentGiven || !this.settings.gdpr) {
1685                return true;
1686            }
1687            if (typeof CLI_Cookie !== "undefined") { // GDPR Cookie Consent by WebToffee
1688                if (CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME) !== null)  {
1689
1690                    // WebToffee no longer uses this cookie but being left here to maintain backwards compatibility
1691                    if (CLI_Cookie.read('cookielawinfo-checkbox-non-necessary') !== 'null') {
1692                        this.settings.consentGiven = CLI_Cookie.read('cookielawinfo-checkbox-non-necessary') === 'yes';
1693                    }
1694
1695                    if (CLI_Cookie.read('cookielawinfo-checkbox-necessary') !== 'null') {
1696                        this.settings.consentGiven = CLI_Cookie.read('cookielawinfo-checkbox-necessary') === 'yes';
1697                    }
1698                }
1699
1700            } else if (typeof window.cnArgs !== "undefined") { // Cookie Notice by dFactory
1701                var value = "; " + document.cookie,
1702                    parts = value.split( '; cookie_notice_accepted=' );
1703
1704                if ( parts.length === 2 ) {
1705                    var val = parts.pop().split( ';' ).shift();
1706
1707                    this.settings.consentGiven = (val === 'true');
1708                }
1709            } else if (typeof window.cookieconsent !== 'undefined') { // Complianz by Really Simple Plugins
1710                this.settings.consentGiven = cffCmplzGetCookie('cmplz_consent_status') === 'allow';
1711            } else if (typeof window.Cookiebot !== "undefined") { // Cookiebot by Cybot A/S
1712                this.settings.consentGiven = Cookiebot.consented;
1713            } else if (typeof window.BorlabsCookie !== 'undefined') { // Borlabs Cookie by Borlabs
1714                this.settings.consentGiven = window.BorlabsCookie.checkCookieConsent('facebook');
1715            }
1716
1717            var evt = jQuery.Event('cffcheckconsent');
1718            evt.feed = this;
1719            jQuery(window).trigger(evt);
1720
1721            return this.settings.consentGiven; // GDPR not enabled
1722        },
1723        afterConsentToggled: function() {
1724            if (this.checkConsent()) {
1725                var feed = this;
1726                feed.maybeRaiseImageResolution();
1727                this.addFullFeatures();
1728                setTimeout(function() {
1729                    feed.afterResize();
1730                },500);
1731            }
1732        }
1733    };
1734
1735    function cffAjax(submitData, onSuccess) {
1736        jQuery.ajax({
1737            url: cffajaxurl,
1738            type: 'post',
1739            data: submitData,
1740            success: onSuccess
1741        });
1742    }
1743    function cffCmplzGetCookie(cname) {
1744        var name = cname + "="; //Create the cookie name variable with cookie name concatenate with = sign
1745        var cArr = window.document.cookie.split(';'); //Create cookie array by split the cookie by ';'
1746
1747        //Loop through the cookies and return the cookie value if it find the cookie name
1748        for (var i = 0; i < cArr.length; i++) {
1749            var c = cArr[i].trim();
1750            //If the name is the cookie string at position 0, we found the cookie and return the cookie value
1751            if (c.indexOf(name) == 0)
1752                return c.substring(name.length, c.length);
1753        }
1754
1755        return "";
1756    }
1757
1758    function cff_init( $cff ){
1759        //JS is running
1760        jQuery('.cff-nojs').removeClass('cff-nojs');
1761
1762        //Check whether it's a touch device
1763        var cffTouchDevice = false;
1764        if (cffIsTouchDevice() === true) cffTouchDevice = true;
1765        function cffIsTouchDevice() {
1766            return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
1767        }
1768
1769        //If a feed selector isn't passed in then default to using selector for all feeds
1770        var firsttime = false;
1771        if(typeof $cff === 'undefined'){
1772            $cff = jQuery('.cff');
1773            firsttime = true;
1774        }
1775
1776        (function($){
1777
1778            //Toggle comments
1779            jQuery(document).off('click', '#cff a.cff-view-comments').on('click', '#cff a.cff-view-comments', function(){
1780                var $self = jQuery(this),
1781                    $commentsBox = $self.closest('.cff-item').find('.cff-comments-box');
1782                $self.toggleClass('cff-open');
1783
1784                $commentsBox.slideToggle(300);
1785
1786                //Masonry - overlap comments box when open
1787                var $feed = $self.closest('#cff'),
1788                    $item = $(this).closest('.cff-item');
1789                if( $feed.hasClass('cff-masonry-js') && !$feed.hasClass('cff-opaque-comments') ){
1790                    setTimeout(function(){
1791                        cffAddMasonry($feed);
1792                    }, 500);
1793                }
1794
1795                //Add comment avatars
1796                $commentsBox.find('.cff-comment:visible').each(function(){
1797                    var $thisComment = jQuery(this); // here
1798                    var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
1799                    if (consentGiven) {
1800                        $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\'" />' );
1801                    }
1802                });
1803
1804            });
1805
1806            //Comments box hover
1807            var cffAnimateIconColorVar,
1808                stopAnimate = false;
1809            $cff.find('.cff-view-comments').on('mouseenter',  function(){
1810                var $self = $(this),
1811                    time = 50;
1812                if( $self.hasClass('cff-open') ) return;
1813
1814                $self.find('.cff-icon').each(function() {
1815                    var $cffIcon = jQuery(this);
1816                    cffAnimateIconColor($cffIcon, time);
1817                    time += 50;
1818                });
1819            }).on('mouseleave',  function(){
1820                cffStopAnimateIconColor();
1821                $(this).find('.cff-icon').removeClass('cff-animate');
1822            });
1823            function cffAnimateIconColor($cffIcon, time){
1824                stopAnimate = false;
1825                cffAnimateIconColorVar = setTimeout( function(){
1826                    if( !stopAnimate ) $cffIcon.addClass('cff-animate');
1827                }, time);
1828            }
1829            function cffStopAnimateIconColor() {
1830                clearTimeout(cffAnimateIconColorVar);
1831                stopAnimate = true;
1832            }
1833
1834            //Set paths for query.php
1835            if (typeof cffsiteurl === 'undefined' || cffsiteurl == '') cffsiteurl = window.location.host + '/wp-content/plugins';
1836            var locatefile = true;
1837
1838            //Create meta data array for caching likes and comments
1839            var metaArr = {},
1840                newMetaArr = {}, metaArray = []; //For caching only new posts that are loaded
1841
1842            //Loop through the feeds on the page and add a unique attribute to each to use for lightbox groups
1843            var lb = 0;
1844            jQuery('#cff.cff-lb').each(function(){
1845                lb++;
1846                $(this).attr('data-cff-lb', lb);
1847            });
1848
1849
1850            //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
1851            var $cff_post_selector = $cff.find('.cff-item.cff-new, .cff-album-item.cff-new');
1852            if( firsttime ){
1853                $cff_post_selector = jQuery('#cff .cff-item.cff-new, #cff .cff-album-item.cff-new');
1854            }
1855
1856            //Loop through each item
1857            $cff_post_selector.each(function(){
1858
1859                var $self = jQuery(this);
1860
1861                //Wpautop fix
1862                if( $self.find('.cff-viewpost-link, .cff-viewpost-facebook, .cff-viewpost').parent('p').length ){
1863                    //Don't unwrap event only viewpost link
1864                    if( !$self.hasClass('event') ) $self.find('.cff-viewpost-link, .cff-viewpost-facebook, .cff-viewpost').unwrap('p');
1865                }
1866                if( $self.find('.cff-photo').parent('p').length ){
1867                    $self.find('p .cff-photo').unwrap('p');
1868                    $self.find('.cff-album-icon').appendTo('.cff-photo:last');
1869                }
1870                if( $self.find('.cff-event-thumb').parent('p').length ){
1871                    $self.find('.cff-event-thumb').unwrap('p');
1872                }
1873                if( $self.find('.cff-vidLink').parent('p').length ){
1874                    $self.find('.cff-vidLink').unwrap('p');
1875                }
1876                if( $self.find('.cff-link').parent('p').length ){
1877                    $self.find('.cff-link').unwrap('p');
1878                }
1879                if( $self.find('.cff-viewpost-link').parent('p').length ){
1880                    $self.find('.cff-viewpost-link').unwrap('p');
1881                }
1882                if( $self.find('.cff-viewpost-facebook').parent('p').length ){
1883                    $self.find('.cff-viewpost-facebook').unwrap('p');
1884                }
1885
1886                if( $self.find('iframe').parent('p').length ){
1887                    $self.find('iframe').unwrap('p');
1888                }
1889                if( $self.find('.cff-author').parent('p').length ){
1890                    $self.find('.cff-author').eq(1).unwrap('p');
1891                    $self.find('.cff-author').eq(1).remove();
1892                }
1893                if( $self.find('.cff-view-comments').parent('p').length ){
1894                    $self.find('.cff-meta-wrap > p').remove();
1895                    $self.find('.cff-view-comments').eq(1).remove();
1896                    //Move meta ul inside the link element
1897                    var $cffMeta = $self.find('.cff-meta'),
1898                        cffMetaClasses = $cffMeta.attr('class');
1899                    $cffMeta.find('.cff-view-comments').unwrap().wrapInner('<ul class="'+cffMetaClasses+'">');
1900                }
1901                if( $self.find('.cff-photo').siblings('.cff-photo').length ){
1902                    $self.find('.cff-photo').slice(0,2).remove();
1903                }
1904                //Fix the formatting issue that pushes avatar to the left
1905                if( $('.cff-author-img').parent().is('p') ) $('.cff-author-img').unwrap('p');
1906                //Remove empty p tags
1907                $self.find('p:empty').not('.cff-comments-box p').remove();
1908
1909                //Expand post
1910                var expanded = false;
1911                if( $self.hasClass('cff-event') ){
1912                    var $post_text = $self.find('.cff-desc .cff-desc-text'),
1913                        text_limit = $post_text.parent().attr('data-char');
1914                } else {
1915                    var $post_text = $self.find('.cff-post-text .cff-text'),
1916                        text_limit = $self.closest('#cff').attr('data-char');
1917                }
1918
1919                if (typeof text_limit === 'undefined' || text_limit == '') text_limit = 99999;
1920
1921                //If the text is linked then use the text within the link
1922                if ( $post_text.find('a.cff-post-text-link').length ) $post_text = $self.find('.cff-post-text .cff-text a');
1923                var full_text = $post_text.html();
1924                if(full_text == undefined) full_text = '';
1925
1926
1927                //Truncate text taking HTML tags into account
1928                var cff_trunc_regx = new RegExp(/(<[^>]*>)/g);
1929                var cff_trunc_counter = 0;
1930
1931                //convert the string to array using the HTML tags as delimiter and keeping them as array elements
1932                full_text_arr = full_text.split(cff_trunc_regx);
1933
1934                for (var i = 0, len = full_text_arr.length; i < len; i++) {
1935                    //ignore the array elements that are HTML tags
1936                    if ( !(cff_trunc_regx.test(full_text_arr[i])) ) {
1937                        //if the counter is 100, remove this element with text
1938                        if (cff_trunc_counter == text_limit) {
1939                            full_text_arr.splice(i, 1);
1940                            continue; //ignore next commands and continue the for loop
1941                        }
1942                        //if the counter != 100, increase the counter with this element length
1943                        cff_trunc_counter = cff_trunc_counter + full_text_arr[i].length;
1944                        //if is over 100, slice the text of this element to match the total of 100 chars and set the counter to 100
1945                        if (cff_trunc_counter > text_limit) {
1946                            var diff = cff_trunc_counter - text_limit;
1947                            full_text_arr[i] = full_text_arr[i].slice(0, -diff);
1948                            cff_trunc_counter = text_limit;
1949
1950                            //Show the 'See More' link if needed
1951                            if (full_text.length > text_limit) $self.find('.cff-expand').show();
1952                        }
1953                    }
1954                }
1955
1956                //new string from the array
1957                var short_text = full_text_arr.join('');
1958
1959                //remove empty html tags from the array
1960                short_text = short_text.replace(/(<(?!\/)[^>]+>)+(<\/[^>]+>)/g, "");
1961
1962                //If the short text cuts off in the middle of a <br> tag then remove the stray '<' which is displayed
1963                var lastChar = short_text.substr(short_text.length - 1);
1964                if(lastChar == '<') short_text = short_text.substring(0, short_text.length - 1);
1965
1966                //Remove any <br> tags from the end of the short_text
1967                short_text = short_text.replace(/(<br>\s*)+$/,'');
1968                short_text = short_text.replace(/(<img class="cff-linebreak">\s*)+$/,'');
1969
1970                //Cut the text based on limits set
1971                $post_text.html( short_text );
1972
1973
1974                //Click function
1975                $self.find('.cff-expand a').off('click').on('click', function(e){
1976                    e.preventDefault();
1977                    var $expand = jQuery(this),
1978                        $more = $expand.find('.cff-more'),
1979                        $less = $expand.find('.cff-less');
1980                    if (expanded == false){
1981                        $post_text.html( full_text );
1982                        expanded = true;
1983                        $more.hide();
1984                        $less.show();
1985                    } else {
1986                        $post_text.html( short_text );
1987                        expanded = false;
1988                        $more.show();
1989                        $less.hide();
1990                    }
1991                    cffLinkHashtags();
1992                    //Add target to links in text when expanded
1993                    $post_text.find('a').attr('target', '_blank');
1994
1995                    //Re-init masonry for JS
1996                    if( $self.closest('.cff').hasClass('cff-masonry-js') && !$self.closest('.cff').hasClass('cff-masonry-css') ){
1997                        cffAddMasonry($cff);
1998                    }
1999
2000                });
2001                //Add target attr to post text links via JS so aren't included in char count
2002                $post_text.find('a').add( $self.find('.cff-post-desc a') ).attr({
2003                    'target' : '_blank',
2004                    'rel' : 'nofollow noopener noreferrer'
2005                });
2006
2007
2008                //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
2009                var post_id = $self.attr('id').substring(4),
2010                    //This is the original post ID which is used to get the number of likes and comments for the timeline post
2011                    post_id_orig = $self.find('.cff-view-comments').attr('id');
2012
2013                if( locatefile != true ) $self.find('.cff-lightbox-thumbs-holder').css('min-height', 0);
2014
2015
2016                //Show all comments on click
2017                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(){
2018
2019                    var $cffMoreCommentsLink = jQuery(this),
2020                        thisCommentsTotal = parseInt($cffMoreCommentsLink.attr('data-cff-comments-total'));
2021
2022                    //If there's more than 25 comments then link the "View more comments" link to post on Facebook
2023                    if( $cffMoreCommentsLink.hasClass('cff-clicked') && thisCommentsTotal > 25 ){
2024                        //Link to Facebook
2025                        $cffMoreCommentsLink.find('a').attr({
2026                            'href' : $cffMoreCommentsLink.closest('.cff-comments-box').find('.cff-comment-on-facebook a').attr('href'),
2027                            'target' : '_blank'
2028                        });
2029                    }
2030                    //Hide 'View more comments' link
2031                    if( thisCommentsTotal <= 25 ) $cffMoreCommentsLink.hide();
2032
2033                    //Add class so we can only trigger the above on the second click
2034                    $cffMoreCommentsLink.addClass('cff-clicked');
2035
2036                    //Show comments and add comment avatars
2037                    $cffMoreCommentsLink.parent().find('.cff-comment').show().each(function(){
2038                        var $thisComment = jQuery(this);
2039                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
2040                        if (consentGiven) {
2041                            $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\'" />' );
2042                        }
2043
2044                    });
2045
2046                    //Re-init masonry when more comments loaded
2047                    var $closestCff = $cffMoreCommentsLink.closest('.cff');
2048                    if( $closestCff.hasClass('cff-masonry-js') && !$closestCff.hasClass('cff-opaque-comments') ){
2049                        setTimeout(function(){
2050                            cffAddMasonry( $closestCff );
2051                        }, 500);
2052                    }
2053                });
2054
2055
2056                //Remove event end date day if the same as the start date
2057                if( $self.hasClass('cff-timeline-event') || $self.hasClass('cff-event') ){
2058                    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();
2059                }
2060
2061
2062                //Replace Photon (Jetpack CDN) images with the originals again
2063                var $cffPhotoImg = $self.find('.cff-photo img, .cff-event-thumb img, .cff-poster, .cff-album-cover img'),
2064                    cffPhotoImgSrc = $cffPhotoImg.attr('src'),
2065                    cffImgStringAttr = $cffPhotoImg.attr('data-querystring');
2066
2067                if( typeof cffPhotoImgSrc == 'undefined' ) cffPhotoImgSrc = '';
2068
2069                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 ){
2070
2071                    //Create new src. Single slash in https is intentional as one is left over from removing i_.wp.com
2072                    var photonSrc = $cffPhotoImg.attr('src').substring(0, $cffPhotoImg.attr('src').indexOf('?')),
2073                        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;
2074
2075                    $cffPhotoImg.attr('src', newSrc);
2076                }
2077
2078                function cffLinkHashtags(){
2079                    //Link hashtags
2080                    var cffTextStr = $self.find('.cff-text').html(),
2081                        cffDescStr = $self.find('.cff-post-desc').html(),
2082                        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
2082D3-\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,
2083                        linkcolor = $self.find('.cff-text').attr('data-color'),
2084                        linkcolorHTML = '';
2085
2086                    function replacer(hash){
2087                        //Remove white space at beginning of hash
2088                        var replacementString = jQuery.trim(hash);
2089                        //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"
2090                        if ( /^#[0-9A-F]{6}$/i.test( replacementString ) ){
2091                            return replacementString;
2092                        } else {
2093                            if( typeof linkcolor !== 'undefined' ){
2094                                if( linkcolor.length > 1 ) linkcolorHTML = 'style="color:#' + linkcolor + '"';
2095                            }
2096                            return ' <a href="https://www.facebook.com/hashtag/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener" '+linkcolorHTML+'>' + replacementString + '</a>';
2097                        }
2098                    }
2099
2100                    //If it's not defined in the source code then set it to be true
2101                    if (typeof cfflinkhashtags == 'undefined') cfflinkhashtags = 'true';
2102
2103                    if(cfflinkhashtags == 'true'){
2104                        //Replace hashtags in text
2105                        var $cffText = $self.find('.cff-text');
2106
2107                        if($cffText.length > 0){
2108                            //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.
2109                            cffTextStr = cffTextStr.replace(/<br>/g, "<br> ");
2110                            $cffText.html( cffTextStr.replace( regex , replacer ) );
2111                        }
2112                    }
2113
2114                    //Replace hashtags in desc
2115                    if( $self.find('.cff-post-desc').length > 0 ) $self.find('.cff-post-desc').html( cffDescStr.replace( regex , replacer ) );
2116                }
2117                cffLinkHashtags();
2118
2119                //Add target attr to post text links via JS so aren't included in char count
2120                $self.find('.cff-text a').attr('target', '_blank');
2121
2122
2123                //Add lightbox tile link to photos
2124                if( $self.closest('#cff').hasClass('cff-lb') ){
2125                    $self.find('.cff-photo, .cff-album-cover, .cff-event-thumb, .cff-html5-video, .cff-iframe-wrap').each(function(){
2126                        var $photo = $(this),
2127                            postId = post_id,
2128                            cffLightboxTitle = '',
2129                            cffShowThumbs = false,
2130                            postType = '',
2131                            cffgroupalbums = '';
2132
2133
2134                        // if( $self.hasClass('cff-album') || $self.hasClass('cff-albums-only') ) cffShowThumbs = true;
2135                        cffShowThumbs = true;
2136
2137                        function cffFormatCaption(text){
2138                            return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
2139                        }
2140
2141                        //Set the caption/title
2142                        if( $self.hasClass('cff-albums-only') ){
2143                            postType = 'albumsonly';
2144                            cffLightboxTitle = cffFormatCaption( $self.find('img').attr('alt') );
2145
2146                            //Check whether there's an absolute path attr and if there is then add it to the query
2147                            var dataGroup = $self.closest('#cff').attr('data-group');
2148                            if( typeof dataGroup !== 'undefined' ) cffgroupalbums = 'data-cffgroupalbums="true"';
2149
2150                        } else if( $self.hasClass('cff-timeline-event') ) {
2151                            var capText = '';
2152                            if( $self.find('.cff-author-text .cff-page-name').length ) capText += $self.find('.cff-author-text .cff-page-name').text() + '<br /><br />';
2153                            //Display the full event details but the info is hidden in CSS as it's too long in some cases
2154                            if( full_text.length > 5 ) capText += full_text;
2155                            cffLightboxTitle = cffFormatCaption( capText );
2156
2157                        } else if ( $self.hasClass('cff-event') ) {
2158                            //Events feed
2159                            if( $self.find('.cff-details').length ){
2160                                // if( $self.find('.cff-event-title').length ) cffLightboxTitle = cffFormatCaption( $self.find('.cff-event-title')[0].outerHTML );
2161                                // if( $self.find('.cff-date').length ) cffLightboxTitle += cffFormatCaption( $self.find('.cff-date')[0].outerHTML );
2162                                // if( $self.find('.cff-location').length ) cffLightboxTitle += cffFormatCaption( $self.find('.cff-location')[0].outerHTML );
2163
2164                                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>' );
2165                                if( $self.find('.cff-date').length ) cffLightboxTitle += '<span class="cff-date">' + cffFormatCaption( $self.find('.cff-date').html() + '</span>' );
2166                                if( $self.find('.cff-location').length ) cffLightboxTitle += '<span class="cff-location">' + cffFormatCaption( $self.find('.cff-location').html() + '</span>' );
2167
2168                                cffLightboxTitle += '<span class="cff-desc">' + full_text + '</span>';
2169                            }
2170
2171                        } else if( $self.hasClass('cff-album-item') ) {
2172                            cffLightboxTitle = cffFormatCaption( $self.find('img').attr('alt') );
2173                        } else {
2174                            var lb_title = full_text;
2175                            //If there's no post text then use the description
2176                            if( full_text.trim() == '' ) lb_title = $self.find('.cff-post-desc').text();
2177
2178                            //If there's no post text or desc then use the story
2179                            if( lb_title == '' && $self.find('.cff-author .cff-story').length ) lb_title = $self.find('.cff-author .cff-page-name').text();
2180
2181                            //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
2182                            if( lb_title == '' ) lb_title = '&nbsp;';
2183
2184                            cffLightboxTitle = cffFormatCaption( lb_title );
2185                        }
2186
2187                        if(cffLightboxTitle.length > 1) cffLightboxTitle = cffLightboxTitle.replace(/"/g, '&quot;');
2188
2189
2190                        //Create the lightbox link
2191                        //Add the hover tile
2192                        var cffLightboxTile = '<a class="cff-lightbox-link nofancybox" rel="nofollow" ';
2193
2194                        //If it's a YouTube or Vimeo then set the poster image to use in the lightbox
2195                        if( $photo.hasClass('cff-iframe-wrap') ){
2196                            //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:
2197                            var iframeSrc = '';
2198                            if ($photo.find('iframe').length) {
2199                                iframeSrc = $photo.find('iframe').attr('src');
2200                            } if ($photo.find('.cff-iframe-placeholder').length ) {
2201                                iframeSrc = $photo.find('.cff-iframe-placeholder').attr('data-src');
2202                            }
2203                            cffLightboxTile += 'href="'+cffsiteurl+'/custom-facebook-feed-pro/assets/img/video-lightbox.png?'+postId+'" data-iframe="'+iframeSrc+'" ';
2204                            //If it's a swf then display it in an iframe
2205                        } else if( $photo.hasClass('cff-swf') ) {
2206                            cffLightboxTile += 'href="'+cffsiteurl+'/custom-facebook-feed-pro/assets/img/video-lightbox.png" data-iframe="'+$photo.find('video').attr('src')+'" ';
2207                        } else {
2208                            var lb_href = $photo.find('img').attr('src').indexOf('placeholder') === -1 ? $photo.find('img').attr('src') : $photo.find('img').attr('data-orig-source');
2209                            if( $photo.find('img').attr('data-cff-no-event-img-large') ) lb_href = $photo.find('img').attr('data-cff-no-event-img-large');
2210                            if( $photo.find('img').attr('data-cff-full-img') ) lb_href = $photo.find('img').attr('data-cff-full-img');
2211                            cffLightboxTile += 'href="'+lb_href+'" data-iframe="" ';
2212                        }
2213                        //No nav
2214                        // cffLightboxTile += 'data-cff-lightbox="'+postId+'" data-title="'+cffLightboxTitle+'" data-id="'+postId+'" data-thumbs="'+cffShowThumbs+'" ';
2215                        cffLightboxTile += 'data-cff-lightbox="cff-lightbox-'+$self.closest("#cff").attr("data-cff-lb")+'" data-title="'+cffLightboxTitle+'" data-id="'+postId+'" data-thumbs="'+cffShowThumbs+'" '+cffgroupalbums+' ';
2216
2217                        //If it's an HTML5 video then set the data-video attr
2218                        if( $photo.hasClass('cff-html5-video') ){
2219
2220                            if($photo.hasClass('cff-swf')){
2221                                cffLightboxTile += 'data-url="'+$photo.find('.cff-html5-play').attr('href')+'" data-video="';
2222                            } else {
2223                                cffLightboxTile += 'data-url="'+$photo.find('.cff-html5-play').attr('href')+'" data-video="'+$photo.find('img').attr('data-cff-video');
2224                            }
2225
2226                            //Videos only:
2227                        } else if( $photo.hasClass('cff-video') ) {
2228                            cffLightboxTile += 'data-url="http://facebook.com/'+$photo.attr('id')+'" data-video="'+$photo.attr('data-source');
2229                        } else if( $photo.hasClass('cff-iframe-wrap') ) {
2230                            cffLightboxTile += 'data-url="http://facebook.com/'+post_id+'" data-video="';
2231                        } else {
2232                            cffLightboxTile += 'data-url="'+$photo.attr('href')+'" data-video="';
2233                        }
2234
2235                        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>';
2236
2237                        //Add the link to the photos/videos in the feed
2238                        $photo.prepend(cffLightboxTile);
2239
2240                        if( !cffTouchDevice ){ //Only apply hover effect if not touch screen device
2241                            //Fade in links on hover
2242                            $photo.on('mouseenter', function(){
2243                                $self.find('.cff-photo-hover').fadeIn(150);
2244                            }).on('mouseleave', function(){
2245                                $self.find('.cff-photo-hover').stop().fadeOut(500);
2246                            });
2247                        }
2248
2249                    });
2250                }
2251
2252                //Share tooltip function
2253                $self.find('.cff-share-link').off('click').on('click', function(e){
2254                    e.preventDefault();
2255                    var $cffShareTooltip = $self.find('.cff-share-tooltip')
2256
2257                    //Hide tooltip
2258                    if( $cffShareTooltip.is(':visible') ){
2259                        $cffShareTooltip.hide().find('a').removeClass('cff-show');
2260                    } else {
2261                        //Show tooltip
2262                        $cffShareTooltip.show();
2263
2264                        var time = 0;
2265                        $cffShareTooltip.find('a').each(function() {
2266                            var $cffShareIcon = jQuery(this);
2267                            setTimeout( function(){
2268                                $cffShareIcon.addClass('cff-show');
2269                            }, time);
2270                            time += 20;
2271                        });
2272                    }
2273                });
2274
2275                //If it's a restricted page then use the lightbox src for the photo feed images
2276                if( typeof $cff.attr('data-restricted') !== 'undefined' ){
2277                    var cff_restricted_page = true;
2278                } else {
2279                    var cff_restricted_page = false;
2280                }
2281
2282                //Photos only
2283                if( $self.hasClass('cff-album-item') ){
2284                    var cff_data_full_size = $self.attr('data-cff-full-size');
2285
2286                    if( typeof cff_data_full_size !== 'undefined' && cff_data_full_size != '' ){
2287
2288                        if( cff_restricted_page ){
2289                            $self.find('.cff-lightbox-link').attr('href', cff_data_full_size).closest('.cff-album-cover').css('background-image', 'url('+cff_data_full_size+')');
2290                            $self.find('img').attr('src', cff_data_full_size);
2291                        } else {
2292                            $self.find('.cff-lightbox-link').attr('href', cff_data_full_size);
2293                        }
2294
2295                    }
2296                }
2297
2298
2299                //Add the HD video player
2300                //If it's a video post then add the video link to the video element so it can be used in the lightbox
2301                if( ( $self.find('.cff-html5-video').length || $self.hasClass('cff-video') ) ){
2302
2303                    var cff_live_video = false;
2304
2305                    //Set the selector based on whether it's a timeline vid or videos only
2306                    if( $self.find('.cff-html5-video').length ){
2307                        var $vid_sel = $self.find('.cff-html5-video');
2308                        if( $vid_sel.attr('data-cff-live') == 'true' ) cff_live_video = true;
2309                    }
2310                    if( $self.hasClass('cff-video') ) var $vid_sel = $self;
2311
2312                    if( cff_live_video && $(window).width() <= 640 ){
2313                        //If it's live video and on mobile then use HTMl5 player as live video doesn't work on mobile using Facebook player
2314                    } else {
2315
2316                        if( !$self.closest('.cff').hasClass('cff-private-group') ){
2317                            //If the Facebook Player is selected then pass the iframe URL into the lightbox.
2318                            if( $vid_sel.attr('data-cff-video-player') != 'standard' ){
2319                                $self.find('.cff-lightbox-link').attr({
2320                                    'data-iframe' : 'https://www.facebook.com/v2.3/plugins/video.php?href=' + $vid_sel.attr('data-cff-video-link'),
2321                                    'data-video' : ''
2322                                });
2323                            }
2324                        }
2325
2326                    }
2327
2328                }
2329
2330                //Try to fix any video wrapper formatting issues
2331                setTimeout(function(){
2332                    $self.find('.cff-iframe-wrap .fluid-width-video-wrapper iframe').unwrap().wrap('<div style="float: left; width: 100%;"></div>');
2333                    $self.find('.cff-iframe-wrap .iframe-embed iframe').unwrap('iframe-embed');
2334                }, 500);
2335
2336
2337                //Open lightbox when clicking album or video title
2338                $self.find('.cff-album-info a').on('click', function(e){
2339                    e.preventDefault();
2340                    $self.find('.cff-lightbox-link').trigger('click');
2341                });
2342
2343
2344            }); //End $cff_post_selector.each loop
2345
2346
2347            //Load comment replies
2348            jQuery(document).off('click', '.cff-comment-replies a').on('click', '.cff-comment-replies a', function(){
2349                cffLoadCommentReplies( $(this) );
2350            });
2351
2352
2353            $('.cff-wrapper').each(function(){
2354                var $cff = $(this).find('#cff'),
2355                    cff_grid_pag = $cff.attr('data-grid-pag');
2356
2357                //Get the Access Token from the shortcode so it can be used in the connect file
2358                var shortcode_token_param = cffGetShortcodeToken($cff);
2359
2360                var $cffNumDiffHide = $(this).find('.cff');
2361                //maybe hide
2362                if (typeof $cffNumDiffHide.attr('data-nummobile') !== 'undefined') {
2363                    var num = typeof $cffNumDiffHide.attr('data-pag-num') !== 'undefined' && $cffNumDiffHide.attr('data-pag-num') !== '' ? parseInt($cffNumDiffHide.attr('data-pag-num')) : 1,
2364                        nummobile = typeof $cffNumDiffHide.attr('data-nummobile') !== 'undefined' && $cffNumDiffHide.attr('data-nummobile') !== '' ? parseInt($cffNumDiffHide.attr('data-nummobile')) : num,
2365                        itemSelector = $cffNumDiffHide.find('.cff-item').length ? '.cff-item' : '.cff-album-item';
2366                    if ($(window).width() < 480) {
2367                        if (nummobile < $cffNumDiffHide.find(itemSelector).length) {
2368                            $cffNumDiffHide.find(itemSelector).slice(nummobile - $cffNumDiffHide.find(itemSelector).length).addClass('cff-num-diff-hide');
2369                        }
2370                    } else {
2371                        if (num < $cffNumDiffHide.find(itemSelector).length) {
2372                            $cffNumDiffHide.find(itemSelector).slice(num - $cffNumDiffHide.find(itemSelector).length).addClass('cff-num-diff-hide');
2373                        }
2374                    }
2375                    $cffNumDiffHide.removeAttr('data-nummobile');
2376                }
2377
2378                //Masonry
2379                if( $cff.hasClass('cff-masonry-js' && ! $cff.hasClass('cff-all-reviews') ) ){
2380
2381                    if( $cff.find('.cff-album-item').length && ! $cff.hasClass('cff-masonry')){
2382                        $cff.removeClass('cff-masonry-js');
2383                        return;
2384                    }
2385
2386                    cffAddMasonry($cff);
2387                    //Call it again in case images aren't fully loaded
2388                    setTimeout(function(){ cffAddMasonry($cff); }, 1000);
2389
2390                    // Resizing the window can affect the masonry feed so it is reset on resize
2391                    $(window).on('resize', function () {
2392                        setTimeout(function(){
2393                            cffAddMasonry($cff);
2394                        }, 500);
2395                    });
2396
2397                    if( $cff.find('.cff-credit').length ) $cff.css('padding-bottom', 30);
2398                }
2399
2400                //Allow us to make some tweaks when the feed is narrow
2401                function cffCheckWidth(){
2402
2403                    if( $cff.hasClass('cff-album-items-feed') ){
2404                        var $cffElement = $cff;
2405                    } else {
2406                        var $cffElement = $cff.find('.cff-item').first();
2407                    }
2408
2409                    if( $cffElement.innerWidth() < 400 ){
2410                        if( !$cff.hasClass('cff-disable-narrow') ){
2411                            $cff.addClass('narrow');
2412                        }
2413                    } else {
2414                        $cff.removeClass('narrow');
2415                    }
2416                    if( $cffElement.innerWidth() < 250 ){
2417                        $cff.addClass('cff-super-narrow');
2418                    }
2419                }
2420                cffCheckWidth();
2421
2422                function cffActionLinksPos(){
2423                    if( $cff.find('.cff-item').first().innerWidth() < (190 + $('.cff-post-links').innerWidth() ) ){
2424                        $cff.find('.cff-post-links').addClass('cff-left')
2425                    } else {
2426                        $cff.find('.cff-post-links').removeClass('cff-left');
2427                    }
2428                }
2429                cffActionLinksPos();
2430
2431                //Only check the width once the resize event is over
2432                var cffdelay = (function(){
2433                    var cfftimer = 0;
2434                    return function(cffcallback, cffms){
2435                        clearTimeout (cfftimer);
2436                        cfftimer = setTimeout(cffcallback, cffms);
2437                    };
2438                })();
2439                window.addEventListener('resize', function(event){
2440                    cffdelay(function(){
2441                        cffCheckWidth();
2442                        cffActionLinksPos();
2443                        cffResizeAlbum();
2444                    }, 500);
2445                });
2446
2447                //Albums only
2448                //Resize image height
2449                function cffResizeAlbum(last){
2450                  if ( $cff.hasClass('cff-masonry') || $cff.hasClass('cff-disable-liquid')) {
2451                    return;
2452                  }
2453                    var cffAlbumWidth = $cff.find('.cff-album-item').eq(0).find('a').innerWidth();
2454
2455                    $cff.find('.cff-album-item a').css('height', cffAlbumWidth);
2456                    //Crops event images when selected
2457                    $cff.find('.cff-photo.cff-crop').css( 'height', $cff.find('.cff-photo.cff-crop').width() );
2458
2459                    //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
2460                    $cff.find('.cff-item.cff-album .cff-photo.cff-multiple, .cff-video-post .cff-html5-video.cff-multiple').each(function(){
2461                        var $cffPhotoEl = $(this);
2462
2463                        //Crop image attachments in posts
2464                        var cffPhotoImgWidth = $cffPhotoEl.find('img').first().width();
2465                        if( cffPhotoImgWidth < 10 ) cffPhotoImgWidth = 300;
2466
2467                        if($cffPhotoEl.hasClass('cff-img-layout-3')) $cffPhotoEl.find('.cff-img-attachments .cff-crop').css( 'height', cffPhotoImgWidth/2 );
2468                        if($cffPhotoEl.hasClass('cff-img-layout-4')) $cffPhotoEl.find('.cff-img-attachments .cff-crop').css( 'height', cffPhotoImgWidth/3 );
2469
2470                        //Crop main image
2471                        if( $cffPhotoEl.is('.cff-img-layout-3, .cff-img-layout-4') ){
2472                            var $cffMainImage = $cffPhotoEl.find('.cff-main-image'),
2473                                cropPercentage = 0.6;
2474                            if( $cffPhotoEl.hasClass('cff-img-layout-4') ) cropPercentage = 0.8;
2475
2476                            //Set the height based on ratio
2477                            var cffImageHeight = Math.round( cffPhotoImgWidth / $cffMainImage.find('img').attr('data-ratio') );
2478                            $cffMainImage.css( 'height', Math.round( Math.max(cffImageHeight*cropPercentage, $cffPhotoEl.find('.cff-img-attachments').height() ) ) );
2479                        } else if( $cffPhotoEl.is('.cff-img-layout-2') ) {
2480                            var $cffCrop = $cffPhotoEl.find('.cff-img-wrap.cff-crop');
2481                            if( $cffPhotoEl.hasClass('cff-portrait') ){
2482                                $cffPhotoEl.find('.cff-img-wrap.cff-crop').css('height', $cffPhotoEl.width()*0.8 );
2483                            } else {
2484                                $cffPhotoEl.find('.cff-img-wrap.cff-crop').css('height', $cffPhotoEl.width()/2 );
2485                            }
2486                        }
2487
2488                        //If the main image is being cropped to zero then remove the crop so the full image is shown
2489                        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({
2490                            'display' : 'block',
2491                            'visibility' : 'visible'
2492                        })
2493
2494                        //Make "+6" text small if the images are small
2495                        if( cffPhotoImgWidth < 200 ){
2496                            $cffPhotoEl.addClass('cff-small-layout');
2497                        } else {
2498                            $cffPhotoEl.removeClass('cff-small-layout');
2499                        }
2500                    });
2501
2502                }
2503                cffResizeAlbum(false);
2504                setTimeout(function(){ cffResizeAlbum(false); }, 50);
2505                setTimeout(function(){ cffResizeAlbum(true); }, 500);
2506                setTimeout(function(){ cffResizeAlbum(true); }, 1500);
2507
2508
2509                //PAGINATION
2510                //Events JS pagination
2511                var num_events = parseInt( $cff.attr('data-pag-num') ),
2512                    show_events = num_events, //Iterated for each set
2513                    cff_total_events = $cff.find('.cff-event').length,
2514                    cff_visible_events = $('.cff-event:visible' ).length;                    
2515
2516                    //Show first set of events
2517                    $cff.find('.cff-event').slice(0, num_events).css('display', 'inline-block');
2518                    
2519                    if ( cff_total_events > num_events ) {
2520                        $('.cff-no-more-posts').replaceWith(function () {
2521                            return $("<a href='javascript:void(0)' class='cff-load-more' />").append($(this).contents()).html('Load More');
2522                        })
2523                        $('.cff').on('click', '.cff-load-more', function(){                  
2524                            cff_visible_events = $(".cff-event:visible").length;
2525                            if ( cff_visible_events + 2 < cff_total_events ) {                        
2526                                $cff.find('.cff-event').slice(0, num_events + $(".cff-event:visible").length).css('display', 'inline-block');                   
2527                            } else {
2528                                $('.cff-load-more').replaceWith(function () {
2529                                    return $('<p class="cff-no-more-posts">No more posts</p>');
2530                                });
2531                            }
2532                        });
2533                    }
2534
2535                //cffResizeAlbum(); //Correctly recalcs height of event images when using eventimage=cropped
2536
2537                //Review JS pagination
2538                if( $cff.hasClass('cff-all-reviews') ){
2539                    var num_reviews = parseInt( $cff.attr('data-pag-num') ),
2540                        show_reviews = num_reviews;
2541
2542                    //Offset
2543                    var review_offset = parseInt($cff.attr('data-offset'));
2544                    if( typeof review_offset == 'undefined' || isNaN(review_offset) ) review_offset = 0;
2545
2546                    //Only show the required number of reviews
2547                    $cff.find('.cff-review').slice(0, num_reviews + review_offset ).css('display', 'inline-block');
2548
2549                    //Hide some reviews if using offset setting
2550                    if( review_offset > 0 ) $cff.find('.cff-review').slice(0, review_offset ).remove();
2551
2552                    //If using masonry then run it here
2553                    if( $cff.hasClass('cff-masonry-js') ) {
2554
2555                        cffAddMasonry($cff);
2556                        //Call it again in case images aren't fully loaded
2557                        setTimeout(function(){ cffAddMasonry($cff); }, 1000);
2558
2559                        // Resizing the window can affect the masonry feed so it is reset on resize
2560                        $(window).on('resize', function () {
2561                            setTimeout(function(){
2562                                cffAddMasonry($cff);
2563                            }, 500);
2564                        });
2565
2566                        if( $cff.find('.cff-credit').length ) $cff.css('padding-bottom', 30);
2567                    }
2568
2569                }
2570
2571                //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
2572                var $cffLoadMore = $cff.find('#cff-load-more'),
2573                    cff_no_posts_added = $cff.find('.cff-load-more').attr('data-cff-no-posts-added');
2574                if (typeof cff_no_posts_added == typeof undefined || cff_no_posts_added == false) {
2575                    $cffLoadMore.attr('data-cff-no-posts-added', 'false');
2576                }
2577
2578                //If there's no posts in the feed initially then set the data-attr to be true
2579                if( $cff.find('.cff-item, .cff-album-item').length < 1 ) $cffLoadMore.attr('data-cff-no-posts-added', 'true');
2580
2581                // add the load more button and input to simulate a dynamic json file call
2582                $cffLoadMore.off().on('click', function() {
2583                    // reveal any hidden posts due to difference in desktop vs mobile devices
2584                    // read the json that is in the cff-data-shortcode that contains all of the shortcode arguments
2585                    var shortcodeData = $cff.attr('data-cff-shortcode'),
2586                        $paginationURL = $cff.find('.cff-pag-url'),
2587                        pag_url = $paginationURL.attr('data-cff-pag-url'),
2588                        feed_id = $paginationURL.attr('data-transient-name'),
2589                        post_id = $paginationURL.attr('data-post-id'),
2590                        location = CFFLocationGuess($cff);
2591                    //Upmcoming events JS pagination
2592                    var events_count = $cff.find('.cff-upcoming-event').length;
2593                    //If it's an event feed
2594                    if( events_count > 0 ){
2595                        show_events = show_events + num_events;
2596                        //Show the next set of events
2597                        $cff.find('.cff-upcoming-event').slice(0, show_events).css('display', 'inline-block');
2598                        if( show_events > events_count ){
2599                            $cff.find('#cff-load-more').hide();
2600                            cff_no_more_posts($cff, $cffLoadMore);
2601                        }
2602
2603                        //Re-init masonry for JS
2604                        if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
2605                            cffAddMasonry($cff);
2606                        }
2607                        return;
2608                    }
2609
2610                    //Reviews JS pagination
2611                    if( $cff.hasClass('cff-all-reviews') ){
2612                        var reviews_count = $cff.find('.cff-review').length;
2613                        //If it's an reviews feed
2614                        if( reviews_count > 0 ){
2615                            show_reviews = show_reviews + num_reviews;
2616                            //Show the next set of reviews
2617                            $cff.find('.cff-review').slice(0, show_reviews).css('display', 'inline-block');
2618                            if( show_reviews > reviews_count ){
2619                                $cff.find('#cff-load-more').hide();
2620                                cff_no_more_posts($cff, $cffLoadMore);
2621                            }
2622
2623                            //Re-init masonry for JS
2624                            if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
2625                                cffAddMasonry($cff);
2626                            }
2627                            return;
2628                        }
2629                    }
2630
2631
2632                    //Remove the ID so it can't be clicked twice before the posts are loaded
2633                    $cffLoadMore.off().removeAttr('id').addClass('cff-disabled');
2634
2635                    // remove the hidden field since it will be replaced with new before token and after token next url data
2636                    $paginationURL.remove();
2637
2638
2639                    //If it's a photo/vid/album feed then change the selector
2640                    if( $cff.hasClass('cff-album-items-feed') ){
2641                        var item_sel = '.cff-album-item';
2642                    } else {
2643                        var item_sel = '.cff-item';
2644                    }
2645
2646                    if( item_sel == '.cff-album-item' ){
2647                        //If the next_url is empty then use the prev_url
2648                        if( (pag_url == '' || pag_url == '{}') ) pag_url = $paginationURL.attr('data-cff-prev-url');
2649
2650                        //Loop through the previous URLs and if the next URL is empty for an ID then add it in
2651                        var prev_urls = $paginationURL.attr('data-cff-prev-url');
2652
2653                        //Convert the JSON string into an object so we can loop through it
2654                        var prev_urls_arr = ( typeof prev_urls == 'undefined' ) ? '' : JSON.parse( prev_urls );
2655                    }
2656
2657                    //Parse the urls string into an array so we can loop through it
2658                    var pag_url_arr = ( typeof pag_url == 'undefined' ) ? '' : JSON.parse( pag_url );
2659
2660                    if( item_sel == '.cff-album-item' ){
2661                        //Add the URL to the next_urls if it doesn't exist in the array
2662                        for (var key in prev_urls_arr) {
2663                            if (prev_urls_arr.hasOwnProperty(key)) {
2664                                if( typeof pag_url_arr[key] == 'undefined' ) pag_url_arr[key] = prev_urls_arr[key];
2665                            }
2666                        }
2667                    }
2668                    if( (pag_url == '' || pag_url == '{}' || pag_url == 0 || pag_url == '0' ) && item_sel == '.cff-item' ){
2669                        $cffLoadMore.hide();
2670                        cff_no_more_posts($cff, $cffLoadMore);
2671                    } else {
2672                        //Display loader
2673                        $cffLoadMore.addClass('cff-loading').append('<div class="cff-loader"></div>');
2674                        $cffLoadMore.find('.cff-loader').css('background-color', $cffLoadMore.css('color'));
2675                    }
2676
2677
2678                    //Check which pagination method to use
2679                    var cff_timeline_api_paging = false;
2680                    if( $cff.attr('data-timeline-pag') ) cff_timeline_api_paging = true;
2681
2682                    if( cff_timeline_api_paging == true ){
2683                        //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.
2684                    } else {
2685                        //Loop through the pag array. Replace the until params for each id. Stringify to send in the ajax request
2686                        for (var key in pag_url_arr) {
2687                            if (pag_url_arr.hasOwnProperty(key) && key != 'latest_record_date') {
2688
2689                                var this_url = pag_url_arr[key],
2690                                    until_old = cffGetParameterByName('until', this_url),
2691                                    $last_item = $cff.find(item_sel+'.cff-' + key).last(),
2692                                    until_new = (parseInt( $last_item.attr('data-cff-timestamp') ) - 1).toString(),
2693                                    backdated_new = false;
2694
2695                                //If the post is backdated then use that instead as the API orders posts by backdate
2696                                if( typeof $last_item.attr('data-cff-backdated') != 'undefined' ){
2697                                    until_new = (parseInt( $last_item.attr('data-cff-backdated') ) - 1).toString();
2698                                }
2699
2700                                //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
2701                                if( isNaN(parseFloat(until_new)) ){
2702                                    $last_item = $cff.find(item_sel).last();
2703                                    until_new = (parseInt( $last_item.attr('data-cff-timestamp') ) - 1).toString();
2704
2705                                    //If the post is backdated then use that instead as the API orders posts by backdate
2706                                    if( typeof $last_item.attr('data-cff-backdated') != 'undefined' ){
2707                                        until_new = (parseInt( $last_item.attr('data-cff-backdated') ) - 1).toString();
2708                                    }
2709                                }
2710
2711                                var new_url = this_url;
2712
2713                                if( $cffLoadMore.attr('data-cff-no-posts-added') == 'true' ){
2714                                    //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
2715                                } else {
2716                                    //If it's a regular timeline feed then add the "until" param
2717                                    if( item_sel !== '.cff-album-item' ){
2718
2719                                        //V2.9+ of the API don't include "until" in the next url so only replace it if it exists
2720                                        if( this_url.indexOf("until=") !== -1 ){
2721                                            //Replace old until value with new one in the URL
2722                                            var new_url = this_url.replace("until="+until_old,"until="+until_new);
2723                                        } else {
2724                                            //If "until" doesn't exist then add it to the end of the URL
2725                                            var new_url = this_url + "&until="+until_new;
2726                                        }
2727
2728                                        //Remove the "after" param as it overrides the "until" param
2729                                        if( new_url.indexOf('&after=') > -1 ) new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
2730
2731                                    }
2732
2733                                }
2734
2735                                //USE OFFSET PAGINATION METHOD
2736                                if( cff_grid_pag == 'offset' ){
2737                                    if( item_sel == '.cff-album-item' ){
2738                                        //If it's an album item then remove the "after" param as it overrides the "until" param
2739                                        if( new_url.indexOf('&after=') > -1 ) new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
2740
2741                                        //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
2742                                        key = key.replace( /(:|\.|\[|\]|,|=)/g, "\\$1" );
2743                                        var albumItemCount = $cff.find('.cff-album-item.cff-' + key).length + $cff.find('.cff-empty-album.cff
2743-' + key).length;
2744                                        if( new_url.indexOf('&offset=') > -1 ){
2745                                            new_url = new_url.replace("&offset="+cffGetParameterByName('offset', new_url), "&offset="+albumItemCount);
2746                                        } else {
2747                                            new_url = new_url + "&offset=" + albumItemCount;
2748                                        }
2749                                        key = key.replace(/\\/g, '');
2750                                    }
2751                                }
2752                                //END USE OFFSET PAGINATION METHOD
2753
2754
2755                                //If it's an events only URL then remove the "after" param as we're using the "until" value instead
2756                                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') ) ){
2757                                    new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
2758                                }
2759
2760                                //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"
2761                                if( new_url.indexOf('&__paging_token') > -1 ){
2762                                    new_url = new_url.replace("&__paging_token="+cffGetParameterByName('__paging_token', new_url),"");
2763                                }
2764
2765                                pag_url_arr[key] = new_url;
2766                            }
2767                        } // End pag_url_arr loop
2768                    } // End cff_timeline_api_paging if/else
2769
2770                    var pageAtt = typeof $cff.attr('data-page') !== 'undefined' ? $cff.attr('data-page') : 1,
2771                        page = parseInt(pageAtt) + 1;
2772                    $cff.attr('data-page', page);
2773                    //Convert the array back into a string
2774                    pag_url = JSON.stringify( pag_url_arr );
2775                    jQuery.ajax({
2776                        url : cffajaxurl,
2777                        type : 'post',
2778                        data : {
2779                            action : 'cff_get_new_posts',
2780                            shortcode_data : shortcodeData,
2781                            pag_url : pag_url,
2782                            feed_id : feed_id,
2783                            post_id : post_id,
2784                            location : location,
2785                            page: page
2786                        },
2787                        success : function(data) {
2788                            $cff.find('.cff-num-diff-hide').removeClass('cff-num-diff-hide');
2789                            //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
2790                            //Check by seeing if the data contains a div (ie. post)
2791                            if( data.indexOf('<div class=') == -1 && data.indexOf('<span class=') == -1 ){
2792                                $cffLoadMore.attr('data-cff-no-posts-added', 'true');
2793                            } else {
2794                                $cffLoadMore.attr('data-cff-no-posts-added', 'false');
2795                            }
2796
2797                            //Appends the html echoed out in cff_get_new_posts() to the last existing post element
2798                            if( $cff.find('.cff-item, .cff-album-item').length ){
2799                                $cff.find('.cff-item, .cff-album-item').addClass('cff-masonry-new').removeClass('cff-new').last().after(data);
2800                            } else {
2801                                //If there's no posts yet then just add it into the posts container
2802                                $cff.find('.cff-posts-wrap').append(data);
2803                            }
2804                            /*
2805                            if($cff.find('.cff-pag-url').attr('data-cff-pag-url') == 0){
2806                                $cffLoadMore.hide();
2807                                cff_no_more_posts($cff, $cffLoadMore);
2808                            }
2809                            */
2810
2811                            //Replace any duplicate album items with empty items so doesn't affect offset pagination
2812                            $cff.find('.cff-album-item').each(function (i) {
2813                                var $el = $('[id="' + this.id + '"]').eq(1);
2814                                if($el.length){
2815                                    this_classes = $el.attr('class');
2816                                    this_classes = this_classes.replace("cff-album-item","");
2817                                }
2818                            });
2819
2820                            //Remove loader
2821                            $cffLoadMore.removeClass('cff-loading').find('.cff-loader').remove();
2822                            //Re-add the ID so it can be clicked again
2823                            $cffLoadMore.attr('id', 'cff-load-more').removeClass('cff-disabled');
2824
2825                            //Rerun JS (only runs on new items - .cff-new)
2826                            cff_init( $cff );
2827
2828                            // rerun image resolution code for new images
2829                            var feedIndex = parseInt($cffLoadMore.closest('.cff').attr('data-cff-index')) - 1;
2830                            if (typeof window.cff !== 'undefined' && window.cff.feeds[feedIndex] !== 'undefined') {
2831                                window.cff.feeds[feedIndex].afterLoadMoreClicked($cffLoadMore);
2832                            }
2833                            /*
2834                            if( $cff.hasClass('cff-album-items-feed')){
2835                                cffAddMasonry($cff);
2836                            }
2837                            */
2838                            //Re-init masonry
2839                            var albumOverride = $cff.find('.cff-album-item').length && $cff.hasClass('cff-disable-liquid');
2840                            if( albumOverride || ($cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css')) ){
2841                                $cff.masonry('appended', $cff.find('.cff-new'));
2842                                $cff.find('.cff-view-comments, .cff-comment-replies a, .cff-show-more-comments a').off().on('click', function() {
2843                                    if( !$cff.hasClass('cff-opaque-comments') ){
2844                                        setTimeout(function(){
2845                                            cffAddMasonry($cff);
2846                                        }, 500);
2847                                    }
2848                                });
2849                            }
2850
2851                            //If there's no more API URLs to hit then hide the load more button
2852                            var next_urls = $cff.find('.cff-pag-url').attr('data-cff-pag-url');
2853                            if( item_sel == '.cff-item' || cff_grid_pag == 'cursor' ){
2854                                if( next_urls == '{}' ) cff_no_more_posts($cff, $cffLoadMore);
2855                            } else {
2856                                if( data.indexOf('class="cff-album-item') < 0 && data.indexOf('class="cff-empty-album') < 0 ){
2857                                    cff_no_more_posts($cff, $cffLoadMore);
2858                                }
2859                            }
2860
2861                            // Call Custom JS if it exists
2862                            // if (typeof cff_custom_js == 'function') setTimeout(function(){ cff_custom_js(jQuery); }, 100);
2863                            if (typeof cff_custom_js == 'function') cff_custom_js(jQuery);
2864
2865                        } // End success
2866                    }); // End Ajax call
2867                //Hover on Load More button
2868                }).on('mouseenter',  function() {
2869                        $(this).css('background', $(this).attr('data-cff-hover') );
2870                }).on('mouseleave', function() {
2871                        $(this).css('background', $(this).attr('data-cff-bg') );
2872                });
2873
2874                function cff_no_more_posts($cff, $cffLoadMore){
2875                    var no_more_posts_text = ( $cffLoadMore.attr('data-no-more') == '' ) ? 'No more posts' : $cffLoadMore.attr('data-no-more').replace(/\\'/g,"'");
2876                    if( $cff.find('.cff-no-more-posts').length < 1 ) $cffLoadMore.hide().after('<p class="cff-no-more-posts">'+no_more_posts_text+'</p>');
2877                }
2878
2879                //Remove the masonry css class if it's a grid feed
2880                if( $cff.find('.cff-album-item').length && ! $cff.hasClass('cff-masonry')){
2881                    $cff.removeClass('cff-masonry cff-masonry-js cff-masonry-css');
2882                }
2883
2884                //Multiple event dates toggle
2885                $cff.find('.cff-more-dates').on('click', function(){
2886                    $(this).siblings('.cff-multiple-dates').slideToggle(100);
2887                });
2888
2889
2890            }); // End .$('.cff-wrapper').each
2891
2892             function cffGetCommentsIDArray(){
2893                    var commentsArrayIDs = [];
2894                    $('.cff-posts-wrap').each(function(){
2895                        var wrapper = $(this);
2896                        wrapper.find('.cff-item.cff-new:not(.cff-event)').each(function(){
2897                            var $self = $(this),
2898                            post_id_orig = $self.find('.cff-view-comments').attr('id'),
2899                            object_id = $self.closest('.cff-item').attr('data-object-id');
2900                            commentsArrayIDs.push(post_id_orig);
2901                        });
2902
2903                    });
2904                    return commentsArrayIDs;
2905                }
2906
2907                function cffGetFeedLocatorDataArray(){
2908                    var feedLocatorData = [];
2909                    $('.cff-timeline-feed').each(function(){
2910                        $cffPagUrl = $(this).find('.cff-pag-url');
2911                        var singleFeedLocatorData = {
2912                            feedID : $cffPagUrl.attr('data-feed-id'),
2913                            postID : $cffPagUrl.attr('data-post-id'),
2914                            shortCodeAtts : $(this).attr('data-cff-shortcode').trim() == '' ? {} : JSON.parse($(this).attr('data-cff-shortcode')),
2915                            location : CFFLocationGuess($(this))
2916                        };
2917                        feedLocatorData.push(singleFeedLocatorData);
2918                    });
2919                    return feedLocatorData;
2920                }
2921            //GET/CACHE COMMENTS
2922            //Check if the meta transient exists (set in head JS vars) and that a timeline feed exists on the page
2923            if($('.cff-timeline-feed').length && (typeof cffdisablecommentcaching == 'undefined') ){
2924                var commentsArrayIDs = cffGetCommentsIDArray(),
2925                feedLocatorData =  cffGetFeedLocatorDataArray();
2926
2927                //If the comments data is cached then get it from the transient in the DB
2928                var atts = typeof $cff.attr('data-cff-shortcode') !== 'undefined' && $cff.attr('data-cff-shortcode').indexOf('{') === 0 ? JSON.parse($cff.attr('data-cff-shortcode')) : {};
2929                var page = typeof $cff.attr('data-page') !== 'undefined' ? parseInt($cff.attr('data-page')) : 1;
2930
2931                $.ajax({
2932                    url: cffajaxurl,
2933                    type: 'POST',
2934                    async: true,
2935                    cache: false,
2936                    data:{
2937                        action: 'get_meta',
2938                        comments_array_ids : commentsArrayIDs,
2939                        feedLocatorData : feedLocatorData,
2940                        atts: atts,
2941                        page: page
2942                    },
2943                    success: function(data) {
2944                        console.log(data)
2945                        //If there's no data then set the array to be empty so that it hits the API for the data
2946                        if( data == '' || data.length < 1 ){
2947                            metaArr = [];
2948                        } else {
2949                            //Decode the JSON to that it can be used again
2950                            //Replace any escaped single quotes as it results in invalid JSON
2951                            data = data.replace(/\\'/g, "'");
2952                            //Convert the cached JSON string back to a JSON object
2953                            metaArr = JSON.parse( data );
2954                        }
2955                        // $cff.find('.cff-item.cff-new').each(function(){
2956                        $cff.each(function(){
2957                            $(this).find('.cff-item.cff-new:not(.cff-event)').each(function(){
2958                                var $self = $(this),
2959                                    post_id_orig = $self.find('.cff-view-comments').attr('id'),
2960                                    object_id = $self.closest('.cff-item').attr('data-object-id');
2961                                //If the post ID doesn't exist in the array then use the API to get the data
2962                                if( metaArr.hasOwnProperty(post_id_orig) && metaArr[post_id_orig] != ""){
2963                                    cffCreateComments($self, JSON.parse(metaArr[post_id_orig])['content']);
2964                                    cffAddFullsizeImageURLs($self, JSON.parse(metaArr[post_id_orig])['content']);
2965                                } else {
2966                                    cffGetMetaAPI($self, post_id_orig, object_id);
2967                                }
2968                            });
2969                        });
2970                    },
2971                    error: function(xhr,textStatus,e) {
2972                        return;
2973                    }
2974
2975                }); //End ajax
2976
2977            } else {
2978                $('#cff .cff-item.cff-new:not(.cff-event)').each(function(){
2979                    var $self = $(this),
2980                    post_id_orig = $self.find('.cff-view-comments').attr('id'),
2981                    object_id = $self.closest('.cff-item').attr('data-object-id');
2982                    cffGetMetaAPI($self, post_id_orig, object_id);
2983                });
2984            } //END GET/CACHE COMMENTS
2985
2986            function cffGetMetaAPI($self, post_id_orig, object_id){
2987
2988                //If there's no comments box on the page then return so we don't hit the API to get the data
2989                if( $self.find('.cff-view-comments').length == 0 ) return;
2990
2991                if( typeof object_id == 'undefined' || object_id.length < 2 ) object_id = '';
2992
2993                var object_id_query = ''+object_id,
2994                    post_id_query = '?post_id='+post_id_orig,
2995                    use_id = 'object',
2996                    post_comment_count = $self.find('.cff-comments .cff-count').text(),
2997                    post_likes_count = $self.find('.cff-likes .cff-count').text(),
2998                    cff_page_id = $self.attr('data-page-id');
2999
3000                if( typeof post_comment_count == 'undefined' || post_comment_count == '' ) post_comment_count = 0;
3001                //Load comment counts via JS
3002                if( typeof $self.attr('data-comments-js') !== 'undefined' ){
3003                    if( typeof post_comment_count == 'undefined' || post_comment_count == '' ) post_comment_count = 1;
3004                }
3005                if( typeof post_likes_count == 'undefined' || post_like
3005s_count == '' ) post_likes_count = 0;
3006
3007                //If it's a video post or there's no object ID then use the post ID (video posts don't have "images" field)
3008                // if( typeof object_id == 'undefined' || object_id.length < 2 || $self.hasClass('cff-video-post') ) use_id = 'post';
3009                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';
3010
3011                var timeline_event = '';
3012                if( $self.hasClass('cff-timeline-event') ) timeline_event = '&timeline_event=true';
3013
3014                var usegrouptoken = '',
3015                    useowntoken = '';
3016                if( $self.closest('#cff').hasClass('cff-group') ) usegrouptoken = '&usegrouptoken=true';
3017                if( $self.closest('#cff').attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
3018
3019                shortcode_token_param = cffGetShortcodeToken( $self.closest('#cff') );
3020
3021                //Is it a video post? If so, then we may be able to use the object ID to get the embeddable video object
3022                var cff_is_video_post = $self.hasClass('cff-video-post') ? '&isvideo=true' : '';
3023
3024                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;
3025
3026                if( $self.hasClass('cff-album') ) url += '&timelinealbum=true';
3027
3028                //Get comments, reactions, and full size images data from the API
3029                if( locatefile == true && typeof window.cff_block_editor === 'undefined' ){
3030                    var submitData = {
3031                        action: 'cff_query',
3032                        o_id: object_id,
3033                        post_id: post_id_orig,
3034                        use_id: use_id,
3035                        comments_num: post_comment_count,
3036                        likes_num: post_likes_count,
3037                        type: 'meta',
3038                        pageid: cff_page_id,
3039                    };
3040                    if( $self.hasClass('cff-video-post') ) {
3041                        submitData.isvideo = true;
3042                    }
3043                    if( $self.hasClass('cff-timeline-event') ) {
3044                        submitData.timeline_event = true;
3045                    }
3046                    if( $self.closest('#cff').hasClass('cff-group') ) {
3047                        submitData.usegrouptoken = true;
3048                    }
3049                    if( $self.closest('#cff').attr('data-own-token') == 'true' ) {
3050                        submitData.useowntoken = true;
3051                    }
3052                    if( shortcode_token_param !== '' ){
3053                        var token = shortcode_token_param.split('=');
3054
3055                        submitData.at = token[1];
3056                    }
3057
3058                    var onSuccess = function(data) {
3059                        metaArray.push( {'id_post' : post_id_orig, 'content' : data} );
3060                        //Cache the comments by adding to the cache array
3061                        metaArr[ post_id_orig ] = data;
3062                        newMetaArr[ post_id_orig ] = data; //This is cached. Only the new comments.
3063                        //Add the comments HTML
3064                        cffCreateComments($self, data);
3065
3066                        //Replace images URLs with full size ones
3067                        cffAddFullsizeImageURLs($self, data);
3068                        //Set the cache
3069                        cffSetMetaCache(metaArray);
3070
3071                    };
3072                    cffAjax(submitData,onSuccess);
3073                }
3074
3075            } //End cffGetMetaAPI()
3076
3077            //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.
3078            var cffSetMetaCache_executed = false;
3079            function cffSetMetaCache(newMetaArr){
3080                if( typeof cffdisablecommentcaching != 'undefined' ) return;
3081                if( !cffSetMetaCache_executed ){
3082
3083                    //Cache the comments data
3084                    var cffTimesCached = 0,
3085                        cffCacheDelay = setTimeout(function() {
3086                            //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
3087                            var cffCacheInterval = setInterval(function(){
3088
3089                                cffCacheMeta(newMetaArr);
3090
3091                                cffTimesCached++;
3092                                if(cffTimesCached == 2) clearInterval(cffCacheInterval);
3093                            }, 3000);
3094
3095                            //Send the data to DB initially via ajax after a 0.5 second delay
3096                            cffCacheMeta(newMetaArr);
3097                        }, 500);
3098
3099                    cffSetMetaCache_executed = true;
3100
3101                } // End cffRunFunction check
3102
3103
3104
3105
3106                //Cache the likes and comments counts by sending an array via ajax to the main plugin file which then stores it in a transient
3107                function cffCacheMeta(newMetaArr){
3108                    //Convert the JSON object to a string
3109                    var jsonstring = JSON.stringify( newMetaArr );
3110
3111                    //If the comments data is cached then get it from the transient in the DB
3112                    var atts = typeof $cff.attr('data-cff-shortcode') !== 'undefined' && $cff.attr('data-cff-shortcode').indexOf('{') === 0 ? JSON.parse($cff.attr('data-cff-shortcode')) : {};
3113                    var page = typeof $cff.attr('data-page') !== 'undefined' ? parseInt($cff.attr('data-page')) : 1;
3114
3115                    //Encode the JSON string so that it can be stored in the database
3116                    //Cache the data
3117                    var opts = {
3118                        url: cffajaxurl,
3119                        type: 'POST',
3120                        async: true,
3121                        cache: false,
3122                        data:{
3123                            action: 'cache_meta',
3124                            metadata: jsonstring, // Passes array of meta data to WP to cache
3125                            atts: atts,
3126                            page: page
3127                        },
3128                        success: function(response) {
3129                            return;
3130                        },
3131                        error: function(xhr,textStatus,e) {
3132                            return;
3133                        }
3134                    };
3135                    $.ajax(opts);
3136
3137                } // End cffCacheMeta()
3138
3139            } // End cffSetMetaCache()
3140
3141
3142            function cffGetParameterByName(name, url) {
3143                name = name.replace(/[\[\]]/g, "\\$&");
3144                var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
3145                    results = regex.exec(url);
3146                if (!results) return null;
3147                if (!results[2]) return '';
3148                return decodeURIComponent(results[2].replace(/\+/g, " "));
3149            }
3150
3151            function cffLinkify(inputText) {
3152                var replacedText, replacePattern1, replacePattern2, replacePattern3;
3153
3154                //URLs starting with http://, https://, or ftp://
3155                replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
3156                replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank" rel="nofollow noopener noreferrer">$1</a>');
3157
3158                //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
3159                replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
3160                replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank" rel="nofollow noopener noreferrer">$2</a>');
3161
3162                //Change email addresses to mailto:: links.
3163                replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
3164                replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
3165
3166                return replacedText;
3167            }
3168
3169
3170            //HTML5 Video play button
3171            $(document).off('click', '#cff .cff-html5-video .cff-html5-play').on('click', '#cff .cff-html5-video .cff-html5-play', function(e){
3172                e.preventDefault();
3173
3174                var $self = $(this),
3175                    $videoWrapper = $self.closest('.cff-html5-video'),
3176                    video = $self.siblings('video')[0];
3177                video.play();
3178                $self.hide();
3179                $self.siblings('.cff-poster').hide();
3180
3181                //Show controls when the play button is clicked
3182                if (video.hasAttribute("controls")) {
3183                    video.removeAttribute("controls")
3184                } else {
3185                    video.setAttribute("controls","controls")
3186                }
3187
3188                if($videoWrapper.innerWidth() < 150 && !$videoWrapper.hasClass('cff-no-video-expand')) {
3189                    $videoWrapper.css('width','100%').closest('.cff-item').find('.cff-text-wrapper').css('width','100%');
3190                }
3191            });
3192
3193
3194            //Replace the lightbox image with the full size image which is retrieved in the meta API request
3195            function cffAddFullsizeImageURLs($self, data){
3196                var data = JSON.parse( data );
3197
3198                if( typeof data.images !== 'undefined' && data.images !== null ) $self.find('.cff-lightbox-link').attr('href', data.images[0].source);
3199
3200                //Removed in v3.7 as shouldn't be needed any longer. Commenting out in case needs to be re-added.
3201                //Add the full size video image which is retrieved from query.php to fix the Facebook video image size API bug
3202                // if( $self.find('.cff-html5-video').length && typeof data.attachments !== 'undefined' && data.attachments !== null ){
3203                //  $self.find('.cff-poster').attr('src', data.attachments.data[0].media.image.src);
3204                //  console.log( data.attachments.data[0] );
3205                //  $self.find('.cff-lightbox-link').attr('href', data.attachments.data[0].media.image.src);
3206                // }
3207            }
3208
3209
3210            //Create comments
3211            function cffCreateComments($self, data){
3212
3213                if (data.substring(0, 1) == "<") return false;
3214
3215                //Convert string of data received from comments.php to a JSON object
3216                var data = JSON.parse( data ),
3217                    cff_comments = '',
3218                    cff_likes_this = '',
3219                    commentShow = parseInt( $self.find('.cff-comments-box').attr('data-num') ),
3220                    like_count = ( typeof data.likes !== 'undefined' ) ? data.likes.summary.total_count : 0,
3221                    $cffCommentsBox = $self.find('.cff-comments-box'),
3222                    $cffCommentLikes = $cffCommentsBox.find('.cff-comment-likes'),
3223                    cff_hide_comment_avatars = Boolean($self.find('.cff-comments-box').attr('data-cff-hide-avatars')),
3224                    cff_expand_comments = Boolean($self.find('.cff-comments-box').attr('data-cff-expand-comments')),
3225                    cff_translate_like_this_text = $cffCommentsBox.attr('data-cff-like-text'),
3226                    cff_translate_likes_this_text = $cffCommentsBox.attr('data-cff-likes-text'),
3227                    cff_translate_reacted_to_this_text = $cffCommentsBox.attr('data-cff-reacted-text'),
3228                    cff_translate_and_text = $cffCommentsBox.attr('data-cff-and-text'),
3229                    cff_translate_other_text = $cffCommentsBox.attr('data-cff-other-text'),
3230                    cff_translate_others_text = $cffCommentsBox.attr('data-cff-others-text'),
3231                    cff_translate_reply_text = $cffCommentsBox.attr('data-cff-reply-text'),
3232                    cff_translate_replies_text = $cffCommentsBox.attr('data-cff-replies-text'),
3233                    cff_total_comments_count = ( typeof data.comments !== 'undefined' ) ? data.comments.summary.total_count : 0,
3234                    cff_meta_link_color = $self.find('.cff-comments-box').attr('data-cff-meta-link-color'),
3235                    cff_post_tags = Boolean( $self.find('.cff-comments-box').attr('data-cff-post-tags') );
3236
3237                //Load comment counts via JS
3238                if( typeof $self.attr('data-comments-js') !== 'undefined' ){
3239                    var comment_count = ( typeof data.comments !== 'undefined' ) ? data.comments.summary.total_count : 0;
3240                    $self.find('.cff-comments .cff-count').text(comment_count);
3241                }
3242
3243                //ADD REACTIONS
3244                var cff_haha_count = ( typeof data.haha !== 'undefined' ) ? data.haha.summary.total_count : 0;
3245                var cff_love_count = ( typeof data.love !== 'undefined' ) ? data.love.summary.total_count : 0;
3246                var cff_wow_count = ( typeof data.wow !== 'undefined' ) ? data.wow.summary.total_count : 0;
3247                var cff_sad_count = ( typeof data.sad !== 'undefined' ) ? data.sad.summary.total_count : 0;
3248                var cff_angry_count = ( typeof data.angry !== 'undefined' ) ? data.angry.summary.total_count : 0;
3249
3250                var reactions_arr = [cff_haha_count, cff_love_count, cff_wow_count, cff_sad_count, cff_angry_count];
3251                var reaction_first_num = reactions_arr.sort(sortNumber)[0];
3252                var reaction_second_num = reactions_arr.sort(sortNumber)[1];
3253
3254                //Sort array highest to lowest
3255                function sortNumber(a,b) {
3256                    return b - a;
3257                }
3258
3259                var reactions_html = '',
3260                    love_added = false,
3261                    haha_added = false,
3262                    wow_added = false,
3263                    sad_added = false,
3264                    angry_added = false,
3265                    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>',
3266                    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
3266-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>',
3267                    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>',
3268                    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>',
3269                    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>',
3270                    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 
3270192 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>',
3271                    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>';
3272
3273
3274                //Add first reaction
3275                var reaction_one_html = '';
3276                if( reaction_first_num > 0 ){
3277                    if(data.love.summary.total_count == reaction_first_num){
3278                        reaction_one_html += '<span class="cff-love cff-reaction-one cff-icon">'+love_svg+'</span>';
3279                        love_added = true;
3280                    }
3281                    if(data.haha.summary.total_count == reaction_first_num){
3282                        reaction_one_html += '<span class="cff-haha cff-reaction-one cff-icon">'+haha_svg+'</span>';
3283                        haha_added = true;
3284                    }
3285                    if(data.wow.summary.total_count == reaction_first_num){
3286                        reaction_one_html += '<span class="cff-wow cff-reaction-one cff-icon">'+wow_svg+'</span>';
3287                        wow_added = true;
3288                    }
3289                    if(data.sad.summary.total_count == reaction_first_num){
3290                        reaction_one_html += '<span class="cff-sad cff-reaction-one cff-icon">'+sad_svg+'</span>';
3291                        sad_added = true;
3292                    }
3293                    if(data.angry.summary.total_count == reaction_first_num){
3294                        reaction_one_html += '<span class="cff-angry cff-reaction-one cff-icon">'+angry_svg+'</span>';
3295                        angry_added = true;
3296                    }
3297                    reactions_html += reaction_one_html;
3298                }
3299
3300                //If reaction one doesn't already contain two reactions (eg: if the two reaction_one
3300s are the same number) then don't include a reaction_two
3301                if( reaction_one_html.split('cff-reaction-one').length < 3 ){
3302                    //Add second reaction
3303                    if( reaction_second_num > 0 ){
3304                        var reaction_two_html = '';
3305
3306                        if(data.love.summary.total_count == reaction_second_num && !love_added){
3307                            reaction_two_html = '<span class="cff-love cff-reaction-two cff-icon">'+love_svg+'</span>';
3308                        }
3309                        if(data.haha.summary.total_count == reaction_second_num && !haha_added){
3310                            reaction_two_html = '<span class="cff-haha cff-reaction-two cff-icon">'+haha_svg+'</span>';
3311                        }
3312                        if(data.wow.summary.total_count == reaction_second_num && !wow_added){
3313                            reaction_two_html = '<span class="cff-wow cff-reaction-two cff-icon">'+wow_svg+'</span>';
3314                        }
3315                        if(data.sad.summary.total_count == reaction_second_num && !sad_added){
3316                            reaction_two_html = '<span class="cff-sad cff-reaction-two cff-icon">'+sad_svg+'</span>';
3317                        }
3318                        if(data.angry.summary.total_count == reaction_second_num && !angry_added){
3319                            reaction_two_html = '<span class="cff-angry cff-reaction-two cff-icon">'+angry_svg+'</span>';
3320                        }
3321                        reactions_html += reaction_two_html;
3322                    }
3323                }
3324
3325                //Add the reaction icons
3326                if( $self.find('.cff-meta .cff-likes').find('.cff-icon').length < 2 ) $self.find('.cff-meta .cff-likes .cff-icon').after( reactions_html );
3327
3328                //If there's no likes but there's a reacton then don't show the like icon - show the reaction icon instead
3329                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 ) ){
3330                    $self.find('.cff-meta .cff-likes .cff-like').remove();
3331                    $self.find('.cff-meta .cff-likes span').addClass('cff-no-animate');
3332                }
3333
3334                //Add reactions to like count
3335                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);
3336                if( cff_reactions_count > 0 ) $self.find('.cff-meta .cff-likes .cff-count').text( cff_reactions_count );
3337
3338
3339                //ADDS REACTIONS TO COMMENTS BOX
3340                var cff_no_reactions = false;
3341                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;
3342
3343                var reactions_count_html = '<span class="cff-reactions-count">';
3344
3345                if( parseInt(like_count) > 0){
3346                    reactions_count_html += '<span class="cff-like cff-icon">'+like_svg+'</span>';
3347
3348                    if( !cff_no_reactions ){
3349                        if( parseInt(like_count) > 0 ) reactions_count_html += '<span class="cff-like-count">
3349'+like_count+'</span>';
3350                        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>';
3351                        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>';
3352                        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>';
3353                        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>';
3354                        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>';
3355                    }
3356                }
3357                reactions_count_html += '</span>';
3358
3359                //CREATE LIKES PART AT TOP OF COMMENTS BOX
3360                if( typeof data.likes !== 'undefined' ){
3361                    if( data.likes.data.length ){
3362
3363                        cff_likes_this += '<span class="cff-likes-this-text">';
3364
3365                        var liker_one = '',
3366                            liker_two = '';
3367
3368                        if ( like_count > 0 && typeof data.likes.data[0] !== 'undefined' ){
3369
3370                            //Only link the name if a legit link is available for this user
3371                            var userHasLink = false;
3372                            if( typeof data.likes.data[0].link !== 'undefined' ){
3373                                if( data.likes.data[0].link.indexOf('/app_scoped_user_id/') == -1 ) userHasLink = true;
3374                            }
3375
3376                            //Creat link or span
3377                            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="';
3378                            if (cff_no_reactions) liker_one += ' margin-left: 5px';
3379                            liker_one += '">'+data.likes.data[0].name;
3380
3381                            userHasLink ? liker_one += '</a>' : liker_one += '</span>';
3382                        }
3383
3384                        if ( like_count > 1 && typeof data.likes.data[1] !== 'undefined' ){
3385
3386                            //Only link the name if a legit link is available for this user
3387                            var userHasLink = false;
3388                            if( typeof data.likes.data[1].link !== 'undefined' ){
3389                                if( data.likes.data[1].link.indexOf('/app_scoped_user_id/') == -1 ) userHasLink = true;
3390                            }
3391
3392                            //Creat link or span
3393                            userHasLink ? liker_two += '<a href="'+data.likes.data[1].link+'" target="_blank" rel="nofollow noopener" style="color:'+cff_meta_link_color+'">' : liker_two = '<span>';
3394                            liker_two += data.likes.data[1].name;
3395
3396                            userHasLink ? liker_two += '</a>' : liker_two += '</span>';
3397                        }
3398
3399                        if (like_count == 1){
3400                            cff_likes_this += liker_one+' '+cff_translate_likes_this_text;
3401                        } else if (like_count == 2){
3402                            cff_likes_this += liker_one+' '+cff_translate_and_text+' '+liker_two+' '+cff_translate_like_this_text;
3403                        } else if (like_count == 3){
3404                            cff_likes_this += liker_one+', '+liker_two+' '+cff_translate_and_text+' 1 '+cff_translate_other_text+' '+cff_translate_like_this_text;
3405                        } else {
3406                            cff_likes_this += liker_one+', '+liker_two+' '+cff_translate_and_text+' ';
3407                            if (like_count == 25) cff_likes_this += '<span class="cff-comment-likes-count">';
3408                            cff_likes_this += parseInt(cff_reactions_count)-2;
3409                            if (like_count == 25) cff_likes_this += '</span>';
3410                            cff_likes_this += ' '+cff_translate_others_text;
3411
3412                            if( parseInt(cff_reactions_count) == parseInt(like_count) ){
3413                                cff_likes_this += ' '+cff_translate_like_this_text;
3414                            } else {
3415                                cff_likes_this += ' '+cff_translate_reacted_to_this_text;
3416                            }
3417
3418                        }
3419
3420                        cff_likes_this += '</span>';
3421
3422                        if( $cffCommentLikes.find('.cff-reactions-count').length < 1 ) $cffCommentLikes.append('<span class="cff-likes-info-wrap">' + reactions_count_html + cff_likes_this + '</span>');
3423
3424                    } else {
3425                        //If there's no likes data then hide the top of the comments box that shows the "likes this" section
3426                        if( cff_no_reactions ){
3427                            $cffCommentLikes.hide();
3428                        } else {
3429                            if( $cffCommentLikes.find('.cff-reactions-count').length < 1 ) $cffCommentLikes.append('<span class="cff-likes-info-wrap">' + reactions_count_html + '</span>');
3430                        }
3431                    }
3432
3433                }
3434
3435
3436                if( typeof data.comments !== 'undefined' ){
3437                    $.each(data.comments.data, function(i, commentItem) {
3438                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
3439
3440                        //Do a final encode of the comment message
3441                        var comment_message = cffEncodeHTML(commentItem.message),
3442                            comment_message = cffLinkify(comment_message),
3443                            cff_comment_author_info = true,
3444                            cff_hide_comment_avatars = Boolean($self.find('.cff-comments-box').attr('data-cff-hide-avatars'));
3445
3446                        //Check whether comment author info exists - only accessible with page access token from the page now
3447                        if( typeof commentItem.from !== 'undefined' ){
3448                            cff_comment_from_id = commentItem.from.id;
3449                        } else {
3450                            cff_hide_comment_avatars = true;
3451                            cff_comment_author_info = false;
3452                            cff_comment_from_id = '';
3453                        }
3454
3455                        cff_comments += '<div class="cff-comment" id="cff_'+commentItem.id+'" data-id="'+cff_comment_from_id+'"';
3456                        cff_comments += ' style="';
3457                        ( i >= commentShow ) ? cff_comments += 'display: none;' : cff_comments += 'display: block;';
3458                        if( typeof $self.find('#cff_'+commentItem.id).attr('style') !== 'undefined' ) cff_comments += $self.find('#cff_'+commentItem.id).attr('style');
3459                        cff_comments += '"';
3460                        if( typeof commentItem.from !== 'undefined' ){
3461                            if( typeof commentItem.from.picture !== 'undefined' ){
3462                                cff_comments += 'data-avatar="'+commentItem.from.picture.data.url+'"';
3463                            }
3464                        }
3465                        cff_comments += '>';
3466                        cff_comments += '<div class="cff-comment-text-wrapper">';
3467                        cff_comments += '<div class="cff-comment-text';
3468                        if( cff_hide_comment_avatars ) cff_comments += ' cff-no-image';
3469                        cff_comments += '"><p>';
3470                        if( cff_comment_author_info ){
3471                            if( typeof commentItem.from.link !== 'undefined' ){
3472                                cff_comments += '<a href="'+commentItem.from.link+'" class="cff-name" target="_blank" rel="nofollow noopener" style="color:' + cff_meta_link_color + '">
3472'+commentItem.from.name+'</a>';
3473                            } else {
3474                                cff_comments += '<span class="cff-name">'+commentItem.from.name+'</span>';
3475                            }
3476                        }
3477
3478                        //MESSAGE TAGS
3479                        if( cff_post_tags && commentItem.hasOwnProperty('message_tags') ){
3480
3481                            //Loop through the tags and use the name to replace them
3482                            $.each(commentItem.message_tags, function(i, message_tag) {
3483                                tag_name = message_tag.name;
3484                                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>';
3485
3486                                comment_message = comment_message.replace(tag_name, tag_link);
3487                            });
3488
3489                        } //END MESSAGE TAGS
3490
3491                        cff_comments += comment_message+'</p>';
3492
3493
3494                        //Add image attachment if exists
3495                        if( commentItem.hasOwnProperty('attachment') ){
3496                            if( commentItem.attachment.hasOwnProperty('media') ){
3497                                if (consentGiven) {
3498                                    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="';
3499                                } else {
3500                                    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>';
3501                                }
3502
3503                                if (consentGiven) {
3504                                    if( commentItem.attachment.hasOwnProperty('title') ){
3505                                        cff_comments += commentItem.attachment.title;
3506                                    } else {
3507                                        cff_comments += 'Attachment';
3508                                    }
3509                                    cff_comments += '" /></a>';
3510                                } else {
3511                                    cff_comments += '</a>';
3512
3513                                }
3514
3515                            }
3516                        }
3517
3518                        cff_comments += '<span class="cff-time">';
3519                        var cff_middot = '',
3520                            cff_comment_time = $self.find('#cff_'+commentItem.id).attr('data-cff-comment-date');
3521                        //If the time is undefined then don't show it
3522                        if( typeof cff_comment_time !== 'undefined' ){
3523                            cff_comments += '<span class="cff-comment-date">'+cff_comment_time+'</span>';
3524                            cff_middot = '&nbsp; &middot; &nbsp;';
3525                        }
3526                        if ( commentItem.like_count > 0 ) cff_comments += '<span class="cff-comment-likes"><span class="cff-comment-likes-bg"><b>'+like_svg_2+'</b>
3526'+commentItem.like_count+'</span></span>';
3527                        cff_comments += '</span>';
3528
3529                        //Comment replies
3530                        var cff_comment_count = parseInt(commentItem.comment_count);
3531                        if( cff_comment_count > 0 ){
3532                            //Get this from a data attr on the comments box container
3533                            var cff_replies_text_string = '';
3534                            (cff_comment_count == 1) ? cff_replies_text_string = cff_translate_reply_text : cff_replies_text_string = cff_translate_replies_text;
3535                            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>';
3536                        }
3537
3538                        cff_comments += '</div>'; //End .cff-comment-text
3539                        cff_comments += '</div>'; //End .cff-comment-text-wrapper
3540
3541                        //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
3542                        if( !cff_hide_comment_avatars && cff_comment_author_info ){
3543                            cff_comments += '<div class="cff-comment-img cff-avatar-fallback">';
3544                            if( typeof commentItem.from.link !== 'undefined' ) cff_comments += '<a href="https://facebook.com/'+commentItem.from.link+'" target="_blank" rel="noopener">';
3545                            if( cff_expand_comments && (i < commentShow) ) {
3546                                if (consentGiven) {
3547                                    cff_comments += '<img src="'+commentItem.from.picture.data.url+'" width=32 height=32 alt="'+commentItem.from.name+'" onerror="this.style.display=\'none\'">';
3548                                } else {
3549                                    cff_comments += '<span class="cff-comment-avatar-placeholder" data-src="'+commentItem.from.picture.data.url+'">';
3550                                }
3551                            } else {
3552                                cff_comments += '<span class="cff-comment-avatar"></span>';
3553                            }
3554                            if( typeof commentItem.from.link !== 'undefined' ) cff_comments += '</a>';
3555                            cff_comments += '</div>';
3556                        }
3557
3558                        cff_comments += '</div>'; //End .cff-comment
3559
3560                    }); //End data.comments.data loop
3561
3562                } //End if
3563
3564                //Remove the comments added for SEO in PHP
3565                $self.find('.cff-comments-wrap .cff-comment').remove();
3566                //Add the comments to the page
3567                $self.find('.cff-comments-wrap').prepend( cff_comments );
3568                $self.find('.cff-show-more-comments').attr('data-cff-comments-total', cff_total_comments_count);
3569
3570                //Add border radius
3571                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"});
3572                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"});
3573                //Add a little more padding if there's no comments
3574                if( $self.find('.cff-comments-wrap .cff-comment').length < 1 ) $self.find('.cff-comment-on-facebook').css('padding','8px 15px 8px 10px');
3575
3576                setTimeout(function(){
3577                    if( $self.closest('.cff').hasClass('cff-masonry-js') && !$self.closest('.cff').hasClass('cff-masonry-css') ) cffAddMasonry( $self.closest('.cff') );
3578                }, 200);
3579
3580            } //End cffCreateComments()
3581
3582
3583            //Check if any lazy loading plugins have changed the image src
3584            function cff_lazy_load_correction(){
3585
3586                var $ = jQuery;
3587
3588                // The lightbox link needs to be reset to the original source
3589                $('.cff-lightbox-link').each(function(){
3590                    var $lbLink = $(this);
3591
3592                    if( $lbLink.closest('.cff-album-item').attr('data-cff-full-size') ){
3593                        lborigSrc = $lbLink.attr('data-cff-full-size');
3594                    } else {
3595                        lborigSrc = $lbLink.parent().find('img').attr('data-orig-source');
3596                    }
3597                    $lbLink.attr('href', lborigSrc);
3598                })
3599
3600                // Check if lazy load placeholder image is being used
3601                $('img[data-orig-source]').each(function(){
3602                    var $self = $(this),
3603                        currentSrc = $self.attr('src'),
3604                        originalSrc = $self.attr('data-orig-source');
3605
3606                    // Check if the img source has been changed by lazy loading
3607                    if(originalSrc != currentSrc){
3608                        $self.attr('src', originalSrc);
3609                    }
3610
3611                    // Timeline album posts need the background source reset
3612                    if($self.hasClass('cff-multi-image')){
3613                        $self.css('background-image', 'url(' + originalSrc + ')');
3614                    }
3615                });
3616
3617                // Need to set a default value for the link slider in shared links otherwise it gets a 1px width
3618                $('.cff-link-slider').each(function(){
3619                    $(this).find('.cff-link-slider-slides').css('width', '2500px')
3620                });
3621            }
3622
3623            if (typeof window.cff === 'undefined' || typeof window.cff.feeds === 'undefined') {
3624                if (!$cff.find('.cff_resized_image_data').length) {
3625                    cff_lazy_load_correction();
3626                }
3627            } else if (typeof window.cff.feeds[0] !== 'undefined') {
3628                if (!window.cff.feeds[0].settings.resizingEnabled) {
3629                    cff_lazy_load_correction();
3630                }
3631            }
3632
3633            //Create shared link multi-image slider
3634            setTimeout(function(){
3635
3636                $cff.find('.cff-link-slider').each(function(){
3637
3638                    var $cffLinkSlider = $(this),
3639                        $cffLinkSliderSlides = $cffLinkSlider.find('.cff-link-slider-slides'),
3640                        $cffLinkSliderItem = $cffLinkSliderSlides.find('.cff-link-slider-item'),
3641                        cffLinkSliderCount = $cffLinkSliderItem.length,
3642                        cffLinkSliderWidth = $cffLinkSlider.width(),
3643                        cffCurSlide = 0;
3644                    $cffLinkSliderSlides.css({ width: cffLinkSliderWidth * cffLinkSliderCount });
3645                    $cffLinkSliderItem.css({ width: cffLinkSliderWidth });
3646
3647                    function cffMoveSlide(dir) {
3648                        //Change slides
3649                        dir == 'prev' ? cffCurSlide-- : cffCurSlide++;
3650                        $cffLinkSliderSlides.css('left', -cffCurSlide*cffLinkSliderWidth);
3651
3652                        //Hide the nav arrows at beginning/end
3653                        cffCurSlide == cffLinkSliderCount-1 ? $cffLinkSlider.find('a.cff-slider-next').hide() : $cffLinkSlider.find('a.cff-slider-next').show();
3654                        cffCurSlide > 0 ? $cffLinkSlider.find('a.cff-slider-prev').show() : $cffLinkSlider.find('a.cff-slider-prev').hide();
3655                    };
3656                    //Nav arrows click
3657                    $cffLinkSlider.find('a.cff-slider-prev, a.cff-slider-next').on('click', function(e){
3658                        e.preventDefault();
3659                        $(this).hasClass('cff-slider-prev') ? cffMoveSlide('prev') : cffMoveSlide('next');
3660                    });
3661                    //Vertically center last image in slider
3662                    setTimeout(function(){
3663                        var cffLastSlideHeight = $cffLinkSliderSlides.find('.cff-link-slider-item').first().height();
3664                        $cffLinkSliderSlides.find('.cff-final-item').css('height', cffLastSlideHeight).find('img').css('margin-top', (cffLastSlideHeight/2)-100 );
3665                    }, 1500);
3666
3667                    //Show all slides (initially hidden in CSS)
3668                    $cffLinkSliderSlides.find('.cff-link-slider-item').show();
3669
3670                });
3671
3672            }, 200);
3673
3674
3675        })(jQuery); //End (function($){
3676
3677        /*!
3678        imgLiquid v0.9.944 / 03-05-2013
3679        https://github.com/karacas/imgLiquid
3680        */
3681
3682        var imgLiquid = imgLiquid || {VER: '0.9.944'};
3683        imgLiquid.bgs_Available = false;
3684        imgLiquid.bgs_CheckRunned = false;
3685        //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.
3686        jQuery('.cff').each(function() {
3687            if (!jQuery(this).hasClass('cff-disable-liquid')) {
3688                $cff.find('.cff-new .cff-album-cover img').css('visibility', 'hidden');
3689            }
3690        });
3691        $cff.find('.cff-new .cff-crop img').css('visibility', 'hidden');
3692        jQuery('#cff .cff-img-attachments .cff-crop img').css('opacity', 0);
3693
3694
3695        (function ($) {
3696
3697            // ___________________________________________________________________
3698
3699            function checkBgsIsavailable() {
3700                if (imgLiquid.bgs_CheckRunned) return;
3701                else imgLiquid.bgs_CheckRunned = true;
3702
3703                var spanBgs = $('<span style="background-size:cover" />');
3704                $('body').append(spanBgs);
3705
3706                !function () {
3707                    var bgs_Check = spanBgs[0];
3708                    if (!bgs_Check || !window.getComputedStyle) return;
3709                    var compStyle = window.getComputedStyle(bgs_Check, null);
3710                    if (!compStyle || !compStyle.backgroundSize) return;
3711                    imgLiquid.bgs_Available = (compStyle.backgroundSize === 'cover');
3712                }();
3713
3714                spanBgs.remove();
3715            }
3716
3717
3718            // ___________________________________________________________________
3719
3720            $.fn.extend({
3721                imgLiquid: function (options) {
3722
3723                    this.defaults = {
3724                        fill: true,
3725                        verticalAlign: 'center',            //  'top'   //  'bottom' // '50%'  // '10%'
3726                        horizontalAlign: 'center',          //  'left'  //  'right'  // '50%'  // '10%'
3727                        useBackgroundSize: false,
3728                        useDataHtmlAttr: true,
3729
3730                        responsive: true,                   /* Only for use with BackgroundSize false (or old browsers) */
3731                        delay: false,                           /* Only for use with BackgroundSize false (or old browsers) */
3732                        fadeInTime: false,                      /* Only for use with BackgroundSize false (or old browsers) */
3733                        removeBoxBackground: false,          /* Only for use with Backgroun
3733dSize false (or old browsers) */
3734                        hardPixels: true,                   /* Only for use with BackgroundSize false (or old browsers) */
3735                        responsiveCheckTime: 500,           /* Only for use with BackgroundSize false (or old browsers) */ /* time to check div resize */
3736                        timecheckvisibility: 500,           /* Only for use with BackgroundSize false (or old browsers) */ /* time to recheck if visible/loaded */
3737
3738                        // CALLBACKS
3739                        onStart: null,                      // no-params
3740                        onFinish: null,                     // no-params
3741                        onItemStart: null,                  // params: (index, container, img )
3742                        onItemFinish: function(index, container, img){  // params: (index, container, img )
3743                            img.addClass('cffFadeIn');
3744                        },
3745                        onItemError: null                   // params: (index, container, img )
3746                    };
3747
3748                    checkBgsIsavailable();
3749                    var imgLiquidRoot = this;
3750
3751                    // Extend global settings
3752                    this.options = options;
3753                    this.settings = $.extend({}, this.defaults, this.options);
3754
3755                    // CallBack
3756                    if (this.settings.onStart) this.settings.onStart();
3757
3758
3759                    // ___________________________________________________________________
3760
3761                    return this.each(function ($i) {
3762
3763                        // MAIN >> each for image
3764
3765                        var settings = imgLiquidRoot.settings,
3766                            $imgBoxCont = $(this),
3767                            $img = $('img:first',$imgBoxCont);
3768                        if (!$img.length) {onError(); return;}
3769
3770
3771                        // Extend settings
3772                        if (!$img.data('imgLiquid_settings')) {
3773                            // First time
3774                            settings = $.extend({}, imgLiquidRoot.settings, getSettingsOverwrite());
3775                        } else {
3776                            // Recall
3777                            // Remove Classes
3778                            $imgBoxCont.removeClass('imgLiquid_error').removeClass('imgLiquid_ready');
3779                            settings = $.extend({}, $img.data('imgLiquid_settings'), imgLiquidRoot.options);
3780                        }
3781                        $img.data('imgLiquid_settings', settings);
3782
3783
3784                        // Start CallBack
3785                        if (settings.onItemStart) settings.onItemStart($i, $imgBoxCont, $img); /* << CallBack */
3786
3787
3788                        // Process
3789                        if (imgLiquid.bgs_Available && settings.useBackgroundSize)
3790                            processBgSize();
3791                        else
3792                            processOldMethod();
3793
3794
3795                        // END MAIN <<
3796
3797                        // ___________________________________________________________________
3798
3799                        function processBgSize() {
3800
3801                            // Check change img src
3802                            if ($imgBoxCont.css('background-image').indexOf(encodeURI($img.attr('src'))) === -1) {
3803                                // Change
3804                                $imgBoxCont.css({'background-image': 'url("' + encodeURI($img.attr('src')) + '")'});
3805                            }
3806
3807                            $imgBoxCont.css({
3808                                'background-size':      (settings.fill) ? 'cover' : 'contain',
3809                                'background-position':  (settings.horizontalAlign + ' ' + settings.verticalAlign).toLowerCase(),
3810                                'background-repeat':    'no-repeat'
3811                            });
3812
3813                            $('a:first', $imgBoxCont).css({
3814                                'display':  'block',
3815                                'width':    '100%',
3816                                'height':   '100%'
3817                            });
3818
3819                            $('img', $imgBoxCont).css({'display': 'none'});
3820
3821                            if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
3822
3823                            $imgBoxCont.addClass('imgLiquid_bgSize');
3824                            $imgBoxCont.addClass('imgLiquid_ready');
3825                            checkFinish();
3826                        }
3827
3828                        // ___________________________________________________________________
3829
3830                        function processOldMethod() {
3831
3832                            // Check change img src
3833                            if ($img.data('oldSrc') && $img.data('oldSrc') !== $img.attr('src')) {
3834
3835                                /* Clone & Reset img */
3836                                var $imgCopy = $img.clone().removeAttr('style');
3837                                $imgCopy.data('imgLiquid_settings', $img.data('imgLiquid_settings'));
3838                                $img.parent().prepend($imgCopy);
3839                                $img.remove();
3840                                $img = $imgCopy;
3841                                $img[0].width = 0;
3842
3843                                // Bug ie with > if (!$img[0].complete && $img[0].width) onError();
3844                                setTimeout(processOldMethod, 10);
3845                                return;
3846                            }
3847
3848
3849                            // Reproceess?
3850                            if ($img.data('imgLiquid_oldProcessed')) {
3851                                makeOldProcess(); return;
3852                            }
3853
3854
3855                            // Set data
3856                            $img.data('imgLiquid_oldProcessed', false);
3857                            $img.data('oldSrc', $img.attr('src'));
3858
3859
3860                            // Hide others images
3861                            $('img:not(:first)', $imgBoxCont).css('display', 'none');
3862
3863
3864                            // CSSs
3865                            $imgBoxCont.css({'overflow': 'hidden'});
3866                            $img.fadeTo(0, 0).removeAttr('width').removeAttr('height').css({
3867                                'visibility': 'visible',
3868                                'max-width': 'none',
3869                                'max-height': 'none',
3870                                'width': 'auto',
3871                                'height': 'auto',
3872                                'display': 'block'
3873                            });
3874
3875
3876                            // CheckErrors
3877                            $img.on('error', onError);
3878                            $img[0].onerror = onError;
3879
3880
3881                            // loop until load
3882                            function onLoad() {
3883                                if ($img.data('imgLiquid_error') || $img.data('imgLiquid_loaded') || $img.data('imgLiquid_oldProcessed')) return;
3884                                if ($imgBoxCont.is(':visible') && $img[0].complete && $img[0].width > 0 && $img[0].height > 0) {
3885                                    $img.data('imgLiquid_loaded', true);
3886                                    setTimeout(makeOldProcess, $i * settings.delay);
3887                                } else {
3888                                    setTimeout(onLoad, settings.timecheckvisibility);
3889                                }
3890                            }
3891
3892
3893                            onLoad();
3894                            checkResponsive();
3895                        }
3896
3897                        // ___________________________________________________________________
3898
3899                        function checkResponsive() {
3900
3901                            /* Only for oldProcessed method (background-size dont need) */
3902
3903                            if (!settings.responsive && !$img.data('imgLiquid_oldProcessed')) return;
3904                            if (!$img.data('imgLiquid_settings')) return;
3905
3906                            settings = $img.data('imgLiquid_settings');
3907
3908                            $imgBoxCont.actualSize = $imgBoxCont.get(0).offsetWidth + ($imgBoxCont.get(0).offsetHeight / 10000);
3909                            if ($imgBoxCont.sizeOld && $imgBoxCont.actualSize !== $imgBoxCont.sizeOld) makeOldProcess();
3910
3911                            $imgBoxCont.sizeOld = $imgBoxCont.actualSize;
3912                            setTimeout(checkResponsive, settings.responsiveCheckTime);
3913                        }
3914
3915                        // ___________________________________________________________________
3916
3917                        function onError() {
3918                            $img.data('imgLiquid_error', true);
3919                            $imgBoxCont.addClass('imgLiquid_error');
3920                            if (settings.onItemError) settings.onItemError($i, $imgBoxCont, $img); /* << CallBack */
3921                            checkFinish();
3922                        }
3923
3924                        // ___________________________________________________________________
3925
3926                        function getSettingsOverwrite() {
3927                            var SettingsOverwrite = {};
3928
3929                            if (imgLiquidRoot.settings.useDataHtmlAttr) {
3930                                var dif = $imgBoxCont.attr('data-imgLiquid-fill'),
3931                                    ha =  $imgBoxCont.attr('data-imgLiquid-horizontalAlign'),
3932                                    va =  $imgBoxCont.attr('data-imgLiquid-verticalAlign');
3933
3934                                if (dif === 'true' || dif === 'false') SettingsOverwrite.fill = Boolean (dif === 'true');
3935                                if (ha !== undefined && (ha === 'left' || ha === 'center' || ha === 'right' || ha.indexOf('%') !== -1)) SettingsOverwrite.horizontalAlign = ha;
3936                                if (va !== undefined && (va === 'top' ||  va === 'bottom' || va === 'center' || va.indexOf('%') !== -1)) SettingsOverwrite.verticalAlign = va;
3937                            }
3938
3939                            if (imgLiquid.isIE && imgLiquidRoot.settings.ieFadeInDisabled) SettingsOverwrite.fadeInTime = 0; //ie no anims
3940                            return SettingsOverwrite;
3941                        }
3942
3943                        // ___________________________________________________________________
3944
3945                        function makeOldProcess() { /* Only for old browsers, or useBackgroun
3945dSize seted false */
3946
3947                            // Calculate size
3948                            var w, h, wn, hn, ha, va, hdif, vdif,
3949                                margT = 0,
3950                                margL = 0,
3951                                $imgCW = $imgBoxCont.width(),
3952                                $imgCH = $imgBoxCont.height();
3953
3954
3955                            // Save original sizes
3956                            if ($img.data('owidth') === undefined) $img.data('owidth',  $img[0].width);
3957                            if ($img.data('oheight') === undefined) $img.data('oheight', $img[0].height);
3958
3959
3960                            // Compare ratio
3961                            if (settings.fill === ($imgCW / $imgCH) >= ($img.data('owidth') / $img.data('oheight'))) {
3962                                w = '100%';
3963                                h = 'auto';
3964                                wn = Math.floor($imgCW);
3965                                hn = Math.floor($imgCW * ($img.data('oheight') / $img.data('owidth')));
3966                            } else {
3967                                w = 'auto';
3968                                h = '100%';
3969                                wn = Math.floor($imgCH * ($img.data('owidth') / $img.data('oheight')));
3970                                hn = Math.floor($imgCH);
3971                            }
3972
3973                            // Align X
3974                            ha = settings.horizontalAlign.toLowerCase();
3975                            hdif = $imgCW - wn;
3976                            if (ha === 'left') margL = 0;
3977                            if (ha === 'center') margL = hdif * 0.5;
3978                            if (ha === 'right') margL = hdif;
3979                            if (ha.indexOf('%') !== -1){
3980                                ha = parseInt (ha.replace('%',''), 10);
3981                                if (ha > 0) margL = hdif * ha * 0.01;
3982                            }
3983
3984
3985                            // Align Y
3986                            va = settings.verticalAlign.toLowerCase();
3987                            vdif = $imgCH - hn;
3988                            if (va === 'left') margT = 0;
3989                            if (va === 'center') margT = vdif * 0.5;
3990                            if (va === 'bottom') margT = vdif;
3991                            if (va.indexOf('%') !== -1){
3992                                va = parseInt (va.replace('%',''), 10);
3993                                if (va > 0) margT = vdif * va * 0.01;
3994                            }
3995
3996
3997                            // Add Css
3998                            if (settings.hardPixels) {w = wn; h = hn;}
3999                            $img.css({
4000                                'width': w,
4001                                'height': h,
4002                                'margin-left': Math.floor(margL),
4003                                'margin-top': Math.floor(margT)
4004                            });
4005
4006
4007                            // FadeIn > Only first time
4008                            if (!$img.data('imgLiquid_oldProcessed')) {
4009                                $img.fadeTo(settings.fadeInTime, 1);
4010                                $img.data('imgLiquid_oldProcessed', true);
4011                               // if (settings.removeBoxBackground) $imgBoxCont.css('background-image', 'none');
4012                                var sourceImage = $img.attr('src');
4013                                $imgBoxCont.css({'background-image': 'url(' + sourceImage + ')'});
4014                                $imgBoxCont.addClass('imgLiquid_nobgSize');
4015                                $imgBoxCont.addClass('imgLiquid_ready');
4016                            }
4017
4018
4019                            if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
4020                            checkFinish();
4021                        }
4022
4023                        // ___________________________________________________________________
4024
4025                        function checkFinish() { /* Check callBack */
4026                            if ($i === imgLiquidRoot.length - 1) if (img
4026LiquidRoot.settings.onFinish) imgLiquidRoot.settings.onFinish();
4027                        }
4028
4029
4030                    });
4031                } //End imgLiquid: function
4032            }); //End $.fn.extend
4033
4034        })(jQuery);
4035
4036        if (typeof window.cff === 'undefined' || typeof window.cff.feeds === 'undefined') {
4037            window.cff = new Cff();
4038            window.cff.createPage(window.cff.createFeeds, {});
4039        }
4040        jQuery(document).ready(function() {
4041            var allInitiated = true;
4042            jQuery('.cff').each(function(index) {
4043                if (typeof window.cff !== 'undefined'
4044                    && typeof window.cff.feeds !== 'undefined'
4045                    && typeof window.cff.feeds[index] === 'undefined' ) {
4046                    allInitiated = false;
4047
4048                }
4049            });
4050
4051            if (!allInitiated) {
4052                window.cff.createPage(window.cff.createFeeds, {});
4053            }
4054
4055            var $ = jQuery;
4056            $('#cookie-notice a').on('click', function() {
4057                setTimeout(function() {
4058                    $.each(window.cff.feeds,function(index){
4059                        window.cff.feeds[ index ].afterConsentToggled();
4060                    });
4061                },1000);
4062            });
4063
4064            // Cookie Notice by dFactory
4065            $('#cookie-law-info-bar a').on('click', function() {
4066                setTimeout(function() {
4067                    $.each(window.cff.feeds,function(index){
4068                        window.cff.feeds[ index ].afterConsentToggled();
4069                    });
4070                },1000);
4071            });
4072
4073            // GDPR Cookie Consent by WebToffee
4074            $('.cli-user-preference-checkbox').on('click', function(){
4075                setTimeout(function() {
4076                    $.each(window.cff.feeds,function(index){
4077                        window.cff.feeds[ index ].settings.consentGiven = false;
4078                        window.cff.feeds[ index ].afterConsentToggled();
4079                    });
4080                },1000);
4081            });
4082
4083            // Cookiebot
4084            $(window).on('CookiebotOnAccept', function (event) {
4085                $.each(window.cff.feeds,function(index){
4086                    window.cff.feeds[ index ].settings.consentGiven = true;
4087                    window.cff.feeds[ index ].afterConsentToggled();
4088                });
4089            });
4090
4091            // Complianz by Really Simple Plugins
4092            $(document).on('cmplzEnableScripts', function (event) {
4093                if ( event.detail === 'marketing' ) {
4094                    $.each(window.cff.feeds,function(index){
4095                        window.cff.feeds[ index ].settings.consentGiven = true;
4096                        window.cff.feeds[ index ].afterConsentToggled();
4097                    });
4098                }
4099            });
4100
4101            // Complianz by Really Simple Plugins
4102            $(document).on('cmplzFireCategories', function (event) {
4103                if ( event.detail.category === 'marketing' ) {
4104                    $.each(window.cff.feeds,function(index){
4105                        window.cff.feeds[ index ].settings.consentGiven = true;
4106                        window.cff.feeds[ index ].afterConsentToggled();
4107                    });
4108                }
4109            });
4110
4111            // Complianz by Really Simple Plugins
4112            $(document).on('cmplzRevoke', function (event) {
4113                $.each(window.cff.feeds,function(index){
4114                    window.cff.feeds[ index ].settings.consentGiven = false;
4115                    window.cff.feeds[ index ].afterConsentToggled();
4116                });
4117            });
4118
4119            // Borlabs Cookie by Borlabs
4120            $(document).on('borlabs-cookie-consent-saved', function (event) {
4121                $.each(window.cff.feeds,function(index){
4122                    window.cff.feeds[ index ].settings.consentGiven = false;
4123                    window.cff.feeds[ index ].afterConsentToggled();
4124                });
4125            });
4126
4127        });
4128
4129        //If a video is wrapped in this element then remove it as it causes an issue with some themes
4130        setTimeout(function(){
4131            jQuery('#cff .embed-responsive video, #cff .embed-responsive iframe').unwrap();
4132        }, 500);
4133
4134
4135        // Inject css styles ______________________________________________________
4136        !function () {
4137            var css = imgLiquid.injectCss,
4138                head = document.getElementsByTagName('head')[0],
4139                style = document.createElement('style');
4140            style.type = 'text/css';
4141            if (style.styleSheet) {
4142                style.styleSheet.cssText = css;
4143            } else {
4144                style.appendChild(document.createTextNode(css));
4145            }
4146            head.appendChild(style);
4147        }();
4148        jQuery('.cff').each(function() {
4149           if (!jQuery(this).hasClass('cff-disable-liquid')) {
4150               jQuery(this).find(".cff-new .cff-album-cover").imgLiquid({fill:true});
4151           }
4152        });
4153        jQuery(".cff-new .cff-crop").imgLiquid({fill:true, useBackgroundSize:true});
4154        jQuery(".cff-header-hero").imgLiquid({fill:true});
4155
4156    } //********* END cff_init() FUNCTION ************//
4157
4158
4159    cff_init();
4160
4161
4162//Get the Access Token from the shortcode so it can be used in the connect file
4163    function cffGetShortcodeToken($cff){
4164        var shortcode_token_param = '';
4165        if ( $cff.attr('data-cff-shortcode') ){
4166            if( $cff.attr('data-cff-shortcode').indexOf('accesstoken') !== -1 ){
4167                var shortcode_att = $cff.attr('data-cff-shortcode'),
4168                    shortcode_att_arr = JSON.parse( shortcode_att );
4169                shortcode_token_param = encodeURI('&at=' + shortcode_att_arr['accesstoken']);
4170            }
4171        }
4172        return shortcode_token_param;
4173    }
4174
4175// Used for linking text in captions
4176    /* JavaScript Linkify - v0.3 - 6/27/2009 - http://benalman.com/projects/javascript-linkify/ */
4177    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}})();
4178
4179//Link #hashtags
4180    function cffReplaceHashtags(hash){
4181        //Remove white space at beginning of hash
4182        var replacementString = jQuery.trim(hash);
4183        //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"
4184        if ( /^#[0-9A-F]{6}$/i.test( replacementString ) ){
4185            return replacementString;
4186        } else {
4187            return '<a href="https://www.facebook.com/hashtag/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener">' + replacementString + '</a>';
4188        }
4189    }
4190//Link @tags
4191    function cffReplaceTags(tag){
4192        var replacementString = jQuery.trim(tag);
4193        return '<a href="https://www.facebook.com/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener">' + replacementString + '</a>';
4194    }
4195    var hashRegex = /[#]+[A-Za-z0-9-_]+/g,
4196        tagRegex = /[@]+[A-Za-z0-9-_]+/g;
4197// End caption linking functions
4198
4199//Encoding comments
4200    function cffEncodeHTML(raw) {
4201        // make sure passed variable is defined
4202        if (typeof raw === 'undefined') {
4203            return '';
4204        }
4205        // replace greater than and less than symbols with html entity to disallow html in comments
4206        var encoded = raw.replace(/(>)/g,'&gt;'),
4207            encoded = encoded.replace(/(<)/g,'&lt;');
4208        encoded = encoded.replace(/(&lt;br\/&gt;)/g,'<br>');
4209        encoded = encoded.replace(/(&lt;br&gt;)/g,'<br>');
4210
4211        return encoded;
4212    }
4213
4214
4215//Load comment replies using Ajax
4216    function cffLoadCommentReplies( $this ){
4217
4218        var usegrouptoken = '',
4219            useowntoken = '',
4220            $cffClosestContainer = jQuery('#cff_'+$this.parent().attr('data-id')).closest('#cff');
4221        if( $cffClosestContainer.hasClass('cff-group') ) usegrouptoken = '&usegrouptoken=true';
4222        if( $cffClosestContainer.attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
4223
4224        //Get the token from the shortcode
4225        var cff_page_id = $this.closest('.cff-item').attr('data-page-id'),
4226            shortcode_token_param = cffGetShortcodeToken( $cffClosestContainer ),
4227            $commentReplies = $this.parent(),
4228            $commentRepliesBox = $commentReplies.siblings('.cff-comment-replies-box'),
4229            comments_url = cffsiteurl + "/custom-facebook-feed-pro/comments.php?id=" + $commentReplies.attr('data-id') + usegrouptoken + useowntoken + '&pageid=' + cff_page_id + shortcode_token_param;
4230
4231        if( $commentReplies.hasClass('cff-hide') ){
4232
4233            $commentRepliesBox.hide();
4234            $commentReplies.removeClass('cff-hide');
4235
4236        } else {
4237
4238            $commentRepliesBox.show();
4239            $commentReplies.addClass('cff-hide');
4240
4241            //If the replies haven't been retrieved yet then get them, otherwise just show the existing ones again
4242            if( $commentRepliesBox.hasClass('cff-empty') ){
4243
4244                //Display loader
4245                var $commentRepliesA = $commentReplies.find('a');
4246                $commentRepliesA.append('<div class="cff-loader"></div>');
4247                $commentReplies.find('.cff-loader').css('background-color', $commentRepliesA.css('color'));
4248
4249                var submitData = {
4250                    action: 'cff_comments',
4251                    id: $commentReplies.attr('data-id'),
4252                    pageid: cff_page_id,
4253                };
4254                if( $cffClosestContainer.hasClass('cff-group') ){
4255                    submitData.usegrouptoken = true;
4256                }
4257                if( $cffClosestContainer.attr('data-own-token') == 'true' ) {
4258                    submitData.useowntoken = true;
4259                }
4260                if( shortcode_token_param !== '' ){
4261                    var token = shortcode_token_param.split('=');
4262                    submitData.at = token[1];
4263                }
4264
4265                var onSuccess = function(data) {
4266
4267                    //Remove loader
4268                    $commentReplies.find('.cff-loader').remove();
4269
4270                    //Convert string of data received from comments.php to a JSON object
4271                    var data = JSON.parse( data ),
4272                        allComments = '';
4273
4274                    if( typeof data.comments !== 'undefined' ){
4275                        jQuery.each(data.comments.data, function(i, commentItem) {
4276                            var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4277
4278                            //Check whether comment author info exists - only accessible with page access token from the page now
4279                            var cff_comment_author_info = true;
4280                            if( typeof commentItem.from !== 'undefined' ){
4281                                cff_comment_from_id = commentItem.from.id;
4282                            } else {
4283                                cff_comment_author_info = false;
4284                                cff_comment_from_id = '';
4285                            }
4286
4287
4288                            allComments += '<div class="cff-comment-reply" id="cff_'+commentItem.id+'"><div class="cff-comment-text-wrapper"><div class="cff-comment-text';
4289                            if(!cff_comment_author_info) allComments += ' cff-no-name';
4290                            allComments += '"><p>';
4291
4292
4293                            if(cff_comment_author_info){
4294                                if( typeof commentItem.from.link != 'undefined' ){
4295                                    allComments += '<a href="http://facebook.com/'+commentItem.from.id+'" class="cff-name" target="_blank" rel="nofollow noopener">
4295'+commentItem.from.name+'</a>';
4296                                } else {
4297                                    allComments += '<span class="cff-name">'+commentItem.from.name+'</span>';
4298                                }
4299                            }
4300
4301
4302                            var cffCommentMessage = cffEncodeHTML(commentItem.message);
4303                            allComments += cffCommentMessage;
4304
4305                            //Show like count if exists
4306                            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>
4306'+commentItem.like_count+'</span></span>';
4307
4308                            allComments += '</p>';
4309
4310                            //Add image attachment if exists
4311                            if( typeof commentItem.attachment !== 'undefined' ) {
4312                                if (consentGiven) {
4313                                    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>';
4314                                } else {
4315                                    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>';
4316                                }
4317                            }
4318
4319                            allComments += '</div></div>';
4320                            if(cff_comment_author_info) {
4321                                if (consentGiven) {
4322                                    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>';
4323                                } else {
4324                                    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>';
4325                                }
4326                            }
4327                            allComments += '</div>';
4328                        });
4329                    }
4330
4331                    $commentRepliesBox.html(allComments).removeClass('cff-empty');
4332
4333                    //Re-init masonry layout when loading comment replies
4334                    if( $this.closest('#cff').hasClass('cff-masonry-js') && !$this.closest('#cff').hasClass('cff-masonry-css') && !$this.closest('#cff').hasClass('cff-opaque-comments') ){
4335                        cffAddMasonry( $this.closest('#cff') );
4336                    }
4337
4338                };
4339                cffAjax(submitData,onSuccess);
4340
4341            } //End if
4342
4343        } //End if/else
4344
4345    } // End cffLoadCommentReplies()
4346
4347
4348
4349
4350    function cffLightbox(){
4351        /**
4352         * Lightbox v2.7.1
4353         * by Lokesh Dhakar - http://lokeshdhakar.com/projects/lightbox2/
4354         *
4355         * @license http://creativecommons.org/licenses/by/2.5/
4356         * - Free for use in both personal and commercial projects
4357         * - Attribution requires leaving author name, author link, and the license info intact
4358         */
4359
4360        (function() {
4361            // Use local alias
4362            var $ = jQuery;
4363
4364            var LightboxOptions = (function() {
4365                function LightboxOptions() {
4366                    this.fadeDuration                = 300;
4367                    this.fitImagesInViewport         = true;
4368                    this.resizeDuration              = 400;
4369                    this.positionFromTop             = 50;
4370                    this.showImageNumberLabel        = true;
4371                    this.alwaysShowNavOnTouchDevices = false;
4372                    this.wrapAround                  = false;
4373                }
4374
4375                // Change to localize to non-english language
4376                LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
4377                    return curImageNum + " / " + albumSize;
4378                };
4379
4380                return LightboxOptions;
4381            })();
4382
4383
4384            var Lightbox = (function() {
4385                function Lightbox(options) {
4386                    this.options           = options;
4387                    this.album             = [];
4388                    this.currentImageIndex = void 0;
4389                    this.init();
4390                }
4391
4392                Lightbox.prototype.init = function() {
4393                    this.enable();
4394                    this.build();
4395                };
4396
4397                // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
4398                // that contain 'cff-lightbox'. When these are clicked, start lightbox.
4399                Lightbox.prototype.enable = function() {
4400                    var self = this;
4401                    $('body').on('click', 'a[data-cff-lightbox], area[data-cff-lightbox]', function(event) {
4402                        self.start($(event.currentTarget));
4403                        return false;
4404                    });
4405                };
4406
4407                // Build html for the lightbox and the overlay.
4408                // Attach event handlers to the new DOM elements.
4409                Lightbox.prototype.build = function() {
4410                    //Disable SVG icons?
4411                    var cff_lightbox_svg_class = '';
4412                    if( $('.cff.cff-no-svgs').length ) cff_lightbox_svg_class = 'cff-no-svgs';
4413
4414                    var self = this;
4415                    $("<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'));
4416
4417                    // Make sure hammer is defined somehow
4418                    if (typeof jQuery("#cff-lightbox-wrapper").find(".cff
4418-lightbox-dataContainer").hammer !== 'function') {
4419                        var Hammer = {
4420                            Manager: {
4421                                prototype: {}
4422                            }
4423                        };
4424                        (function (factory) {
4425                            if (typeof define === 'function' && define.amd) {
4426                                define(['jquery', 'hammerjs'], factory);
4427                            } else if (typeof exports === 'object') {
4428                                factory(require('jquery'), require('hammerjs'));
4429                            } else {
4430                                factory(jQuery, Hammer);
4431                            }
4432                        }(function (jQuery, Hammer) {
4433                            function hammerify(el, options) {
4434                            }
4435
4436                            jQuery.fn.hammer = function (options) {
4437                                return this.each(function () {
4438                                    hammerify(this, options);
4439                                });
4440                            };
4441                            // extend the emit method to also trigger jQuery events
4442                            Hammer.Manager.prototype.emit = (function (originalEmit) {
4443                                return function (type, data) {
4444                                    originalEmit.call(this, type, data);
4445                                    jQuery(this.element).trigger({
4446                                        type: type,
4447                                        gesture: data
4448                                    });
4449                                };
4450                            })(Hammer.Manager.prototype.emit);
4451                        }));
4452                    }
4453
4454                    // Cache jQuery objects
4455                    this.$lightbox       = $('#cff-lightbox-wrapper');
4456                    this.$overlay        = $('#cff-lightbox-overlay');
4457                    this.$outerContainer = this.$lightbox.find('.cff-lightbox-outerContainer');
4458                    this.$container      = this.$lightbox.find('.cff-lightbox-container');
4459
4460                    // Store css values for future lookup
4461                    this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10);
4462                    this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10);
4463                    this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10);
4464                    this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10);
4465
4466                    // Attach event handlers to the newly minted DOM elements
4467                    this.$overlay.hide().on('click', function() {
4468                        self.end();
4469                        if( cff_supports_video() && $('#cff-lightbox-wrapper video.cff-lightbox-video').length ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4470                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4471                        if ($('body').length) {
4472                            $('body').removeClass('cff_no_scroll');
4473                        }
4474                        return false;
4475                    });
4476
4477
4478                    this.$lightbox.hide().on('click', function(event) {
4479                        self.album.length = 0;
4480                        if ($(event.target).attr('id') === 'cff-lightbox-wrapper') {
4481                            self.end();
4482                            if( cff_supports_video() && $('#cff-lightbox-wrapper video.cff-lightbox-video').length ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4483                            $('#cff-lightbox-wrapper iframe').attr('src', '');
4484                            if ($('body').length) {
4485                                $('body').removeClass('cff_no_scroll');
4486                            }
4487                        }
4488                        return false;
4489                    });
4490                    this.$outerContainer.on('click', function(event) {
4491                        if ($(event.target).attr('id') === 'cff-lightbox-wrapper') {
4492                            self.album.length = 0;
4493                            self.end();
4494                            if( cff_supports_video() && $('#cff-lightbox-wrapper video.cff-lightbox-video').length ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4495                            $('#cff-lightbox-wrapper iframe').attr('src', '');
4496                        }
4497                        return false;
4498                    });
4499
4500
4501                    this.$lightbox.find('.cff-lightbox-prev').on('click', function() {
4502                        if (self.currentImageIndex === 0) {
4503                            self.changeImage(self.album.length - 1);
4504                        } else {
4505                            self.changeImage(self.currentImageIndex - 1);
4506                        }
4507                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4508                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4509                        return false;
4510                    });
4511
4512                    this.$lightbox.find('.cff-lightbox-next').on('click', function() {
4513                        if (self.currentImageIndex === self.album.length - 1) {
4514                            self.changeImage(0);
4515                        } else {
4516                            self.changeImage(self.currentImageIndex + 1);
4517                        }
4518                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4519                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4520                        return false;
4521                    });
4522
4523                    this.$lightbox.find('.cff-lightbox-outerContainer').hammer().on("swipeleft", function() {
4524                        if (self.currentImageIndex === self.album.length - 1) {
4525                            self.changeImage(0);
4526                        } else {
4527                            self.changeImage(self.currentImageIndex + 1);
4528                        }
4529                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4530                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4531                        return false;
4532                    });
4533
4534                    this.$lightbox.find('.cff-lightbox-outerContainer').hammer().on("swiperight", function() {
4535                        if (self.currentImageIndex === 0) {
4536                            self.changeImage(self.album.length - 1);
4537                        } else {
4538                            self.changeImage(self.currentImageIndex - 1);
4539                        }
4540                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4541                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4542                        return false;
4543                    });
4544
4545                    //CHANGE IMAGE ON THUMB CLICK
4546                    $('.cff-lightbox-thumbs').on('click', '.cff-lightbox-attachment', function (){
4547                        var $thumb = $(this),
4548                            $thumbImg = $thumb.find('img'),
4549                            captionText = $thumb.attr('data-caption');
4550
4551                        if(captionText == '' || captionText == 'undefined') captionText = $thumb.attr('orig-caption');
4552
4553                        //Pass image URL, width and height to the change image function
4554                        self.changeImage(parseInt( $thumb.attr('data-cff-lightbox-order') ), $thumb.attr('href'), $thumbImg.attr('width'), $thumbImg.attr('height'), $thumb.attr('data-facebook'), captionText);
4555                        return false;
4556                    });
4557
4558
4559                    this.$lightbox.find('.cff-lightbox-loader, .cff-lightbox-close').on('click', function() {
4560                        self.album.length = 0;
4561                        self.end();
4562                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4563                        $('#cff-lightbox-wrapper iframe').attr('src', '');
4564                        if ($('body').length) {
4565                            $('body').removeClass('cff_no_scroll');
4566                        }
4567                        return false;
4568                    });
4569
4570                }; //End build()
4571
4572                // Show overlay and lightbox. If the image is part of a set, add siblings to album array.
4573                Lightbox.prototype.start = function($link) {
4574                    var self    = this;
4575                    var $window = $(window);
4576
4577                    $window.on('resize', $.proxy(this.sizeOverlay, this));
4578
4579                    if ($('body').length) {
4580                        $('body').addClass('cff_no_scroll');
4581                    }
4582
4583                    $('select, object, embed').css({
4584                        visibility: "hidden"
4585                    });
4586
4587                    this.sizeOverlay();
4588
4589                    //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
4590                    if(this.album.length == 0) this.album = [];
4591                    var imageNumber = 0;
4592
4593                    function addToAlbum($link) {
4594
4595                        if( !$link.closest('.cff-posts-wrap').hasClass('cff_owl-carousel') ) {
4596                            var albumClassName = $link.closest('.cff-posts-wrap').children('div').attr('class');
4597                        } else {
4598                            var albumClassName = $link.closest('.cff-posts-wrap .cff_owl-item').children('div').attr('class');
4599                        }
4600
4601                        linkParentPostID = '';
4602
4603                        if ( typeof albumClassName !== 'undefined' ) {
4604                            linkParentPostID = $link.closest('.'+albumClassName.split(' ')[0]).attr('id');
4605                            linkParentPostID = (linkParentPostID !== 'undefined') ? linkParentPostID.replace('cff_','') : linkParentPostID;
4606                        }
4607
4608                        //If an image with the same href has already been added then don't add it to the lightbox order again
4609                        var found = false;
4610                        $.each(self.album, function(i, imageitem) {
4611                            if( ( imageitem.link == $link.attr('href') ) && ( imageitem.postid == linkParentPostID ) ){
4612                                found = true;
4613                                return;
4614                            }
4615                        });
4616                        //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.
4617                        if( !$('.cff-duplicate-video-thumbnails').length ) if(found == true) return;
4618                        var closestFeedIndex = parseInt($link.closest('.cff').attr('data-cff-index')-1);
4619
4620                        var video = $link.attr("data-video"),
4621                            iframe = $link.attr('data-iframe'),
4622                            link = $link.attr("href"),
4623                            count = 0;
4624                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4625                        if (!consentGiven) {
4626                            if (iframe !== '') {
4627                                iframe = 'link';
4628                            }
4629                            if (video !== '') {
4630                                video = 'link';
4631                            }
4632                            if ($link.closest('.cff-album-item').length
4633                                && typeof $link.closest('.cff-album-item').attr('data-count') !== 'undefined') {
4634                                count = $link.closest('.cff-album-item').attr('data-count');
4635                            }
4636                        }
4637                        self.album.push({
4638                            link: link,
4639                            title: $link.attr('data-title') || $link.attr('title'),
4640                            postid: $link.attr('data-id'),
4641                            showthumbs: $link.attr('data-thumbs'),
4642                            facebookurl: $link.attr('data-url'),
4643                            video: video,
4644                            iframe: iframe,
4645                            type: $link.attr('data-type'),
4646                            cffgroupalbums: $link.attr('data-cffgroupalbums'),
4647                            isthumbnail: $link.attr('data-cff-isthumbnail'),
4648                            pagename: $link.parent().attr('data-cff-page-name'),
4649                            posttime: $link.parent().attr('data-cff-post-time'),
4650                            lbcomments: $link.attr('data-lb-comments'),
4651                            feedIndex: closestFeedIndex,
4652                            count: count
4653                        });
4654                    }
4655
4656                    // Support both data-lightbox attribute and rel attribute implementations
4657                    var dataLightboxValue = $link.attr('data-cff-lightbox');
4658                    var $links;
4659
4660                    if (dataLightboxValue) {
4661                        $links = $($link.prop("tagName") + '[data-cff-lightbox="' + dataLightboxValue + '"]');
4662                        for (var i = 0; i < $links.length; i = ++i) {
4663                            addToAlbum($($links[i]));
4664                            if ($links[i] === $link[0]) {
4665                                imageNumber = i;
4666
4667                                //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.
4668                                $.each(self.album, function(i, image) {
4669                                    if( (image.postid == $link.attr('data-id')) && image.isthumbnail != true ) imageNumber = i;
4670                                });
4671                            }
4672                        }
4673                    } else {
4674                        if ($link.attr('rel') === 'lightbox') {
4675                            // If image is not part of a set
4676                            addToAlbum($link);
4677                        } else {
4678                            // If image is part of a set
4679                            $links = $($link.prop("tagName") + '[rel="' + $link.attr('rel') + '"]');
4680                            for (var j = 0; j < $links.length; j = ++j) {
4681                                addToAlbum($($links[j]));
4682                                if ($links[j] === $link[0]) {
4683                                    imageNumber = j;
4684                                }
4685                            }
4686                        }
4687                    }
4688
4689                    // Position Lightbox
4690                    var top  = $window.scrollTop() + this.options.positionFromTop;
4691                    var left = $window.scrollLeft();
4692                    this.$lightbox.css({
4693                        top: top + 'px',
4694                        left: left + 'px'
4695                    }).fadeIn(this.options.fadeDuration);
4696
4697                    this.changeImage(imageNumber);
4698                };
4699
4700                // Hide most UI elements in preparation for the animated resizing of the lightbox.
4701                Lightbox.prototype.changeImage = function(imageNumberVal, imageUrl, imgWidth, imgHeight, facebookLink, captionText) {
4702                    var self = this,
4703                        isThumb = false,
4704                        bottomPadding = 120;
4705
4706                    imageNumber = imageNumberVal;
4707
4708                    //Is this a thumb being clicked?
4709                    if(typeof imageUrl !== 'undefined') isThumb = true;
4710
4711                    this.disableKeyboardNav();
4712                    var $image = this.$lightbox.find('.cff-lightbox-image');
4713
4714                    this.$overlay.fadeIn(this.options.fadeDuration);
4715
4716                    $('.cff-lightbox-loader').fadeIn('slow');
4717                    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();
4718
4719                    this.$outerContainer.addClass('animating');
4720
4721
4722                    // When image to show is preloaded, we send the width and height to sizeContainer()
4723                    var preloader = new Image();
4724                    preloader.onload = function() {
4725                        var $preloader, imageHeight, imageWidth, maxImageHeight, maxImageWidth, windowHeight, windowWidth;
4726
4727                        $image.attr('src', self.album[imageNumber].link);
4728
4729                        /*** THUMBS ***/
4730                        //Change the main image when it's a thumb that's being clicked
4731                        if(isThumb){
4732                            $image.attr('src', imageUrl);
4733                            $('.cff-lightbox-facebook').attr('href', facebookLink);
4734                            $('.cff-lightbox-caption .cff-lightbox-caption-text').html(captionText);
4735
4736                            //Set width and height of image when thumb is clicked
4737                            preloader.width = imgWidth;
4738                            preloader.height = imgHeight;
4739
4740                            //Increase bottom padding to make room for at least one row of thumbs
4741                            bottomPadding = 180;
4742                        }
4743                        /*** THUMBS ***/
4744
4745                        $preloader = $(preloader);
4746
4747                        $image.width(preloader.width);
4748                        $image.height(preloader.height);
4749
4750                        if (self.options.fitImagesInViewport) {
4751                            // Fit image inside the viewport.
4752                            // Take into account the border around the image and an additional 10px gutter on each side.
4753                            windowWidth    = $(window).width();
4754                            windowHeight   = $(window).height();
4755
4756                            //If this feed has lightbox comments enabled then add room for the sidebar
4757                            var cff_lb_comments_width = 0,
4758                                cffNavArrowsWidth = 80;
4759
4760                            if( $('#cff_' + self.album[0].postid).closest('#cff').attr('data-lb-comments') == 'true' && windowWidth > 640 ) cff_lb_comments_width = 300;
4761
4762                            //Use narrower arrows on mobile
4763                            if(window.innerWidth < 640) cffNavArrowsWidth = 40;
4764
4765                            maxImageWidth  = windowWidth - self.containerLeftPadding - self.containerRightPadding - 20 - cff_lb_comments_width - cffNavArrowsWidth;
4766                            maxImageHeight = windowHeight - self.containerTopPadding - self.containerBottomPadding - bottomPadding;
4767
4768                            // Is there a fitting issue?
4769                            if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) {
4770                                if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) {
4771                                    imageWidth  = maxImageWidth;
4772                                    imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10);
4773                                    $image.width(imageWidth);
4774                                    $image.height(imageHeight);
4775                                } else {
4776                                    imageHeight = maxImageHeight;
4777                                    imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10);
4778                                    $image.width(imageWidth);
4779                                    $image.height(imageHeight);
4780                                }
4781                            }
4782                        }
4783
4784                        //Pass the width and height of the main image
4785                        self.sizeContainer($image.width(), $image.height());
4786
4787                    };
4788
4789                    preloader.src          = this.album[imageNumber].link;
4790                    this.currentImageIndex = imageNumber;
4791                };
4792
4793                // Stretch overlay to fit the viewport
4794                Lightbox.prototype.sizeOverlay = function() {
4795                    this.$overlay
4796                        .width($(window).width())
4797                        .height($(document).height());
4798                };
4799
4800                // Animate the size of the lightbox to fit the image we are showing
4801                Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
4802                    var self = this;
4803
4804                    var oldWidth  = this.$outerContainer.outerWidth();
4805                    var oldHeight = this.$outerContainer.outerHeight();
4806                    var newWidth  = imageWidth + this.containerLeftPadding + this.containerRightPadding;
4807                    var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding;
4808
4809                    function postResize() {
4810                        self.$lightbox.find('.cff-lightbox-dataContainer').width(newWidth);
4811                        self.$lightbox.find('.cff-lightbox-prevLink').height(newHeight);
4812                        self.$lightbox.find('.cff-lightbox-nextLink').height(newHeight);
4813                        self.showImage();
4814                    }
4815
4816                    if (oldWidth !== newWidth || oldHeight !== newHeight) {
4817                        this.$outerContainer.animate({
4818                            width: newWidth,
4819                            height: newHeight
4820                        }, this.options.resizeDuration, 'swing', function() {
4821                            postResize();
4822                        });
4823                    } else {
4824                        postResize();
4825                    }
4826                };
4827
4828                // Display the image and it's details and begin preload neighboring images.
4829                Lightbox.prototype.showImage = function() {
4830                    this.$lightbox.find('.cff-lightbox-loader').hide();
4831                    this.$lightbox.find('.cff-lightbox-image').fadeIn('slow');
4832
4833                    this.updateNav();
4834                    this.updateDetails();
4835                    this.preloadNeighboringImages();
4836                    this.enableKeyboardNav();
4837                };
4838
4839                // Display previous and next navigation if appropriate.
4840                Lightbox.prototype.updateNav = function() {
4841                    // Check to see if the browser supports touch events. If so, we take the conservative approach
4842                    // and assume that mouse hover events are not supported and always show prev/next navigation
4843                    // arrows in image sets.
4844                    var alwaysShowNav = false;
4845                    try {
4846                        document.createEvent("TouchEvent");
4847                        alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices)? true: false;
4848                    } catch (e) {}
4849
4850                    this.$lightbox.find('.cff-lightbox-nav').show();
4851
4852                    if (this.album.length > 1) {
4853                        if (this.options.wrapAround) {
4854                            if (alwaysShowNav) {
4855                                this.$lightbox.find('.cff-lightbox-prev, .cff-lightbox-next').css('opacity', '1');
4856                            }
4857                            this.$lightbox.find('.cff-lightbox-prev, .cff-lightbox-next').show();
4858                        } else {
4859                            if (this.currentImageIndex > 0) {
4860                                this.$lightbox.find('.cff-lightbox-prev').show();
4861                                if (alwaysShowNav) {
4862                                    this.$lightbox.find('.cff-lightbox-prev').css('opacity', '1');
4863                                }
4864                            }
4865                            if (this.currentImageIndex < this.album.length - 1) {
4866                                this.$lightbox.find('.cff-lightbox-next').show();
4867                                if (alwaysShowNav) {
4868                                    this.$lightbox.find('.cff-lightbox-next').css('opacity', '1');
4869                                }
4870                            }
4871                        }
4872                    }
4873                };
4874
4875                var thumbsArr = {};
4876
4877                // Display caption, image number, and closing button.
4878                Lightbox.prototype.updateDetails = function() {
4879                    var self = this;
4880                    var origCaption = '';
4881
4882                    this.$lightbox.find('.cff-lightbox-nav, .cff-lightbox-nav a').show();
4883
4884                    /** NEW PHOTO ACTION **/
4885
4886                    //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
4886)
4887                    if( $('.cff-lightbox-video').length == 0 ) $('.cff-lightbox-container').prepend("<video class='cff-lightbox-video' src='' poster='' controls></video>");
4888
4889                    //Switch video when either a new popup or navigating to new one
4890                    if( cff_supports_video() ){
4891                        $('#cff-lightbox-wrapper').removeClass('cff-has-video');
4892
4893                        if (typeof this.album[this.currentImageIndex].video !== 'undefined'
4894                            && this.album[this.currentImageIndex].video !== 'link'){
4895                            if( this.album[this.currentImageIndex].video.length ){
4896
4897                                $('#cff-lightbox-wrapper').addClass('cff-has-video');
4898                                $('.cff-lightbox-video').attr({
4899                                    'src' : this.album[this.currentImageIndex].video,
4900                                    'poster' : this.album[this.currentImageIndex].link,
4901                                    'autoplay' : 'true'
4902                                });
4903                            }
4904                        }
4905
4906                    }
4907
4908                    var iframeIsLink = false;
4909                    if (this.album[this.currentImageIndex].iframe === 'link') {
4910                        iframeIsLink = true;
4911                    }
4912                    if ((this.album[this.currentImageIndex].video === 'link' || iframeIsLink)
4913                        && ! jQuery(".cff-lightbox-container .cff_gdpr_notice").length) {
4914                        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>')
4915                    } else if (this.album[this.currentImageIndex].video !== 'link' && !iframeIsLink) {
4916                        jQuery('.cff_gdpr_notice').remove();
4917                    } else if (jQuery(".cff-lightbox-container .cff_gdpr_notice").length) {
4918                        jQuery(".cff-lightbox-container .cff_gdpr_notice").attr('href',this.album[this.currentImageIndex].facebookurl);
4919                    }
4920
4921                    //***LIGHTBOX COMMENTS***
4922                    //Enable/disable lightbox comments. If it's a lightbox thumbnail then check whether the parent post has lb_comments enabled/disabled.
4923                    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;
4924
4925                    if( $(window).width() <= 640 ) cff_lb_comments = false;
4926
4927                    //Add lightbox sidebar
4928                    if( cff_lb_comments ){
4929                        var lb_post_id = this.album[this.currentImageIndex].postid,
4930                            page_id = lb_post_id.split('_')[0],
4931                            author_name = this.album[this.currentImageIndex].pagename,
4932                            date_in_correct_format = this.album[this.currentImageIndex].posttime,
4933                            $lightbox_sidebar = $('.cff-lightbox-container .cff-lightbox-sidebar'),
4934                            $lightbox_thumbs_holder = $('.cff-lightbox-thumbs-holder'),
4935                            from_id = $( '#cff_'+this.album[this.currentImageIndex].postid ).attr('data-cff-from');
4936
4937                        //Add class to the lightbox container
4938                        $('.cff-lightbox-wrapper').addClass('cff-enable-lb-comments');
4939
4940                        //Adjust width to make room for the sidebar
4941                        $('.cff-lightbox-dataContainer').css( 'width', $('.cff-lightbox-dataContainer').innerWidth() + 300 );
4942                        $lightbox_sidebar.css('display', 'block');
4943
4944                        //If the from info isn't available then dis
4944play a placeholder avatar and the date
4945                        var cff_post_author = "";
4946                        var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4947                        if( consentGiven && typeof from_id !== 'undefined' ){
4948                            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>";
4949                        } else {
4950                            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>";
4951                        }
4952
4953                        //Remove the close button from the bottom of lightbox as it's added to the top of the sidebar
4954                        $('.cff-lightbox-dataContainer .cff-lightbox-close').remove();
4955
4956                        $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 );
4957
4958                        this.$lightbox.find('.cff-lightbox-close').on('click', function() {
4959                            self.end();
4960                            self.album.length = 0;
4961                            if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
4962                            $('#cff-lightbox-wrapper iframe').attr('src', '');
4963                            if ($('body').length) {
4964                                $('body').removeClass('cff_no_scroll');
4965                            }
4966                            return false;
4967                        });
4968
4969                        //Use a timeout to delay this as the thumbs aren't added till further down
4970                        setTimeout(function(){
4971                            if( $lightbox_thumbs_holder.find('a').length > 1 ){
4972                                $lightbox_sidebar.find('.cff-page-name a').text( $lightbox_thumbs_holder.find('a.cff-selected').attr('data-page-name') );
4973                                $lightbox_sidebar.find('.cff-date').text( $lightbox_thumbs_holder.find('a.cff-selected').attr('data-post-date') );
4974                            }
4975                        }, 0);
4976
4977                        //Bump the thumbs section up if the sidebar section is enabled as there's no caption under the photo
4978                        $lightbox_thumbs_holder.css('margin-top', -10);
4979
4980                        //If the "__ likes this" text is too long then bump it onto the next line
4981                        if( $lightbox_sidebar.find('.cff-reactions-count').innerWidth() > 150 ){
4982                            $lightbox_sidebar.find('.cff-likes-this-text').addClass('cff-long');
4983                        }
4984
4985                        //Add comment avatars
4986                        $lightbox_sidebar.find('.cff-comment:visible').each(function(){
4987                            var $thisComment = jQuery(this);
4988                            var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
4989                            if (consentGiven) {
4990                                $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\'" />' );
4991                            }
4992
4993                        });
4994
4995                        //Load comment replies
4996                        $lightbox_sidebar.find('.cff-comment-replies a').on('click', function(){
4997                            cffLoadCommentReplies( $(this) );
4998                        });
4999
5000                        $lightbox_sidebar.find('.cff-show-more-comments a').attr('href', $lightbox_sidebar.find('.cff-comment-on-facebook a').attr('href') );
5001
5002                    } else { //End add lightbox sidebar
5003
5004                        //Disable lightbox
5005                        $('.cff-lightbox-wrapper .cff-lightbox-sidebar').html('');
5006                        $('.cff-lightbox-wrapper').removeClass('cff-enable-lb-comments');
5007
5008                    }
5009                    //***END LIGHTBOX COMMENTS***
5010
5011
5012
5013                    $('#cff-lightbox-wrapper').removeClass('cff-has-iframe cff-fb-player cff-has-thumbs');
5014
5015                    //If it's an iframe video (embed or FB video player)
5016                    if( typeof this.album[this.currentImageIndex].iframe !== 'undefined' ){
5017                        if( this.album[this.currentImageIndex].iframe.length && this.album[this.currentImageIndex].iframe !== 'link'){
5018                            var videoURL = this.album[this.currentImageIndex].iframe;
5019                            $('#cff-lightbox-wrapper').addClass('cff-has-iframe');
5020
5021                            if( videoURL.indexOf("https://www.facebook.com/v2.3/plugins/video.php?") !=-1 ) $('#cff
5021-lightbox-wrapper').addClass('cff-fb-player');
5022
5023                            //If it's a swf then don't add the autoplay parameter. This is only for embedded videos like YouTube or Vimeo.
5024                            if( videoURL.indexOf(".swf") > -1 || videoURL.indexOf("&autoplay=1") !=-1 ){
5025                                var autoplayParam = '';
5026                            } else {
5027                                var autoplayParam = '?autoplay=1';
5028                            }
5029
5030                            //Add a slight delay before adding the URL else it doesn't autoplay on Firefox
5031                            var vInt = setTimeout(function() {
5032                                $('#cff-lightbox-wrapper iframe').attr({
5033                                    'src' : videoURL + autoplayParam + "&mute=0"
5034                                });
5035                            }, 500);
5036                        }
5037                    }
5038
5039                    //Check whether it's a thumbnail image that's currently being shown in the lightbox
5040                    var isThumbnail = false;
5041                    if( this.album[this.currentImageIndex].isthumbnail ) isThumbnail = true;
5042
5043                    //Remove existing thumbs unless it's a thumbnail image which is being navigated through in which case keep the existing thumbnails
5044                    if( !isThumbnail ) $('.cff-lightbox-thumbs-holder').empty().removeClass('cff-animate');
5045
5046                    //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
5047                    if( this.album[this.currentImageIndex].link == $('.cff-lightbox-image').attr('src') ){
5048                        $('.cff-lightbox-facebook').attr('href', this.album[this.currentImageIndex].facebookurl);
5049                    }
5050
5051                    //Show thumbs area if there are thumbs
5052                    if( this.album[this.currentImageIndex].showthumbs == 'true' ){
5053                        $('.cff-lightbox-thumbs').show();
5054
5055                        //Get the post ID
5056                        var thisPostId = this.album[this.currentImageIndex].postid,
5057                            albumInfo = '',
5058                            albumThumbs = '',
5059                            albumsonly = false;
5060                        if( this.album[this.currentImageIndex].type == 'albumsonly' ) albumsonly = true;
5061
5062
5063                        if( typeof thumbsArr[thisPostId] !== 'undefined' ){
5064
5065                            //load them in from array in local var
5066                            $.each(thumbsArr[thisPostId], function(i, thumb) {
5067                                var origCaption = thumb[5].replace(/"/g, '&quot;');
5068
5069                                //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.
5070                                var albumIndex = 0;
5071                                $.each(self.album, function(i, albumItem) {
5072                                    if( albumItem.postid == thisPostId ){
5073                                        albumIndex = i;
5074                                        //Once found the first match exit the loop
5075                                        return false;
5076                                    }
5077                                });
5078
5079                                var lightboxImageOrder = (parseInt(albumIndex)+parseInt(i));
5080
5081                                //If the small thumb isn't defined (like in regular posts) then use the full image instead
5082                                if( typeof thumb[8] == 'undefined' ) thumb[8] = thumb[0];
5083                                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 ';
5084
5085                                (albumsonly) ? albumThumbs += 'data-type="albumsonly" ' : albumThumbs += 'data-type ';
5086                                albumThumbs += 'data-cff-isthumbnail="true"><img src="'+thumb[8]+'" width="'+thumb[1]+'" height="'+thumb[2]+'" /></a>';
5087
5088                                //Add all of the thumbs (apart from the first thumb) to the lightbox order
5089                                if( i > 0 ){
5090                                    cffInsertLightboxImage(lightboxImageOrder, thumb[0], thumb[4], thumb[3], thisPostId, albumsonly, true, thumb[6], thumb[7], thumb[8]);
5091                                }
5092                            });
5093
5094                            //Add thumbs to the page
5095                            $('.cff-lightbox-thumbs-holder').html( '<div class="cff-lightbox-thumbs-wrap">' + albumThumbs + '</div>' ).addClass('cff-animate');
5096                            $('.cff-lightbox-wrapper').addClass('cff-has-thumbs');
5097
5098                            //Liquidfill the thumbs
5099                            jQuery(".cff-lightbox-thumbs-holder a").imgLiquid({fill:true, useBackgroun
5099dSize:true});
5100
5101                            //Hide the loader
5102                            $('.cff-loader').hide();
5103                            $('.cff-lightbox-thumbs-holder').css('min-height', 0);
5104
5105                        } else {
5106                            //Use ajax to get them from Facebook API
5107
5108                            //Set paths for thumbs.php
5109                            if (typeof cffsiteurl === 'undefined' || cffsiteurl == '') cffsiteurl = window.location.host + '/wp-content/plugins';
5110
5111                            //Get the token from the shortcode
5112                            var $cffClosest = $('#cff_'+thisPostId).closest('.cff'),
5113                                cff_page_id = $('#cff_'+thisPostId).attr('data-page-id'),
5114                                shortcode_token_param = cffGetShortcodeToken( $cffClosest ),
5115                                useowntoken = '';
5116                            if( $cffClosest.attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
5117
5118                            //AJAX
5119                            var cffAttachmentsUrl = cffsiteurl + "/custom-facebook-feed-pro/thumbs.php?id=" + thisPostId + '&pageid=' + cff_page_id + useowntoken + shortcode_token_param,
5120                                thumbsData = [];
5121
5122                            //If this is an albums only item and the thumbs will
5123                            if( albumsonly ){
5124                                cffAttachmentsUrl = cffAttachmentsUrl + '&albumsonly=true';
5125                                var consentGiven = (typeof window.cff !== 'undefined' && typeof window.cff.feeds !== 'undefined') ? window.cff.feeds[0].settings.consentGiven : true;
5126                                if (consentGiven) {
5127                                    $('.cff-lightbox-thumbs-holder').css('min-height', 45).after('<div class="cff-loader"></div>');
5128                                }
5129                            }
5130
5131                            //If it's a group album then add the absolute path so we can get the User Access Token from the DB
5132                            var cffgroupalbums = this.album[this.currentImageIndex].cffgroupalbums;
5133                            if( cffgroupalbums ) cffAttachmentsUrl = cffAttachmentsUrl + '&usegrouptoken=' + cffgroupalbums;
5134
5135                            var submitData = {
5136                                action: 'cff_thumbs',
5137                                id: thisPostId,
5138                                pageid: cff_page_id,
5139                            };
5140                            if( shortcode_token_param !== '' ){
5141                                var token = shortcode_token_param.split('=');
5142                                submitData.at = token[1];
5143                            }
5144                            if( $cffClosest.attr('data-own-token') == 'true' ) {
5145                                submitData.useowntoken = true;
5146                            }
5147                            if( cffgroupalbums ){
5148                                submitData.usegrouptoken = cffgroupalbums;
5149                            }
5150                            if( albumsonly ){
5151                                submitData.albumsonly = true;
5152                            }
5153
5154                            var onSuccess = function(data) {
5155                                //Convert string of data received from thumbs.php to a JSON object
5156                                data = JSON.parse( data );
5157
5158                                if(albumsonly){
5159                                    //Compile the thumbs
5160                                    $.each(data.data, function(i, photoItem) {
5161                                        var dataCaption = '';
5162                                        if( photoItem.name ) dataCaption = photoItem.name;
5163                                        // origCaption = String(origCaption).replace(/"/g, '&quot;');
5164
5165                                        //Format the caption and add links
5166                                        dataCaption = cffLinkify(dataCaption);
5167                                        dataCaption = dataCaption.replace( hashRegex , cffReplaceHashtags );
5168
5169                                        // dataCaption = dataCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
5170                                        dataCaption = String(dataCaption).replace(/& /g, '&amp; ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
5171
5172                                        origCaption = String(origCaption).replace(/& /g, '&amp; ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
5173
5174                                        var lightboxImageOrder = (parseInt(self.currentImageIndex)+parseInt(i));
5175
5176                                        //If it's a group then use the source otherwise it displays as question marks
5177                                        var cffThumbHref = photoItem.source,
5178                                            cffPhotoItemWidth = photoItem.width,
5179                                            cffPhotoItemHeight = photoItem.height;
5180
5181                                        //Use the full size image if available
5182                                        if( typeof photoItem.images[0] !== 'undefined' ){
5183                                            cffThumbHref = photoItem.images[0].source;
5184                                            cffPhotoItemWidth = photoItem.images[0].width;
5185                                            cffPhotoItemHeight = photoItem.images[0].height;
5186                                        }
5187
5188                                        //Set the thumbnail image to be the smallest size available, which is the second from last in images arr
5189                                        if( typeof photoItem.images[ photoItem.images.length-2 ] !== 'undefined' ){
5190                                            var cffThumbImg = photoItem.images[ photoItem.images.length-2 ].source;
5191                                        } else {
5192                                            var cffThumbImg = cffThumbHref;
5193                                        }
5194
5195                                        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>';
5196
5197                                        thumbsData.push([cffThumbHref, cffPhotoItemWidth, cffPhotoItemHeight, 'http://facebook.com/'+photoItem.id, dataCaption, origCaption, undefined, undefined, cffThumbImg]);
5198
5199                                        //Add all of the thumbs (apart from the first thumb) to the lightbox order
5200                                        if( i > 0 ){
5201                                            cffInsertLightboxImage(lightboxImageOrder, cffThumbHref, dataCaption, 'http://facebook.com/'+photoItem.id, thisPostId, albumsonly, true, cffThumbImg);
5202                                        }
5203
5204                                    }); //End each
5205
5206                                } else {
5207                                    //Check whether there's data..
5208                                    if (typeof data.attachments !== 'undefined') {
5209
5210                                        //..Then compile the thumbs
5211                                        $.each(data.attachments.data[0].subattachments.data, function(i, subattachment) {
5212                                            var dataCaption = '';
5213                                            if( subattachment.description ) dataCaption = subattachment.description;
5214                                            origCaption = String(origCaption).replace(/"/g, '&quot;');
5215
5216                                            //Format the caption and add links
5217                                            dataCaption = cffLinkify(dataCaption);
5218                                            dataCaption = dataCaption.replace( hashRegex , cffReplaceHashtags );
5219                                            // dataCaption = dataCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
5220                                            dataCaption = String(dataCaption).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
5221
5222                                            var lightboxImageOrder = (parseInt(self.currentImageIndex)+parseInt(i));
5223
5224                                            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
5224+'" 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>';
5225
5226                                            thumbsData.push([subattachment.media.image.src, subattachment.media.image.width, subattachment.media.image.height, subattachment.url, dataCaption, origCaption, author_name, date_in_correct_format]);
5227
5228                                            //Add all of the thumbs (apart from the first thumb) to the lightbox order
5229                                            if( i > 0 ){
5230                                                cffInsertLightboxImage(lightboxImageOrder, subattachment.media.image.src, dataCaption, subattachment.url, thisPostId, albumsonly, true, author_name, date_in_correct_format, subattachment.media.image.src);
5231                                            }
5232
5233                                        });
5234
5235                                    } //End undefined check
5236
5237                                } //End if/else
5238
5239                                //Add thumbs to the page
5240                                if( albumThumbs.length > 0 ){
5241                                    $('.cff-lightbox-thumbs-holder').html( '<div class="cff-lightbox-thumbs-wrap">' + albumThumbs + '</div>' ).addClass('cff-animate');
5242                                    $('.cff-lightbox-wrapper').addClass('cff-has-thumbs');
5243                                }
5244
5245                                //Liquidfill the thumbs
5246                                jQuery(".cff-lightbox-thumbs-holder .cff-lightbox-attachment").imgLiquid({fill:true, useBackgroundSize:true});
5247
5248                                //Hide the loader
5249                                $('.cff-loader').hide();
5250
5251                                $('.cff-lightbox-thumbs-holder').css('min-height', 0);
5252
5253                                //Add the thumbs to the thumbs array to store them
5254                                thumbsArr[ thisPostId ] = thumbsData;
5255
5256                                //album done loading, can change items now
5257                                if (albumsonly) {
5258                                    jQuery('.cff-lightbox-container').removeClass('cff-album-loading');
5259                                    jQuery('.cff-lightbox-prev, .cff-lightbox-next').show();
5260                                }
5261                            }; // end success
5262                            $('.cff-gdpr-more-link').remove();
5263                            if (window.cff.feeds[ this.album[this.currentImageIndex].feedIndex ].settings.consentGiven) {
5264                                // disable navigation while albums load
5265                                if (albumsonly) {
5266                                    jQuery('.cff-lightbox-container').addClass('cff-album-loading');
5267                                    jQuery('.cff-lightbox-prev, .cff-lightbox-next').hide();
5268                                }
5269                                cffAjax(submitData,onSuccess);
5270                            } else {
5271                                if (parseInt(this.album[this.currentImageIndex].count) > 0) {
5272                                    $('.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>');
5273                                    $('.cff-gdpr-more-link').imgLiquid({fill:true, useBackgroundSize:true});
5274                                    setTimeout(function () {
5275                                        $('.cff-gdpr-more-link span').css({
5276                                            'margin-top': '-' + ($('.cff-gdpr-more-link span').height() / 2) + 'px',
5277                                            'margin-right': '-' + ($('.cff-gdpr-more-link span').width() / 2) + 'px',
5278                                            'display': 'block'
5279                                        });
5280                                    }, 200);
5281                                }
5282                            }
5283
5284                        } //End if/else
5285
5286                    } else {
5287                        //If there are no thumbs then hide the thumbs area
5288                        $('.cff-lightbox-thumbs').hide();
5289                    }
5290
5291                    //Add a class to the selected thumb
5292                    $(".cff-lightbox-attachment").removeClass('cff-selected');
5293                    $(".cff-lightbox-attachment[href='"+$('.cff-lightbox-image').attr('src')+"']").addClass('cff-selected');
5294
5295
5296                    function cffInsertLightboxImage(currentImageIndex, link, title, facebookurl, postid, albumsonly, isThumbnail, 
5296cffThumbImg){
5297
5298                        //Make sure the thumbs aren't added to the lightbox order more than once
5299                        var found = false;
5300                        $.each(self.album, function(i, thumbitem) {
5301                            if( ( thumbitem.link == link ) && ( thumbitem.postid == postid ) ){
5302                                found = true;
5303                                return;
5304                            }
5305                        });
5306                        if(found == true) return;
5307
5308                        ( albumsonly ) ? postType = 'albumsonly' : postType = '';
5309                        ( albumsonly ) ? lbcomments = 'false' : lbcomments = 'true';
5310
5311                        //Push the image into the album array at the correct location so it's included in the lightbox order
5312                        self.album.splice(currentImageIndex, 0, {
5313                            link: link,
5314                            title: title,
5315                            postid: postid,
5316                            showthumbs: 'true',
5317                            facebookurl: facebookurl,
5318                            video: '',
5319                            iframe: '',
5320                            type: postType,
5321                            cffgroupalbums: undefined,
5322                            isthumbnail: isThumbnail,
5323                            lbcomments: lbcomments,
5324                            thumbimg: cffThumbImg
5325                        });
5326
5327                    } //End cffInsertLightboxImage()
5328
5329                    /** END NEW PHOTO ACTION **/
5330
5331
5332                    //Still show the caption section even if there's not a caption as it contains the View on Facebook link
5333                    this.$lightbox.find('.cff-lightbox-caption').fadeIn('fast');
5334
5335
5336                    // Enable anchor clicks in the injected caption html.
5337                    if (typeof this.album[this.currentImageIndex].title !== 'undefined' && this.album[this.currentImageIndex].title !== "") {
5338
5339                        //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
5340                        var origCaption = this.album[this.currentImageIndex].title;
5341                        //Add hashtag and tag links
5342                        // origCaption = cffLinkify(origCaption); - Caused issues with @tag links in regular lightbox popup
5343                        origCaption = origCaption.replace( hashRegex , cffReplaceHashtags );
5344                        // origCaption = origCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
5345                        //Decode the caption back so that the tags are rendered as HTML:
5346                        origCaption = String(origCaption).replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"');
5347
5348                        var $lightboxCaption = this.$lightbox.find('.cff-lightbox-caption'),
5349                            $lightboxCaptionText = $lightboxCaption.find('.cff-lightbox-caption-text');
5350                        if( this.album[this.currentImageIndex].link == $('.cff-lightbox-image').attr('src') ) $lightboxCaptionText.html( origCaption );
5351
5352                        //If there's no caption then remove the border and margin from the View on Facebook link
5353                        if( $lightboxCaptionText.text() == ' ' || $lightboxCaptionText.text() == '' ){
5354                            $lightboxCaption.addClass('cff-no-caption');
5355                        } else {
5356                            $lightboxCaption.removeClass('cff-no-caption');
5357                        }
5358
5359                    } else {
5360                        if(albumsonly || this.album[this.currentImageIndex].title === undefined) this.$lightbox.find('.cff-lightbox-caption-text').html('');
5361
5362                        //If there's no caption then add a class
5363                        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('');
5364                    }
5365
5366                    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){
5367                            window.open(
5368                                $(this).attr('href'),
5369                                '_blank'
5370                            )
5371                        }
5372                    );
5373
5374                    if (this.album.length > 1 && this.options.showImageNumberLabel) {
5375                        this.$lightbox.find('.cff-lightbox-number').text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn('fast');
5376                    } else {
5377                        this.$lightbox.find('.cff-lightbox-number').hide();
5378                    }
5379
5380                    if (typeof cffLightboxAction === 'function') {
5381                        setTimeout(function() {
5382                            cffLightboxAction();
5383                        },100);
5384                    }
5385
5386                    this.$outerContainer.removeClass('animating');
5387
5388                    this.$lightbox.find('.cff-lightbox-dataContainer').fadeIn(this.options.resizeDuration, function() {
5389                        return self.sizeOverlay();
5390                    });
5391
5392                }; //End Lightbox.prototype.updateDetails
5393
5394                // Preload previous and next images in set.
5395                Lightbox.prototype.preloadNeighboringImages = function() {
5396                    if (this.album.length > this.currentImageIndex + 1) {
5397                        var preloadNext = new Image();
5398                        preloadNext.src = this.album[this.currentImageIndex + 1].link;
5399                    }
5400                    if (this.currentImageIndex > 0) {
5401                        var preloadPrev = new Image();
5402                        preloadPrev.src = this.album[this.currentImageIndex - 1].link;
5403                    }
5404                };
5405
5406                Lightbox.prototype.enableKeyboardNav = function() {
5407                    $(document).on('keyup.keyboard', $.proxy(this.keyboardAction, this));
5408                };
5409
5410                Lightbox.prototype.disableKeyboardNav = function() {
5411                    $(document).off('.keyboard');
5412                };
5413
5414                Lightbox.prototype.keyboardAction = function(event) {
5415                    var KEYCODE_ESC        = 27;
5416                    var KEYCODE_LEFTARROW  = 37;
5417                    var KEYCODE_RIGHTARROW = 39;
5418
5419                    var keycode = event.keyCode;
5420                    var key     = String.fromCharCode(keycode).toLowerCase();
5421                    if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
5422                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
5423                        $('#cff-lightbox-wrapper iframe').attr('src', '');
5424
5425                        this.end();
5426                    } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
5427                        if (jQuery('.cff-lightbox-container').hasClass('cff-album-loading')) {
5428                            // disable navigation while albums load
5429                            return;
5430                        }
5431                        if (this.currentImageIndex !== 0) {
5432                            this.changeImage(this.currentImageIndex - 1);
5433                        } else if (this.options.wrapAround && this.album.length > 1) {
5434                            this.changeImage(this.album.length - 1);
5435                        }
5436
5437                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
5438                        $('#cff-lightbox-wrapper iframe').attr('src', '');
5439
5440                    } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
5441                        if (jQuery('.cff-lightbox-container').hasClass('cff-album-loading')) {
5442                            // disable navigation while albums load
5443                            return;
5444                        }
5445                        if (this.currentImageIndex !== this.album.length - 1) {
5446                            this.changeImage(this.currentImageIndex + 1);
5447                        } else if (this.options.wrapAround && this.album.length > 1) {
5448                            this.changeImage(0);
5449                        }
5450
5451                        if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
5452                        $('#cff-lightbox-wrapper iframe').attr('src', '');
5453
5454                    }
5455                };
5456
5457                // Closing time
5458                Lightbox.prototype.end = function() {
5459                    this.disableKeyboardNav();
5460                    $(window).off("resize", this.sizeOverlay);
5461                    this.$lightbox.fadeOut(this.options.fadeDuration);
5462                    this.$overlay.fadeOut(this.options.fadeDuration);
5463                    $('select, object, embed').css({
5464                        visibility: "visible"
5465                    });
5466                };
5467
5468                return Lightbox;
5469
5470            })(); //End Lightbox = (function()
5471
5472            $(function() {
5473                var options  = new LightboxOptions();
5474                var lightbox = new Lightbox(options);
5475            });
5476
5477        }).call(this); //End (function() {
5478
5479        //Checks whether browser support HTML5 video element
5480        function cff_supports_video() {
5481            return !!document.createElement('video').canPlayType;
5482        }
5483
5484
5485    } //End cffLightbox function
5486
5487//Only call the lightbox if the class is on at least one feed on the page
5488    if( jQuery('#cff.cff-lb').length ) cffLightbox();
5489
5490
5491
5492} //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.