class PhotoSwipeGallery{constructor(containerId){this.containerId=containerId;this.currentPageNumber=1;this.totalNumberOfPages=0;this.currentGalleryItems=[];this.galleryItems=[];this.containerElement=document.getElementById(containerId);this.requestUri=this.containerElement.dataset.requestUri;if(document.getElementById(this.containerId+'_pagination_container'))this.paginationContainer=document.getElementById(this.containerId+'_pagination_container');this.numberOfItemsPerPage=this.containerElement.dataset.galleryItemsPerPage;this.numberOfItemsOnPrevPage=0;this.currentSlideIndex=1;this.container=document.getElementById(containerId);this.galleryShouldPaginate=!1;this.galleryPaginationDirection="next";this.shouldPaginateNext=!0;this.activeImageIndex=undefined;this.photoSwipeElement=document.querySelector('.pswp');this.photoSwipeItems=[];this.photoSwipeOptions=null;this.photoSwipeGallery=null;this.buildPhotoSwipeItems=this.buildPhotoSwipeItems.bind(this);this.openPhotoSwipeAtIndex=this.openPhotoSwipeAtIndex.bind(this);this.buildSwiperOptions=this.buildSwiperOptions.bind(this);this.closest=this.closest.bind(this);this.openPhotoSwipe=this.openPhotoSwipe.bind(this);this.onThumbnailsClick=this.onThumbnailsClick.bind(this);this.photoSwipeOnChangeListener=this.photoSwipeOnChangeListener.bind(this);this.clearContainerMarkup=this.clearContainerMarkup.bind(this);this.updateSwiperItems=this.updateSwiperItems.bind(this);this.rebuildContainerMarkup=this.rebuildContainerMarkup.bind(this);this.paginationLinkHandler=this.paginationLinkHandler.bind(this);this.bindImageClickHandler=this.bindImageClickHandler.bind(this);this.galleryPaginationHandler=this.galleryPaginationHandler.bind(this);this.checkURLForQueryString=this.checkURLForQueryString.bind(this);this.setActiveImageQueryVars=this.setActiveImageQueryVars.bind(this);this.parseQueryStringVars=this.parseQueryStringVars.bind(this);this.setPaginationQueryVars=this.setPaginationQueryVars.bind(this);this.photoswipeDragEventListener=this.photoswipeDragEventListener.bind(this);this.swipePaginationHandler=this.swipePaginationHandler.bind(this);console.log("test");this.init=this.init.bind(this)} closest(el,fn){return el&&(fn(el)?el:this.closest(el.parentNode,fn))};onThumbnailsClick(e){e=e||window.event;e.preventDefault?e.preventDefault():e.returnValue=!1;var eTarget=e.target||e.srcElement;var clickedListItem=this.closest(eTarget,function(el){return(el.tagName&&el.tagName.toUpperCase()==='FIGURE')});if(!clickedListItem){return} var childNodes=clickedListItem.parentNode.childNodes,numChildNodes=childNodes.length,nodeIndex=0,index;for(var i=0;i=0){this.openPhotoSwipeAtIndex(index)} return!1} calculateNumberOfPages(){var context=this;var numberOfItemsPerPage=context.numberOfItemsPerPage;var numberOfGalleryItems=context.galleryItems.length;var numberOfGalleryPages=Math.trunc(numberOfGalleryItems/numberOfItemsPerPage);context.totalNumberOfPages=numberOfGalleryPages+1;return} setCurrentGalleryItems(){var context=this;var currentPageNumber=parseInt(context.currentPageNumber);var numberOfItemsPerPage=parseInt(context.numberOfItemsPerPage);var sliceStart,sliceEnd;if(currentPageNumber==1){context.currentGalleryItems=context.galleryItems.slice(0,numberOfItemsPerPage)}else{sliceStart=(currentPageNumber-1)*numberOfItemsPerPage;sliceEnd=sliceStart+numberOfItemsPerPage;context.currentGalleryItems=context.galleryItems.slice(sliceStart,sliceEnd)} return} fetchGalleryItems(){var context=this;console.log("loading gallery "+context.requestUri);var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){let response=this.responseText;let context=this.context;context.galleryItems=JSON.parse(response);context.calculateNumberOfPages();context.checkURLForQueryString();context.setCurrentGalleryItems();context.rebuildContainerMarkup(context.currentGalleryItems);context.buildPhotoSwipeItems();context.buildSwiperOptions();context.bindImageClickHandler();context.renderPaginationLinks();if(context.activeImageIndex!=undefined){context.openPhotoSwipeAtIndex(context.activeImageIndex)}}};xhttp.context=this;xhttp.open("GET",context.requestUri);xhttp.send();if(typeof gsa==='function')gsa("#gallery:"+context.requestUri);return} renderPaginationLinks(){var context=this;if(context.paginationContainer){var linksMarkup="";var arrowsMarkup="";var arrowsContainer=context.paginationContainer.querySelector('.pagination_arrows');var linksContainer=context.paginationContainer.querySelector('.pagination_links');if(context.currentPageNumber>1){arrowsMarkup+=`   `}else{arrowsMarkup+=`   `} if(context.currentPageNumber   `}else{arrowsMarkup+=`   `} for(var i=1;i<=context.totalNumberOfPages;i++){if(i===context.currentPageNumber){linksMarkup+='Page '+i+''}else{linksMarkup+=''+i+''}} arrowsContainer.innerHTML=arrowsMarkup;linksContainer.innerHTML=linksMarkup;context.bindPaginationLinkHandler()}} bindPaginationLinkHandler(){var context=this;var paginationLinkHandler=this.paginationLinkHandler;var paginationLinks=context.paginationContainer.querySelectorAll('a');paginationLinks.forEach(function(link,index){link.onclick=paginationLinkHandler})} clearContainerMarkup(){var context=this;context.numberOfItemsOnPrevPage=context.containerElement.childElementCount;this.container.innerHTML="";return} rebuildContainerMarkup(galleryItems){var context=this;var items=galleryItems var markup="";items.forEach(function(item,index){markup+=`
`+item.alt+` `+item.id+`
`+item.alt+`
`}) context.container.innerHTML+=(markup);return} paginationLinkHandler(event){event.preventDefault();var context=this;var requestedPageNumber=event.target.dataset.pageNum;if(requestedPageNumber==="next"){requestedPageNumber=parseInt(context.currentPageNumber)+1}else if(requestedPageNumber==="prev"){if(context.currentPageNumber>1){requestedPageNumber=parseInt(context.currentPageNumber)-1}else{requestedPageNumber=1}}else{requestedPageNumber=parseInt(requestedPageNumber)} context.currentPageNumber=requestedPageNumber;context.setCurrentGalleryItems();context.clearContainerMarkup();context.rebuildContainerMarkup(context.currentGalleryItems);context.buildPhotoSwipeItems();context.bindImageClickHandler();context.setPaginationQueryVars();context.renderPaginationLinks();if(typeof gsa==='function')gsa("#gallery-page:"+requestdPageNumber);return} buildPhotoSwipeItems(){var context=this;context.photoSwipeItems=[];context.currentGalleryItems.forEach(function(galleryItem,index){var dimensions=galleryItem.size.split('x');var element=context.containerElement.querySelector(`#photoswipe-image-`+galleryItem.id);if(element&&element.parentElement){if(galleryItem.filetype=="video"){context.photoSwipeItems.push({html:'
',w:dimensions[0],h:dimensions[1],msrc:galleryItem.thumb,el:element,title:galleryItem.alt})}else{context.photoSwipeItems.push({src:galleryItem.file,w:dimensions[0],h:dimensions[1],msrc:galleryItem.thumb,el:element,title:galleryItem.alt})}}});return} buildSwiperOptions(index){var photoSwipeItems=this.photoSwipeItems;var options={history:!1,loop:!1,galleryUID:this.container.getAttribute('data-pswp-uid'),getThumbBoundsFn:function(index){var thumbnail=photoSwipeItems[index].el.getElementsByTagName('img')[0];var pageYScroll=window.pageYOffset||document.documentElement.scrollTop;var rect=thumbnail.getBoundingClientRect();return{x:rect.left,y:rect.top+pageYScroll,w:rect.width}},addCaptionHTMLFn:function(item,captionEl,isFake){if(!item.title){captionEl.children[0].innerHTML='';return!1} captionEl.children[0].innerHTML=item.title;return!0}} if(index){options.index=index} this.photoSwipeOptions=options;return} bindImageClickHandler(){var context=this var photoSwipeItems=context.photoSwipeItems;var onThumbnailsClick=context.onThumbnailsClick;photoSwipeItems.forEach(function(item,index){item.el.onclick=onThumbnailsClick})} updateSwiperItems(direction){var context=this;var photoSwipeGallery=context.photoSwipeGallery;var photoSwipeItems=context.photoSwipeItems;photoSwipeItems.forEach(function(item,index){photoSwipeGallery.items.splice(index,1,item)}) photoSwipeGallery.items.splice(photoSwipeItems.length,(context.numberOfItemsOnPrevPage-photoSwipeItems.length));photoSwipeGallery.updateSize(!0);if(direction=="prev"){setTimeout(function(){photoSwipeGallery.goTo(photoSwipeItems.length-1)})} context.setPaginationQueryVars();context.renderPaginationLinks()} swipePaginationHandler(clientXStart,clientXEnd){let context=this;let delta=clientXStart-clientXEnd;let swipeOffsetTrigger=125;let direction=undefined;if(delta>swipeOffsetTrigger){direction="next"}else if(delta<-swipeOffsetTrigger){direction="prev"} if(context.currentGalleryItems.length>2){if(direction=="prev"&&context.currentPageNumber>1){if(context.currentSlideIndex===1){context.photoSwipeGallery.prev()}}else if(direction=="next"&&context.currentSlideIndex===context.currentGalleryItems.length){if(context.currentPageNumber iframe').forEach(function(el){el.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}','*')});var slideIndex=parseInt(photoSwipeGallery.getCurrentIndex()+1);var pswpContainer=document.querySelector('.pswp__container') if(context.currentGalleryItems.length>2){if(context.currentSlideIndex===1&&slideIndex===context.currentGalleryItems.length){if(context.currentPageNumber>1){pswpContainer.css('opacity','0') setTimeout(function(){context.galleryPaginationHandler("prev") pswpContainer.css('opacity','1')},500)}}else if(slideIndex===1&&context.currentSlideIndex===context.currentGalleryItems.length){if(context.currentPageNumber iframe').forEach(function(){this.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}','*')})})} galleryPaginationHandler(direction){var context=this;var currentPageNumber=parseInt(this.currentPageNumber);var requestedPageNumber=1;if(direction==="next"&¤tPageNumber1){requestedPageNumber=parseInt(currentPageNumber)-1}else{requestedPageNumber=1}} context.currentPageNumber=requestedPageNumber;context.setCurrentGalleryItems();context.clearContainerMarkup();context.rebuildContainerMarkup(context.currentGalleryItems);context.buildPhotoSwipeItems();context.bindImageClickHandler();context.updateSwiperItems(direction);context.setPaginationQueryVars();context.renderPaginationLinks();return} openPhotoSwipe(){var photoSwipeGallery=new PhotoSwipe(this.photoSwipeElement,PhotoSwipeUI_Default,this.photoSwipeItems,this.photoSwipeOptions);photoSwipeGallery.init();this.photoSwipeGallery=photoSwipeGallery;this.currentSlideIndex=(photoSwipeGallery.getCurrentIndex()+1);this.photoSwipeOnChangeListener();this.photoswipeDragEventListener();return} openPhotoSwipeAtIndex(index){this.buildSwiperOptions(index);this.setActiveImageQueryVars(index);this.openPhotoSwipe()} setPaginationQueryVars(){let context=this;let parsedQueryVars=this.parseQueryStringVars();let baseURL=window.location.protocol+"//"+window.location.host+window.location.pathname;var updatedQueryString="",updatedURL;if(parsedQueryVars){if(parsedQueryVars[context.containerId+"-page"]){parsedQueryVars[context.containerId+"-page"]=context.currentPageNumber}else{parsedQueryVars.push(context.containerId+"-page") parsedQueryVars[context.containerId+"-page"]=context.currentPageNumber} parsedQueryVars.forEach(function(parsedQueryVar,index){let key=parsedQueryVar;let value=parsedQueryVars[parsedQueryVar];if(index===0){updatedQueryString+="?"+key+"="+value}else{updatedQueryString+="&"+key+"="+value}})}else{updatedQueryString="?"+context.containerId+"-page="+context.currentPageNumber} updatedURL=baseURL+updatedQueryString window.history.pushState({path:updatedURL},'',updatedURL)} setActiveImageQueryVars(index){let context=this;let parsedQueryVars=this.parseQueryStringVars();let baseURL=window.location.protocol+"//"+window.location.host+window.location.pathname;var updatedQueryString="",updatedURL;if(parsedQueryVars){parsedQueryVars[context.containerId+"-page"]=context.currentPageNumber;if(parsedQueryVars["active-gallery"]){parsedQueryVars["active-gallery"]=context.containerId}else{parsedQueryVars.push('active-gallery');parsedQueryVars["active-gallery"]=context.containerId} if(parsedQueryVars["active-image"]){parsedQueryVars["active-image"]=index}else{parsedQueryVars.push('active-image') parsedQueryVars["active-image"]=index} parsedQueryVars.forEach(function(parsedQueryVar,index){let key=parsedQueryVar;let value=parsedQueryVars[parsedQueryVar];if(index===0){updatedQueryString+="?"+key+"="+value}else{updatedQueryString+="&"+key+"="+value}})}else{updatedQueryString="?"+context.containerId+"-page="+context.currentPageNumber;updatedQueryString+="&active-gallery="+context.containerId;updatedQueryString+="&active-image="+index} updatedURL=baseURL+updatedQueryString window.history.pushState({path:updatedURL},'',updatedURL)} parseQueryStringVars(){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');if(window.location.href.indexOf('?')!=-1){for(var i=0;i'+document.getElementById("email_input_input").value+' (Change)';document.getElementById('gsdz-email-confirm').classList.add("active");if(document.querySelector('.dz-preview'))document.querySelector('.dz-preview').style.display=document.querySelector('.dz-preview').getAttribute("data-original-display")}}else{alert("The email address entered is not valid.")}} function changeEmail(){if(document.getElementById('gsdropzone').classList.contains("dz-started")){if(window.confirm("Changing your email address will abandon uploaded files. Continue?"))resetEmail()}else resetEmail()} function resetEmail(){document.getElementById('email_input_input').setAttribute("type","text");document.querySelector('#gsdropzone .email_input').style.height=document.querySelector('#gsdropzone .email_input').getAttribute("data-original-height");document.getElementById('gsdz_add').classList.add("gsdz_hidden");document.querySelector('.dz-preview').setAttribute("data-original-display",document.querySelector('.dz-preview').getAttribute("display"));document.querySelector('.dz-preview').style.display="none";document.querySelector('.dz-message').style.display="none";document.getElementById('gsdz-close').remove();document.getElementById('gallery_save').classList.remove("active");document.getElementById('gallery_save_all').remove();document.getElementById('gsdz_confirm').classList.add("gsdz_hidden");document.getElementById('gsdropzone').classList.remove("dz-started");document.getElementById('gsdz-email-confirm').innerHTML="";document.getElementById('gsdz-email-confirm').classList.remove("active")} function validateEmail(email){var re=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return re.test(email)} var saveCaptions=function(event){if(event){var post_data=new FormData(document.getElementById("gsdropzone"));console.log("event/form")}else{var post_data=new FormData();document.querySelectorAll("#gallery_captions-"+arguments[1]+" input").forEach(function(el,i){post_data.append(el.getAttribute("name"),el.value)});document.querySelectorAll("#gallery_captions-"+arguments[1]+" textarea").forEach(function(el,i){post_data.append(el.getAttribute("name"),el.value)})} console.log(post_data);var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){let response=this.responseText;let context=this.context;if(response.length>2){if(!document.getElementById('gsdz-email-confirm').classList.contains("notice-served")){document.getElementById('gsdz_confirm').classList.remove("gsdz_hidden")} gallerySaveText("Success: Captions and rotation saved. Thanks again for sharing!");let res=JSON.parse(response);let resArray=Object.entries(res);if(Array.isArray(resArray))[...resArray].forEach(([id,val])=>{[...Object.entries(val)].forEach(([key,val2])=>{console.log(key+": "+val2+" for id:"+id+', label[for="upload_'+key+"-"+id+'"]');if(key=="rotate"){document.getElementById('preview'+id).setAttribute("data-saved-rotate",val2)}else{document.querySelector('label[for="upload_'+key+"-"+id+'"]').classList.add("saved");document.getElementById('upload_'+key+"-"+id).setAttribute("data-last",val2)}});if(document.getElementById('preview'+id))document.getElementById('preview'+id).classList.add("dz-saved");document.getElementById('save-'+id).classList.remove("dz-save");document.getElementById('save-'+id).classList.add("dz-editor");setTimeout('document.getElementById("preview'+id+'").classList.remove("dz-saved");',3300)});document.getElementById('gallery_save_all').classList.add("disabled");document.getElementById('gallery_save_all').value="Save Complete"}else alert("An error has occurred saving information about this upload.\n\nPlease contact us if you continue to encounter this error.")}};xhttp.context=this;xhttp.open("POST",document.getElementById('gsdropzone').getAttribute("action")+"?dropzone&gallery_captions&rand="+Math.random());xhttp.send(post_data);if(event)event.preventDefault()} var dropzone;if(document.getElementById('gsdropzone')){Dropzone.options.gsdropzone={url:document.getElementById('gsdropzone').getAttribute("action")+"?dropzone=true&rand="+Math.random(),clickable:'.dz-clickable',addRemoveLinks:!0,acceptedFiles:"video/mp4,video/x-m4v,video/webm,video/mpeg,video/*,image/*",thumbnailWidth:150,thumbnailHeight:150,dictDefaultMessage:'Drop files here or click to upload',dictRemoveFileConfirmation:"Are you sure you wish to delete this upload?",dictCancelUpload:"Cancel",dictRemoveFile:"Delete",init:function(){var that=this;this.on("addedfile",function(file){if(!document.getElementById('gsdz-email-confirm').classList.contains("notice-served")){document.getElementById('gsdz_confirm').classList.remove("gsdz_hidden")} if(!document.body.contains(document.getElementById('gsdz-close'))){let s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("version","1.1");s.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink");s.setAttribute("viewBox","0 0 8 8");s.setAttribute("xml:space","preserve");let sl1=document.createElementNS("http://www.w3.org/2000/svg","line");sl1.setAttribute("x1","1");sl1.setAttribute("y1","1");sl1.setAttribute("x2","7");sl1.setAttribute("y2","7");s.appendChild(sl1);let sl2=document.createElementNS("http://www.w3.org/2000/svg","line");sl2.setAttribute("x1","1");sl2.setAttribute("y1","7");sl2.setAttribute("x2","7");sl2.setAttribute("y2","1");s.appendChild(sl2);let a=document.createElement("a");a.setAttribute("id","gsdz-close");a.setAttribute("href","javascript:void()");a.appendChild(s);document.getElementById('gsdropzone').appendChild(a);document.getElementById('gsdz-close').addEventListener("click",function(event){event.preventDefault();if(document.getElementById('gsdropzone').classList.contains("dz-started")){if(window.confirm("Finished uploading?\n\nYou may manage prior uploads via the confirmation emails.")){document.getElementById('email_input_input').value="";resetEmail()}}else{document.getElementById('email_input_input').value="";resetEmail()}})} if(document.body.contains(document.getElementById('gsdz_add')))document.getElementById('gsdz_add').classList.remove("gsdz_hidden")}),this.on("sending",function(file,xhr,formData){this.options.url+="&random="+Math.random()}),this.on("canceled",function(file){}),this.on("removedfile",function(file){var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){let response=this.responseText;let context=this.context;let r=JSON.parse(response);gallerySaveText("Notice: A file has been removed.");if(r.remove){if(document.getElementById('gallery_captions').childNodes.length<2){document.getElementById('gallery_save_all').remove();document.getElementById('gallery_captions').classList.remove("active")}}else{alert(r.removal_confirmation)}}};xhttp.context=this;xhttp.open("POST",this.options.url);var post_data=new FormData();post_data.append("ajax","true");post_data.append("e",file._email);post_data.append("k",file._key);post_data.append("rand",Math.random());post_data.append("remove","remove");xhttp.send(post_data)}),this.on("error",function(file,response){document.getElementById('gallery_status').setAttribute("data-error",document.getElementById('gallery_status').getAttribute("data-error")*1+1);gallerySaveText("Error: Apologies, but an error occurred. Try again?")}),this.on("success",function(file,response){console.log(response);gallerySaveText("Success: Upload finished; thank you! Please consider adding captions?");document.getElementById('gallery_status').setAttribute("data-total",document.getElementById('gallery_status').getAttribute("data-total")*1+1);var html_message='';let e=('file-'+file.name.replace(/[^A-z0-9\-\_]+/g,""));if(document.getElementById(e))document.getElementById(e).remove();let r=JSON.parse(response);console.log("json parse:");console.log(response.id);console.log(r.id);console.log(r);file._id=r.id;file._email=r.email;file._key=r.key;file._type=r.type;console.log("file:");console.log(file);let a=document.createElement("a");a.classList.add("dz-save");a.setAttribute("id",'save-'+file._id);a.setAttribute("href","javascript:void('save')");a.setAttribute("data-id",file._id);a.innerHTML="Save";file.previewElement.appendChild(a);a.addEventListener("click",function(el){if(this.classList.contains("dz-save")){saveCaptions(!1,this.getAttribute("data-id"));this.classList.remove("dz-save");this.classList.add("dz-editor")}else{document.getElementById('preview'+this.getAttribute("data-id")).classList.add("dz-edit");this.classList.remove("dz-editor");this.classList.add("dz-save")}});if(r.type!="Video"){let a2=document.createElement("a");a2.classList.add("dz-rotate");a2.setAttribute("id",'rotate-'+file._id);a2.setAttribute("href","javascript:void('rotate')");a2.setAttribute("data-id",file._id);a2.innerHTML="Rotate";file.previewElement.appendChild(a2);a2.addEventListener('click',function(){var currot=document.getElementById("preview"+this.getAttribute("data-id")).getAttribute("data-rotate")*1+90;let el=this;let animation=document.querySelector("#preview"+this.getAttribute("data-id")+" .dz-image img").animate([{transform:"rotate("+currot+"deg)"}],200);animation.onfinish=function(e){document.querySelector("#preview"+el.getAttribute("data-id")+" .dz-image img").style.transform="rotate("+currot+"deg)"} if(currot==360)currot=0;document.getElementById("preview"+this.getAttribute("data-id")).setAttribute("data-rotate",currot);document.getElementById('upload_rotate-'+this.getAttribute("data-id")).value=(currot);document.getElementById('save-'+this.getAttribute("data-id")).classList.remove("dz-editor");document.getElementById('save-'+this.getAttribute("data-id")).classList.add("dz-save");document.getElementById('gallery_save_all').classList.remove("disabled");document.getElementById('gallery_save_all').value=("Save All")})} file.previewElement.setAttribute("id","preview"+file._id);file.previewElement.setAttribute("data-rotate","0");file._form=r.form;let h=document.createElement("div");h.classList.add("dz-editform");h.innerHTML=file._form;file.previewElement.appendChild(h);setTimeout('document.getElementById("'+file.previewElement.getAttribute("id")+'").classList.add("dz-edit");',2000);if(!document.body.contains(document.getElementById('gallery_save_all'))){let i=document.createElement("input");i.setAttribute("type","submit");i.setAttribute("value","Save All");i.classList.add("small");i.classList.add("button");i.setAttribute("id","gallery_save_all");document.getElementById('gallery_save').appendChild(i);document.getElementById('gallery_save').classList.add("active");document.getElementById("gallery_save_all").addEventListener('click',function(event){saveCaptions(event)});document.getElementById("gsdropzone").addEventListener('submit',function(event){event.preventDefault();saveCaptions(event)})}}),this.on("queuecomplete",function(a){document.querySelectorAll('.gallery_caption_input input').forEach(function(el){if(el.getAttribute("hasOnChange")!="true"){el.addEventListener("change",function(){if(this.getAttribute("data-last")!=this.value){document.querySelector('label[for="'+this.getAttribute("id")+'"]').classList.remove("saved");document.getElementById('gallery_save_all').classList.remove("disabled");document.getElementById('gallery_save_all').value=("Save All");document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.add("edited")}else document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.remove("edited")});el.addEventListener('keyup',function(key){if(this.getAttribute("data-last")!=this.value){document.querySelector('label[for="'+this.getAttribute("id")+'"]').classList.remove("saved");document.getElementById('gallery_save_all').classList.remove("disabled");document.getElementById('gallery_save_all').value=("Save All");document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.add("edited")}else document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.remove("edited")});el.setAttribute("hasOnChange","true")}});document.querySelectorAll('.gallery_caption_input textarea').forEach(function(el){if(el.getAttribute("hasOnChange")!="true"){el.addEventListener('change',function(){if(this.getAttribute("data-last")!=this.value){document.querySelector('label[for="'+this.getAttribute("id")+'"]').classList.remove("saved");document.getElementById('gallery_save_all').classList.remove("disabled");document.getElementById('gallery_save_all').value=("Save All");document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.add("edited")}else document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.remove("edited")});el.addEventListener('keyup',function(key){if(this.getAttribute("data-last")!=this.value){document.querySelector('label[for="'+this.getAttribute("id")+'"]').classList.remove("saved");document.getElementById('gallery_save_all').classList.remove("disabled");document.getElementById('gallery_save_all').value=("Save All");document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.add("edited")}else document.querySelector("label[for='"+this.getAttribute("id")+"']").classList.remove("edited")});el.setAttribute("hasOnChange","true")}})}),this.on('focusout','textarea.dropzone_caption',function(){})},accept:function(file,done){done()}}} function timeoutUploadThanks(){var to=document.getElementById('gallery_save_text').getAttribute("data-timeout");if(to>999){to=Math.floor(to-1000);document.getElementById('gallery_save_text').setAttribute("data-timeout",to);setTimeout(timeoutUploadThanks,1000)}else{document.getElementById('gallery_save_text').classList.add("inactive")}} function gallerySaveText(text){if(document.body.contains(document.getElementById('gallery_save_text'))){document.getElementById('gallery_save_text').innerHTML=(text);document.getElementById('gallery_save_text').classList.remove("inactive");document.getElementById('gallery_save_text').setAttribute("data-timeout",10000);setTimeout(timeoutUploadThanks,1000)}}})()