/*2019.02.01 ver1.0.0*/ var list = ""; var collapsed = false; var hidden = false; var last_state = ""; var win = $(this); var checkbox_checked = false; var hide_timeout, widget_timeout, list_timeout, debug_hide_timeout, top_timeout; // a kisebb a gyorsabb var animation_speed = 300; var change_to_mid_size = 1000; var change_to_small_size = 480; //Erre van optimalizálva var narrow_menu_width = 60; var wide_menu_width = 240; var icons_path = "../proxer_pay_webgui/karc_frame/static/icons/" var animation_down_finished = true var animation_up_finished = true var top_menu_hide_enabled = false window.onresize = function(event){ // console.log("resize"); if (checkbox_checked == true){ hide_menu(); $("#Theme").css("display", "block"); $("#Settings").css("display", "block"); $("#Power").css("display", "block"); top_menu_hide_enabled = true; } else{ if (win.width() <= change_to_small_size) { hide_menu(); $("#Theme").css("display", "block"); $("#Settings").css("display", "block"); $("#Power").css("display", "block"); top_menu_hide_enabled = true; } else if (last_state == "narrow"){ narrow_menu(); top_menu_hide_enabled = false; } else { wide_menu(); top_menu_hide_enabled = false; } } } // Egyszer fut le az elején function width_check(){ // console.log("width check"); if (win.width() <= change_to_small_size) { console.log('kisebb 480-nál'); last_state = "narrow"; hide_menu(); top_menu_hide_enabled = true; } else if (win.width() <= change_to_mid_size && win.width() > change_to_small_size){ //console.log('kisebb 1000-nél, nagyobb 480-nál'); last_state = "narrow"; narrow_menu(); top_menu_hide_enabled = true; } else{ //console.log('nagyobb 1000-nél'); last_state = "wide"; wide_menu(); top_menu_hide_enabled = false; } } function mouseOver(var1) { txt = var1.id.replace("__", "/"); txt = txt.replace("_", " "); if (txt == "Menu Collapse" && collapsed == 1){ txt = "Menu Expand"; } widgetid = "#show_"+var1.id; widget = $(widgetid) // widget.text(txt); widget.css("display", "block"); clearTimeout(widget_timeout); widget_timeout = setTimeout(function(){ widget.css("display", "none"); }, 1000); } function mouseOverEnd(var1) { widgetid = "#show_"+var1.id; $(widgetid).css("display", "none"); clearTimeout(widget_timeout); } function menuHideOpen(var1){ // console.log("menu hide open"); if (var1 == 'menu' && checkbox_checked == false){} else if (var1 != 'menu' && checkbox_checked == true){ if (hidden == false){ hide_menu('animation'); // clearTimeout(hide_timeout); $("#Theme").css("display", "block"); $("#Settings").css("display", "block"); $("#Power").css("display", "block"); } else { if (last_state == 'narrow'){ narrow_menu("animation"); } else{ if (win.width() <= wide_menu_width + 190){ $("#Theme").css("display", "none"); $("#Settings").css("display", "none"); $("#Power").css("display", "none"); } wide_menu("animation"); } // hide_timeout = setTimeout(function(){ // hide_menu("animation"); // }, 10000); } } else{ if (hidden == false){ hide_menu("animation"); // clearTimeout(hide_timeout); $("#Theme").css("display", "block"); $("#Settings").css("display", "block"); $("#Power").css("display", "block"); } else{ if (last_state == 'narrow'){ narrow_menu("animation"); } else{ if (win.width() <= change_to_small_size){ $("#Theme").css("display", "none"); $("#Settings").css("display", "none"); $("#Power").css("display", "none"); } wide_menu("animation"); } } } } function menuCollapse(){ // console.log("menu collapse"); if (collapsed == false){ last_state = 'narrow'; narrow_menu("animation"); $("#Theme").css("display", "block"); $("#Settings").css("display", "block"); $("#Power").css("display", "block"); } else{ if (win.width() <= change_to_small_size){ $("#Theme").css("display", "none"); $("#Settings").css("display", "none"); $("#Power").css("display", "none"); } last_state = "wide"; wide_menu("animation"); } } function openList(var1){ console.log("openList"); list = var1.id widgetid = "#show_"+var1.id; $(widgetid).css("display", "none"); listid = "#index_body_top_"+var1.id+"_list"; $(listid).css("display", "block"); // list_timeout = setTimeout(function(){ // $(listid).css("display", "none"); // }, 5000); } function onmouseLeaveList(var1){ $(var1).css("display", "none"); list = ""; clearTimeout(list_timeout); } function hide_menu(var1){ // console.log("hide_menu"); if (var1 == "animation"){ //Animáció zár if ($("#wide_menu").is(":visible") == true){ //wide menu-ból kell eltüntetni valt = wide_menu_width; } else if($("#narrow_menu").is(":visible") == true){ //narrow menu-ból kell eltüntetni valt = narrow_menu_width; } animate_hide(); function animate_hide(){ element_width = win.width(); $("#narrow_menu").animate({left: "-" +narrow_menu_width+ "px", width: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#wide_menu").animate({left: "-" +wide_menu_width+ "px", width: "" +wide_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_widgets").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_lists").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#footer").animate({left: "0px"}, animation_speed, function() {/*Animation complete.*/}); $("#content_parent").animate({left: "0px", width: element_width}, animation_speed, function() {hide_menu_finally();}); } function hide_menu_finally(){ $("#Menu_Collapse").css("display", "none"); $("#replace_arrow").css("width", "45px"); $("#wide_menu").css("display", "none"); $("#narrow_menu").css("display", "none"); } } else{ $("#narrow_menu").css("left", "-" +narrow_menu_width+ "px"); $("#wide_menu").css("left", "-" +wide_menu_width+ "px"); $("#index_body_top").css("width", "100%"); $("#index_body_top_widgets").css("width", "100%"); $("#index_body_top_lists").css("width", "100%"); $("#footer").css("left", "0px"); $("#content_parent").css("left", "0px"); $("#content_parent").css("width", "100%"); $("#Menu_Collapse").css("display", "none"); $("#replace_arrow").css("width", "45px"); $("#wide_menu").css("display", "none"); $("#narrow_menu").css("display", "none"); $("#menu_opener").css("display", "block"); } menu_opener = setTimeout(function(){ $("#menu_opener").css("display", "block"); }, 200); collapsed = true; hidden = true; } function narrow_menu(var1){ // console.log("narrow_menu"); if (var1 == "animation"){ //Animáció wide_left = wide_menu_width - narrow_menu_width if ($("#wide_menu").is(":visible") == true){ //wide menu-ból kell eltüntetni valt = wide_menu_width; animate_narrow(); } else if ($("#wide_menu").is(":visible") == false){ //hide menu-ból kell nyitni valt = 0; narrow_menu_finally(); } function animate_narrow(){ element_width = win.width() - narrow_menu_width; if(valt == wide_menu_width){ $("#narrow_menu").animate({left: "0px", width: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#wide_menu").animate({left: "-" +wide_left+ "px", width: "" +wide_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_widgets").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_lists").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#footer").animate({left: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#content_parent").animate({left: "" +narrow_menu_width+ "px", width: element_width}, animation_speed, function() {narrow_menu_finally();}); } else if(valt == 0){ $("#narrow_menu").animate({left: "0px", width: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#wide_menu").animate({left: "-" +wide_left+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_widgets").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_lists").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#footer").animate({left: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#content_parent").animate({left: "" +narrow_menu_width+ "px", width: element_width}, animation_speed, function() {}); } } function narrow_menu_finally(){ $("#arrow").attr("src", "" +icons_path+ "right_arrow.png"); $("#Menu_Collapse").css("display", "block"); $("#replace_arrow").css("width", "0px"); $("#wide_menu").css("display", "none"); $("#narrow_menu").css("display", "flex"); if (valt == 0){animate_narrow();} } } else{ $("#narrow_menu").css("left", "0px"); $("#narrow_menu").css("width", "" +narrow_menu_width+ "px"); $("#wide_menu").css("left", "-" +wide_menu_width - narrow_menu_width+ "px"); $("#index_body_top").css("width", "calc(100% - " +narrow_menu_width+ "px)"); $("#index_body_top_widgets").css("width", "calc(100% - " +narrow_menu_width+ "px)"); $("#index_body_top_lists").css("width", "calc(100% - " +narrow_menu_width+ "px)"); $("#footer").css("left", "" +narrow_menu_width+ "px"); $("#content_parent").css("left", "" +narrow_menu_width+ "px"); $("#content_parent").css("width", "calc(100% - " +narrow_menu_width+ "px)"); $("#arrow").attr("src", "" +icons_path+ "right_arrow.png"); $("#Menu_Collapse").css("display", "block"); $("#replace_arrow").css("width", "0px"); $("#wide_menu").css("display", "none"); $("#narrow_menu").css("display", "flex"); } menu_opener = setTimeout(function(){ $("#menu_opener").css("display", "block"); }, 200); hidden = false; collapsed = true; } function wide_menu(var1){ // console.log("wide_menu"); if (var1 =="animation"){ //Animáció nyit if (win.width() <= wide_menu_width + 190){ valt = win.width(); info_img_margin = (valt - 20)/ 2; left = wide_menu_width; animate_extra_wide(); function animate_extra_wide(){ $("#wide_menu").css("display", "flex"); $("#info_img").css("margin-left", info_img_margin); $("#menu_options").css("display", "block"); $("#narrow_menu").animate({left: "0px", width: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#wide_menu").animate({left: "0px", width: valt}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top").animate({width: "0px"}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_widgets").animate({width: "0px"}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_lists").animate({width: "0px"}, animation_speed, function() {/*Animation complete.*/}); $("#footer").animate({left: "100%"}, animation_speed, function() {/*Animation complete.*/}); $("#content_parent").animate({left: "100%", width: "0px"}, animation_speed, function() {wide_menu_finally();}); } function wide_menu_finally(){ $("#arrow").attr("src", "" +icons_path+ "left_arrow.png"); $("#Menu_Collapse").css("display", "block"); $("#replace_arrow").css("width", "0px"); $("#narrow_menu").css("display", "none"); } } else{ if ($("#narrow_menu").is(":visible") == true){ //narrow menu-ból kell nyitni valt = narrow_menu_width; } else if($("#narrow_menu").is(":visible") == false){ //hide menu-ból kell nyitni valt = 0; } animate_wide(); function animate_wide(){ element_width = win.width() - wide_menu_width; info_img_margin = (wide_menu_width - 20)/ 2; $("#wide_menu").css("display", "flex"); $("#info_img").css("margin-left", "" +info_img_margin+ "px"); $("#menu_options").css("display", "none"); $("#narrow_menu").animate({left: "0px", width: "" +narrow_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#wide_menu").animate({left: "0px", width: "" +wide_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_widgets").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#index_body_top_lists").animate({width: element_width}, animation_speed, function() {/*Animation complete.*/}); $("#footer").animate({left: "" +wide_menu_width+ "px"}, animation_speed, function() {/*Animation complete.*/}); $("#content_parent").animate({left: "" +wide_menu_width+ "px", width: element_width}, animation_speed, function() {wide_menu_finally();}); } function wide_menu_finally(){ $("#arrow").attr("src", "" +icons_path+ "left_arrow.png"); $("#Menu_Collapse").css("display", "block"); $("#replace_arrow").css("width", "0px"); $("#narrow_menu").css("display", "none"); } } } else{ info_img_margin = (wide_menu_width - 20)/ 2; $("#info_img").css("margin-left", "" +info_img_margin+ "px"); $("#menu_options").css("display", "none"); $("#wide_menu").css("width", "" +wide_menu_width+ "px"); $("#narrow_menu").css("left", "0px"); $("#wide_menu").css("left", "0px"); $("#wide_menu").css("display", "flex"); $("#narrow_menu").css("display", "none"); $("#index_body_top").css("width", "calc(100% - " +wide_menu_width+ "px)"); $("#index_body_top_widgets").css("width", "calc(100% - " +wide_menu_width+ "px)"); $("#index_body_top_lists").css("width", "calc(100% - " +wide_menu_width+ "px)"); $("#footer").css("left", "" +wide_menu_width+ "px"); $("#content_parent").css("left", "" +wide_menu_width+ "px"); $("#content_parent").css("width", "calc(100% - " +wide_menu_width+ "px)"); $("#arrow").attr("src", "" +icons_path+ "left_arrow.png"); $("#Menu_Collapse").css("display", "block"); $("#replace_arrow").css("width", "0px"); } menu_opener = setTimeout(function(){ $("#menu_opener").css("display", "block"); }, 200); hidden = false; collapsed = false; } function hide_menu_always_button_click(){ src = $("#hide_menu_always_img").attr('src'); if (~src.search("left")){ console.log("all set to right"); src = src.replace('left', 'right'); document.getElementById("hide_menu_always_cb").checked = true; $("#hide_menu_always_div").css("background", "#E59B48"); $("#hide_menu_always_div").css("color", "#000000"); $("#hide_menu_always_div").css("filter", "invert(100%)"); $("#narrow_hide_menu_always_div").css("background", "#E59B48"); $("#narrow_hide_menu_always_div").css("color", "#000000"); $("#narrow_hide_menu_always_div").css("filter", "invert(100%)"); document.getElementById("hide_menu_always_div").style.WebkitAnimationName = "hide_menu_always_keyframe_right"; document.getElementById("narrow_hide_menu_always_div").style.WebkitAnimationName = "hide_menu_always_keyframe_right"; } else{ src = src.replace('right', 'left'); document.getElementById("hide_menu_always_cb").checked = false; $("#hide_menu_always_div").css("background", "#ffffff"); $("#hide_menu_always_div").css("color", "#000000"); $("#hide_menu_always_div").css("filter", "invert(0%)"); $("#narrow_hide_menu_always_div").css("background", "#ffffff"); $("#narrow_hide_menu_always_div").css("color", "#000000"); $("#narrow_hide_menu_always_div").css("filter", "invert(0%)"); document.getElementById("hide_menu_always_div").style.WebkitAnimationName = "hide_menu_always_keyframe_left"; document.getElementById("narrow_hide_menu_always_div").style.WebkitAnimationName = "hide_menu_always_keyframe_left"; } $("#hide_menu_always_img").attr('src', src); $("#narrow_hide_menu_always_img").attr('src', src); } function hide_menu_always(){ // console.log("hide menu always"); var checkBox = document.getElementById("hide_menu_always_cb"); if (checkBox.checked == true){ checkbox_checked = true; clearTimeout(hide_timeout); hide_menu("animation"); $("#Theme").css("display", "block"); $("#Settings").css("display", "block"); $("#Power").css("display", "block"); top_menu_hide_enabled = true; } else{ checkbox_checked = false; clearTimeout(hide_timeout); if (win.width() <= change_to_small_size){ top_menu_hide_enabled = true; } else{ top_menu_hide_enabled = false; } } } function menuOpener(var1){ // console.log("menu opener"); if (var1 == 'debug'){ // console.log("debug menu opener"); clearTimeout(debug_hide_timeout); open_debug_menu(); } else{ if(checkbox_checked == true){ clearTimeout(hide_timeout); if (last_state == 'narrow'){ narrow_menu("animation"); } else{ wide_menu("animation"); } } } } function menuLeaveHide(){ // console.log("menu leave hide"); if(checkbox_checked == true){ clearTimeout(hide_timeout); if (hidden == false){ hide_timeout = setTimeout(function(){ hide_menu("animation"); }, 500); } } } function open_or_hide_submenus(menu){ // console.log("Kattintott menu " + menu); var src = $("#" + menu + ">img").attr('src'); var elems = document.getElementsByName('submenu'); // console.log(elems); for(i = 0; i < elems.length; i++){ var id = elems[i].id; var child_id = elems[i].firstElementChild.id; // ha a kattintott main_menu submenu-je if(elems[i].attributes.main_menu.value == menu){ // console.log("Kattintott menu submenu-je " + id); // ha nincsenek becsukódva teljesen akkor becsukjuk a submenu-ket if(elems[i].firstElementChild.style.height != "0px"){ // console.log("Nincs becsukódva teljesen " + child_id); animate_submenu_hide(id, child_id); src = src.replace('up', 'down'); } // ha be vannak csukódva tejlesen, akkor kinyitjuk a submenu-ket else{ // console.log("Teljesen be van csukódva " + child_id); animate_submenu_show(id, child_id); src = src.replace('down', 'up'); } } // ha másik main_menu submenu-je akkor tuti elrejtjük else{ // console.log("Nem kattintott menu submenu-je " + id); animate_submenu_hide(id, child_id) var _src = src.replace('up', 'down'); $("#" + elems[i].attributes.main_menu.value + ">img").attr('src', _src); $("#" + elems[i].attributes.main_menu.value + "_w>img").attr('src', _src); // $("#" + child_id).animate({height: "0px"}, animation_speed, function() {/*Animation complete.*/}); // $("#" + id).css("display", "none"); } $("#" + menu + ">img").attr('src', src); $("#" + menu + "_w>img").attr('src', src); } } function animate_submenu_hide(id, child_id){ $("#" + child_id).animate({height: "0px"}, animation_speed, function() {$("#" + id).css("display", "none");/*Animation complete.*/}); } function animate_submenu_show(id, child_id){ $("#" + id).css("display", "block"); $("#" + child_id).animate({height: "50px"}, animation_speed, function() {/*Animation complete.*/}); } function debug_menuLeaveHide(){ // console.log("debug menu leave hide"); clearTimeout(debug_hide_timeout); debug_hide_timeout = setTimeout(function(){ hide_debug_menu(); }, 500); } function open_debug_menu(){ $("#debug_menu").animate({right: "0px"}, animation_speed, function() {/*Animation complete.*/}); } function hide_debug_menu(){ $("#debug_menu").animate({right: "-240px"}, animation_speed, function() {/*Animation complete.*/}); } start_download = function (self) { let url = "/proxer_pay_webgui/ajax/%filename%.%ext%?export_length=%export_length%&wg_name=%wg_name%"; let name = self.name === null ? self.id : self.name; let element; url = url.replace("%filename%", name); if (self.id === "excel_export") { url = url.replace("%ext%", "xlsx") } if (self.id === "csv_export") { url = url.replace("%ext%", "csv") } try{ url = url.replace("%wg_name%", self.parentElement.parentElement.parentElement.parentElement.parentElement.children[2].id) } catch(err){ console.log(err) } url = url.replace("%export_length%", $("select#export_length").val()); element = document.createElement("a"); element.target = "_blank"; element.href = url; element.hidden = true; document.body.appendChild(element); element.click(); document.body.removeChild(element); } start_download_ws = function (self) { var name = ""; for (let i = 0; i < self.parentElement.parentElement.parentElement.parentElement.parentElement.children.length; i++) { if (self.parentElement.parentElement.parentElement.parentElement.parentElement.children[i].id == "wg_head") { name = self.parentElement.parentElement.parentElement.parentElement.parentElement.children[i + 1].id; break; } } if (self.id === "excel_export") { karc.href(this, '/proxer_pay_webgui/ajax/export.xlsx', {'name': name, 'ext': 'xlsx', 'length': $("select#export_length").val()}) } if (self.id === "csv_export") { karc.href(this, '/proxer_pay_webgui/ajax/export.csv', {'name': name, 'ext': 'csv', 'length': $("select#export_length").val()}) } if (self.id === "generate_qr_code") { karc.href(this, '/proxer_pay_webgui/ajax/generate_qr_code.json', {'vin': document.getElementById('vin_number').value, 'add_text_to_qr': document.getElementById('add_text_to_qr').value}) } } function download_sample_file(filename){ let url = "/proxer_pay_webgui/ajax/" + filename; element = document.createElement("a"); element.target = "_blank"; element.href = url; element.hidden = true; document.body.appendChild(element); element.click(); document.body.removeChild(element); } ap_print = function (self) { try{ var from_date = document.getElementById("from_date").value; var to_date = document.getElementById("to_date").value; } catch(err){ from_date = null to_date = null } karc.href(this, '/proxer_pay_webgui/ajax/print.json', {'name': document.getElementById('statement_name').innerHTML, 'length': $("select#export_length").val(), 'from_date': from_date, 'to_date': to_date}) } function add_listener_login(){ $("#login_credentials").off(); $("#login_credentials").keypress(function(event){ if (event.keyCode == 13) { document.getElementById('login').click(); event.preventDefault(); } }); } function on_scroll(){ offset_top = document.getElementById('content_parent').scrollTop; // console.log(offset_top); if (offset_top > 50 && animation_up_finished == true){ if (top_menu_hide_enabled == true){ animation_up_finished = false $("#index_body_top").animate({top: "-50px"}, animation_speed, function() {animation_up_finished = true}); } } else if (offset_top < 50 && animation_down_finished == true){ animation_down_finished = false $("#index_body_top").animate({top: "0px"}, animation_speed, function() {animation_down_finished = true}); } } function set_cookie(name, value, expires_days){ // console.log(value); var expires = ""; if (expires_days) { var date = new Date(); date.setTime(date.getTime() + (expires_days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function get_cookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i