// LiteBox v1.2, Copyright 2014, Joe Mottershaw, https://github.com/joemottershaw/ // =============================================================================== !function(e,t){function o(t,o){this.element=t,this.$element=e(this.element),this.options=e.extend({},a,o),this._defaults=a,this._name=l,this.init()}function i(){return t.innerHeight?t.innerHeight:e(t).height()}function n(t){e(t).each(function(){var t=new Image;t.src=this,t.width>0&&e("").attr("src",this).addClass("litebox-preload").appendTo("body").hide()})}var l="liteBox",a={revealSpeed:400,background:"rgba(0,0,0,.8)",overlayClose:!0,escKey:!0,navKey:!0,closeTip:"tip-l-fade",closeTipText:"Close",prevTip:"tip-t-fade",prevTipText:"Previous",nextTip:"tip-t-fade",nextTipText:"Next",callbackInit:function(){},callbackBeforeOpen:function(){},callbackAfterOpen:function(){},callbackBeforeClose:function(){},callbackAfterClose:function(){},callbackError:function(){},callbackPrev:function(){},callbackNext:function(){},errorMessage:"Error loading content."};o.prototype={init:function(){var t=this;this.$element.on("click",function(e){e.preventDefault(),t.openLitebox()}),keyEsc=27,keyLeft=37,keyRight=39,e("body").off("keyup").on("keyup",function(o){t.options.escKey&&o.keyCode==keyEsc&&t.closeLitebox(),t.options.navKey&&o.keyCode==keyLeft&&e(".litebox-prev").trigger("click"),t.options.navKey&&o.keyCode==keyRight&&e(".litebox-next").trigger("click")}),this.options.callbackInit.call(this)},openLitebox:function(){var t=this;this.options.callbackBeforeOpen.call(this),t.buildLitebox();var o=this.$element;if(t.populateLitebox(o),t.options.overlayClose&&$litebox.on("click",function(o){(o.target===this||e(o.target).hasClass("litebox-container")||e(o.target).hasClass("litebox-error"))&&t.closeLitebox()}),$close.on("click",function(){t.closeLitebox()}),this.$element.attr("data-litebox-group")){var t=this,i=this.$element.attr("data-litebox-group"),l=e('[data-litebox-group="'+this.$element.attr("data-litebox-group")+'"]'),a=[];e('[data-litebox-group="'+i+'"]').each(function(){var t=e(this).attr("href");a.push(t)}),n(a),e(".litebox-nav").show(),$prevNav.off("click").on("click",function(){t.options.callbackPrev.call(this);var i=l.index(o);o=l.eq(i-1),e(o).length||(o=l.last()),t.populateLitebox(o)}),$nextNav.off("click").on("click",function(){t.options.callbackNext.call(this);var i=l.index(o);o=l.eq(i+1),e(o).length||(o=l.first()),t.populateLitebox(o)})}this.options.callbackAfterOpen.call(this)},buildLitebox:function(){$litebox=e("
",{"class":"litebox-overlay"}),$close=e("
",{"class":"litebox-close "+this.options.closeTip,"data-tooltip":this.options.closeTipText}),$error=e('
'+this.options.errorMessage+"
"),$prevNav=e("
",{"class":"litebox-nav litebox-prev "+this.options.prevTip,"data-tooltip":this.options.prevTipText}),$nextNav=e("
",{"class":"litebox-nav litebox-next "+this.options.nextTip,"data-tooltip":this.options.nextTipText}),$container=e("
",{"class":"litebox-container"}),$loader=e("
",{"class":"litebox-loader"}),e("body").prepend($litebox.css({"background-color":this.options.background})),$litebox.append($close,$prevNav,$nextNav,$container),$litebox.fadeIn(this.options.revealSpeed)},populateLitebox:function(t){var o=this,i=t.attr("href"),n=e(".litebox-content");if($litebox.append($loader),null!==i.match(/\.(jpeg|jpg|gif|png|bmp)/i)){var l=e("",{src:i,"class":"litebox-content"});o.transitionContent("image",n,l),e("img.litebox-content").imagesLoaded(function(){$loader.remove()}),l.error(function(){o.liteboxError(),$loader.remove()})}else if(videoURL=i.match(/(youtube|youtu|vimeo|dailymotion|kickstarter)\.(com|be)\/((watch\?v=([-\w]+))|(video\/([-\w]+))|(projects\/([-\w]+)\/([-\w]+))|([-\w]+))/)){var a="",r="?autoplay=1";if("youtube"==videoURL[1]&&(a="http://www.youtube.com/v/"+videoURL[5]+r),"youtu"==videoURL[1]&&(a="http://www.youtube.com/v/"+videoURL[3]+r),"vimeo"==videoURL[1]&&(a="http://player.vimeo.com/video/"+videoURL[3]+r),"dailymotion"==videoURL[1]&&(a="https://www.dailymotion.com/embed/video/"+videoURL[7]+r),"kickstarter"==videoURL[1]&&(a="https://www.kickstarter.com/projects/"+videoURL[9]+"/"+videoURL[10]+"/widget/video.html"),a){var c=e("