').text(newError)));
$(elt).tooltipster('show');
}
},
submitHandler: function () {return false;},
success: function (label, elt) {$(elt).tooltipster('hide');}
};
$.validator.setDefaults(jqvDefaultOptions);
var jqvStepTwoOptions = {
rules: {
description: {
required: true,
minlength: 2,
lettersonly: false
},
}
};
$('#dhDescriptionForm').validate(jqvStepTwoOptions);
$(document).scrollTop(0);
}
if (page === 3) {
$('.step-1 img').attr('src', '/icons/design/dh_1_gray.svg');
$('.step-2 img').attr('src', '/icons/design/dh_2_gray.svg');
$('.step-3 img').attr('src', '/icons/design/dh_3_green.svg');
$('.step-4 img').attr('src', '/icons/design/dh_4_gray.svg');
$('.step-5 img').attr('src', '/icons/design/dh_5_gray.svg');
$(document).scrollTop(0);
}
if (page === 4) {
$('.step-1 img').attr('src', '/icons/design/dh_1_gray.svg');
$('.step-2 img').attr('src', '/icons/design/dh_2_gray.svg');
$('.step-3 img').attr('src', '/icons/design/dh_3_gray.svg');
$('.step-4 img').attr('src', '/icons/design/dh_4_green.svg');
$('.step-5 img').attr('src', '/icons/design/dh_5_gray.svg');
$(document).scrollTop(0);
}
if (page === 5) {
$('.step-1 img').attr('src', '/icons/design/dh_1_gray.svg');
$('.step-2 img').attr('src', '/icons/design/dh_2_gray.svg');
$('.step-3 img').attr('src', '/icons/design/dh_3_gray.svg');
$('.step-4 img').attr('src', '/icons/design/dh_4_gray.svg');
$('.step-5 img').attr('src', '/icons/design/dh_5_green.svg');
$('#dhEmail, #dhPhone').tooltipster({
trigger: 'custom',
onlyOne: false,
position: 'top',
theme: 'tooltipster-errortip'
});
var jqvDefaultOptions = {
debug: true,
errorPlacement: function (err, elt) {
var lastError = $(elt).data('lastError'),
newError = $(err).text();
$(elt).data('lastError', newError);
if (newError !== '' && newError !== lastError) {
$(elt).tooltipster('content', $('
').append($('
').text(newError)));
$(elt).tooltipster('show');
}
},
submitHandler: function () {return false;},
success: function (label, elt) {$(elt).tooltipster('hide');}
};
$.validator.setDefaults(jqvDefaultOptions);
var jqvStepFiveOptions = {
rules: {
email: {
required: true,
email: false,
strict_email: true
},
phone: {
required: false,
phoneUS: true
}
}
};
$('#dhNewRequestForm').validate(jqvStepFiveOptions);
$(document).scrollTop(0);
}
if (page === 6) {
window.location.href = '/thank-you';
}
}
}
function retrieveCurrentPage () {
console.log('refresh');
var data = {'action': 'refresh'};
$.post('/lets-be-friends', data, handleJSON, 'json');
}
$bmc.on('click', '#dh-1-to-2', function () {
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var vF = $('#dhFirstName').valid(),
vL = $('#dhLastName').valid();
if ( vF && vL ) {
var data = {
action: 'next',
page: 1,
first: $('#dhFirstName').val().trim(),
last: $('#dhLastName').val().trim(),
};
$.post('/lets-be-friends', data, handleJSON, 'json');
} else {
$this.attr('disabled', false).boxer('remove');
}
});
$bmc.on('click', '#dh-2-to-1', function () {
console.log('prev!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var data = {
action: 'prev',
page: 2,
};
$.post('/lets-be-friends', data, handleJSON, 'json');
});
$bmc.on('click', '#dh-2-to-3', function () {
console.log('next!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var vD = $('#dhDescription').valid();
if ( vD ) {
var data = {
action: 'next',
page: 2,
description: $('#dhDescription').val().trim(),
};
$.post('/lets-be-friends', data, handleJSON, 'json');
} else {
$this.attr('disabled', false).boxer('remove');
}
});
$bmc.on('click', '#dh-3-to-2', function () {
console.log('prev!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var data = {
action: 'prev',
page: 3,
};
$.post('/lets-be-friends', data, handleJSON, 'json');
});
$bmc.on('click', '#dh-3-to-4', function () {
console.log('next!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
console.log('deadlineOption1 is: ');
console.log($('#deadlineOption1')[0]);
// var vOpt1 = $('#deadlineOption1').valid(),
// vOpt2 = $('#deadlineOption2').valid(),
// vOpt3 = $('#deadlineOption3').valid();
if ($('#deadlineOption1').hasClass('active'))
deadlineText = $('#deadlineOption1').text()
else if ($('#deadlineOption2').hasClass('active'))
deadlineText = $('#deadlineOption2').text()
else if ($('#deadlineOption3').hasClass('active'))
deadlineText = $('#deadlineOption3').text()
else
deadlineText = 'Information Not Given'
if ( 1 ) {
var data = {
action: 'next',
page: 3,
deadline: deadlineText,
};
$.post('/lets-be-friends', data, handleJSON, 'json');
} else {
$this.attr('disabled', false).boxer('remove');
}
});
$bmc.on('click', '#dh-4-to-3', function () {
console.log('prev!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var data = {
action: 'prev',
page: 4,
};
$.post('/lets-be-friends', data, handleJSON, 'json');
});
$bmc.on('click', '#dh-4-to-5', function () {
console.log('next!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
file_list = [];
$('.quote-file').each( function () {
var file_data = $(this).data('file_data');
if (file_data) {
file_data.description = $(this).find('.quote-file-description').val();
file_list.push(file_data);
}
});
console.log('file list is: ');
console.log(file_list);
if ( 1 ) {
var data = {
action: 'next',
page: 4,
file_list: JSON.stringify(file_list),
};
$.post('/lets-be-friends', data, handleJSON, 'json');
} else {
$this.attr('disabled', false).boxer('remove');
}
});
$bmc.on('click', '#dh-5-to-4', function () {
console.log('prev!');
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var data = {
action: 'prev',
page: 5,
};
$.post('/lets-be-friends', data, handleJSON, 'json');
});
$bmc.on('click', '#dh-submit', function () {
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var vE = $('#dhEmail').valid(),
vP = $('#dhPhone').valid();
if ( vE && vP ) {
var data = {
action: 'submit',
page: 5,
email: $('#dhEmail').val().trim(),
phone: $('#dhPhone').val().trim(),
};
$.post('/lets-be-friends', data, handleJSON, 'json');
} else {
$this.attr('disabled', false).boxer('remove');
}
});
$bmc.on('submit', '#dhNewRequestForm', function (jqEvent) {
jqEvent.preventDefault();
jqEvent.originalEvent.preventDefault();
});
$bmc.on('submit', '#dhExistingRequestForm', function (jqEvent) {
jqEvent.preventDefault();
jqEvent.originalEvent.preventDefault();
});
$bmc.on('click', '#dhNewRequestBtn', function () {
var $this = $('#dhNewRequestBtn');
$this.attr('disabled', true).boxer('foorj-btn-boxer', 'prepend');
var vF = $('#dhFirstName').valid(),
vL = $('#dhLastName').valid(),
vE = $('#dhNewRequestEmail').valid(),
vP = $('#dhPhone').valid();
if ( vF && vL && vE && vP ) {
var data = {
action: 'next',
type: 'new',
page: 2,
first: $('#dhFirstName').val().trim(),
last: $('#dhLastName').val().trim(),
phone: $('#dhPhone').val().trim(),
email: $('#dhNewRequestEmail').val().trim()
};
$.post('/lets-be-friends', data, function (d) {
if (d.result === 'success') {
$('.dh-panel').html(d.html);
}
}, 'json');
} else {
$this.attr('disabled', false).boxer('remove');
}
});
$bmc.on('click', '.dh-p3-opt1', function () {
console.log('clicked');
$(this).addClass('active');
$('.dh-p3-opt2').removeClass('active');
$('.dh-p3-opt3').removeClass('active');
$(this).val('active');
$('.dh-p3-opt2').val('');
$('.dh-p3-opt3').val('');
});
$bmc.on('click', '.dh-p3-opt2', function () {
console.log('clicked');
$('.dh-p3-opt1').removeClass('active');
$(this).addClass('active');
$('.dh-p3-opt3').removeClass('active');
$('.dh-p3-opt1').val('');
$(this).val('active');
$('.dh-p3-opt3').val('');
});
$bmc.on('click', '.dh-p3-opt3', function () {
console.log('clicked');
$('.dh-p3-opt1').removeClass('active');
$('.dh-p3-opt2').removeClass('active');
$(this).addClass('active');
$('.dh-p3-opt1').val('');
$('.dh-p3-opt2').val('');
$(this).val('active');
});
retrieveCurrentPage();
});