(function($){$(function(){if(window.FormStuff&&$.isFunction(FormStuff.showDomain))$("select[id$\x3d'P_FOTIP']").on("change",function(){var $ptip=$("select[id$\x3d'P_TIP']");if($ptip.data("selectpicker"))$ptip.selectpicker("refresh")})})})(jQuery);
function checkBackgroundJobStatus($root,url,jobId,timeout){$.ajax({type:"GET",url:url,cache:false,dataType:"html",success:function(data,textStatus,jqXHR){if(jqXHR.status===204){setTimeout(function(){checkBackgroundJobStatus($root,url,jobId,timeout)},timeout);return}$root.html(data);initPairForms($root);initBootstrapSelectPicker($root);initDataTable($root);initDatePicker($root);initValidation($root)},error:function(XMLHttpRequest,textStatus,errorThrown){console.error(errorThrown);$root.html("Hiba a PAIR kommunik\x26aacute;ci\x26oacute; k\x26ouml;zben!")}})}
;
Liferay.on("allPortletsReady",function(){initPairForms()});function initPairForms($root){$root=$root||$(document);$root.find(".pair-content form").attr("onsubmit","saveFormData()");generateButtons($root);resetForm($root);checkNavigationType($root)}
function checkNavigationType($root){if(!$root.find(".pair-content form").length)return;if(navigator.userAgent.indexOf("Safari")!=-1)if(performance.navigation.type==2)loadFormData($root);else sessionStorage.clear();let perfEntries=performance.getEntriesByType("navigation");for(let i=0;i<perfEntries.length;i++)if(perfEntries[i].type==="back_forward")loadFormData($root);else sessionStorage.clear()}
function generateButtons($root){let currentDropdowns=$root.find("table tr .bootstrap-select").not(".P_RENDEZ");let divToAppend='\x3cbutton class\x3d"btn btn-primary btn-reset reset-current" type\x3d"button"\x3e T\u00f6rl\u00e9s \x3c/button\x3e';currentDropdowns.closest("tr td").append(divToAppend);$root.find("tr:has('.date-picker')").find("td:last-child").append(divToAppend)}
function resetForm($root){let currentButton=$root.find(".btn-reset");currentButton.on("click",function(){let currentRow=jQuery(this).closest("tr");let currentSelect=currentRow.find("select");let currentOptions=currentRow.find(".bootstrap-select li");currentSelect.val("");currentOptions.each(function(){jQuery(this).removeClass("active selected")});currentSelect.selectpicker("refresh");let currentDates=currentRow.find(".date-picker");currentDates.val("")})}
function saveFormData(){let checkboxArr=jQuery('.pair-content input[type\x3d"checkbox"]').map(function(){return this.checked}).get();sessionStorage.setItem("checked",JSON.stringify(checkboxArr));let textValues=[];let textInputs=jQuery('.pair-content input[type\x3d"text"]:not([type\x3dhidden]):not(".bs-searchbox input"):not(".date-picker")');textInputs.each(function(){textValues.push(jQuery(this).val())});sessionStorage.setItem("textVals",JSON.stringify(textValues));let selectValues=[];let selectElements=
jQuery(".pair-content select");selectElements.each(function(){selectValues.push(jQuery(this).val())});sessionStorage.setItem("selectedVals",JSON.stringify(selectValues));let dateValues=[];let dateInputs=jQuery(".pair-content input.date-picker");dateInputs.each(function(){dateValues.push(jQuery(this).val())});sessionStorage.setItem("dateVals",JSON.stringify(dateValues));let radioValues=[];let radioButtons=jQuery('.pair-content input[type\x3d"radio"]');radioButtons.each(function(){radioValues.push(jQuery(this).is(":checked"))});
sessionStorage.setItem("radioVals",JSON.stringify(radioValues));let currentFormURL=location.href.substring(location.href.indexOf("p_modul"));sessionStorage.setItem("sessionFormURL",currentFormURL)}
function loadFormData($root){let currentFormURL=location.href.substring(location.href.indexOf("p_modul"));let savedUrl=sessionStorage.getItem("sessionFormURL");if(currentFormURL!==savedUrl)sessionStorage.clear();else{let checkboxArr=JSON.parse(sessionStorage.getItem("checked"))||[];checkboxArr.forEach(function(isChecked,i){$root.find('.pair-content input[type\x3d"checkbox"]').eq(i).prop("checked",isChecked)});let textArr=JSON.parse(sessionStorage.getItem("textVals"))||[];let textInputs=$root.find('.pair-content input[type\x3d"text"]:not([type\x3dhidden]):not(".bs-searchbox input"):not(".date-picker")');
textInputs.each(function(item){jQuery(this).val(textArr[item])});let selectArr=JSON.parse(sessionStorage.getItem("selectedVals"))||[];let selectElements=$root.find(".pair-content select");selectElements.each(function(item){jQuery(this).selectpicker("val",selectArr[item])});$root.find(".pair-content select").selectpicker("render");let dateArr=JSON.parse(sessionStorage.getItem("dateVals"))||[];let dateInputs=$root.find(".pair-content input.date-picker");dateInputs.each(function(item){jQuery(this).val(dateArr[item])});
let radioArr=JSON.parse(sessionStorage.getItem("radioVals"))||[];radioArr.forEach(function(isChecked,i){$root.find('.pair-content input[type\x3d"radio"]').eq(i).prop("checked",isChecked)})}};
