/*! angular-bootstrap-lightbox */ angular.module("bootstrapLightbox",["ui.bootstrap"]);try{angular.module("angular-loading-bar"),angular.module("bootstrapLightbox").requires.push("angular-loading-bar")}catch(e){}try{angular.module("ngTouch"),angular.module("bootstrapLightbox").requires.push("ngTouch")}catch(e){}angular.module("bootstrapLightbox").run(["$templateCache",function(a){"use strict";a.put("lightbox.html",'
')}]),angular.module("bootstrapLightbox").service("ImageLoader",["$q",function(a){this.load=function(b){var c=a.defer(),d=new Image;return d.onload=function(){("boolean"==typeof this.complete&&this.complete===!1||"number"==typeof this.naturalWidth&&0===this.naturalWidth)&&c.reject(),c.resolve(d)},d.onerror=function(){c.reject()},d.src=b,c.promise}}]),angular.module("bootstrapLightbox").provider("Lightbox",function(){this.templateUrl="lightbox.html",this.getImageUrl=function(a){return a.url},this.getImageCaption=function(a){return a.caption},this.calculateImageDimensionLimits=function(a){return a.windowWidth>=768?{maxWidth:a.windowWidth-92,maxHeight:a.windowHeight-126}:{maxWidth:a.windowWidth-52,maxHeight:a.windowHeight-86}},this.calculateModalDimensions=function(a){var b=Math.max(400,a.imageDisplayWidth+32),c=Math.max(200,a.imageDisplayHeight+66);return(b>=a.windowWidth-20||a.windowWidth<768)&&(b="auto"),c>=a.windowHeight&&(c="auto"),{width:b,height:c}},this.$get=["$document","$injector","$modal","$timeout","ImageLoader",function(a,b,c,d,e){var f=b.has("cfpLoadingBar")?b.get("cfpLoadingBar"):null,g={};return g.images=[],g.index=-1,g.templateUrl=this.templateUrl,g.getImageUrl=this.getImageUrl,g.getImageCaption=this.getImageCaption,g.calculateImageDimensionLimits=this.calculateImageDimensionLimits,g.calculateModalDimensions=this.calculateModalDimensions,g.keyboardNavEnabled=!1,g.image={},g.modalInstance=null,g.openModal=function(a,b){return g.images=a,g.setImage(b),g.modalInstance=c.open({templateUrl:g.templateUrl,controller:["$scope",function(a){a.Lightbox=g,g.keyboardNavEnabled=!0}],windowClass:"lightbox-modal"}),g.modalInstance.result["finally"](function(){g.images=[],g.index=1,g.image={},g.imageUrl=null,g.imageCaption=null,g.keyboardNavEnabled=!1,f&&f.complete()}),g.modalInstance},g.closeModal=function(a){return g.modalInstance.close(a)},g.setImage=function(a){if(!(a in g.images))throw"Invalid image.";f&&f.start();var b=function(){g.index=a,g.image=g.images[g.index],f&&f.complete()},c=g.getImageUrl(g.images[a]);e.load(c).then(function(){b(),g.imageUrl=c,g.imageCaption=g.getImageCaption(g.image)},function(){b(),g.imageUrl="//:0",g.imageCaption="Failed to load image"})},g.firstImage=function(){g.setImage(0)},g.prevImage=function(){g.setImage((g.index-1+g.images.length)%g.images.length)},g.nextImage=function(){g.setImage((g.index+1)%g.images.length)},g.lastImage=function(){g.setImage(g.images.length-1)},g.setImages=function(a){g.images=a,g.setImage(g.index)},a.bind("keydown",function(a){if(g.keyboardNavEnabled){var b=null;switch(a.which){case 39:b="nextImage";break;case 37:b="prevImage"}null!==b&&-1===["input","textarea"].indexOf(a.target.tagName.toLowerCase())&&(d(function(){g[b]()}),a.preventDefault())}}),g}]}),angular.module("bootstrapLightbox").directive("lightboxSrc",["$window","ImageLoader","Lightbox",function(a,b,c){var d=function(a){var b=a.width,c=a.height,d=a.minWidth,e=a.minHeight,f=a.maxWidth,g=a.maxHeight,h=b,i=c;return d>b&&e>c?b/c>f/g?(i=e,h=Math.round(b*e/c)):(h=d,i=Math.round(c*d/b)):d>b?(h=d,i=Math.round(c*d/b)):e>c&&(i=e,h=Math.round(b*e/c)),b>f&&c>g?b/c>f/g?(h=f,i=Math.round(c*f/b)):(i=g,h=Math.round(b*g/c)):b>f?(h=f,i=Math.round(c*f/b)):c>g&&(i=g,h=Math.round(b*g/c)),{width:h||0,height:i||0}},e=0,f=0;return{link:function(g,h,i){var j=function(){var b=a.innerWidth,g=a.innerHeight,i=c.calculateImageDimensionLimits({windowWidth:b,windowHeight:g,imageWidth:e,imageHeight:f}),j=d(angular.extend({width:e,height:f,minWidth:1,minHeight:1,maxWidth:3e3,maxHeight:3e3},i)),k=c.calculateModalDimensions({windowWidth:b,windowHeight:g,imageDisplayWidth:j.width,imageDisplayHeight:j.height});h.css({width:j.width+"px",height:j.height+"px"}),angular.element(document.querySelector(".lightbox-modal .modal-dialog")).css({width:k.width+"px"}),angular.element(document.querySelector(".lightbox-modal .modal-content")).css({height:k.height+"px"})};g.$watch(function(){return i.lightboxSrc},function(a){h[0].src="//:0",b.load(a).then(function(b){e=b.naturalWidth,f=b.naturalHeight,j(),h[0].src=a})}),angular.element(a).on("resize",j)}}}]);