/*! ========================================================= * Material Bootstrap Wizard - v1.0.2 ========================================================= * Product Page: https://www.creative-tim.com/product/material-bootstrap-wizard * Copyright 2017 Creative Tim (http://www.creative-tim.com) * Licensed under MIT (https://github.com/creativetimofficial/material-bootstrap-wizard/blob/master/LICENSE.md) ========================================================= * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. */ // Material Bootstrap Wizard Functions var searchVisible = 0; var transparent = true; var mobile_device = false; var address_found = false; $('.btn-finish').click(function(){ document.getElementById('contactloader').innerHTML = '

'; document.getElementById('contactloader').style.display=''; document.getElementById('contactusform').style.display='none'; // AJAX QUERY MAGIC var nlat = parseFloat(document.getElementById("latitude").value); var nlng = parseFloat(document.getElementById("longitude").value); var street_number = encodeURIComponent(document.getElementById("street_number").value); var route = encodeURIComponent(document.getElementById("route").value); var locality = encodeURIComponent(document.getElementById("locality").value); var administrative_area_level_1 = encodeURIComponent(document.getElementById("administrative_area_level_1").value); var postal_code = encodeURIComponent(document.getElementById("postal_code").value); var country = encodeURIComponent(document.getElementById("country").value); var qualify_title = encodeURIComponent(document.getElementById('qualify_title').innerHTML); var qualify_body = encodeURIComponent(document.getElementById('qualify_body').innerHTML); var contact_name = encodeURIComponent(document.getElementById('contact_name').value); var contact_email = encodeURIComponent(document.getElementById('contact_email').value); var contact_phone = encodeURIComponent(document.getElementById('contact_phone').value); var contact_body = encodeURIComponent(document.getElementById('contact_detail').value); var token = document.getElementById('token').value; var contact_reason; if (document.getElementById('radioservice').checked) { contact_reason = 'service'; } if (document.getElementById('radiosales').checked) { contact_reason = 'sales'; } $.post( "email.php", { 'nlat': nlat, 'nlng': nlng, 'street_number': street_number, 'route': route, 'locality': locality, 'administrative_area_level_1': administrative_area_level_1, 'postal_code': postal_code, 'country': country, 'qualify_title': qualify_title, 'qualify_body': qualify_body, 'contact_name': contact_name, 'contact_email': contact_email, 'contact_phone': contact_phone, 'contact_body': contact_body, 'contact_reason': contact_reason, 'token': token } ).done(function(data) { document.getElementById('contactloader').innerHTML = '
Thank you! Our team will be in contact soon.
'; document.getElementById('contactloader').style.display=''; document.getElementById('contactusform').style.display='none'; }); }); $(document).ready(function(){ $.material.init(); /* Activate the tooltips */ $('[rel="tooltip"]').tooltip(); // Code for the Validator var $validator = $('.wizard-card form').validate({ rules: { firstname: { required: true, minlength: 3 }, lastname: { required: true, minlength: 3 }, email: { required: true, minlength: 3, } }, errorPlacement: function(error, element) { $(element).parent('div').addClass('has-error'); } }); // Wizard Initialization $('.wizard-card').bootstrapWizard({ 'tabClass': 'nav nav-pills', 'nextSelector': '.btn-next', 'previousSelector': '.btn-previous', onNext: function(tab, navigation, index) { var $valid = $('.wizard-card form').valid(); if(!$valid) { $validator.focusInvalid(); return false; } }, onInit : function(tab, navigation, index){ //check number of tabs and fill the entire row var $total = navigation.find('li').length; var $wizard = navigation.closest('.wizard-card'); $first_li = navigation.find('li:first-child a').html(); $moving_div = $('
' + $first_li + '
'); $('.wizard-card .wizard-navigation').append($moving_div); refreshAnimation($wizard, index); $('.moving-tab').css('transition','transform 0s'); }, onTabClick : function(tab, navigation, index){ var $valid = $('.wizard-card form').valid(); if(!$valid){ return false; } else{ return true; } }, onTabShow: function(tab, navigation, index) { var $total = navigation.find('li').length; var $current = index+1; var $wizard = navigation.closest('.wizard-card'); // If it's the last tab then hide the last button and show the finish instead if($current >= $total) { $($wizard).find('.btn-next').hide(); $($wizard).find('.btn-finish').show(); } else { $($wizard).find('.btn-next').show(); $($wizard).find('.btn-finish').hide(); } tabText = tab[0].innerText; tabText = tabText.trim(); console.log(tabText); if (tabText == "ADDRESS") { console.log("do we hide button?"); if (address_found != true) { console.log("hidding next"); $($wizard).find('.btn-next').hide(); } } if (tabText == "VERIFY") { if (address_found != false) { document.getElementById('verifyTitle').innerHTML = "Use the map to confirm your position"; document.getElementById('verifyMap').style.display = ""; var nlat = document.getElementById("latitude").value; var nlng = document.getElementById("longitude").value; var uluru = {lat: parseFloat(nlat), lng: parseFloat(nlng)}; console.log('moving map to '); console.log(uluru); verifyMarker.setMap(null); verifyMarker = new google.maps.Marker({position: uluru, map: verifymap}); verifymap.setCenter(new google.maps.LatLng(parseFloat(nlat), parseFloat(nlng))); } } if (tabText == "QUALIFY") { if (address_found != false) { document.getElementById('qualify_header').innerHTML = 'Loading'; document.getElementById('qualify_title').innerHTML = ''; document.getElementById('qualify_body').innerHTML = ''; document.getElementById('qualify_icon_div').style.display="none"; // AJAX QUERY MAGIC var nlat = parseFloat(document.getElementById("latitude").value); var nlng = parseFloat(document.getElementById("longitude").value); // Telemetry var street_number = encodeURIComponent(document.getElementById("street_number").value); var route = encodeURIComponent(document.getElementById("route").value); var locality = encodeURIComponent(document.getElementById("locality").value); var administrative_area_level_1 = encodeURIComponent(document.getElementById("administrative_area_level_1").value); var postal_code = encodeURIComponent(document.getElementById("postal_code").value); var country = encodeURIComponent(document.getElementById("country").value); var url = 'ajax.php?lat=' + nlat + '&lng=' + nlng + '&street_number=' + street_number + '&route=' + route + '&locality=' + locality + '&administrative_area_level_1=' + administrative_area_level_1 + '&postal_code=' + postal_code + '&country=' + country; console.log(url); $.getJSON( url, function( data ) { console.log(data); document.getElementById('qualify_header').innerHTML = 'Qualification Results'; var ndist = Math.round(data.distance * 100) / 100; document.getElementById('qualify_icon_div').style.display=""; if (data.chance < 25) { document.getElementById('qualify_icon').innerHTML = "cancel"; document.getElementById('qualify_title').innerHTML = 'Out of service area. :('; document.getElementById('qualify_body').innerHTML = 'Sorry! Our automated tools don\'t think you are near enough to our towers to get wirelss service, but we may have other services available through NetAccess that may be able to reach you. You should contact us anyways to see what we can do for you.'; } else if ((data.chance > 24) && (data.chance < 50)) { document.getElementById('qualify_icon').innerHTML = "sentiment_dissatisfied"; // sad face document.getElementById('qualify_title').innerHTML = 'Edge of service area.'; document.getElementById('qualify_body').innerHTML = 'Our automated tools think you are on the edge of our service area, and its going to take some humans to check it an make sure. Head over to the next page and we will have someone contact you with availability as soon as possible.'; } else if ((data.chance > 49) && (data.chance < 65)) { document.getElementById('qualify_icon').innerHTML = "star_half"; // half filled star document.getElementById('qualify_title').innerHTML = 'You are in our service area, but...'; document.getElementById('qualify_body').innerHTML = 'You are in our service area, but we think you may be at the edge of our acceptable range to the nearest tower. Our team of professionals can check your address and confirm with you if you fill in the contact form with your details.'; } else if ((data.chance > 64) && (data.chance < 75)) { document.getElementById('qualify_icon').innerHTML = "star"; // filled star document.getElementById('qualify_title').innerHTML = 'Everything looks good'; document.getElementById('qualify_body').innerHTML = 'Our systems show you are well within our service area, and the nearest wireless tower to you covers your general area. Our team of professionals can do a final assessment and confirm availability for you, just complete the contact form and we will contact you as soon as we can.'; } else if (data.chance > 75) { document.getElementById('qualify_icon').innerHTML = "check_box"; // box with checkmark document.getElementById('qualify_title').innerHTML = 'No Worries!'; document.getElementById('qualify_body').innerHTML = 'Servicing your address shouldn\'t be a problem. We still want to verify your address with our team of professionals, so if you could fill our the contact form, we will verify your address and get back to you as soon as posible.'; } console.log(data.chance); }); } } button_text = navigation.find('li:nth-child(' + $current + ') a').html(); setTimeout(function(){ $('.moving-tab').text(button_text); }, 150); var checkbox = $('.footer-checkbox'); if( !index == 0 ){ $(checkbox).css({ 'opacity':'0', 'visibility':'hidden', 'position':'absolute' }); } else { $(checkbox).css({ 'opacity':'1', 'visibility':'visible' }); } refreshAnimation($wizard, index); } }); // Prepare the preview for profile picture $("#wizard-picture").change(function(){ readURL(this); }); $('[data-toggle="wizard-radio"]').click(function(){ wizard = $(this).closest('.wizard-card'); wizard.find('[data-toggle="wizard-radio"]').removeClass('active'); $(this).addClass('active'); $(wizard).find('[type="radio"]').removeAttr('checked'); $(this).find('[type="radio"]').attr('checked','true'); }); $('[data-toggle="wizard-checkbox"]').click(function(){ if( $(this).hasClass('active')){ $(this).removeClass('active'); $(this).find('[type="checkbox"]').removeAttr('checked'); } else { $(this).addClass('active'); $(this).find('[type="checkbox"]').attr('checked','true'); } }); $('.set-full-height').css('height', 'auto'); }); //Function to show image before upload function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#wizardPicturePreview').attr('src', e.target.result).fadeIn('slow'); } reader.readAsDataURL(input.files[0]); } } $(window).resize(function(){ $('.wizard-card').each(function(){ $wizard = $(this); index = $wizard.bootstrapWizard('currentIndex'); refreshAnimation($wizard, index); $('.moving-tab').css({ 'transition': 'transform 0s' }); }); }); function refreshAnimation($wizard, index){ $total = $wizard.find('.nav li').length; $li_width = 100/$total; total_steps = $wizard.find('.nav li').length; move_distance = $wizard.width() / total_steps; index_temp = index; vertical_level = 0; mobile_device = $(document).width() < 600 && $total > 3; if(mobile_device){ move_distance = $wizard.width() / 2; index_temp = index % 2; $li_width = 50; } $wizard.find('.nav li').css('width',$li_width + '%'); step_width = move_distance; move_distance = move_distance * index_temp; $current = index + 1; if($current == 1 || (mobile_device == true && (index % 2 == 0) )){ move_distance -= 8; } else if($current == total_steps || (mobile_device == true && (index % 2 == 1))){ move_distance += 8; } if(mobile_device){ vertical_level = parseInt(index / 2); vertical_level = vertical_level * 38; } $wizard.find('.moving-tab').css('width', step_width); $('.moving-tab').css({ 'transform':'translate3d(' + move_distance + 'px, ' + vertical_level + 'px, 0)', 'transition': 'all 0.5s cubic-bezier(0.29, 1.42, 0.79, 1)' }); } materialDesign = { checkScrollForTransparentNavbar: debounce(function() { if($(document).scrollTop() > 260 ) { if(transparent) { transparent = false; $('.navbar-color-on-scroll').removeClass('navbar-transparent'); } } else { if( !transparent ) { transparent = true; $('.navbar-color-on-scroll').addClass('navbar-transparent'); } } }, 17) } function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; clearTimeout(timeout); timeout = setTimeout(function() { timeout = null; if (!immediate) func.apply(context, args); }, wait); if (immediate && !timeout) func.apply(context, args); }; };