!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:'<div class="ng-image-gallery img-move-dir-{{_imgMoveDirection}}" ng-class="{inline:inline}" ng-hide="images.length == 0"><div ng-if="thumbnails && !inline" class="ng-image-gallery-thumbnails"><div class="thumb" ng-repeat="image in images track by image.id" ng-click="methods.open($index);" show-image-async="{{image.thumbUrl || image.url}}" async-kind="thumb" ng-style="{\'width\' : thumbSize+\'px\', \'height\' : thumbSize+\'px\'}"><div class="loader"></div></div></div><div class="ng-image-gallery-modal" ng-if="opened" ng-cloak><div class="ng-image-gallery-backdrop" ng-if="!inline"></div><div class="ng-image-gallery-content" ng-show="!imgLoading" ng-click="backgroundClose($event);"><div class="actions-icons-container"><div class="delete-img" ng-repeat="image in images track by image.id" ng-if="_activeImg == image && image.deletable" title="Delete this image..." ng-click="_deleteImg(image)"></div></div><div class="control-icons-container"><a class="ext-url" ng-repeat="image in images track by image.id" ng-if="_activeImg == image && image.extUrl" href="{{image.extUrl}}" target="_blank" title="Open image in new tab..."></a><div class="close" ng-click="methods.close();" ng-if="!inline"></div></div><div class="prev" ng-click="methods.prev();" ng-class="{\'bubbles-on\':bubbles}" ng-hide="images.length == 1"></div><div class="next" ng-click="methods.next();" ng-class="{\'bubbles-on\':bubbles}" ng-hide="images.length == 1"></div><div class="galleria"><div class="galleria-images img-anim-{{imgAnim}} img-move-dir-{{_imgMoveDirection}}"><img class="galleria-image" ng-right-click ng-repeat="image in images track by image.id" ng-if="_activeImg == image" ng-src="{{image.url}}" ondragstart="return false;" ng-attr-alt="{{image.alt || undefined}}"/></div><div class="galleria-title-description-wrapper"><div ng-repeat="image in images track by image.id" ng-if="(image.title || image.desc) && (_activeImg == image)"><div class="title" ng-if="image.title" ng-bind-html="image.title | ngImageGalleryTrust"></div><div class="desc" ng-if="image.desc" ng-bind-html="image.desc | ngImageGalleryTrust"></div></div></div><div class="galleria-bubbles-wrapper" ng-if="bubbles && !imgBubbles" ng-hide="images.length == 1" ng-style="{\'height\' : bubbleSize+\'px\'}" bubble-auto-fit><div class="galleria-bubbles" bubble-auto-scroll ng-style="{\'margin-left\': _bubblesContainerMarginLeft}"><span class="galleria-bubble" ng-click="_setActiveImg(image);" ng-repeat="image in images track by image.id" ng-class="{active : (_activeImg == image)}" ng-style="{\'width\' : bubbleSize+\'px\', \'height\' : bubbleSize+\'px\', margin: _bubbleMargin}"></span></div></div><div class="galleria-bubbles-wrapper" ng-if="bubbles && imgBubbles" ng-hide="images.length == 1" ng-style="{\'height\' : bubbleSize+\'px\'}" bubble-auto-fit><div class="galleria-bubbles" bubble-auto-scroll ng-style="{\'margin-left\': _bubblesContainerMarginLeft}"><span class="galleria-bubble img-bubble" ng-click="_setActiveImg(image);" ng-repeat="image in images track by image.id" ng-class="{active : (_activeImg == image)}" show-image-async="{{image.bubbleUrl || image.thumbUrl || image.url}}" async-kind="bubble" ng-style="{\'width\' : bubbleSize+\'px\', \'height\' : bubbleSize+\'px\', \'border-width\' : bubbleSize/10+\'px\', margin: _bubbleMargin}"></span></div></div></div></div><div class="ng-image-gallery-loader" ng-show="imgLoading"><div class="spinner"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div></div><div class="ng-image-gallery-errorplaceholder" ng-show="imgError"><div class="ng-image-gallery-error-placeholder" ng-bind-html="errorPlaceHolder | ngImageGalleryTrust"></div></div></div></div>',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<e.target.classList.length&&i.indexOf(e.target.classList[n])==-1;n++)l.methods.close()},angular.element(document).bind("keyup",function(i){l.inline||(i.which==e.right||i.which==e.enter?n(function(){l.methods.next()}):i.which==e.left?n(function(){l.methods.prev()}):i.which==e.esc&&n(function(){l.methods.close()}))}),window.Hammer){var c=new Hammer(g[0]);c.on("swiperight",function(e){n(function(){l.methods.prev()})}),c.on("swipeleft",function(e){n(function(){l.methods.next()})}),c.on("doubletap",function(e){l.inline||n(function(){l.methods.close()})})}var b=function(){angular.element(document.body).removeClass("body-overflow-hidden")};i.$on("$stateChangeSuccess",b),i.$on("$routeChangeSuccess",b)}}}}])}();
|