{"version":3,"file":"contact.min.js","sources":["scripts/contact.min.js"],"sourcesContent":["/**************************************************************************\r\nName: contact.js\r\nDescription: Scripts for the contact page.\r\nDate Created: 2022-10-21 by Owen Haggerty\r\nModified:\r\n**************************************************************************/\r\njQuery(window).on(\"load\",function(){\r\n\t//Add click handlers for the category buttons\r\n\tjQuery(\"button.contactCategoryButton, button.contactCategoryLinkButton\").on(\"click\", selectCategory);\r\n\r\n\t//Add listener to the contact type dropdown\r\n\tjQuery(\".contactForm select[name='category']\").on(\"change\",changeCategory);\r\n\tjQuery(\".contactForm select[name='category']\").trigger(\"change\");\r\n\r\n\t//Resize the contact form when the viewport changes\r\n\tjQuery(window).on(\"resize\", setContactFormHeight);\r\n\tsetContactFormHeight();\r\n\r\n\t//Delete the upper cms content div\r\n\tjQuery(\"div.cmsContainer\").remove();\r\n});\r\n\r\nfunction changeCategory(){\r\n\t/* Listener for category dropdown changes */\r\n\tswitch (jQuery(this).val()){\r\n\t\tcase \"featured\":\r\n\t\t\t//Update the featured-specific fields\r\n\t\t\tjQuery(\".contactForm .order-number-label\").hide(300);\r\n\t\t\tjQuery(\".contactForm .social-select-label\").show(300);\r\n\t\t\tjQuery(\".contactForm .outer-label > .company-text\").text(\"Company\");\r\n\t\t\tjQuery(\".contactForm .outer-label > .prompt-text\").text(\"Describe Your Relationship with CHEF'STORE\");\r\n\t\t\tbreak;\r\n\t\tcase \"clickCarry\":\r\n\t\t\t//Show the order number field\r\n\t\t\tjQuery(\".contactForm .order-number-label\").show(300);\r\n\t\t\tjQuery(\".contactForm .social-select-label\").hide(300);\r\n\t\t\tjQuery(\".contactForm .outer-label > .company-text\").text(\"Company (optional)\");\r\n\t\t\tjQuery(\".contactForm .outer-label > .prompt-text\").text(\"How can we help you?\");\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\t//In all other cases restore the form to the default\r\n\t\t\tjQuery(\".contactForm .order-number-label\").hide(300);\r\n\t\t\tjQuery(\".contactForm .social-select-label\").hide(300);\r\n\t\t\tjQuery(\".contactForm .outer-label > .company-text\").text(\"Company (optional)\");\r\n\t\t\tjQuery(\".contactForm .outer-label > .prompt-text\").text(\"How can we help you?\");\r\n\t}\r\n\t//Update the contact form height\r\n\tsetContactFormHeight();\r\n}\r\n\r\nfunction selectCategory(){\r\n\t/* Handler for clicking one of the category buttons */\r\n\tlet newCat = jQuery(this).attr(\"data-category\");\r\n\t//Select the \"Category\" dropdown value\r\n\tlet categorySelect = jQuery(\".contactForm select[name='category']\");\r\n\tcategorySelect.val(newCat).trigger(\"change\");\r\n\t\r\n\t//Show the CMS content\r\n\tlet cmsContent = jQuery(\".contactLowerCmsContent\")\r\n\tcmsContent.show(300);\r\n\t//Show the contact form\r\n\tjQuery(\"#contactForm\").removeClass(\"collapsed\");\r\n\r\n\t//Scroll to the contact form\r\n\tlet scrollPos = cmsContent.offset().top;\r\n\tscrollPos -= jQuery(\".layHeader\").height();\t//To avoid hiding parts of the form under the header\r\n\tjQuery([document.documentElement, document.body]).animate({scrollTop: scrollPos}, 1000);\r\n\r\n\t//Set the focus on the first empty field\r\n\tlet formFields = jQuery(\".contactForm select, .contactForm input\");\r\n\tlet foundField = false;\r\n\tfor(let i=0; i