xref: /webtrees/public/js/webtrees.min.js (revision abdaad0d9fecead08c23d3eb00187f320a625403)
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 a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,a){return t&&_defineProperties(e.prototype,t),a&&_defineProperties(e,a),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 a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function _iterableToArrayLimit(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,o,r=[],i=!0,l=!1;try{for(a=a.call(e);!(i=(n=a.next()).done)&&(r.push(n.value),!t||r.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(l)throw o}}return r}}function _arrayWithHoles(e){if(Array.isArray(e))return e}!function(e){var t=document.documentElement.lang,a={Han:/[\u3400-\u9FCC]/,Grek:/[\u0370-\u03FF]/,Cyrl:/[\u0400-\u04FF]/,Hebr:/[\u0590-\u05FF]/,Arab:/[\u0600-\u06FF]/};function n(e){return e.replace(/\s+/g," ").trim()}e.detectScript=function(e){for(var t in a)if(e.match(a[t]))return t;return"Latn"},e.buildNameFromParts=function(a,o,r,i,l,s){var c="Han"===e.detectScript(a+o+r+o+i+l),d=c?"":" ",u=c||-1!==["hu","jp","ko","vi","zh-Hans","zh-Hant"].indexOf(t),p=-1!==["is"].indexOf(t)?"":"/";a=n(a),o=n(o.replace(/,/g,d)),r=n(r),i=function(e,a){return"pl"===t&&"F"===a?e.replace(/ski$/,"ska").replace(/cki$/,"cka").replace(/dzki$/,"dzka").replace(/żki$/,"żka"):e}(n(i.replace(/,/g,d)),s),l=n(l);var g=n(r+d+i);return n(a+d+(u?p+g+p+d+o:o+d+p+g+p)+d+l)},e.pasteAtCursor=function(e,t){if(null!==e){var a=e.selectionStart+t.length,n=e.value.substring(0,e.selectionStart),o=e.value.substring(e.selectionEnd);e.value=n+t+o,e.setSelectionRange(a,a),e.focus()}},e.reformatDate=function(e,t){var a=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],n=e.value,o=n.split("("),r="";o.length>1&&(n=o[0],r=o[1]),(n=(n=(n=(n=(n=n.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)$/)&&(n="BET "+a[3*RegExp.$1-3]+" "+RegExp.$2+" AND "+a[3*RegExp.$1-1]+" "+RegExp.$2),n.match(/^(@#DHIJRI@|HIJRI)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(n="@#DHIJRI@"+RegExp.$2+["MUHAR","SAFAR","RABIA","RABIT","JUMAA","JUMAT","RAJAB","SHAAB","RAMAD","SHAWW","DHUAQ","DHUAH"][parseInt(RegExp.$3,10)-1]+RegExp.$4),n.match(/^(@#DJALALI@|JALALI)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(n="@#DJALALI@"+RegExp.$2+["FARVA","ORDIB","KHORD","TIR","MORDA","SHAHR","MEHR","ABAN","AZAR","DEY","BAHMA","ESFAN"][parseInt(RegExp.$3,10)-1]+RegExp.$4),n.match(/^(@#DHEBREW@|HEBREW)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(n="@#DHEBREW@"+RegExp.$2+["TSH","CSH","KSL","TVT","SHV","ADR","ADS","NSN","IYR","SVN","TMZ","AAV","ELL"][parseInt(RegExp.$3,10)-1]+RegExp.$4),n.match(/^(@#DFRENCH R@|FRENCH)( \d?\d )(\d?\d)( \d?\d?\d?\d)$/)&&(n="@#DFRENCH R@"+RegExp.$2+["VEND","BRUM","FRIM","NIVO","PLUV","VENT","GERM","FLOR","PRAI","MESS","THER","FRUC","COMP"][parseInt(RegExp.$3,10)-1]+RegExp.$4),n=(n=(n=n.replace(/(\d\d)(\d\d)(\d\d)(\d\d)/g,(function(){return RegExp.$1>"12"&&RegExp.$3<="12"&&RegExp.$4<="31"?RegExp.$4+" "+a[RegExp.$3-1]+" "+RegExp.$1+RegExp.$2:RegExp.$1<="31"&&RegExp.$2<="12"&&RegExp.$3>"12"?RegExp.$1+" "+a[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),n=parseInt(RegExp.$3,10),o=parseInt(RegExp.$5,10),r=(new Date).getFullYear(),i=r%100,l=r-i;return("DMY"===t||e>13&&o>31)&&e<=31&&n<=12?e+" "+a[n-1]+" "+(o>=100?o:o<=i?o+l:o+l-100):("MDY"===t||n>13&&o>31)&&e<=12&&n<=31?n+" "+a[e-1]+" "+(o>=100?o:o<=i?o+l:o+l-100):("YMD"===t||e>31)&&n<=12&&o<=31?o+" "+a[n-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&&(n=n+" ("+r),e.value!==n&&(e.value=n)};var o=[];o[1]="January",o[2]="February",o[3]="March",o[4]="April",o[5]="May",o[6]="June",o[7]="July",o[8]="August",o[9]="September",o[10]="October",o[11]="November",o[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,a){var n,r,s='<table border="1"><tr>';for(s+='<td><select class="form-control" id="'+e+'_daySelect" onchange="return webtrees.calUpdateCalendar(\''+e+"', '"+t+"');\">",n=1;n<32;n++)s+='<option value="'+n+'"',a.getDate()===n&&(s+=' selected="selected"'),s+=">"+n+"</option>";for(s+="</select></td>",s+='<td><select class="form-control" id="'+e+'_monSelect" onchange="return webtrees.calUpdateCalendar(\''+e+"', '"+t+"');\">",n=1;n<13;n++)s+='<option value="'+n+'"',a.getMonth()+1===n&&(s+=' selected="selected"'),s+=">"+o[n]+"</option>";for(s+="</select></td>",s+='<td><input class="form-control" type="text" id="'+e+'_yearInput" size="5" value="'+a.getFullYear()+'" onchange="return webtrees.calUpdateCalendar(\''+e+"', '"+t+"');\" /></td></tr>",s+='<tr><td colspan="3">',s+='<table width="100%">',s+="<tr>",r=l,n=0;n<7;n++)s+="<td ",s+='class="descriptionbox"',s+=">",s+=i[r],s+="</td>",++r>6&&(r=0);s+="</tr>";var c=new Date(a.getFullYear(),a.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>",n=0;n<7;n++){s+="<td ",c.getMonth()===a.getMonth()?c.getDate()===a.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,a,n){return document.getElementById(e).value=(n<10?"0":"")+n+" "+r[a+1]+" "+t,!1}function d(e,t,a){var n=e.value.toUpperCase();(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/(^\s*)|(\s*$)/g,"")).replace(/ /g,":")).replace(/\+/g,"")).replace(/-/g,a)).replace(/,/g,".")).replace(/\u00b0/g,":")).replace(/\u0027/g,":")).replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g,(function(e,t,a,n,o){var r=parseFloat(t);return r+=a/60,r+=n/3600,o+(r=Math.round(1e4*r)/1e4)}))).replace(/^([0-9]+):([0-9]+)(.*)/g,(function(e,t,a,n){var o=parseFloat(t);return o+=a/60,n+(o=Math.round(1e4*o)/1e4)}))).replace(/(.*)(NSEW])$/g,"$2$1"))&&n.charAt(0)!==a&&n.charAt(0)!==t&&(n=t+n),e.value=n}e.calLocalize=function(e,t,a,n,r,s,c,d,u,p,g,f,h,v,m,b,y,x,E,$){o[1]=e,o[2]=t,o[3]=a,o[4]=n,o[5]=r,o[6]=s,o[7]=c,o[8]=d,o[9]=u,o[10]=p,o[11]=g,o[12]=f,i[0]=h,i[1]=v,i[2]=m,i[3]=b,i[4]=y,i[5]=x,i[6]=E,$>=0&&$<7&&(l=$)},e.calendarWidget=function(e,t){var a=document.getElementById(e),n=document.getElementById(t);if("visible"===a.style.visibility)return a.style.visibility="hidden",!1;if("show"===a.style.visibility)return a.style.visibility="hide",!1;var o;if(/(?:(\d*) ?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) )?(\d+)/i.exec(n.value)){var r=RegExp.$1||"1",i=RegExp.$2||"JAN",l=RegExp.$3;o=new Date(r+" "+i+" "+l)}else o=new Date;return a.innerHTML=s(t,e,o),"hidden"===a.style.visibility?(a.style.visibility="visible",!1):"hide"===a.style.visibility&&(a.style.visibility="show",!1)},e.calUpdateCalendar=function(e,t){var a=document.getElementById(e+"_daySelect");if(!a)return!1;var n=document.getElementById(e+"_monSelect");if(!n)return!1;var o=document.getElementById(e+"_yearInput");if(!o)return!1;var r=parseInt(n.options[n.selectedIndex].value,10);r-=1;var i=new Date(o.value,r,a.options[a.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,a,n,o,r){return c(t,n,o,r),e.calendarWidget(a,t),!1},e.persistentToggle=function(e){var t=document.getElementById(e),a="state-of-"+e,n=localStorage.getItem(a);t instanceof HTMLInputElement&&"checkbox"===t.type&&("true"===n&&t.click(),t.addEventListener("change",(function(){localStorage.setItem(a,t.checked)})))},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.autocompleteUrl,replace:function(t,a){if("SOUR"===e.dataset.autocompleteExtra){for(var n=e.closest(".form-group").previousElementSibling;null===n.querySelector("select");)n=n.previousElementSibling;var o=n.querySelector("select"),r=o.options[o.selectedIndex].value.replace(/@/g,""),i=t.indexOf("?")>0?"&":"?";return t.replace(/(%7B|{)query(%7D|})/,a)+i+"extra="+encodeURIComponent(r)}return t.replace(/(%7B|{)query(%7D|})/,a)},wildcard:"{query}"}})})}))},e.buildLeafletJsMap=function(e,t){for(var a=new L.control.zoom({zoomInTitle:t.i18n.zoomIn,zoomoutTitle:t.i18n.zoomOut}),n=null,o=0,r=Object.entries(t.mapProviders);o<r.length;o++)for(var i=_slicedToArray(r[o],2)[1],l=0,s=Object.entries(i.children);l<s.length;l++){var c=_slicedToArray(s[l],2)[1];c.layer="bingMapsKey"in c?L.tileLayer.bing(c):L.tileLayer(c.url,c),i.default&&c.default&&(n=c.layer)}if(null===n){console.log("No default map layer defined - using the first one.");t.mapProviders[0].children[0].layer}return L.map(e,{zoomControl:!1}).addControl(a).addLayer(n).addControl(L.control.layers.tree(t.mapProviders,null,{closedSymbol:t.icons.expand,openedSymbol:t.icons.collapse}))}}(window.webtrees=window.webtrees||{}),$.ajaxSetup({headers:{"X-CSRF-TOKEN":$("meta[name=csrf]").attr("content")}}),$((function(){$("[data-ajax-url]").each((function(){$(this).load($(this).data("ajaxUrl"))})),webtrees.autocomplete("input[data-autocomplete-url]");var e,t=document.documentElement.lang;$("select.select2").select2({language:{"zh-Hans":"zh-CN","zh-Hant":"zh-TW"}[t]||t,width:"100%",escapeMarkup:function(e){return e}}),$("select.select2:not([multiple])").on("select2:unselect",(function(e){$(e.delegateTarget).html('<option value="" selected></option>')})),$.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-toggle=button][data-persist]").forEach((function(e){"T"===localStorage.getItem("state-of-"+e.dataset.persist)&&e.click(),e.addEventListener("click",(function(e){localStorage.setItem("state-of-"+e.target.dataset.persist,e.target.classList.contains("active")?"F":"T")}))})),$(".wt-osk-trigger").click((function(){(e=document.getElementById($(this).data("id"))).focus(),$(".wt-osk").show()})),$(".wt-osk-script-button").change((function(){$(".wt-osk-script").prop("hidden",!0),$(".wt-osk-script-"+$(this).data("script")).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,a=$(".wt-osk-shift-button").hasClass("active"),n=$("sup",this)[0];a&&void 0!==n&&(t=n.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()}))})),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(!("confirm"in t.dataset)||confirm(t.dataset.confirm)){if("postUrl"in t.dataset){var a=document.querySelector("meta[name=csrf]").content;fetch(t.dataset.postUrl,{method:"POST",headers:{"X-CSRF-TOKEN":a,"X-Requested-with":"XMLHttpRequest"}}).then((function(){"reloadUrl"in t.dataset?document.location=t.dataset.reloadUrl: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,a){var n=document.createElement("script");n.async=!0,n.onload=function(){t(e)},n.onerror=function(){a(e)},n.src=e,document.body.appendChild(n)}))}},{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,a,n){var o=google.visualization.arrayToDataTable(a);new google.visualization.ChartWrapper({chartType:t,dataTable:o,options:n,containerId:e}).draw()}},{key:"drawPieChart",value:function(e,t,a){a=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:[]},a),this.drawChart(e,"PieChart",t,a)}},{key:"drawColumnChart",value:function(e,t,a){a=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"},a),this.drawChart(e,"ColumnChart",t,a)}},{key:"drawComboChart",value:function(e,t,a){a=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"},a),this.drawChart(e,"ComboChart",t,a)}},{key:"drawGeoChart",value:function(e,t,a){a=Object.assign({title:"",subtitle:"",height:"100%",width:"100%"},a),this.drawChart(e,"GeoChart",t,a)}}]),e}(),statistics=new Statistics;function TreeViewHandler(e,t){var a,n,o,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(),o=!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;a=r.treeview.offset().left-t,n=r.treeview.offset().top-i,o=!0})),$(document).on("mousemove touchmove",(function(e){if(o){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+a,top:i+n})}})),$(document).on("mouseup touchend",(function(e){o&&(e.preventDefault(),o=!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 a=$(t,r.toolbox);t.onclick=function(){a.addClass("tvPressed"),r.setLoading();var e=jQuery.Event("click");r.treeview.find(".tv_box:not(.boxExpanded)").each((function(t,a){var n=$(a,r.treeview).offset();n.left>=r.leftMin&&n.left<=r.leftMax&&n.top>=r.topMin&&n.top<=r.topMax&&r.expandBox(a,e)})),a.removeClass("tvPressed"),r.setComplete()}})),r.toolbox.find("#tvbClose").each((function(e,t){var a=$(t,r.toolbox);t.onclick=function(){a.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")})),a.removeClass("tvPressed"),r.setComplete()}})),r.centerOnRoot()}function createCookie(e,t,a){if(a){var n=new Date;n.setTime(n.getTime()+24*a*60*60*1e3),document.cookie=e+"="+t+"; expires="+n.toGMTString()+"; path=/"}else document.cookie=e+"="+t+"; path=/"}function readCookie(e){for(var t=e+"=",a=document.cookie.split(";"),n=0;n<a.length;n++){for(var o=a[n];" "===o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(t))return o.substring(t.length,o.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(),a=t.offset();e.leftMin=a.left,e.leftMax=e.leftMin+t.innerWidth(),e.topMin=a.top,e.topMax=e.topMin+t.innerHeight()},TreeViewHandler.prototype.updateTree=function(e,t){var a=this,n=[],o=[];return this.getSize(),a.treeview.find("td[abbr]").each((function(e,t){var r=(t=$(t,a.treeview)).offset();r.left>=a.leftMin&&r.left<=a.leftMax&&r.top>=a.topMin&&r.top<=a.topMax&&(n.push(t.attr("abbr")),o.push(t))})),n.length>0?(a.updating=!0,a.setLoading(),jQuery.ajax({url:a.ajaxPersons,dataType:"json",data:"q="+n.join(";"),success:function(e){for(var t=o.length,n=($(".rootPerson",this.treeview).offset().left,0);n<t;n++)o[n].removeAttr("abbr").html(e[n]);a.getSize()},complete:function(){a.treeview.find("td[abbr]").length&&a.updateTree(e,t),a.auto_box_width&&a.treeview.find(".tv_box").css("width","auto"),a.updating=!0,e&&a.centerOnRoot(),t&&t.removeClass("tvPressed"),a.setComplete(),a.updating=!1},timeout:function(){t&&t.removeClass("tvPressed"),a.updating=!1,a.setComplete()}})):(t&&t.removeClass("tvPressed"),a.setComplete()),!1},TreeViewHandler.prototype.compact=function(){var e=this,t=$("#tvbCompact",e.toolbox);if(e.setLoading(),e.auto_box_width){var a=e.boxWidth*(e.zoom/100)+"px",n=e.boxExpandedWidth*(e.zoom/100)+"px";e.treeview.find(".tv_box:not(boxExpanded)",e.treeview).css("width",a),e.treeview.find(".boxExpanded",e.treeview).css("width",n),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 a,n,o=(e=$(e,this.treeview)).parent(),r=e.attr("abbr"),i=this;if(o.hasClass("detailsLoaded"))n=o.find(".collapsedContent"),a=o.find(".tv_box:not(.collapsedContent)");else{a=e,n=e.clone(),o.append(n.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(),o.addClass("detailsLoaded"),i.setComplete(),i.updating=!1}))}return e.hasClass("boxExpanded")?(a.css("display","none"),n.css("display","block"),e.removeClass("boxExpanded")):(a.css("display","block"),n.css("display","none"),a.addClass("boxExpanded")),this.getSize(),!1};
2