events.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. var timer = null;
  2. $(function() {
  3. var demo1 = $("#banner").slippry({
  4. // transition: 'fade',
  5. // useCSS: true,
  6. // speed: 1000,
  7. // pause: 3000,
  8. // auto: true,
  9. responsive: true
  10. // autoHover: false
  11. });
  12. });
  13. $(window).ready(function() {
  14. $(".nav").sticky({ topSpacing: 80 });
  15. $('.logo').sticky({ topSpacing: 0 });
  16. $('.top-middle').sticky({ topSpacing: 0 });
  17. $('#mobile-nav').sticky({ topSpacing: 0 });
  18. $.get('/cart/minicart/load',function(data) {
  19. $('#minicart').html(data);
  20. });
  21. $('.cart').hover(function() {
  22. $('#minicart').show();
  23. },function() {
  24. $('#minicart').hide();
  25. });
  26. $('.tab-nav-link').on('click',function(e) {
  27. e.preventDefault();
  28. var anchor = $(this).attr('href');
  29. $('.content').hide();
  30. $(anchor).show();
  31. });
  32. $('#chBox').on('click',function() {
  33. if ($(this).is(':checked')) {
  34. $('#billingDetails').slideUp();
  35. }
  36. else {
  37. $('#billingDetails').slideDown();
  38. }
  39. });
  40. $('#password').keypress(function(e) {
  41. if (e.keyCode===13) {
  42. login();
  43. }
  44. });
  45. //Alert bars
  46. var barTimer = setInterval(function() {
  47. $('.bar').fadeOut('slow');
  48. clearInterval(barTimer);
  49. },5000);
  50. //Range slider
  51. var ranger = document.getElementById('range');
  52. noUiSlider.create(ranger,{
  53. start: [0,maxPrice],
  54. step: 10,
  55. range: {
  56. 'min': 0,
  57. 'max': maxPrice
  58. }
  59. });
  60. if (actualMin!=='' && actualMax!=='' && actualMin>0 && actualMax>0) {
  61. ranger.noUiSlider.set([actualMin,actualMax]);
  62. }
  63. //Ranger event handler
  64. ranger.noUiSlider.on('update',function (values,handle) {
  65. if (handle) {
  66. var mp = values[handle].replace('.00','');
  67. mp = mp.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 ");
  68. $('#maxPrice').html(mp);
  69. $('#maxval').val(values[handle].replace('.00',''));
  70. }
  71. else {
  72. var mp = values[handle].replace('.00','');
  73. mp = mp.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 ");
  74. $('#minPrice').html(mp);
  75. $('#minval').val(values[handle].replace('.00',''));
  76. }
  77. });
  78. //End of range slider
  79. $('#accept').parent('div').children('label').children('span').on('click',function() {
  80. alert('ok');
  81. });
  82. });
  83. function searchEnter(e) {
  84. if (e.keyCode===13) {
  85. searchClick();
  86. }
  87. }
  88. function searchEnterMobile(e) {
  89. if (e.keyCode===13) {
  90. searchClickMobile();
  91. }
  92. }
  93. function searchClick() {
  94. var keyword = $('#search').val();
  95. if (keyword!=='') {
  96. var categories = [];
  97. var categoryJSON = '';
  98. $('.category_checkbox').each(function() {
  99. if ($(this).is(':checked')) {
  100. categories.push($(this).attr('data-category-id'));
  101. }
  102. });
  103. categoryJSON = JSON.stringify(categories);
  104. window.location='/search/index/'+keyword+'/?categories='+categoryJSON;
  105. }
  106. else {
  107. $('.search').addClass('error-empty');
  108. }
  109. }
  110. function searchClickMobile() {
  111. var keyword = $('#search-mobile').val();
  112. if (keyword!=='') {
  113. var categories = [];
  114. var categoryJSON = '';
  115. $('.category_checkbox').each(function() {
  116. if ($(this).is(':checked')) {
  117. categories.push($(this).attr('data-category-id'));
  118. }
  119. });
  120. categoryJSON = JSON.stringify(categories);
  121. window.location='/search/index/'+keyword+'/?categories='+categoryJSON;
  122. }
  123. else {
  124. $('.search').addClass('error-empty');
  125. }
  126. }
  127. function add_to_cart(product_id) {
  128. var hasError = false;
  129. var animdelay = null;
  130. if (product_id!=='') {
  131. if (has_numberbox()) {
  132. var options = {};
  133. $('.options').each(function() {
  134. if ($(this).val!=='') {
  135. options[$(this).attr('name')] = $(this).val();
  136. }
  137. });
  138. options = JSON.stringify(options);
  139. if ($('li').hasClass('color-box')) {
  140. if ($('#color').val()==='') {
  141. hasError = true;
  142. }
  143. else {
  144. hasError = false;
  145. }
  146. }
  147. if (hasError) {
  148. //$('.color-error').show();
  149. if (lang==='hu') {
  150. open_modal('#error-message','Kérjük válasszon színt!');
  151. }
  152. else {
  153. open_modal('#error-message','Please choose color!');
  154. }
  155. }
  156. else {
  157. $('#cart_icon').addClass('animated bounce');
  158. $('#cart-mobiled').addClass('animated bounce');
  159. $.post('/cart/add/'+product_id,{options: options, qnt: numberbox_get()},function(data) {
  160. $('#minicart').html(data);
  161. update_mini_cart();
  162. animdelay = setInterval(function() {
  163. $('#cart_icon').removeClass('animated bounce');
  164. $('#cart-mobiled').removeClass('animated bounce');
  165. },3000);
  166. return true;
  167. });
  168. }
  169. }
  170. else {
  171. numberbox_error();
  172. }
  173. }
  174. else {
  175. return false;
  176. }
  177. }
  178. function delete_from_cart(product_id,reload,url) {
  179. if (product_id!=='') {
  180. $.get('/cart/delete/'+product_id,function(data) {
  181. if (reload===true) {
  182. if (url) {
  183. window.location=url;
  184. }
  185. else {
  186. window.location='/cart';
  187. }
  188. }
  189. $('#minicart').html(data);
  190. update_mini_cart();
  191. return true;
  192. });
  193. }
  194. else {
  195. return false;
  196. }
  197. }
  198. function delete_direct_from_cart(cartitem_id,reload,url) {
  199. if (cartitem_id!=='') {
  200. $.get('/cart/deletedirect/'+cartitem_id,function(data) {
  201. if (reload===true) {
  202. if (url) {
  203. window.location=url;
  204. }
  205. else {
  206. window.location='/cart';
  207. }
  208. }
  209. $('#minicart').html(data);
  210. update_mini_cart();
  211. return true;
  212. });
  213. }
  214. else {
  215. return false;
  216. }
  217. }
  218. function inc_cart_item(cart_item_id,obj) {
  219. if (cart_item_id) {
  220. $.getJSON('/cart/increment/'+cart_item_id,function(data) {
  221. $('#cart_item_qnt_'+cart_item_id).val(data['qnt']);
  222. $('#cart_direct_item_'+cart_item_id).val(data['qnt']);
  223. $('#item_price_'+cart_item_id).html(data['item_price']+' Ft');
  224. $('#sumprice').html(data['sum_price']+' Ft');
  225. $('#summa').html(data['sum_price']+' Ft');
  226. update_mini_cart();
  227. });
  228. }
  229. else {
  230. return false;
  231. }
  232. }
  233. function dec_cart_item(cart_item_id) {
  234. if (cart_item_id) {
  235. $.getJSON('/cart/decrement/'+cart_item_id,function(data) {
  236. $('#cart_item_qnt_'+cart_item_id).val(data['qnt']);
  237. $('#cart_direct_item_'+cart_item_id).val(data['qnt']);
  238. $('#item_price_'+cart_item_id).html(data['item_price']+' Ft');
  239. $('#sumprice').html(data['sum_price']+' Ft');
  240. $('#summa').html(data['sum_price']+' Ft');
  241. update_mini_cart();
  242. });
  243. }
  244. else {
  245. return false;
  246. }
  247. }
  248. function inc_product_item(cart_item_id) {
  249. if (cart_item_id) {
  250. $.getJSON('/cart/increment/'+cart_item_id,function(data) {
  251. $('#cart_item_qnt_'+cart_item_id).html(data['qnt']);
  252. $('#item_price_'+cart_item_id).html(data['item_price']+' Ft');
  253. $('#sumprice').html(data['sum_price']+' Ft');
  254. $('#summa').html(data['sum_price']+' Ft');
  255. update_mini_cart();
  256. });
  257. }
  258. else {
  259. return false;
  260. }
  261. }
  262. function dec_product_item(cart_item_id) {
  263. if (cart_item_id) {
  264. $.getJSON('/cart/decrement/'+cart_item_id,function(data) {
  265. $('#cart_item_qnt_'+cart_item_id).html(data['qnt']);
  266. $('#item_price_'+cart_item_id).html(data['item_price']+' Ft');
  267. $('#sumprice').html(data['sum_price']+' Ft');
  268. $('#summa').html(data['sum_price']+' Ft');
  269. update_mini_cart();
  270. });
  271. }
  272. else {
  273. return false;
  274. }
  275. }
  276. function isEmail(email) {
  277. var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  278. return regex.test(email);
  279. }
  280. function send_order(type,editor) {
  281. var hasError = false;
  282. $('#sendorder').attr('disabled','true');
  283. if ($('#vnev').val()==='') {
  284. hasError = true;
  285. $('#vnev').parent('div').addClass('error');
  286. }
  287. else {
  288. $('#vnev').parent('div').removeClass('error');
  289. }
  290. if ($('#knev').val()==='') {
  291. hasError = true;
  292. $('#knev').parent('div').addClass('error');
  293. }
  294. else {
  295. $('#knev').parent('div').removeClass('error');
  296. }
  297. if ($('#email').val()==='') {
  298. hasError = true;
  299. $('#email').parent('div').addClass('error');
  300. }
  301. else {
  302. $('#email').parent('div').removeClass('error');
  303. }
  304. if (!isEmail($('#email').val())) {
  305. hasError = true;
  306. $('#email').parent('div').addClass('error');
  307. }
  308. else {
  309. $('#email').parent('div').removeClass('error');
  310. }
  311. if (editor!=='sales') {
  312. if ($('#accept').is(':checked')===false) {
  313. hasError = true;
  314. //$('#accept').parent('div').css('border','solid 2px #E05E73');
  315. $('#accept').parent('div').children('label').children('span').css('border','solid 2px #E05E73');
  316. }
  317. else {
  318. $('#accept').parent('div').parent('div').removeClass('error');
  319. $('#accept').parent('div').children('label').children('span').css('border','2px solid #b7c0c7');
  320. }
  321. }
  322. // if ($('#pass1').val()==='') {
  323. // hasError = true;
  324. // $('#pass1').parent('div').addClass('error');
  325. // }
  326. // else {
  327. // $('#pass1').parent('div').removeClass('error');
  328. // }
  329. //
  330. // if ($('#pass1').val()!==$('#pass2').val() || $('#pass2').val()==='') {
  331. // hasError = true;
  332. // $('#pass2').parent('div').addClass('error');
  333. // }
  334. // else {
  335. // $('#pass2').parent('div').removeClass('error');
  336. // }
  337. if ($('#tel').val()==='') {
  338. hasError = true;
  339. $('#tel').parent('div').addClass('error');
  340. }
  341. else {
  342. $('#tel').parent('div').removeClass('error');
  343. }
  344. if (editor==='sales') {
  345. if ($('#ajanlat_ervenyesseg').val()==='') {
  346. hasError = true;
  347. $('#ajanlat_ervenyesseg').parent('div').addClass('error');
  348. }
  349. else {
  350. $('#ajanlat_ervenyesseg').parent('div').removeClass('error');
  351. }
  352. if ($('#szallitasi_ido').val()==='') {
  353. hasError = true;
  354. $('#szallitasi_ido').parent('div').addClass('error');
  355. }
  356. else {
  357. $('#szallitasi_ido').parent('div').removeClass('error');
  358. }
  359. }
  360. // if ($('#irsz').val()==='') {
  361. // hasError = true;
  362. // $('#irsz').parent('div').parent('div').addClass('error');
  363. // }
  364. // else {
  365. // $('#irsz').parent('div').parent('div').removeClass('error');
  366. // }
  367. //
  368. // if ($('#telepules').val()==='') {
  369. // hasError = true;
  370. // $('#telepules').parent('div').parent('div').addClass('error');
  371. // }
  372. // else {
  373. // $('#telepules').parent('div').parent('div').removeClass('error');
  374. // }
  375. //
  376. // if ($('#utca').val()==='') {
  377. // hasError = true;
  378. // $('#utca').parent('div').addClass('error');
  379. // }
  380. // else {
  381. // $('#utca').parent('div').removeClass('error');
  382. // }
  383. // if (!$('#chBox').is(':checked')) {
  384. // if ($('#sznev').val()==='') {
  385. // hasError = true;
  386. // $('#sznev').parent('div').addClass('error');
  387. // }
  388. // else {
  389. // $('#sznev').parent('div').removeClass('error');
  390. // }
  391. //
  392. // if ($('#szirsz').val()==='') {
  393. // hasError = true;
  394. // $('#szirsz').parent('div').parent('div').addClass('error');
  395. // }
  396. // else {
  397. // $('#szirsz').parent('div').parent('div').removeClass('error');
  398. // }
  399. //
  400. // if ($('#sztelepules').val()==='') {
  401. // hasError = true;
  402. // $('#sztelepules').parent('div').parent('div').addClass('error');
  403. // }
  404. // else {
  405. // $('#sztelepules').parent('div').parent('div').removeClass('error');
  406. // }
  407. //
  408. // if ($('#szutca').val()==='') {
  409. // hasError = true;
  410. // $('#szutca').parent('div').addClass('error');
  411. // }
  412. // else {
  413. // $('#szutca').parent('div').removeClass('error');
  414. // }
  415. // }
  416. $('#send_type').val(type);
  417. if (hasError===false) {
  418. $('#sendFRM').submit();
  419. }
  420. else {
  421. $('#sendorder').removeAttr('disabled');
  422. if (lang==='hu') {
  423. open_modal('#error-message','Kérjük ellenőrizze a megadott adatokat!');
  424. }
  425. else {
  426. open_modal('#error-message','Please check order details!');
  427. }
  428. }
  429. }
  430. function login(error1,error2) {
  431. var user = $('#username').val();
  432. var pass = $('#password').val();
  433. if (user!=='' && pass!=='') {
  434. $.getJSON('/user/auth/login',{username: user, password: pass},function(data) {
  435. if (data.status===true) {
  436. //$('.login-reg').hide();
  437. $('.links').html('<ul><li><a href="/order/inbox">Beérkezett ajánlatok</li><li><a href="/order/sent">Elküldött ajánlatok</li><li><a href="/user/auth/logout">Kilépés</li></ul>');
  438. $('.login-reg').html(data.userbox);
  439. $('.links').html(data.usermenu);
  440. }
  441. else {
  442. $('#container_user').addClass('error');
  443. $('#user_error_msg').html(data.message);
  444. $('#container_password').addClass('error');
  445. }
  446. });
  447. }
  448. else {
  449. $('#container_user').addClass('error');
  450. $('#container_password').addClass('error');
  451. $('#user_error_msg').html(error1);
  452. $('#password_error_msg').html(error2);
  453. }
  454. }
  455. function login_mobile(error1,error2) {
  456. var user = $('#username2').val();
  457. var pass = $('#password2').val();
  458. if (user!=='' && pass!=='') {
  459. $.getJSON('/user/auth/login',{username: user, password: pass},function(data) {
  460. if (data.status===true) {
  461. //$('.login-reg').hide();
  462. window.location='/order/inbox';
  463. }
  464. else {
  465. $('#container_user2').addClass('error');
  466. $('#user_error_msg2').html(data.message);
  467. $('#container_password2').addClass('error');
  468. }
  469. });
  470. }
  471. else {
  472. $('#container_user2').addClass('error');
  473. $('#container_password2').addClass('error');
  474. $('#user_error_msg2').html(error1);
  475. $('#password_error_msg2').html(error2);
  476. }
  477. }
  478. function user_login() {
  479. var user = $('#login_username').val();
  480. var pass = $('#login_password').val();
  481. var redirect = $('#login_redirect').val();
  482. if (user!=='' && pass!=='') {
  483. $.getJSON('/user/auth/login',{username: user, password: pass},function(data) {
  484. if (data.status===true) {
  485. window.location=redirect;
  486. }
  487. else {
  488. $('#login_username_container').addClass('error');
  489. $('#login_error_text').html(data.message);
  490. $('#login_password_container').addClass('error');
  491. }
  492. });
  493. }
  494. else {
  495. $('#login_username_container').addClass('error');
  496. $('#login_password_container').addClass('error');
  497. $('#login_error_text').html('Kérjük adja meg a belépési adatokat!');
  498. }
  499. }
  500. function user_reminder(error) {
  501. var user = $('#username').val();
  502. if (user!=='') {
  503. $.post('/user/reminder/send',{login_username: user},function(data) {
  504. $('#userboxfrm').hide();
  505. $('#response_text').html(data);
  506. $('#usermessage').show();
  507. });
  508. }
  509. else {
  510. $('#container_user').addClass('error');
  511. $('#user_error_msg').html(error);
  512. }
  513. }
  514. function add_new_product() {
  515. $('#addnew').toggle();
  516. }
  517. function add_product_to_cart() {
  518. var nev = $('#termeknev').val();
  519. var ar = $('#termekar').val();
  520. var leiras = $('#termekleiras').val();
  521. var error = false;
  522. if (nev==='') {
  523. error = true;
  524. $('#termeknev').parent('div').parent('div').addClass('error');
  525. }
  526. if (ar==='') {
  527. error = true;
  528. $('#termekar').parent('div').parent('div').addClass('error');
  529. }
  530. if (!error) {
  531. $.post('/order/products/add',{nev: nev, ar: ar, leiras: leiras},function(data) {
  532. window.location.reload();
  533. });
  534. }
  535. }
  536. function update_item_number_value(cart_item_id,number,obj) {
  537. if (cart_item_id && number>0) {
  538. $.getJSON('/cart/update/'+cart_item_id+'/',{qnt: number},function(data) {
  539. $('#cart_item_qnt_'+cart_item_id).html(data['qnt']);
  540. $('#cart_direct_item_'+cart_item_id).val(data['qnt']);
  541. $('#item_price_'+cart_item_id).html(data['item_price']+' Ft');
  542. $('#sumprice').html(data['sum_price']+' Ft');
  543. $('#summa').html(data['sum_price']+' Ft');
  544. update_mini_cart();
  545. });
  546. }
  547. else {
  548. return false;
  549. }
  550. }
  551. function update_item_price(cart_item_id,price) {
  552. if (cart_item_id) {
  553. $.post('/cart/updateprice/'+cart_item_id,{price: price},function(data) {
  554. $('#cart_wrapper').html(data);
  555. input_initialization();
  556. update_mini_cart();
  557. });
  558. }
  559. }
  560. function resert_price(cart_item_id) {
  561. if (cart_item_id) {
  562. $.post('/cart/resetprice/'+cart_item_id,function(data) {
  563. $('#cart_wrapper').html(data);
  564. input_initialization();
  565. update_mini_cart();
  566. });
  567. }
  568. }
  569. function update_mini_cart() {
  570. $.get('/cart/minicart',function(data) {
  571. $('#minicart').html(data);
  572. });
  573. $.getJSON('/cart/cartinfo',function(data) {
  574. if (data['sumqnt']==null) data['sumqnt'] = '0';
  575. if (lang==='hu') {
  576. $('#mini_sumqnt').html(data['sumqnt']+' termék');
  577. $('#prodnumber').html(data['sumqnt']);
  578. $('#mini_sumprice').html(data['sumprice']+' Ft');
  579. }
  580. else {
  581. $('#mini_sumqnt').html(data['sumqnt']+' products');
  582. $('#prodnumber').html(data['sumqnt']);
  583. $('#mini_sumprice').html(data['sumprice']+' Ft');
  584. }
  585. });
  586. }
  587. function add_direct_product() {
  588. var prod_name = $('#direct_cartitem_procut_name').val();
  589. var prod_desc = $('#direct_cartitem_product_desc').val();
  590. var prod_price = parseInt($('#direct_cartitem_product_price').val());
  591. var prod_qnt = parseInt($('#direct_cartitem_product_qnt').val());
  592. var hasError = false;
  593. var file_data = $('#kep').prop('files')[0];
  594. var form_data = new FormData();
  595. form_data.append('file', file_data);
  596. form_data.append('prod_name',prod_name);
  597. form_data.append('prod_price',prod_price);
  598. form_data.append('prod_qnt',prod_qnt);
  599. form_data.append('prod_desc',prod_desc);
  600. if (prod_name==='') {
  601. $('#direct_cartitem_procut_name').addClass('input-error');
  602. hasError = true;
  603. }
  604. if (prod_price==='') {
  605. $('#direct_cartitem_product_price').addClass('input-error');
  606. hasError = true;
  607. }
  608. if (prod_qnt==='' || prod_qnt===0) {
  609. $('#direct_cartitem_product_qnt').addClass('input-error');
  610. hasError = true;
  611. }
  612. if (!hasError) {
  613. $.ajax({
  614. url: '/cart/adddirect/',
  615. dataType: 'text',
  616. cache: false,
  617. contentType: false,
  618. processData: false,
  619. data: form_data,
  620. type: 'post',
  621. success: function(data) {
  622. $('#cart_wrapper').html(data);
  623. input_initialization();
  624. update_mini_cart();
  625. }
  626. });
  627. // $.post('/cart/adddirect/',{prod_name: prod_name, prod_price: prod_price, prod_qnt: prod_qnt, prod_desc: prod_desc},function(data) {
  628. // $('#cart_wrapper').html(data);
  629. // input_initialization();
  630. // update_mini_cart();
  631. // });
  632. }
  633. }
  634. function add_direct_product_item(id) {
  635. var hash_name = '#direct_cartitem_procut_name_'+id;
  636. var hash_desc = '#direct_cartitem_product_desc_'+id;
  637. var hash_price = '#direct_cartitem_product_price_'+id;
  638. var hash_qnt = '#direct_cartitem_product_qnt_'+id;
  639. var prod_name = $(hash_name).val();
  640. var prod_desc = $(hash_desc).val();
  641. var prod_price = parseInt($(hash_price).val());
  642. var prod_qnt = parseInt($(hash_qnt).val());
  643. var hasError = false;
  644. if (prod_name==='') {
  645. $('#direct_cartitem_procut_name').addClass('input-error');
  646. hasError = true;
  647. }
  648. if (prod_price==='') {
  649. $('#direct_cartitem_product_price').addClass('input-error');
  650. hasError = true;
  651. }
  652. if (prod_qnt==='' || prod_qnt===0) {
  653. $('#direct_cartitem_product_qnt').addClass('input-error');
  654. hasError = true;
  655. }
  656. if (!hasError) {
  657. $.post('/cart/adddirect/',{prod_id: id, prod_name: prod_name, prod_price: prod_price, prod_qnt: prod_qnt, prod_desc: prod_desc},function(data) {
  658. $('#cart_wrapper').html(data);
  659. input_initialization();
  660. update_mini_cart();
  661. });
  662. }
  663. }
  664. function set_orig_price_visibility(cart_item_id) {
  665. if (cart_item_id) {
  666. $.post('/cart/setorigprice/'+cart_item_id,function(data) {
  667. });
  668. }
  669. else {
  670. return false;
  671. }
  672. }
  673. function select_color(obj) {
  674. $('.color-box').html('&nbsp;');
  675. $('.color-error').hide();
  676. if (obj) {
  677. var color = $(obj).attr('data-color');
  678. $('#color').val(color);
  679. $(obj).html('<i class="fa fa-check"></i>');
  680. }
  681. else {
  682. $(obj).html('&nbsp;');
  683. $('#color').val('');
  684. }
  685. }
  686. function checkit(obj) {
  687. if ($(obj).children('span').children('i').hasClass('checkedin')) {
  688. $(obj).children('span').children('i').removeClass('checkedin');
  689. $(obj).css('border','none');
  690. }
  691. else {
  692. $(obj).children('span').children('i').addClass('checkedin');
  693. }
  694. }
  695. function modalSendEmail(url) {
  696. var dialog = nanoModal("Valóban el szertené küldeni az árajánlatot az ügyfélnek?",{
  697. overlayClose: false,
  698. buttons: [
  699. {text: "Igen", handler: function(modal) { window.location = url; }, primary: true },
  700. {text: "Nem", handler: "hide"}
  701. ]
  702. });
  703. dialog.show();
  704. }
  705. function sendSearch() {
  706. var cid = '';
  707. var list = '';
  708. $('.ccategories').each(function() {
  709. if ($(this).attr('data-cid')!=='' && $(this).children('span').children('i').hasClass('checkedin')) {
  710. list+= $(this).attr('data-cid')+',';
  711. }
  712. });
  713. $('#categories_list').val(list);
  714. list = '';
  715. var colors = '';
  716. $('.filtered').each(function() {
  717. colors+= $(this).children('label').attr('data-id')+',';
  718. });
  719. $('#colors_list').val(colors);
  720. list = '';
  721. $('.cmaterials').each(function() {
  722. if ($(this).attr('data-cid')!=='' && $(this).children('span').children('i').hasClass('checkedin')) {
  723. list+= $(this).attr('data-cid')+',';
  724. }
  725. });
  726. $('#materials_list').val(list);
  727. }
  728. function filterit(obj) {
  729. if ($(obj).parent('li').hasClass('filtered')) {
  730. $(obj).parent('li').removeClass('filtered');
  731. $(obj).parent('li').css('border-color','transparent');
  732. }
  733. else {
  734. $(obj).parent('li').addClass('filtered');
  735. var bg = $(obj).parent('li').attr('data-over');
  736. $(obj).parent('li').css('border-color','#666565');
  737. }
  738. }
  739. function filter() {
  740. var catid = $('#cid').val();
  741. var colors = '';
  742. var materials = '';
  743. var maxprice = $('#maxPrice').val();
  744. var minprice = $('#minPrice').val();
  745. var keyword = $('#filter_keyword').val();
  746. var slug = $('#cslug').val();
  747. $('.product-list-2').html($('.product-list-2').attr('data-msg'));
  748. $('.sccolor').each(function() {
  749. if ($(this).parent('li').hasClass('filtered')) {
  750. colors+= $(this).attr('data-id')+',';
  751. }
  752. });
  753. $('.scmaterial').each(function() {
  754. if ($(this).parent('li').hasClass('filtered')) {
  755. materials+= $(this).attr('data-id')+',';
  756. }
  757. });
  758. $.post('/categories/filter/'+slug,{colors: colors, materials: materials, minprice: minprice, maxprice: maxprice, keyword: keyword, category: catid},function(data) {
  759. $('.product-list-2').html(data);
  760. });
  761. }
  762. function selectSales(obj) {
  763. if (obj && $(obj).val()!=='' && $(obj).val()!=='0') {
  764. $.post('/order/sales/set',{orderid: $(obj).attr('data-orderid'), salesid: $(obj).val()});
  765. return true;
  766. }
  767. else {
  768. return false;
  769. }
  770. }
  771. function setPrintColor(obj) {
  772. var id = $(obj).attr('data-cartitemid');
  773. var ertek = $(obj).val();
  774. if (ertek!=='' && ertek!=='Nem kérek emblémát') {
  775. $('#printing_locations_'+id).show();
  776. }
  777. else {
  778. $('#printing_locations_'+id).hide();
  779. }
  780. $.post('/order/printing/color',{
  781. id: id,
  782. ertek: ertek
  783. });
  784. return true;
  785. }
  786. function setPrintPosition(obj) {
  787. var id = $(obj).attr('data-cartitemid');
  788. var ertek = $(obj).val();
  789. $.post('/order/printing/position',{
  790. id: id,
  791. ertek: ertek
  792. });
  793. return true;
  794. }
  795. function show_mobile_menu() {
  796. $('#mobile-menu').slideToggle('fast');
  797. if ($('#mobile-search').is(':visible')) $('#mobile-search').hide();
  798. if ($('#mobile-login').is(':visible')) $('#mobile-login').hide();
  799. }
  800. function show_mobile_search() {
  801. $('#mobile-search').slideToggle('fast');
  802. if ($('#mobile-login').is(':visible')) $('#mobile-login').hide();
  803. if ($('#mobile-menu').is(':visible')) $('#mobile-menu').hide();
  804. }
  805. function show_mobile_login() {
  806. $('#mobile-login').slideToggle('fast');
  807. if ($('#mobile-menu').is(':visible')) $('#mobile-menu').hide();
  808. if ($('#mobile-search').is(':visible')) $('#mobile-search').hide();
  809. }
  810. function show_mobile_cart(url) {
  811. window.location=url;
  812. }
  813. function reminder() {
  814. $('#container_password').hide();
  815. $('#sendlogin').hide();
  816. $('#login_title').hide();
  817. $('#sendpwreminder').show();
  818. $('#reminder_title').show();
  819. }
  820. function back_to_login() {
  821. $('#sendpwreminder').hide();
  822. $('#reminder_title').hide();
  823. $('#container_password').show();
  824. $('#sendlogin').show();
  825. $('#login_title').show();
  826. $('#usermessage').hide();
  827. $('#userboxfrm').show();
  828. $('#response_text').html('');
  829. }
  830. function open_modal(id,text) {
  831. var ww = $(window).width();
  832. if (ww>1000) {
  833. $(id).children('h6').html(text);
  834. $(id).slideToggle();
  835. timer = setInterval(function() {
  836. close_modal(id);
  837. },5000);
  838. }
  839. else {
  840. $(id+'2').children('h6').html(text);
  841. $(id+'2').slideToggle();
  842. timer = setInterval(function() {
  843. close_modal(id+'2');
  844. },5000);
  845. }
  846. }
  847. function close_modal(id) {
  848. if (id) {
  849. $(id).slideToggle();
  850. $(id).children('h6').html('');
  851. clearInterval(timer);
  852. }
  853. }
  854. function isNumber(evt) {
  855. evt = (evt) ? evt : window.event;
  856. var charCode = (evt.which) ? evt.which : evt.keyCode;
  857. if (charCode > 31 && (charCode < 48 || charCode > 57)) {
  858. return false;
  859. }
  860. return true;
  861. }
  862. function checkover(obj) {
  863. if (!$(obj).hasClass('filtered')) {
  864. }
  865. }
  866. function checkout(obj) {
  867. if (!$(obj).hasClass('filtered')) {
  868. }
  869. }