!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Instafeed=t()}(this,function(){"use strict";function e(e,t){if(!e)throw new Error(t)}function t(t){e(!t||"object"==typeof t,"options must be an object, got "+t+" ("+typeof t+")");var o={accessToken:null,accessTokenTimeout:1e4,after:null,apiTimeout:1e4,apiLimit:null,before:null,debug:!1,error:null,filter:null,limit:null,mock:!1,render:null,sort:null,success:null,target:"instafeed",template:'
',templateBoundaries:["{{","}}"],transform:null};if(t)for(var n in o)"undefined"!=typeof t[n]&&(o[n]=t[n]);e("string"==typeof o.target||"object"==typeof o.target,"target must be a string or DOM node, got "+o.target+" ("+typeof o.target+")"),e("string"==typeof o.accessToken||"function"==typeof o.accessToken,"accessToken must be a string or function, got "+o.accessToken+" ("+typeof o.accessToken+")"),e("number"==typeof o.accessTokenTimeout,"accessTokenTimeout must be a number, got "+o.accessTokenTimeout+" ("+typeof o.accessTokenTimeout+")"),e("number"==typeof o.apiTimeout,"apiTimeout must be a number, got "+o.apiTimeout+" ("+typeof o.apiTimeout+")"),e("boolean"==typeof o.debug,"debug must be true or false, got "+o.debug+" ("+typeof o.debug+")"),e("boolean"==typeof o.mock,"mock must be true or false, got "+o.mock+" ("+typeof o.mock+")"),e("object"==typeof o.templateBoundaries&&2===o.templateBoundaries.length&&"string"==typeof o.templateBoundaries[0]&&"string"==typeof o.templateBoundaries[1],"templateBoundaries must be an array of 2 strings, got "+o.templateBoundaries+" ("+typeof o.templateBoundaries+")"),e(!o.template||"string"==typeof o.template,"template must null or string, got "+o.template+" ("+typeof o.template+")"),e(!o.error||"function"==typeof o.error,"error must be null or function, got "+o.error+" ("+typeof o.error+")"),e(!o.before||"function"==typeof o.before,"before must be null or function, got "+o.before+" ("+typeof o.before+")"),e(!o.after||"function"==typeof o.after,"after must be null or function, got "+o.after+" ("+typeof o.after+")"),e(!o.success||"function"==typeof o.success,"success must be null or function, got "+o.success+" ("+typeof o.success+")"),e(!o.filter||"function"==typeof o.filter,"filter must be null or function, got "+o.filter+" ("+typeof o.filter+")"),e(!o.transform||"function"==typeof o.transform,"transform must be null or function, got "+o.transform+" ("+typeof o.transform+")"),e(!o.sort||"function"==typeof o.sort,"sort must be null or function, got "+o.sort+" ("+typeof o.sort+")"),e(!o.render||"function"==typeof o.render,"render must be null or function, got "+o.render+" ("+typeof o.render+")"),e(!o.limit||"number"==typeof o.limit,"limit must be null or number, got "+o.limit+" ("+typeof o.limit+")"),e(!o.apiLimit||"number"==typeof o.apiLimit,"apiLimit must null or number, got "+o.apiLimit+" ("+typeof o.apiLimit+")"),this._state={running:!1,node:null,token:null,paging:null,pool:[]},this._options=o}return t.prototype.run=function(){var e=this;return this._debug("run","options",this._options),this._debug("run","state",this._state),this._state.running?(this._debug("run","already running, skipping"),!1):(this._start(),this._debug("run","getting dom node"),"string"==typeof this._options.target?this._state.node=document.getElementById(this._options.target):this._state.node=this._options.target,this._state.node?(this._debug("run","got dom node",this._state.node),this._debug("run","getting access token"),this._getAccessToken(function(t,o){if(t)return e._debug("onTokenReceived","error",t),void e._fail(new Error("error getting access token: "+t.message));e._debug("onTokenReceived","got token",o),e._state.token=o,e._showNext(function(t){if(t)return e._debug("onNextShown","error",t),void e._fail(t);e._finish()})}),!0):(this._fail(new Error("no element found with ID "+this._options.target)),!1))},t.prototype.hasNext=function(){var e=this._state.paging,t=this._state.pool;return this._debug("hasNext","paging",e),this._debug("hasNext","pool",t.length,t),t.length>0||e&&"string"==typeof e.next},t.prototype.next=function(){var e=this;return e.hasNext()?e._state.running?(e._debug("next","already running, skipping"),!1):(e._start(),void e._showNext(function(t){if(t)return e._debug("onNextShown","error",t),void e._fail(t);e._finish()})):(e._debug("next","hasNext is false, skipping"),!1)},t.prototype._showNext=function(e){var t=this,o=null,n=null,i="number"==typeof this._options.limit;if(t._debug("showNext","pool",t._state.pool.length,t._state.pool),t._state.pool.length>0){if(n=i?t._state.pool.splice(0,t._options.limit):t._state.pool.splice(0),t._debug("showNext","items from pool",n.length,n),t._debug("showNext","updated pool",t._state.pool.length,t._state.pool),t._options.mock)t._debug("showNext","mock enabled, skipping render");else try{t._renderData(n)}catch(s){return void e(s)}e(null)}else t._state.paging&&"string"==typeof t._state.paging.next?o=t._state.paging.next:(o="https://graph.instagram.com/me/media?fields=caption,id,media_type,media_url,permalink,thumbnail_url,timestamp,username&access_token="+t._state.token,t._options.apiLimit||"number"!=typeof t._options.limit?"number"==typeof t._options.apiLimit&&(t._debug("showNext","apiLimit set, overriding limit",t._options.apiLimit,t._options.limit),o=o+"&limit="+t._options.apiLimit):(t._debug("showNext","no apiLimit set, falling back to limit",t._options.apiLimit,t._options.limit),o=o+"&limit="+t._options.limit)),t._debug("showNext","making request",o),t._makeApiRequest(o,function(o,n){var i=null;if(o)return t._debug("onResponseReceived","error",o),void e(new Error("api request error: "+o.message));t._debug("onResponseReceived","data",n),t._success(n),t._debug("onResponseReceived","setting paging",n.paging),t._state.paging=n.paging;try{if(i=t._processData(n),t._debug("onResponseReceived","processed data",i),i.unused&&i.unused.length>0){t._debug("onResponseReceived","saving unused to pool",i.unused.length,i.unused);for(var r=0;r0&&(p=s.slice(s.length-r),this._debug("processData","unusedItems",p.length,p),s.splice(s.length-r,r))),{items:s,unused:p}},t.prototype._extractTags=function(e){var t=/#([^\s]+)/gi,o=/[~`!@#$%^&*\(\)\-\+={}\[\]:;"'<>\?,\./|\\\s]+/i,n=[],i=null;if("string"==typeof e)for(;null!==(i=t.exec(e));)!1===o.test(i[1])&&n.push(i[1]);return n},t.prototype._getItemData=function(e){var t=null,o=null;switch(e.media_type){case"IMAGE":t="image",o=e.media_url;break;case"VIDEO":t="video",o=e.thumbnail_url;break;case"CAROUSEL_ALBUM":t="album",o=e.media_url}return{caption:e.caption,tags:this._extractTags(e.caption),id:e.id,image:o,link:e.permalink,model:e,timestamp:e.timestamp,type:t,username:e.username}},t.prototype._renderData=function(e){var t="string"==typeof this._options.template,o="function"==typeof this._options.render,n=null,i=null,s=null,r="";if(this._debug("renderData","hasTemplate",t,"hasRender",o),!("object"!=typeof e||e.length<=0)){for(var a=0;a0;)this._debug("renderData","appending child",s.childNodes[0]),this._state.node.appendChild(s.childNodes[0])}},t.prototype._basicRender=function(e){for(var t=new RegExp(this._options.templateBoundaries[0]+"([\\s\\w.]+)"+this._options.templateBoundaries[1],"gm"),o=this._options.template,n=null,i="",s=0,r=null,a=null;null!==(n=t.exec(o));)r=n[1],i+=o.slice(s,n.index),(a=this._valueForKeyPath(r,e))&&(i+=a.toString()),s=t.lastIndex;return s=0)try{o=JSON.parse(i.responseText)}catch(r){return n._debug("apiRequestOnLoad","json parsing error",r,i.responseText),void s(new Error("error parsing response json"))}200===i.status?s(null,o):o&&o.error?s(new Error(o.error.code+" "+o.error.message)):s(new Error("status code "+i.status))},i.open("GET",e,!0),i.timeout=this._options.apiTimeout,i.send()},t.prototype._getAccessToken=function(e){var t=!1,o=this,n=null,i=function(o,i){t||(t=!0,clearTimeout(n),e(o,i))};if("function"==typeof this._options.accessToken){this._debug("getAccessToken","calling accessToken as function"),n=setTimeout(function(){o._debug("getAccessToken","timeout check",t),i(new Error("accessToken timed out"),null)},this._options.accessTokenTimeout);try{this._options.accessToken(function(e,n){o._debug("getAccessToken","received accessToken callback",t,e,n),i(e,n)})}catch(s){this._debug("getAccessToken","error invoking the accessToken as function",s),i(s,null)}}else this._debug("getAccessToken","treating accessToken as static",typeof this._options.accessToken),i(null,this._options.accessToken)},t.prototype._debug=function(){var e=null;this._options.debug&&console&&"function"==typeof console.log&&((e=[].slice.call(arguments))[0]="[Instafeed] ["+e[0]+"]",console.log.apply(null,e))},t.prototype._runHook=function(e,t){var o=!1;if("function"==typeof this._options[e])try{this._options[e](t),o=!0}catch(n){this._debug("runHook","error calling hook",e,n)}return o},t});var insta_run=!1;Shopcada.tasks.InstagramFeeds=function(){if(insta_run==!0){return}
insta_run=!0;for(const instance in Shopcada.settings.InstagramFeeds){try{var feed=new Instafeed({accessToken:Shopcada.settings.InstagramFeeds[instance].id,template:'
',target:instance,limit:$('#'+instance).data('count')?$('#'+instance).data('count'):10,after:function(){$(".instafeed[id='"+instance+"'").not(".bxprocessed").each(function(){let _this=$(this);_this.addClass("bxprocessed");if(_this.hasClass('custom-instafeed-wrapper')){let desktop_col=_this.data('desktop-column').toString();let tablet_col=_this.data('tablet-column').toString();let mobile_col=_this.data('mobile-column').toString();let extra_classes='';switch(desktop_col){case '1':extra_classes+=' col-lg-12';break;case '2':extra_classes+=' col-lg-6';break;case '3':extra_classes+=' col-lg-4';break;case '4':extra_classes+=' col-lg-3';break;case '5':extra_classes+=' col-lg-5ths';break;case '6':extra_classes+=' col-lg-2';break}
switch(tablet_col){case '1':extra_classes+=' col-md-12';break;case '2':extra_classes+=' col-md-6';break;case '3':extra_classes+=' col-md-4';break;case '4':extra_classes+=' col-md-3';break;case '5':extra_classes+=' col-md-5ths';break;case '6':extra_classes+=' col-md-2';break}
switch(mobile_col){case '1':extra_classes+=' col-12';break;case '2':extra_classes+=' col-6';break;case '3':extra_classes+=' col-4';break;case '4':extra_classes+=' col-3';break;case '5':extra_classes+=' col-5ths';break;case '6':extra_classes+=' col-2';break}
_this.find('.instafeed-row').addClass(extra_classes);if(_this.hasClass('instafeed-sliding-wrapper')){_this.find('.instafeed-row').addClass('swiper-slide').wrapAll('');let swiper_container=_this.find('.swiper');let swiper_prev;let swiper_next;if(_this.data('navigation')){swiper_container.after('');swiper_prev=_this.find('.swiper-prev');swiper_next=_this.find('.swiper-next')}
new Swiper(swiper_container.get(0),{slidesPerView:'auto',navigation:{prevEl:swiper_prev?swiper_prev.get(0):'',nextEl:swiper_next?swiper_next.get(0):''}});if(_this.data('navigation')){const swiper_resize_observer=new ResizeObserver(function(){let item_height=0;_this.find('.swiper-slide').each(function(){if($(this).outerHeight()>item_height){item_height=$(this).outerHeight()}})
let swiper_prev_height=0;if(swiper_prev.css('translate')=='none'&&swiper_prev.css('transform')=='none'){swiper_prev_height=swiper_prev.outerHeight()}
let swiper_next_height=0;if(swiper_next.css('translate')=='none'&&swiper_next.css('transform')=='none'){swiper_next_height=swiper_next.outerHeight()}
swiper_prev.css({'top':(item_height/2)-(swiper_prev_height/2)+'px'})
swiper_next.css({'top':(item_height/2)-(swiper_next_height/2)+'px'})});swiper_resize_observer.observe(_this.get(0))}}}else{_this.bxSlider({minSlides:3,maxSlides:7,slideWidth:170,slideMargin:10,nextText:'',prevText:'',pager:!1,infiniteLoop:!1,hideControlOnEnd:!0})}})}});feed.run()}catch(e){console.log(e)}}};/*! ResponsiveSlides.js v1.54
* http://responsiveslides.com
* http://viljamis.com
*
* Copyright (c) 2011-2012 @viljamis
* Available under the MIT license
*/
(function($,window,i){$.fn.responsiveSlides=function(options){var settings=$.extend({"auto":!0,"speed":500,"timeout":4000,"pager":!1,"nav":!1,"random":!1,"pause":!1,"pauseControls":!0,"touch":!0,"touchThreshold":100,"prevText":"Previous","nextText":"Next","maxwidth":"","navContainer":"","manualControls":"","namespace":"rslides","before":$.noop,"after":$.noop},options);return this.each(function(){i++;var $this=$(this),vendor,selectTab,startCycle,restartCycle,rotate,$tabs,index=0,$slide=$this.children(),length=$slide.size(),fadeTime=parseFloat(settings.speed),waitTime=parseFloat(settings.timeout),maxw=parseFloat(settings.maxwidth),namespace=settings.namespace,namespaceIdx=namespace+i,navClass=namespace+"_nav "+namespaceIdx+"_nav",activeClass=namespace+"_here",visibleClass=namespaceIdx+"_on",slideClassPrefix=namespaceIdx+"_s",$pager=$(""),visible={"float":"left","position":"relative","opacity":1,"zIndex":2},hidden={"float":"none","position":"absolute","opacity":0,"zIndex":1},supportsTransitions=(function(){var docBody=document.body||document.documentElement;var styles=docBody.style;var prop="transition";if(typeof styles[prop]==="string"){return!0}
vendor=["Moz","Webkit","Khtml","O","ms"];prop=prop.charAt(0).toUpperCase()+prop.substr(1);var i;for(i=0;i1){if(waitTime"+""+n+""+""});$pager.append(tabMarkup);if(options.navContainer){$(settings.navContainer).append($pager)}else{$this.after($pager)}}
if(settings.manualControls){$pager=$(settings.manualControls);$pager.addClass(namespace+"_tabs "+namespaceIdx+"_tabs")}
if(settings.pager||settings.manualControls){$pager.find('li').each(function(i){$(this).addClass(slideClassPrefix+(i+1))})}
if(settings.pager||settings.manualControls){$tabs=$pager.find('a');selectTab=function(idx){$tabs.closest("li").removeClass(activeClass).eq(idx).addClass(activeClass)}}
if(settings.auto){startCycle=function(){rotate=setInterval(function(){$slide.stop(!0,!0);var idx=index+1"+settings.prevText+""+""+settings.nextText+"";if(options.navContainer){$(settings.navContainer).append(navMarkup)}else{$this.after(navMarkup)}
var $trigger=$("."+namespaceIdx+"_nav"),$prev=$trigger.filter(".prev");$trigger.bind("click",function(e){e.preventDefault();var $visibleClass=$("."+visibleClass);if($visibleClass.queue('fx').length){return}
var idx=$slide.index($visibleClass),prevIdx=idx-1,nextIdx=idx+1-1&&rsTouch.touches.touchmove.x>-1&&(Math.abs(rsTouch.touches.touchstart.y-rsTouch.touches.touchmove.y)<20)){rsTouch.touches.direction=rsTouch.touches.touchstart.xsettings.touchThreshold){if(rsTouch.touches.direction==="left"){slideTo(nextIdx)}else{slideTo(prevIdx)}
e.preventDefault();rsTouch.touches.touchstart={"x":-1,"y":-1};rsTouch.touches.touchmove={"x":-1,"y":-1};rsTouch.touches.direction="undetermined";restartCycle()}}
break;default:break}}}},init:function(){$slide.bind('touchstart',rsTouch.touchHandler);$slide.bind('touchmove',rsTouch.touchHandler);$slide.bind('touchend',rsTouch.touchHandler)}};rsTouch.init()}
if(typeof document.body.style.maxWidth==="undefined"&&options.maxwidth){var widthSupport=function(){$this.css("width","100%");if($this.width()>maxw){$this.css("width",maxw)}};widthSupport();$(window).bind("resize",function(){widthSupport()})}})}})(jQuery,this,0);Shopcada.functions.initMessageBar=function(){$(".messagebar.autorotate #messagebar-inner").responsiveSlides({timeout:Shopcada.settings.MessageBar.Timeout,pager:!1,nav:!1,speed:Shopcada.settings.MessageBar.Speed})}
$(document).ready(function(){Shopcada.functions.initMessageBar()});Shopcada.tasks.FAPI_OnOff=function(){$("input.onff-enabled").not(".onoff-processed").each(function(){var _this=$(this);var _parent=_this.parent();_this.addClass("onoff-processed");className="toggle-enable";if(_this.prop("disabled")==="disabled"){className+=" disabled"}else{if(_this.prop("checked")===!0){className+=" enabled"}else{className+=" off"}}
_parent.append("");_this.change(function(){_widget=_parent.find(".toggle-enable");_widget.toggleClass("off");_widget.toggleClass("enabled")});_this.hide()})}