xref: /webtrees/public/js/webtrees.min.js (revision a2a485c37cd2b74783bf6a0721064e22864f4a08)
1"use strict";var pastefield,webtrees=function(){var e=document.documentElement.lang;function t(e){return e.replace(/\s+/g," ").trim()}function a(e){return e.match(/[\u3400-\u9FCC]/)?"cjk":e.match(/[\u0370-\u03FF]/)?"greek":e.match(/[\u0400-\u04FF]/)?"cyrillic":e.match(/[\u0590-\u05FF]/)?"hebrew":e.match(/[\u0600-\u06FF]/)?"arabic":"latin"}return{buildNameFromParts:function(n,o,l,r,i,c){var s="cjk"===a(n+o+l+o+r+i),d=s?"":" ",u=s||-1!==["hu","jp","ko","vi","zh-Hans","zh-Hant"].indexOf(e),p=-1!==["is"].indexOf(e)?"":"/";n=t(n),o=t(o.replace(",",d)),l=t(l),r=function(t,a){return"pl"===e&&"F"===a?t.replace(/ski$/,"ska").replace(/cki$/,"cka").replace(/dzki$/,"dzka").replace(/żki$/,"żka"):t}(t(r.replace(",",d)),c),i=t(i);var m=t(l+d+r);return t(n+d+(u?p+m+p+d+o:o+d+p+m+p)+d+i)},detectScript:a}}();function expand_layer(e){return $("#"+e+"_img").toggleClass("icon-plus icon-minus"),$("#"+e).slideToggle("fast"),$("#"+e+"-alt").toggle(),!1}function accept_changes(e,t){return $.post("index.php",{route:"accept-changes",xref:e,ged:t},function(){document.location.reload()}),!1}function reject_changes(e,t){return $.post("index.php",{route:"reject-changes",xref:e,ged:t},function(){document.location.reload()}),!1}function delete_record(e,t){return $.post("index.php",{route:"delete-record",xref:e,ged:t},function(){document.location.reload()}),!1}function delete_fact(e,t,a,n){return confirm(e)&&$.post("index.php",{route:"delete-fact",xref:a,fact_id:n,ged:t},function(){document.location.reload()}),!1}function copy_fact(e,t,a){return $.post("index.php",{route:"copy-fact",xref:t,fact_id:a,ged:e},function(){document.location.reload()}),!1}function paste_fact(e,t,a){return $.post("index.php",{route:"paste-fact",xref:t,fact_id:$(a).val(),ged:e},function(){document.location.reload()}),!1}function delete_user(e,t){return confirm(e)&&$.post("index.php",{route:"delete-user",user_id:t},function(){document.location.reload()}),!1}function masquerade(e){return $.post("index.php",{route:"masquerade",user_id:e},function(){document.location.reload()}),!1}function addmedia_links(e,t,a){return pastefield=e,insertRowToTable(t,a),!1}function valid_date(e,t){var a=["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"],n=e.value,o=n.split("("),l="";o.length>1&&(n=o[0],l=o[1]),(n=(n=(n=(n=(n=n.toUpperCase()).replace(/\s+/," ")).replace(/(^\s)|(\s$)/,"")).replace(/(\d)([A-Z])/,"$1 $2")).replace(/([A-Z])(\d)/,"$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);if(/^([^\d]*)(\d+)[^\d](\d+)[^\d](\d+)$/i.exec(n)){var r=RegExp.$1,i=parseInt(RegExp.$2,10),c=parseInt(RegExp.$3,10),s=parseInt(RegExp.$4,10),d=(new Date).getFullYear(),u=d%100,p=d-u;"DMY"===t&&i<=31&&c<=12||i>13&&i<=31&&c<=12&&s>31?n=r+i+" "+a[c-1]+" "+(s>=100?s:s<=u?s+p:s+p-100):"MDY"===t&&i<=12&&c<=31||c>13&&c<=31&&i<=12&&s>31?n=r+c+" "+a[i-1]+" "+(s>=100?s:s<=u?s+p:s+p-100):("YMD"===t&&c<=12&&s<=31||s>13&&s<=31&&c<=12&&i>31)&&(n=r+s+" "+a[c-1]+" "+(i>=100?i:i<=u?i+p:i+p-100))}n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.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)/,"JAN")).replace(/(FEBRUARY)/,"FEB")).replace(/(MARCH)/,"MAR")).replace(/(APRIL)/,"APR")).replace(/(MAY)/,"MAY")).replace(/(JUNE)/,"JUN")).replace(/(JULY)/,"JUL")).replace(/(AUGUST)/,"AUG")).replace(/(SEPTEMBER)/,"SEP")).replace(/(OCTOBER)/,"OCT")).replace(/(NOVEMBER)/,"NOV")).replace(/(DECEMBER)/,"DEC")).replace(/(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\.? (\d\d?)[, ]+(\d\d\d\d)/,"$2 $1 $3")).replace(/(^| )(\d [A-Z]{3,5} \d{4})/,"$10$2"),l&&(n=n+" ("+l),e.value!==n&&(e.value=n)}var menutimeouts=[];function show_submenu(e,t){var a=document.body.scrollWidth+document.documentElement.scrollLeft,n=document.getElementById(e);if(n&&n.style){document.all?a=document.body.offsetWidth:(a=document.body.scrollWidth+document.documentElement.scrollLeft-55,"rtl"===document.documentElement.dir&&n.offsetLeft+n.offsetWidth+10);for(var o,l=0,r=n.childNodes.length,i=0;i<r;i++){var c=n.childNodes[i];c.offsetWidth>l+5&&(l=c.offsetWidth)}if(n.offsetWidth<l&&(n.style.width=l+"px"),(o=document.getElementById(t))&&(n.style.left=o.style.left,n.offsetLeft+n.offsetWidth+10>a)){var s=a-n.offsetWidth;n.style.left=s+"px"}n.offsetLeft<0&&(n.style.left="0px"),n.offsetHeight>500&&(n.style.height="400px",n.style.overflow="auto"),n.style.visibility="visible"}clearTimeout(menutimeouts[e]),menutimeouts[e]=null}function hide_submenu(e){if("number"==typeof menutimeouts[e]){var t=document.getElementById(e);t&&t.style&&(t.style.visibility="hidden"),clearTimeout(menutimeouts[e]),menutimeouts[e]=null}}function timeout_submenu(e){"number"!=typeof menutimeouts[e]&&(menutimeouts[e]=setTimeout("hide_submenu('"+e+"')",100))}var monthLabels=[];monthLabels[1]="January",monthLabels[2]="February",monthLabels[3]="March",monthLabels[4]="April",monthLabels[5]="May",monthLabels[6]="June",monthLabels[7]="July",monthLabels[8]="August",monthLabels[9]="September",monthLabels[10]="October",monthLabels[11]="November",monthLabels[12]="December";var monthShort=[];monthShort[1]="JAN",monthShort[2]="FEB",monthShort[3]="MAR",monthShort[4]="APR",monthShort[5]="MAY",monthShort[6]="JUN",monthShort[7]="JUL",monthShort[8]="AUG",monthShort[9]="SEP",monthShort[10]="OCT",monthShort[11]="NOV",monthShort[12]="DEC";var daysOfWeek=[];daysOfWeek[0]="S",daysOfWeek[1]="M",daysOfWeek[2]="T",daysOfWeek[3]="W",daysOfWeek[4]="T",daysOfWeek[5]="F",daysOfWeek[6]="S";var weekStart=0;function cal_setMonthNames(e,t,a,n,o,l,r,i,c,s,d,u){monthLabels[1]=e,monthLabels[2]=t,monthLabels[3]=a,monthLabels[4]=n,monthLabels[5]=o,monthLabels[6]=l,monthLabels[7]=r,monthLabels[8]=i,monthLabels[9]=c,monthLabels[10]=s,monthLabels[11]=d,monthLabels[12]=u}function cal_setDayHeaders(e,t,a,n,o,l,r){daysOfWeek[0]=e,daysOfWeek[1]=t,daysOfWeek[2]=a,daysOfWeek[3]=n,daysOfWeek[4]=o,daysOfWeek[5]=l,daysOfWeek[6]=r}function cal_setWeekStart(e){e>=0&&e<7&&(weekStart=e)}function calendarWidget(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;return o=/((\d+ (JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC) )?\d+)/i.exec(n.value)?new Date(RegExp.$1):new Date,a.innerHTML=cal_generateSelectorContent(t,e,o),"hidden"===a.style.visibility?(a.style.visibility="visible",!1):"hide"===a.style.visibility&&(a.style.visibility="show",!1)}function cal_generateSelectorContent(e,t,a){var n,o,l='<table border="1"><tr>';for(l+='<td><select class="form-control" id="'+e+'_daySelect" onchange="return cal_updateCalendar(\''+e+"', '"+t+"');\">",n=1;n<32;n++)l+='<option value="'+n+'"',a.getDate()===n&&(l+=' selected="selected"'),l+=">"+n+"</option>";for(l+="</select></td>",l+='<td><select class="form-control" id="'+e+'_monSelect" onchange="return cal_updateCalendar(\''+e+"', '"+t+"');\">",n=1;n<13;n++)l+='<option value="'+n+'"',a.getMonth()+1===n&&(l+=' selected="selected"'),l+=">"+monthLabels[n]+"</option>";for(l+="</select></td>",l+='<td><input class="form-control" type="text" id="'+e+'_yearInput" size="5" value="'+a.getFullYear()+'" onchange="return cal_updateCalendar(\''+e+"', '"+t+"');\" /></td></tr>",l+='<tr><td colspan="3">',l+='<table width="100%">',l+="<tr>",o=weekStart,n=0;n<7;n++)l+="<td ",l+='class="descriptionbox"',l+=">",l+=daysOfWeek[o],l+="</td>",++o>6&&(o=0);l+="</tr>";var r=new Date(a.getFullYear(),a.getMonth(),1),i=r.getDay();i-=weekStart;for(r=r.getTime()-864e5*i+432e5,r=new Date(r),o=0;o<6;o++){for(l+="<tr>",n=0;n<7;n++){l+="<td ",r.getMonth()===a.getMonth()?r.getDate()===a.getDate()?l+='class="descriptionbox"':l+='class="optionbox"':l+='style="background-color:#EAEAEA; border: solid #AAAAAA 1px;"',l+='><a href="#" onclick="return cal_dateClicked(\''+e+"', '"+t+"', "+r.getFullYear()+", "+r.getMonth()+", "+r.getDate()+');">',l+=r.getDate(),l+="</a></td>";var c=r.getTime()+864e5;r=new Date(c)}l+="</tr>"}return l+="</table>",l+="</td></tr>",l+="</table>"}function cal_setDateField(e,t,a,n){var o=document.getElementById(e);return!!o&&(n<10&&(n="0"+n),o.value=n+" "+monthShort[a+1]+" "+t,!1)}function cal_updateCalendar(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 l=parseInt(n.options[n.selectedIndex].value,10);l-=1;var r=new Date(o.value,l,a.options[a.selectedIndex].value);cal_setDateField(e,r.getFullYear(),r.getMonth(),r.getDate());var i=document.getElementById(t);return i?(i.innerHTML=cal_generateSelectorContent(e,t,r),!1):(alert("no dateDiv "+t),!1)}function cal_dateClicked(e,t,a,n,o){return cal_setDateField(e,a,n,o),calendarWidget(t,e),!1}function openerpasteid(e){window.opener.paste_id&&window.opener.paste_id(e),window.close()}function paste_id(e){pastefield.value=e}function pastename(e){nameElement&&(nameElement.innerHTML=e),remElement&&(remElement.style.display="block")}function paste_char(e){document.selection?(pastefield.focus(),document.selection.createRange().text=e):pastefield.selectionStart||0===pastefield.selectionStart?(pastefield.value=pastefield.value.substring(0,pastefield.selectionStart)+e+pastefield.value.substring(pastefield.selectionEnd,pastefield.value.length),pastefield.selectionStart=pastefield.selectionEnd=pastefield.selectionStart+e.length):pastefield.value+=e,"NPFX"!==pastefield.id&&"GIVN"!==pastefield.id&&"SPFX"!==pastefield.id&&"SURN"!==pastefield.id&&"NSFX"!==pastefield.id||updatewholename()}function persistent_toggle(e){var t=document.getElementById(e),a="state-of-"+e;"true"===localStorage.getItem(a)&&$(t).click(),$(t).on("change",function(){localStorage.setItem(a,t.checked)})}function valid_lati_long(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 l=parseFloat(t);return l+=a/60,l+=n/3600,o+(l=Math.round(1e4*l)/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(/(.*)([N|S|E|W]+)$/g,"$2$1"))&&n.charAt(0)!==a&&n.charAt(0)!==t&&(n=t+n),e.value=n}function activate_colorbox(e){$.extend($.colorbox.settings,{fixed:!0,current:"",previous:"",next:"",slideshowStart:"",slideshowStop:"",close:""}),e&&$.extend($.colorbox.settings,e),$("body").on("click","a.gallery",function(){$("a[type^=image].gallery").colorbox({photo:!0,maxWidth:"95%",maxHeight:"95%",rel:"gallery",slideshow:!0,slideshowAuto:!1,onComplete:function(){$(".cboxPhoto").unbind("click"),wheelzoom(document.querySelectorAll(".cboxPhoto"))}})})}function autocomplete(e){$(e).each(function(){var e=this;$(this).typeahead(null,{display:"value",source:new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("value"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:this.dataset.autocompleteUrl,replace:function(t,a){if(e.dataset.autocompleteExtra){var n=$(document.querySelector(e.dataset.autocompleteExtra)).val();return t.replace("QUERY",a)+"&extra="+encodeURIComponent(n)}return t.replace("QUERY",a)},wildcard:"QUERY"}})})})}function insertTextAtCursor(e,t){var a=e.scrollTop,n=e.selectionStart,o=e.value.substring(0,n),l=e.value.substring(e.selectionEnd,e.value.length);e.value=o+t+l,e.selectionStart=n+t.length,e.selectionEnd=e.selectionStart,e.focus(),e.scrollTop=a}function drawPieChart(e,t,a,n,o){t=google.visualization.arrayToDataTable(t);var l={title:n,height:"100%",width:"100%",pieStartAngle:0,pieSliceText:"none",pieSliceTextStyle:{color:"#777"},pieHole:.4,legend:{alignment:"center",labeledValueText:o||"value",position:"labeled"},chartArea:{left:0,top:"5%",height:"90%",width:"100%"},tooltip:{trigger:"none",text:"both"},backgroundColor:"transparent",colors:a};new google.visualization.PieChart(document.getElementById(e)).draw(t,l)}function drawColumnChart(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);var n=new google.visualization.ColumnChart(document.getElementById(e));t=google.visualization.arrayToDataTable(t);n.draw(t,a)}function drawComboChart(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);var n=new google.visualization.ComboChart(document.getElementById(e));t=google.visualization.arrayToDataTable(t);n.draw(t,a)}function drawGeoChart(e,t,a){a=Object.assign({title:"",subtitle:"",height:"100%",width:"100%"},a);var n=new google.visualization.GeoChart(document.getElementById(e));t=google.visualization.arrayToDataTable(t);n.draw(t,a)}$.ajaxSetup({headers:{"X-CSRF-TOKEN":$("meta[name=csrf]").attr("content")}}),$(function(){var e;$("[data-ajax-url]").each(function(){$(this).load($(this).data("ajaxUrl"))}),autocomplete("input[data-autocomplete-url]"),$("select.select2").select2({escapeMarkup:function(e){return e}}).on("select2:unselect",function(e){$(e.delegateTarget).append('<option value="" selected="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")}),$(".wt-modal-create-record").on("show.bs.modal",function(e){$("form",$(this)).data("element-id",$(e.relatedTarget).data("element-id")),$("form .form-group input:first",$(this)).focus()}),$(".wt-modal-create-record form").on("submit",function(e){e.preventDefault();var t=$(this).data("element-id");$.ajax({url:"index.php",type:"POST",data:new FormData(this),async:!1,cache:!1,contentType:!1,processData:!1,success:function(e){$("#"+t).select2().empty().append(new Option(e.text,e.id)).val(e.id).trigger("change")},failure:function(e){alert(e.error_message)}}),this.reset(),$(this).closest(".wt-modal-create-record").modal("hide")}),$(".menu-language").on("click","[data-language]",function(){return $.post("index.php",{route:"language",language:$(this).data("language")},function(){document.location.reload()}),!1}),$(".menu-theme").on("click","[data-theme]",function(){return $.post("index.php",{route:"theme",theme:$(this).data("theme")},function(){document.location.reload()}),!1}),$(".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];if(a&&void 0!==n&&(t=n.innerText),null!==e){var o=e.selectionStart,l=e.value,r=l.substring(0,o),i=l.substring(o,l.length);e.value=r+t+i,!1===$(".wt-osk-pin-button").hasClass("active")&&$(".wt-osk").hide()}}),$(".wt-osk-close").on("click",function(){$(".wt-osk").hide()})});
2