{"version":3,"sources":["webpack:///./src/js/components/Component.js","webpack:///./src/js/components/Form.js","webpack:///./src/js/components/ZipLocation.js","webpack:///./node_modules/form-serializer/jquery.serialize-object.js"],"names":["domTree","WeakMap","configuration","Component","el","config","arguments","length","undefined","_classCallCheck","this","Error","$el","jQuery","$","set","hasOwnProperty","dom","setupDefaults","addListeners","get","elements","_component","__webpack_require__","Form","_possibleConstructorReturn","__proto__","Object","getPrototypeOf","call","$formLevelErrorContainer","prev","errorMessage","_this2","errorMessages","indexOf","split","push","insertBefore","forEach","errorMsg","append","html","_Form2","ZipLocation","_get","prototype","endpoint","attr","_extends","$toggleBtn","find","$inputField","$zipLocationParent","parent","$submitBtn","$changeLocation","$changeLocationField","on","onZipSubmit","bind","onZipToggle","displayChangeLocationForm","e","preventDefault","addClass","toggleClass","hasClass","focus","stopPropagation","checkValidity","submitZip","catch","err","console","log","postZip","res","success","redirectURL","response","redirectUrl","window","location","replace","clearFormLevelError","displayFormLevelError","message","data","serializeJSON","ajax","method","url","contentType","__WEBPACK_AMD_DEFINE_ARRAY__","__WEBPACK_AMD_DEFINE_RESULT__","factory","exports","patterns","validate","key","fixed","named","FormSerializer","helper","$form","pushes","build","base","value","serialize","addPair","pair","test","name","obj","root","k","keys","match","pop","makeObject","encode","extend","addPairs","pairs","isArray","i","len","JSON","stringify","serializeObject","serializeArray","fn","apply","module"],"mappings":"uhBAAA,IAAMA,EAAU,IAAIC,QACdC,EAAgB,IAAID,QA4BpBE,aAOJ,SAAAA,EAAYC,GAAgB,IAAZC,EAAYC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,MAC1B,+FAD0BG,CAAAC,KAAAP,QACR,IAAPC,EACT,MAAM,IAAIO,MAAM,wEASlBD,KAAKE,IAAMR,aAAcS,EAAST,EAAKU,EAAEV,GAEjB,IAApBM,KAAKE,IAAIL,SAEbP,EAAQe,IAAIL,SACZR,EAAca,IAAIL,KAAML,GAEpBK,KAAKL,OAAOW,eAAe,SAC7B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qG,QAAAc,EAAAE,IAEA,OAAArH,MAcAA,KAAAoG,YACApG,KAAA+E,cARA,WACA,OAAAwC,KAAAC,UAAApB,MA+BA,OArBAP,EAAAL,WAEAK,EAAA4B,gBAAA,WACA,WAAA5B,EAAAzF,EAAAJ,MACAkH,SAAAlH,KAAA0H,kBACAtB,aAGAP,EAAAd,cAAA,WACA,WAAAc,EAAAzF,EAAAJ,MACAkH,SAAAlH,KAAA0H,kBACA3C,sBAGA,IAAA3E,EAAAuH,KACAvH,EAAAuH,GAAAF,gBAAA5B,EAAA4B,gBACArH,EAAAuH,GAAA5C,cAAAc,EAAAd,eAGAQ,EAAAM,iBAEAA,GArIIT,GAAQG,EAAW1E,EAAA,UAElBf,KAF2BuF,EAAE,SAAAE,EAAAnF,GAClC,OAAAkF,EAAAC,EAAAnF,IACKwH,MAAArC,EAAAH,MAAAyC,EAAAtC,QAAAF","file":"19.e5af1f12db476507c0fc.js","sourcesContent":["const domTree = new WeakMap();\r\nconst configuration = new WeakMap();\r\n\r\n/**\r\n * Component is a class that should be extended for every component that's being made. It\r\n * is a helper class to keep the code uniform.\r\n *\r\n * __PLEASE NOTE__: This is only to be extended, not instantiated.\r\n *\r\n * @example\r\n * import Component from 'component';\r\n *\r\n * class Foo extends Component {\r\n * construction(el){\r\n * super(el);\r\n * }\r\n *\r\n * setupDefaults(){\r\n * // ...defaults go here\r\n * }\r\n *\r\n * addListeners(){\r\n * // ...listeners go here\r\n * }\r\n * }\r\n *\r\n * // Create a new Foo component\r\n * new Foo('.foo');\r\n */\r\nclass Component {\r\n /**\r\n * Component constructor - see {@link config} on how to pass in additional configuration to the constructor\r\n *\r\n * @param {string|Object} el - Main DOM element, you can pass a string such as `'.foo'` __or__ a jQuery object such as `$('.foo')`\r\n * @param {Object} [config={ }] - Additional component configuration; reachable with `this.config`\r\n */\r\n constructor(el, config = {}){\r\n if (typeof el === 'undefined') {\r\n throw new Error('You must provide an element as a String type or a jQuery object type');\r\n }\r\n\r\n /**\r\n * Main class element, this will be a jQuery instance\r\n * This can be reachable at any time in your superclass with `this.$el`\r\n *\r\n * @type {Object}\r\n */\r\n this.$el = el instanceof jQuery ? el : $(el);\r\n\r\n if (this.$el.length === 0) return;\r\n\r\n domTree.set(this, {});\r\n configuration.set(this, config);\r\n\r\n if (this.config.hasOwnProperty('dom')) {\r\n this.dom = this.config.dom;\r\n }\r\n\r\n this.setupDefaults();\r\n this.addListeners();\r\n }\r\n\r\n /**\r\n * This method is used for override;\r\n * It's called directly after the element and configuration have been set up\r\n * @abstract\r\n */\r\n setupDefaults(){}\r\n\r\n /**\r\n * This method is used for override;\r\n * It's called directly after `setupDefaults()`, so everything is ready and setup at this point.\r\n * @abstract\r\n */\r\n addListeners(){}\r\n\r\n /**\r\n * Get component configuration\r\n *\r\n * @example\r\n * class Foo extends Component {\r\n * construction(el, config){\r\n * super(el, config);\r\n * }\r\n *\r\n * setupDefaults(){\r\n * console.log(this.config.name); // Outputs \"Foo\"\r\n * }\r\n * }\r\n *\r\n * // Create a new Foo component with some configuration\r\n * new Foo('.foo', {\r\n * name: 'Foo'\r\n * });\r\n *\r\n * @type {Object}\r\n */\r\n get config(){\r\n return configuration.get(this);\r\n }\r\n\r\n /**\r\n * Set DOM object\r\n *\r\n * @example\r\n * class Foo extends Component {\r\n * construction(el){\r\n * super(el);\r\n * }\r\n *\r\n * setupDefaults(){\r\n * this.dom = {\r\n * $container: this.$el.find('.container')\r\n * }\r\n * }\r\n *\r\n * addListeners(){\r\n * //DOM object is available\r\n * console.log(this.dom.$container);\r\n * }\r\n * }\r\n *\r\n * // Create a new Foo component\r\n * new Foo('.foo');\r\n *\r\n * @type {Object}\r\n */\r\n set dom(elements){\r\n elements = {\r\n ...this.dom,\r\n ...elements\r\n };\r\n\r\n domTree.set(this, elements);\r\n }\r\n\r\n /**\r\n * Get DOM object\r\n *\r\n * @example\r\n * this.dom\r\n *\r\n * @type {Object}\r\n */\r\n get dom(){\r\n return domTree.get(this);\r\n }\r\n}\r\n\r\nexport default Component;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/js/components/Component.js","import Component from 'component';\r\n\r\nclass Form extends Component {\r\n constructor(el, config) {\r\n super(el, config);\r\n }\r\n\r\n setupDefaults() {\r\n this.dom = {\r\n $formLevelErrorContainer: this.$el.prev('.form__global-error')\r\n };\r\n }\r\n\r\n displayFormLevelError(errorMessage) {\r\n let errorMessages = [];\r\n if (errorMessage.indexOf('~') !== -1) {\r\n errorMessages = errorMessage.split('~');\r\n } else {\r\n errorMessages.push(errorMessage);\r\n }\r\n\r\n if (typeof this.dom.$formLevelErrorContainer === 'undefined' || this.dom.$formLevelErrorContainer.length === 0) {\r\n $('<div class=\"form__global-error\"></div>').insertBefore(this.$el);\r\n errorMessages.forEach(errorMsg => {\r\n this.dom.$formLevelErrorContainer = this.$el.prev('.form__global-error').append(`<p>${errorMsg}</p>`);\r\n });\r\n } else {\r\n errorMessages.forEach(errorMsg => {\r\n this.dom.$formLevelErrorContainer.append(`<p>${errorMsg}</p>`);\r\n });\r\n }\r\n }\r\n\r\n clearFormLevelError() {\r\n if (this.dom.$formLevelErrorContainer.length > 0) {\r\n this.dom.$formLevelErrorContainer.html('');\r\n }\r\n }\r\n}\r\n\r\nexport default Form;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/js/components/Form.js","import Form from '../components/Form';\r\nimport 'form-serializer';\r\n\r\nclass ZipLocation extends Form {\r\n setupDefaults() {\r\n super.setupDefaults();\r\n\r\n this.endpoint = this.$el.attr('action');\r\n\r\n this.dom = {\r\n ...this.dom,\r\n $toggleBtn: this.$el.find('.zip-locator__toggle'),\r\n $inputField: this.$el.find('.zip-locator__field'),\r\n $zipLocationParent: this.$el.parent(),\r\n $submitBtn: this.$el.find('.js-zip-location-submit'),\r\n $changeLocation: this.$el.find('.zip-locator__change-location'),\r\n $changeLocationField: this.$el.find(\r\n '.zip-locator__change-location .zip-locator__form-field'\r\n )\r\n };\r\n }\r\n\r\n addListeners() {\r\n this.$el.on('submit', ::this.onZipSubmit);\r\n this.dom.$submitBtn.on('click', ::this.onZipSubmit);\r\n this.dom.$toggleBtn.on('click', ::this.onZipToggle);\r\n this.dom.$changeLocationField.on('focus', ::this.displayChangeLocationForm);\r\n }\r\n\r\n displayChangeLocationForm(e) {\r\n e.preventDefault();\r\n this.dom.$changeLocation.addClass('zip-locator__change-location--opened');\r\n }\r\n\r\n onZipToggle(e) {\r\n this.dom.$zipLocationParent.toggleClass('zip-locator--open');\r\n if (this.dom.$zipLocationParent.hasClass('zip-locator--open')) {\r\n this.dom.$inputField.attr('tabindex', 0);\r\n this.dom.$submitBtn.attr('tabindex', 0);\r\n this.dom.$inputField.focus();\r\n } else {\r\n this.dom.$inputField.attr('tabindex', -1);\r\n this.dom.$submitBtn.attr('tabindex', -1);\r\n }\r\n }\r\n\r\n onZipSubmit(e) {\r\n e.stopPropagation();\r\n e.preventDefault();\r\n if (this.$el[0].checkValidity()) {\r\n this.submitZip().catch(err => {\r\n console.log('Server error: ', err);\r\n });\r\n }\r\n }\r\n\r\n async submitZip() {\r\n this.dom.$submitBtn.addClass('is-loading');\r\n const res = await this.postZip();\r\n\r\n if (res.success) {\r\n const redirectURL = res.response.redirectUrl;\r\n window.location.replace(redirectURL);\r\n } else {\r\n //Error handling here\r\n this.clearFormLevelError();\r\n this.displayFormLevelError(res.message);\r\n }\r\n }\r\n\r\n postZip() {\r\n const data = this.$el.serializeJSON();\r\n return $.ajax({\r\n method: 'POST',\r\n url: this.endpoint,\r\n contentType: 'application/json',\r\n data\r\n });\r\n }\r\n}\r\n\r\nexport default ZipLocation;\r\n\n\n\n// WEBPACK FOOTER //\n// ./src/js/components/ZipLocation.js","/**\n * jQuery serializeObject\n * @copyright 2014, macek <paulmacek@gmail.com>\n * @link https://github.com/macek/jquery-serialize-object\n * @license BSD\n * @version 2.5.0\n */\n(function(root, factory) {\n\n // AMD\n if (typeof define === \"function\" && define.amd) {\n define([\"exports\", \"jquery\"], function(exports, $) {\n return factory(exports, $);\n });\n }\n\n // CommonJS\n else if (typeof exports !== \"undefined\") {\n var $ = require(\"jquery\");\n factory(exports, $);\n }\n\n // Browser\n else {\n factory(root, (root.jQuery || root.Zepto || root.ender || root.$));\n }\n\n}(this, function(exports, $) {\n\n var patterns = {\n validate: /^[a-z_][a-z0-9_]*(?:\\[(?:\\d*|[a-z0-9_]+)\\])*$/i,\n key: /[a-z0-9_]+|(?=\\[\\])/gi,\n push: /^$/,\n fixed: /^\\d+$/,\n named: /^[a-z0-9_]+$/i\n };\n\n function FormSerializer(helper, $form) {\n\n // private variables\n var data = {},\n pushes = {};\n\n // private API\n function build(base, key, value) {\n base[key] = value;\n return base;\n }\n\n function makeObject(root, value) {\n\n var keys = root.match(patterns.key), k;\n\n // nest, nest, ..., nest\n while ((k = keys.pop()) !== undefined) {\n // foo[]\n if (patterns.push.test(k)) {\n var idx = incrementPush(root.replace(/\\[\\]$/, ''));\n value = build([], idx, value);\n }\n\n // foo[n]\n else if (patterns.fixed.test(k)) {\n value = build([], k, value);\n }\n\n // foo; foo[bar]\n else if (patterns.named.test(k)) {\n value = build({}, k, value);\n }\n }\n\n return value;\n }\n\n function incrementPush(key) {\n if (pushes[key] === undefined) {\n pushes[key] = 0;\n }\n return pushes[key]++;\n }\n\n function encode(pair) {\n switch ($('[name=\"' + pair.name + '\"]', $form).attr(\"type\")) {\n case \"checkbox\":\n return pair.value === \"on\" ? true : pair.value;\n default:\n return pair.value;\n }\n }\n\n function addPair(pair) {\n if (!patterns.validate.test(pair.name)) return this;\n var obj = makeObject(pair.name, encode(pair));\n data = helper.extend(true, data, obj);\n return this;\n }\n\n function addPairs(pairs) {\n if (!helper.isArray(pairs)) {\n throw new Error(\"formSerializer.addPairs expects an Array\");\n }\n for (var i=0, len=pairs.length; i<len; i++) {\n this.addPair(pairs[i]);\n }\n return this;\n }\n\n function serialize() {\n return data;\n }\n\n function serializeJSON() {\n return JSON.stringify(serialize());\n }\n\n // public API\n this.addPair = addPair;\n this.addPairs = addPairs;\n this.serialize = serialize;\n this.serializeJSON = serializeJSON;\n }\n\n FormSerializer.patterns = patterns;\n\n FormSerializer.serializeObject = function serializeObject() {\n return new FormSerializer($, this).\n addPairs(this.serializeArray()).\n serialize();\n };\n\n FormSerializer.serializeJSON = function serializeJSON() {\n return new FormSerializer($, this).\n addPairs(this.serializeArray()).\n serializeJSON();\n };\n\n if (typeof $.fn !== \"undefined\") {\n $.fn.serializeObject = FormSerializer.serializeObject;\n $.fn.serializeJSON = FormSerializer.serializeJSON;\n }\n\n exports.FormSerializer = FormSerializer;\n\n return FormSerializer;\n}));\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/form-serializer/jquery.serialize-object.js\n// module id = 486\n// module chunks = 7 17 18 19 21"],"sourceRoot":""}