init
This commit is contained in:
82
public/js/agency.js
Normal file
82
public/js/agency.js
Normal file
@@ -0,0 +1,82 @@
|
||||
// Smooth scrolling via animate()
|
||||
$(document).ready(function(){
|
||||
if ($('.g-recaptcha')) {
|
||||
checkReCaptcha()
|
||||
}
|
||||
|
||||
$("a").on('click', function(event) {
|
||||
if (this.hash && window.location.pathname == "/") {
|
||||
event.preventDefault();
|
||||
var hash = this.hash;
|
||||
$('html, body').animate({
|
||||
scrollTop: $(hash).offset().top
|
||||
}, 800, function(){
|
||||
window.location.hash = hash;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Navigation change on scroll
|
||||
var maxOffset = 50;
|
||||
$(window).scroll(function() {
|
||||
if ($(window).scrollTop() >= maxOffset) {
|
||||
$('.navbar-default').addClass('navbar-shrink');
|
||||
}
|
||||
else {
|
||||
$('.navbar-default').removeClass('navbar-shrink');
|
||||
}
|
||||
});
|
||||
|
||||
var maxOffset = 50;
|
||||
if ($(window).scrollTop() >= maxOffset) {
|
||||
$('.navbar-default').addClass('navbar-shrink');
|
||||
}
|
||||
else {
|
||||
$('.navbar-default').removeClass('navbar-shrink');
|
||||
}
|
||||
});
|
||||
|
||||
// Highlight the top nav as scrolling occurs
|
||||
$('body').scrollspy({
|
||||
target: '.navbar-fixed-top'
|
||||
})
|
||||
|
||||
// Closes the Responsive Menu on Menu Item Click
|
||||
$('.navbar-collapse ul li a').click(function() {
|
||||
$('.navbar-toggle:visible').click();
|
||||
});
|
||||
|
||||
// Async contact form
|
||||
$('form[id=contactForm]').submit(function(){
|
||||
$.post($(this).attr('action'), $(this).serialize(), function(data, textStatus, jqXHR){
|
||||
$('form[id=contactForm] #success').hide();
|
||||
$('form[id=contactForm] #error').hide();
|
||||
if (jqXHR.status == 200) {
|
||||
$('form[id=contactForm] #success').show();
|
||||
}}, 'json').fail(function(){
|
||||
$('form[id=contactForm] #success').hide();
|
||||
$('form[id=contactForm] #error').hide();
|
||||
$('form[id=contactForm] #error').show();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// Contact form validation
|
||||
//$.validate({
|
||||
// modules : 'html5, toggleDisabled'
|
||||
//});
|
||||
|
||||
function onContactCaptcha($form) {
|
||||
$('form#contactForm').submit();
|
||||
}
|
||||
|
||||
function checkReCaptcha() {
|
||||
if (typeof grecaptcha === "undefined") {
|
||||
$('.captcha-error').show();
|
||||
setTimeout(checkReCaptcha, 200);
|
||||
} else {
|
||||
$('.captcha-error').hide();
|
||||
$('.g-recaptcha-filler').hide();
|
||||
$('.g-recaptcha').attr('disabled', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user