OwlCyberSecurity - MANAGER
Edit File: juxtapose.min.js
/* juxtapose - v1.2.1 - 2019-04-18 * Copyright (c) 2019 Alex Duner and Northwestern University Knight Lab */ !function(t,e){var i={sliders:[],OPTIMIZATION_ACCEPTED:1,OPTIMIZATION_WAS_CONSTRAINED:2},s=["Large","Medium"];function r(t,e){var i=this;this.image=new Image,this.loaded=!1,this.image.onload=function(){i.loaded=!0,e._onLoaded()},this.image.src=t.src,this.image.alt=t.alt||"",this.label=t.label||!1,this.credit=t.credit||!1}function a(t,e){var i=this;this.image=new Image,this.loaded=!1,this.image.onload=function(){i.loaded=!0,e._onLoaded()},this.flickrID=this.getFlickrID(t.src),this.callFlickrAPI(this.flickrID,i),this.label=t.label||!1,this.credit=t.credit||!1}function n(t){if(t.naturalWidth&&t.naturalHeight)return{width:t.naturalWidth,height:t.naturalHeight};var e=new Image;return e.src=t.src,{width:e.width,height:e.height}}function o(t){return{width:n(t).width,height:n(t).height,aspect:function(){return this.width/this.height}}}function l(t,e){t.classList?t.classList.add(e):t.className+=" "+e}function d(t,e){t.className=t.className.replace(/(\S+)\s*/g,function(t,i){return i===e?"":t}).replace(/^\s+/,"")}function c(e,i){t.body.textContent?e.textContent=i:e.innerText=i}function p(t){return e.getComputedStyle?{width:parseInt(getComputedStyle(t).width,10),height:parseInt(getComputedStyle(t).height,10)}:(w=t.getBoundingClientRect().right-t.getBoundingClientRect().left,h=t.getBoundingClientRect().bottom-t.getBoundingClientRect().top,{width:parseInt(w,10)||0,height:parseInt(h,10)||0})}function g(t){return!!t.match(/flic.kr\/.+/i)||-1!=t.indexOf("flickr.com/photos/")}function m(e,i){if("string"==typeof i||"number"==typeof i)leftPercent=parseInt(i,10);else{var s=e.getBoundingClientRect(),r={top:s.top+t.body.scrollTop+t.documentElement.scrollTop,left:s.left+t.body.scrollLeft+t.documentElement.scrollLeft},a=e.offsetWidth,n=(o=i).pageX?o.pageX:o.touches?o.touches[0].pageX:o.clientX+t.body.scrollLeft+t.documentElement.scrollLeft;leftPercent=(n-r.left)/a*100}var o;return leftPercent}function u(e,i){if("string"==typeof i||"number"==typeof i)topPercent=parseInt(i,10);else{var s=e.getBoundingClientRect(),r={top:s.top+t.body.scrollTop+t.documentElement.scrollTop,left:s.left+t.body.scrollLeft+t.documentElement.scrollLeft},a=e.offsetHeight,n=(o=i).pageY?o.pageY:o.touches?o.touches[0].pageY:o.clientY+t.body.scrollTop+t.documentElement.scrollTop;topPercent=(n-r.top)/a*100}var o;return topPercent}a.prototype={getFlickrID:function(t){if(t.match(/flic.kr\/.+/i))return function(t){var e="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",i=e.length;if("string"!=typeof t)throw'"base58Decode" only accepts strings.';var s=0;for(;t;){var r=e.indexOf(t[0]);if(r<0)throw'"base58Decode" can\'t find "'+t[0]+'" in the alphabet: "'+e+'"';var a=t.length-1;s+=r*Math.pow(i,a),t=t.substring(1)}return s.toString()}(t.split("/").slice(-1)[0]);var e=t.indexOf("flickr.com/photos/")+"flickr.com/photos/".length,i=t.substr(e);return-1==i.indexOf("/")?null:(0===i.indexOf("/")&&(i=i.substr(1)),id=i.split("/")[1],id)},callFlickrAPI:function(t,e){var i="https://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=d90fc2d1f4acc584e08b8eaea5bf4d6c&photo_id="+t+"&format=json&nojsoncallback=1",s=new XMLHttpRequest;s.open("GET",i,!0),s.onload=function(){if(s.status>=200&&s.status<400){data=JSON.parse(s.responseText);var t=e.bestFlickrUrl(data.sizes.size);e.setFlickrImage(t)}else console.error("There was an error getting the picture from Flickr")},s.onerror=function(){console.error("There was an error getting the picture from Flickr")},s.send()},setFlickrImage:function(t){this.image.src=t},bestFlickrUrl:function(t){for(var e={},i=0;i<t.length;i++)e[t[i].label]=t[i].source;for(var r=0;r<s.length;r++)if(s[r]in e)return e[s[r]];return t[0].source}};var f={animate:!0,showLabels:!0,showCredits:!0,makeResponsive:!0};function v(t,e,i){var s,n;for(s in this.selector=t,this.options={animate:!0,showLabels:!0,showCredits:!0,makeResponsive:!0,startingPosition:"50%",mode:"horizontal",callback:null},this.options)s in i&&(this.options[s]=s in f?"string"!=typeof(n=i[s])?Boolean(n):!("false"===n||""===n):i[s]);2==e.length?(g(e[0].src)?this.imgBefore=new a(e[0],this):this.imgBefore=new r(e[0],this),g(e[1].src)?this.imgAfter=new a(e[1],this):this.imgAfter=new r(e[1],this)):console.warn("The images parameter takes two Image objects."),this.imgBefore.credit||this.imgAfter.credit?this.options.showCredits=!0:this.options.showCredits=!1}v.prototype={updateSlider:function(t,e){var i,s;i=(i="vertical"===this.options.mode?u(this.slider,t):m(this.slider,t)).toFixed(2)+"%",leftPercentNum=parseFloat(i),s=100-leftPercentNum+"%",leftPercentNum>0&&leftPercentNum<100&&(d(this.handle,"transition"),d(this.rightImage,"transition"),d(this.leftImage,"transition"),this.options.animate&&e&&(l(this.handle,"transition"),l(this.leftImage,"transition"),l(this.rightImage,"transition")),"vertical"===this.options.mode?(this.handle.style.top=i,this.leftImage.style.height=i,this.rightImage.style.height=s):(this.handle.style.left=i,this.leftImage.style.width=i,this.rightImage.style.width=s),this.sliderPosition=i)},getPosition:function(){return this.sliderPosition},displayLabel:function(e,i){label=t.createElement("div"),label.className="jx-label",label.setAttribute("tabindex",0),c(label,i),e.appendChild(label)},displayCredits:function(){credit=t.createElement("div"),credit.className="jx-credit",text="<em>Photo Credits:</em>",this.imgBefore.credit&&(text+=" <em>Before</em> "+this.imgBefore.credit),this.imgAfter.credit&&(text+=" <em>After</em> "+this.imgAfter.credit),credit.innerHTML=text,this.wrapper.appendChild(credit)},setStartingPosition:function(t){this.options.startingPosition=t},checkImages:function(){return o(this.imgBefore.image).aspect()==o(this.imgAfter.image).aspect()},calculateDims:function(t,e){var i=o(this.imgBefore.image).aspect();return t?e=t/i:e&&(t=e*i),{width:t,height:e,ratio:i}},responsivizeIframe:function(t){return t.height<e.innerHeight?t.ratio>=1&&(this.wrapper.style.paddingTop=parseInt((e.innerHeight-t.height)/2)+"px"):t.height>e.innerHeight&&(t=this.calculateDims(0,e.innerHeight),this.wrapper.style.paddingLeft=parseInt((e.innerWidth-t.width)/2)+"px"),this.options.showCredits&&(t.height-=13),t},setWrapperDimensions:function(){var t=p(this.wrapper).width,i=p(this.wrapper).height,s=this.calculateDims(t,i);e.location===e.parent.location||this.options.makeResponsive||(s=this.responsivizeIframe(s)),this.wrapper.style.height=parseInt(s.height)+"px",this.wrapper.style.width=parseInt(s.width)+"px"},optimizeWrapper:function(t){var e=i.OPTIMIZATION_ACCEPTED;return this.imgBefore.image.naturalWidth>=t&&this.imgAfter.image.naturalWidth>=t?(this.wrapper.style.width=t+"px",e=i.OPTIMIZATION_WAS_CONSTRAINED):this.imgAfter.image.naturalWidth<t?this.wrapper.style.width=this.imgAfter.image.naturalWidth+"px":this.wrapper.style.width=this.imgBefore.image.naturalWidth+"px",this.setWrapperDimensions(),e},_onLoaded:function(){this.imgBefore&&!0===this.imgBefore.loaded&&this.imgAfter&&!0===this.imgAfter.loaded&&(this.wrapper=t.querySelector(this.selector),l(this.wrapper,"juxtapose"),this.wrapper.style.width=n(this.imgBefore.image).width,this.setWrapperDimensions(),this.slider=t.createElement("div"),this.slider.className="jx-slider",this.wrapper.appendChild(this.slider),"horizontal"!=this.options.mode&&l(this.slider,this.options.mode),this.handle=t.createElement("div"),this.handle.className="jx-handle",this.rightImage=t.createElement("div"),this.rightImage.className="jx-image jx-right",this.rightImage.appendChild(this.imgAfter.image),this.leftImage=t.createElement("div"),this.leftImage.className="jx-image jx-left",this.leftImage.appendChild(this.imgBefore.image),this.labCredit=t.createElement("a"),this.labCredit.setAttribute("href","http://juxtapose.knightlab.com"),this.labCredit.setAttribute("target","_blank"),this.labCredit.className="jx-knightlab",this.labLogo=t.createElement("div"),this.labLogo.className="knightlab-logo",this.labCredit.appendChild(this.labLogo),this.projectName=t.createElement("span"),this.projectName.className="juxtapose-name",c(this.projectName,"JuxtaposeJS"),this.labCredit.appendChild(this.projectName),this.slider.appendChild(this.handle),this.slider.appendChild(this.leftImage),this.slider.appendChild(this.rightImage),this.slider.appendChild(this.labCredit),this.leftArrow=t.createElement("div"),this.rightArrow=t.createElement("div"),this.control=t.createElement("div"),this.controller=t.createElement("div"),this.leftArrow.className="jx-arrow jx-left",this.rightArrow.className="jx-arrow jx-right",this.control.className="jx-control",this.controller.className="jx-controller",this.controller.setAttribute("tabindex",0),this.controller.setAttribute("role","slider"),this.controller.setAttribute("aria-valuenow",50),this.controller.setAttribute("aria-valuemin",0),this.controller.setAttribute("aria-valuemax",100),this.handle.appendChild(this.leftArrow),this.handle.appendChild(this.control),this.handle.appendChild(this.rightArrow),this.control.appendChild(this.controller),this._init())},_init:function(){!1===this.checkImages()&&console.warn(this,"Check that the two images have the same aspect ratio for the slider to work correctly."),this.updateSlider(this.options.startingPosition,!1),!0===this.options.showLabels&&(this.imgBefore.label&&this.displayLabel(this.leftImage,this.imgBefore.label),this.imgAfter.label&&this.displayLabel(this.rightImage,this.imgAfter.label)),!0===this.options.showCredits&&this.displayCredits();var t=this;e.addEventListener("resize",function(){t.setWrapperDimensions()}),this.slider.addEventListener("mousedown",function(i){(i=i||e.event).preventDefault(),t.updateSlider(i,!0),animate=!0,this.addEventListener("mousemove",function(i){(i=i||e.event).preventDefault(),animate&&t.updateSlider(i,!1)}),this.addEventListener("mouseup",function(t){(t=t||e.event).preventDefault(),t.stopPropagation(),this.removeEventListener("mouseup",arguments.callee),animate=!1})}),this.slider.addEventListener("touchstart",function(i){(i=i||e.event).preventDefault(),i.stopPropagation(),t.updateSlider(i,!0),this.addEventListener("touchmove",function(i){(i=i||e.event).preventDefault(),i.stopPropagation(),t.updateSlider(event,!1)})}),this.handle.addEventListener("keydown",function(i){var s=(i=i||e.event).which||i.keyCode,r=parseFloat(this.style.left);if(37==s){r-=1;var a=parseFloat(this.style.left)-1;t.updateSlider(a,!1),t.controller.setAttribute("aria-valuenow",r)}if(39==s){r+=1;var n=parseFloat(this.style.left)+1;t.updateSlider(n,!1),t.controller.setAttribute("aria-valuenow",r)}}),this.leftImage.addEventListener("keydown",function(e){var i=e.which||e.keyCode;13!=i&&32!=i||(t.updateSlider("90%",!0),t.controller.setAttribute("aria-valuenow",90))}),this.rightImage.addEventListener("keydown",function(e){var i=e.which||e.keyCode;13!=i&&32!=i||(t.updateSlider("10%",!0),t.controller.setAttribute("aria-valuenow",10))}),i.sliders.push(this),this.options.callback&&"function"==typeof this.options.callback&&this.options.callback(this)}},i.makeSlider=function(t,e){void 0===e&&(e=i.sliders.length);var s=t,r=s.querySelectorAll("img"),a={};s.getAttribute("data-animate")&&(a.animate=s.getAttribute("data-animate")),s.getAttribute("data-showlabels")&&(a.showLabels=s.getAttribute("data-showlabels")),s.getAttribute("data-showcredits")&&(a.showCredits=s.getAttribute("data-showcredits")),s.getAttribute("data-startingposition")&&(a.startingPosition=s.getAttribute("data-startingposition")),s.getAttribute("data-mode")&&(a.mode=s.getAttribute("data-mode")),s.getAttribute("data-makeresponsive")&&(a.mode=s.getAttribute("data-makeresponsive")),specificClass="juxtapose-"+e,l(t,specificClass),selector="."+specificClass,s.innerHTML?s.innerHTML="":s.innerText="",slider=new i.JXSlider(selector,[{src:r[0].src,label:r[0].getAttribute("data-label"),credit:r[0].getAttribute("data-credit"),alt:r[0].alt},{src:r[1].src,label:r[1].getAttribute("data-label"),credit:r[1].getAttribute("data-credit"),alt:r[1].alt}],a)},i.scanPage=function(){for(var e=t.querySelectorAll(".juxtapose"),s=0;s<e.length;s++)i.makeSlider(e[s],s)},i.JXSlider=v,e.juxtapose=i,i.scanPage()}(document,window),!window.addEventListener&&function(t,e,i,s,r,a,n){t.addEventListener=e.addEventListener=i.addEventListener=function(t,e){var i=this;n.unshift([i,t,e,function(t){t.currentTarget=i,t.preventDefault=function(){t.returnValue=!1},t.stopPropagation=function(){t.cancelBubble=!0},t.target=t.srcElement||i,e.call(i,t)}]),this.attachEvent("on"+t,n[0][3])},t.removeEventListener=e.removeEventListener=i.removeEventListener=function(t,e){for(var i,s=0;i=n[s];++s)if(i[0]==this&&i[1]==t&&i[2]==e)return this.detachEvent("on"+t,n.splice(s,1)[0][3])},t.dispatchEvent=e.dispatchEvent=i.dispatchEvent=function(t){return this.fireEvent("on"+t.type,t)}}(Window.prototype,HTMLDocument.prototype,Element.prototype,0,0,0,[]);