!function(){"use strict";var e={enter:13,esc:27,left:37,right:39};angular.module("thatisuday.ng-image-gallery",["ngAnimate"]).provider("ngImageGalleryOpts",function(){var e={thumbnails:!0,thumbSize:80,inline:!1,bubbles:!0,bubbleSize:20,imgBubbles:!1,bgClose:!1,piracy:!1,imgAnim:"fadeup",errorPlaceHolder:"Error when loading the image!"};return{setOpts:function(i){angular.extend(e,i)},$get:function(){return e}}}).filter("ngImageGalleryTrust",["$sce",function(e){return function(i,n){return e.trustAs(n||"html",i)}}]).directive("ngRightClick",["$parse",function(e){return{restrict:"A",scope:!1,link:function(e,i,n){i.bind("contextmenu",function(i){if(0==e.piracy)return i.preventDefault(),e.piracy})}}}]).directive("showImageAsync",[function(){return{restrict:"A",scope:!1,link:function(e,i,n){var a=new Image;a.src=n.showImageAsync,a.onload=function(){e.$apply(function(){"thumb"==n.asyncKind?(i.css({backgroundImage:'url("'+n.showImageAsync+'")'}),i.empty()):"bubble"==n.asyncKind&&i.css({backgroundImage:'url("'+n.showImageAsync+'")'})})},a.onerror=function(){i.empty()}}}}]).directive("bubbleAutoFit",["$window","$timeout",function(e,i){return{restrict:"A",scope:!1,link:{pre:function(n,a,t){var l=function(){var e=a[0].getBoundingClientRect().width;if(0!=e){var i=n.bubbleSize,t=8,l=i+t,g=e/l,o=Math.floor(g),s=e-o*l,r=s/o,c=t+r,b=c+i;n._bubblesInView=o,n._finalBubbleSpace=b,n._bubbleMargin="0 "+c/2+"px",n._safeApply(angular.noop)}};i(l),angular.element(e).bind("resize",function(){i(l)}),n.$watch("inline",function(){i(l)}),n.$watch("bubbleSize",function(){i(l)}),n.$watchCollection("images",function(){i(l)})}}}}]).directive("bubbleAutoScroll",["$window","$timeout",function(e,i){return{restrict:"A",scope:!1,link:function(n,a,t){var l=function(){var e=n._bubblesInView-(n._bubblesInView-n._activeImageIndex);i(function(){if(e>n._bubblesInView-2){var i=n._activeImageIndex+1-n._bubblesInView+1;n._activeImageIndex!=n.images.length-1?n._bubblesContainerMarginLeft="-"+n._finalBubbleSpace*i+"px":n._bubblesContainerMarginLeft="-"+n._finalBubbleSpace*(i-1)+"px"}else n._bubblesContainerMarginLeft="0px"})};angular.element(e).bind("resize",function(){i(l)}),n.$watch("_bubblesInView",function(){i(l)}),n.$watch("_activeImageIndex",function(){i(l)}),n.$watchCollection("images",function(){i(l)})}}}]).directive("ngImageGallery",["$rootScope","$timeout","$q","ngImageGalleryOpts",function(i,n,a,t){return{replace:!0,transclude:!1,restrict:"AE",scope:{images:"=",methods:"=?",conf:"=?",thumbnails:"=?",thumbSize:"=?",inline:"=?",bubbles:"=?",bubbleSize:"=?",imgBubbles:"=?",bgClose:"=?",piracy:"=?",imgAnim:"@?",errorPlaceHolder:"@?",onOpen:"&?",onClose:"&?",onDelete:"&?"},template:'
',link:{pre:function(l,g,o){l._showLoader=function(){l.imgLoading=!0},l._hideLoader=function(){l.imgLoading=!1},l._loadImg=function(e){if(!e)return a.reject();var i=a.defer();e.hasOwnProperty("cached")||l._showLoader();var n=new Image;return n.src=e.url,n.onload=function(){e.hasOwnProperty("cached")||l._hideLoader(),e.hasOwnProperty("cached")||(e.cached=!0),i.resolve(e)},n.onerror=function(){e.hasOwnProperty("cached")||l._hideLoader(),i.reject("Error when loading img")},i.promise},l._setActiveImg=function(e){l.images.indexOf(l._activeImg)-l.images.indexOf(e)==l.images.length-1||l.images.indexOf(l._activeImg)-l.images.indexOf(e)<=0&&l.images.indexOf(l._activeImg)-l.images.indexOf(e)!=-(l.images.length-1)?l._imgMoveDirection="forward":l._imgMoveDirection="backward",l._loadImg(e).then(function(e){l._activeImg=e,l._activeImageIndex=l.images.indexOf(e),l.imgError=!1},function(){l._activeImg=null,l._activeImageIndex=l.images.indexOf(e),l.imgError=!0})},l._safeApply=function(e){var i=this.$root.$$phase;"$apply"==i||"$digest"==i?e&&"function"==typeof e&&e():this.$apply(e)},l._deleteImg=function(e){var i=function(){var i=l.images.indexOf(e);console.log(i),l.images.splice(i,1),l._activeImageIndex=0};l.onDelete({img:e,cb:i})},l.images=void 0!=l.images?l.images:[],l.methods=void 0!=l.methods?l.methods:{},l.conf=void 0!=l.conf?l.conf:{},l.$watchCollection("conf",function(e){l.thumbnails=void 0!=e.thumbnails?e.thumbnails:void 0!=l.thumbnails?l.thumbnails:t.thumbnails,l.thumbSize=void 0!=e.thumbSize?e.thumbSize:void 0!=l.thumbSize?l.thumbSize:t.thumbSize,l.inline=void 0!=e.inline?e.inline:void 0!=l.inline?l.inline:t.inline,l.bubbles=void 0!=e.bubbles?e.bubbles:void 0!=l.bubbles?l.bubbles:t.bubbles,l.bubbleSize=void 0!=e.bubbleSize?e.bubbleSize:void 0!=l.bubbleSize?l.bubbleSize:t.bubbleSize,l.imgBubbles=void 0!=e.imgBubbles?e.imgBubbles:void 0!=l.imgBubbles?l.imgBubbles:t.imgBubbles,l.bgClose=void 0!=e.bgClose?e.bgClose:void 0!=l.bgClose?l.bgClose:t.bgClose,l.piracy=void 0!=e.piracy?e.piracy:void 0!=l.piracy?l.piracy:t.piracy,l.imgAnim=void 0!=e.imgAnim?e.imgAnim:void 0!=l.imgAnim?l.imgAnim:t.imgAnim,l.errorPlaceHolder=void 0!=e.errorPlaceHolder?e.errorPlaceHolder:void 0!=l.errorPlaceHolder?l.errorPlaceHolder:t.errorPlaceHolder}),l.onOpen=void 0!=l.onOpen?l.onOpen:angular.noop,l.onClose=void 0!=l.onClose?l.onClose:angular.noop,l.onDelete=void 0!=l.onDelete?l.onDelete:angular.noop;var s=!0;l.$watchCollection("images",function(){s?s=!1:l.images.length&&l._setActiveImg(l.images[l._activeImageIndex||0])});var r=!0;if(l.$watch("_activeImageIndex",function(e){r?r=!1:l.images.length&&l._setActiveImg(l.images[e])}),l.$watch("inline",function(){n(function(){l.inline&&l.methods.open()})}),l.methods.open=function(e){l._activeImageIndex=e?e:0,l.opened=!0,l.inline||angular.element(document.body).addClass("body-overflow-hidden"),n(function(){l.onOpen()},300)},l.methods.close=function(){l.opened=!1,angular.element(document.body).removeClass("body-overflow-hidden"),n(function(){l.onClose(),l._activeImageIndex=0},300)},l.methods.next=function(){l._activeImageIndex==l.images.length-1?l._activeImageIndex=0:l._activeImageIndex=l._activeImageIndex+1},l.methods.prev=function(){0==l._activeImageIndex?l._activeImageIndex=l.images.length-1:l._activeImageIndex--},l.backgroundClose=function(e){if(l.bgClose&&!l.inline)for(var i=["galleria-image","destroy-icons-container","ext-url","close","next","prev","galleria-bubble"],n=0;n