{"version":3,"sources":["../../Content/js/Gluespec.ContactUs.js","../../Content/templates/contactUsMaterials.js"],"names":["selectedMaterials","notListedMaterials","notListedMaterialId","contactUsValidationReady","validateProducts","$","valid","renderContactUsMaterials","data","materials","showQuantity","is","showNeedByDate","dust","render","err","out","console","log","html","length","attr","wireContactUsMaterials","data2","off","on","materialId","this","idx","collection","i","Id","splice","material","getSelectedMaterialById","parents","first","val","each","rules","quantityRequired","needByDateRequired","getSelectedMaterialAndSku","result","updateOptionalRequired","show","hide","remove","removeClass","jQuery","validator","addMethod","value","element","trim","window","preSelectedMaterial","push","ManufacturerName","Name","preSelectedMaterials","trigger","formData","DispenserId","dispenserId","UseType","ApplicationAssistance","RequestSamples","RequestQuotes","DataRequest","GeneralInquiry","Materials","OtherMaterials","Comments","BondAreaSize","PartsToBondPerDay","CountriesToManufactureIn","FirstTime","Destination","Email","FirstName","LastName","CompanyName","Phone","JobFunction","JobFunctionOther","Industry","IndustryOther","Address","City","State","PostalCode","Country","Ma","ma","gtagData","email","gtag","text","prop","ajax","url","JSON","stringify","type","dataType","contentType","success","Success","location","href","Info","alert","Message","error","validate","errorClass","size","required","parts","application","firstTime","destination","materialName","oneProductRequired","unlistedMaterialName","useType","applicationAssistance","oneRequestRequired","errorPlacement","insertAfter","user","serverSideData","loadCountriesInSelect","loadAndWireJobFunctionsInSelect","loadAndWireIndustriesInSelect","autocomplete","source","minLength","select","event","ui","preventDefault","item","newValue","keypress","e","which","t","w","s","get","block","a","f","x","n","r","register","__dustBody"],"mappings":"AAAA,IAAAA,kBAAA,GACAC,mBAAA,GACAC,qBAAA,EACAC,0BAAA,EAsPA,SAAAC,mBACAC,EAAA,iBAAAC,QACAD,EAAA,yBAAAC,QAGA,SAAAC,2BACA,IAAAC,EAAA,CACAC,UAAAT,kBACAU,aAAAL,EAAA,iBAAAM,GAAA,YACAC,eAAAP,EAAA,iBAAAM,GAAA,aAEAE,KAAAC,OAAA,qBAAAN,GAAA,SAAAO,EAAAC,GACAD,GA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,EAAAC,EAAA,uHAAAK,EAAAR,EAAAK,IAAA,CAAA,OAAA,GAAAL,EAAA,KAAAG,EAAA,mBAAAK,EAAAR,EAAAK,IAAA,CAAA,OAAA,GAAAL,EAAA,KAAAG,EAAA,kFAAAK,EAAAR,EAAAK,IAAA,CAAA,aAAA,GAAAL,EAAA,KAAAG,EAAA,8BAAA,SAAAQ,EAAAT,EAAAF,GAAA,OAAAE,EAAAC,EAAA,6HAAAK,EAAAR,EAAAK,IAAA,CAAA,OAAA,GAAAL,EAAA,KAAAG,EAAA,qBAAAK,EAAAR,EAAAK,IAAA,CAAA,OAAA,GAAAL,EAAA,KAAAG,EAAA,sFAAAK,EAAAR,EAAAK,IAAA,CAAA,eAAA,GAAAL,EAAA,KAAAG,EAAA,8BAAAxI,KAAAiJ,SAAA,qBAAAZ,GAAAA,EAAAa,YAAA,EAAAN,EAAAM,YAAA,EAAAjI,EAAAiI,YAAA,EAAAH,EAAAG,YAAA,EAAAF,EAAAE,YAAA,EAAA","file":"contactUs.min.js","sourcesContent":["var selectedMaterials = [];\r\nvar notListedMaterials = [];\r\nvar notListedMaterialId = -1;\r\nvar contactUsValidationReady = false;\r\n\r\njQuery.validator.addMethod(\"oneProductRequired\", function (value, element) {\r\n if ($(\"#productQuote\").is(\":checked\") || $(\"#productInfo\").is(\":checked\")) {\r\n if (selectedMaterials.length == 0 && notListedMaterials == 0 && $(\"#unlistedMaterialName\").val().trim() == \"\") {\r\n return false;\r\n }\r\n return true;\r\n }\r\n}, \"At least one product is required\");\r\n\r\njQuery.validator.addMethod(\"quantityRequired\", function (value, element) {\r\n if ($(\"#productQuote\").is(\":checked\")) {\r\n if (value == \"\") return false;\r\n return true;\r\n }\r\n}, \"At least one product is required\");\r\n\r\njQuery.validator.addMethod(\"needByDateRequired\", function (value, element) {\r\n if ($(\"#productQuote\").is(\":checked\")) {\r\n if (value == \"\") return false;\r\n return true;\r\n }\r\n}, \"At least one product is required\");\r\n\r\njQuery.validator.addMethod(\"oneRequestRequired\", function (value, element) {\r\n if (\r\n !$(\"#applicationAssistance\").is(\":checked\") &&\r\n !$(\"#productQuote\").is(\":checked\") &&\r\n !$(\"#productInfo\").is(\":checked\") &&\r\n !$(\"#dataRequest\").is(\":checked\") &&\r\n !$(\"#generalInquiry\").is(\":checked\")\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n}, \"At least one request type is required\");\r\n\r\n$(function () {\r\n if (window.preSelectedMaterial != null) {\r\n selectedMaterials.push({\r\n Id: preSelectedMaterial.Id,\r\n ManufacturerName: preSelectedMaterial.ManufacturerName,\r\n Name: preSelectedMaterial.Name\r\n });\r\n renderContactUsMaterials();\r\n }\r\n if (window.preSelectedMaterials != null) {\r\n for (var i = 0; i < window.preSelectedMaterials.length; i++) {\r\n selectedMaterials.push({\r\n Id: preSelectedMaterials[i].Id,\r\n ManufacturerName: preSelectedMaterials[i].ManufacturerName,\r\n Name: preSelectedMaterials[i].Name\r\n });\r\n }\r\n renderContactUsMaterials();\r\n }\r\n\r\n $(\"#submitFormButton\").off(\"click\");\r\n $(\"#submitFormButton\").on(\"click\", function () {\r\n //If the user has added a not-found material but didn't click the add button,\r\n //do it for them here so it's not lost.\r\n $(\"#addNotFoundMaterial\").trigger(\"click\");\r\n\r\n if ($(\"#contact-us-form\").valid()) {\r\n var formData = {\r\n DispenserId: window.dispenserId,\r\n UseType: $(\"#useType\").val(),\r\n ApplicationAssistance: $(\"#applicationAssistance\").is(\":checked\"),\r\n RequestSamples: $(\"#productInfo\").is(\":checked\"),\r\n RequestQuotes: $(\"#productQuote\").is(\":checked\"),\r\n DataRequest: $(\"#dataRequest\").is(\":checked\"),\r\n GeneralInquiry: $(\"#generalInquiry\").is(\":checked\"),\r\n Materials: selectedMaterials,\r\n OtherMaterials: notListedMaterials,\r\n Comments: $(\"#help\").val(),\r\n BondAreaSize: $(\"#size\").val(),\r\n PartsToBondPerDay: $(\"#parts\").val(),\r\n CountriesToManufactureIn: $(\"#application\").val(),\r\n FirstTime: $(\"#firstTime\").val(),\r\n Destination: $(\"#destination\").val(),\r\n Email: $(\"#email\").val(),\r\n FirstName: $(\"#firstName\").val(),\r\n LastName: $(\"#lastName\").val(),\r\n CompanyName: $(\"#company\").val(),\r\n Phone: $(\"#phone\").val(),\r\n JobFunction: $(\"#jobFunction\").val(),\r\n JobFunctionOther: $(\"#jobFunctionOther\").val(),\r\n Industry: $(\"#industry\").val(),\r\n IndustryOther: $(\"#industryOther\").val(),\r\n Address: $(\"#address\").val(),\r\n City: $(\"#city\").val(),\r\n State: $(\"#state\").val(),\r\n PostalCode: $(\"#zip\").val(),\r\n Country: $(\"#country\").val(),\r\n Ma: window.ma\r\n };\r\n\r\n var gtagData = { email: formData.Email };\r\n console.log(\"Sending gtag: \" + gtagData);\r\n gtag(\"event\", \"contact us\", { email: formData.Email });\r\n\r\n $(\"#submitFormButton\").text(\"Submitting...\");\r\n $(\"#submitFormButton\").prop(\"disabled\", true);\r\n\r\n $.ajax({\r\n url: \"/Modal/ContactUs\",\r\n data: JSON.stringify(formData),\r\n type: \"POST\",\r\n dataType: \"json\",\r\n contentType: \"application/json\",\r\n success: function (data) {\r\n console.log(data);\r\n if (data.Success) {\r\n window.location.href = data.Info;\r\n }\r\n else {\r\n alert(\"Unexpected error: \" + data.Message);\r\n $(\"#submitFormButton\").text(\"Submit\");\r\n $(\"#submitFormButton\").prop(\"disabled\", false);\r\n }\r\n },\r\n error: function () {\r\n $(\"#submitFormButton\").text(\"Submit\");\r\n $(\"#submitFormButton\").prop(\"disabled\", false);\r\n }\r\n });\r\n }\r\n });\r\n\r\n $(\"#contact-us-form\").validate({\r\n errorClass: \"invalid\",\r\n rules: {\r\n size: {\r\n required: \"#productInfo:checked\"\r\n },\r\n parts: {\r\n required: \"#productInfo:checked\"\r\n },\r\n application: {\r\n required: \"#productInfo:checked\"\r\n },\r\n firstTime: {\r\n required: \"#productInfo:checked\"\r\n },\r\n destination: {\r\n required: \"#productInfo:checked\"\r\n },\r\n \"materialName\": {\r\n oneProductRequired: true\r\n },\r\n \"unlistedMaterialName\": {\r\n oneProductRequired: true\r\n },\r\n \"useType\": {\r\n required: true\r\n },\r\n \"applicationAssistance\": {\r\n oneRequestRequired: true\r\n }\r\n },\r\n errorPlacement: function (error, element) {\r\n if (error.text() == \"At least one request type is required\") {\r\n error.insertAfter(\".requestType\");\r\n }\r\n else {\r\n if ($(element).attr(\"id\") == \"termsCheckbox\") {\r\n error.insertAfter($(element).parents(\"label\").first());\r\n }\r\n else {\r\n error.insertAfter(element);\r\n }\r\n }\r\n }\r\n });\r\n\r\n contactUsValidationReady = true;\r\n\r\n $(\"#productInfo\").off(\"change\");\r\n $(\"#productInfo\").on(\"change\", function () { \r\n updateOptionalRequired();\r\n });\r\n \r\n $(\"#productQuote\").off(\"change\"); \r\n $(\"#productQuote\").on(\"change\", function () {\r\n updateOptionalRequired();\r\n });\r\n\r\n $(\".requestType input[type='checkbox']\").on(\"change\", function () {\r\n renderContactUsMaterials();\r\n });\r\n\r\n $(\"#useType\").off(\"change\");\r\n $(\"#useType\").on(\"change\", function () {\r\n updateOptionalRequired();\r\n });\r\n\r\n $(\".requestType\").off(\"click\");\r\n $(\".requestType\").on(\"click\", function () {\r\n $(\"#applicationAssistance\").valid();\r\n });\r\n\r\n var user = serverSideData.user;\r\n loadCountriesInSelect(\"#country\", user.Country);\r\n loadAndWireJobFunctionsInSelect(\"#jobFunction\", user.JobFunction);\r\n loadAndWireIndustriesInSelect(\"#industry\", user.Industry);\r\n\r\n $(\"#materialName\").autocomplete({\r\n source: \"/Materials/AutoCompleteContactUs\",\r\n minLength: 2,\r\n select: function (event, ui) {\r\n event.preventDefault();\r\n var material = ui.item.material;\r\n selectedMaterials.push(material);\r\n renderContactUsMaterials();\r\n $(\"#materialName\").val(\"\");\r\n validateProducts();\r\n return false;\r\n }\r\n });\r\n\r\n $(\"#addNotFoundMaterial\").off(\"click\");\r\n $(\"#addNotFoundMaterial\").on(\"click\", function () {\r\n var newValue = $(\"#unlistedMaterialName\").val();\r\n if (newValue.trim() != \"\") {\r\n notListedMaterials.push({\r\n Id: notListedMaterialId--,\r\n Name: newValue\r\n });\r\n renderContactUsMaterials();\r\n $(\"#unlistedMaterialName\").val(\"\");\r\n validateProducts();\r\n }\r\n });\r\n\r\n $(\"#unlistedMaterialName\").keypress(function (e) {\r\n if (e.which == 13) {\r\n e.preventDefault();\r\n $(\"#addNotFoundMaterial\").trigger(\"click\");\r\n return false; \r\n }\r\n });\r\n\r\n updateOptionalRequired();\r\n});\r\n\r\nfunction validateProducts() {\r\n $(\"#materialName\").valid();\r\n $(\"#unlistedMaterialName\").valid();\r\n}\r\n\r\nfunction renderContactUsMaterials() {\r\n var data = {\r\n materials: selectedMaterials,\r\n showQuantity: $(\"#productQuote\").is(\":checked\"),\r\n showNeedByDate: $(\"#productQuote\").is(\":checked\")\r\n };\r\n dust.render(\"contactUsMaterials\", data, function (err, out) {\r\n if (err) console.log(err);\r\n $(\"#materialsContainer\").html(out);\r\n\r\n if (selectedMaterials.length > 0) {\r\n $(\"#materialName\").attr(\"placeholder\", \"Type to add more products\");\r\n }\r\n else {\r\n $(\"#materialName\").attr(\"placeholder\", \"Type to add products\");\r\n }\r\n\r\n wireContactUsMaterials();\r\n });\r\n\r\n var data2 = {\r\n materials: notListedMaterials,\r\n showQuantity: $(\"#productQuote\").is(\":checked\"),\r\n showNeedByDate: $(\"#productQuote\").is(\":checked\")\r\n };\r\n dust.render(\"contactUsMaterials\", data2, function (err, out) {\r\n if (err) console.log(err);\r\n $(\"#unlistedMaterialsContainer\").html(out);\r\n\r\n if (notListedMaterials.length > 0) {\r\n $(\"#unlistedMaterialName\").attr(\"placeholder\", \"Type to add more products\");\r\n }\r\n else {\r\n $(\"#unlistedMaterialName\").attr(\"placeholder\", \"Type to add products\");\r\n }\r\n\r\n wireContactUsMaterials();\r\n });\r\n}\r\n\r\nfunction wireContactUsMaterials() {\r\n $(\".removeMaterialButton\").off(\"click\");\r\n $(\".removeMaterialButton\").on(\"click\", function () {\r\n var materialId = $(this).data(\"material-id\");\r\n var idx = -1;\r\n\r\n var collection = selectedMaterials;\r\n if (materialId < 0) {\r\n collection = notListedMaterials;\r\n }\r\n\r\n for (var i = 0; i < collection.length; i++) {\r\n if (collection[i].Id == materialId) {\r\n idx = i;\r\n break;\r\n }\r\n }\r\n collection.splice(idx, 1);\r\n renderContactUsMaterials();\r\n });\r\n\r\n $(\".saveMaterialField\").off(\"change\");\r\n $(\".saveMaterialField\").on(\"change\", function () {\r\n var materialId = $(this).parents(\"li\").first().data(\"material-id\");\r\n\r\n var material = getSelectedMaterialById(materialId);\r\n if (material == null) return;\r\n\r\n material[$(this).data(\"field\")] = $(this).val();\r\n });\r\n\r\n if (contactUsValidationReady) {\r\n $(\".saveMaterialQuantity\").each(function () {\r\n $(this).rules(\"remove\");\r\n $(this).rules(\"add\", { quantityRequired: true });\r\n });\r\n\r\n $(\".saveMaterialNeedByDate\").each(function () {\r\n $(this).rules(\"remove\");\r\n $(this).rules(\"add\", { needByDateRequired: true });\r\n });\r\n }\r\n}\r\n\r\nfunction getSelectedMaterialById(materialId) {\r\n var collection = selectedMaterials;\r\n if (materialId < 0) {\r\n collection = notListedMaterials;\r\n }\r\n\r\n for (var i = 0; i < collection.length; i++) {\r\n if (collection[i].Id == materialId) {\r\n return collection[i];\r\n break; \r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\nfunction getSelectedMaterialAndSku(materialId) {\r\n var result = {\r\n material: null\r\n };\r\n for (var i = 0; i < selectedMaterials.length; i++) {\r\n if (selectedMaterials[i].Id == materialId) {\r\n result.material = selectedMaterials[i];\r\n break;\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction updateOptionalRequired() {\r\n if ($(\"#productInfo\").is(\":checked\")) {\r\n $(\".requiredQuestions\").show();\r\n $(\".optionalQuestions\").hide();\r\n $(\".optionalRequired\").show();\r\n $(\".sampleOnlyQuestion\").show();\r\n }\r\n else {\r\n $(\".requiredQuestions\").hide();\r\n $(\".optionalQuestions\").show();\r\n $(\".optionalRequired\").hide();\r\n $(\"#size-error\").remove();\r\n $(\"#parts-error\").remove();\r\n $(\"#application-error\").remove();\r\n $(\"#firstTime-error\").remove();\r\n $(\"#destination-error\").remove();\r\n $(\"#size\").removeClass(\"invalid\");\r\n $(\"#parts\").removeClass(\"invalid\");\r\n $(\"#application\").removeClass(\"invalid\");\r\n $(\"#firstTime\").removeClass(\"invalid\");\r\n $(\"#destination\").removeClass(\"invalid\");\r\n $(\".sampleOnlyQuestion\").hide();\r\n }\r\n\r\n if ($(\"#useType\").val() == \"\") {\r\n //$(\"#requestType\").hide();\r\n //$(\"#descriptionContainer\").hide();\r\n }\r\n else {\r\n $(\"#requestType\").show();\r\n $(\"#descriptionContainer\").show();\r\n }\r\n\r\n if (($(\"#productQuote\").is(\":checked\") || $(\"#productInfo\").is(\":checked\")) && $(\"#useType\").val() != \"\") {\r\n $(\"#addMaterialContainer\").show();\r\n $(\"#addUnlistedMaterialContainer\").show();\r\n }\r\n else {\r\n $(\".quoteTermsAndConditions\").hide();\r\n $(\"#addMaterialContainer\").hide();\r\n $(\"#addUnlistedMaterialContainer\").hide();\r\n }\r\n\r\n if ($(\"#productQuote\").is(\":checked\") && $(\"useType\").val() != \"\") {\r\n $(\".quoteTermsAndConditions\").hide();\r\n }\r\n else {\r\n $(\".quoteTermsAndConditions\").hide();\r\n }\r\n}","!function(t){function e(t,e){return t.w(\"