/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.5.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2019 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["gallery_slideshow","no_photos_found_or_post_deleted"]);(function(E){window.vBulletin=window.vBulletin||{};vBulletin.gallery=vBulletin.gallery||{};var K=5,N=E("#slideshow-dialog"),D=false,R=false,P=0,I={},B="fast",G="swing";function C(U,V,Y,T){var a=U.find(".caption"),X;a.html("").hide();if(V.links){a.append(E("<div />").addClass("links ellipsis").html(V.links))}if(V.title){a.append(E("<div />").addClass("title ellipsis").html(V.title))}if(V.links&&V.title){X=15}else{if(V.links||V.title){X=35}else{X=50}}var W=U.find(".slideshow-wrapper .jcarousel-item-"+Y+" img");var Z=W.outerWidth();a.css({marginBottom:X+"px",width:"100%",textAlign:"center",marginLeft:"auto",marginRight:"auto"});W.one("load",function(){var b=E(this).outerWidth();a.css("width",b+"px")});if(T){a.fadeIn("fast",function(){U.click()})}else{a.show()}}function L(U){var T=vBulletin.isRtl();if(U.which==37){vBulletin.gallery.slideshow.jcarousel(T?"next":"prev")}else{if(U.which==39){vBulletin.gallery.slideshow.jcarousel(T?"prev":"next")}}if(U.which>=33&&U.which<=40){return false}}function M(T){var U=T.originalEvent.wheelDelta||-T.originalEvent.detail;if(U>0){vBulletin.gallery.slideshow.jcarousel("prev")}else{vBulletin.gallery.slideshow.jcarousel("next")}return false}function A(U){if(U){var T=vBulletin.isRtl(),W=0,V=false,Z=false;function Y(b,c){var g=E(".slideshow-wrapper .jcarousel-list"),n=T?"right":"left",o=parseInt(g.css(n),10);if(b==="restore"){var m=o+(W*-1);if(c){var q={};q[n]=m;g.animate(q,B,G)}else{g.css(n,m)}W=0;V=false}else{if(b==="prev"||b==="next"){var p=parseInt(g.css("width"),10),l=g.find(".jcarousel-item"),a=l.length,e=l.first(),k=parseInt(e.css("width"),10),j=(a-1)*k,h=Math.abs(V),f,i,d;f=(b==="prev")?(h-k):(h+k);i=(f>=0&&f<=j);d=(!f?0:(f/k))+1;f=(f*-1);if(i){var q={};q[n]=f;g.animate(q,B,G,function(){W=0;if(V!==false){g.css("visibility","hidden");g.css(n,V);V=false;vBulletin.gallery.slideshow.jcarousel("scroll",d,false);g.css("visibility","visible")}});if(V!==false){return true}}}else{if(T){b=b*-1}g.css(n,o+b);W+=b;if(V===false){V=o}}}}function X(b){Z=true;var a=Y(b,true);if(!a){Y("restore",true)}}E(document).swipeable({swipeleft:function(b,a){X(T?"prev":"next")},swiperight:function(b,a){X(T?"next":"prev")},swiping:function(b,a){Y(a.moved.x)},swipeend:function(b,a){if(W&&!Z){Y("restore",true)}if(Z){Z=false}},})}else{E(document).swipeable("disable")}}function J(){var j=E(this);R=this;if(j.closest("#preview-overlay").length==1){return false}var X=j.attr("data-channelid"),f=j.closest(".photoPreviewBox"),k=j.attr("src");if(typeof (k)==="undefined"){k=j.attr("href")}if(D===false){D=(f.length>0)?f.index():j.index()}E(document).off("click","#slideshow-dialog .close-btn").on("click","#slideshow-dialog .close-btn",function(){N.dialog("close")});E(document).off("click",".thumbnails .image-wrapper").on("click",".thumbnails .image-wrapper",function(q,p){if(typeof p=="undefined"){p=true}E(".thumbnails .image-wrapper",N).addClass("dimmed");E(this).removeClass("dimmed");var o=Number(E(this).parent().attr("jcarouselindex"));N.data("thumbclick",true);vBulletin.gallery.slideshow.jcarousel("scroll",o,p);N.removeData("thumbclick")});E("body").css("overflow","hidden");var n=E(window).innerWidth(),a=E(window).innerHeight(),h=false;var U=h?20:0,l=10,g=parseInt(n-(U*2),10),V=parseInt(a-(U*2),10);if(!h){N.css({borderRadius:0,borderWidth:0})}else{N.css({borderRadius:"",borderWidth:""})}var Z=parseInt(g-(l*2),10),i=parseInt(V-(l*2),10),W=60,Y=90,e=50,m=Z-10,c=parseInt(i-W-e-(l*3),10),d=parseInt(((c/2)-21),10);P=m;K=Math.max(1,Math.floor(P/Y));N.dialog({autoOpen:false,resizable:false,closeOnEscape:true,showTitleBar:false,modal:true,width:g,height:V,dialogClass:"slideshow-dialog",open:function(){E(".ui-widget-overlay").bind("click",function(){N.dialog("close")});E(document).off("keydown",L).on("keydown",L);E(document).off("mousewheel DOMMouseScroll",M).on("mousewheel DOMMouseScroll",M);A(true)},close:function(p,o){if(vBulletin.gallery.thumbnails){vBulletin.gallery.thumbnails.jcarousel("destroy")}if(vBulletin.gallery.slideshow){vBulletin.gallery.slideshow.jcarousel("destroy")}E("body").css("overflow","auto");E(document).off("keydown",L);E(document).off("mousewheel DOMMouseScroll",M);A(false);R=false;D=false}});var T=N.find(".slideshow-wrapper .slideshow-list");if(T.length==0){T=N.find(".slideshow-wrapper").append(E("<ul />").addClass("slideshow-list"))}N.dialog("open");window.vBulletin.loadingIndicator.show();var b=j.closest(".js-slideshow__gallery-node").attr("data-node-id")||j.closest(".js-slideshow__gallery-node").attr("data-nodeid")||j.closest(".js-post-sm").attr("data-nodeid");E('<style type="text/css">			.slideshow .slideshow-wrapper > .jcarousel-clip-horizontal {				width: '+m+"px;				height: "+c+"px;			}			.slideshow .thumbnails > .jcarousel-clip-horizontal {				width: "+P+"px;			}			.slideshow .slideshow-wrapper > .jcarousel-clip .jcarousel-item {				width: "+m+"px;				height: "+c+"px;			}			.slideshow .jcarousel-item .image {				max-width: "+m+"px;				max-height: "+c+"px;			}			.slideshow .slideshow-wrapper > .jcarousel-prev-horizontal,			.slideshow .slideshow-wrapper > .jcarousel-next-horizontal {				top: "+d+"px;			}		</style>").appendTo("head");vBulletin.gallery.slideshow=T.jcarousel({wrap:null,animation:B,easing:G,scroll:1,rtl:vBulletin.isRtl(),initCallback:function(x,r){if(r=="init"){var p=j.closest(".b-content-entry-panel__content--gallery").find(".js-photo-postdata input");if(p.length>0){var o={photos:[]};p.filter('[name="filedataid[]"]').each(function(){var y={title:JShtmlEncode(p.filter('[name="title_'+this.value+'"]').val()),url:pageData.baseurl+"/filedata/fetch?filedataid="+this.value,thumb:pageData.baseurl+"/filedata/fetch?thumb=1&filedataid="+this.value};o.photos.push(y)});setTimeout(function(){S(o,x)},10)}else{var t={nodeid:b};if(vBulletin.media&&vBulletin.media.MEDIA_USERID){t.userid=vBulletin.media.MEDIA_USERID}if(X){t.channelid=X}var q=parseInt(E(".albumSlideShowPageNo").val());if(!isNaN(q)){t.pageno=q}var u=parseInt(E(".albumSlideShowPerPage").val());if(!isNaN(u)){t.perpage=u}var s=E(".media-tab .media-filter-overlay .filter-options input:checked").val();if(s){t.dateFilter=s}if(!isNaN(D)){t.startIndex=D}var w=t;if(b>0){w.startIndex=""}var v=JSON.stringify(w);if(I[v]){S(I[v],x)}else{E.post(vBulletin.getAjaxBaseurl()+"/filedata/gallery",t,function(y){if(!y&&k){y={photos:[{title:"",url:k,thumb:""}]}}I[v]=y;S(y,x)},"json").complete(function(){window.vBulletin.loadingIndicator.hide()})}}}},itemVisibleInCallback:{onBeforeAnimation:function(t,r,q,s){if(s=="init"){return false}var v=N.data("image-data");if(v){var o=v.photos.length;if(q>0){while(q>o){q-=o}}else{while(q<=0){q+=o}}C(N,v.photos[q-1],q,true);var u=Math.floor(K/2);var p=q-u;p=Math.max(p,1);vBulletin.gallery.thumbnails.jcarousel("scroll",p,true);if(!N.data("thumbclick")){E("#slideshow-dialog .thumbnails .image-wrapper").addClass("dimmed");vBulletin.gallery.thumbnails.jcarousel("get",q).find(".image-wrapper").removeClass("dimmed")}D=q-1}}}});return false}function S(a,Z){if(!a||!a.photos){openAlertDialog({title:vBulletin.phrase.get("gallery_slideshow"),message:vBulletin.phrase.get("no_photos_found_or_post_deleted"),iconType:"warning"});return }N.data("image-data",a);Q(Z,a,N);N.find(".slideshow-wrapper").find(".jcarousel-prev-horizontal").addClass("b-icon b-icon__arrow-block-left").end().find(".jcarousel-next-horizontal").addClass("b-icon b-icon__arrow-block-right");var V=N.find(".thumbnails"),U=V.find(".jcarousel-prev-horizontal"),T=V.find(".jcarousel-next-horizontal");U.addClass("b-icon b-icon__arrow-bar-left").toggleClass("b-icon--disabled",U.is(".jcarousel-prev-disabled"));T.addClass("b-icon b-icon__arrow-bar-right").toggleClass("b-icon--disabled",T.is(".jcarousel-next-disabled"));C(N,a.photos[0],1);if(a.photos.length>1){vBulletin.gallery.thumbnails.jcarousel("get",1).find(".image-wrapper").removeClass("dimmed")}var X=D;var W=parseInt(E(".albumSlideShowPerPage").val());if(!isNaN(W)){X=D%W}if(X>0){var Y=vBulletin.gallery.slideshow.jcarousel("scroll",X+1,false);if(typeof Y!="undefined"){N.find(".slideshow-wrapper").css("visibility","hidden");window.setTimeout(function(){E(".thumbnails .image-wrapper",N).eq(X).trigger("click",[false]);N.find(".slideshow-wrapper").css("visibility","")},0)}}window.vBulletin.loadingIndicator.hide()}function Q(U,W,T){U.size(W.photos.length);if(W.photos.length>1){E("#slideshow-dialog .thumbnails").show();H(W)}else{E("#slideshow-dialog .thumbnails").hide();T.dialog("option","height","auto")}var V=U.first||1;E.each(W.photos,function(Y,X){U.add(V+Y,'<div class="image-wrapper"><a href="{0}"><img src="{0}" alt="{1}" class="image" /></a></div>'.format(X.url,X.htmltitle))})}function H(V){var U=E("#slideshow-dialog .thumbnails .thumbnail-list");if(U.length==0){U=E("#slideshow-dialog .thumbnails").append(E("<ul />").addClass("thumbnail-list"))}function T(Y){var X=E(Y.buttonPrev[0]),W=E(Y.buttonNext[0]);X.toggleClass("b-icon--disabled",X.is(".jcarousel-prev-disabled"));W.toggleClass("b-icon--disabled",W.is(".jcarousel-next-disabled"))}vBulletin.gallery.thumbnails=U.jcarousel({wrap:null,animation:"fast",easing:"swing",scroll:K,rtl:vBulletin.isRtl(),size:V.photos.length,initCallback:function(a,Y){if(Y=="init"){a.size(V.photos.length);E.each(V.photos,function(d,c){var b=(a.first||1)+d;if(a.has(b)){return true}if(b>V.photos.length){return false}var e=E("<img />").addClass("thumbnail").on("load",function(){}).attr({src:c.thumb,alt:""}).appendTo(E("<div />").addClass("image-wrapper dimmed"));a.add(b,e.parent().get(0))});var W=E("#slideshow-dialog .thumbnails .jcarousel-clip");var Z=Math.min(a.size(),K)*90;var X=Math.min(P,Z);W.css("width",X+"px");if(a.size()<=K){a.buttonNext.hide();a.buttonPrev.hide()}}},itemVisibleInCallback:{onBeforeAnimation:function(Z,X,W,Y){E("#slideshow-dialog .thumbnails").data("visible-range",{first:Z.first,last:Z.last})}},buttonNextCallback:T,buttonPrevCallback:T}).disableSelection()}function F(){if(R){var U=R;var T=D;N.dialog("close");D=T;J.call(U)}}function O(){E(document).off("click",".b-gallery-thumbnail-list__item").on("click",".b-gallery-thumbnail-list__item",J);N.addClass("js-no-responsive-resize");E(window).on("resize",E.debounce(300,F))}E(document).ready(O)})(jQuery);