$( document ).ready(function() { var basket_count = $('#shopping_basket_count').val(); var show_modal = false; var upsell_id = ""; // Moves the page down on small devices if (screen.width < 470) { window.scrollTo(0, 90); } $('#desktop_submit,#mobile_submit').click(function () { if (!$('.repair').is(':checked')) { alert('Please select the repair option(s) you require'); return false; } // Call out device, don't upsell if( $('#mail_in_device').val() == "n" ) { $( '#selected_repairs' ).submit(); } // Will contain a number if basket exists if(typeof basket_count == 'undefined') { if ( $('#upsell_device').val() == "y" && $('#mail_in_device').val() == "y" ) { $(".repair").each(function( ){ if ( $( this ).is( ":checked" ) ) { // certain repairs need to not upsell and go straight to their product page on Shopify if ($( this ).data('disclaimer') == "y" ) { $( '#selected_repairs' ).submit(); }; // if the repair is marked as upsell, then we need to show a screen! if ($( this ).data('upsell') == "y" ) { show_modal = true; // id of the hidden checkbox. Gets the screen protector upsell_id = $('input#screen_protector').val(); } } } ); // Gets the upsell modal content if ( show_modal === true ) { $( "#upsell-show" ).load( "/upsell_modal?id=" + upsell_id , function() { $('#page-hide').hide(); $('#upsell-show').show(); if (screen.width < 470) { window.scrollTo(0, 85); } }); } else { $( '#selected_repairs' ).submit(); } } else { $( '#selected_repairs' ).submit(); } return false; } else { $( '#selected_repairs' ).submit(); } }); // Add a screen protector button $( document ).on( "click", "#screen_upsell", function( ) { $('input#screen_protector').prop('checked', true); $(".repair").change(); $('#related_products').modal('hide'); $( '#selected_repairs' ).submit(); }); // Don't add a screen protector button $( document ).on( "click", "#screen_upsell_no", function( ) { $('input#screen_protector').prop('checked', false); $('#related_products').modal('hide'); $( '#selected_repairs' ).submit(); }); $( "#Closepopover" ).live( "click", function() { $( ".popover" ).hide(); }); // Disclaimers $('#water').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Liquid Damage Repair', content : 'Due to the specialist nature of this repair it can only be done via our postal service. We offer a fast turnaround.
' }); $('#glass').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Front Glass Repair', content : 'Due to the specialist nature of this repair it can only be done via our postal service. We offer a fast turnaround with same day repair, next day courier delivery.
' }); $('#sim').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Sim Reader Repair', content : 'Due to the specialist nature of this repair it can only be done via our postal service. We offer a fast turnaround with same day repair, next day courier delivery.
' }); $('#software').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Software Fix', content : 'Due to the specialist nature of this repair it can only be done via our postal service. We offer a fast turnaround with same day repair, next day courier delivery.
' }); $('#diagnostic').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Full Diagnostic Service', content : 'If you don\'t know what is wrong with your device our Diagnostic Service tests all hardware & software functions to identify the problem. We will then advise what repair is required and cost. The Diagnostic fee is deducted off the total cost of the repair. This service is only available via our postal service.
' }); $('#rearcase').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Replace Rear Housing', content : 'Due to the specialist nature of this repair it can only be done via our postal service. We offer a fast turnaround with same day repair, next day courier delivery.
' }); $('#rearglass').popover({ trigger : 'click', placement : 'auto', html : 'true', title : 'Replace Rear Glass', content : 'Due to the specialist nature of this repair it can only be done via our postal service. We offer a fast turnaround with same day repair, next day courier delivery.
' }); $( ".success" ).hide(); // Validates form to see if user has entered a correct number $('#callback').on('submit', function(e) { e.preventDefault(); var elem = document.getElementById('inputphone').value; elem = elem.replace(/\s/g, ''); if (isNaN(elem)) { alert("Please only enter your phone number."); return false; } else { $.ajax({ url : $(this).attr('action') || window.location.pathname, type: "GET", data: $(this).serialize(), success: function (data) { $( ".modal-body" ).hide(); $( ".success" ).show(); $("#success_message").html("Thank you, your contact number has been received.

One of our highly trained iTechs will be in contact shortly.

"); }, error: function (jXHR, textStatus, errorThrown) { alert(errorThrown); } }); } }); // Reselects checkboxes on back navigation (from Shopify for example) var total = 0; $(".repair").each(function( ){ if ( $( this ).is( ":checked" ) ) { $( this ).parent().toggleClass( "active" ); total += parseFloat( $(this).attr("data-value") ); } } ); price.innerHTML = '£' + total.toFixed(2) ; price_mobile.innerHTML = '£' + total.toFixed(2) ; // Calculates repair costs $( ".repair" ).change(function() { var total = 0; $(".repair").each(function( ){ if ( $( this ).is( ":checked" ) ) { total += parseFloat( $(this).attr("data-value") ); } } ); price.innerHTML = '£' + total.toFixed(2) ; price_mobile.innerHTML = '£' + total.toFixed(2) ; } ); } );