var header = {
menuList: [],
changeLanguage: (lang, url) => {
$.ajax({
url: "/ChangeLanguage",
data: { language: lang },
type: "POST",
cache: false,
success: function (html) {
/*console.log("sikeres nyelváltás");*/
window.location = url;
},
error: (e) => {
console.log(e);
},
});
},
//acceptAnalyticsCookiesMod: () => {
// var acceptPrivacyCheckedState = $("#acceptAnalyticsCookies").prop("checked");
// $("#acceptAnalyticsCookies").prop("checked", !acceptPrivacyCheckedState);
//},
//acceptSocialCookiesMod: () => {
// var acceptPrivacyCheckedState = $("#acceptSocialCookies").prop("checked");
// $("#acceptSocialCookies").prop("checked", !acceptPrivacyCheckedState);
//},
buildMenuTreeFromHTML: function () {
$(".menu_items li a").each(function (index, element) {
/*console.log($(this).text());*/
var submenuItems = [];
$("[data-mainmenuidentifier='" + $(this).text() + "']")
.find("p")
.each(function (index, element) {
var submenuItem = {
displayName: $(this).text(),
href: $(this).attr("data-url"),
};
submenuItems.push(submenuItem);
});
var menuItem = {
menuname: $(this).text(),
subMenuList: submenuItems,
};
header.menuList.push(menuItem);
});
header.menuNavigationLogic();
},
menuNavigationLogic: function () {
$(".menu_items li").on("mouseover", function () {
var currentMenu = $(this).text().toUpperCase().trim();
$(".menu_open ul").html("");
SubmenuItem = header.menuList.find(
(x) => x.menuname.toLowerCase() === currentMenu.toLowerCase()
);
var menuListLength = SubmenuItem.subMenuList.length;
if (menuListLength != 0) {
for (let i = 0; i < SubmenuItem.subMenuList.length; i++) {
displayName = SubmenuItem.subMenuList[i].displayName;
href = SubmenuItem.subMenuList[i].href;
$(".menu_open ul").append(
"
" + displayName + ""
);
}
$(".menu_open").slideDown();
$( ".menu_open ul li" ).each(function( index ) {
if($(this).height() > 45) {
$(this).css("background-position","10px 13px");
}
});
setTimeout(function () {
$(".menu_open ul li").css("opacity", "1");
}, 200);
}else {
$(".menu_open").slideUp();
}
});
$(".menu_items a").on("focus", function () {
$(".menu_open").slideUp();
var currentMenu = $(this).parent().text().toUpperCase().trim();
$(this).parent().next().next().find("ul").html("");
SubmenuItem = header.menuList.find(
(x) => x.menuname.toLowerCase() === currentMenu.toLowerCase()
);
var menuListLength = SubmenuItem.subMenuList.length;
if (menuListLength != 0) {
for (let i = 0; i < SubmenuItem.subMenuList.length; i++) {
displayName = SubmenuItem.subMenuList[i].displayName;
href = SubmenuItem.subMenuList[i].href;
var tabIndex = i+1;
$(this).parent().next().next().find("ul").append(
"" + displayName + ""
);
}
$(this).parent().next().next().slideDown();
$(this).parent().next().next().find("li").each(function( index ) {
if($(this).height() > 45) {
$(this).css("background-position","10px 13px");
}
$(this).css("opacity", "1");
});
setTimeout(function () {
$(this).parent().next().next().find("li").css("opacity", "1");
}, 200);
}else {
$(this).parent().next().next().slideUp();
}
});
$("nav > a").on("focus", function () {
$(".menu_open").slideUp();
});
$(".right_col > a").on("focus", function () {
$(".menu_open").slideUp();
});
$(".breadcrumb_item").on("focus", function () {
$(".menu_open").slideUp();
});
$(".menu_open").on("mouseleave", function () {
$(".menu_open").slideUp();
});
},
init: function () {
header.buildMenuTreeFromHTML();
$(".language_en").on("click", function () {
let url = $(this).data("url");
header.changeLanguage("EN", url);
});
$(".language_en").on('keypress',function(e) {
if(e.which == 13) {
let url = $(this).data("url");
header.changeLanguage("EN", url);
}
});
$(".language_hu").on("click", function () {
let url = $(this).data("url");
header.changeLanguage("HU", url);
});
$(".language_hu").on('keypress',function(e) {
if(e.which == 13) {
let url = $(this).data("url");
header.changeLanguage("HU", url);
}
});
$(".search_wrapper img").on('keypress',function(e) {
if(e.which == 13) {
common.relatedSearch($(this));
}
});
$(".checkboxContentWithText").on('keypress',function(e) {
if(e.which == 13) {
$(".acceptPrivacyAlert").hide();
$(".acceptPrivacyAlert").removeAttr("role");
var acceptPrivacyCheckedState = $(this).find("input").prop("checked");
$(this).find("input").prop("checked", !acceptPrivacyCheckedState);
}
});
//$(".acceptSocialCookies").on('keypress',function(e) {
// if(e.which == 32) {
// console.log("search_wrapper img");
// var acceptPrivacyCheckedState = $(this).find("input").prop("checked");
// $(this).find("input").prop("checked", !acceptPrivacyCheckedState);
// }
//});
$(".questionnaireContainer .chbWrapperAcceptPrivacy").on('keypress',function(e) {
if(e.which == 13) {
var acceptPrivacyCheckedState = $("#acceptPrivacy").prop("checked");
$("#acceptPrivacy").prop("checked", !acceptPrivacyCheckedState);
}
});
$(".ratingColumn input[type='radio']").on("focus", function () {
$(this).parent().parent().find(".inactiveSelection").show();
$(this).siblings("img").css("border","1px solid black");
var hasChecked = false;
$(this).parent().parent().find("input").each(function( index ) {
if($(this).prop("checked")) {
hasChecked = true;
}
});
if(hasChecked) {
$(this).siblings(".inactiveSelection").hide();
}
});
$(".ratingColumn input[type='radio']").on("focusout", function () {
$(this).parent().parent().find(".inactiveSelection").show();
$(this).siblings("img").css("border","none");
var hasCheckedasd = false;
$(this).parent().parent().find("input").each(function( index ) {
if($(this).prop("checked")) {
hasCheckedasd = true;
}
});
if(hasCheckedasd) {
$(this).siblings(".inactiveSelection").hide();
}
});
$(".ratingColumn .inactiveSelection").on("click", function () {
$(this).parent().parent().find(".inactiveSelection").show();
$(this).siblings("input").prop("checked",true);
$(this).hide();
$(this).siblings(".activeSelection").show();
});
},
};
$(document).ready(function () {
header.init();
});