PageSourceSearch

https://darwin200.com/wp-content/plugins/custom-facebook-feed-pro/js/cff-scripts.js?ver=3.10.6

js darwin200.com collected 2026-10-02 04:59:49 UTC 185,777 bytes, 3,317 lines download raw bytes

1var cff_js_exists = (typeof cff_js_exists !== 'undefined') ? true : false;
2if(!cff_js_exists){
3
4//Only load the Masonry code if there's a masonry feed on the page
5if( jQuery('#cff.cff-masonry-js').length ){
6
7	//Masonry
8	!function(a){function b(){}
9	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))})}
10	function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(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+"'")}
11	return this}
12	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))})}}
13	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}}
14	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}
15	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(){}
16	function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}
17	function c(a){return function(){return this[a].apply(this,arguments)}}
18	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
18);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}}
19	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}
20	function c(){}
21	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}
22	return a}
23	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)}}}
24	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}
25	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}}
26	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}
27	var j,k,l,m=!1;return h}
28	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))}
29	function c(a){var c="readystatechange"===a.type&&"complete"!==f.readyState;b.isReady||c||d()}
30	function d(){b.isReady=!0;for(var a=0,c=g.length;c>a;a++){var d=g[a];d()}}
31	function e(e){return"complete"===f.readyState?d():(e.bind(f,"DOMContentLoaded",c),e.bind(f,"readystatechange",c),e.bind(a,"load",c)),b}
32	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)}
33	function c(a){if(!a.parentNode){var b=document.createDocumentFragment();b.appendChild(a)}}
34	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}
35	function e(a,d){return c(a),b(a,d)}
36	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}
37	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)}
38	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}
39	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={}
39,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}
40	function g(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}
41	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)}
42	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}
43	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]}
44	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={}
44,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()}
45	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)}
46	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)}
47	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)}
48	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])}
49	function d(){g++,g===f&&c()}
50	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}
50,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}
51	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)}
52	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()}
53	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]}
53,g.create=function(a,b){function c(){g.apply(this,arguments)}
54	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}
55	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)}
56	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})
57
58	function cffAddMasonry($self) {
59	    if (jQuery(window).width() > 780 || $self.hasClass('masonry-2-mobile') ) {
60	        //Add the class in case it was removed when resizing down
61	        $self.addClass('cff-masonry cff-masonry-js').removeClass('cff-disable-masonry');
62	        if($self.find('.cff-item').length) {
63	            $self.masonry({itemSelector: '.cff-new, .cff-item, .cff-likebox'});
64	            // Add margin to the bottom of each post to give some space
65	            $self.find('.cff-item').each( function() {
66	                jQuery(this).css('margin-bottom', '15px');
67	            });
68	        } else if($self.find('.cff-album-item').length) {
69	            $self.masonry({itemSelector: '.cff-album-item'});
70	        }
71	    } else {
72	    	//Disable masonry in 1 col mobile as isn't needed
73	        $self.addClass('cff-disable-masonry');
74	    }
75	}
76
77} //End Masonry code
78
79function cff_init( $cff ){
80
81	//JS is running
82	jQuery('.cff-nojs').removeClass('cff-nojs');
83
84	//Check whether it's a touch device
85	var cffTouchDevice = false;
86    if (cffIsTouchDevice() === true) cffTouchDevice = true;
87    function cffIsTouchDevice() {
88        return true == ("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch);
89    }
90
91	//If a feed selector isn't passed in then default to using selector for all feeds
92	var firsttime = false;
93	if(typeof $cff === 'undefined'){
94		$cff = jQuery('.cff');
95		firsttime = true;
96	}
97
98	(function($){
99
100		//Set likebox width
101		$('.cff-likebox iframe').each(function(){
102			var $likebox = $(this),
103				likeboxWidth = $likebox.attr('data-likebox-width'),
104				cffFeedWidth = $likebox.parent().width();
105
106			//Default width is 340
107			if( likeboxWidth == '' ) likeboxWidth = 340;
108			//Change the width dynamically so it's responsive
109			if( cffFeedWidth < likeboxWidth ) likeboxWidth = cffFeedWidth;
110
111			$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='+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'));
112		});
113
114		//Toggle comments
115		jQuery(document).off('click', '#cff a.cff-view-comments').on('click', '#cff a.cff-view-comments', function(){
116			var $self = jQuery(this),
117				$commentsBox = $self.closest('.cff-item').find('.cff-comments-box');
118			$self.toggleClass('cff-open');
119			
120			$commentsBox.slideToggle(300);
121
122			//Masonry - overlap comments box when open
123			var $feed = $self.closest('#cff'),
124	        	$item = $(this).closest('.cff-item');
125	        if( $feed.hasClass('cff-masonry-js') && !$feed.hasClass('cff-opaque-comments') ){
126	        	setTimeout(function(){
127	                cffAddMasonry($feed);
128	            }, 500);
129	        }
130
131			//Add comment avatars
132			$commentsBox.find('.cff-comment:visible').each(function(){
133				var $thisComment = jQuery(this);
134				$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\'" />' );
135			});
136
137		});
138
139		//Comments box hover
140		var cffAnimateIconColorVar,
141			stopAnimate = false;
142		$cff.find('.cff-view-comments').hover(function(){
143			var $self = $(this),
144				time = 50;
145			if( $self.hasClass('cff-open') ) return;
146
147			$self.find('.cff-icon').each(function() {
148			    var $cffIcon = jQuery(this);
149			    cffAnimateIconColor($cffIcon, time);
150			    time += 50;
151			});
152		}, function(){
153			cffStopAnimateIconColor();
154			$(this).find('.cff-icon').removeClass('cff-animate');
155		});
156		function cffAnimateIconColor($cffIcon, time){
157			stopAnimate = false;
158			cffAnimateIconColorVar = setTimeout( function(){
159		        if( !stopAnimate ) $cffIcon.addClass('cff-animate');
160		    }, time);
161		}
162		function cffStopAnimateIconColor() {
163			clearTimeout(cffAnimateIconColorVar);
164			stopAnimate = true;
165		}
166
167		//Set paths for query.php
168		if (typeof cffsiteurl === 'undefined' || cffsiteurl == '') cffsiteurl = window.location.host + '/wp-content/plugins';
169		var locatefile = true;
170
171		//Create meta data array for caching likes and comments
172		var metaArr = {},
173			newMetaArr = {}; //For caching only new posts that are loaded
174
175		//Loop through the feeds on the page and add a unique attribute to each to use for lightbox groups
176		var lb = 0;
177		jQuery('#cff.cff-lb').each(function(){
178			lb++;
179			$(this).attr('data-cff-lb', lb);
180		});
181
182		
183		//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
184		var $cff_post_selector = $cff.find('.cff-item.cff-new, .cff-album-item.cff-new');
185		if( firsttime ){
186			$cff_post_selector = jQuery('#cff .cff-item.cff-new, #cff .cff-album-item.cff-new');
187		}
188
189		//Loop through each item
190		$cff_post_selector.each(function(){
191
192			var $self = jQuery(this);
193
194			//Wpautop fix
195			if( $self.find('.cff-viewpost-link, .cff-viewpost-facebook, .cff-viewpost').parent('p').length ){
196				//Don't unwrap event only viewpost link
197				if( !$self.hasClass('event') ) $self.find('.cff-viewpost-link, .cff-viewpost-facebook, .cff-viewpost').unwrap('p');
198			}
199			if( $self.find('.cff-photo').parent('p').length ){
200				$self.find('p .cff-photo').unwrap('p');
201				$self.find('.cff-album-icon').appendTo('.cff-photo:last');
202			}
203			if( $self.find('.cff-event-thumb').parent('p').length ){
204				$self.find('.cff-event-thumb').unwrap('p');
205			}
206			if( $self.find('.cff-vidLink').parent('p').length ){
207				$self.find('.cff-vidLink').unwrap('p');
208			}
209			if( $self.find('.cff-link').parent('p').length ){
210				$self.find('.cff-link').unwrap('p');
211			}
212			if( $self.find('.cff-viewpost-link').parent('p').length ){
213				$self.find('.cff-viewpost-link').unwrap('p');
214			}
215			if( $self.find('.cff-viewpost-facebook').parent('p').length ){
216				$self.find('.cff-viewpost-facebook').unwrap('p');
217			}
218
219			if( $self.find('iframe').parent('p').length ){
220				$self.find('iframe').unwrap('p');
221			}
222			if( $self.find('.cff-author').parent('p').length ){
223				$self.find('.cff-author').eq(1).unwrap('p');
224				$self.find('.cff-author').eq(1).remove();
225			}
226			if( $self.find('.cff-view-comments').parent('p').length ){
227				$self.find('.cff-meta-wrap > p').remove();
228				$self.find('.cff-view-comments').eq(1).remove();
229				//Move meta ul inside the link element
230				var $cffMeta = $self.find('.cff-meta'),
231					cffMetaClasses = $cffMeta.attr('class');
232				$cffMeta.find('.cff-view-comments').unwrap().wrapInner('<ul class="'+cffMetaClasses+'">');
233			}
234			if( $self.find('.cff-photo').siblings('.cff-photo').length ){
235				$self.find('.cff-photo').slice(0,2).remove();
236			}
237			//Fix the formatting issue that pushes avatar to the left
238			if( $('.cff-author-img').parent().is('p') ) $('.cff-author-img').unwrap('p');
239			//Remove empty p tags
240			$self.find('p:empty').not('.cff-comments-box p').remove();
241
242			//Expand post
243			var	expanded = false;
244			if( $self.hasClass('cff-event') ){
245				var $post_text = $self.find('.cff-desc .cff-desc-text'),
246					text_limit = $post_text.parent().attr('data-char');
247			} else {
248				var $post_text = $self.find('.cff-post-text .cff-text'),
249					text_limit = $self.closest('#cff').attr('data-char');
250			}
251
252			if (typeof text_limit === 'undefined' || text_limit == '') text_limit = 99999;
253			
254			//If the text is linked then use the text within the link
255			if ( $post_text.find('a.cff-post-text-link').length ) $post_text = $self.find('.cff-post-text .cff-text a');
256			var	full_text = $post_text.html();
257			if(full_text == undefined) full_text = '';
258
259
260			//Truncate text taking HTML tags into account
261			var cff_trunc_regx = new RegExp(/(<[^>]*>)/g);
262			var cff_trunc_counter = 0;
263
264			//convert the string to array using the HTML tags as delimiter and keeping them as array elements
265			full_text_arr = full_text.split(cff_trunc_regx);
266
267			for (var i = 0, len = full_text_arr.length; i < len; i++) {
268				//ignore the array elements that are HTML tags
269				if ( !(cff_trunc_regx.test(full_text_arr[i])) ) {
270				  	//if the counter is 100, remove this element with text
271					if (cff_trunc_counter == text_limit) {
272				    	full_text_arr.splice(i, 1);
273				        continue; //ignore next commands and continue the for loop
274				    }
275				    //if the counter != 100, increase the counter with this element length
276				    cff_trunc_counter = cff_trunc_counter + full_text_arr[i].length;
277				    //if is over 100, slice the text of this element to match the total of 100 chars and set the counter to 100
278				    if (cff_trunc_counter > text_limit) {
279				      	var diff = cff_trunc_counter - text_limit;
280				        full_text_arr[i] = full_text_arr[i].slice(0, -diff);
281				        cff_trunc_counter = text_limit;
282
283				        //Show the 'See More' link if needed
284						if (full_text.length > text_limit) $self.find('.cff-expand').show();
285				    }
286				}
287			}
288
289			//new string from the array
290			var short_text = full_text_arr.join('');
291
292			//remove empty html tags from the array
293			short_text = short_text.replace(/(<(?!\/)[^>]+>)+(<\/[^>]+>)/g, "");
294
295			//If the short text cuts off in the middle of a <br> tag then remove the stray '<' which is displayed
296			var lastChar = short_text.substr(short_text.length - 1);
297			if(lastChar == '<') short_text = short_text.substring(0, short_text.length - 1);
298
299			//Remove any <br> tags from the end of the short_text
300			short_text = short_text.replace(/(<br>
300\s*)+$/,''); 
301			short_text = short_text.replace(/(<img class="cff-linebreak">\s*)+$/,''); 
302
303			//Cut the text based on limits set
304			$post_text.html( short_text );
305
306
307			//Click function
308			$self.find('.cff-expand a').unbind('click').bind('click', function(e){
309				e.preventDefault();
310				var $expand = jQuery(this),
311					$more = $expand.find('.cff-more'),
312					$less = $expand.find('.cff-less');
313				if (expanded == false){
314					$post_text.html( full_text );
315					expanded = true;
316					$more.hide();
317					$less.show();
318				} else {
319					$post_text.html( short_text );
320					expanded = false;
321					$more.show();
322					$less.hide();			
323				}
324				cffLinkHashtags();
325				//Add target to links in text when expanded
326				$post_text.find('a').attr('target', '_blank');
327
328				//Re-init masonry for JS
329				if( $self.closest('.cff').hasClass('cff-masonry-js') && !$self.closest('.cff').hasClass('cff-masonry-css') ){
330					cffAddMasonry($cff);
331				}
332
333			});
334			//Add target attr to post text links via JS so aren't included in char count
335			$post_text.find('a').add( $self.find('.cff-post-desc a') ).attr({
336				'target' : '_blank',
337				'rel' : 'nofollow noopener noreferrer'
338			});
339
340
341			//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
342			var post_id = $self.attr('id').substring(4),
343				//This is the original post ID which is used to get the number of likes and comments for the timeline post
344				post_id_orig = $self.find('.cff-view-comments').attr('id');
345
346			if( locatefile != true ) $self.find('.cff-lightbox-thumbs-holder').css('min-height', 0);
347			
348
349			//Show all comments on click
350			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(){
351
352				var $cffMoreCommentsLink = jQuery(this),
353					thisCommentsTotal = parseInt($cffMoreCommentsLink.attr('data-cff-comments-total'));
354
355				//If there's more than 25 comments then link the "View more comments" link to post on Facebook
356				if( $cffMoreCommentsLink.hasClass('cff-clicked') && thisCommentsTotal > 25 ){
357					//Link to Facebook
358					$cffMoreCommentsLink.find('a').attr({
359						'href' : $cffMoreCommentsLink.closest('.cff-comments-box').find('.cff-comment-on-facebook a').attr('href'),
360						'target' : '_blank'
361					});
362				}
363				//Hide 'View more comments' link
364				if( thisCommentsTotal <= 25 ) $cffMoreCommentsLink.hide();
365
366				//Add class so we can only trigger the above on the second click
367				$cffMoreCommentsLink.addClass('cff-clicked');
368
369				//Show comments and add comment avatars
370				$cffMoreCommentsLink.parent().find('.cff-comment').show().each(function(){
371					var $thisComment = jQuery(this);
372					$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\'" />' );
373				});
374
375				//Re-init masonry when more comments loaded
376				var $closestCff = $cffMoreCommentsLink.closest('.cff');
377				if( $closestCff.hasClass('cff-masonry-js') && !$closestCff.hasClass('cff-opaque-comments') ){
378		        	setTimeout(function(){
379		                cffAddMasonry( $closestCff );
380		            }, 500);
381		        }
382			});
383			
384
385			//Remove event end date day if the same as the start date
386			if( $self.hasClass('cff-timeline-event') || $self.hasClass('cff-event') ){
387				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();
388			}
389
390
391			//Replace Photon (Jetpack CDN) images with the originals again
392			var $cffPhotoImg = $self.find('.cff-photo img, .cff-event-thumb img, .cff-poster, .cff-album-cover img'),
393				cffPhotoImgSrc = $cffPhotoImg.attr('src'),
394				cffImgStringAttr = $cffPhotoImg.attr('data-querystring');
395
396			if( typeof cffPhotoImgSrc == 'undefined' ) cffPhotoImgSrc = '';
397
398			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 ){
399				
400				//Create new src. Single slash in https is intentional as one is left over from remov
400ing i_.wp.com
401				var photonSrc = $cffPhotoImg.attr('src').substring(0, $cffPhotoImg.attr('src').indexOf('?')),
402					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;
403
404				$cffPhotoImg.attr('src', newSrc);
405			}
406
407			function cffLinkHashtags(){
408				//Link hashtags
409				var cffTextStr = $self.find('.cff-text').html(),
410					cffDescStr = $self.find('.cff-post-desc').html(),
411					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
411D3-\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,
412					linkcolor = $self.find('.cff-text').attr('data-color'),
413					linkcolorHTML = '';
414
415				function replacer(hash){
416					//Remove white space at beginning of hash
417					var replacementString = jQuery.trim(hash);
418					//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"
419					if ( /^#[0-9A-F]{6}$/i.test( replacementString ) ){
420						return replacementString;
421					} else {
422						if( typeof linkcolor !== 'undefined' ){
423							if( linkcolor.length > 1 ) linkcolorHTML = 'style="color:#' + linkcolor + '"';
424						}
425						return ' <a href="https://www.facebook.com/hashtag/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener" '+linkcolorHTML+'>' + replacementString + '</a>';
426					}
427				}
428
429				//If it's not defined in the source code then set it to be true
430				if (typeof cfflinkhashtags == 'undefined') cfflinkhashtags = 'true';
431
432				if(cfflinkhashtags == 'true'){
433					//Replace hashtags in text
434					var $cffText = $self.find('.cff-text');
435					
436					if($cffText.length > 0){
437						//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.
438						cffTextStr = cffTextStr.replace(/<br>/g, "<br> ");
439						$cffText.html( cffTextStr.replace( regex , replacer ) );
440					}
441				}
442
443				//Replace hashtags in desc
444				if( $self.find('.cff-post-desc').length > 0 ) $self.find('.cff-post-desc').html( cffDescStr.replace( regex , replacer ) );
445			}
446			cffLinkHashtags();
447
448			//Add target attr to post text links via JS so aren't included in char count
449			$self.find('.cff-text a').attr('target', '_blank');
450
451
452			//Add lightbox tile link to photos
453			if( $self.closest('#cff').hasClass('cff-lb') ){
454				$self.find('.cff-photo, .cff-album-cover, .cff-event-thumb, .cff-html5-video, .cff-iframe-wrap').each(function(){
455					var $photo = $(this),
456						postId = post_id,
457						cffLightboxTitle = '',
458						cffShowThumbs = false,
459						postType = '',
460						cffgroupalbums = '';
461
462
463					// if( $self.hasClass('cff-album') || $self.hasClass('cff-albums-only') ) cffShowThumbs = true;
464					cffShowThumbs = true;
465
466					function cffFormatCaption(text){
467						return String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
468					}
469
470					//Set the caption/title
471					if( $self.hasClass('cff-albums-only') ){
472						postType = 'albumsonly';
473						cffLightboxTitle = cffFormatCaption( $self.find('img').attr('alt') );
474						
475						//Check whether there's an absolute path attr and if there is then add it to the query
476		      			var dataGroup = $self.closest('#cff').attr('data-group');
477						if( typeof dataGroup !== 'undefined' ) cffgroupalbums = 'data-cffgroupalbums="true"';
478
479					} else if( $self.hasClass('cff-timeline-event') ) {
480						var capText = '';
481						if( $self.find('.cff-author-text .cff-page-name').length ) capText += $self.find('.cff-author-text .cff-page-name').text() + '<br /><br />';
482						//Display the full event details but the info is hidden in CSS as it's too long in some cases
483						if( full_text.length > 5 ) capText += full_text;
484						cffLightboxTitle = cffFormatCaption( capText );
485
486					} else if ( $self.hasClass('cff-event') ) {
487						//Events feed
488						if( $self.find('.cff-details').length ){
489							// if( $self.find('.cff-event-title').length ) cffLightboxTitle = cffFormatCaption( $self.find('.cff-event-title')[0].outerHTML );
490							// if( $self.find('.cff-date').length ) cffLightboxTitle += cffFormatCaption( $self.find('.cff-date')[0].outerHTML );
491							// if( $self.find('.cff-location').length ) cffLightboxTitle += cffFormatCaption( $self.find('.cff-location')[0].outerHTML );
492
493							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>' );
494							if( $self.find('.cff-date').length ) cffLightboxTitle += '<span class="cff-date">' + cffFormatCaption( $self.find('.cff-date').html() + '</span>' );
495							if( $self.find('.cff-location').length ) cffLightboxTitle += '<span class="cff-location">' + cffFormatCaption( $self.find('.cff-location').html() + '</span>' );
496
497							cffLightboxTitle += '<span class="cff-desc">' + full_text + '</span>';
498						}
499
500					} else if( $self.hasClass('cff-album-item') ) {
501						cffLightboxTitle = cffFormatCaption( $self.find('img').attr('alt') );
502					} else {
503						var lb_title = full_text;
504						//If there's no post text then use the description
505						if( full_text.trim() == '' ) lb_title = $self.find('.cff-post-desc').text();
506
507						//If there's no post text or desc then use the story
508						if( lb_title == '' && $self.find('.cff-author .cff-story').length ) lb_title = $self.find('.cff-author .cff-page-name').text();
509
510						//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
511						if( lb_title == '' ) lb_title = '&nbsp;';
512
513						cffLightboxTitle = cffFormatCaption( lb_title );
514					}
515
516					if(cffLightboxTitle.length > 1) cffLightboxTitle = cffLightboxTitle.replace(/"/g, '&quot;');
517
518
519					//Create the lightbox link
520					//Add the hover tile
521					var cffLightboxTile = '<a class="cff-lightbox-link nofancybox" rel="nofollow" ';
522
523					//If it's a YouTube or Vimeo then set the poster image to use in the lightbox
524					if( $photo.hasClass('cff-iframe-wrap') ){
525						//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:
526						cffLightboxTile += 'href="'+cffsiteurl+'/custom-facebook-feed-pro/img/vi
526deo-lightbox.png?'+postId+'" data-iframe="'+$photo.find('iframe').attr('src')+'" ';
527					//If it's a swf then display it in an iframe
528					} else if( $photo.hasClass('cff-swf') ) {
529						cffLightboxTile += 'href="'+cffsiteurl+'/custom-facebook-feed-pro/img/video-lightbox.png" data-iframe="'+$photo.find('video').attr('src')+'" ';
530					} else {
531						var lb_href = $photo.find('img').attr('src');
532						if( $photo.find('img').attr('data-cff-no-event-img-large') ) lb_href = $photo.find('img').attr('data-cff-no-event-img-large');
533						if( $photo.find('img').attr('data-cff-full-img') ) lb_href = $photo.find('img').attr('data-cff-full-img');
534						cffLightboxTile += 'href="'+lb_href+'" data-iframe="" ';
535					}
536
537					//No nav
538					// cffLightboxTile += 'data-cff-lightbox="'+postId+'" data-title="'+cffLightboxTitle+'" data-id="'+postId+'" data-thumbs="'+cffShowThumbs+'" ';
539					cffLightboxTile += 'data-cff-lightbox="cff-lightbox-'+$self.closest("#cff").attr("data-cff-lb")+'" data-title="'+cffLightboxTitle+'" data-id="'+postId+'" data-thumbs="'+cffShowThumbs+'" '+cffgroupalbums+' ';
540
541					//If it's an HTML5 video then set the data-video attr
542					if( $photo.hasClass('cff-html5-video') ){
543
544						if($photo.hasClass('cff-swf')){
545							cffLightboxTile += 'data-url="'+$photo.find('.cff-html5-play').attr('href')+'" data-video="';
546						} else {
547							cffLightboxTile += 'data-url="'+$photo.find('.cff-html5-play').attr('href')+'" data-video="'+$photo.find('img').attr('data-cff-video');
548						}
549
550					//Videos only:
551					} else if( $photo.hasClass('cff-video') ) {
552						cffLightboxTile += 'data-url="http://facebook.com/'+$photo.attr('id')+'" data-video="'+$photo.attr('data-source');
553					} else if( $photo.hasClass('cff-iframe-wrap') ) {
554						cffLightboxTile += 'data-url="http://facebook.com/'+post_id+'" data-video="';
555					} else {
556						cffLightboxTile += 'data-url="'+$photo.attr('href')+'" data-video="';
557					}
558
559					cffLightboxTile += '" data-type="'+postType+'" data-lb-comments="'+$photo.closest('.cff-lb').attr('data-lb-comments')+'"><div class="cff-photo-hover"><span class="fa fa-search-plus" aria-hidden="true"></span><span class="cff-screenreader">View</span></div></a>';
560
561					//Add the link to the photos/videos in the feed
562					$photo.prepend(cffLightboxTile);
563
564					if( !cffTouchDevice ){ //Only apply hover effect if not touch screen device
565						//Fade in links on hover
566						$photo.hover(function(){
567							$self.find('.cff-photo-hover').fadeIn(150);
568						}, function(){
569							$self.find('.cff-photo-hover').stop().fadeOut(500);
570						});
571					}
572
573				});
574			}
575
576			//Share tooltip function
577			$self.find('.cff-share-link').unbind().bind('click', function(e){
578				e.preventDefault();
579				var $cffShareTooltip = $self.find('.cff-share-tooltip')
580
581				//Hide tooltip
582				if( $cffShareTooltip.is(':visible') ){
583					$cffShareTooltip.hide().find('a').removeClass('cff-show');
584				} else {
585				//Show tooltip
586					$cffShareTooltip.show();
587
588					var time = 0;
589		        	$cffShareTooltip.find('a').each(function() {
590					    var $cffShareIcon = jQuery(this);
591					    setTimeout( function(){
592					        $cffShareIcon.addClass('cff-show');
593					    }, time);
594					    time += 20;
595					});
596				}
597	      	});
598
599
600
601
602			
603			//If it's a restricted page then use the lightbox src for the photo feed images
604			if( typeof $cff.attr('data-restricted') !== 'undefined' ){
605				var cff_restricted_page = true;
606			} else {
607				var cff_restricted_page = false;
608			}
609
610      		//Photos only
611      		if( $self.hasClass('cff-album-item') ){
612				var cff_data_full_size = $self.attr('data-cff-full-size');
613				
614				if( typeof cff_data_full_size !== 'undefined' && cff_data_full_size != '' ){
615
616					if( cff_restricted_page ){
617						$self.find('.cff-lightbox-link').attr('href', cff_data_full_size).closest('.cff-album-cover').css('background-image', 'url('+cff_data_full_size+')');
618						$self.find('img').attr('src', cff_data_full_size);
619					} else {
620						$self.find('.cff-lightbox-link').attr('href', cff_data_full_size);
621					}
622
623				}
624			}
625
626
627			//Add the HD video player
628			//If it's a video post then add the video link to the video element so it can be used in the lightbox
629			if( ( $self.find('.cff-html5-video').length || $self.hasClass('cff-video') ) ){
630				
631				var cff_live_video = false;
632
633				//Set the selector based on whether it's a timeline vid or videos only
634				if( $self.find('.cff-html5-video').length ){
635					var $vid_sel = $self.find('.cff-html5-video');
636					if( $vid_sel.attr('data-cff-live') == 'true' ) cff_live_video = true;
637				}
638				if( $self.hasClass('cff-video') ) var $vid_sel = $self;
639
640				if( cff_live_video && $(window).width() <= 640 ){
641					//If it's live video and on mobile then use HTMl5 player as live video doesn't work on mobile using Facebook player
642				} else {
643
644					if( !$self.closest('.cff').hasClass('cff-private-group') ){
645						//If the Facebook Player is selected then pass the iframe URL into the lightbox.
646						if( $vid_sel.attr('data-cff-video-player') != 'standard' ){
647							$self.find('.cff-lightbox-link').attr({
648								'data-iframe' : 'https://www.facebook.com/v2.3/plugins/video.php?href=' + $vid_sel.attr('data-cff-video-link'),
649								'data-video' : ''
650							});
651						}
652					}
653
654				}
655
656			}
657
658			//Try to fix any video wrapper formatting issues
659   			setTimeout(function(){
660			  $self.find('.cff-iframe-wrap .fluid-width-video-wrapper iframe').unwrap().wrap('<div style="float: left; width: 100%;"></div>');
661			  $self.find('.cff-iframe-wrap .iframe-embed iframe').unwrap('iframe-embed');
662			}, 500);
663
664
665			//Open lightbox when clicking album or video title
666			$self.find('.cff-album-info a').on('click', function(e){
667				e.preventDefault();
668				$self.find('.cff-lightbox-link').trigger('click');
669			});
670
671
672		}); //End $cff_post_selector.each loop
673
674
675		//Load comment replies
676		jQuery(document).off('click', '.cff-comment-replies a').on('click', '.cff-comment-replies a', function(){
677			cffLoadCommentReplies( $(this) );
678		});
679
680
681		$('.cff-wrapper').each(function(){
682			var $cff = $(this).find('#cff'),
683				cff_grid_pag = $cff.attr('data-grid-pag');
684
685			//Get the Access Token from the shortcode so it can be used in the connect file
686			var shortcode_token_param = cffGetShortcodeToken($cff);
687
688			//Masonry
689			if( $cff.hasClass('cff-masonry-js') ){
690
691		        if( $cff.find('.cff-album-item').length ){
692		            $cff.removeClass('cff-masonry-js');
693		            return;
694		        }
695
696		        cffAddMasonry($cff);
697		        //Call it again in case images aren't fully loaded
698		        setTimeout(function(){ cffAddMasonry($cff); }, 1000);
699
700		        // Resizing the window can affect the masonry feed so it is reset on resize
701		        $(window).resize(function () {
702		            setTimeout(function(){
703		                cffAddMasonry($cff);
704		            }, 500);
705		        });
706
707		        if( $cff.find('.cff-credit').length ) $cff.css('padding-bottom', 30);
708		    }
709
710			//Allow us to make some tweaks when the feed is narrow
711			function cffCheckWidth(){
712
713				if( $cff.hasClass('cff-album-items-feed') ){
714					var $cffElement = $cff;
715				} else {
716					var $cffElement = $cff.find('.cff-item').first();
717				}
718
719				if( $cffElement.innerWidth() < 400 ){
720					if( !$cff.hasClass('cff-disable-narrow') ){
721						$cff.addClass('narrow');
722					}
723				} else {
724					$cff.removeClass('narrow');
725				}
726				if( $cffElement.innerWidth() < 250 ){
727					$cff.addClass('cff-super-narrow');
728				}
729			}
730			cffCheckWidth();
731
732			function cffActionLinksPos(){
733				if( $cff.find('.cff-item').first().innerWidth() < (190 + $('.cff-post-links').innerWidth() ) ){
734					$cff.find('.cff-post-links').addClass('cff-left')
735				} else {
736					$cff.find('.cff-post-links').removeClass('cff-left');
737				}
738			}
739			cffActionLinksPos();
740
741			//Only check the width once the resize event is over
742			var cffdelay = (function(){
743				var cfftimer = 0;
744					return function(cffcallback, cffms){
745					clearTimeout (cfftimer);
746					cfftimer = setTimeout(cffcallback, cffms);
747				};
748			})();
749			window.addEventListener('resize', function(event){
750				cffdelay(function(){
751			    	cffCheckWidth();
752			    	cffActionLinksPos();
753			    	cffResizeAlbum();
754			    }, 500);
755			});
756
757			//Albums only
758			//Resize image height
759			function cffResizeAlbum(last){
760				var cffAlbumWidth = $cff.find('.cff-album-item').eq(0).find('a').innerWidth();
761				$cff.find('.cff-album-item a').css('height', cffAlbumWidth);
762				//Crops event images when selected
763				$cff.find('.cff-photo.cff-crop').css( 'height', $cff.find('.cff-photo.cff-crop').width() );
764
765				//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
766				$cff.find('.cff-item.cff-album .cff-photo.cff-multiple, .cff-video-post .cff-html5-video.cff-multiple').each(function(){
767					var $cffPhotoEl = $(this);
768
769					//Crop image attachments in posts
770					var cffPhotoImgWidth = $cffPhotoEl.find('img').first().width();
771					if( cffPhotoImgWidth < 10 ) cffPhotoImgWidth = 300;
772
773					if($cffPhotoEl.hasClass('cff-img-layout-3')) $cffPhotoEl.find('.cff-img-attachments .cff-crop').css( 'height', cffPhotoImgWidth/2 );
774					if($cffPhotoEl.hasClass('cff-img-layout-4')) $cffPhotoEl.find('.cff-img-attachments .cff-crop').css( 'height', cffPhotoImgWidth/3 );
775
776					//Crop main image
777					if( $cffPhotoEl.is('.cff-img-layout-3, .cff-img-layout-4') ){
778						var $cffMainImage = $cffPhotoEl.find('.cff-main-image'),
779							cropPercentage = 0.6;
780						if( $cffPhotoEl.hasClass('cff-img-layout-4') ) cropPercentage = 0.8;
781
782						//Set the height based on ratio
783						var cffImageHeight = Math.round( cffPhotoImgWidth / $cffMainImage.find('img').attr('data-ratio') );
784						$cffMainImage.css( 'height', Math.round( Math.max(cffImageHeight*cropPercentage, $cffPhotoEl.find('.cff-img-attachments').height() ) ) );
785					} else if( $cffPhotoEl.is('.cff-img-layout-2') ) {
786						var $cffCrop = $cffPhotoEl.find('.cff-img-wrap.cff-crop');
787						if( $cffPhotoEl.hasClass('cff-portrait') ){
788							$cffPhotoEl.find('.cff-img-wrap.cff-crop').css('height', $cffPhotoEl.width()*0.8 );
789						} else {
790							$cffPhotoEl.find('.cff-img-wrap.cff-crop').css('height', $cffPhotoEl.width()/2 );
791						}
792					}
793
794					//If the main image is being cropped to zero then remove the crop so the full image is shown
795					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({
796						'display' : 'block',
797						'visibility' : 'visible'
798					})
799
800					//Make "+6" text small if the images are small
801					if( cffPhotoImgWidth < 200 ){
802						$cffPhotoEl.addClass('cff-small-layout');
803					} else {
804						$cffPhotoEl.removeClass('cff-small-layout');
805					}
806				});
807				
808			}
809			cffResizeAlbum(false);
810			setTimeout(function(){ cffResizeAlbum(false); }, 50);
811			setTimeout(function(){ cffResizeAlbum(true); }, 500);
812			setTimeout(function(){ cffResizeAlbum(true); }, 1500);
813
814
815			//PAGINATION
816			//Events JS pagination
817			var num_events = parseInt( $cff.attr('data-pag-num') ),
818				show_events = num_events; //Iterated for each set
819			//Show first set of events
820			$cff.find('.cff-event').slice(0, num_events).css('display', 'inline-block');
821			//cffResizeAlbum(); //Correctly recalcs height of event images when using eventimage=cropped
822
823			//Review JS pagination
824			if( $cff.hasClass('cff-all-reviews') ){
825				var num_reviews = parseInt( $cff.attr('data-pag-num') ),
826					show_reviews = num_reviews;
827
828				//Offset
829				var review_offset = parseInt($cff.attr('data-offset'));
830				if( typeof review_offset == 'undefined' || isNaN(review_offset) ) review_offset = 0;
831
832				//Only show the required number of reviews
833				$cff.find('.cff-review').slice(0, num_reviews + review_offset ).css('display', 'inline-block');
834
835				//If using masonry then run it here
836				if( $cff.hasClass('cff-masonry-js') ) cffAddMasonry($cff);
837
838				//Hide some reviews if using offset setting
839				if( review_offset > 0 ) $cff.find('.cff-review').slice(0, review_offset ).remove();
840			}
841
842			//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
843			var $cffLoadMore = $cff.find('#cff-load-more'),
844				cff_no_posts_added = $cff.find('.cff-load-more').attr('data-cff-no-posts-added');
845			if (typeof cff_no_posts_added == typeof undefined || cff_no_posts_added == false) {
846				$cffLoadMore.attr('data-cff-no-posts-added', 'false');
847			}
848
849			//If there's no posts in the feed initially then set the data-attr to be true
850			if( $cff.find('.cff-item, .cff-album-item').length < 1 ) $cffLoadMore.attr('data-cff-no-posts-added', 'true');
851
852		    // add the load more button and input to simulate a dynamic json file call
853		    $cffLoadMore.off().on('click', function() {
854
855			    // read the json that is in the cff-data-shortcode that contains all of the shortcode arguments
856		        var shortcodeData = $cff.attr('data-cff-shortcode'),
857		            $paginationURL = $cff.find('.cff-pag-url'),
858		            pag_url = $paginationURL.attr('data-cff-pag-url');
859
860		    	//Upmcoming events JS pagination
861		    	var events_count = $cff.find('.cff-upcoming-event').length;
862		    	//If it's an event feed
863		    	if( events_count > 0 ){
864		    		show_events = show_events + num_events;
865		    		//Show the next set of events
866		    		$cff.find('.cff-upcoming-event').slice(0, show_events).css('display', 'inline-block');
867		    		if( show_events > events_count ){
868		    			$cff.find('#cff-load-more').hide();
869		    			cff_no_more_posts($cff, $cffLoadMore);
870		    		}
871
872		    		//Re-init masonry for JS
873		            if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
874				        cffAddMasonry($cff);
875		            }
876		    		return;
877		    	}
878
879		    	//Reviews JS pagination
880		    	if( $cff.hasClass('cff-all-reviews') ){
881			    	var reviews_count = $cff.find('.cff-review').length;
882			    	//If it's an reviews feed
883			    	if( reviews_count > 0 ){
884			    		show_reviews = show_reviews + num_reviews;
885			    		//Show the next set of reviews
886			    		$cff.find('.cff-review').slice(0, show_reviews).css('display', 'inline-block');
887			    		if( show_reviews > reviews_count ){
888			    			$cff.find('#cff-load-more').hide();
889			    			cff_no_more_posts($cff, $cffLoadMore);
890			    		}
891
892			    		//Re-init masonry for JS
893			            if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
894					        cffAddMasonry($cff);
895			            }
896			    		return;
897			    	}
898			    }
899
900
901		        //Remove the ID so it can't be clicked twice before the posts are loaded
902		        $cffLoadMore.off().removeAttr('id').addClass('cff-disabled');
903
904		        // remove the hidden field since it will be replaced with new before token and after token next url data
905		        $paginationURL.remove();
906
907			    	
908		        //If it's a photo/vid/album feed then change the selector
909			  	if( $cff.hasClass('cff-album-items-feed') ){
910			  		var item_sel = '.cff-album-item';
911			  	} else {
912			  		var item_sel = '.cff-item';
913			  	}
914
915			  	if( item_sel == '.cff-album-item' ){
916			  		//If the next_url is empty then use the prev_url
917			  		if( (pag_url == '' || pag_url == '{}') ) pag_url = $paginationURL.attr('data-cff-prev-url');
918
919				  	//Loop through the previous URLs and if the next URL is empty for an ID then add it in
920				  	var prev_urls = $paginationURL.attr('data-cff-prev-url');
921
922				  	//Convert the JSON string into an object so we can loop through it
923		        	var prev_urls_arr = ( typeof prev_urls == 'undefined' ) ? '' : JSON.parse( prev_urls );
924		      	}
925
926			    //Parse the urls string into an array so we can loop through it
927			    var pag_url_arr = ( typeof pag_url == 'undefined' ) ? '' : JSON.parse( pag_url );
928
929			    if( item_sel == '.cff-album-item' ){
930			        //Add the URL to the next_urls if it doesn't exist in the array
931				  	for (var key in prev_urls_arr) {
932						if (prev_urls_arr.hasOwnProperty(key)) {
933							if( typeof pag_url_arr[key] == 'undefined' ) pag_url_arr[key] = prev_urls_arr[key];
934						}
935					}
936				}
937
938		        if( (pag_url == '' || pag_url == '{}') && item_sel == '.cff-item' ){
939		        	$cffLoadMore.hide();
940		        	cff_no_more_posts($cff, $cffLoadMore);
941		        } else {
942		        	//Display loader
943	          		$cffLoadMore.addClass('cff-loading').append('<div class="cff-loader"></div>');
944	          		$cffLoadMore.find('.cff-loader').css('background-color', $cffLoadMore.css('color'));
945		        }
946
947
948		        //Check which pagination method to use
949		        var cff_timeline_api_paging = false;
950		        if( $cff.attr('data-timeline-pag') ) cff_timeline_api_paging = true;
951
952		        if( cff_timeline_api_paging == true ){
953		        	//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.
954		        } else {
955			        //Loop through the pag array. Replace the until params for each id. Stringify to send in the ajax request
956					for (var key in pag_url_arr) {
957					  	if (pag_url_arr.hasOwnProperty(key)) {
958
959						  	var this_url = pag_url_arr[key],
960						  		until_old = cffGetParameterByName('until', this_url),
961						  		until_new = (parseInt( $cff.find(item_sel+'.cff-' + key).last().attr('data-cff-timestamp') ) - 1).toString();
962
963						  	//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
964						  	if( isNaN(parseFloat(until_new)) ){
965						  		until_new = (parseInt( $cff.find(item_sel).last().attr('data-cff-timestamp') ) - 1).toString();
966						  	}
967
968						  	
969						  	var new_url = this_url;
970
971						  	if( $cffLoadMore.attr('data-cff-no-posts-added') == 'true' ){
972						  		//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
973						  	} else {
974						  		//If it's a regular timeline feed then add the "until" param
975						  		if( item_sel !== '.cff-album-item' ){
976
977							  		//V2.9+ of the API don't include "until" in the next url so only replace it if it exists
978							  		if( this_url.indexOf("until=") !== -1 ){
979							  			//Replace old until value with new one in the URL
980							  			var new_url = this_url.replace("until="+until_old,"until="+until_new);
981							  		} else {
982							  			//If "until" doesn't exist then add it to the end of the URL
983							  			var new_url = this_url + "&until="+until_new;
984							  		}
985
986							  		//Remove the "after" param as it overrides the "until" param
987							  		if( new_url.indexOf('&after=') > -1 ) new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
988
989							  	}
990
991						  	}
992
993						  	//USE OFFSET PAGINATION METHOD
994						  	if( cff_grid_pag == 'offset' ){
995						  		if( item_sel == '.cff-album-item' ){
996						  			//If it's an album item then remove the "after" param as it overrides the "until" param
997						  			if( new_url.indexOf('&after=') > -1 ) new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
998
999						  			//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
1000						  			key = key.replace( /(:|\.|\[|\]|,|=)/g, "\\$1" );
1001						  			var albumItemCount = $cff.find('.cff-album-item.cff-' + key).length + $cff.find('.cff-empty-album.cff-' + key).length;
1002						  			if( new_url.indexOf('&offset=') > -1 ){
1003						  				new_url = new_url.replace("&offset="+cffGetParameterByName('offset', new_url), "&offset="+albumItemCount);
1004						  			} else {
1005						  				new_url = new_url + "&offset=" + albumItemCount;
1006						  			}
1007						  			key = key.replace(/\\/g, '');
1008						  		}
1009						  	}
1010							//END USE OFFSET PAGINATION METHOD
1011
1012
1013						  	//If it's an events only URL then remove the "after" param as we're using the "until" value instead
1014						  	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') ) ){
1015						  		new_url = new_url.replace("&after="+cffGetParameterByName('after', new_url),"");
1016						  	}
1017
1018						  	//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"
1019						  	if( new_url.indexOf('&__paging_token') > -1 ){
1020						  		new_url = new_url.replace("&__paging_token="+cffGetParameterByName('__paging_token', new_url),"");
1021						  	}
1022
1023						  	pag_url_arr[key] = new_url;
1024					  	}
1025					} // End pag_url_arr loop
1026				} // End cff_timeline_api_paging if/else
1027
1028				//Convert the array back into a string
1029				pag_url = JSON.stringify( pag_url_arr );
1030
1031		        jQuery.ajax({
1032		            url : cffajaxurl,
1033		            type : 'post',
1034		            data : {
1035		                action : 'cff_get_new_posts',
1036		                shortcode_data : shortcodeData,
1037		                pag_url : pag_url
1038		            },
1039		            success : function(data) {
1040
1041	            		//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
1042	            		//Check by seeing if the data contains a div (ie. post)
1043	            		if( data.indexOf('<div class=') == -1 && data.indexOf('<span class=') == -1 ){
1044	            			$cffLoadMore.attr('data-cff-no-posts-added', 'true');
1045	            		} else {
1046	            			$cffLoadMore.attr('data-cff-no-posts-added', 'false');
1047	            		}
1048
1049		                //Appends the html echoed out in cff_get_new_posts() to the last existing post element
1050		                if( $cff.find('.cff-item, .cff-album-item').length ){
1051		                	$cff.find('.cff-item, .cff-album-item').removeClass('cff-new').last().after(data);
1052		                } else {
1053		                	//If there's no posts yet then just add it into the posts container
1054		                	$cff.find('.cff-posts-wrap').append(data);
1055		                }
1056
1057		                //Replace any duplicate album items with empty items so doesn't affect offset pagination 
1058		                $cff.find('.cff-album-item').each(function (i) {
1059							var $el = $('[id="' + this.id + '"]').eq(1);
1060							if($el.length){
1061								this_classes = $el.attr('class');
1062								this_classes = this_classes.replace("cff-album-item","");
1063							}
1064						});
1065
1066		                //Remove loader
1067	                  	$cffLoadMore.removeClass('cff-loading').find('.cff-loader').remove();
1068	                  	//Re-add the ID so it can be clicked again
1069	                  	$cffLoadMore.attr('id', 'cff-load-more').removeClass('cff-disabled');
1070
1071		                //Rerun JS (only runs on new items - .cff-new)
1072		                cff_init( $cff );
1073
1074		                //Re-init masonry
1075		                if( $cff.hasClass('cff-masonry-js') && !$cff.hasClass('cff-masonry-css') ){
1076
1077				            $cff.masonry('appended', $cff.find('.cff-new'));
1078
1079				            $cff.find('.cff-view-comments, .cff-comment-replies a, .cff-show-more-comments a').off().on('click', function() {
1080						        if( !$cff.hasClass('cff-opaque-comments') ){
1081						            setTimeout(function(){
1082						            	cffAddMasonry($cff);
1083						            }, 500);
1084						        }
1085						    });
1086
1087		                }
1088
1089		                //If there's no more API URLs to hit then hide the load more button
1090		                var next_urls = $cff.find('.cff-pag-url').attr('data-cff-pag-url');
1091		                if( item_sel == '.cff-item' || cff_grid_pag == 'cursor' ){
1092		                	if( next_urls == '{}' ) cff_no_more_posts($cff, $cffLoadMore);
1093		                } else {
1094		                	if( data.indexOf('class="cff-album-item') < 0 && data.indexOf('class="cff-empty-album') < 0 ){
1095		                		cff_no_more_posts($cff, $cffLoadMore);
1096		                	}
1097		                }
1098
1099		                // Call Custom JS if it exists
1100						// if (typeof cff_custom_js == 'function') setTimeout(function(){ cff_custom_js(jQuery); }, 100);
1101						if (typeof cff_custom_js == 'function') cff_custom_js(jQuery);
1102
1103		            } // End success
1104		        }); // End Ajax call
1105
1106		    }).hover( //Hover on Load More button
1107				function() {
1108			    	$(this).css('background', $(this).attr('data-cff-hover') );
1109			  	}, function() {
1110			    	$(this).css('background', $(this).attr('data-cff-bg') );
1111			  	}
1112			);
1113
1114			function cff_no_more_posts($cff, $cffLoadMore){
1115				var no_more_posts_text = ( $cffLoadMore.attr('data-no-more') == '' ) ? 'No more posts' : $cffLoadMore.attr('data-no-more').replace(/\\'/g,"'");
1116        		if( $cff.find('.cff-no-more-posts').length < 1 ) $cffLoadMore.hide().after('<p class="cff-no-more-posts">'+no_more_posts_text+'</p>');
1117        		$cff.find('.cff-error-msg').remove();
1118			}
1119
1120		    //Remove the masonry css class if it's a grid feed
1121		    if( $cff.find('.cff-album-item').length ){
1122            	$cff.removeClass('cff-masonry cff-masonry-js cff-masonry-css');
1123        	}
1124
1125	        //Multiple event dates toggle
1126			$cff.find('.cff-more-dates').on('click', function(){
1127				$(this).siblings('.cff-multiple-dates').slideToggle(100);
1128			});
1129
1130
1131		}); // End .$('.cff-wrapper').each
1132
1133
1134		//GET/CACHE COMMENTS
1135		//Check if the meta transient exists (set in head JS vars) and that a timeline feed exists on the page
1136		if(cffmetatrans != 'false' && $('.cff-timeline-feed').length && (typeof cffdisablecommentcaching == 'undefined') ){
1137
1138			//If the comments data is cached then get it from the transient in the DB
1139			$.ajax({
1140			    url: cffajaxurl,
1141			    type: 'POST',
1142		        async: true,
1143		        cache: false,
1144		        data:{
1145		            action: 'get_meta'
1146		        },
1147			    success: function(data) {
1148
1149			      	//If there's no data then set the array to be empty so that it hits the API for the data
1150			      	if( data == '' || data.length < 1 ){
1151			      		metaArr = [];
1152			      	} else {
1153			      		//Decode the JSON to that it can be used again
1154			            data = decodeURI(data);
1155
1156			            //Replace any escaped single quotes as it results in invalid JSON
1157			            data = data.replace(/\\'/g, "'");
1158
1159			            //Convert the cached JSON string back to a JSON object
1160			            metaArr = JSON.parse( data );
1161			      	}
1162
1163			      	// $cff.find('.cff-item.cff-new').each(function(){
1164			      	$cff.each(function(){
1165			      		$(this).find('.cff-item.cff-new:not(.cff-event)').each(function(){
1166				      		var $self = $(this),
1167				      			post_id_orig = $self.find('.cff-view-comments').attr('id'),
1168				      			object_id = $self.closest('.cff-item').attr('data-object-id');
1169
1170				      		//If the post ID doesn't exist in the array then use the API to get the data
1171				      		if( metaArr.hasOwnProperty(post_id_orig) ){
1172				      			cffCreateComments($self, metaArr[post_id_orig]);
1173				      			cffAddFullsizeImageURLs($self, metaArr[post_id_orig]);
1174				      		} else {
1175				      			cffGetMetaAPI($self, post_id_orig, object_id);
1176				      		}		
1177						});
1178			      	});
1179							
1180				},
1181				error: function(xhr,textStatus,e) {
1182		            return; 
1183		        }
1184
1185			}); //End ajax
1186
1187		} else {
1188
1189			$('#cff .cff-item.cff-new:not(.cff-event)').each(function(){
1190		  		var $self = $(this),
1191		  			post_id_orig = $self.find('.cff-view-comments').attr('id'),
1192		  			object_id = $self.closest('.cff-item').attr('data-object-id');
1193
1194		  		cffGetMetaAPI($self, post_id_orig, object_id);
1195			});			
1196
1197		} //END GET/CACHE COMMENTS
1198
1199
1200		function cffGetMetaAPI($self, post_id_orig, object_id){
1201
1202			//If there's no comments box on the page then return so we don't hit the API to get the data
1203			if( $self.find('.cff-view-comments').length == 0 ) return;
1204			
1205			if( typeof object_id == 'undefined' || object_id.length < 2 ) object_id = '';
1206
1207			var object_id_query = ''+object_id,
1208				post_id_query = '?post_id='+post_id_orig,
1209				use_id = 'object',
1210				post_comment_count = $self.find('.cff-comments .cff-count').text(),
1211				post_likes_count = $self.find('.cff-likes .cff-count').text(),
1212				cff_page_id = $self.attr('data-page-id');
1213
1214			if( typeof post_comment_count == 'undefined' || post_comment_count == '' ) post_comment_count = 0;
1215			if( typeof post_likes_count == 'undefined' || post_likes_count == '' ) post_likes_count = 0;
1216
1217			//If it's a video post or there's no object ID then use the post ID (video posts don't have "images" field)
1218			// if( typeof object_id == 'undefined' || object_id.length < 2 || $self.hasClass('cff-video-post') ) use_id = 'post';
1219			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';
1220
1221			var timeline_event = '';
1222			if( $self.hasClass('cff-timeline-event') ) timeline_event = '&timeline_event=true';
1223
1224			var usegrouptoken = '',
1225				useowntoken = '';
1226			if( $self.closest('#cff').hasClass('cff-group') ) usegrouptoken = '&usegrouptoken=true';
1227			if( $self.closest('#cff').attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
1228
1229			shortcode_token_param = cffGetShortcodeToken( $self.closest('#cff') );
1230
1231			//Is it a video post? If so, then we may be able to use the object ID to get the embeddable video object
1232			var cff_is_video_post = $self.hasClass('cff-video-post') ? '&isvideo=true' : '';
1233
1234			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_like
1234s_count + '&type=meta' + cff_is_video_post + '&pageid=' + cff_page_id + shortcode_token_param;
1235
1236			if( $self.hasClass('cff-album') ) url += '&timelinealbum=true';
1237
1238			//Get comments, reactions, and full size images data from the API
1239			if( locatefile == true ){
1240				$.ajax({
1241		      		method: "GET",
1242		     		url: url,
1243		      		success: function(data) {
1244
1245		      			//Cache the comments by adding to the cache array
1246						metaArr[ post_id_orig ] = data;
1247						newMetaArr[ post_id_orig ] = data; //This is cached. Only the new comments.
1248
1249						//Add the comments HTML
1250						cffCreateComments($self, data);
1251
1252						//Replace images URLs with full size ones
1253						cffAddFullsizeImageURLs($self, data);
1254
1255						//Set the cache
1256						cffSetMetaCache(newMetaArr);
1257		      	
1258					}//End ajax success
1259
1260				});
1261			}
1262
1263  		} //End cffGetMetaAPI()
1264
1265  		//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.
1266		var cffSetMetaCache_executed = false;
1267		function cffSetMetaCache(newMetaArr){
1268
1269			if( typeof cffdisablecommentcaching != 'undefined' ) return;
1270
1271			if( !cffSetMetaCache_executed ){
1272
1273				//Cache the comments data
1274				var cffTimesCached = 0,
1275				cffCacheDelay = setTimeout(function() {
1276					//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
1277					var cffCacheInterval = setInterval(function(){
1278						
1279						cffCacheMeta(newMetaArr);
1280
1281						cffTimesCached++;
1282						if(cffTimesCached == 2) clearInterval(cffCacheInterval);
1283					}, 3000);
1284
1285					//Send the data to DB initially via ajax after a 0.5 second delay
1286					cffCacheMeta(newMetaArr);
1287				}, 500);
1288
1289				cffSetMetaCache_executed = true;
1290
1291			} // End cffRunFunction check
1292
1293
1294			//Cache the likes and comments counts by sending an array via ajax to the main plugin file which then stores it in a transient
1295			function cffCacheMeta(newMetaArr){
1296
1297				//Convert the JSON object to a string
1298		        var jsonstring = JSON.stringify( newMetaArr );
1299
1300		        //Encode the JSON string so that it can be stored in the database
1301		        jsonstring = encodeURI(jsonstring);
1302
1303				//Cache the data
1304				var opts = {
1305			        url: cffajaxurl,
1306			        type: 'POST',
1307			        async: true,
1308			        cache: false,
1309			        data:{
1310			            action: 'cache_meta',
1311			            metadata: jsonstring // Passes array of meta data to WP to cache
1312			        },
1313			        success: function(response) {
1314			            return; 
1315			        },
1316			        error: function(xhr,textStatus,e) {
1317			            return; 
1318			        }
1319			    };
1320			    $.ajax(opts);
1321			    
1322			} // End cffCacheMeta()
1323
1324		} // End cffSetMetaCache()
1325
1326
1327		function cffGetParameterByName(name, url) {
1328		    name = name.replace(/[\[\]]/g, "\\$&");
1329		    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
1330		        results = regex.exec(url);
1331		    if (!results) return null;
1332		    if (!results[2]) return '';
1333		    return decodeURIComponent(results[2].replace(/\+/g, " "));
1334		}
1335
1336		function cffLinkify(inputText) {
1337		    var replacedText, replacePattern1, replacePattern2, replacePattern3;
1338
1339		    //URLs starting with http://, https://, or ftp://
1340		    replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
1341		    replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank" rel="nofollow noopener noreferrer">$1</a>');
1342
1343		    //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
1344		    replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
1345		    replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank" rel="nofollow noopener noreferrer">$2</a>');
1346
1347		    //Change email addresses to mailto:: links.
1348		    replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
1349		    replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
1350
1351		    return replacedText;
1352		}
1353
1354
1355		//HTML5 Video play button
1356		$(document).off('click', '#cff .cff-html5-video .cff-html5-play').on('click', '#cff .cff-html5-video .cff-html5-play', function(e){
1357			e.preventDefault();
1358
1359			var $self = $(this),
1360				$videoWrapper = $self.closest('.cff-html5-video'),
1361				video = $self.siblings('video')[0];
1362			video.play();
1363			$self.hide();
1364			$self.siblings('.cff-poster').hide();
1365
1366			//Show controls when the play button is clicked
1367			if (video.hasAttribute("controls")) {
1368			    video.removeAttribute("controls")   
1369			} else {
1370			    video.setAttribute("controls","controls")   
1371			}
1372
1373			if($videoWrapper.innerWidth() < 150 && !$videoWrapper.hasClass('cff-no-video-expand')) {
1374				$videoWrapper.css('width','100%').closest('.cff-item').find('.cff-text-wrapper').css('width','100%');
1375			}
1376		});
1377
1378
1379		//Replace the lightbox image with the full size image which is retrieved in the meta API request
1380		function cffAddFullsizeImageURLs($self, data){
1381			var data = jQuery.parseJSON( data );
1382
1383			if( typeof data.images !== 'undefined' && data.images !== null ) $self.find('.cff-lightbox-link').attr('href', data.images[0].source);
1384			
1385			//Removed in v3.7 as shouldn't be needed any longer. Commenting out in case needs to be re-added.
1386			//Add the full size video image which is retrieved from query.php to fix the Facebook video image size API bug
1387			// if( $self.find('.cff-html5-video').length && typeof data.attachments !== 'undefined' && data.attachments !== null ){
1388			// 	$self.find('.cff-poster').attr('src', data.attachments.data[0].media.image.src);
1389			// 	console.log( data.attachments.data[0] );
1390			// 	$self.find('.cff-lightbox-link').attr('href', data.attachments.data[0].media.image.src);
1391			// }
1392		}
1393
1394
1395		//Create comments
1396		function cffCreateComments($self, data){
1397
1398			if (data.substring(0, 1) == "<") return false;
1399
1400			//Convert string of data received from comments.php to a JSON object
1401      		var data = jQuery.parseJSON( data ),
1402      			cff_comments = '',
1403      			cff_likes_this = '',
1404      			commentShow = parseInt( $self.find('.cff-comments-box').attr('data-num') ),
1405      			like_count = ( typeof data.likes !== 'undefined' ) ? data.likes.summary.total_count : 0
1406      			$cffCommentsBox = $self.find('.cff-comments-box'),
1407      			$cffCommentLikes = $cffCommentsBox.find('.cff-comment-likes'),
1408      			cff_hide_comment_avatars = Boolean($self.find('.cff-comments-box').attr('data-cff-hide-avatars')),
1409      			cff_expand_comments = Boolean($self.find('.cff-comments-box').attr('data-cff-expand-comments')),
1410      			cff_translate_like_this_text = $cffCommentsBox.attr('data-cff-like-text'),
1411      			cff_translate_likes_this_text = $cffCommentsBox.attr('data-cff-likes-text'),
1412      			cff_translate_reacted_to_this_text = $cffCommentsBox.attr('data-cff-reacted-text'),
1413      			cff_translate_and_text = $cffCommentsBox.attr('data-cff-and-text'),
1414      			cff_translate_other_text = $cffCommentsBox.attr('data-cff-other-text'),
1415      			cff_translate_others_text = $cffCommentsBox.attr('data-cff-others-text'),
1416      			cff_translate_reply_text = $cffCommentsBox.attr('data-cff-reply-text'),
1417      			cff_translate_replies_text = $cffCommentsBox.attr('data-cff-replies-text'),
1418      			cff_total_comments_count = ( typeof data.comments !== 'undefined' ) ? data.comments.summary.total_count : 0,
1419	      		cff_meta_link_color = $self.find('.cff-comments-box').attr('data-cff-meta-link-color'),
1420				cff_post_tags = Boolean( $self.find('.cff-comments-box').attr('data-cff-post-tags') );
1421
1422      		//ADD REACTIONS
1423			var cff_haha_count = ( typeof data.haha !== 'undefined' ) ? data.haha.summary.total_count : 0;
1424			var cff_love_count = ( typeof data.love !== 'undefined' ) ? data.love.
1424summary.total_count : 0;
1425			var cff_wow_count = ( typeof data.wow !== 'undefined' ) ? data.wow.summary.total_count : 0;
1426			var cff_sad_count = ( typeof data.sad !== 'undefined' ) ? data.sad.summary.total_count : 0;
1427			var cff_angry_count = ( typeof data.angry !== 'undefined' ) ? data.angry.summary.total_count : 0;
1428
1429			var reactions_arr = [cff_haha_count, cff_love_count, cff_wow_count, cff_sad_count, cff_angry_count];
1430			var reaction_first_num = reactions_arr.sort(sortNumber)[0];
1431			var reaction_second_num = reactions_arr.sort(sortNumber)[1];
1432
1433			//Sort array highest to lowest
1434			function sortNumber(a,b) {
1435			    return b - a;
1436			}
1437
1438			var reactions_html = '',
1439				love_added = false,
1440				haha_added = false,
1441				wow_added = false,
1442				sad_added = false,
1443				angry_added = false,
1444				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>',
1445				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-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-1
14455.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>',
1446				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>',
1447				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>',
1448				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>',
1449				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 
1449192 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>',
1450				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>';
1451
1452
1453			//Add first reaction
1454			var reaction_one_html = '';
1455			if( reaction_first_num > 0 ){
1456				if(data.love.summary.total_count == reaction_first_num){
1457					reaction_one_html += '<span class="cff-love cff-reaction-one cff-icon">'+love_svg+'</span>';
1458					love_added = true;
1459				}
1460				if(data.haha.summary.total_count == reaction_first_num){
1461					reaction_one_html += '<span class="cff-haha cff-reaction-one cff-icon">'+haha_svg+'</span>';
1462					haha_added = true;
1463				}
1464				if(data.wow.summary.total_count == reaction_first_num){
1465					reaction_one_html += '<span class="cff-wow cff-reaction-one cff-icon">'+wow_svg+'</span>';
1466					wow_added = true;
1467				}
1468				if(data.sad.summary.total_count == reaction_first_num){
1469					reaction_one_html += '<span class="cff-sad cff-reaction-one cff-icon">'+sad_svg+'</span>';
1470					sad_added = true;
1471				}
1472				if(data.angry.summary.total_count == reaction_first_num){
1473					reaction_one_html += '<span class="cff-angry cff-reaction-one cff-icon">'+angry_svg+'</span>';
1474					angry_added = true;
1475				}
1476				reactions_html += reaction_one_html;
1477			}
1478
1479			//If reaction one doesn't already contain two reactions (eg: if the two reaction_one
1479s are the same number) then don't include a reaction_two
1480			if( reaction_one_html.split('cff-reaction-one').length < 3 ){
1481				//Add second reaction
1482				if( reaction_second_num > 0 ){
1483					var reaction_two_html = '';
1484
1485					if(data.love.summary.total_count == reaction_second_num && !love_added){
1486						reaction_two_html = '<span class="cff-love cff-reaction-two cff-icon">'+love_svg+'</span>';
1487					}
1488					if(data.haha.summary.total_count == reaction_second_num && !haha_added){
1489						reaction_two_html = '<span class="cff-haha cff-reaction-two cff-icon">'+haha_svg+'</span>';
1490					}
1491					if(data.wow.summary.total_count == reaction_second_num && !wow_added){
1492						reaction_two_html = '<span class="cff-wow cff-reaction-two cff-icon">'+wow_svg+'</span>';
1493					}
1494					if(data.sad.summary.total_count == reaction_second_num && !sad_added){
1495						reaction_two_html = '<span class="cff-sad cff-reaction-two cff-icon">'+sad_svg+'</span>';
1496					}
1497					if(data.angry.summary.total_count == reaction_second_num && !angry_added){
1498						reaction_two_html = '<span class="cff-angry cff-reaction-two cff-icon">'+angry_svg+'</span>';
1499					}
1500					reactions_html += reaction_two_html;
1501				}
1502			}
1503
1504			//Add the reaction icons
1505			if( $self.find('.cff-meta .cff-likes').find('.cff-icon').length < 2 ) $self.find('.cff-meta .cff-likes .cff-icon').after( reactions_html );
1506
1507			//If there's no likes but there's a reacton then don't show the like icon - show the reaction icon instead
1508			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 ) ){
1509				$self.find('.cff-meta .cff-likes .cff-like').remove();
1510				$self.find('.cff-meta .cff-likes span').addClass('cff-no-animate');
1511			}
1512
1513			//Add reactions to like count
1514			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);
1515			if( cff_reactions_count > 0 ) $self.find('.cff-meta .cff-likes .cff-count').text( cff_reactions_count );
1516
1517
1518			//ADDS REACTIONS TO COMMENTS BOX
1519			var cff_no_reactions = false;
1520			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;
1521
1522			var reactions_count_html = '<span class="cff-reactions-count">';
1523
1524			if( parseInt(like_count) > 0){
1525				reactions_count_html += '<span class="cff-like cff-icon">'+like_svg+'</span>';
1526
1527				if( !cff_no_reactions ){
1528					if( parseInt(like_count) > 0 ) reactions_count_html += '<span class="cff-like-count">
1528'+like_count+'</span>';
1529					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>';
1530					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>';
1531					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>';
1532					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>';
1533					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>';
1534				}
1535			}
1536			reactions_count_html += '</span>';
1537
1538  			//CREATE LIKES PART AT TOP OF COMMENTS BOX
1539      		if( typeof data.likes !== 'undefined' ){
1540	      		if( data.likes.data.length ){
1541
1542	      			cff_likes_this += '<span class="cff-likes-this-text">';
1543
1544		      		var liker_one = '',
1545		      			liker_two = '';
1546
1547			      	if ( like_count > 0 && typeof data.likes.data[0] !== 'undefined' ){
1548
1549			      		//Only link the name if a legit link is available for this user
1550			      		var userHasLink = false;
1551			      		if( typeof data.likes.data[0].link !== 'undefined' ){
1552			      			if( data.likes.data[0].link.indexOf('/app_scoped_user_id/') == -1 ) userHasLink = true;
1553			      		}
1554
1555			      		//Creat link or span
1556			      		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="';
1557			      		if (cff_no_reactions) liker_one += ' margin-left: 5px';
1558			      		liker_one += '">'+data.likes.data[0].name;
1559
1560			      		userHasLink ? liker_one += '</a>' : liker_one += '</span>';
1561			      	}
1562
1563		            if ( like_count > 1 && typeof data.likes.data[1] !== 'undefined' ){
1564
1565		            	//Only link the name if a legit link is available for this user
1566			      		var userHasLink = false;
1567			      		if( typeof data.likes.data[1].link !== 'undefined' ){
1568			      			if( data.likes.data[1].link.indexOf('/app_scoped_user_id/') == -1 ) userHasLink = true;
1569			      		}
1570
1571			      		//Creat link or span
1572			      		userHasLink ? liker_two += '<a href="'+data.likes.data[1].link+'" target="_blank" rel="nofollow noopener" style="color:'+cff_meta_link_color+'">;' : liker_two = '<span>';
1573			      		liker_two += data.likes.data[1].name;
1574
1575			      		userHasLink ? liker_two += '</a>' : liker_two += '</span>';
1576		            }
1577
1578		            if (like_count == 1){
1579		                cff_likes_this += liker_one+' '+cff_translate_likes_this_text;
1580		            } else if (like_count == 2){
1581		                cff_likes_this += liker_one+' '+cff_translate_and_text+' '+liker_two+' '+cff_translate_like_this_text;
1582		            } else if (like_count == 3){
1583		                cff_likes_this += liker_one+', '+liker_two+' '+cff_translate_and_text+' 1 '+cff_translate_other_text+' '+cff_translate_like_this_text;
1584		            } else {
1585		                cff_likes_this += liker_one+', '+liker_two+' '+cff_translate_and_text+' ';
1586		                if (like_count == 25) cff_likes_this += '<span class="cff-comment-likes-count">';
1587		                cff_likes_this += parseInt(cff_reactions_count)-2;
1588		                if (like_count == 25) cff_likes_this += '</span>';
1589		                cff_likes_this += ' '+cff_translate_others_text;
1590
1591		                if( parseInt(cff_reactions_count) == parseInt(like_count) ){
1592		                	cff_likes_this += ' '+cff_translate_like_this_text;
1593		                } else {
1594		                	cff_likes_this += ' '+cff_translate_reacted_to_this_text;
1595		                }
1596
1597		            }
1598
1599		            cff_likes_this += '</span>';
1600
1601	            	if( $cffCommentLikes.find('.cff-reactions-count').length < 1 ) $cffCommentLikes.append('<span class="cff-likes-info-wrap">' + reactions_count_html + cff_likes_this + '</span>');
1602
1603				} else {
1604					//If there's no likes data then hide the top of the comments box that shows the "likes this" section
1605					if( cff_no_reactions ){
1606						$cffCommentLikes.hide();
1607					} else {
1608						if( $cffCommentLikes.find('.cff-reactions-count').length < 1 ) $cffCommentLikes.append('<span class="cff-likes-info-wrap">' + reactions_count_html + '</span>');
1609					}
1610				}
1611
1612			}
1613			
1614
1615			if( typeof data.comments !== 'undefined' ){
1616	    		$.each(data.comments.data, function(i, commentItem) {
1617
1618	    			//Do a final encode of the comment message
1619	    			var comment_message = cffEncodeHTML(commentItem.message),
1620	    				comment_message = cffLinkify(comment_message),
1621	    				cff_comment_author_info = true;
1622
1623	    			//Check whether comment author info exists - only accessible with page access token from the page now
1624	    			if( typeof commentItem.from !== 'undefined' ){
1625	    				cff_comment_from_id = commentItem.from.id;
1626	    			} else {
1627	    				cff_hide_comment_avatars = true;
1628	    				cff_comment_author_info = false;
1629	    				cff_comment_from_id = '';
1630	    			}
1631
1632	    			cff_comments += '<div class="cff-comment" id="cff_'+commentItem.id+'" data-id="'+cff_comment_from_id+'"';
1633	    			cff_comments += ' style="';
1634	    			( i >= commentShow ) ? cff_comments += 'display: none;' : cff_comments += 'display: block;';
1635	    			if( typeof $self.find('#cff_'+commentItem.id).attr('style') !== 'undefined' ) cff_comments += $self.find('#cff_'+commentItem.id).attr('style');
1636	    			cff_comments += '"';
1637	    			if( typeof commentItem.from !== 'undefined' ){
1638	    				if( typeof commentItem.from.picture !== 'undefined' ){
1639	    					cff_comments += 'data-avatar="'+commentItem.from.picture.data.url+'"';
1640	    				}
1641	    			}
1642	    			cff_comments += '>';
1643		          	cff_comments += '<div class="cff-comment-text-wrapper">';
1644		          	cff_comments += '<div class="cff-comment-text';
1645		          	if( cff_hide_comment_avatars ) cff_comments += ' cff-no-image';
1646		          	cff_comments += '"><p>';
1647		          	if( cff_comment_author_info ){
1648		          		if( typeof commentItem.from.link !== 'undefined' ){
1649		          			cff_comments += '<a href="'+commentItem.from.link+'" class="cff-name" target="_blank" rel="nofollow noopener" style="color:' + cff_meta_link_color + '">
1649'+commentItem.from.name+'</a>';
1650		          		} else {
1651		          			cff_comments += '<span class="cff-name">'+commentItem.from.name+'</span>';
1652		          		}
1653		          	}
1654
1655					//MESSAGE TAGS
1656					if( cff_post_tags && commentItem.hasOwnProperty('message_tags') ){
1657
1658						//Loop through the tags and use the name to replace them
1659						$.each(commentItem.message_tags, function(i, message_tag) {
1660						   tag_name = message_tag.name;
1661						   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>';
1662
1663						   comment_message = comment_message.replace(tag_name, tag_link);
1664						});
1665
1666					} //END MESSAGE TAGS
1667
1668	          		cff_comments += comment_message+'</p>';
1669
1670
1671					//Add image attachment if exists
1672					if( commentItem.hasOwnProperty('attachment') ){
1673					  if( commentItem.attachment.hasOwnProperty('media') ){
1674					    	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="';
1675					    	if( commentItem.attachment.hasOwnProperty('title') ){
1676					        	cff_comments += commentItem.attachment.title;
1677					    	} else {
1678					    		cff_comments += 'Attachment';
1679					      	}
1680					      	cff_comments += '" /></a>';
1681					  	}
1682					}
1683
1684					cff_comments += '<span class="cff-time">';
1685					var cff_middot = '',
1686						cff_comment_time = $self.find('#cff_'+commentItem.id).attr('data-cff-comment-date');
1687					//If the time is undefined then don't show it
1688					if( typeof cff_comment_time !== 'undefined' ){
1689						cff_comments += '<span class="cff-comment-date">'+cff_comment_time+'</span>';
1690						cff_middot = '&nbsp; &middot; &nbsp;';
1691					}
1692					if ( commentItem.like_count > 0 ) cff_comments += '<span class="cff-comment-likes"><span class="cff-comment-likes-bg"><b>'+like_svg_2+'</b>
1692'+commentItem.like_count+'</span></span>';
1693					cff_comments += '</span>';
1694
1695					//Comment replies
1696					var cff_comment_count = parseInt(commentItem.comment_count);
1697					if( cff_comment_count > 0 ){
1698						//Get this from a data attr on the comments box container
1699						var cff_replies_text_string = '';
1700						(cff_comment_count == 1) ? cff_replies_text_string = cff_translate_reply_text : cff_replies_text_string = cff_translate_replies_text;
1701						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>';
1702					}
1703
1704					cff_comments += '</div>'; //End .cff-comment-text
1705					cff_comments += '</div>'; //End .cff-comment-text-wrapper
1706
1707					//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
1708					if( !cff_hide_comment_avatars && cff_comment_author_info ){
1709							cff_comments += '<div class="cff-comment-img cff-avatar-fallback">';
1710							if( typeof commentItem.from.link !== 'undefined' ) cff_comments += '<a href="https://facebook.com/'+commentItem.from.link+'" target="_blank" rel="noopener">';
1711					  	if( cff_expand_comments && (i < commentShow) ) {
1712					    	cff_comments += '<img src="'+commentItem.from.picture.data.url+'" width=32 height=32 alt="'+commentItem.from.name+'" onerror="this.style.display=\'none\'">';
1713					  	} else {
1714					    	cff_comments += '<span class="cff-comment-avatar"></span>';
1715					  	}
1716					  	if( typeof commentItem.from.link !== 'undefined' ) cff_comments += '</a>';
1717					  	cff_comments += '</div>';
1718					}
1719
1720					cff_comments += '</div>'; //End .cff-comment
1721
1722				}); //End data.comments.data loop
1723
1724			} //End if
1725
1726			//Remove the comments added for SEO in PHP
1727			$self.find('.cff-comments-wrap .cff-comment').remove();
1728			//Add the comments to the page
1729			$self.find('.cff-comments-wrap').prepend( cff_comments );
1730			$self.find('.cff-show-more-comments').attr('data-cff-comments-total', cff_total_comments_count);
1731
1732			//Add border radius
1733			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});
1734			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});
1735			//Add a little more padding if there's no comments
1736			if( $self.find('.cff-comments-wrap .cff-comment').length < 1 ) $self.find('.cff-comment-on-facebook').css('padding','8px 15px 8px 10px');
1737
1738			setTimeout(function(){
1739        		if( $self.closest('.cff').hasClass('cff-masonry-js') && !$self.closest('.cff').hasClass('cff-masonry-css') ) cffAddMasonry( $self.closest('.cff') );
1740      		}, 200);
1741
1742		} //End cffCreateComments()
1743
1744
1745		//Create shared link multi-image slider
1746		setTimeout(function(){
1747
1748			$cff.find('.cff-link-slider').each(function(){
1749
1750				var $cffLinkSlider = $(this),
1751					$cffLinkSliderSlides = $cffLinkSlider.find('.cff-link-slider-slides'),
1752					$cffLinkSliderItem = $cffLinkSliderSlides.find('.cff-link-slider-item'),
1753					cffLinkSliderCount = $cffLinkSliderItem.length,
1754					cffLinkSliderWidth = $cffLinkSlider.width(),
1755					cffCurSlide = 0;
1756				$cffLinkSliderSlides.css({ width: cffLinkSliderWidth * cffLinkSliderCount });
1757				$cffLinkSliderItem.css({ width: cffLinkSliderWidth });
1758
1759			    function cffMoveSlide(dir) {
1760			    	//Change slides
1761			    	dir == 'prev' ?	cffCurSlide-- : cffCurSlide++;
1762			        $cffLinkSliderSlides.css('left', -cffCurSlide*cffLinkSliderWidth);
1763
1764			        //Hide the nav arrows at beginning/end
1765			    	cffCurSlide == cffLinkSliderCount-1 ? $cffLinkSlider.find('a.cff-slider-next').hide() : $cffLinkSlider.find('a.cff-slider-next').show();
1766			    	cffCurSlide > 0 ? $cffLinkSlider.find('a.cff-slider-prev').show() : $cffLinkSlider.find('a.cff-slider-prev').hide();
1767			    };
1768			    //Nav arrows click
1769			    $cffLinkSlider.find('a.cff-slider-prev, a.cff-slider-next').click(function(e){
1770			    	e.preventDefault();
1771			        $(this).hasClass('cff-slider-prev') ? cffMoveSlide('prev') : cffMoveSlide('next');
1772			    });
1773			    //Vertically center last image in slider
1774			    setTimeout(function(){
1775			    	var cffLastSlideHeight = $cffLinkSliderSlides.find('.cff-link-slider-item').first().height();
1776			    	$cffLinkSliderSlides.find('.cff-final-item').css('height', cffLastSlideHeight).find('img').css('margin-top', (cffLastSlideHeight/2)-100 );
1777			    }, 1500);
1778
1779			    //Show all slides (initially hidden in CSS)
1780			    $cffLinkSliderSlides.find('.cff-link-slider-item').show();
1781
1782			});
1783
1784		}, 200);
1785
1786
1787	})(jQuery); //End (function($){ 
1788
1789
1790
1791
1792	/*!
1793	imgLiquid v0.9.944 / 03-05-2013
1794	https://github.com/karacas/imgLiquid
1795	*/
1796
1797	var imgLiquid = imgLiquid || {VER: '0.9.944'};
1798	imgLiquid.bgs_Available = false;
1799	imgLiquid.bgs_CheckRunned = false;
1800	//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.
1801	jQuery('.cff-new .cff-album-cover img, .cff-new .cff-crop img').css('visibility', 'hidden');
1802	jQuery('#cff .cff-img-attachments .cff-crop img').css('opacity', 0);
1803
1804
1805	(function ($) {
1806
1807		// ___________________________________________________________________
1808
1809		function checkBgsIsavailable() {
1810			if (imgLiquid.bgs_CheckRunned) return;
1811			else imgLiquid.bgs_CheckRunned = true;
1812
1813			var spanBgs = $('<span style="background-size:cover" />');
1814			$('body').append(spanBgs);
1815
1816			!function () {
1817				var bgs_Check = spanBgs[0];
1818				if (!bgs_Check || !window.getComputedStyle) return;
1819				var compStyle = window.getComputedStyle(bgs_Check, null);
1820				if (!compStyle || !compStyle.backgroundSize) return;
1821				imgLiquid.bgs_Available = (compStyle.backgroundSize === 'cover');
1822			}();
1823
1824			spanBgs.remove();
1825		}
1826
1827
1828		// ___________________________________________________________________
1829
1830		$.fn.extend({
1831			imgLiquid: function (options) {
1832
1833				this.defaults = {
1834					fill: true,
1835					verticalAlign: 'center',			//	'top'	//	'bottom' // '50%'  // '10%'
1836					horizontalAlign: 'center',			//	'left'	//	'right'  // '50%'  // '10%'
1837					useBackgroundSize: false,
1838					useDataHtmlAttr: true,
1839
1840					responsive: true,					/* Only for use with BackgroundSize false (or old browsers) */
1841					delay: false,							/* Only for use with BackgroundSize false (or old browsers) */
1842					fadeInTime: false,						/* Only for use with BackgroundSize false (or old browsers) */
1843					removeBoxBackground: true,			/* Only for use with BackgroundSize false (or old browsers) */
1844					hardPixels: true,					/* Only for use with BackgroundSize false (or old browsers) */
1845					responsiveCheckTime: 500,			/* Only for use with BackgroundSize false (or old browsers) */ /* time to check div resize */
1846					timecheckvisibility: 500,			/* Only for use with BackgroundSize false (or old browsers) */ /* time to recheck if visible/loaded */
1847
1848					// CALLBACKS
1849					onStart: null,						// no-params
1850					onFinish: null,						// no-params
1851					onItemStart: null,					// params: (index, container, img )
1852					onItemFinish: function(index, container, img){  // params: (index, container, img )
1853						img.addClass('cffFadeIn');
1854					},					
1855					onItemError: null					// params: (index, container, img )
1856				};
1857
1858				checkBgsIsavailable();
1859				var imgLiquidRoot = this;
1860
1861				// Extend global settings
1862				this.options = options;
1863				this.settings = $.extend({}, this.defaults, this.options);
1864
1865				// CallBack
1866				if (this.settings.onStart) this.settings.onStart();
1867
1868
1869				// ___________________________________________________________________
1870
1871				return this.each(function ($i) {
1872
1873					// MAIN >> each for image
1874
1875					var settings = imgLiquidRoot.settings,
1876					$imgBoxCont = $(this),
1877					$img = $('img:first',$imgBoxCont);
1878					if (!$img.length) {onError(); return;}
1879
1880
1881					// Extend settings
1882					if (!$img.data('imgLiquid_settings')) {
1883						// First time
1884						settings = $.extend({}, imgLiquidRoot.settings, getSettingsOverwrite());
1885					} else {
1886						// Recall
1887						// Remove Classes
1888						$imgBoxCont.removeClass('imgLiquid_error').removeClass('imgLiquid_ready');
1889						settings = $.extend({}, $img.data('imgLiquid_settings'), imgLiquidRoot.options);
1890					}
1891					$img.data('imgLiquid_settings', settings);
1892
1893
1894					// Start CallBack
1895					if (settings.onItemStart) settings.onItemStart($i, $imgBoxCont, $img); /* << CallBack */
1896
1897
1898					// Process
1899					if (imgLiquid.bgs_Available && settings.useBackgroundSize)
1900						processBgSize();
1901					else
1902						processOldMethod();
1903
1904
1905					// END MAIN <<
1906
1907					// ___________________________________________________________________
1908
1909					function processBgSize() {
1910
1911						// Check change img src
1912						if ($imgBoxCont.css('background-image').indexOf(encodeURI($img.attr('src'))) === -1) {
1913							// Change
1914							$imgBoxCont.css({'background-image': 'url("' + encodeURI($img.attr('src')) + '")'});
1915						}
1916
1917						$imgBoxCont.css({
1918							'background-size':		(settings.fill) ? 'cover' : 'contain',
1919							'background-position':	(settings.horizontalAlign + ' ' + settings.verticalAlign).toLowerCase(),
1920							'background-repeat':	'no-repeat'
1921						});
1922
1923						$('a:first', $imgBoxCont).css({
1924							'display':	'block',
1925							'width':	'100%',
1926							'height':	'100%'
1927						});
1928
1929						$('img', $imgBoxCont).css({'display': 'none'});
1930
1931						if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
1932
1933						$imgBoxCont.addClass('imgLiquid_bgSize');
1934						$imgBoxCont.addClass('imgLiquid_ready');
1935						checkFinish();
1936					}
1937
1938					// ___________________________________________________________________
1939
1940					function processOldMethod() {
1941
1942						// Check change img src
1943						if ($img.data('oldSrc') && $img.data('oldSrc') !== $img.attr('src')) {
1944
1945							/* Clone & Reset img */
1946							var $imgCopy = $img.clone().removeAttr('style');
1947							$imgCopy.data('imgLiquid_settings', $img.data('imgLiquid_settings'));
1948							$img.parent().prepend($imgCopy);
1949							$img.remove();
1950							$img = $imgCopy;
1951							$img[0].width = 0;
1952
1953							// Bug ie with > if (!$img[0].complete && $img[0].width) onError();
1954							setTimeout(processOldMethod, 10);
1955							return;
1956						}
1957
1958
1959						// Reproceess?
1960						if ($img.data('imgLiquid_oldProcessed')) {
1961							makeOldProcess(); return;
1962						}
1963
1964
1965						// Set data
1966						$img.data('imgLiquid_oldProcessed', false);
1967						$img.data('oldSrc', $img.attr('src'));
1968
1969
1970						// Hide others images
1971						$('img:not(:first)', $imgBoxCont).css('display', 'none');
1972
1973
1974						// CSSs
1975						$imgBoxCont.css({'overflow': 'hidden'});
1976						$img.fadeTo(0, 0).removeAttr('width').removeAttr('height').css({
1977							'visibility': 'visible',
1978							'max-width': 'none',
1979							'max-height': 'none',
1980							'width': 'auto',
1981							'height': 'auto',
1982							'display': 'block'
1983						});
1984
1985
1986						// CheckErrors
1987						$img.on('error', onError);
1988						$img[0].onerror = onError;
1989
1990
1991						// loop until load
1992						function onLoad() {
1993							if ($img.data('imgLiquid_error') || $img.data('imgLiquid_loaded') || $img.data('imgLiquid_oldProcessed')) return;
1994							if ($imgBoxCont.is(':visible') && $img[0].complete && $img[0].width > 0 && $img[0].height > 0) {
1995								$img.data('imgLiquid_loaded', true);
1996								setTimeout(makeOldProcess, $i * settings.delay);
1997							} else {
1998								setTimeout(onLoad, settings.timecheckvisibility);
1999							}
2000						}
2001
2002
2003						onLoad();
2004						checkResponsive();
2005					}
2006
2007					// ___________________________________________________________________
2008
2009					function checkResponsive() {
2010
2011						/* Only for oldProcessed method (background-size dont need) */
2012
2013						if (!settings.responsive && !$img.data('imgLiquid_oldProcessed')) return;
2014						if (!$img.data('imgLiquid_settings')) return;
2015
2016						settings = $img.data('imgLiquid_settings');
2017
2018						$imgBoxCont.actualSize = $imgBoxCont.get(0).offsetWidth + ($imgBoxCont.get(0).offsetHeight / 10000);
2019						if ($imgBoxCont.sizeOld && $imgBoxCont.actualSize !== $imgBoxCont.sizeOld) makeOldProcess();
2020
2021						$imgBoxCont.sizeOld = $imgBoxCont.actualSize;
2022						setTimeout(checkResponsive, settings.responsiveCheckTime);
2023					}
2024
2025					// ___________________________________________________________________
2026
2027					function onError() {
2028						$img.data('imgLiquid_error', true);
2029						$imgBoxCont.addClass('imgLiquid_error');
2030						if (settings.onItemError) settings.onItemError($i, $imgBoxCont, $img); /* << CallBack */
2031						checkFinish();
2032					}
2033
2034					// ___________________________________________________________________
2035
2036					function getSettingsOverwrite() {
2037						var SettingsOverwrite = {};
2038
2039						if (imgLiquidRoot.settings.useDataHtmlAttr) {
2040							var dif = $imgBoxCont.attr('data-imgLiquid-fill'),
2041							ha =  $imgBoxCont.attr('data-imgLiquid-horizontalAlign'),
2042							va =  $imgBoxCont.attr('data-imgLiquid-verticalAlign');
2043
2044							if (dif === 'true' || dif === 'false') SettingsOverwrite.fill = Boolean (dif === 'true');
2045							if (ha !== undefined && (ha === 'left' || ha === 'center' || ha === 'right' || ha.indexOf('%') !== -1)) SettingsOverwrite.horizontalAlign = ha;
2046							if (va !== undefined && (va === 'top' ||  va === 'bottom' || va === 'center' || va.indexOf('%') !== -1)) SettingsOverwrite.verticalAlign = va;
2047						}
2048
2049						if (imgLiquid.isIE && imgLiquidRoot.settings.ieFadeInDisabled) SettingsOverwrite.fadeInTime = 0; //ie no anims
2050						return SettingsOverwrite;
2051					}
2052
2053					// ___________________________________________________________________
2054
2055					function makeOldProcess() { /* Only for old browsers, or useBackgroun
2055dSize seted false */
2056
2057						// Calculate size
2058						var w, h, wn, hn, ha, va, hdif, vdif,
2059						margT = 0,
2060						margL = 0,
2061						$imgCW = $imgBoxCont.width(),
2062						$imgCH = $imgBoxCont.height();
2063
2064
2065						// Save original sizes
2066						if ($img.data('owidth')	=== undefined) $img.data('owidth',	$img[0].width);
2067						if ($img.data('oheight') === undefined) $img.data('oheight', $img[0].height);
2068
2069
2070						// Compare ratio
2071						if (settings.fill === ($imgCW / $imgCH) >= ($img.data('owidth') / $img.data('oheight'))) {
2072							w = '100%';
2073							h = 'auto';
2074							wn = Math.floor($imgCW);
2075							hn = Math.floor($imgCW * ($img.data('oheight') / $img.data('owidth')));
2076						} else {
2077							w = 'auto';
2078							h = '100%';
2079							wn = Math.floor($imgCH * ($img.data('owidth') / $img.data('oheight')));
2080							hn = Math.floor($imgCH);
2081						}
2082
2083						// Align X
2084						ha = settings.horizontalAlign.toLowerCase();
2085						hdif = $imgCW - wn;
2086						if (ha === 'left') margL = 0;
2087						if (ha === 'center') margL = hdif * 0.5;
2088						if (ha === 'right') margL = hdif;
2089						if (ha.indexOf('%') !== -1){
2090							ha = parseInt (ha.replace('%',''), 10);
2091							if (ha > 0) margL = hdif * ha * 0.01;
2092						}
2093
2094
2095						// Align Y
2096						va = settings.verticalAlign.toLowerCase();
2097						vdif = $imgCH - hn;
2098						if (va === 'left') margT = 0;
2099						if (va === 'center') margT = vdif * 0.5;
2100						if (va === 'bottom') margT = vdif;
2101						if (va.indexOf('%') !== -1){
2102							va = parseInt (va.replace('%',''), 10);
2103							if (va > 0) margT = vdif * va * 0.01;
2104						}
2105
2106
2107						// Add Css
2108						if (settings.hardPixels) {w = wn; h = hn;}
2109						$img.css({
2110							'width': w,
2111							'height': h,
2112							'margin-left': Math.floor(margL),
2113							'margin-top': Math.floor(margT)
2114						});
2115
2116
2117						// FadeIn > Only first time
2118						if (!$img.data('imgLiquid_oldProcessed')) {
2119							$img.fadeTo(settings.fadeInTime, 1);
2120							$img.data('imgLiquid_oldProcessed', true);
2121							if (settings.removeBoxBackground) $imgBoxCont.css('background-image', 'none');
2122							$imgBoxCont.addClass('imgLiquid_nobgSize');
2123							$imgBoxCont.addClass('imgLiquid_ready');
2124						}
2125
2126
2127						if (settings.onItemFinish) settings.onItemFinish($i, $imgBoxCont, $img); /* << CallBack */
2128						checkFinish();
2129					}
2130
2131					// ___________________________________________________________________
2132
2133					function checkFinish() { /* Check callBack */
2134						if ($i === imgLiquidRoot.length - 1) if (imgLiquidRoot.settings.onFinish) imgLiquidRoot.settings.onFinish();
2135					}
2136
2137
2138				});
2139			} //End imgLiquid: function
2140		}); //End $.fn.extend
2141
2142	})(jQuery);
2143
2144
2145	//If a video is wrapped in this element then remove it as it causes an issue with some themes
2146	setTimeout(function(){
2147		jQuery('#cff .embed-responsive video, #cff .embed-responsive iframe').unwrap();
2148	}, 500);
2149
2150
2151	// Inject css styles ______________________________________________________
2152	!function () {
2153		var css = imgLiquid.injectCss,
2154		head = document.getElementsByTagName('head')[0],
2155		style = document.createElement('style');
2156		style.type = 'text/css';
2157		if (style.styleSheet) {
2158			style.styleSheet.cssText = css;
2159		} else {
2160			style.appendChild(document.createTextNode(css));
2161		}
2162		head.appendChild(style);
2163	}();
2164	jQuery(".cff-new .cff-album-cover").imgLiquid({fill:true});
2165	jQuery(".cff-new .cff-crop").imgLiquid({fill:true, useBackgroundSize:true});
2166
2167
2168
2169} //********* END cff_init() FUNCTION ************//
2170
2171cff_init();
2172
2173
2174//Get the Access Token from the shortcode so it can be used in the connect file
2175function cffGetShortcodeToken($cff){
2176	var shortcode_token_param = '';
2177	if ( $cff.attr('data-cff-shortcode') ){
2178		if( $cff.attr('data-cff-shortcode').indexOf('accesstoken') !== -1 ){
2179			var shortcode_att = $cff.attr('data-cff-shortcode'),
2180				shortcode_att_arr = JSON.parse( shortcode_att );
2181			shortcode_token_param = encodeURI('&at=' + shortcode_att_arr['accesstoken']);
2182		}
2183	}
2184	return shortcode_token_param;
2185}
2186
2187// Used for linking text in captions
2188/* JavaScript Linkify - v0.3 - 6/27/2009 - http://benalman.com/projects/javascript-linkify/ */
2189window.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}})();
2190
2191//Link #hashtags
2192function cffReplaceHashtags(hash){
2193    //Remove white space at beginning of hash
2194    var replacementString = jQuery.trim(hash);
2195    //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"
2196    if ( /^#[0-9A-F]{6}$/i.test( replacementString ) ){
2197        return replacementString;
2198    } else {
2199        return '<a href="https://www.facebook.com/hashtag/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener">' + replacementString + '</a>';
2200    }
2201}
2202//Link @tags
2203function cffReplaceTags(tag){
2204    var replacementString = jQuery.trim(tag);
2205    return '<a href="https://www.facebook.com/'+ replacementString.substring(1) +'" target="_blank" rel="nofollow noopener">' + replacementString + '</a>';
2206}
2207var hashRegex = /[#]+[A-Za-z0-9-_]+/g,
2208	tagRegex = /[@]+[A-Za-z0-9-_]+/g;
2209// End caption linking functions
2210
2211//Encoding comments
2212function cffEncodeHTML(raw) {
2213	// make sure passed variable is defined
2214	if (typeof raw === 'undefined') {
2215		return '';
2216	}
2217   // replace greater than and less than symbols with html entity to disallow html in comments
2218   	var encoded = raw.replace(/(>)/g,'&gt;'),
2219    	encoded = encoded.replace(/(<)/g,'&lt;');
2220    	encoded = encoded.replace(/(&lt;br\/&gt;)/g,'<br>');
2221    	encoded = encoded.replace(/(&lt;br&gt;)/g,'<br>');
2222
2223	return encoded;
2224}
2225
2226
2227//Load comment replies using Ajax
2228function cffLoadCommentReplies( $this ){
2229
2230	var usegrouptoken = '',
2231		useowntoken = '',
2232		$cffClosestContainer = jQuery('#cff_'+$this.parent().attr('data-id')).closest('#cff');
2233	if( $cffClosestContainer.hasClass('cff-group') ) usegrouptoken = '&usegrouptoken=true';
2234	if( $cffClosestContainer.attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
2235
2236	//Get the token from the shortcode
2237	var cff_page_id = $this.closest('.cff-item').attr('data-page-id'),
2238		shortcode_token_param = cffGetShortcodeToken( $cffClosestContainer ),
2239		$commentReplies = $this.parent(),
2240		$commentRepliesBox = $commentReplies.siblings('.cff-comment-replies-box'),
2241		comments_url = cffsiteurl + "/custom-facebook-feed-pro/comments.php?id=" + $commentReplies.attr('data-id') + usegrouptoken + useowntoken + '&pageid=' + cff_page_id + shortcode_token_param;
2242
2243	if( $commentReplies.hasClass('cff-hide') ){
2244
2245		$commentRepliesBox.hide();
2246		$commentReplies.removeClass('cff-hide');
2247
2248	} else {
2249
2250		$commentRepliesBox.show();
2251		$commentReplies.addClass('cff-hide');
2252
2253		//If the replies haven't been retrieved yet then get them, otherwise just show the existing ones again
2254		if( $commentRepliesBox.hasClass('cff-empty') ){
2255
2256			//Display loader
2257			var $commentRepliesA = $commentReplies.find('a');
2258			$commentRepliesA.append('<div class="cff-loader"></div>');
2259			$commentReplies.find('.cff-loader').css('background-color', $commentRepliesA.css('color'));
2260
2261			jQuery.ajax({
2262		      	method: "GET",
2263		      	url: comments_url,
2264		      	success: function(data) {
2265
2266			      	//Remove loader
2267			      	$commentReplies.find('.cff-loader').remove();
2268
2269			      	//Convert string of data received from comments.php to a JSON object
2270			      	var data = jQuery.parseJSON( data ),
2271			      		allComments = '';
2272
2273			      	if( typeof data.comments !== 'undefined' ){
2274			    		jQuery.each(data.comments.data, function(i, commentItem) {
2275
2276			    			//Check whether comment author info exists - only accessible with page access token from the page now
2277			    			var cff_comment_author_info = true;
2278			    			if( typeof commentItem.from !== 'undefined' ){
2279			    				cff_comment_from_id = commentItem.from.id;
2280			    			} else {
2281			    				cff_comment_author_info = false;
2282			    				cff_comment_from_id = '';
2283			    			}
2284
2285
2286							allComments += '<div class="cff-comment-reply" id="cff_'+commentItem.id+'"><div class="cff-comment-text-wrapper"><div class="cff-comment-text';
2287							if(!cff_comment_author_info) allComments += ' cff-no-name';
2288							allComments += '"><p>';
2289
2290
2291							if(cff_comment_author_info){
2292								if( typeof commentItem.from.link != 'undefined' ){
2293									allComments += '<a href="http://facebook.com/'+commentItem.from.id+'" class="cff-name" target="_blank" rel="nofollow noopener">
2293'+commentItem.from.name+'</a>';
2294								} else {
2295									allComments += '<span class="cff-name">'+commentItem.from.name+'</span>';
2296								}
2297							}
2298
2299
2300							var cffCommentMessage = cffEncodeHTML(commentItem.message);
2301							allComments += cffCommentMessage;
2302
2303							//Show like count if exists
2304						  	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>
2304'+commentItem.like_count+'</span></span>';
2305
2306							allComments += '</p>';
2307
2308						  	//Add image attachment if exists
2309							if( typeof commentItem.attachment !== 'undefined' ) 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>';
2310
2311						  	allComments += '</div></div>';
2312						  	if(cff_comment_author_info) 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>';
2313						  	allComments += '</div>';
2314						});
2315					}
2316
2317		    		$commentRepliesBox.html(allComments).removeClass('cff-empty');
2318
2319		    		//Re-init masonry layout when loading comment replies
2320		    		if( $this.closest('#cff').hasClass('cff-masonry-js') && !$this.closest('#cff').hasClass('cff-masonry-css') && !$this.closest('#cff').hasClass('cff-opaque-comments') ){
2321		    			cffAddMasonry( $this.closest('#cff') );
2322		    		}
2323
2324		    	} //End success
2325
2326			}); //End ajax
2327
2328		} //End if
2329
2330	} //End if/else
2331
2332} // End cffLoadCommentReplies()
2333
2334
2335
2336
2337function cffLightbox(){
2338	/**
2339	 * Lightbox v2.7.1
2340	 * by Lokesh Dhakar - http://lokeshdhakar.com/projects/lightbox2/
2341	 *
2342	 * @license http://creativecommons.org/licenses/by/2.5/
2343	 * - Free for use in both personal and commercial projects
2344	 * - Attribution requires leaving author name, author link, and the license info intact
2345	 */
2346
2347	(function() {
2348		// Use local alias
2349		var $ = jQuery;
2350
2351		var LightboxOptions = (function() {
2352			function LightboxOptions() {
2353				this.fadeDuration                = 300;
2354				this.fitImagesInViewport         = true;
2355				this.resizeDuration              = 400;
2356				this.positionFromTop             = 50;
2357				this.showImageNumberLabel        = true;
2358				this.alwaysShowNavOnTouchDevices = false;
2359				this.wrapAround                  = false;
2360			}
2361
2362			// Change to localize to non-english language
2363			LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
2364			  	return curImageNum + " / " + albumSize;
2365			};
2366
2367			return LightboxOptions;
2368		})();
2369
2370
2371		var Lightbox = (function() {
2372			function Lightbox(options) {
2373				this.options           = options;
2374				this.album             = [];
2375				this.currentImageIndex = void 0;
2376				this.init();
2377			}
2378
2379			Lightbox.prototype.init = function() {
2380			  	this.enable();
2381			  	this.build();
2382			};
2383
2384			// Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
2385			// that contain 'cff-lightbox'. When these are clicked, start lightbox.
2386			Lightbox.prototype.enable = function() {
2387			  	var self = this;
2388			  	$('body').on('click', 'a[data-cff-lightbox], area[data-cff-lightbox]', function(event) {
2389			    	self.start($(event.currentTarget));
2390			    	return false;
2391			  	});
2392			};
2393
2394			// Build html for the lightbox and the overlay.
2395			// Attach event handlers to the new DOM elements. click click click
2396			Lightbox.prototype.build = function() {
2397
2398				//Disable SVG icons?
2399				var cff_lightbox_svg_class = '';
2400				if( $('.cff.cff-no-svgs').length ) cff_lightbox_svg_class = 'cff-no-svgs';
2401
2402			  	var self = this;
2403			  	$("<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=''><span class='fa fab fa-facebook-square' aria-hidden='true' style='margin-right:6px;'></span>"+$('#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'><span class='fa fa-times' aria-hidden='true'></span></a></div></div></div></div>").appendTo($('body'));
2404			  
2405				// Cache jQuery objects
2406				this.$lightbox       = $('#cff-lightbox-wrapper');
2407				this.$overlay        = $('#cff-lightbox-overlay');
2408				this.$outerContainer = this.$lightbox.find('.cff-lightbox-outerContainer');
2409				this.$container      = this.$lightbox.find('.cff-lightbox-container');
2410
2411				// Store css values for future lookup
2412				this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10);
2413				this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10);
2414				this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10);
2415				this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10);
2416
2417				// Attach event handlers to the newly minted DOM elements
2418				this.$overlay.hide().on('click', function() {
2419					self.end();
2420					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2421					$('#cff-lightbox-wrapper iframe').attr('src', '');
2422					if ($('body').length) {
2423						$('body').removeClass('cff_no_scroll');
2424					}
2425					return false;
2426				});
2427
2428
2429				this.$lightbox.hide().on('click', function(event) {
2430					if ($(event.target).attr('id') === 'cff-lightbox-wrapper') {
2431					  	self.end();
2432					    if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2433					    $('#cff-lightbox-wrapper iframe').attr('src', '');
2434						if ($('body').length) {
2435							$('body').removeClass('cff_no_scroll');
2436						}
2437					}
2438					return false;
2439				});
2440				this.$outerContainer.on('click', function(event) {
2441					if ($(event.target).attr('id') === 'cff-lightbox-wrapper') {
2442					  	self.end();
2443					  	if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2444						$('#cff-lightbox-wrapper iframe').attr('src', '');
2445					}
2446					return false;
2447				});
2448
2449
2450				this.$lightbox.find('.cff-lightbox-prev').on('click', function() {
2451					if (self.currentImageIndex === 0) {
2452					  	self.changeImage(self.album.length - 1);
2453					} else {
2454					  	self.changeImage(self.currentImageIndex - 1);
2455					}
2456					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2457					$('#cff-lightbox-wrapper iframe').attr('src', '');
2458					return false;
2459				});
2460
2461				this.$lightbox.find('.cff-lightbox-next').on('click', function() {
2462					if (self.currentImageIndex === self.album.length - 1) {
2463					  	self.changeImage(0);
2464					} else {
2465					  	self.changeImage(self.currentImageIndex + 1);
2466					}
2467					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2468					$('#cff-lightbox-wrapper iframe').attr('src', '');
2469					return false;
2470				});
2471
2472
2473				//CHANGE IMAGE ON THUMB CLICK
2474				$('.cff-lightbox-thumbs').on('click', '.cff-lightbox-attachment', function (){
2475					var $thumb = $(this),
2476						$thumbImg = $thumb.find('img'),
2477						captionText = $thumb.attr('data-caption');
2478
2479					if(captionText == '' || captionText == 'undefined') captionText = $thumb.attr('orig-caption');
2480
2481					//Pass image URL, width and height to the change image function
2482					self.changeImage(parseInt( $thumb.attr('data-cff-lightbox-order') ), $thumb.attr('href'), $thumbImg.attr('width'), $thumbImg.attr('height'), $thumb.attr('data-facebook'), captionText);
2483					return false;
2484				});
2485
2486
2487				this.$lightbox.find('.cff-lightbox-loader, .cff-lightbox-close').on('click', function() {
2488					self.end();
2489					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2490					$('#cff-lightbox-wrapper iframe').attr('src', '');
2491					if ($('body').length) {
2492						$('body').removeClass('cff_no_scroll');
2493					}
2494					return false;
2495				});
2496
2497	    	}; //End build()
2498
2499		    // Show overlay and lightbox. If the image is part of a set, add siblings to album array.
2500		    Lightbox.prototype.start = function($link) {
2501				var self    = this;
2502				var $window = $(window);
2503
2504				$window.on('resize', $.proxy(this.sizeOverlay, this));
2505
2506				if ($('body').length) {
2507					$('body').addClass('cff_no_scroll');
2508				}
2509
2510				$('select, object, embed').css({
2511					visibility: "hidden"
2512				});
2513
2514				this.sizeOverlay();
2515
2516				//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
2517				if(this.album.length == 0) this.album = [];
2518				var imageNumber = 0;
2519
2520				function addToAlbum($link) {
2521					//If an image with the same href has already been added then don't add it to the lightbox order again
2522					var found = false;
2523					$.each(self.album, function(i, imageitem) {
2524						if( imageitem.link == $link.attr('href') ){
2525							found = true;
2526							return;
2527						}
2528					});
2529					//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.
2530					if( !$('.cff-duplicate-video-thumbnails').length ) if(found == true) return;	  
2531
2532					self.album.push({
2533						link: $link.attr('href'),
2534						title: $link.attr('data-title') || $link.attr('title'),
2535						postid: $link.attr('data-id'),
2536						showthumbs: $link.attr('data-thumbs'),
2537						facebookurl: $link.attr('data-url'),
2538						video: $link.attr('data-video'),
2539						iframe: $link.attr('data-iframe'),
2540						type: $link.attr('data-type'),
2541						cffgroupalbums: $link.attr('data-cffgroupalbums'),
2542						isthumbnail: $link.attr('data-cff-isthumbnail'),
2543						pagename: $link.parent().attr('data-cff-page-name'),
2544						posttime: $link.parent().attr('data-cff-post-time'),
2545						lbcomments: $link.attr('data-lb-comments')
2546					});
2547				}
2548
2549				// Support both data-lightbox attribute and rel attribute implementations
2550				var dataLightboxValue = $link.attr('data-cff-lightbox');
2551				var $links;
2552
2553				if (dataLightboxValue) {
2554					$links = $($link.prop("tagName") + '[data-cff-lightbox="' + dataLightboxValue + '"]');
2555					for (var i = 0; i < $links.length; i = ++i) {
2556						addToAlbum($($links[i]));
2557						if ($links[i] === $link[0]) {
2558							imageNumber = i;
2559
2560							//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.
2561							$.each(self.album, function(i, image) {
2562								if( (image.postid == $link.attr('data-id')) && image.isthumbnail != true ) imageNumber = i;
2563							});
2564						}
2565					}
2566				} else {
2567					if ($link.attr('rel') === 'lightbox') {
2568					  	// If image is not part of a set
2569					  	addToAlbum($link);
2570					} else {
2571					  	// If image is part of a set
2572					  	$links = $($link.prop("tagName") + '[rel="' + $link.attr('rel') + '"]');
2573					  	for (var j = 0; j < $links.length; j = ++j) {
2574					    addToAlbum($($links[j]));
2575						    if ($links[j] === $link[0]) {
2576						     	imageNumber = j;
2577						    }
2578						}
2579					}
2580				}
2581
2582				// Position Lightbox
2583				var top  = $window.scrollTop() + this.options.positionFromTop;
2584				var left = $window.scrollLeft();
2585				this.$lightbox.css({
2586					top: top + 'px',
2587					left: left + 'px'
2588				}).fadeIn(this.options.fadeDuration);
2589
2590				this.changeImage(imageNumber);
2591		    };
2592
2593		    // Hide most UI elements in preparation for the animated resizing of the lightbox.
2594		    Lightbox.prototype.changeImage = function(imageNumberVal, imageUrl, imgWidth, imgHeight, facebookLink, captionText) {
2595				var self = this,
2596					isThumb = false,
2597					bottomPadding = 120;
2598
2599					imageNumber = imageNumberVal;
2600
2601				//Is this a thumb being clicked?
2602				if(typeof imageUrl !== 'undefined') isThumb = true;
2603
2604				this.disableKeyboardNav();
2605				var $image = this.$lightbox.find('.cff-lightbox-image');
2606
2607				this.$overlay.fadeIn(this.options.fadeDuration);
2608
2609				$('.cff-lightbox-loader').fadeIn('slow');
2610				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();
2611
2612				this.$outerContainer.addClass('animating');
2613
2614
2615				// When image to show is preloaded, we send the width and height to sizeContainer()
2616				var preloader = new Image();
2617				preloader.onload = function() {
2618					var $preloader, imageHeight, imageWidth, maxImageHeight, maxImageWidth, windowHeight, windowWidth;
2619
2620					$image.attr('src', self.album[imageNumber].link);
2621
2622					/*** THUMBS ***/
2623					//Change the main image when it's a thumb that's being clicked
2624					if(isThumb){
2625						$image.attr('src', imageUrl);
2626						$('.cff-lightbox-facebook').attr('href', facebookLink);
2627						$('.cff-lightbox-caption .cff-lightbox-caption-text').html(captionText);
2628
2629						//Set width and height of image when thumb is clicked
2630						preloader.width = imgWidth;
2631						preloader.height = imgHeight;
2632
2633						//Increase bottom padding to make room for at least one row of thumbs
2634						bottomPadding = 180;
2635					}
2636					/*** THUMBS ***/
2637
2638					$preloader = $(preloader);
2639
2640					$image.width(preloader.width);
2641					$image.height(preloader.height);
2642
2643					if (self.options.fitImagesInViewport) {
2644						// Fit image inside the viewport.
2645						// Take into account the border around the image and an additional 10px gutter on each side.
2646						windowWidth    = $(window).width();
2647						windowHeight   = $(window).height();
2648
2649						//If this feed has lightbox comments enabled then add room for the sidebar
2650						var cff_lb_comments_width = 0,
2651							cffNavArrowsWidth = 80;
2652
2653						if( $('#cff_' + self.album[0].postid).closest('#cff').attr('data-lb-comments') == 'true' && windowWidth > 640 ) cff_lb_comments_width = 300;
2654
2655						//Use narrower arrows on mobile
2656						if(window.innerWidth < 640) cffNavArrowsWidth = 40;
2657
2658						maxImageWidth  = windowWidth - self.containerLeftPadding - self.containerRightPadding - 20 - cff_lb_comments_width - cffNavArrowsWidth;
2659						maxImageHeight = windowHeight - self.containerTopPadding - self.containerBottomPadding - bottomPadding;
2660
2661						// Is there a fitting issue?
2662						if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) {
2663							if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) {
2664							  	imageWidth  = maxImageWidth;
2665							  	imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10);
2666							  	$image.width(imageWidth);
2667							  	$image.height(imageHeight);
2668							} else {
2669							  	imageHeight = maxImageHeight;
2670							  	imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10);
2671							  	$image.width(imageWidth);
2672							  	$image.height(imageHeight);
2673							}
2674						}
2675					}
2676
2677					//Pass the width and height of the main image
2678					self.sizeContainer($image.width(), $image.height());
2679
2680				};
2681
2682				preloader.src          = this.album[imageNumber].link;
2683				this.currentImageIndex = imageNumber;
2684		    };
2685
2686		    // Stretch overlay to fit the viewport
2687		    Lightbox.prototype.sizeOverlay = function() {
2688		      	this.$overlay
2689		        	.width($(window).width())
2690		        	.height($(document).height());
2691		    };
2692
2693		    // Animate the size of the lightbox to fit the image we are showing
2694		    Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
2695				var self = this;
2696
2697				var oldWidth  = this.$outerContainer.outerWidth();
2698				var oldHeight = this.$outerContainer.outerHeight();
2699				var newWidth  = imageWidth + this.containerLeftPadding + this.containerRightPadding;
2700				var newHeight = imageHeight + this.containerTopPadding + this.containerBottomPadding;
2701
2702				function postResize() {
2703					self.$lightbox.find('.cff-lightbox-dataContainer').width(newWidth);
2704					self.$lightbox.find('.cff-lightbox-prevLink').height(newHeight);
2705					self.$lightbox.find('.cff-lightbox-nextLink').height(newHeight);
2706					self.showImage();
2707				}
2708
2709				if (oldWidth !== newWidth || oldHeight !== newHeight) {
2710					this.$outerContainer.animate({
2711					 	width: newWidth,
2712					 	height: newHeight
2713					}, this.options.resizeDuration, 'swing', function() {
2714					  	postResize();
2715					});
2716				} else {
2717					postResize();
2718				}
2719		    };
2720
2721		    // Display the image and it's details and begin preload neighboring images.
2722		    Lightbox.prototype.showImage = function() {
2723				this.$lightbox.find('.cff-lightbox-loader').hide();
2724				this.$lightbox.find('.cff-lightbox-image').fadeIn('slow');
2725
2726				this.updateNav();
2727				this.updateDetails();
2728				this.preloadNeighboringImages();
2729				this.enableKeyboardNav();
2730		    };
2731
2732		    // Display previous and next navigation if appropriate.
2733		    Lightbox.prototype.updateNav = function() {
2734				// Check to see if the browser supports touch events. If so, we take the conservative approach
2735				// and assume that mouse hover events are not supported and always show prev/next navigation
2736				// arrows in image sets.
2737				var alwaysShowNav = false;
2738				try {
2739					document.createEvent("TouchEvent");
2740					alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices)? true: false;
2741				} catch (e) {}
2742
2743				this.$lightbox.find('.cff-lightbox-nav').show();
2744
2745				if (this.album.length > 1) {
2746					if (this.options.wrapAround) {
2747					  	if (alwaysShowNav) {
2748					    	this.$lightbox.find('.cff-lightbox-prev, .cff-lightbox-next').css('opacity', '1');
2749					  	}
2750					  	this.$lightbox.find('.cff-lightbox-prev, .cff-lightbox-next').show();
2751					} else {
2752					  	if (this.currentImageIndex > 0) {
2753						    this.$lightbox.find('.cff-lightbox-prev').show();
2754						    if (alwaysShowNav) {
2755						      	this.$lightbox.find('.cff-lightbox-prev').css('opacity', '1');
2756						    }
2757					  	}
2758						if (this.currentImageIndex < this.album.length - 1) {
2759							this.$lightbox.find('.cff-lightbox-next').show();
2760							if (alwaysShowNav) {
2761							  	this.$lightbox.find('.cff-lightbox-next').css('opacity', '1');
2762							}
2763						}
2764					}
2765				}
2766		    };
2767
2768		    var thumbsArr = {};
2769
2770		    // Display caption, image number, and closing button.
2771		    Lightbox.prototype.updateDetails = function() {
2772		    	var self = this;
2773		    	var origCaption = '';
2774
2775		    	this.$lightbox.find('.cff-lightbox-nav, .cff-lightbox-nav a').show();
2776
2777		      	/** NEW PHOTO ACTION **/
2778
2779		      	//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)
2780		      	if( $('.cff-lightbox-video').length == 0 ) $('.cff-lightbox-container').prepend("<video class='cff-lightbox-video' src='' poster='' controls></video>");
2781
2782		      	//Switch video when either a new popup or navigating to new one
2783	            if( cff_supports_video() ){
2784	              	$('#cff-lightbox-wrapper').removeClass('cff-has-video');
2785
2786	              	if (typeof this.album[this.currentImageIndex].video !== 'undefined'){
2787		              	if( this.album[this.currentImageIndex].video.length ){
2788
2789		                	$('#cff-lightbox-wrapper').addClass('cff-has-video');
2790			                $('.cff-lightbox-video').attr({
2791			                	'src' : this.album[this.currentImageIndex].video,
2792			                	'poster' : this.album[this.currentImageIndex].link,
2793			                	'autoplay' : 'true'
2794			                });
2795			            }
2796			        }
2797
2798		        }
2799
2800		        //***LIGHTBOX COMMENTS***
2801		        //Enable/disable lightbox comments. If it's a lightbox thumbnail then check whether the parent post has lb_comments enabled/disabled.
2802				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;
2803
2804				if( $(window).width() <= 640 ) cff_lb_comments = false;
2805
2806		        //Add lightbox sidebar
2807		        if( cff_lb_comments ){
2808		        	var lb_post_id = this.album[this.currentImageIndex].postid,
2809	        			page_id = lb_post_id.split('_')[0],
2810	        			author_name = this.album[this.currentImageIndex].pagename,
2811	        			date_in_correct_format = this.album[this.currentImageIndex].posttime,
2812	        			$lightbox_sidebar = $('.cff-lightbox-container .cff-lightbox-sidebar'),
2813	        			$lightbox_thumbs_holder = $('.cff-lightbox-thumbs-holder'),
2814	        			from_id = $( '#cff_'+this.album[this.currentImageIndex].postid ).attr('data-cff-from');
2815
2816		        	//Add class to the lightbox container
2817					$('.cff-lightbox-wrapper').addClass('cff-enable-lb-comments');
2818
2819					//Adjust width to make room for the sidebar
2820					$('.cff-lightbox-dataContainer').css( 'width', $('.cff-lightbox-dataContainer').innerWidth() + 300 );
2821					$lightbox_sidebar.css('display', 'block');
2822
2823					//If the from info isn't available then display a placeholder avatar and the date
2824					var cff_post_author = "";
2825					if( typeof from_id !== 'undefined' ){
2826						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'>
2826"+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>";
2827					} else {
2828						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>";
2829					}
2830
2831					//Remove the close button from the bottom of lightbox as it's added to the top of the sidebar
2832					$('.cff-lightbox-dataContainer .cff-lightbox-close').remove();
2833
2834		        	$lightbox_sidebar.html("<div class='cff-lightbox-closeContainer'><div class='cff-lightbox-close'><span class='fa fa-times' aria-hidden='true'></span></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 );
2835
2836		        	this.$lightbox.find('.cff-lightbox-close').on('click', function() {
2837						self.end();
2838						if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
2839						$('#cff-lightbox-wrapper iframe').attr('src', '');
2840						if ($('body').length) {
2841							$('body').removeClass('cff_no_scroll');
2842						}
2843						return false;
2844					});
2845
2846		        	//Use a timeout to delay this as the thumbs aren't added till further down
2847		        	setTimeout(function(){
2848			        	if( $lightbox_thumbs_holder.find('a').length > 1 ){
2849			        		$lightbox_sidebar.find('.cff-page-name a').text( $lightbox_thumbs_holder.find('a.cff-selected').attr('data-page-name') );
2850			        		$lightbox_sidebar.find('.cff-date').text( $lightbox_thumbs_holder.find('a.cff-selected').attr('data-post-date') );
2851			        	}
2852		        	}, 0);
2853
2854		        	//Bump the thumbs section up if the sidebar section is enabled as there's no caption under the photo
2855		        	$lightbox_thumbs_holder.css('margin-top', -10);
2856
2857		        	//If the "__ likes this" text is too long then bump it onto the next line
2858		        	if( $lightbox_sidebar.find('.cff-reactions-count').innerWidth() > 150 ){
2859		        		$lightbox_sidebar.find('.cff-likes-this-text').addClass('cff-long');
2860		        	}
2861
2862		        	//Add comment avatars
2863					$lightbox_sidebar.find('.cff-comment:visible').each(function(){
2864						var $thisComment = jQuery(this);
2865						$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\'" />' );
2866					});
2867
2868					//Load comment replies
2869					$lightbox_sidebar.find('.cff-comment-replies a').on('click', function(){
2870						cffLoadCommentReplies( $(this) );
2871					});
2872
2873					$lightbox_sidebar.find('.cff-show-more-comments a').attr('href', $lightbox_sidebar.find('.cff-comment-on-facebook a').attr('href') );
2874
2875		        } else { //End add lightbox sidebar
2876
2877		        	//Disable lightbox
2878		        	$('.cff-lightbox-wrapper .cff-lightbox-sidebar').html('');
2879					$('.cff-lightbox-wrapper').removeClass('cff-enable-lb-comments');
2880
2881		        }
2882		        //***END LIGHTBOX COMMENTS***
2883
2884
2885
2886		        $('#cff-lightbox-wrapper').removeClass('cff-has-iframe cff-fb-player cff-has-thumbs');
2887
2888		        //If it's an iframe video (embed or FB video player)
2889		        if( typeof this.album[this.currentImageIndex].iframe !== 'undefined' ){
2890				    if( this.album[this.currentImageIndex].iframe.length ){
2891				        var videoURL = this.album[this.currentImageIndex].iframe;
2892		            	$('#cff-lightbox-wrapper').addClass('cff-has-iframe');
2893
2894		            	if( videoURL.indexOf("https://www.facebook.com/v2.3/plugins/video.php?") !=-1 ) $('#cff-lightbox-wrapper').addClass('cff-fb-player');
2895
2896		            	//If it's a swf then don't add the autoplay parameter. This is only for embedded videos like YouTube or Vimeo.
2897		            	if( videoURL.indexOf(".swf") > -1 || videoURL.indexOf("&autoplay=1") !=-1 ){
2898		            		var autoplayParam = '';
2899		            	} else {
2900		            		var autoplayParam = '?autoplay=1';
2901		            	}
2902
2903		            	//Add a slight delay before adding the URL else it doesn't autoplay on Firefox
2904			            var vInt = setTimeout(function() {
2905							$('#cff-lightbox-wrapper iframe').attr({
2906						    	'src' : videoURL + autoplayParam + "&mute=0"
2907						    });
2908						}, 500);
2909		            }
2910		        }
2911
2912	            //Check whether it's a thumbnail image that's currently being shown in the lightbox
2913	            var isThumbnail = false;
2914	            if( this.album[this.currentImageIndex].isthumbnail ) isThumbnail = true;
2915
2916		      	//Remove existing thumbs unless it's a thumbnail image which is being navigated through in which case keep the existing thumbnails
2917		      	if( !isThumbnail ) $('.cff-lightbox-thumbs-holder').empty().removeClass('cff-animate');
2918
2919		      	//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
2920		      	if( this.album[this.currentImageIndex].link == $('.cff-lightbox-image').attr('src') ){
2921		      		$('.cff-lightbox-facebook').attr('href', this.album[this.currentImageIndex].facebookurl);
2922		      	}
2923
2924		      	//Show thumbs area if there are thumbs
2925		     	if( this.album[this.currentImageIndex].showthumbs == 'true' ){
2926		      		$('.cff-lightbox-thumbs').show();
2927
2928		      		//Get the post ID
2929		      		var thisPostId = this.album[this.currentImageIndex].postid,
2930		      			albumInfo = '',
2931				      	albumThumbs = '',
2932				      	albumsonly = false;
2933				    if( this.album[this.currentImageIndex].type == 'albumsonly' ) albumsonly = true;
2934
2935
2936			      	if( typeof thumbsArr[thisPostId] !== 'undefined' ){
2937
2938			      		//load them in from array in local var
2939			      		// console.log(thumbsArr[thisPostId]);
2940			      		$.each(thumbsArr[thisPostId], function(i, thumb) {
2941				      		var origCaption = thumb[5].replace(/"/g, '&quot;');
2942
2943			      		  	//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.
2944			      		  	var albumIndex = 0;
2945				      		$.each(self.album, function(i, albumItem) {
2946				      			if( albumItem.postid == thisPostId ){
2947				      				albumIndex = i;
2948				      				//Once found the first match exit the loop
2949				      				return false;
2950				      			}
2951				      		});
2952
2953			      		  	var lightboxImageOrder = (parseInt(albumIndex)+parseInt(i));
2954
2955		      		  		//If the small thumb isn't defined (like in regular posts) then use the full image instead
2956		      		  		if( typeof thumb[8] == 'undefined' ) thumb[8] = thumb[0];
2957
2958							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 ';
2959
2960							(albumsonly) ? albumThumbs += 'data-type="albumsonly" ' : albumThumbs += 'data-type ';
2961							albumThumbs += 'data-cff-isthumbnail="true"><img src="'+thumb[8]+'" width="'+thumb[1]+'" height="'+thumb[2]+'" /></a>';
2962
2963							//Add all of the thumbs (apart from the first thumb) to the lightbox order
2964							if( i > 0 ){
2965								cffInsertLightboxImage(lightboxImageOrder, thumb[0], thumb[4], thumb[3], thisPostId, albumsonly, true, thumb[6], thumb[7], thumb[8]);
2966							}
2967						});
2968
2969			      		//Add thumbs to the page
2970		            	$('.cff-lightbox-thumbs-holder').html( '<div class="cff-lightbox-thumbs-wrap">' + albumThumbs + '</div>' ).addClass('cff-animate');
2971		            	$('.cff-lightbox-wrapper').addClass('cff-has-thumbs');
2972
2973		            	//Liquidfill the thumbs
2974		            	jQuery(".cff-lightbox-thumbs-holder a").imgLiquid({fill:true, useBackgroundSize:true});
2975
2976		            	//Hide the loader
2977		            	$('.cff-loader').hide();
2978						$('.cff-lightbox-thumbs-holder').css('min-height', 0);
2979
2980			      	} else {
2981			      		//Use ajax to get them from Facebook API
2982
2983			      		//Set paths for thumbs.php
2984				  		if (typeof cffsiteurl === 'undefined' || cffsiteurl == '') cffsiteurl = window.location.host + '/wp-content/plugins';
2985
2986				  		//Get the token from the shortcode
2987				  		var $cffClosest = $('#cff_'+thisPostId).closest('.cff'),
2988				  			cff_page_id = $('#cff_'+thisPostId).attr('data-page-id'),
2989				  			shortcode_token_param = cffGetShortcodeToken( $cffClosest ),
2990				  			useowntoken = '';
2991						if( $cffClosest.attr('data-own-token') == 'true' ) useowntoken = '&useowntoken=true';
2992
2993					  	//AJAX
2994					  	var cffAttachmentsUrl = cffsiteurl + "/custom-facebook-feed-pro/thumbs.php?id=" + thisPostId + '&pageid=' + cff_page_id + useowntoken + shortcode_token_param,
2995				      		thumbsData = [];
2996
2997				      	//If this is an albums only item and the thumbs will
2998				      	if( albumsonly ){
2999				      		cffAttachmentsUrl = cffAttachmentsUrl + '&albumsonly=true';
3000				      		$('.cff-lightbox-thumbs-holder').css('min-height', 45).after('<div class="cff-loader"></div>');
3001				      	}
3002
3003				      	//If it's a group album then add the absolute path so we can get the User Access Token from the DB
3004				      	var cffgroupalbums = this.album[this.currentImageIndex].cffgroupalbums;
3005				      	if( cffgroupalbums ) cffAttachmentsUrl = cffAttachmentsUrl + '&usegrouptoken=' + cffgroupalbums;
3006
3007				      	$.ajax({
3008				            method: "GET",
3009				            url: cffAttachmentsUrl,
3010				            // dataType: "jsonp",
3011				            success: function(data) {
3012
3013				            	//Convert string of data received from thumbs.php to a JSON object
3014				            	data = jQuery.parseJSON( data );
3015
3016				            	if(albumsonly){
3017				            		//Compile the thumbs
3018						      		$.each(data.data, function(i, photoItem) {
3019						      		  	var dataCaption = '';
3020						      		  	if( photoItem.name ) dataCaption = photoItem.name;
3021						      		  	// origCaption = String(origCaption).replace(/"/g, '&quot;');
3022
3023							      		//Format the caption and add links
3024							      		dataCaption = cffLinkify(dataCaption);
3025		                				dataCaption = dataCaption.replace( hashRegex , cffReplaceHashtags );
3026
3027		                				// dataCaption = dataCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
3028										dataCaption = String(dataCaption).replace(/& /g, '&amp; ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
3029
3030										origCaption = String(origCaption).replace(/& /g, '&amp; ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
3031
3032										var lightboxImageOrder = (parseInt(self.currentImageIndex)+parseInt(i));
3033
3034										//If it's a group then use the source otherwise it displays as question marks
3035										var cffThumbHref = photoItem.source,
3036											cffPhotoItemWidth = photoItem.width,
3037											cffPhotoItemHeight = photoItem.height;
3038
3039										//Use the full size image if available
3040										if( typeof photoItem.images[0] !== 'undefined' ){
3041											cffThumbHref = photoItem.images[0].source;
3042											cffPhotoItemWidth = photoItem.images[0].width;
3043											cffPhotoItemHeight = photoItem.images[0].height;
3044										}
3045
3046										//Set the thumbnail image to be the smallest size available, which is the second from last in images arr
3047										if( typeof photoItem.images[ photoItem.images.length-2 ] !== 'undefined' ){
3048											var cffThumbImg = photoItem.images[ photoItem.images.length-2 ].source;
3049										} else {
3050											var cffThumbImg = cffThumbHref;
3051										}
3052
3053								  		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>';
3054
3055								  		thumbsData.push([cffThumbHref, cffPhotoItemWidth, cffPhotoItemHeight, 'http://facebook.com/'+photoItem.id, dataCaption, origCaption, undefined, undefined, cffThumbImg]);
3056
3057								  		//Add all of the thumbs (apart from the first thumb) to the lightbox order
3058								  		if( i > 0 ){
3059										  	cffInsertLightboxImage(lightboxImageOrder, cffThumbHref, dataCaption, 'http://facebook.com/'+photoItem.id, thisPostId, albumsonly, true, cffThumbImg);
3060										}
3061
3062									}); //End each
3063
3064				            	} else {
3065				            		//Check whether there's data..
3066				            		if (typeof data.attachments !== 'undefined') {
3067
3068				            			//..Then compile the thumbs
3069				            			$.each(data.attachments.data[0].subattachments.data, function(i, subattachment) {
3070				            			  	var dataCaption = '';
3071											if( subattachment.description ) dataCaption = subattachment.description;
3072											origCaption = String(origCaption).replace(/"/g, '&quot;');
3073
3074											//Format the caption and add links
3075											dataCaption = cffLinkify(dataCaption);
3076											dataCaption = dataCaption.replace( hashRegex , cffReplaceHashtags );
3077											// dataCaption = dataCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
3078											dataCaption = String(dataCaption).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/\n/g, "<br/>");
3079
3080											var lightboxImageOrder = (parseInt(self.currentImageIndex)+parseInt(i));
3081
3082											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
3082+'" 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>';
3083
3084											thumbsData.push([subattachment.media.image.src, subattachment.media.image.width, subattachment.media.image.height, subattachment.url, dataCaption, origCaption, author_name, date_in_correct_format]);
3085
3086											//Add all of the thumbs (apart from the first thumb) to the lightbox order
3087											if( i > 0 ){
3088												cffInsertLightboxImage(lightboxImageOrder, subattachment.media.image.src, dataCaption, subattachment.url, thisPostId, albumsonly, true, author_name, date_in_correct_format, subattachment.media.image.src);
3089											}
3090
3091										});
3092
3093									} //End undefined check
3094						      		
3095				            	} //End if/else
3096
3097								//Add thumbs to the page
3098				            	if( albumThumbs.length > 0 ){
3099				            		$('.cff-lightbox-thumbs-holder').html( '<div class="cff-lightbox-thumbs-wrap">' + albumThumbs + '</div>' ).addClass('cff-animate');
3100				            		$('.cff-lightbox-wrapper').addClass('cff-has-thumbs');
3101				            	}
3102
3103				            	//Liquidfill the thumbs
3104				            	jQuery(".cff-lightbox-thumbs-holder .cff-lightbox-attachment").imgLiquid({fill:true, useBackgroundSize:true});
3105
3106				            	//Hide the loader
3107				            	$('.cff-loader').hide();
3108
3109								$('.cff-lightbox-thumbs-holder').css('min-height', 0);
3110
3111				            	//Add the thumbs to the thumbs array to store them
3112				            	thumbsArr[ thisPostId ] = thumbsData;
3113
3114					        } //End success
3115
3116				        }); //End ajax
3117
3118			      	} //End if/else
3119
3120		      	} else {
3121		      		//If there are no thumbs then hide the thumbs area
3122		      		$('.cff-lightbox-thumbs').hide();
3123		      	}
3124
3125		      	//Add a class to the selected thumb
3126		      	$(".cff-lightbox-attachment").removeClass('cff-selected');
3127		      	$(".cff-lightbox-attachment[href='"+$('.cff-lightbox-image').attr('src')+"']").addClass('cff-selected');
3128
3129
3130		      	function cffInsertLightboxImage(currentImageIndex, link, title, facebookurl, postid, albumsonly, isThumbnail, cffThumbImg){
3131
3132		      		//Make sure the thumbs aren't added to the lightbox order more than once
3133		      		var found = false;
3134		      		$.each(self.album, function(i, thumbitem) {
3135		      			if( thumbitem.link == link ){
3136		      				found = true;
3137		      				return;
3138		      			}
3139		      		});
3140		      		if(found == true) return;
3141
3142		      		( albumsonly ) ? postType = 'albumsonly' : postType = '';
3143		      		( albumsonly ) ? lbcomments = 'false' : lbcomments = 'true';
3144
3145		      		//Push the image into the album array at the correct location so it's included in the lightbox order
3146		      		self.album.splice(currentImageIndex, 0, {
3147						link: link,
3148						title: title,
3149						postid: postid,
3150						showthumbs: 'true',
3151						facebookurl: facebookurl,
3152						video: '',
3153						iframe: '',
3154						type: postType,
3155						cffgroupalbums: undefined,
3156						isthumbnail: isThumbnail,
3157						lbcomments: lbcomments,
3158						thumbimg: cffThumbImg
3159			        });
3160
3161		      	} //End cffInsertLightboxImage()
3162
3163		      	/** END NEW PHOTO ACTION **/
3164
3165		      
3166				//Still show the caption section even if there's not a caption as it contains the View on Facebook link
3167				this.$lightbox.find('.cff-lightbox-caption').fadeIn('fast');
3168
3169				// Enable anchor clicks in the injected caption html.
3170				if (typeof this.album[this.currentImageIndex].title !== 'undefined' && this.album[this.currentImageIndex].title !== "") {
3171
3172					//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
3173					var origCaption = this.album[this.currentImageIndex].title;
3174
3175					//Add hashtag and tag links
3176					// origCaption = cffLinkify(origCaption); - Caused issues with @tag links in regular lightbox popup
3177					origCaption = origCaption.replace( hashRegex , cffReplaceHashtags );
3178					// origCaption = origCaption.replace( tagRegex , cffReplaceTags ); - causes an issue with email address linking
3179					//Decode the caption back so that the tags are rendered as HTML:
3180					origCaption = String(origCaption).replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"');
3181
3182					var $lightboxCaption = this.$lightbox.find('.cff-lightbox-caption'),
3183						$lightboxCaptionText = $lightboxCaption.find('.cff-lightbox-caption-text');
3184					if( this.album[this.currentImageIndex].link == $('.cff-lightbox-image').attr('src') ) $lightboxCaptionText.html( origCaption );
3185
3186					//If there's no caption then remove the border and margin from the View on Facebook link
3187					if( $lightboxCaptionText.text() == ' ' || $lightboxCaptionText.text() == '' ){
3188						$lightboxCaption.addClass('cff-no-caption');
3189					} else {
3190						$lightboxCaption.removeClass('cff-no-caption');
3191					}
3192
3193				} else {
3194					
3195					//If there's no caption then add a class
3196					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('');
3197				}
3198
3199				this.$lightbox.find('.cff-lightbox-facebook, .cff-lightbox-caption-text a, .cff-lightbox-sidebar a:not(.cff-comment-replies-a)').unbind().on('click', function(event){
3200						window.open(
3201						$(this).attr('href'),
3202						'_blank'
3203						)
3204		        	}
3205		        );
3206			    
3207				if (this.album.length > 1 && this.options.showImageNumberLabel) {
3208					this.$lightbox.find('.cff-lightbox-number').text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn('fast');
3209				} else {
3210					this.$lightbox.find('.cff-lightbox-number').hide();
3211				}
3212
3213				if (typeof cffLightboxAction === 'function') {
3214					setTimeout(function() {
3215						cffLightboxAction();
3216					},100);
3217				}
3218
3219				this.$outerContainer.removeClass('animating');
3220
3221				this.$lightbox.find('.cff-lightbox-dataContainer').fadeIn(this.options.resizeDuration, function() {
3222					return self.sizeOverlay();
3223				});
3224
3225		    }; //End Lightbox.prototype.updateDetails
3226
3227		    // Preload previous and next images in set.
3228		    Lightbox.prototype.preloadNeighboringImages = function() {
3229				if (this.album.length > this.currentImageIndex + 1) {
3230					var preloadNext = new Image();
3231					preloadNext.src = this.album[this.currentImageIndex + 1].link;
3232				}
3233				if (this.currentImageIndex > 0) {
3234					var preloadPrev = new Image();
3235					preloadPrev.src = this.album[this.currentImageIndex - 1].link;
3236				}
3237		    };
3238
3239		    Lightbox.prototype.enableKeyboardNav = function() {
3240		      	$(document).on('keyup.keyboard', $.proxy(this.keyboardAction, this));
3241		    };
3242
3243		    Lightbox.prototype.disableKeyboardNav = function() {
3244		      	$(document).off('.keyboard');
3245		    };
3246
3247		    Lightbox.prototype.keyboardAction = function(event) {
3248				var KEYCODE_ESC        = 27;
3249				var KEYCODE_LEFTARROW  = 37;
3250				var KEYCODE_RIGHTARROW = 39;
3251
3252				var keycode = event.keyCode;
3253				var key     = String.fromCharCode(keycode).toLowerCase();
3254				if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
3255					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
3256					$('#cff-lightbox-wrapper iframe').attr('src', '');
3257						
3258					this.end();
3259				} else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
3260					if (this.currentImageIndex !== 0) {
3261					  	this.changeImage(this.currentImageIndex - 1);
3262					} else if (this.options.wrapAround && this.album.length > 1) {
3263					  	this.changeImage(this.album.length - 1);
3264					}
3265
3266					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
3267					$('#cff-lightbox-wrapper iframe').attr('src', '');
3268
3269				} else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
3270					if (this.currentImageIndex !== this.album.length - 1) {
3271					 	this.changeImage(this.currentImageIndex + 1);
3272					} else if (this.options.wrapAround && this.album.length > 1) {
3273					  	this.changeImage(0);
3274					}
3275
3276					if( cff_supports_video() ) $('#cff-lightbox-wrapper video.cff-lightbox-video')[0].pause();
3277					$('#cff-lightbox-wrapper iframe').attr('src', '');
3278
3279				}
3280			};
3281
3282		    // Closing time
3283		    Lightbox.prototype.end = function() {
3284				this.disableKeyboardNav();
3285				$(window).off("resize", this.sizeOverlay);
3286				this.$lightbox.fadeOut(this.options.fadeDuration);
3287				this.$overlay.fadeOut(this.options.fadeDuration);
3288				$('select, object, embed').css({
3289					visibility: "visible"
3290				});
3291		    };
3292
3293		    return Lightbox;
3294
3295	  	})(); //End Lightbox = (function()
3296
3297		$(function() {
3298			var options  = new LightboxOptions();
3299			var lightbox = new Lightbox(options);
3300		});
3301
3302	}).call(this); //End (function() {
3303
3304	//Checks whether browser support HTML5 video element
3305	function cff_supports_video() {
3306	  return !!document.createElement('video').canPlayType;
3307	}
3308
3309
3310} //End cffLightbox function
3311
3312//Only call the lightbox if the class is on at least one feed on the page
3313if( jQuery('#cff.cff-lb').length ) cffLightbox();
3314
3315
3316
3317} //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.