function fnGenerujPdf(){var n=$(this);n.find(".fa-spin").show();$.ajax({cache:!1,type:"GET",url:"./generujpdf",data:{url:$(this).data("url"),filename:$(this).data("filename")},xhrFields:{responseType:"blob"},complete:function(){n.find(".fa-spin").hide()},success:function(n,t,i){var u="",s=i.getResponseHeader("Content-Disposition"),h,f,l,o,c,e,r;s&&(h=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/,f=h.exec(s),f!==null&&f[1]&&(u=f[1].replace(/['"]/g,"")));l=document.createElement("a");try{o=new Blob([n],{type:"application/octet-stream"});typeof window.navigator.msSaveBlob!="undefined"?window.navigator.msSaveBlob(o,u):(c=window.URL||window.webkitURL,e=c.createObjectURL(o),u?(r=document.createElement("a"),typeof r.download=="undefined"?window.location=e:(r.href=e,r.download=u,document.body.appendChild(r),r.target="_blank",r.click())):window.location=e)}catch(a){console.log(a)}}})}$(document).ready(function(){$.typeahead({input:".js-typeahead-ppropo",minLength:1,maxItem:8,accent:!0,order:"asc",hint:!0,cache:!0,display:["caption"],template:"<span>{{caption}}<\/span>",source:{teams:{url:"/Naseptavac/ppropo.data.kapitoly.json"}},callback:{onClickAfter:function(n,t,i,r){r.preventDefault();window.location.href="./"+i.filename}}});$("#buttonGenerujPDF,#modalButtonGenerujPDF").click(fnGenerujPdf);$("#buttonGenerujPDF .fa-spin,#modalButtonGenerujPDF .fa-spin").hide()});var loadUrlToModalBody=function(n){$("#modal-body").load(n,complete=function(){})};$("#modal-rejstrik-window").on("show.bs.modal",function(n){var r=$(n.relatedTarget),t=r.data("odkaz"),i=window.location.protocol+"//"+window.location.host+"/"+t,u=r.data("nazev"),s=$(this),f,e,o;s.find("#modal-subtitle").html(u);f="./pdf/{filename}.pdf".replace("{filename}",t);$("#modalSaveAsPdf").prop("href",f);$("#modalButtonGenerujPDF").data("url",i).data("filename",t+".pdf");e="http://www.facebook.com/sharer.php?u={url}".replace("{url}",i);$("#modalShareOnFacebook").prop("href",e);o="mailto:?Subject={title}&body={url}".replace("{title}",u).replace("{url}",i);$("#modalSendByEmail").prop("href",o);$("#modalPrint").attr("data-ppropo-print",i);loadUrlToModalBody(t+" #body-content")})