diff --git a/app/Exceptions/FileUploadException.php b/app/Exceptions/FileUploadException.php index 44ec0df03c4..ac5edc53182 100644 --- a/app/Exceptions/FileUploadException.php +++ b/app/Exceptions/FileUploadException.php @@ -91,14 +91,11 @@ public function __construct(UploadedFileInterface|null $uploaded_file) break; } - $filename = $uploaded_file->getClientFilename() ?? '????????.???'; - - $message = - I18N::translate('There was an error uploading your file.') . - '
' . - I18N::translate('%1$s: %2$s', I18N::translate('Filename'), e($filename)) . - '
' . - $message; + $filename = $uploaded_file->getClientFilename() ?? ''; + + if ($filename !== '') { + $message = I18N::translate('%1$s: %2$s', e($filename), $message); + } parent::__construct($message); } diff --git a/app/Http/RequestHandlers/CreateMediaObjectAction.php b/app/Http/RequestHandlers/CreateMediaObjectAction.php index b6faf29596b..1d8b4d95ceb 100644 --- a/app/Http/RequestHandlers/CreateMediaObjectAction.php +++ b/app/Http/RequestHandlers/CreateMediaObjectAction.php @@ -20,6 +20,7 @@ namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; +use Fisharebest\Webtrees\Exceptions\FileUploadException; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\MediaFileService; @@ -30,6 +31,7 @@ use Psr\Http\Server\RequestHandlerInterface; use function response; +use function view; /** * Process a form to create a new media object. @@ -70,7 +72,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface $title = Registry::elementFactory()->make('OBJE:FILE:TITL')->canonical($title); $restriction = Registry::elementFactory()->make('OBJE:RESN')->canonical($restriction); - $file = $this->media_file_service->uploadFile($request); + try { + $file = $this->media_file_service->uploadFile($request); + } catch (FileUploadException $exception) { + return response([ + 'value' => '', + 'text' => '', + 'html' => view('components/alert-danger', [ + 'alert' => $exception->getMessage(), + ]), + ]); + } if ($file === '') { return response(['error_message' => I18N::translate('There was an error uploading your file.')], StatusCodeInterface::STATUS_NOT_ACCEPTABLE); diff --git a/public/js/webtrees.min.js b/public/js/webtrees.min.js index 7a1ac8a6169..ba3eff701ba 100644 --- a/public/js/webtrees.min.js +++ b/public/js/webtrees.min.js @@ -1 +1 @@ -"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=Array(t);n1&&void 0!==arguments[1]?arguments[1]:"",n=document.head.querySelector("meta[name=csrf]").getAttribute("content"),o={body:t,method:"POST",credentials:"same-origin",referrerPolicy:"same-origin",headers:new Headers({"X-CSRF-TOKEN":n,"x-requested-with":"XMLHttpRequest"})};return fetch(e,o,t)},e.detectScript=function(e){for(var t in n)if(e.match(n[t]))return t;return"Latn"},e.buildNameFromParts=function(n,r,a,i,l,s){var c="Han"===e.detectScript(n+r+a+r+i+l),d=c?"":" ",u=c||-1!==["hu","jp","ko","vi","zh-Hans","zh-Hant"].indexOf(t),p=-1!==["is"].indexOf(t)?"":"/";n=o(n),r=o(r.replace(/,/g,d)),a=o(a),i=function(e,n){return"pl"===t&&"F"===n?e.replace(/ski$/,"ska").replace(/cki$/,"cka").replace(/dzki$/,"dzka").replace(/żki$/,"żka"):e}(o(i.replace(/,/g,d)),s),l=o(l);var f=a.endsWith("'")||a.endsWith("‘")?"":" ",h=o(a+f+i);return o(n+d+(u?p+h+p+d+r:r+d+p+h+p)+d+l)},e.pasteAtCursor=function(e,t){if(null!==e){var n=e.selectionStart+t.length,o=e.value.substring(0,e.selectionStart),r=e.value.substring(e.selectionEnd);e.value=o+t+r,e.setSelectionRange(n,n),e.focus()}},e.reformatDate=function(e,t){var n=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],o=e.value,r=o.split("("),a="";r.length>1&&(o=r[0],a=r[1]),(o=(o=(o=(o=(o=o.toUpperCase()).replace(/\s+/g," ")).replace(/(^\s)|(\s$)/,"")).replace(/(\d)([A-Z])/g,"$1 $2")).replace(/([A-Z])(\d)/g,"$1 $2")).match(/^Q ([1-4]) (\d\d\d\d)$/)&&(o="BET "+n[3*RegExp.$1-3]+" "+RegExp.$2+" AND "+n[3*RegExp.$1-1]+" "+RegExp.$2),o.match(/^(@#DHIJRI@|HIJRI)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DHIJRI@"+RegExp.$2+["MUHAR","SAFAR","RABIA","RABIT","JUMAA","JUMAT","RAJAB","SHAAB","RAMAD","SHAWW","DHUAQ","DHUAH"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o.match(/^(@#DJALALI@|JALALI)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DJALALI@"+RegExp.$2+["FARVA","ORDIB","KHORD","TIR","MORDA","SHAHR","MEHR","ABAN","AZAR","DEY","BAHMA","ESFAN"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o.match(/^(@#DHEBREW@|HEBREW)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DHEBREW@"+RegExp.$2+["TSH","CSH","KSL","TVT","SHV","ADR","ADS","NSN","IYR","SVN","TMZ","AAV","ELL"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o.match(/^(@#DFRENCH R@|FRENCH)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DFRENCH R@"+RegExp.$2+["VEND","BRUM","FRIM","NIVO","PLUV","VENT","GERM","FLOR","PRAI","MESS","THER","FRUC","COMP"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o=(o=(o=o.replace(/(\d\d)(\d\d)(\d\d)(\d\d)/g,(function(){return RegExp.$1>"12"&&RegExp.$3<="12"&&RegExp.$4<="31"?RegExp.$4+" "+n[RegExp.$3-1]+" "+RegExp.$1+RegExp.$2:RegExp.$1<="31"&&RegExp.$2<="12"&&RegExp.$3>"12"?RegExp.$1+" "+n[RegExp.$2-1]+" "+RegExp.$3+RegExp.$4:RegExp.$1+RegExp.$2+RegExp.$3+RegExp.$4}))).replace(/(\d+)([ ./-])(\d+)(\2)(\d+)/g,(function(){var e=parseInt(RegExp.$1,10),o=parseInt(RegExp.$3,10),r=parseInt(RegExp.$5,10),a=(new Date).getFullYear(),i=a%100,l=a-i;return("DMY"===t||e>13&&r>31)&&e<=31&&o<=12?e+" "+n[o-1]+" "+(r>=100?r:r<=i?r+l:r+l-100):("MDY"===t||o>13&&r>31)&&e<=12&&o<=31?o+" "+n[e-1]+" "+(r>=100?r:r<=i?r+l:r+l-100):("YMD"===t||e>31)&&o<=12&&r<=31?r+" "+n[o-1]+" "+(e>=100?e:e<=i?e+l:e+l-100):RegExp.$1+RegExp.$2+RegExp.$3+RegExp.$4+RegExp.$5}))).replace(/^[>]([\w ]+)$/,"AFT $1").replace(/^[<]([\w ]+)$/,"BEF $1").replace(/^([\w ]+)[-]$/,"FROM $1").replace(/^[-]([\w ]+)$/,"TO $1").replace(/^[~]([\w ]+)$/,"ABT $1").replace(/^[*]([\w ]+)$/,"EST $1").replace(/^[#]([\w ]+)$/,"CAL $1").replace(/^([\w ]+) ?- ?([\w ]+)$/,"BET $1 AND $2").replace(/^([\w ]+) ?~ ?([\w ]+)$/,"FROM $1 TO $2").replace(/JANUARY/g,"JAN").replace(/FEBRUARY/g,"FEB").replace(/MARCH/g,"MAR").replace(/APRIL/g,"APR").replace(/JUNE/g,"JUN").replace(/JULY/g,"JUL").replace(/AUGUST/g,"AUG").replace(/SEPTEMBER/g,"SEP").replace(/OCTOBER/,"OCT").replace(/NOVEMBER/g,"NOV").replace(/DECEMBER/g,"DEC").replace(/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\.? (\d\d?)[, ]+(\d\d\d\d)/g,"$2 $1 $3").replace(/(^| )(\d [A-Z]{3,5} \d{4})/g,"$10$2"),a&&(o=o+" ("+a),e.value!==o&&(e.value=o)};var r=[];r[1]="January",r[2]="February",r[3]="March",r[4]="April",r[5]="May",r[6]="June",r[7]="July",r[8]="August",r[9]="September",r[10]="October",r[11]="November",r[12]="December";var a=[];a[1]="JAN",a[2]="FEB",a[3]="MAR",a[4]="APR",a[5]="MAY",a[6]="JUN",a[7]="JUL",a[8]="AUG",a[9]="SEP",a[10]="OCT",a[11]="NOV",a[12]="DEC";var i=[];i[0]="S",i[1]="M",i[2]="T",i[3]="W",i[4]="T",i[5]="F",i[6]="S";var l=0;function s(e,t,n){var o,a,s='';for(s+='",s+='",s+='",s+='",s+="
',s+='',s+="",a=l,o=0;o<7;o++)s+="";var c=new Date(n.getFullYear(),n.getMonth(),1),d=c.getDay();d-=l;var u=864e5;for(c=c.getTime()-d*u+432e5,c=new Date(c),a=0;a<6;a++){for(s+="",o=0;o<7;o++){s+="";var p=c.getTime()+u;c=new Date(p)}s+=""}return s+="
",++a>6&&(a=0);s+="
',s+=c.getDate(),s+="
",s+="
"}function c(e,t,n,o){return document.getElementById(e).value=(o<10?"0":"")+o+" "+a[n+1]+" "+t,!1}function d(e,t,n){var o=e.value.toUpperCase();(o=(o=(o=(o=(o=(o=(o=(o=(o=(o=o.replace(/(^\s*)|(\s*$)/g,"")).replace(/ /g,":")).replace(/\+/g,"")).replace(/-/g,n)).replace(/,/g,".")).replace(/\u00b0/g,":")).replace(/\u0027/g,":")).replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g,(function(e,t,n,o,r){var a=parseFloat(t);return a+=n/60,a+=o/3600,r+(a=Math.round(1e4*a)/1e4)}))).replace(/^([0-9]+):([0-9]+)(.*)/g,(function(e,t,n,o){var r=parseFloat(t);return r+=n/60,o+(r=Math.round(1e4*r)/1e4)}))).replace(/(.*)(NSEW])$/g,"$2$1"))&&o.charAt(0)!==n&&o.charAt(0)!==t&&(o=t+o),e.value=o}e.calLocalize=function(e,t,n,o,a,s,c,d,u,p,f,h,g,m,v,b,y,w,x,E){r[1]=e,r[2]=t,r[3]=n,r[4]=o,r[5]=a,r[6]=s,r[7]=c,r[8]=d,r[9]=u,r[10]=p,r[11]=f,r[12]=h,i[0]=g,i[1]=m,i[2]=v,i[3]=b,i[4]=y,i[5]=w,i[6]=x,E>=0&&E<7&&(l=E)},e.calendarWidget=function(e,t){var n=document.getElementById(e),o=document.getElementById(t);if("visible"===n.style.visibility)return n.style.visibility="hidden",!1;if("show"===n.style.visibility)return n.style.visibility="hide",!1;var r;if(/(?:(\d*) ?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) )?(\d+)/i.exec(o.value)){var a=RegExp.$1||"1",i=RegExp.$2||"JAN",l=RegExp.$3;r=new Date(a+" "+i+" "+l)}else r=new Date;return n.innerHTML=s(t,e,r),"hidden"===n.style.visibility?(n.style.visibility="visible",!1):"hide"===n.style.visibility&&(n.style.visibility="show",!1)},e.calUpdateCalendar=function(e,t){var n=document.getElementById(e+"_daySelect");if(!n)return!1;var o=document.getElementById(e+"_monSelect");if(!o)return!1;var r=document.getElementById(e+"_yearInput");if(!r)return!1;var a=parseInt(o.options[o.selectedIndex].value,10);a-=1;var i=new Date(r.value,a,n.options[n.selectedIndex].value);c(e,i.getFullYear(),i.getMonth(),i.getDate());var l=document.getElementById(t);return l?(l.innerHTML=s(e,t,i),!1):(alert("no dateDiv "+t),!1)},e.calDateClicked=function(t,n,o,r,a){return c(t,o,r,a),e.calendarWidget(n,t),!1},e.persistentToggle=function(e){var t,n="state-of-"+e.dataset.wtPersist,o=localStorage.getItem(n),r=null!==(t=e.getAttribute("aria-expanded"))&&void 0!==t?t:e.checked.toString();null!==o&&o!==r&&e.click(),e.addEventListener("click",(function(){"checkbox"===e.type&&localStorage.setItem(n,e.checked.toString()),"button"===e.type&&localStorage.setItem(n,e.getAttribute("aria-expanded"))}))},e.reformatLatitude=function(e){return d(e,"N","S")},e.reformatLongitude=function(e){return d(e,"E","W")},e.autocomplete=function(e){$(e).each((function(){var e=this;$(this).typeahead(null,{display:"value",limit:10,minLength:2,source:new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("value"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:this.dataset.wtAutocompleteUrl,replace:function(t,n){var o=t.indexOf("?")>0?"&":"?";if("SOUR"===e.dataset.wtAutocompleteExtra){for(var r=e.closest(".wt-nested-edit-fields").previousElementSibling;null===r.querySelector("select");)r=r.previousElementSibling;var a=r.querySelector("select"),i=a.options[a.selectedIndex].value.replace(/@/g,"");return t+o+"query="+n+"&extra="+encodeURIComponent(i)}return t+o+"query="+n}}})})}))},e.buildLeafletJsMap=function(e,t,n){for(var o=new L.control.zoom({zoomInTitle:t.i18n.zoomIn,zoomoutTitle:t.i18n.zoomOut}),r=L.Control.extend({options:{position:"topleft"},onAdd:function(){var e=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-custom"),o=L.DomUtil.create("a","leaflet-control-reset",e);return o.href="#",o.setAttribute("aria-label",t.i18n.reset),o.title=t.i18n.reset,o.setAttribute("role","button"),o.innerHTML=t.icons.reset,o.onclick=n,e}}),a=L.Control.extend({options:{position:"topleft"},onAdd:function(e){var n=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-custom"),o=L.DomUtil.create("a","leaflet-control-fullscreen",n);return o.href="#",o.setAttribute("role","button"),o.dataset.wtFullscreen=".wt-fullscreen-container",o.innerHTML=t.icons.fullScreen,n}}),i=null,l=0,s=Object.entries(t.mapProviders);l"+e.text+""},option:function(e,t){return"
"+e.text+"
"},no_results:function(e,n){return'
'+t.dataset.wtI18nNoResults+"
"}},firstUrl:function(e){return t.dataset.wtUrl+"&query="+encodeURIComponent(e)},load:function(t,n){var o=this;e.httpGet(this.getUrl(t)).then((function(e){return e.json()})).then((function(e){null!==e.nextUrl&&o.setNextUrl(t,e.nextUrl+"&query="+encodeURIComponent(t)),n(e.data)})).catch(n)}};return t.required||n.plugins.push("clear_button"),new TomSelect(t,n)}return t.multiple?new TomSelect(t,{plugins:["caret_position","remove_button"]}):t.required?new TomSelect(t,{}):new TomSelect(t,{plugins:["clear_button"]})},e.resetTomSelect=function(e,t,n){e.clear(!0),e.clearOptions(),e.addOption({value:t,text:n}),e.refreshOptions(),e.addItem(t,!0),e.refreshItems()},e.initializeIFSRO=function(e,t){e.addEventListener("change",(function(){t.querySelectorAll(".select-record").forEach((function(e){return e.classList.add("d-none")})),t.querySelectorAll(".select-"+e.value).forEach((function(e){return e.classList.remove("d-none")})),t.querySelectorAll(".select-record select").forEach((function(e){e.disabled=!0,e.matches(".tom-select")&&e.tomselect.disable()})),t.querySelectorAll(".select-"+e.value+" select").forEach((function(e){e.disabled=!1,e.matches(".tom-select")&&e.tomselect.enable()}))}))},e.createRecordModalSubmit=function(t){t.preventDefault();var n=t.target,o=document.getElementById("wt-ajax-modal"),r=o.querySelector(".modal-content"),a=document.getElementById(r.dataset.wtSelectId);e.httpPost(n.action,new FormData(n)).then((function(e){return e.json()})).then((function(t){a?(e.resetTomSelect(a.tomselect,t.value,t.text),bootstrap.Modal.getInstance(o).hide()):r.innerHTML=t.html})).catch((function(e){r.innerHTML=e}))},e.textareaPatterns=function(e){e.addEventListener("submit",(function(e){e.target.querySelectorAll("textarea[data-wt-pattern]").forEach((function(t){var n=new RegExp("^"+t.dataset.wtPattern+"$");t.readOnly||""===t.value||n.test(t.value)?t.classList.remove("is-invalid"):(e.preventDefault(),e.stopPropagation(),t.classList.add("is-invalid"),t.scrollIntoView())}))}))}}(window.webtrees=window.webtrees||{}),$.ajaxSetup({headers:{"X-CSRF-TOKEN":$("meta[name=csrf]").attr("content")}}),$((function(){var e;$("[data-wt-ajax-url]").each((function(){$(this).load(this.dataset.wtAjaxUrl)})),webtrees.autocomplete("input[data-wt-autocomplete-url]"),document.querySelectorAll(".tom-select").forEach((function(e){return webtrees.initializeTomSelect(e)})),document.querySelectorAll("select.tom-select:not([multiple])").forEach((function(e){e.addEventListener("clear",(function(){webtrees.resetTomSelect(e.tomselect,"","")}))})),$.fn.dataTableExt.oSort["text-asc"]=function(e,t){return e.localeCompare(t,document.documentElement.lang,{sensitivity:"base"})},$.fn.dataTableExt.oSort["text-desc"]=function(e,t){return t.localeCompare(e,document.documentElement.lang,{sensitivity:"base"})},$("table.datatables").each((function(){$(this).DataTable(),$(this).removeClass("d-none")})),document.querySelectorAll("[data-wt-persist]").forEach((function(e){return webtrees.persistentToggle(e)})),$(".wt-osk-trigger").click((function(){(e=document.getElementById(this.dataset.wtId)).focus(),$(".wt-osk").show()})),$(".wt-osk-script-button").change((function(){$(".wt-osk-script").prop("hidden",!0),$(".wt-osk-script-"+this.dataset.wtOskScript).prop("hidden",!1)})),$(".wt-osk-shift-button").click((function(){document.querySelector(".wt-osk-keys").classList.toggle("shifted")})),$(".wt-osk-keys").on("click",".wt-osk-key",(function(){var t=$(this).contents().get(0).nodeValue,n=$(".wt-osk-shift-button").hasClass("active"),o=$("sup",this)[0];n&&void 0!==o&&(t=o.innerText),webtrees.pasteAtCursor(e,t),!1===$(".wt-osk-pin-button").hasClass("active")&&$(".wt-osk").hide(),e.dispatchEvent(new Event("input"))})),$(".wt-osk-close").on("click",(function(){$(".wt-osk").hide()})),$("input[type=password]").each((function(){$(this).hideShowPassword("infer",!0,{states:{shown:{toggle:{content:this.dataset.wtHidePasswordText,attr:{title:this.dataset.wtHidePasswordTitle,"aria-label":this.dataset.wtHidePasswordTitle}}},hidden:{toggle:{content:this.dataset.wtShowPasswordText,attr:{title:this.dataset.wtShowPasswordTitle,"aria-label":this.dataset.wtShowPasswordTitle}}}}})}))})),document.addEventListener("submit",(function(e){"POST"===e.target.method&&(e.target.classList.contains("form-is-submitting")?e.preventDefault():e.target.classList.add("form-is-submitting"))})),document.addEventListener("click",(function(e){var t=e.target.closest("a,button");if(null!==t)if(!("wtConfirm"in t.dataset)||confirm(t.dataset.wtConfirm)){if("wtPostUrl"in t.dataset&&webtrees.httpPost(t.dataset.wtPostUrl).then((function(){"wtReloadUrl"in t.dataset?document.location=t.dataset.wtReloadUrl:document.location.reload()})).catch((function(e){alert(e)})),"wtFullscreen"in t.dataset){e.stopPropagation();var n=t.closest(t.dataset.wtFullscreen);document.fullscreenElement===n?document.exitFullscreen().catch((function(e){return alert(e)})):n.requestFullscreen().catch((function(e){return alert(e)}))}}else e.preventDefault()}));var GOOGLE_CHARTS_LIB="https://www.gstatic.com/charts/loader.js",Statistics=function(){return _createClass((function e(){return _classCallCheck(this,e),e.instance||(e.instance=this,this.callbacks=[],this.initialized=!1,this.loading=!1),e.instance}),[{key:"init",value:function(e){if(!this.loading&&!this.initialized){var t=this;Promise.all([this.load(GOOGLE_CHARTS_LIB)]).then((function(){google.charts.load("current",{packages:["corechart","geochart","bar"],language:e,mapsApiKey:""}),google.charts.setOnLoadCallback((function(){t.callbacks.forEach((function(e){e()}))})),t.initialized=!0})).catch((function(e){console.log(e)}))}}},{key:"load",value:function(e){if(!this.loading)return this.loading=!0,new Promise((function(t,n){var o=document.createElement("script");o.async=!0,o.onload=function(){t(e)},o.onerror=function(){n(e)},o.src=e,document.body.appendChild(o)}))}},{key:"addCallback",value:function(e){this.initialized?google.charts.setOnLoadCallback(e):this.callbacks.push(e),$(window).resize((function(){e()}))}},{key:"drawChart",value:function(e,t,n,o){var r=google.visualization.arrayToDataTable(n);new google.visualization.ChartWrapper({chartType:t,dataTable:r,options:o,containerId:e}).draw()}},{key:"drawPieChart",value:function(e,t,n){n=Object.assign({title:"",height:"100%",width:"100%",pieStartAngle:0,pieSliceText:"none",pieSliceTextStyle:{color:"#777"},pieHole:.4,legend:{alignment:"center",labeledValueText:"value",position:"labeled"},chartArea:{left:0,top:"5%",height:"90%",width:"100%"},tooltip:{trigger:"none",text:"both"},backgroundColor:"transparent",colors:[]},n),this.drawChart(e,"PieChart",t,n)}},{key:"drawColumnChart",value:function(e,t,n){n=Object.assign({title:"",subtitle:"",titleTextStyle:{color:"#757575",fontName:"Roboto",fontSize:"16px",bold:!1,italic:!1},height:"100%",width:"100%",vAxis:{title:""},hAxis:{title:""},legend:{position:"none"},backgroundColor:"transparent"},n),this.drawChart(e,"ColumnChart",t,n)}},{key:"drawComboChart",value:function(e,t,n){n=Object.assign({title:"",subtitle:"",titleTextStyle:{color:"#757575",fontName:"Roboto",fontSize:"16px",bold:!1,italic:!1},height:"100%",width:"100%",vAxis:{title:""},hAxis:{title:""},legend:{position:"none"},seriesType:"bars",series:{2:{type:"line"}},colors:[],backgroundColor:"transparent"},n),this.drawChart(e,"ComboChart",t,n)}},{key:"drawGeoChart",value:function(e,t,n){n=Object.assign({title:"",subtitle:"",height:"100%",width:"100%"},n),this.drawChart(e,"GeoChart",t,n)}}])}(),statistics=new Statistics;function TreeViewHandler(e,t){var n,o,r,a,i=this;this.treeview=$("#"+e+"_in"),this.loadingImage=$("#"+e+"_loading"),this.toolbox=$("#tv_tools"),this.buttons=$(".tv_button:first",this.toolbox),this.zoom=100,this.boxWidth=180,this.boxExpandedWidth=250,this.cookieDays=3,this.ajaxDetails=document.getElementById(e+"_out").dataset.urlDetails+"&instance="+encodeURIComponent(e),this.ajaxPersons=document.getElementById(e+"_out").dataset.urlIndividuals+"&instance="+encodeURIComponent(e),this.container=this.treeview.parent(),this.auto_box_width=!1,this.updating=!1,"true"===readCookie("compact")&&i.compact(),r=!1,a=!1,i.treeview.on("mousedown touchstart",(function(e){var t="touchstart"===e.type?e.touches[0].pageX:e.pageX,r="touchstart"===e.type?e.touches[0].pageY:e.pageY;n=i.treeview.offset().left-t,o=i.treeview.offset().top-r,a=!0})),$(document).on("mousemove touchmove",(function(e){if(a){e.preventDefault(),r=!0;var t="touchmove"===e.type?e.touches[0].pageX:e.pageX,l="touchmove"===e.type?e.touches[0].pageY:e.pageY;i.treeview.offset({left:t+n,top:l+o})}})),$(document).on("mouseup touchend",(function(e){a=!1,r&&(e.preventDefault(),r=!1,i.updateTree())})),i.toolbox.find("#tvbCompact").each((function(e,t){t.onclick=function(){i.compact()}})),i.toolbox.find("#tvbAllPartners").each((function(e,t){t.onclick=function(){createCookie("allPartners","true"===readCookie("allPartners")?"false":"true",i.cookieDays),document.location=document.location}})),i.toolbox.find("#tvbOpen").each((function(e,t){var n=$(t,i.toolbox);t.onclick=function(){n.addClass("tvPressed"),i.setLoading();var e=jQuery.Event("click");i.treeview.find(".tv_box:not(.boxExpanded)").each((function(t,n){var o=$(n,i.treeview).offset();o.left>=i.leftMin&&o.left<=i.leftMax&&o.top>=i.topMin&&o.top<=i.topMax&&i.expandBox(n,e)})),n.removeClass("tvPressed"),i.setComplete()}})),i.toolbox.find("#tvbClose").each((function(e,t){var n=$(t,i.toolbox);t.onclick=function(){n.addClass("tvPressed"),i.setLoading(),i.treeview.find(".tv_box.boxExpanded").each((function(e,t){$(t).css("display","none").removeClass("boxExpanded").parent().find(".tv_box.collapsedContent").css("display","block")})),n.removeClass("tvPressed"),i.setComplete()}})),i.centerOnRoot()}function createCookie(e,t,n){if(n){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),document.cookie=e+"="+t+"; expires="+o.toGMTString()+"; path=/"}else document.cookie=e+"="+t+"; path=/"}function readCookie(e){for(var t=e+"=",n=document.cookie.split(";"),o=0;o=n.leftMin&&a.left<=n.leftMax&&a.top>=n.topMin&&a.top<=n.topMax&&(o.push(t.attr("abbr")),r.push(t))})),o.length>0?(n.updating=!0,n.setLoading(),jQuery.ajax({url:n.ajaxPersons,dataType:"json",data:"q="+o.join(";"),success:function(e){for(var t=r.length,o=($(".rootPerson",this.treeview).offset().left,0);oe.length)&&(t=e.length);for(var n=0,o=Array(t);n1&&void 0!==arguments[1]?arguments[1]:"",n=document.head.querySelector("meta[name=csrf]").getAttribute("content"),o={body:t,method:"POST",credentials:"same-origin",referrerPolicy:"same-origin",headers:new Headers({"X-CSRF-TOKEN":n,"x-requested-with":"XMLHttpRequest"})};return fetch(e,o,t)},e.detectScript=function(e){for(var t in n)if(e.match(n[t]))return t;return"Latn"},e.buildNameFromParts=function(n,r,a,i,l,s){var c="Han"===e.detectScript(n+r+a+r+i+l),d=c?"":" ",u=c||-1!==["hu","jp","ko","vi","zh-Hans","zh-Hant"].indexOf(t),p=-1!==["is"].indexOf(t)?"":"/";n=o(n),r=o(r.replace(/,/g,d)),a=o(a),i=function(e,n){return"pl"===t&&"F"===n?e.replace(/ski$/,"ska").replace(/cki$/,"cka").replace(/dzki$/,"dzka").replace(/żki$/,"żka"):e}(o(i.replace(/,/g,d)),s),l=o(l);var f=a.endsWith("'")||a.endsWith("‘")?"":" ",h=o(a+f+i);return o(n+d+(u?p+h+p+d+r:r+d+p+h+p)+d+l)},e.pasteAtCursor=function(e,t){if(null!==e){var n=e.selectionStart+t.length,o=e.value.substring(0,e.selectionStart),r=e.value.substring(e.selectionEnd);e.value=o+t+r,e.setSelectionRange(n,n),e.focus()}},e.reformatDate=function(e,t){var n=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],o=e.value,r=o.split("("),a="";r.length>1&&(o=r[0],a=r[1]),(o=(o=(o=(o=(o=o.toUpperCase()).replace(/\s+/g," ")).replace(/(^\s)|(\s$)/,"")).replace(/(\d)([A-Z])/g,"$1 $2")).replace(/([A-Z])(\d)/g,"$1 $2")).match(/^Q ([1-4]) (\d\d\d\d)$/)&&(o="BET "+n[3*RegExp.$1-3]+" "+RegExp.$2+" AND "+n[3*RegExp.$1-1]+" "+RegExp.$2),o.match(/^(@#DHIJRI@|HIJRI)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DHIJRI@"+RegExp.$2+["MUHAR","SAFAR","RABIA","RABIT","JUMAA","JUMAT","RAJAB","SHAAB","RAMAD","SHAWW","DHUAQ","DHUAH"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o.match(/^(@#DJALALI@|JALALI)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DJALALI@"+RegExp.$2+["FARVA","ORDIB","KHORD","TIR","MORDA","SHAHR","MEHR","ABAN","AZAR","DEY","BAHMA","ESFAN"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o.match(/^(@#DHEBREW@|HEBREW)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DHEBREW@"+RegExp.$2+["TSH","CSH","KSL","TVT","SHV","ADR","ADS","NSN","IYR","SVN","TMZ","AAV","ELL"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o.match(/^(@#DFRENCH R@|FRENCH)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(o="@#DFRENCH R@"+RegExp.$2+["VEND","BRUM","FRIM","NIVO","PLUV","VENT","GERM","FLOR","PRAI","MESS","THER","FRUC","COMP"][parseInt(RegExp.$3,10)-1]+RegExp.$4),o=(o=(o=o.replace(/(\d\d)(\d\d)(\d\d)(\d\d)/g,(function(){return RegExp.$1>"12"&&RegExp.$3<="12"&&RegExp.$4<="31"?RegExp.$4+" "+n[RegExp.$3-1]+" "+RegExp.$1+RegExp.$2:RegExp.$1<="31"&&RegExp.$2<="12"&&RegExp.$3>"12"?RegExp.$1+" "+n[RegExp.$2-1]+" "+RegExp.$3+RegExp.$4:RegExp.$1+RegExp.$2+RegExp.$3+RegExp.$4}))).replace(/(\d+)([ ./-])(\d+)(\2)(\d+)/g,(function(){var e=parseInt(RegExp.$1,10),o=parseInt(RegExp.$3,10),r=parseInt(RegExp.$5,10),a=(new Date).getFullYear(),i=a%100,l=a-i;return("DMY"===t||e>13&&r>31)&&e<=31&&o<=12?e+" "+n[o-1]+" "+(r>=100?r:r<=i?r+l:r+l-100):("MDY"===t||o>13&&r>31)&&e<=12&&o<=31?o+" "+n[e-1]+" "+(r>=100?r:r<=i?r+l:r+l-100):("YMD"===t||e>31)&&o<=12&&r<=31?r+" "+n[o-1]+" "+(e>=100?e:e<=i?e+l:e+l-100):RegExp.$1+RegExp.$2+RegExp.$3+RegExp.$4+RegExp.$5}))).replace(/^[>]([\w ]+)$/,"AFT $1").replace(/^[<]([\w ]+)$/,"BEF $1").replace(/^([\w ]+)[-]$/,"FROM $1").replace(/^[-]([\w ]+)$/,"TO $1").replace(/^[~]([\w ]+)$/,"ABT $1").replace(/^[*]([\w ]+)$/,"EST $1").replace(/^[#]([\w ]+)$/,"CAL $1").replace(/^([\w ]+) ?- ?([\w ]+)$/,"BET $1 AND $2").replace(/^([\w ]+) ?~ ?([\w ]+)$/,"FROM $1 TO $2").replace(/JANUARY/g,"JAN").replace(/FEBRUARY/g,"FEB").replace(/MARCH/g,"MAR").replace(/APRIL/g,"APR").replace(/JUNE/g,"JUN").replace(/JULY/g,"JUL").replace(/AUGUST/g,"AUG").replace(/SEPTEMBER/g,"SEP").replace(/OCTOBER/,"OCT").replace(/NOVEMBER/g,"NOV").replace(/DECEMBER/g,"DEC").replace(/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\.? (\d\d?)[, ]+(\d\d\d\d)/g,"$2 $1 $3").replace(/(^| )(\d [A-Z]{3,5} \d{4})/g,"$10$2"),a&&(o=o+" ("+a),e.value!==o&&(e.value=o)};var r=[];r[1]="January",r[2]="February",r[3]="March",r[4]="April",r[5]="May",r[6]="June",r[7]="July",r[8]="August",r[9]="September",r[10]="October",r[11]="November",r[12]="December";var a=[];a[1]="JAN",a[2]="FEB",a[3]="MAR",a[4]="APR",a[5]="MAY",a[6]="JUN",a[7]="JUL",a[8]="AUG",a[9]="SEP",a[10]="OCT",a[11]="NOV",a[12]="DEC";var i=[];i[0]="S",i[1]="M",i[2]="T",i[3]="W",i[4]="T",i[5]="F",i[6]="S";var l=0;function s(e,t,n){var o,a,s='';for(s+='",s+='",s+='",s+='",s+="
',s+='',s+="",a=l,o=0;o<7;o++)s+="";var c=new Date(n.getFullYear(),n.getMonth(),1),d=c.getDay();d-=l;var u=864e5;for(c=c.getTime()-d*u+432e5,c=new Date(c),a=0;a<6;a++){for(s+="",o=0;o<7;o++){s+="";var p=c.getTime()+u;c=new Date(p)}s+=""}return s+="
",++a>6&&(a=0);s+="
',s+=c.getDate(),s+="
",s+="
"}function c(e,t,n,o){return document.getElementById(e).value=(o<10?"0":"")+o+" "+a[n+1]+" "+t,!1}function d(e,t,n){var o=e.value.toUpperCase();(o=(o=(o=(o=(o=(o=(o=(o=(o=(o=o.replace(/(^\s*)|(\s*$)/g,"")).replace(/ /g,":")).replace(/\+/g,"")).replace(/-/g,n)).replace(/,/g,".")).replace(/\u00b0/g,":")).replace(/\u0027/g,":")).replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g,(function(e,t,n,o,r){var a=parseFloat(t);return a+=n/60,a+=o/3600,r+(a=Math.round(1e4*a)/1e4)}))).replace(/^([0-9]+):([0-9]+)(.*)/g,(function(e,t,n,o){var r=parseFloat(t);return r+=n/60,o+(r=Math.round(1e4*r)/1e4)}))).replace(/(.*)(NSEW])$/g,"$2$1"))&&o.charAt(0)!==n&&o.charAt(0)!==t&&(o=t+o),e.value=o}e.calLocalize=function(e,t,n,o,a,s,c,d,u,p,f,h,g,m,v,b,y,w,x,E){r[1]=e,r[2]=t,r[3]=n,r[4]=o,r[5]=a,r[6]=s,r[7]=c,r[8]=d,r[9]=u,r[10]=p,r[11]=f,r[12]=h,i[0]=g,i[1]=m,i[2]=v,i[3]=b,i[4]=y,i[5]=w,i[6]=x,E>=0&&E<7&&(l=E)},e.calendarWidget=function(e,t){var n=document.getElementById(e),o=document.getElementById(t);if("visible"===n.style.visibility)return n.style.visibility="hidden",!1;if("show"===n.style.visibility)return n.style.visibility="hide",!1;var r;if(/(?:(\d*) ?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) )?(\d+)/i.exec(o.value)){var a=RegExp.$1||"1",i=RegExp.$2||"JAN",l=RegExp.$3;r=new Date(a+" "+i+" "+l)}else r=new Date;return n.innerHTML=s(t,e,r),"hidden"===n.style.visibility?(n.style.visibility="visible",!1):"hide"===n.style.visibility&&(n.style.visibility="show",!1)},e.calUpdateCalendar=function(e,t){var n=document.getElementById(e+"_daySelect");if(!n)return!1;var o=document.getElementById(e+"_monSelect");if(!o)return!1;var r=document.getElementById(e+"_yearInput");if(!r)return!1;var a=parseInt(o.options[o.selectedIndex].value,10);a-=1;var i=new Date(r.value,a,n.options[n.selectedIndex].value);c(e,i.getFullYear(),i.getMonth(),i.getDate());var l=document.getElementById(t);return l?(l.innerHTML=s(e,t,i),!1):(alert("no dateDiv "+t),!1)},e.calDateClicked=function(t,n,o,r,a){return c(t,o,r,a),e.calendarWidget(n,t),!1},e.persistentToggle=function(e){var t,n="state-of-"+e.dataset.wtPersist,o=localStorage.getItem(n),r=null!==(t=e.getAttribute("aria-expanded"))&&void 0!==t?t:e.checked.toString();null!==o&&o!==r&&e.click(),e.addEventListener("click",(function(){"checkbox"===e.type&&localStorage.setItem(n,e.checked.toString()),"button"===e.type&&localStorage.setItem(n,e.getAttribute("aria-expanded"))}))},e.reformatLatitude=function(e){return d(e,"N","S")},e.reformatLongitude=function(e){return d(e,"E","W")},e.autocomplete=function(e){$(e).each((function(){var e=this;$(this).typeahead(null,{display:"value",limit:10,minLength:2,source:new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("value"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:this.dataset.wtAutocompleteUrl,replace:function(t,n){var o=t.indexOf("?")>0?"&":"?";if("SOUR"===e.dataset.wtAutocompleteExtra){for(var r=e.closest(".wt-nested-edit-fields").previousElementSibling;null===r.querySelector("select");)r=r.previousElementSibling;var a=r.querySelector("select"),i=a.options[a.selectedIndex].value.replace(/@/g,"");return t+o+"query="+n+"&extra="+encodeURIComponent(i)}return t+o+"query="+n}}})})}))},e.buildLeafletJsMap=function(e,t,n){for(var o=new L.control.zoom({zoomInTitle:t.i18n.zoomIn,zoomoutTitle:t.i18n.zoomOut}),r=L.Control.extend({options:{position:"topleft"},onAdd:function(){var e=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-custom"),o=L.DomUtil.create("a","leaflet-control-reset",e);return o.href="#",o.setAttribute("aria-label",t.i18n.reset),o.title=t.i18n.reset,o.setAttribute("role","button"),o.innerHTML=t.icons.reset,o.onclick=n,e}}),a=L.Control.extend({options:{position:"topleft"},onAdd:function(e){var n=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-custom"),o=L.DomUtil.create("a","leaflet-control-fullscreen",n);return o.href="#",o.setAttribute("role","button"),o.dataset.wtFullscreen=".wt-fullscreen-container",o.innerHTML=t.icons.fullScreen,n}}),i=null,l=0,s=Object.entries(t.mapProviders);l"+e.text+""},option:function(e,t){return"
"+e.text+"
"},no_results:function(e,n){return'
'+t.dataset.wtI18nNoResults+"
"}},firstUrl:function(e){return t.dataset.wtUrl+"&query="+encodeURIComponent(e)},load:function(t,n){var o=this;e.httpGet(this.getUrl(t)).then((function(e){return e.json()})).then((function(e){null!==e.nextUrl&&o.setNextUrl(t,e.nextUrl+"&query="+encodeURIComponent(t)),n(e.data)})).catch(n)}};return t.required||n.plugins.push("clear_button"),new TomSelect(t,n)}return t.multiple?new TomSelect(t,{plugins:["caret_position","remove_button"]}):t.required?new TomSelect(t,{}):new TomSelect(t,{plugins:["clear_button"]})},e.resetTomSelect=function(e,t,n){e.clear(!0),e.clearOptions(),e.addOption({value:t,text:n}),e.refreshOptions(),e.addItem(t,!0),e.refreshItems()},e.initializeIFSRO=function(e,t){e.addEventListener("change",(function(){t.querySelectorAll(".select-record").forEach((function(e){return e.classList.add("d-none")})),t.querySelectorAll(".select-"+e.value).forEach((function(e){return e.classList.remove("d-none")})),t.querySelectorAll(".select-record select").forEach((function(e){e.disabled=!0,e.matches(".tom-select")&&e.tomselect.disable()})),t.querySelectorAll(".select-"+e.value+" select").forEach((function(e){e.disabled=!1,e.matches(".tom-select")&&e.tomselect.enable()}))}))},e.createRecordModalSubmit=function(t){t.preventDefault();var n=t.target,o=document.getElementById("wt-ajax-modal"),r=o.querySelector(".modal-content"),a=document.getElementById(r.dataset.wtSelectId);e.httpPost(n.action,new FormData(n)).then((function(e){return e.json()})).then((function(t){a&&""!==t.value?(e.resetTomSelect(a.tomselect,t.value,t.text),bootstrap.Modal.getInstance(o).hide()):r.innerHTML=t.html})).catch((function(e){r.innerHTML=e}))},e.textareaPatterns=function(e){e.addEventListener("submit",(function(e){e.target.querySelectorAll("textarea[data-wt-pattern]").forEach((function(t){var n=new RegExp("^"+t.dataset.wtPattern+"$");t.readOnly||""===t.value||n.test(t.value)?t.classList.remove("is-invalid"):(e.preventDefault(),e.stopPropagation(),t.classList.add("is-invalid"),t.scrollIntoView())}))}))}}(window.webtrees=window.webtrees||{}),$.ajaxSetup({headers:{"X-CSRF-TOKEN":$("meta[name=csrf]").attr("content")}}),$((function(){var e;$("[data-wt-ajax-url]").each((function(){$(this).load(this.dataset.wtAjaxUrl)})),webtrees.autocomplete("input[data-wt-autocomplete-url]"),document.querySelectorAll(".tom-select").forEach((function(e){return webtrees.initializeTomSelect(e)})),document.querySelectorAll("select.tom-select:not([multiple])").forEach((function(e){e.addEventListener("clear",(function(){webtrees.resetTomSelect(e.tomselect,"","")}))})),$.fn.dataTableExt.oSort["text-asc"]=function(e,t){return e.localeCompare(t,document.documentElement.lang,{sensitivity:"base"})},$.fn.dataTableExt.oSort["text-desc"]=function(e,t){return t.localeCompare(e,document.documentElement.lang,{sensitivity:"base"})},$("table.datatables").each((function(){$(this).DataTable(),$(this).removeClass("d-none")})),document.querySelectorAll("[data-wt-persist]").forEach((function(e){return webtrees.persistentToggle(e)})),$(".wt-osk-trigger").click((function(){(e=document.getElementById(this.dataset.wtId)).focus(),$(".wt-osk").show()})),$(".wt-osk-script-button").change((function(){$(".wt-osk-script").prop("hidden",!0),$(".wt-osk-script-"+this.dataset.wtOskScript).prop("hidden",!1)})),$(".wt-osk-shift-button").click((function(){document.querySelector(".wt-osk-keys").classList.toggle("shifted")})),$(".wt-osk-keys").on("click",".wt-osk-key",(function(){var t=$(this).contents().get(0).nodeValue,n=$(".wt-osk-shift-button").hasClass("active"),o=$("sup",this)[0];n&&void 0!==o&&(t=o.innerText),webtrees.pasteAtCursor(e,t),!1===$(".wt-osk-pin-button").hasClass("active")&&$(".wt-osk").hide(),e.dispatchEvent(new Event("input"))})),$(".wt-osk-close").on("click",(function(){$(".wt-osk").hide()})),$("input[type=password]").each((function(){$(this).hideShowPassword("infer",!0,{states:{shown:{toggle:{content:this.dataset.wtHidePasswordText,attr:{title:this.dataset.wtHidePasswordTitle,"aria-label":this.dataset.wtHidePasswordTitle}}},hidden:{toggle:{content:this.dataset.wtShowPasswordText,attr:{title:this.dataset.wtShowPasswordTitle,"aria-label":this.dataset.wtShowPasswordTitle}}}}})}))})),document.addEventListener("submit",(function(e){"POST"===e.target.method&&(e.target.classList.contains("form-is-submitting")?e.preventDefault():e.target.classList.add("form-is-submitting"))})),document.addEventListener("click",(function(e){var t=e.target.closest("a,button");if(null!==t)if(!("wtConfirm"in t.dataset)||confirm(t.dataset.wtConfirm)){if("wtPostUrl"in t.dataset&&webtrees.httpPost(t.dataset.wtPostUrl).then((function(){"wtReloadUrl"in t.dataset?document.location=t.dataset.wtReloadUrl:document.location.reload()})).catch((function(e){alert(e)})),"wtFullscreen"in t.dataset){e.stopPropagation();var n=t.closest(t.dataset.wtFullscreen);document.fullscreenElement===n?document.exitFullscreen().catch((function(e){return alert(e)})):n.requestFullscreen().catch((function(e){return alert(e)}))}}else e.preventDefault()}));var GOOGLE_CHARTS_LIB="https://www.gstatic.com/charts/loader.js",Statistics=function(){return _createClass((function e(){return _classCallCheck(this,e),e.instance||(e.instance=this,this.callbacks=[],this.initialized=!1,this.loading=!1),e.instance}),[{key:"init",value:function(e){if(!this.loading&&!this.initialized){var t=this;Promise.all([this.load(GOOGLE_CHARTS_LIB)]).then((function(){google.charts.load("current",{packages:["corechart","geochart","bar"],language:e,mapsApiKey:""}),google.charts.setOnLoadCallback((function(){t.callbacks.forEach((function(e){e()}))})),t.initialized=!0})).catch((function(e){console.log(e)}))}}},{key:"load",value:function(e){if(!this.loading)return this.loading=!0,new Promise((function(t,n){var o=document.createElement("script");o.async=!0,o.onload=function(){t(e)},o.onerror=function(){n(e)},o.src=e,document.body.appendChild(o)}))}},{key:"addCallback",value:function(e){this.initialized?google.charts.setOnLoadCallback(e):this.callbacks.push(e),$(window).resize((function(){e()}))}},{key:"drawChart",value:function(e,t,n,o){var r=google.visualization.arrayToDataTable(n);new google.visualization.ChartWrapper({chartType:t,dataTable:r,options:o,containerId:e}).draw()}},{key:"drawPieChart",value:function(e,t,n){n=Object.assign({title:"",height:"100%",width:"100%",pieStartAngle:0,pieSliceText:"none",pieSliceTextStyle:{color:"#777"},pieHole:.4,legend:{alignment:"center",labeledValueText:"value",position:"labeled"},chartArea:{left:0,top:"5%",height:"90%",width:"100%"},tooltip:{trigger:"none",text:"both"},backgroundColor:"transparent",colors:[]},n),this.drawChart(e,"PieChart",t,n)}},{key:"drawColumnChart",value:function(e,t,n){n=Object.assign({title:"",subtitle:"",titleTextStyle:{color:"#757575",fontName:"Roboto",fontSize:"16px",bold:!1,italic:!1},height:"100%",width:"100%",vAxis:{title:""},hAxis:{title:""},legend:{position:"none"},backgroundColor:"transparent"},n),this.drawChart(e,"ColumnChart",t,n)}},{key:"drawComboChart",value:function(e,t,n){n=Object.assign({title:"",subtitle:"",titleTextStyle:{color:"#757575",fontName:"Roboto",fontSize:"16px",bold:!1,italic:!1},height:"100%",width:"100%",vAxis:{title:""},hAxis:{title:""},legend:{position:"none"},seriesType:"bars",series:{2:{type:"line"}},colors:[],backgroundColor:"transparent"},n),this.drawChart(e,"ComboChart",t,n)}},{key:"drawGeoChart",value:function(e,t,n){n=Object.assign({title:"",subtitle:"",height:"100%",width:"100%"},n),this.drawChart(e,"GeoChart",t,n)}}])}(),statistics=new Statistics;function TreeViewHandler(e,t){var n,o,r,a,i=this;this.treeview=$("#"+e+"_in"),this.loadingImage=$("#"+e+"_loading"),this.toolbox=$("#tv_tools"),this.buttons=$(".tv_button:first",this.toolbox),this.zoom=100,this.boxWidth=180,this.boxExpandedWidth=250,this.cookieDays=3,this.ajaxDetails=document.getElementById(e+"_out").dataset.urlDetails+"&instance="+encodeURIComponent(e),this.ajaxPersons=document.getElementById(e+"_out").dataset.urlIndividuals+"&instance="+encodeURIComponent(e),this.container=this.treeview.parent(),this.auto_box_width=!1,this.updating=!1,"true"===readCookie("compact")&&i.compact(),r=!1,a=!1,i.treeview.on("mousedown touchstart",(function(e){var t="touchstart"===e.type?e.touches[0].pageX:e.pageX,r="touchstart"===e.type?e.touches[0].pageY:e.pageY;n=i.treeview.offset().left-t,o=i.treeview.offset().top-r,a=!0})),$(document).on("mousemove touchmove",(function(e){if(a){e.preventDefault(),r=!0;var t="touchmove"===e.type?e.touches[0].pageX:e.pageX,l="touchmove"===e.type?e.touches[0].pageY:e.pageY;i.treeview.offset({left:t+n,top:l+o})}})),$(document).on("mouseup touchend",(function(e){a=!1,r&&(e.preventDefault(),r=!1,i.updateTree())})),i.toolbox.find("#tvbCompact").each((function(e,t){t.onclick=function(){i.compact()}})),i.toolbox.find("#tvbAllPartners").each((function(e,t){t.onclick=function(){createCookie("allPartners","true"===readCookie("allPartners")?"false":"true",i.cookieDays),document.location=document.location}})),i.toolbox.find("#tvbOpen").each((function(e,t){var n=$(t,i.toolbox);t.onclick=function(){n.addClass("tvPressed"),i.setLoading();var e=jQuery.Event("click");i.treeview.find(".tv_box:not(.boxExpanded)").each((function(t,n){var o=$(n,i.treeview).offset();o.left>=i.leftMin&&o.left<=i.leftMax&&o.top>=i.topMin&&o.top<=i.topMax&&i.expandBox(n,e)})),n.removeClass("tvPressed"),i.setComplete()}})),i.toolbox.find("#tvbClose").each((function(e,t){var n=$(t,i.toolbox);t.onclick=function(){n.addClass("tvPressed"),i.setLoading(),i.treeview.find(".tv_box.boxExpanded").each((function(e,t){$(t).css("display","none").removeClass("boxExpanded").parent().find(".tv_box.collapsedContent").css("display","block")})),n.removeClass("tvPressed"),i.setComplete()}})),i.centerOnRoot()}function createCookie(e,t,n){if(n){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),document.cookie=e+"="+t+"; expires="+o.toGMTString()+"; path=/"}else document.cookie=e+"="+t+"; path=/"}function readCookie(e){for(var t=e+"=",n=document.cookie.split(";"),o=0;o=n.leftMin&&a.left<=n.leftMax&&a.top>=n.topMin&&a.top<=n.topMax&&(o.push(t.attr("abbr")),r.push(t))})),o.length>0?(n.updating=!0,n.setLoading(),jQuery.ajax({url:n.ajaxPersons,dataType:"json",data:"q="+o.join(";"),success:function(e){for(var t=r.length,o=($(".rootPerson",this.treeview).offset().left,0);o response.json()) .then(json => { - if (select) { + if (select && json.value !== '') { // This modal was activated by the "create new" button in a select edit control. webtrees.resetTomSelect(select.tomselect, json.value, json.text); bootstrap.Modal.getInstance(modal).hide(); } else { - // Show the success message in the existing modal. + // Show the success/fail message in the existing modal. modal_content.innerHTML = json.html; } })