/*jquery.als v.2.1 | (c) 2012-2020 Federica Sibella musings(at)musings(dot)it | https://www.musings.it | MIT license.*/ !function(t){function i(t){if("string"==typeof t){var i=t.indexOf("_");-1!=i&&(t=t.substr(i+1))}return t}function e(e,s){e.preventDefault(),void 0===s&&(s=t(this));var n=i(s.attr("data-id")),r=o[n];r.next.off(),r.prev.off(),r.viewport.off("touchend"),"yes"===r.settings.autoscroll&&t.fn.als("stop",n),t.fn.als("step",n,"next"),"yes"===r.settings.autoscroll&&t.fn.als("start",n)}function s(e,s){e.preventDefault(),void 0===s&&(s=t(this));var n=i(s.attr("data-id")),r=o[n];r.prev.off(),r.next.off(),r.viewport.off("touchend"),"yes"===r.settings.autoscroll&&t.fn.als("stop",n),t.fn.als("step",n,"prev"),"yes"===r.settings.autoscroll&&t.fn.als("start",n)}function n(e,s){e.preventDefault(),void 0===s&&(s=t(this));var n=i(s.attr("data-id")),r=o[n],a=r.mm,l=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0];void 0===e.originalEvent.touches&&(l=e),a.ox=l.pageX,a.oy=l.pageY,a.startTime=(new Date).getTime()}function r(n,r){n.preventDefault(),void 0===r&&(r=t(this));var a=i(r.attr("data-id")),l=o[a],c=l.mm,m=n.originalEvent.touches[0]||n.originalEvent.changedTouches[0],h=0;void 0===n.originalEvent.touches&&(m=n),c.dx=m.pageX-c.ox,c.dy=m.pageY-c.oy,c.endTime=(new Date).getTime()-c.startTime,h="horizontal"==l.settings.orientation?c.dx:c.dy,h<-c.swipeTreshold&&c.endTimec.swipeTreshold&&c.endTime0)&&s(n,r)}var o=[],a=0,l={init:function(i){var l={visible_items:"auto",scrolling_items:1,orientation:"horizontal",circular:"no",autoscroll:"no",interval:4e3,speed:600,easing:"swing",direction:"left",start_from:0},c=t.extend({},l,i);o[a]={container:t(),instance:a,settings:c,viewport:t(),wrapper:t(),prev:t(),next:t(),item:t(),num_items:0,init_visible_items:0,init_scrolling_items:0,initial_movement:0,wrapper_width:0,wrapper_height:0,viewport_width:0,viewport_height:0,max_viewport_dimension:0,max_item_dimension:0,max_height:0,max_width:0,current:0,timer:0,mm:{swipeTreshold:30,allowedTime:1e3}},this.each(function(){if(o[a].container=t(this),"no"==o[a].settings.circular&&"yes"==o[a].settings.autoscroll&&(o[a].settings.circular="yes"),"linear"==o[a].settings.easing&&"swing"==o[a].settings.easing||(o[a].settings.easing="swing"),o[a].container.attr("id")&&""!==o[a].container.attr("id")||o[a].container.attr("id","als-container_"+a),o[a].container.attr("data-id","als-container_"+a),o[a].viewport=o[a].container.find(".als-viewport").attr("data-id","als-viewport_"+a),o[a].wrapper=o[a].container.find(".als-wrapper").attr("data-id","als-wrapper_"+a),o[a].item=o[a].container.find(".als-item"),o[a].num_items=o[a].item.length,"number"==typeof o[a].settings.visible_items&&(o[a].settings.visible_items>o[a].num_items&&(o[a].settings.visible_items=o[a].num_items-1),o[a].init_visible_items=o[a].settings.visible_items,o[a].settings.scrolling_items>o[a].settings.visible_items&&(o[a].settings.scrolling_items=o[a].settings.visible_items-1)),o[a].init_scrolling_items=o[a].settings.scrolling_items,o[a].settings.start_from>o[a].num_items-o[a].settings.visible_items&&(o[a].settings.start_from=0),o[a].prev=o[a].container.find(".als-prev").attr("data-id","als-prev_"+a),o[a].next=o[a].container.find(".als-next").attr("data-id","als-next_"+a),o[a].settings.start_from>0&&o[a].settings.start_from0&&io[a].max_height&&(o[a].max_height=t(this).outerHeight(!0))):"vertical"==o[a].settings.orientation&&(o[a].wrapper_height+=t(this).outerHeight(!0),o[a].current>0&&io[a].max_width&&(o[a].max_width=t(this).outerWidth(!0)))}),t.fn.als("resize",a),"horizontal"==o[a].settings.orientation){if(o[a].wrapper.css("width",o[a].wrapper_width),o[a].item.css("left",-o[a].initial_movement),o[a].wrapper.css("height",o[a].max_height),o[a].viewport.css("height",o[a].max_height),o[a].viewport_height=o[a].max_height,o[a].wrapper_height=o[a].max_height,"yes"==o[a].settings.circular&&0!==o[a].settings.start_from)for(var i=o[a].item.last().position().left+o[a].item.last().outerWidth(!0),l=0;l=o[t].num_items&&(f=_-o[t].num_items),"horizontal"==o[t].settings.orientation?a+=o[t].item.eq(f).outerWidth(!0):"vertical"==o[t].settings.orientation&&(a+=o[t].item.eq(f).outerHeight(!0)),u[g]=f,g++}else"horizontal"==o[t].settings.orientation?a+=o[t].item.eq(_).outerWidth(!0):"vertical"==o[t].settings.orientation&&(a+=o[t].item.eq(_).outerHeight(!0));"next"==n&&(o[t].current+=o[t].settings.scrolling_items,h="-=","yes"==o[t].settings.circular&&o[t].current>=o[t].num_items&&(o[t].current-=o[t].num_items));for(var w=o[t].current;w=o[t].num_items&&(x=w-o[t].num_items),"horizontal"==o[t].settings.orientation?c+o[t].item.eq(x).outerWidth(!0)H;H++)o[t].item.eq(u[H]).css(q)}}o[t].viewport.animate(m,o[t].settings.speed,o[t].settings.easing),o[t].item.animate(l,o[t].settings.speed,o[t].settings.easing),"yes"==o[t].settings.circular&&"next"==n&&o[t].item.promise().done(function(){p=o[t].item.last().position(),"horizontal"==o[t].settings.orientation?(d=p.left+o[t].item.last().outerWidth(!0),v.left=d):"vertical"==o[t].settings.orientation&&(d=p.top+o[t].item.last().outerHeight(!0),v.top=d);for(var i=0;i0?o[t].prev.show():o[t].prev.hide(),o[t].current+o[t].settings.visible_items>=o[t].num_items?o[t].next.hide():o[t].next.show()),o[t].item.promise().done(function(){o[t].next.on("click touchstart touchend",e),o[t].prev.on("click touchstart touchend",s),o[t].viewport.on("touchend",r)})},start:function(e){e=i(e);var s=o[e];switch(0!==s.timer&&clearInterval(s.timer),s.settings.direction){default:s.timer=setInterval(function(){s.next.off(),s.prev.off(),s.viewport.off("touchend"),t.fn.als("step",e,"next")},s.settings.interval);break;case"right":case"down":s.timer=setInterval(function(){s.prev.off(),s.next.off(),s.viewport.off("touchend"),t.fn.als("step",e,"prev")},s.settings.interval)}return o[e]=s,o},stop:function(t){t=i(t);var e=o[t];return clearInterval(e.timer),o[t]=e,o},resize:function(e){e=i(e);var s=0,n=0,r=!1,a=t(),l=t(),c=0,m=0,h={};return o[e].current>0?(a=o[e].item.slice(o[e].current),l=o[e].item.slice(0,o[e].current),t.merge(a,l)):a=o[e].item,o[e].prev.length>0&&(n=o[e].prev.position(),"horizontal"==o[e].settings.orientation?n=n.left+o[e].prev.outerWidth(!0):"vertical"==o[e].settings.orientation&&(n=n.top+o[e].prev.outerHeight(!0))),"horizontal"==o[e].settings.orientation?m=parseInt(o[e].container.width()-2*n):"vertical"==o[e].settings.orientation&&(m=parseInt(o[e].container.height()-2*n)),o[e].max_viewport_dimension=m,o[e].max_item_dimension=m,a.each(function(){"horizontal"==o[e].settings.orientation?t(this).css("max-width",m):"vertical"==o[e].settings.orientation&&t(this).css("max-height",m),o[e].init_visible_items>0?r===!1&&("horizontal"==o[e].settings.orientation?s0&&o[e].init_scrolling_items<=o[e].settings.visible_items?o[e].settings.scrolling_items=o[e].init_scrolling_items:o[e].settings.visible_items>1?o[e].settings.scrolling_items=o[e].settings.visible_items-1:o[e].settings.scrolling_items=1,o},destroy:function(){var e=i(t(this).attr("data-id")),s=o[e];s.prev.off(),s.next.off(),s.viewport.off(),t.fn.als("stop",e),this.unbind(),this.element=null}};t(window).resize(function(){for(var i=0;a>i;i++)t.fn.als("resize",i)}),t.fn.als=function(i){return l[i]?l[i].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof i&&i?void t.error("Method "+i+" does not exist on jQuery.als"):l.init.apply(this,arguments)}}(jQuery);