text: var FocalSlider=function(){function t(t,e,i,n){this.src=t,this.focalPoint=c[e.toUpperCase().replace("-","_")],this.parent=i,this.index=n,this.image=new Image,this.loaded=!1}function e(t){this.containerSelector=t.container,this.container=null,this.canvas=null,this.context=null,this.slides=[],this.currentSlideIndex=-1,this.numSlides=0,this.autoPlay=t.autoPlay!==!1,this.hideArrows=t.hideArrows===!0,this.slideDuration=t.slideDuration||5e3,this.transitionInProgress=!1,this.createCanvas(),t.slides&&t.slides.length>0&&this.loadSlides(t.slides)}function n(t,e,i,s,o){return s>100?void("function"==typeof o&&o()):(t.drawImage(i,s/100),t.drawImage(e,1-s/100),s+=4,void l(function(){n(t,e,i,s,o)}))}function s(t,e){t.save(),t.globalAlpha=.8,t.drawImage(a,0,e.y/2-16),t.drawImage(r,e.x-32,e.y/2-16),t.restore()}function o(t,e){var i=t.getBoundingClientRect(),n=e.clientX-i.left,s=e.clientY-i.top;return{x:n,y:s}}var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA8UlEQVRYhd2X0QYCQRSG10pPkCRJz5QkXaQXSrJWkvREe5EkSdI7dLfyddFGRrszy5456WevZna/zxk7cyYIKg4QAhEwqPrbrvANr6TAWAvOh8TEF3zL9zyAqRb8nQSoacF3QEMKbq65mb0m/AA0teBHoCUFX1vgJ6AtBV/9MvwMdP4SvtSCB9rw2Ac8LBi7W96tZ49MsirMLFW4AT1piblF4upDYuEg0ZWWiCwSFx8SXv6MIgm9XbGkhMyhZEjYjmWZnsCQcGlMqu+KDAlbJWT6wpISCVC07YtK+Lmi5UikwEgcniORAkNvcEMiBvou85/zmmf/a5dcPQAAAABJRU5ErkJggg==";var r=new Image;r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA7klEQVRYhe2X0QYCQRSGx0qXK0mPlGSlN1xJkqyeIF0mSZKeJRFfFy1t2m0OO2dmL/qvl++b3ePsP8YIAgyAFGhJnncaYATceGXlVQJIgDuf8SMBTErgfiQAA2wr4N4kYmAXWqIDHEJLdIGjRWLpQ+IUWqIHnJsgcbFILLQl+gKJeVMkotASs79EnmmVhAuzyBhjG7iHA8538tNfLadPVT5B3VdfFy5ZSDrDh2wl62xDQv6UhHCdboCsE6jBJa0o04LHwD4k3FZK10BbA26ATRB4QeLXxUQXXpAYl0hkXuAFiYT35VRn4AQSQ5R63hNnHGgduYs84gAAAABJRU5ErkJggg==";var d,h,c={TOP_LEFT:0,TOP_MIDDLEe:1,TOP_RIGHT:2,MIDDLE_LEFT:3,MIDDLE:4,MIDDLE_RIGHT:5,BOTTOM_LEFT:6,BOTTOM_MIDDLE:7,BOTTOM_RIGHT:8},l=function(t){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}();return"undefined"!=typeof document.hidden?(d="hidden",h="visibilitychange"):"undefined"!=typeof document.msHidden?(d="msHidden",h="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(d="webkitHidden",h="webkitvisibilitychange"),function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}return"function"!=typeof window.CustomEvent&&(t.prototype=window.Event.prototype,void(window.CustomEvent=t))}(),t.prototype.load=function(t,e){var n=this;this.image.onload=function(){n.loaded=!0,"function"==typeof t&&t(n)},this.image.onerror=function(){console.error("Unable to load image "+i+" src: "+slides[i].src),"function"==typeof e&&e(n)},this.image.src=this.src},t.prototype.show=function(){if(this.loaded)this.parent.showSlide(this);else{var t=this;this.load(function(){t.parent.showSlide(this)})}},e.prototype.addSlide=function(e,i){this.numSlides=this.slides.push(new t(e,i,this,this.slides.length))},e.prototype.removeSlide=function(t){if("undefined"!=typeof this.slides[t])for(this.slides.splice(t,1);t<this.slides.length;t++)this.slides[t].index=t},e.prototype.loadSlides=function(t){for(i=0;i<t.length;i++)this.addSlide(t[i].src,t[i].focus);this.waiting=!0;var e=this,n=function(t){var i=new CustomEvent("slideloaded",{detail:t});e.getCanvas().dispatchEvent(i),t.index<e.numSlides-1&&e.slides[t.index+1].load(n)};this.slides[0].load(n),this.autoPlay&&this.start()},e.prototype.showSlide=function(t){var e;if(void 0===t||null===t?(e=this.currentSlideIndex,t=this.slides[e]):"number"==typeof t?(e=t,t=this.slides[e]):e=t.index,this.currentSlideIndex!==-1){var i=this.slides[this.currentSlideIndex],s=this;this.transitionInProgress=!0,n(this,i,t,0,function(){s.transitionInProgress=!1,s.currentSlideIndex=e,void 0!==s.timer&&s.restart()})}else this.drawImage(t),this.currentSlideIndex=e},e.prototype.next=function(){var t=this.currentSlideIndex+1;t===this.numSlides&&(t=0);var e=this.slides[t];e.loaded?this.showSlide(e):this.waiting=!0},e.prototype.previous=function(){var t=this.currentSlideIndex-1;t===-1&&(t=this.numSlides-1);var e=this.slides[t];e.loaded?this.showSlide(e):this.waiting=!0},e.prototype.start=function(t){"number"!=typeof t?t=this.slideDuration:this.slideDuration=t,this.stop(),this.timer=setInterval(this.next.bind(this),t)},e.prototype.stop=function(){"undefined"!=typeof this.timer&&(clearInterval(this.timer),delete this.timer)},e.prototype.restart=function(){this.stop(),this.start()},e.prototype.getCanvas=function(){return this.canvas},e.prototype.getContext=function(){return this.context||(this.context=this.canvas.getContext("2d")),this.context},e.prototype.getCanvasSize=function(){return{x:this.getCanvas().scrollWidth,y:this.getCanvas().scrollHeight}},e.prototype.drawImage=function(t,e){void 0===e&&(e=1);var i,n,o=t.image.width,a=t.image.height,r=o/a,d=this.getCanvasSize(),h=d.x,l=d.y,u=h/l;u<r?(i=o*l/a,n=l):(i=h,n=a*h/o);var v=0,m=0;switch(t.focalPoint){case c.TOP_RIGHT:case c.MIDDLE_RIGHT:case c.BOTTOM_RIGHT:i>h&&(v=h-i);break;case c.TOP_MIDDLE:case c.MIDDLE:case c.BOTTOM_MIDDLE:i>h&&(v=(h-i)/2)}switch(t.focalPoint){case c.BOTTOM_LEFT:case c.BOTTOM_MIDDLE:case c.BOTTOM_RIGHT:n>l&&(m=l-n);break;case c.MIDDLE_LEFT:case c.MIDDLE:case c.MIDDLE_RIGHT:n>l&&(m=(l-n)/2)}var A=this.getContext();A.globalAlpha=e,A.drawImage(t.image,v,m,i,n),this.hideIcons||s(A,d)},e.prototype.createCanvas=function(t){t?this.containerSelector=t:t=this.containerSelector,this.container=document.querySelector(t),this.canvas=document.createElement("canvas"),this.setCanvasSize(),this.container.appendChild(this.canvas),this.addEventListeners()},e.prototype.addEventListeners=function(){var t=this;window.addEventListener("resize",function(){t.resize()},!1),document.addEventListener(h,function(){document[d]?"undefined"!=typeof t.timer&&(t.resumeTimer=!0,t.stop()):t.resumeTimer===!0&&(delete t.resumeTimer,t.start())},!1),this.canvas.addEventListener("click",function(e){if(!t.transitionInProgress){var i=o(t.canvas,e),n=t.getCanvasSize();i.x>0&&i.x<64?t.previous():i.x>n.x-64&&i.x<n.x&&t.next()}},!1),this.canvas.addEventListener("slideloaded",function(e){t.waiting&&(t.waiting=!1,t.showSlide(e.detail))})},e.prototype.setCanvasSize=function(){this.canvas.width=this.container.clientWidth,this.canvas.height=this.container.clientHeight},e.prototype.resize=function(){this.setCanvasSize(),this.transitionInProgress||this.drawImage(this.slides[this.currentSlideIndex])},e}();