From 9e17045dd17c066c69c66d637f65c96486f97ce0 Mon Sep 17 00:00:00 2001 From: Aravind V Nair <22199259+aravindvnair99@users.noreply.github.com> Date: Mon, 1 Oct 2018 00:59:32 +0530 Subject: [PATCH] Refactor --- js/contact_me.js | 75 --------------- js/contact_me.min.js | 1 - js/index.js | 216 +++++++++++++++++++++---------------------- 3 files changed, 108 insertions(+), 184 deletions(-) delete mode 100644 js/contact_me.js delete mode 100644 js/contact_me.min.js diff --git a/js/contact_me.js b/js/contact_me.js deleted file mode 100644 index 71698e6..0000000 --- a/js/contact_me.js +++ /dev/null @@ -1,75 +0,0 @@ -$(function () { - - $("#contactForm input,#contactForm textarea").jqBootstrapValidation({ - preventSubmit: true, - submitError: function ($form, event, errors) { - // additional error messages or events - }, - submitSuccess: function ($form, event) { - event.preventDefault(); // prevent default submit behaviour - // get values from FORM - var name = $("input#name").val(); - var email = $("input#email").val(); - var phone = $("input#phone").val(); - var message = $("textarea#message").val(); - var firstName = name; // For Success/Failure Message - // Check for white space in name for Success/Fail message - if (firstName.indexOf(' ') >= 0) { - firstName = name.split(' ').slice(0, -1).join(' '); - } - $this = $("#sendMessageButton"); - $this.prop("disabled", true); // Disable submit button until AJAX call is complete to prevent duplicate messages - $.ajax({ - url: "././mail/contact_me.php", - type: "POST", - data: { - name: name, - phone: phone, - email: email, - message: message - }, - cache: false, - success: function () { - // Success message - $('#success').html("
"); - $('#success > .alert-success').html(""); - $('#success > .alert-success') - .append("Your message has been sent. "); - $('#success > .alert-success') - .append('
'); - //clear all fields - $('#contactForm').trigger("reset"); - }, - error: function () { - // Fail message - $('#success').html("
"); - $('#success > .alert-danger').html(""); - $('#success > .alert-danger').append($("").text("Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!")); - $('#success > .alert-danger').append('
'); - //clear all fields - $('#contactForm').trigger("reset"); - }, - complete: function () { - setTimeout(function () { - $this.prop("disabled", false); // Re-enable submit button when AJAX call is complete - }, 1000); - } - }); - }, - filter: function () { - return $(this).is(":visible"); - }, - }); - - $("a[data-toggle=\"tab\"]").click(function (e) { - e.preventDefault(); - $(this).tab("show"); - }); -}); - -/*When clicking on Full hide fail/success boxes */ -$('#name').focus(function () { - $('#success').html(''); -}); diff --git a/js/contact_me.min.js b/js/contact_me.min.js deleted file mode 100644 index 0268cb1..0000000 --- a/js/contact_me.min.js +++ /dev/null @@ -1 +0,0 @@ -$(function(){$("#contactForm input,#contactForm textarea").jqBootstrapValidation({preventSubmit:!0,submitError:function(t,e,s){},submitSuccess:function(t,e){e.preventDefault();var s=$("input#name").val(),a=$("input#email").val(),n=$("input#phone").val(),c=$("textarea#message").val(),i=s;i.indexOf(" ")>=0&&(i=s.split(" ").slice(0,-1).join(" ")),$this=$("#sendMessageButton"),$this.prop("disabled",!0),$.ajax({url:"././mail/contact_me.php",type:"POST",data:{name:s,phone:n,email:a,message:c},cache:!1,success:function(){$("#success").html("
"),$("#success > .alert-success").html(""),$("#success > .alert-success").append("Your message has been sent. "),$("#success > .alert-success").append("
"),$("#contactForm").trigger("reset")},error:function(){$("#success").html("
"),$("#success > .alert-danger").html(""),$("#success > .alert-danger").append($("").text("Sorry "+i+", it seems that my mail server is not responding. Please try again later!")),$("#success > .alert-danger").append("
"),$("#contactForm").trigger("reset")},complete:function(){setTimeout(function(){$this.prop("disabled",!1)},1e3)}})},filter:function(){return $(this).is(":visible")}}),$('a[data-toggle="tab"]').click(function(t){t.preventDefault(),$(this).tab("show")})}),$("#name").focus(function(){$("#success").html("")}); \ No newline at end of file diff --git a/js/index.js b/js/index.js index c275177..13f8dc3 100644 --- a/js/index.js +++ b/js/index.js @@ -1,112 +1,112 @@ /* ---- particles.js config ---- */ particlesJS("particles-js", { - "particles": { - "number": { - "value": 100, - "density": { - "enable": true, - "value_area": 800 - } - }, - "color": { - "value": "#ffffff" - }, - "shape": { - "type": "polygon", - "stroke": { - "width": 0, - "color": "#000000" - }, - "polygon": { - "nb_sides": 5 - }, - "image": { - "src": "img/github.svg", - "width": 100, - "height": 100 - } - }, - "opacity": { - "value": 0.5, - "random": false, - "anim": { - "enable": false, - "speed": 1, - "opacity_min": 0.1, - "sync": false - } - }, - "size": { - "value": 4, - "random": true, - "anim": { - "enable": false, - "speed": 40, - "size_min": 0.1, - "sync": false - } - }, - "line_linked": { - "enable": true, - "distance": 150, - "color": "#00abff", - "opacity": 0.4, - "width": 1 - }, - "move": { - "enable": true, - "speed": 6, - "direction": "none", - "random": false, - "straight": false, - "out_mode": "out", - "bounce": false, - "attract": { - "enable": false, - "rotateX": 600, - "rotateY": 1200 - } - } - }, - "interactivity": { - "detect_on": "canvas", - "events": { - "onhover": { - "enable": true, - "mode": "grab" - }, - "onclick": { - "enable": true, - "mode": "push" - }, - "resize": true - }, - "modes": { - "grab": { - "distance": 400, - "line_linked": { - "opacity": 1 - } - }, - "bubble": { - "distance": 400, - "size": 40, - "duration": 2, - "opacity": 8, - "speed": 3 - }, - "repulse": { - "distance": 200, - "duration": 0.4 - }, - "push": { - "particles_nb": 4 - }, - "remove": { - "particles_nb": 2 - } - } - }, - "retina_detect": true + "particles": { + "number": { + "value": 100, + "density": { + "enable": true, + "value_area": 800 + } + }, + "color": { + "value": "#ffffff" + }, + "shape": { + "type": "polygon", + "stroke": { + "width": 0, + "color": "#000000" + }, + "polygon": { + "nb_sides": 5 + }, + "image": { + "src": "img/github.svg", + "width": 100, + "height": 100 + } + }, + "opacity": { + "value": 0.5, + "random": false, + "anim": { + "enable": false, + "speed": 1, + "opacity_min": 0.1, + "sync": false + } + }, + "size": { + "value": 4, + "random": true, + "anim": { + "enable": false, + "speed": 40, + "size_min": 0.1, + "sync": false + } + }, + "line_linked": { + "enable": true, + "distance": 150, + "color": "#00abff", + "opacity": 0.4, + "width": 1 + }, + "move": { + "enable": true, + "speed": 6, + "direction": "none", + "random": false, + "straight": false, + "out_mode": "out", + "bounce": false, + "attract": { + "enable": false, + "rotateX": 600, + "rotateY": 1200 + } + } + }, + "interactivity": { + "detect_on": "canvas", + "events": { + "onhover": { + "enable": true, + "mode": "grab" + }, + "onclick": { + "enable": true, + "mode": "push" + }, + "resize": true + }, + "modes": { + "grab": { + "distance": 400, + "line_linked": { + "opacity": 1 + } + }, + "bubble": { + "distance": 400, + "size": 40, + "duration": 2, + "opacity": 8, + "speed": 3 + }, + "repulse": { + "distance": 200, + "duration": 0.4 + }, + "push": { + "particles_nb": 4 + }, + "remove": { + "particles_nb": 2 + } + } + }, + "retina_detect": true }); \ No newline at end of file