var timer = null; $(function() { var demo1 = $("#banner").slippry({ // transition: 'fade', // useCSS: true, // speed: 1000, // pause: 3000, // auto: true, responsive: true // autoHover: false }); }); $(window).ready(function() { $(".nav").sticky({ topSpacing: 80 }); $('.logo').sticky({ topSpacing: 0 }); $('.top-middle').sticky({ topSpacing: 0 }); $('#mobile-nav').sticky({ topSpacing: 0 }); $.get('/cart/minicart/load',function(data) { $('#minicart').html(data); }); $('.cart').hover(function() { $('#minicart').show(); },function() { $('#minicart').hide(); }); $('.tab-nav-link').on('click',function(e) { e.preventDefault(); var anchor = $(this).attr('href'); $('.content').hide(); $(anchor).show(); }); $('#chBox').on('click',function() { if ($(this).is(':checked')) { $('#billingDetails').slideUp(); } else { $('#billingDetails').slideDown(); } }); $('#password').keypress(function(e) { if (e.keyCode===13) { login(); } }); //Alert bars var barTimer = setInterval(function() { $('.bar').fadeOut('slow'); clearInterval(barTimer); },5000); //Range slider var ranger = document.getElementById('range'); noUiSlider.create(ranger,{ start: [0,maxPrice], step: 10, range: { 'min': 0, 'max': maxPrice } }); if (actualMin!=='' && actualMax!=='' && actualMin>0 && actualMax>0) { ranger.noUiSlider.set([actualMin,actualMax]); } //Ranger event handler ranger.noUiSlider.on('update',function (values,handle) { if (handle) { var mp = values[handle].replace('.00',''); mp = mp.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 "); $('#maxPrice').html(mp); $('#maxval').val(values[handle].replace('.00','')); } else { var mp = values[handle].replace('.00',''); mp = mp.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 "); $('#minPrice').html(mp); $('#minval').val(values[handle].replace('.00','')); } }); //End of range slider $('#accept').parent('div').children('label').children('span').on('click',function() { alert('ok'); }); }); function searchEnter(e) { if (e.keyCode===13) { searchClick(); } } function searchEnterMobile(e) { if (e.keyCode===13) { searchClickMobile(); } } function searchClick() { var keyword = $('#search').val(); if (keyword!=='') { var categories = []; var categoryJSON = ''; $('.category_checkbox').each(function() { if ($(this).is(':checked')) { categories.push($(this).attr('data-category-id')); } }); categoryJSON = JSON.stringify(categories); window.location='/search/index/'+keyword+'/?categories='+categoryJSON; } else { $('.search').addClass('error-empty'); } } function searchClickMobile() { var keyword = $('#search-mobile').val(); if (keyword!=='') { var categories = []; var categoryJSON = ''; $('.category_checkbox').each(function() { if ($(this).is(':checked')) { categories.push($(this).attr('data-category-id')); } }); categoryJSON = JSON.stringify(categories); window.location='/search/index/'+keyword+'/?categories='+categoryJSON; } else { $('.search').addClass('error-empty'); } } function add_to_cart(product_id) { var hasError = false; var animdelay = null; if (product_id!=='') { if (has_numberbox()) { var options = {}; $('.options').each(function() { if ($(this).val!=='') { options[$(this).attr('name')] = $(this).val(); } }); options = JSON.stringify(options); if ($('li').hasClass('color-box')) { if ($('#color').val()==='') { hasError = true; } else { hasError = false; } } if (hasError) { //$('.color-error').show(); if (lang==='hu') { open_modal('#error-message','Kérjük válasszon színt!'); } else { open_modal('#error-message','Please choose color!'); } } else { $('#cart_icon').addClass('animated bounce'); $('#cart-mobiled').addClass('animated bounce'); $.post('/cart/add/'+product_id,{options: options, qnt: numberbox_get()},function(data) { $('#minicart').html(data); update_mini_cart(); animdelay = setInterval(function() { $('#cart_icon').removeClass('animated bounce'); $('#cart-mobiled').removeClass('animated bounce'); },3000); return true; }); } } else { numberbox_error(); } } else { return false; } } function delete_from_cart(product_id,reload,url) { if (product_id!=='') { $.get('/cart/delete/'+product_id,function(data) { if (reload===true) { if (url) { window.location=url; } else { window.location='/cart'; } } $('#minicart').html(data); update_mini_cart(); return true; }); } else { return false; } } function delete_direct_from_cart(cartitem_id,reload,url) { if (cartitem_id!=='') { $.get('/cart/deletedirect/'+cartitem_id,function(data) { if (reload===true) { if (url) { window.location=url; } else { window.location='/cart'; } } $('#minicart').html(data); update_mini_cart(); return true; }); } else { return false; } } function inc_cart_item(cart_item_id,obj) { if (cart_item_id) { $.getJSON('/cart/increment/'+cart_item_id,function(data) { $('#cart_item_qnt_'+cart_item_id).val(data['qnt']); $('#cart_direct_item_'+cart_item_id).val(data['qnt']); $('#item_price_'+cart_item_id).html(data['item_price']+' Ft'); $('#sumprice').html(data['sum_price']+' Ft'); $('#summa').html(data['sum_price']+' Ft'); update_mini_cart(); }); } else { return false; } } function dec_cart_item(cart_item_id) { if (cart_item_id) { $.getJSON('/cart/decrement/'+cart_item_id,function(data) { $('#cart_item_qnt_'+cart_item_id).val(data['qnt']); $('#cart_direct_item_'+cart_item_id).val(data['qnt']); $('#item_price_'+cart_item_id).html(data['item_price']+' Ft'); $('#sumprice').html(data['sum_price']+' Ft'); $('#summa').html(data['sum_price']+' Ft'); update_mini_cart(); }); } else { return false; } } function inc_product_item(cart_item_id) { if (cart_item_id) { $.getJSON('/cart/increment/'+cart_item_id,function(data) { $('#cart_item_qnt_'+cart_item_id).html(data['qnt']); $('#item_price_'+cart_item_id).html(data['item_price']+' Ft'); $('#sumprice').html(data['sum_price']+' Ft'); $('#summa').html(data['sum_price']+' Ft'); update_mini_cart(); }); } else { return false; } } function dec_product_item(cart_item_id) { if (cart_item_id) { $.getJSON('/cart/decrement/'+cart_item_id,function(data) { $('#cart_item_qnt_'+cart_item_id).html(data['qnt']); $('#item_price_'+cart_item_id).html(data['item_price']+' Ft'); $('#sumprice').html(data['sum_price']+' Ft'); $('#summa').html(data['sum_price']+' Ft'); update_mini_cart(); }); } else { return false; } } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function send_order(type,editor) { var hasError = false; $('#sendorder').attr('disabled','true'); if ($('#vnev').val()==='') { hasError = true; $('#vnev').parent('div').addClass('error'); } else { $('#vnev').parent('div').removeClass('error'); } if ($('#knev').val()==='') { hasError = true; $('#knev').parent('div').addClass('error'); } else { $('#knev').parent('div').removeClass('error'); } if ($('#email').val()==='') { hasError = true; $('#email').parent('div').addClass('error'); } else { $('#email').parent('div').removeClass('error'); } if (!isEmail($('#email').val())) { hasError = true; $('#email').parent('div').addClass('error'); } else { $('#email').parent('div').removeClass('error'); } if (editor!=='sales') { if ($('#accept').is(':checked')===false) { hasError = true; //$('#accept').parent('div').css('border','solid 2px #E05E73'); $('#accept').parent('div').children('label').children('span').css('border','solid 2px #E05E73'); } else { $('#accept').parent('div').parent('div').removeClass('error'); $('#accept').parent('div').children('label').children('span').css('border','2px solid #b7c0c7'); } } // if ($('#pass1').val()==='') { // hasError = true; // $('#pass1').parent('div').addClass('error'); // } // else { // $('#pass1').parent('div').removeClass('error'); // } // // if ($('#pass1').val()!==$('#pass2').val() || $('#pass2').val()==='') { // hasError = true; // $('#pass2').parent('div').addClass('error'); // } // else { // $('#pass2').parent('div').removeClass('error'); // } if ($('#tel').val()==='') { hasError = true; $('#tel').parent('div').addClass('error'); } else { $('#tel').parent('div').removeClass('error'); } if (editor==='sales') { if ($('#ajanlat_ervenyesseg').val()==='') { hasError = true; $('#ajanlat_ervenyesseg').parent('div').addClass('error'); } else { $('#ajanlat_ervenyesseg').parent('div').removeClass('error'); } if ($('#szallitasi_ido').val()==='') { hasError = true; $('#szallitasi_ido').parent('div').addClass('error'); } else { $('#szallitasi_ido').parent('div').removeClass('error'); } } // if ($('#irsz').val()==='') { // hasError = true; // $('#irsz').parent('div').parent('div').addClass('error'); // } // else { // $('#irsz').parent('div').parent('div').removeClass('error'); // } // // if ($('#telepules').val()==='') { // hasError = true; // $('#telepules').parent('div').parent('div').addClass('error'); // } // else { // $('#telepules').parent('div').parent('div').removeClass('error'); // } // // if ($('#utca').val()==='') { // hasError = true; // $('#utca').parent('div').addClass('error'); // } // else { // $('#utca').parent('div').removeClass('error'); // } // if (!$('#chBox').is(':checked')) { // if ($('#sznev').val()==='') { // hasError = true; // $('#sznev').parent('div').addClass('error'); // } // else { // $('#sznev').parent('div').removeClass('error'); // } // // if ($('#szirsz').val()==='') { // hasError = true; // $('#szirsz').parent('div').parent('div').addClass('error'); // } // else { // $('#szirsz').parent('div').parent('div').removeClass('error'); // } // // if ($('#sztelepules').val()==='') { // hasError = true; // $('#sztelepules').parent('div').parent('div').addClass('error'); // } // else { // $('#sztelepules').parent('div').parent('div').removeClass('error'); // } // // if ($('#szutca').val()==='') { // hasError = true; // $('#szutca').parent('div').addClass('error'); // } // else { // $('#szutca').parent('div').removeClass('error'); // } // } $('#send_type').val(type); if (hasError===false) { $('#sendFRM').submit(); } else { $('#sendorder').removeAttr('disabled'); if (lang==='hu') { open_modal('#error-message','Kérjük ellenőrizze a megadott adatokat!'); } else { open_modal('#error-message','Please check order details!'); } } } function login(error1,error2) { var user = $('#username').val(); var pass = $('#password').val(); if (user!=='' && pass!=='') { $.getJSON('/user/auth/login',{username: user, password: pass},function(data) { if (data.status===true) { //$('.login-reg').hide(); $('.links').html(''); $('.login-reg').html(data.userbox); $('.links').html(data.usermenu); } else { $('#container_user').addClass('error'); $('#user_error_msg').html(data.message); $('#container_password').addClass('error'); } }); } else { $('#container_user').addClass('error'); $('#container_password').addClass('error'); $('#user_error_msg').html(error1); $('#password_error_msg').html(error2); } } function login_mobile(error1,error2) { var user = $('#username2').val(); var pass = $('#password2').val(); if (user!=='' && pass!=='') { $.getJSON('/user/auth/login',{username: user, password: pass},function(data) { if (data.status===true) { //$('.login-reg').hide(); window.location='/order/inbox'; } else { $('#container_user2').addClass('error'); $('#user_error_msg2').html(data.message); $('#container_password2').addClass('error'); } }); } else { $('#container_user2').addClass('error'); $('#container_password2').addClass('error'); $('#user_error_msg2').html(error1); $('#password_error_msg2').html(error2); } } function user_login() { var user = $('#login_username').val(); var pass = $('#login_password').val(); var redirect = $('#login_redirect').val(); if (user!=='' && pass!=='') { $.getJSON('/user/auth/login',{username: user, password: pass},function(data) { if (data.status===true) { window.location=redirect; } else { $('#login_username_container').addClass('error'); $('#login_error_text').html(data.message); $('#login_password_container').addClass('error'); } }); } else { $('#login_username_container').addClass('error'); $('#login_password_container').addClass('error'); $('#login_error_text').html('Kérjük adja meg a belépési adatokat!'); } } function user_reminder(error) { var user = $('#username').val(); if (user!=='') { $.post('/user/reminder/send',{login_username: user},function(data) { $('#userboxfrm').hide(); $('#response_text').html(data); $('#usermessage').show(); }); } else { $('#container_user').addClass('error'); $('#user_error_msg').html(error); } } function add_new_product() { $('#addnew').toggle(); } function add_product_to_cart() { var nev = $('#termeknev').val(); var ar = $('#termekar').val(); var leiras = $('#termekleiras').val(); var error = false; if (nev==='') { error = true; $('#termeknev').parent('div').parent('div').addClass('error'); } if (ar==='') { error = true; $('#termekar').parent('div').parent('div').addClass('error'); } if (!error) { $.post('/order/products/add',{nev: nev, ar: ar, leiras: leiras},function(data) { window.location.reload(); }); } } function update_item_number_value(cart_item_id,number,obj) { if (cart_item_id && number>0) { $.getJSON('/cart/update/'+cart_item_id+'/',{qnt: number},function(data) { $('#cart_item_qnt_'+cart_item_id).html(data['qnt']); $('#cart_direct_item_'+cart_item_id).val(data['qnt']); $('#item_price_'+cart_item_id).html(data['item_price']+' Ft'); $('#sumprice').html(data['sum_price']+' Ft'); $('#summa').html(data['sum_price']+' Ft'); update_mini_cart(); }); } else { return false; } } function update_item_price(cart_item_id,price) { if (cart_item_id) { $.post('/cart/updateprice/'+cart_item_id,{price: price},function(data) { $('#cart_wrapper').html(data); input_initialization(); update_mini_cart(); }); } } function resert_price(cart_item_id) { if (cart_item_id) { $.post('/cart/resetprice/'+cart_item_id,function(data) { $('#cart_wrapper').html(data); input_initialization(); update_mini_cart(); }); } } function update_mini_cart() { $.get('/cart/minicart',function(data) { $('#minicart').html(data); }); $.getJSON('/cart/cartinfo',function(data) { if (data['sumqnt']==null) data['sumqnt'] = '0'; if (lang==='hu') { $('#mini_sumqnt').html(data['sumqnt']+' termék'); $('#prodnumber').html(data['sumqnt']); $('#mini_sumprice').html(data['sumprice']+' Ft'); } else { $('#mini_sumqnt').html(data['sumqnt']+' products'); $('#prodnumber').html(data['sumqnt']); $('#mini_sumprice').html(data['sumprice']+' Ft'); } }); } function add_direct_product() { var prod_name = $('#direct_cartitem_procut_name').val(); var prod_desc = $('#direct_cartitem_product_desc').val(); var prod_price = parseInt($('#direct_cartitem_product_price').val()); var prod_qnt = parseInt($('#direct_cartitem_product_qnt').val()); var hasError = false; var file_data = $('#kep').prop('files')[0]; var form_data = new FormData(); form_data.append('file', file_data); form_data.append('prod_name',prod_name); form_data.append('prod_price',prod_price); form_data.append('prod_qnt',prod_qnt); form_data.append('prod_desc',prod_desc); if (prod_name==='') { $('#direct_cartitem_procut_name').addClass('input-error'); hasError = true; } if (prod_price==='') { $('#direct_cartitem_product_price').addClass('input-error'); hasError = true; } if (prod_qnt==='' || prod_qnt===0) { $('#direct_cartitem_product_qnt').addClass('input-error'); hasError = true; } if (!hasError) { $.ajax({ url: '/cart/adddirect/', dataType: 'text', cache: false, contentType: false, processData: false, data: form_data, type: 'post', success: function(data) { $('#cart_wrapper').html(data); input_initialization(); update_mini_cart(); } }); // $.post('/cart/adddirect/',{prod_name: prod_name, prod_price: prod_price, prod_qnt: prod_qnt, prod_desc: prod_desc},function(data) { // $('#cart_wrapper').html(data); // input_initialization(); // update_mini_cart(); // }); } } function add_direct_product_item(id) { var hash_name = '#direct_cartitem_procut_name_'+id; var hash_desc = '#direct_cartitem_product_desc_'+id; var hash_price = '#direct_cartitem_product_price_'+id; var hash_qnt = '#direct_cartitem_product_qnt_'+id; var prod_name = $(hash_name).val(); var prod_desc = $(hash_desc).val(); var prod_price = parseInt($(hash_price).val()); var prod_qnt = parseInt($(hash_qnt).val()); var hasError = false; if (prod_name==='') { $('#direct_cartitem_procut_name').addClass('input-error'); hasError = true; } if (prod_price==='') { $('#direct_cartitem_product_price').addClass('input-error'); hasError = true; } if (prod_qnt==='' || prod_qnt===0) { $('#direct_cartitem_product_qnt').addClass('input-error'); hasError = true; } if (!hasError) { $.post('/cart/adddirect/',{prod_id: id, prod_name: prod_name, prod_price: prod_price, prod_qnt: prod_qnt, prod_desc: prod_desc},function(data) { $('#cart_wrapper').html(data); input_initialization(); update_mini_cart(); }); } } function set_orig_price_visibility(cart_item_id) { if (cart_item_id) { $.post('/cart/setorigprice/'+cart_item_id,function(data) { }); } else { return false; } } function select_color(obj) { $('.color-box').html(' '); $('.color-error').hide(); if (obj) { var color = $(obj).attr('data-color'); $('#color').val(color); $(obj).html(''); } else { $(obj).html(' '); $('#color').val(''); } } function checkit(obj) { if ($(obj).children('span').children('i').hasClass('checkedin')) { $(obj).children('span').children('i').removeClass('checkedin'); $(obj).css('border','none'); } else { $(obj).children('span').children('i').addClass('checkedin'); } } function modalSendEmail(url) { var dialog = nanoModal("Valóban el szertené küldeni az árajánlatot az ügyfélnek?",{ overlayClose: false, buttons: [ {text: "Igen", handler: function(modal) { window.location = url; }, primary: true }, {text: "Nem", handler: "hide"} ] }); dialog.show(); } function sendSearch() { var cid = ''; var list = ''; $('.ccategories').each(function() { if ($(this).attr('data-cid')!=='' && $(this).children('span').children('i').hasClass('checkedin')) { list+= $(this).attr('data-cid')+','; } }); $('#categories_list').val(list); list = ''; var colors = ''; $('.filtered').each(function() { colors+= $(this).children('label').attr('data-id')+','; }); $('#colors_list').val(colors); list = ''; $('.cmaterials').each(function() { if ($(this).attr('data-cid')!=='' && $(this).children('span').children('i').hasClass('checkedin')) { list+= $(this).attr('data-cid')+','; } }); $('#materials_list').val(list); } function filterit(obj) { if ($(obj).parent('li').hasClass('filtered')) { $(obj).parent('li').removeClass('filtered'); $(obj).parent('li').css('border-color','transparent'); } else { $(obj).parent('li').addClass('filtered'); var bg = $(obj).parent('li').attr('data-over'); $(obj).parent('li').css('border-color','#666565'); } } function filter() { var catid = $('#cid').val(); var colors = ''; var materials = ''; var maxprice = $('#maxPrice').val(); var minprice = $('#minPrice').val(); var keyword = $('#filter_keyword').val(); var slug = $('#cslug').val(); $('.product-list-2').html($('.product-list-2').attr('data-msg')); $('.sccolor').each(function() { if ($(this).parent('li').hasClass('filtered')) { colors+= $(this).attr('data-id')+','; } }); $('.scmaterial').each(function() { if ($(this).parent('li').hasClass('filtered')) { materials+= $(this).attr('data-id')+','; } }); $.post('/categories/filter/'+slug,{colors: colors, materials: materials, minprice: minprice, maxprice: maxprice, keyword: keyword, category: catid},function(data) { $('.product-list-2').html(data); }); } function selectSales(obj) { if (obj && $(obj).val()!=='' && $(obj).val()!=='0') { $.post('/order/sales/set',{orderid: $(obj).attr('data-orderid'), salesid: $(obj).val()}); return true; } else { return false; } } function setPrintColor(obj) { var id = $(obj).attr('data-cartitemid'); var ertek = $(obj).val(); if (ertek!=='' && ertek!=='Nem kérek emblémát') { $('#printing_locations_'+id).show(); } else { $('#printing_locations_'+id).hide(); } $.post('/order/printing/color',{ id: id, ertek: ertek }); return true; } function setPrintPosition(obj) { var id = $(obj).attr('data-cartitemid'); var ertek = $(obj).val(); $.post('/order/printing/position',{ id: id, ertek: ertek }); return true; } function show_mobile_menu() { $('#mobile-menu').slideToggle('fast'); if ($('#mobile-search').is(':visible')) $('#mobile-search').hide(); if ($('#mobile-login').is(':visible')) $('#mobile-login').hide(); } function show_mobile_search() { $('#mobile-search').slideToggle('fast'); if ($('#mobile-login').is(':visible')) $('#mobile-login').hide(); if ($('#mobile-menu').is(':visible')) $('#mobile-menu').hide(); } function show_mobile_login() { $('#mobile-login').slideToggle('fast'); if ($('#mobile-menu').is(':visible')) $('#mobile-menu').hide(); if ($('#mobile-search').is(':visible')) $('#mobile-search').hide(); } function show_mobile_cart(url) { window.location=url; } function reminder() { $('#container_password').hide(); $('#sendlogin').hide(); $('#login_title').hide(); $('#sendpwreminder').show(); $('#reminder_title').show(); } function back_to_login() { $('#sendpwreminder').hide(); $('#reminder_title').hide(); $('#container_password').show(); $('#sendlogin').show(); $('#login_title').show(); $('#usermessage').hide(); $('#userboxfrm').show(); $('#response_text').html(''); } function open_modal(id,text) { var ww = $(window).width(); if (ww>1000) { $(id).children('h6').html(text); $(id).slideToggle(); timer = setInterval(function() { close_modal(id); },5000); } else { $(id+'2').children('h6').html(text); $(id+'2').slideToggle(); timer = setInterval(function() { close_modal(id+'2'); },5000); } } function close_modal(id) { if (id) { $(id).slideToggle(); $(id).children('h6').html(''); clearInterval(timer); } } function isNumber(evt) { evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } return true; } function checkover(obj) { if (!$(obj).hasClass('filtered')) { } } function checkout(obj) { if (!$(obj).hasClass('filtered')) { } }