Initial Release
This commit is contained in:
40
assets/js/formhandler.js
Normal file
40
assets/js/formhandler.js
Normal file
@@ -0,0 +1,40 @@
|
||||
window.addEventListener("DOMContentLoaded", function() {
|
||||
var form = document.getElementById("contact-form");
|
||||
var button = document.getElementById("contact-form-button");
|
||||
var status = document.getElementById("contact-form-status");
|
||||
|
||||
function success() {
|
||||
form.reset();
|
||||
button.style = "display: none ";
|
||||
status.innerHTML = "Thanks! Contact form is submitted successfully.";
|
||||
}
|
||||
|
||||
function error() {
|
||||
status.innerHTML = "Oops! There was a problem.";
|
||||
}
|
||||
|
||||
// handle the form submission event
|
||||
|
||||
form.addEventListener("submit", function(ev) {
|
||||
ev.preventDefault();
|
||||
var data = new FormData(form);
|
||||
ajax(form.method, form.action, data, success, error);
|
||||
});
|
||||
});
|
||||
|
||||
// helper function for sending an AJAX request
|
||||
|
||||
function ajax(method, url, data, success, error) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open(method, url);
|
||||
xhr.setRequestHeader("Accept", "application/json");
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState !== XMLHttpRequest.DONE) return;
|
||||
if (xhr.status === 200) {
|
||||
success(xhr.response, xhr.responseType);
|
||||
} else {
|
||||
error(xhr.status, xhr.response, xhr.responseType);
|
||||
}
|
||||
};
|
||||
xhr.send(data);
|
||||
}
|
||||
35
assets/js/script.js
Normal file
35
assets/js/script.js
Normal file
@@ -0,0 +1,35 @@
|
||||
$(document).ready(function() {
|
||||
"use strict";
|
||||
// Scroll to top
|
||||
$("a[href='#top']").click(function() {
|
||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
return false;
|
||||
});
|
||||
|
||||
// Smooth scroll
|
||||
$('a.scroll-to').on('click', function (event) {
|
||||
var $anchor = $(this);
|
||||
$('html, body').stop().animate({
|
||||
scrollTop: ($($anchor.attr('href')).offset().top - 50)
|
||||
}, 700);
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('.site-testimonial-item').on('mouseenter', function(){
|
||||
$('.site-testimonial-item').addClass('inactive');
|
||||
$(this).removeClass('inactive').addClass('active');
|
||||
});
|
||||
$('.site-testimonial-item').on('mouseleave', function(){
|
||||
$('.site-testimonial-item').removeClass('inactive');
|
||||
$('.site-testimonial-item').removeClass('active');
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('scroll', function () {
|
||||
var windscroll = $(window).scrollTop();
|
||||
if (windscroll >= 100) {
|
||||
$('.site-navigation').addClass('nav-bg');
|
||||
} else {
|
||||
$('.site-navigation').removeClass('nav-bg');
|
||||
}
|
||||
});
|
||||
50
assets/js/vendor.js
Normal file
50
assets/js/vendor.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user