xref: /webtrees/public/js/webtrees.min.js (revision b63ebfff10c4f748c10374a14a84550d3b653912)
1"use strict";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;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,a,r=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw a}}return r}}function _arrayWithHoles(e){if(Array.isArray(e))return e}!function(e){var t=document.documentElement.lang,n={Han:/[\u3400-\u9FCC]/,Grek:/[\u0370-\u03FF]/,Cyrl:/[\u0400-\u04FF]/,Hebr:/[\u0590-\u05FF]/,Arab:/[\u0600-\u06FF]/};function o(e){return e.replace(/\s+/g," ").trim()}e.detectScript=function(e){for(var t in n)if(e.match(n[t]))return t;return"Latn"},e.buildNameFromParts=function(n,a,r,i,l,s){var c="Han"===e.detectScript(n+a+r+a+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),a=o(a.replace(/,/g,d)),r=o(r),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=r.endsWith("'")||r.endsWith("‘")?"":" ",h=o(r+f+i);return o(n+d+(u?p+h+p+d+a:a+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),a=e.value.substring(e.selectionEnd);e.value=o+t+a,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,a=o.split("("),r="";a.length>1&&(o=a[0],r=a[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),a=parseInt(RegExp.$5,10),r=(new Date).getFullYear(),i=r%100,l=r-i;return("DMY"===t||e>13&&a>31)&&e<=31&&o<=12?e+" "+n[o-1]+" "+(a>=100?a:a<=i?a+l:a+l-100):("MDY"===t||o>13&&a>31)&&e<=12&&o<=31?o+" "+n[e-1]+" "+(a>=100?a:a<=i?a+l:a+l-100):("YMD"===t||e>31)&&o<=12&&a<=31?a+" "+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"),r&&(o=o+" ("+r),e.value!==o&&(e.value=o)};var a=[];a[1]="January",a[2]="February",a[3]="March",a[4]="April",a[5]="May",a[6]="June",a[7]="July",a[8]="August",a[9]="September",a[10]="October",a[11]="November",a[12]="December";var r=[];r[1]="JAN",r[2]="FEB",r[3]="MAR",r[4]="APR",r[5]="MAY",r[6]="JUN",r[7]="JUL",r[8]="AUG",r[9]="SEP",r[10]="OCT",r[11]="NOV",r[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,r,s='<table border="1"><tr>';for(s+='<td><select class="form-control" id="'+e+'_daySelect" onchange="return webtrees.calUpdateCalendar(\''+e+"', '"+t+"');\">",o=1;o<32;o++)s+='<option value="'+o+'"',n.getDate()===o&&(s+=' selected="selected"'),s+=">"+o+"</option>";for(s+="</select></td>",s+='<td><select class="form-control" id="'+e+'_monSelect" onchange="return webtrees.calUpdateCalendar(\''+e+"', '"+t+"');\">",o=1;o<13;o++)s+='<option value="'+o+'"',n.getMonth()+1===o&&(s+=' selected="selected"'),s+=">"+a[o]+"</option>";for(s+="</select></td>",s+='<td><input class="form-control" type="text" id="'+e+'_yearInput" size="5" value="'+n.getFullYear()+'" onchange="return webtrees.calUpdateCalendar(\''+e+"', '"+t+"');\" /></td></tr>",s+='<tr><td colspan="3">',s+='<table width="100%">',s+="<tr>",r=l,o=0;o<7;o++)s+="<td ",s+='class="descriptionbox"',s+=">",s+=i[r],s+="</td>",++r>6&&(r=0);s+="</tr>";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),r=0;r<6;r++){for(s+="<tr>",o=0;o<7;o++){s+="<td ",c.getMonth()===n.getMonth()?c.getDate()===n.getDate()?s+='class="descriptionbox"':s+='class="optionbox"':s+='style="background-color:#EAEAEA; border: solid #AAAAAA 1px;"',s+='><a href="#" onclick="return webtrees.calDateClicked(\''+e+"', '"+t+"', "+c.getFullYear()+", "+c.getMonth()+", "+c.getDate()+');">',s+=c.getDate(),s+="</a></td>";var p=c.getTime()+u;c=new Date(p)}s+="</tr>"}return s+="</table>",s+="</td></tr>",s+="</table>"}function c(e,t,n,o){return document.getElementById(e).value=(o<10?"0":"")+o+" "+r[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,a){var r=parseFloat(t);return r+=n/60,r+=o/3600,a+(r=Math.round(1e4*r)/1e4)}))).replace(/^([0-9]+):([0-9]+)(.*)/g,(function(e,t,n,o){var a=parseFloat(t);return a+=n/60,o+(a=Math.round(1e4*a)/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,r,s,c,d,u,p,f,h,g,v,m,b,w,y,x,E){a[1]=e,a[2]=t,a[3]=n,a[4]=o,a[5]=r,a[6]=s,a[7]=c,a[8]=d,a[9]=u,a[10]=p,a[11]=f,a[12]=h,i[0]=g,i[1]=v,i[2]=m,i[3]=b,i[4]=w,i[5]=y,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 a;if(/(?:(\d*) ?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) )?(\d+)/i.exec(o.value)){var r=RegExp.$1||"1",i=RegExp.$2||"JAN",l=RegExp.$3;a=new Date(r+" "+i+" "+l)}else a=new Date;return n.innerHTML=s(t,e,a),"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 a=document.getElementById(e+"_yearInput");if(!a)return!1;var r=parseInt(o.options[o.selectedIndex].value,10);r-=1;var i=new Date(a.value,r,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,a,r){return c(t,o,a,r),e.calendarWidget(n,t),!1},e.persistentToggle=function(e){if(e instanceof HTMLInputElement&&"checkbox"===e.type){var t="state-of-"+e.dataset.wtPersist;"true"===localStorage.getItem(t)&&e.click(),e.addEventListener("change",(function(){localStorage.setItem(t,e.checked.toString())}))}},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 a=e.closest(".form-group").parentElement.previousElementSibling;null===a.querySelector("select");)a=a.previousElementSibling;var r=a.querySelector("select"),i=r.options[r.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}),a=L.Control.extend({options:{position:"topleft"},onAdd:function(e){var o=L.DomUtil.create("div","leaflet-bar leaflet-control leaflet-control-custom");o.onclick=n;var a=t.i18n.reset,r=L.DomUtil.create("a","leaflet-control-reset",o);return r.setAttribute("aria-label",a),r.href="#",r.title=a,r.role="button",L.DomEvent.addListener(r,"click",L.DomEvent.preventDefault),L.DomUtil.create("i","fas fa-redo",r).alt=a,o}}),r=null,i=0,l=Object.entries(t.mapProviders);i<l.length;i++)for(var s=_slicedToArray(l[i],2)[1],c=0,d=Object.entries(s.children);c<d.length;c++){var u=_slicedToArray(d[c],2)[1];u.layer="bingMapsKey"in u?L.tileLayer.bing(u):L.tileLayer(u.url,u),s.default&&u.default&&(r=u.layer)}if(null===r){console.log("No default map layer defined - using the first one.");t.mapProviders[0].children[0].layer}return L.map(e,{zoomControl:!1}).addControl(o).addControl(new a).addLayer(r).addControl(L.control.layers.tree(t.mapProviders,null,{closedSymbol:t.icons.expand,openedSymbol:t.icons.collapse}))},e.initializeTomSelect=function(e){if(e.tomselect)return e.tomselect;var t={};if(e.dataset.url){var n=["dropdown_input","virtual_scroll"];e.multiple?n.push("remove_button"):e.required||n.push("clear_button"),t={plugins:n,maxOptions:!1,render:{item:function(e,t){return"<div>"+e.text+"</div>"},option:function(e,t){return"<div>"+e.text+"</div>"}},firstUrl:function(t){return e.dataset.url+"&query="+encodeURIComponent(t)},load:function(e,t){var n=this;fetch(this.getUrl(e)).then((function(e){return e.json()})).then((function(o){null!==o.nextUrl&&n.setNextUrl(e,o.nextUrl+"&query="+encodeURIComponent(e)),t(o.data)})).catch(t)}}}return new TomSelect(e,t)},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(){console.log(e.value),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.tomselect.disable()})),t.querySelectorAll(".select-"+e.value+" select").forEach((function(e){e.disabled=!1,e.tomselect.enable()}))}))}}(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){var t=e.target;t.reportValidity()&&t.addEventListener("submit",(function(e){t.classList.contains("form-is-submitting")&&e.preventDefault(),t.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){var n=document.querySelector("meta[name=csrf]").content;fetch(t.dataset.wtPostUrl,{method:"POST",headers:{"X-CSRF-TOKEN":n,"X-Requested-with":"XMLHttpRequest"}}).then((function(){"wtReloadUrl"in t.dataset?document.location=t.dataset.wtReloadUrl:document.location.reload()})).catch((function(e){alert(e)}))}}else e.preventDefault()}));var GOOGLE_CHARTS_LIB="https://www.gstatic.com/charts/loader.js",Statistics=function(){function e(){return _classCallCheck(this,e),e.instance||(e.instance=this,this.callbacks=[],this.initialized=!1,this.loading=!1),e.instance}return _createClass(e,[{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 a=google.visualization.arrayToDataTable(n);new google.visualization.ChartWrapper({chartType:t,dataTable:a,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)}}]),e}(),statistics=new Statistics;function TreeViewHandler(e,t){var n,o,a,r=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")&&r.compact(),a=!1,r.treeview.on("mousedown touchstart",(function(e){e.preventDefault();var t="touchstart"===e.type?e.touches[0].pageX:e.pageX,i="touchstart"===e.type?e.touches[0].pageY:e.pageY;n=r.treeview.offset().left-t,o=r.treeview.offset().top-i,a=!0})),$(document).on("mousemove touchmove",(function(e){if(a){e.preventDefault();var t="touchmove"===e.type?e.touches[0].pageX:e.pageX,i="touchmove"===e.type?e.touches[0].pageY:e.pageY;r.treeview.offset({left:t+n,top:i+o})}})),$(document).on("mouseup touchend",(function(e){a&&(e.preventDefault(),a=!1,r.updateTree())})),r.toolbox.find("#tvbCompact").each((function(e,t){t.onclick=function(){r.compact()}})),r.toolbox.find("#tvbAllPartners").each((function(e,t){t.onclick=function(){createCookie("allPartners","true"===readCookie("allPartners")?"false":"true",r.cookieDays),document.location=document.location}})),r.toolbox.find("#tvbOpen").each((function(e,t){var n=$(t,r.toolbox);t.onclick=function(){n.addClass("tvPressed"),r.setLoading();var e=jQuery.Event("click");r.treeview.find(".tv_box:not(.boxExpanded)").each((function(t,n){var o=$(n,r.treeview).offset();o.left>=r.leftMin&&o.left<=r.leftMax&&o.top>=r.topMin&&o.top<=r.topMax&&r.expandBox(n,e)})),n.removeClass("tvPressed"),r.setComplete()}})),r.toolbox.find("#tvbClose").each((function(e,t){var n=$(t,r.toolbox);t.onclick=function(){n.addClass("tvPressed"),r.setLoading(),r.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"),r.setComplete()}})),r.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.length;o++){for(var a=n[o];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t))return a.substring(t.length,a.length)}return null}TreeViewHandler.prototype.setLoading=function(){this.treeview.css("cursor","wait"),this.loadingImage.css("display","block")},TreeViewHandler.prototype.setComplete=function(){this.treeview.css("cursor","move"),this.loadingImage.css("display","none")},TreeViewHandler.prototype.getSize=function(){var e=this,t=e.container.parent(),n=t.offset();e.leftMin=n.left,e.leftMax=e.leftMin+t.innerWidth(),e.topMin=n.top,e.topMax=e.topMin+t.innerHeight()},TreeViewHandler.prototype.updateTree=function(e,t){var n=this,o=[],a=[];return this.getSize(),n.treeview.find("td[abbr]").each((function(e,t){var r=(t=$(t,n.treeview)).offset();r.left>=n.leftMin&&r.left<=n.leftMax&&r.top>=n.topMin&&r.top<=n.topMax&&(o.push(t.attr("abbr")),a.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=a.length,o=($(".rootPerson",this.treeview).offset().left,0);o<t;o++)a[o].removeAttr("abbr").html(e[o]);n.getSize()},complete:function(){n.treeview.find("td[abbr]").length&&n.updateTree(e,t),n.auto_box_width&&n.treeview.find(".tv_box").css("width","auto"),n.updating=!0,e&&n.centerOnRoot(),t&&t.removeClass("tvPressed"),n.setComplete(),n.updating=!1},timeout:function(){t&&t.removeClass("tvPressed"),n.updating=!1,n.setComplete()}})):(t&&t.removeClass("tvPressed"),n.setComplete()),!1},TreeViewHandler.prototype.compact=function(){var e=this,t=$("#tvbCompact",e.toolbox);if(e.setLoading(),e.auto_box_width){var n=e.boxWidth*(e.zoom/100)+"px",o=e.boxExpandedWidth*(e.zoom/100)+"px";e.treeview.find(".tv_box:not(boxExpanded)",e.treeview).css("width",n),e.treeview.find(".boxExpanded",e.treeview).css("width",o),e.auto_box_width=!1,readCookie("compact")&&createCookie("compact",!1,e.cookieDays),t.removeClass("tvPressed")}else e.treeview.find(".tv_box").css("width","auto"),e.auto_box_width=!0,readCookie("compact")||createCookie("compact",!0,e.cookieDays),e.updating||e.updateTree(),t.addClass("tvPressed");return e.setComplete(),!1},TreeViewHandler.prototype.centerOnRoot=function(){this.loadingImage.css("display","block");var e=this.container,t=e.innerWidth()/2;if(Number.isNaN(t))return!1;e.innerHeight(),$(".rootPerson",this.treeview);return this.updating||this.setComplete(),!1},TreeViewHandler.prototype.expandBox=function(e,t){if($(t.target).hasClass("tv_link"))return!1;var n,o,a=(e=$(e,this.treeview)).parent(),r=e.attr("abbr"),i=this;if(a.hasClass("detailsLoaded"))o=a.find(".collapsedContent"),n=a.find(".tv_box:not(.collapsedContent)");else{n=e,o=e.clone(),a.append(o.addClass("collapsedContent").css("display","none"));var l=this.loadingImage.find("img").clone().addClass("tv_box_loading").css("display","block");e.prepend(l),i.updating=!0,i.setLoading(),e.load(i.ajaxDetails+"&pid="+encodeURIComponent(r),(function(){"function"==typeof CB_Init&&CB_Init(),e.css("width",i.boxExpandedWidth*(i.zoom/100)+"px"),l.remove(),a.addClass("detailsLoaded"),i.setComplete(),i.updating=!1}))}return e.hasClass("boxExpanded")?(n.css("display","none"),o.css("display","block"),e.removeClass("boxExpanded")):(n.css("display","block"),o.css("display","none"),n.addClass("boxExpanded")),this.getSize(),!1};
2