1$(function() { 2 // Painting - Exterior - Estimate 3 $("#get-exterior-estimate").click(function(e) { 4 e.preventDefault(); 5 6 const $form = $(this).closest("form"); 7 8 // By default, jQuery doesn't know anything about the HTML5 validation. Below 9 // is a workaround 10 if (!$form[0].checkValidity()) { 11 const $submitInput = $('<input type="submit" name="commit" style="display:none" >'); 12 $form.append($submitInput); 13 $submitInput.click(); 14 } else { 15 const roomHeight = parseInt($form.find(".dimensions .height").val()) || 0; 16 const roomLength = parseInt($form.find(".dimensions .length").val()) || 0; 17 const roomWidth = parseInt($form.find(".dimensions .width").val()) || 0; 18 19 const doorsAmount = parseInt($form.find(".excluding-areas-doors .amount").val()) || 0; 20 const doorsHeight = parseInt($form.find(".excluding-areas-doors .height").val()) || 0; 21 const doorsWidth = parseInt($form.find(".excluding-areas-doors .width").val()) || 0; 22 23 const windowsAmount = parseInt($form.find(".excluding-areas-windows .amount").val()) || 0; 24 const windowsHeight = parseInt($form.find(".excluding-areas-windows .height").val()) || 0; 25 const windowsWidth = parseInt($form.find(".excluding-areas-windows .width").val()) || 0; 26 27 const squareFt = roomHeight * (roomLength + roomWidth) * 2 - doorsAmount * doorsHeight * doorsWidth - windowsAmount * windowsHeight * windowsWidth; 28 const ftPerGallon = 400; // rb: 400 is used at current DE site 29 const gallonsNeeded = Math.ceil(squareFt / ftPerGallon) + " Gallons"; 30 31 const $estimate = $form.find("#estimate"); 32 $estimate.find("strong").text(gallonsNeeded); 33 $estimate.fadeIn(); 34 } 35 }); 36 37 // Project Planner 38 // Form submit 39 $('.project-planner #submit').on('click', function(e) { 40 console.log("----get first estimate---"); 41 e.preventDefault(); 42 43 // By default, jQuery doesn't know anything about the HTML5 validation. Below 44 // is a workaround 45 const $form = $(this).closest("form"); 46 47 // Disable things that we don't want to validate 48 $form.find("input[name^='project_planner']:hidden") 49 .not("#project_planner_room_shape") 50 .not("#project_planner_paint_finish") 51 .prop("disabled", true); 52 53 if (!$form[0].checkValidity()) { 54 const $submitInput = $('<input type="submit" name="commit" style="display:none" >'); 55 $form.append($submitInput); 56 $submitInput.click(); 57 58 // Re-enable things that we previously disabled 59 $form.find("input[name^='project_planner']:hidden").prop("disabled", false); 60 61 if (window.mobileScreen) { 62 alert('Some fields are empty or incorrect information entered, please fix them above and submit again.'); 63 } 64 } else { 65 $form.submit(); 66 } 67 }); 68 69 // Set room_shape depending on the active tab 70 $('#project-planner .tabbed#room-shape').on("update.tabber", function(e) { 71 const room_shape = $(e.target).find(".active").attr("data-room-shape"); 72 $("#project_planner_room_shape").val(room_shape); 73 }); 74 75 // Set paint_finish depending on the active tab 76 $('#project-planner .tabbed#paint-finish').on("update.tabber", function(e) { 77 const paint_finish = $(e.target).find(".active").attr("data-paint-finish"); 78 $("#project_planner_paint_finish").val(paint_finish); 79 }); 80 81 // Project Planner: Edit Project Info 82 $('.project-planner-estimate #submit').on('click', function(e) { 83 console.log("----edit estimate---"); 84 e.preventDefault(); 85 $(this).closest("form").submit(); 86 }); 87 88 // Project planner tips 89 $('.project-planner .clear-fieldset-how-to-options .question').each(function(i, obj) { 90 $(obj).attr('tabindex', 0); 91 }); 92});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.