HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers26/gripp.nu/wwwroot/js/form.js
/**
 * Created by Pascal on 23/02/16.
 */

$(function () {
    $('<input type="hidden" />').attr({
        name: 'secretCode',
        id: 'secretCode',
        value: 'isHuman'
    }).appendTo($('#contact form'));

    $('#contact form').submit(function (event) {
        event.preventDefault();

        $('#contact').css('min-height', $('#contact').height());
        $('#contact .alert').removeClass('alert');
        $('.alertMessage').remove();


        var form = $(this);


        var companyName = form.find('input[name="companyName"]').val();
        var contactName = form.find('input[name="contactName"]').val();
        var emailForm = form.find('input[name="emailForm"]').val();
        var phoneForm = form.find('input[name="phoneForm"]').val();
        var formMessage = form.find('textarea#formMessage').val();
        var secretCode = form.find('input[name="secretCode"]').val();

        if (formMessage == '') {
            formMessage = null;
        }


        var submitting = $.post(form.attr('action'), {
            companyName: companyName,
            contactName: contactName,
            emailForm: emailForm,
            phoneForm: phoneForm,
            secretCode: secretCode,
            formMessage: formMessage
        });

        submitting.done(function (data) {
            if (data == 'true') {
                $(' #contact form').remove();
                $('.thank-you').css('opacity', 1);
                $('.thank-you').css('margin-bottom', '0');
                $('.offer-placeholder').css('min-height', 100);
            }
            else {
                $.each(data, function (key, value) {
                    $('#'+key).addClass('alert');
                    $('#'+key+'Label').addClass('alert');
                    $('#'+key+'Label').after('<div class="alertMessage"><p>' + value + '</p><span>i</span></div>');
                });
            }
        });

    });

    $('.internalLink').click(function () {
        animateScroll($(this));
        return false;
    });

});

function animateScroll(e, offset, time){
    offset = typeof offset !== 'undefined' ? offset : 60;
    time = typeof time !== 'undefined' ? time : 800;

    var scrollTo = e.prop('href');
    scrollTo = scrollTo.substr(scrollTo.indexOf('#')+1);

    $('html,body').animate({
        scrollTop: $('#'+scrollTo).offset().top - offset
    }, time);
}