jQuery.fn.extend({ scrollTo : function(speed, easing) { return this.each(function() { var targetOffset = $(this).offset().top; $('html,body').animate({scrollTop: targetOffset}, speed, easing); }); } }); $(document).ready(function() { function toggleMenu() { $('.js-btn-nav').toggleClass('active'); $('.js-header-menu').slideToggle(); } $(document).on('click', '.js-btn-nav', function(e) { e.preventDefault(); toggleMenu(); }); $('.js-owl-carousel').owlCarousel({ autoplay: true, items: 1, loop: true, nav: true }); $(".js-scrollto").click(function(e) { e.preventDefault(); const href = $(this).attr("href"); $(href).scrollTo(1000); }); $('#uploadcw_a').click(function(e) { e.preventDefault(); $('#cv_file').click(); }); window.jobforminsubmit = false; $("#jobform").submit(function(e) { if (window.jobforminsubmit) { return; } window.jobforminsubmit = true; e.preventDefault(); var formData = new FormData(this); $("#loadingLayer").show(); $.ajax({ url: '/jobform', type: 'POST', data: formData, dataType: "json", success: function (ret) { $("#loadingLayer").hide(); window.jobforminsubmit = false; if (ret.success) { alert (ret.msg); window.location = '/'; return; } alert (ret.msg); }, error: function () { $("#loadingLayer").hide(); window.jobforminsubmit = false; }, cache: false, contentType: false, processData: false }); }); window.contactforminsubmit = false; $("#contactform").submit(function(e) { if (window.contactforminsubmit) { return; } window.contactforminsubmit = true; e.preventDefault(); var formData = new FormData(this); $("#loadingLayer").show(); $.ajax({ url: '/contactform', type: 'POST', data: formData, dataType: "json", success: function (ret) { $("#loadingLayer").hide(); window.contactforminsubmit = false; if (ret.success) { alert (ret.msg); window.location = '/'; return; } alert (ret.msg); }, error: function () { $("#loadingLayer").hide(); window.contactforminsubmit = false; }, cache: false, contentType: false, processData: false }); }); });