/* # ----------------------------------------------------------------------------- # ~/theme_uno/modules/lightbox/js/lightbox.min.js # Lightbox v.2.11.2 implementation for J1 Template. # # Product/Info: # https://jekyll.one # http://lokeshdhakar.com/projects/lightbox2/ # # Copyright (C) 2021 Juergen Adams # Copyright (C) 2015 Lokesh Dhakar # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE # Lightbox is licensed under the MIT License. # See: https://github.com/lokesh/lightbox2/blob/master/LICENSE # ----------------------------------------------------------------------------- */ (function(a,b){if(typeof define==="function"&&define.amd){define(["jquery"],b)}else{if(typeof exports==="object"){module.exports=b(require("jquery"))}else{a.lightbox=b(a.jQuery)}}}(this,function(a){function b(c){this.album=[];this.currentImageIndex=void 0;this.init();this.options=a.extend({},this.constructor.defaults);this.option(c)}b.defaults={albumLabel:"Image %1 of %2",alwaysShowNavOnTouchDevices:false,fadeDuration:600,fitImagesInViewport:true,imageFadeDuration:600,positionFromTop:50,resizeDuration:700,showImageNumberLabel:true,wrapAround:false,disableScrolling:false,sanitizeTitle:false};b.prototype.option=function(c){a.extend(this.options,c)};b.prototype.imageCountLabel=function(d,c){return this.options.albumLabel.replace(/%1/g,d).replace(/%2/g,c)};b.prototype.init=function(){var c=this;a(document).ready(function(){c.enable();c.build()})};b.prototype.enable=function(){var c=this;a("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(d){c.start(a(d.currentTarget));return false})};b.prototype.build=function(){if(a("#lightbox").length>0){return}var c=this;a('
').appendTo(a("body"));this.$lightbox=a("#lightbox");this.$overlay=a("#lightboxOverlay");this.$outerContainer=this.$lightbox.find(".lb-outerContainer");this.$container=this.$lightbox.find(".lb-container");this.$image=this.$lightbox.find(".lb-image");this.$nav=this.$lightbox.find(".lb-nav");this.containerPadding={top:parseInt(this.$container.css("padding-top"),10),right:parseInt(this.$container.css("padding-right"),10),bottom:parseInt(this.$container.css("padding-bottom"),10),left:parseInt(this.$container.css("padding-left"),10)};this.imageBorderWidth={top:parseInt(this.$image.css("border-top-width"),10),right:parseInt(this.$image.css("border-right-width"),10),bottom:parseInt(this.$image.css("border-bottom-width"),10),left:parseInt(this.$image.css("border-left-width"),10)};this.$overlay.hide().on("click",function(){c.end();return false});this.$lightbox.hide().on("click",function(d){if(a(d.target).attr("id")==="lightbox"){c.end()}});this.$outerContainer.on("click",function(d){if(a(d.target).attr("id")==="lightbox"){c.end()}return false});this.$lightbox.find(".lb-prev").on("click",function(){if(c.currentImageIndex===0){c.changeImage(c.album.length-1)}else{c.changeImage(c.currentImageIndex-1)}return false});this.$lightbox.find(".lb-next").on("click",function(){if(c.currentImageIndex===c.album.length-1){c.changeImage(0)}else{c.changeImage(c.currentImageIndex+1)}return false});this.$nav.on("mousedown",function(d){if(d.which===3){c.$nav.css("pointer-events","none");c.$lightbox.one("contextmenu",function(){setTimeout(function(){this.$nav.css("pointer-events","auto")}.bind(c),0)})}});this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){c.end();return false})};b.prototype.start=function(g){var o=this;var c=a(window);c.on("resize",a.proxy(this.sizeOverlay,this));this.sizeOverlay();this.album=[];var n=0;function l(i){o.album.push({alt:i.attr("data-alt"),link:i.attr("href"),title:i.attr("data-title")||i.attr("title")})}var k=g.attr("data-lightbox");var m;if(k){m=a(g.prop("tagName")+'[data-lightbox="'+k+'"]');for(var f=0;fi)||(c.height>o)){if((c.width/i)>(c.height/o)){k=i;j=parseInt(c.height/(c.width/k),10);g.width(k);g.height(j)}else{j=o;k=parseInt(c.width/(c.height/j),10);g.width(k);g.height(j)}}e.sizeContainer(g.width(),g.height())};c.src=this.album[h].link;this.currentImageIndex=h};b.prototype.sizeOverlay=function(){var c=this;setTimeout(function(){c.$overlay.width(a(document).width()).height(a(document).height())},0)};b.prototype.sizeContainer=function(g,c){var f=this;var e=this.$outerContainer.outerWidth();var j=this.$outerContainer.outerHeight();var i=g+this.containerPadding.left+this.containerPadding.right+this.imageBorderWidth.left+this.imageBorderWidth.right;var d=c+this.containerPadding.top+this.containerPadding.bottom+this.imageBorderWidth.top+this.imageBorderWidth.bottom;function h(){f.$lightbox.find(".lb-dataContainer").width(i);f.$lightbox.find(".lb-prevLink").height(d);f.$lightbox.find(".lb-nextLink").height(d);f.$overlay.focus();f.showImage()}if(e!==i||j!==d){this.$outerContainer.animate({width:i,height:d},this.options.resizeDuration,"swing",function(){h()})}else{h()}};b.prototype.showImage=function(){this.$lightbox.find(".lb-loader").stop(true).hide();this.$lightbox.find(".lb-image").fadeIn(this.options.imageFadeDuration);this.updateNav();this.updateDetails();this.preloadNeighboringImages();this.enableKeyboardNav()};b.prototype.updateNav=function(){var c=false;try{document.createEvent("TouchEvent");c=(this.options.alwaysShowNavOnTouchDevices)?true:false}catch(d){}this.$lightbox.find(".lb-nav").show();if(this.album.length>1){if(this.options.wrapAround){if(c){this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1")}this.$lightbox.find(".lb-prev, .lb-next").show()}else{if(this.currentImageIndex>0){this.$lightbox.find(".lb-prev").show();if(c){this.$lightbox.find(".lb-prev").css("opacity","1")}}if(this.currentImageIndex1&&this.options.showImageNumberLabel){var d=this.imageCountLabel(this.currentImageIndex+1,this.album.length);this.$lightbox.find(".lb-number").text(d).fadeIn("fast")}else{this.$lightbox.find(".lb-number").hide()}this.$outerContainer.removeClass("animating");this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return c.sizeOverlay()})};b.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var d=new Image();d.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var c=new Image();c.src=this.album[this.currentImageIndex-1].link}};b.prototype.enableKeyboardNav=function(){this.$lightbox.on("keyup.keyboard",a.proxy(this.keyboardAction,this));this.$overlay.on("keyup.keyboard",a.proxy(this.keyboardAction,this))};b.prototype.disableKeyboardNav=function(){this.$lightbox.off(".keyboard");this.$overlay.off(".keyboard")};b.prototype.keyboardAction=function(e){var g=27;var f=37;var d=39;var c=e.keyCode;if(c===g){e.stopPropagation();this.end()}else{if(c===f){if(this.currentImageIndex!==0){this.changeImage(this.currentImageIndex-1)}else{if(this.options.wrapAround&&this.album.length>1){this.changeImage(this.album.length-1)}}}else{if(c===d){if(this.currentImageIndex!==this.album.length-1){this.changeImage(this.currentImageIndex+1)}else{if(this.options.wrapAround&&this.album.length>1){this.changeImage(0)}}}}}};b.prototype.end=function(){this.disableKeyboardNav();a(window).off("resize",this.sizeOverlay);this.$lightbox.fadeOut(this.options.fadeDuration);this.$overlay.fadeOut(this.options.fadeDuration);if(this.options.disableScrolling){a("body").removeClass("lb-disable-scrolling")}};return new b()}));