{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./assets/src/js/easyshade-ordering.js","webpack:///./assets/src/js/utils/string-utils.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","EasyShadeOrdering","this","priceListUrl","window","getPriceListUrl","getModelAndHousingCodesUrl","itemPrefix","priceList","lineItemSelectors","document","querySelectorAll","lineItemInputs","ppoIpts","qtyIpts","lineItemsEnteredIpt","getElementById","orderItems","modelHousingCodes","addToCartRedirectUrl","that","resetBtn","querySelector","addEventListener","resetLineItems","getPriceListData","then","data","onPriceListDataLoaded","Promise","resolve","reject","fetch","method","headers","accept","response","ok","json","catch","console","error","model","size","price","item","find","Size","parseFloat","PriceM","PriceO","PriceS","qty","map","ipt","lineItem","sizeVal","modelVal","qtyVal","formattedPpoIpt","ppoIpt","getPriceByModelSize","parseInt","toFixed","formatInDollars","updateLineItemsEntered","selector","event","target","closest","onLineItemUpdated","input","firstOption","getAttribute","capitalizeFirstLetter","str","charAt","toUpperCase","slice","encodeKebabCase","toLowerCase","replace","num","toString","isJson","JSON","parse","e"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IA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gBApBsB,sBAClBkB,EAAInB,QAAQ,GAAGoB,WAAWF,QAAQ,wBAAyB,M,EAoB/DG,OAba,SAACT,GACd,IACEU,KAAKC,MAAMX,GACX,MAAOY,GACP,OAAM,EAER,OAAM","file":"easyshade-ordering.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/* eslint-disable no-console */\nimport { formatInDollars } from './utils/string-utils';\n\nexport default class EasyShadeOrdering {\n constructor() {\n this.priceListUrl = window.getPriceListUrl;\n this.getModelAndHousingCodesUrl = window.getModelAndHousingCodesUrl;\n this.itemPrefix = window.itemPrefix;\n this.priceList = {};\n this.lineItemSelectors = document.querySelectorAll('.easyshade-line-item .form-select');\n this.lineItemInputs = document.querySelectorAll('.easyshade-line-item .form-control');\n this.ppoIpts = document.querySelectorAll('.line-item-price-per-order');\n this.qtyIpts = document.querySelectorAll('.line-item-quantity');\n this.lineItemsEnteredIpt = document.getElementById('LineItemsEntered');\n this.orderItems = [];\n this.modelHousingCodes = [];\n this.addToCartRedirectUrl = window.addToCartRedirectUrl;\n\n const that = this;\n const resetBtn = document.querySelector('.reset-btn');\n if (resetBtn) {\n resetBtn.addEventListener('click', () => {\n that.resetLineItems();\n });\n }\n\n this.getPriceListData()\n .then((data) => {\n this.priceList = data;\n this.onPriceListDataLoaded();\n });\n }\n\n getPriceListData() {\n return new Promise((resolve, reject) => {\n fetch(this.priceListUrl, {\n method: 'GET',\n headers: {\n accept: 'application/json',\n 'content-type': 'application/json',\n },\n })\n .then((response) => {\n if (response.ok) {\n response.json().then(resolve);\n } else {\n response.json().then(reject);\n }\n })\n .catch(console.error);\n });\n }\n\n getPriceByModelSize(model, size) {\n let price = -1;\n if (size === '' || model === '') {\n return price;\n }\n const item = this.priceList.find(p => p.Size === size);\n if (item !== undefined) {\n switch (model) {\n case '0':\n price = parseFloat(item.PriceM, 10);\n break;\n case '1':\n case '2':\n price = parseFloat(item.PriceO, 10);\n break;\n case '3':\n price = parseFloat(item.PriceS, 10);\n break;\n default:\n }\n }\n return price;\n }\n\n updateLineItemsEntered() {\n let qty = 0;\n [].map.call(this.ppoIpts, (ipt) => {\n if (ipt.value !== '') {\n qty += 1;\n }\n });\n if (this.lineItemsEnteredIpt) {\n this.lineItemsEnteredIpt.value = qty;\n }\n }\n\n onLineItemUpdated(lineItem) {\n const sizeVal = lineItem.querySelector('.line-item-size').value;\n const modelVal = lineItem.querySelector('.line-item-model').value;\n const qtyVal = lineItem.querySelector('.line-item-quantity').value;\n const formattedPpoIpt = lineItem.querySelector('.line-item-formatted-price-per-order');\n const ppoIpt = lineItem.querySelector('.line-item-price-per-order');\n const price = this.getPriceByModelSize(modelVal, sizeVal);\n if (qtyVal !== '' && qtyVal !== '0' && price !== -1) {\n ppoIpt.value = (price * parseInt(qtyVal, 10)).toFixed(2);\n formattedPpoIpt.value = formatInDollars(price * parseInt(qtyVal, 10));\n } else {\n formattedPpoIpt.value = '';\n ppoIpt.value = '';\n }\n this.updateLineItemsEntered();\n }\n\n onPriceListDataLoaded() {\n [].map.call(this.lineItemSelectors, selector => (\n selector.addEventListener('change', (event) => {\n const lineItem = event.target.closest('tr');\n this.onLineItemUpdated(lineItem);\n })\n ));\n [].map.call(this.lineItemInputs, input => (\n input.addEventListener('keyup', (event) => {\n const lineItem = event.target.closest('tr');\n this.onLineItemUpdated(lineItem);\n })\n ));\n // Calculate prices on load, if quantities are already set\n [].map.call(this.qtyIpts, (ipt) => {\n if (ipt.value !== '' && ipt.value !== '0') {\n const lineItem = ipt.closest('tr');\n this.onLineItemUpdated(lineItem);\n }\n });\n }\n\n resetLineItems() {\n [].map.call(this.lineItemSelectors, (selector) => {\n // Set selected to first value\n const firstOption = selector.querySelector('option:first-child');\n if (firstOption) {\n selector.value = firstOption.getAttribute('value');\n }\n });\n [].map.call(this.lineItemInputs, (input) => {\n input.value = '';\n });\n }\n}\nwindow.EasyShadeOrdering = EasyShadeOrdering;\n/* eslint-enable no-console */\n","const encodeKebabCase = (str) => {\n if (!str) {\n return '';\n }\n return str.toLowerCase().replace(/\\s/g, '-');\n};\n\nconst formatInDollars = num => (\n `$${num.toFixed(2).toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',')}`\n);\n\nconst capitalizeFirstLetter = str => (\n str.charAt(0).toUpperCase() + str.slice(1)\n);\n\nconst isJson = (str) => {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n};\n\nexport {\n capitalizeFirstLetter,\n encodeKebabCase,\n formatInDollars,\n isJson,\n};\n"],"sourceRoot":""}