{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./Static/javascript/ace/modules/amount-selection.ts","webpack:///./Static/javascript/ace/pages/giftCertificatePage/gift-certificate-page.ts"],"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","AmountSelection","customAmountInput","radioInputs","customAmountRadio","this","inputBlurHandlers","radioSelectHandlers","addEventListener","inputBlurred","inputChanged","on","event","handler","push","newValue","parseFloat","_this","checked","forEach","setTimeout","amount_selection_1","imagePathInputName","formFieldAttribute","amountRadioGroupName","imageApiRoute","giftCertificatePage","queryStringElements","altTextElements","previewImage","document","querySelector","designRadios","slice","querySelectorAll","formInputs","hiddenInput","amountGroup","selectedDesign","amountName","getAttribute","designRadio","radioInGroup","updateSelectedDesign","input","updateImagePreview","radio","selectedDesignUrl","appendToQueryString","serializedQueryString","join","currentAltText","src","alt","paramName","paramValue","replace"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,GAAA,EACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,aAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB,EAAAsB,EA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AAUqC,MAIzC,SAASF,EAAqBI,GAE1BX,EAAYlD,MAAQ6D,EAEpBF,IAGJ,SAASA,IAGLG,EADsBlB,SAASC,cAAc,UAAUP,EAAoB,cACxCe,MAGhCpB,QAAQ/C,KAAK+D,EAAY,SAAAS,GACxBI,EAAoBJ,KAIxB,IAAMK,EAAwBtB,EAAoBuB,KAAK,KACjDC,EAAiBvB,EAAgBsB,KAAK,MAC5CrB,EAAauB,IAAS3B,EAAa,IAAIwB,EACvCpB,EAAawB,IAAMF,EACnBxB,KACAC,KAGJ,SAASoB,EAAoBJ,EAAyBU,GAElDA,EAAyB,MAAbA,EAAoBV,EAAMJ,aAAajB,GAAsB+B,EACzE,IAAMC,EAAkB,OAALX,QAAK,IAALA,OAAK,EAALA,EAAO1D,MACtBoE,GAAaC,GACb5B,EAAoBb,KAAQwC,EAAS,IAAIC,GAGzCD,GAAahC,GACbM,EAAgBd,MAASwC,EAAS,KAAKC,GAAcC,QAAQ,KAAM,QAK/EzF,EAAA2D","file":"gift-certificates.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 = 81);\n","export class AmountSelection {\r\n customAmountInput: HTMLInputElement;\r\n radioInputs: HTMLInputElement[];\r\n inputBlurHandlers: Function[];\r\n radioSelectHandlers: Function[];\r\n customAmountRadio?: HTMLInputElement;\r\n\r\n constructor(customAmountInput: HTMLInputElement, radioInputs: HTMLInputElement[], customAmountRadio?: HTMLInputElement) {\r\n this.customAmountInput = customAmountInput;\r\n this.radioInputs = radioInputs;\r\n this.customAmountRadio = customAmountRadio;\r\n this.inputBlurHandlers = [];\r\n this.radioSelectHandlers = [];\r\n this.customAmountInput.addEventListener('blur', this.inputBlurred.bind(this));\r\n this.customAmountInput.addEventListener('change', this.inputChanged.bind(this));\r\n }\r\n\r\n on(event: string, handler: Function) {\r\n switch (event) {\r\n case \"inputBlur\":\r\n return this.inputBlurHandlers.push(handler);\r\n case \"radioSelect\":\r\n return this.radioSelectHandlers.push(handler);\r\n }\r\n }\r\n\r\n inputChanged() {\r\n const newValue = parseFloat(this.customAmountInput.value);\r\n if (newValue) {\r\n this.customAmountRadio.value = `${newValue}`;\r\n }\r\n }\r\n\r\n inputBlurred() {\r\n const newValue = parseFloat(this.customAmountInput.value);\r\n if (newValue <= 0) {\r\n this.customAmountInput.value = null;\r\n }\r\n else {\r\n this.customAmountRadio.checked = true;\r\n }\r\n if (this.inputBlurHandlers) {\r\n this.inputBlurHandlers.forEach(handler => {\r\n setTimeout(handler.bind(this), 0);\r\n })\r\n }\r\n }\r\n}","import { AmountSelection } from '../../modules/amount-selection';\r\n\r\nconst imageAttribute = \"data-preview-selected-image\";\r\nconst imageRadioAttribute = \"data-preview-image-radio\";\r\nconst imagePathInputAttribute = \"data-preview-selected-value\";\r\nconst imagePathInputName = \"ImageUrl\";\r\nconst formFieldAttribute = \"data-preview-field\";\r\nconst amountRadioGroupName = \"GiftCertificatesRequest.Amount\";\r\nconst amountLabelAttribute = \"data-amount-name\";\r\nconst imageApiRoute = \"/ace-api/gift/preview\";\r\n\r\nexport const giftCertificatePage = () => {\r\n let queryStringElements = [];\r\n let altTextElements = [];\r\n const previewImage = document.querySelector(`[${imageAttribute}]`) as HTMLImageElement;\r\n const designRadios = [].slice.call(document.querySelectorAll(`[${imageRadioAttribute}]`)) as HTMLInputElement[];\r\n const formInputs = document.querySelectorAll(`[${formFieldAttribute}]`);\r\n const hiddenInput = document.querySelector(`[${imagePathInputAttribute}]`) as HTMLInputElement;\r\n const amountGroup = [].slice.call(document.querySelectorAll(`[name=\"${amountRadioGroupName}\"]`)) as HTMLInputElement[];\r\n let selectedDesign = document.querySelector(`[${imageRadioAttribute}]:checked`) as HTMLInputElement || designRadios[0];\r\n\r\n // Amount radio inputs + custom textbox\r\n const customAmountInput = document.querySelector('#Amounts_custom-field') as HTMLInputElement;\r\n const customAmountRadio = document.querySelector('#Amounts_custom') as HTMLInputElement;\r\n const amountName = customAmountInput?.getAttribute(amountLabelAttribute);\r\n\r\n // Bind radio buttons to create a new preview\r\n designRadios.forEach(designRadio => {\r\n designRadio.addEventListener('change', () => {\r\n designRadios.forEach(radioInGroup => {\r\n if (radioInGroup.checked) {\r\n updateSelectedDesign(radioInGroup.value);\r\n }\r\n })\r\n });\r\n });\r\n\r\n // Bind inputs to refresh preview image when they change text\r\n [].forEach.call(formInputs, (input) => {\r\n input.addEventListener(\"change\", () => {\r\n updateImagePreview();\r\n });\r\n });\r\n\r\n // Initialize preview to the first image (or already-selected image if refreshed/user has gone back in browser)\r\n selectedDesign.checked = true;\r\n updateSelectedDesign(selectedDesign.value);\r\n\r\n if (customAmountInput && amountGroup) {\r\n const amountSelection = new AmountSelection(customAmountInput, amountGroup, customAmountRadio);\r\n amountSelection.on('inputBlur', () => {\r\n updateImagePreview();\r\n });\r\n\r\n amountGroup.forEach(radio => {\r\n radio.addEventListener('change', updateImagePreview);\r\n });\r\n }\r\n\r\n function updateSelectedDesign(selectedDesignUrl) {\r\n // set hidden field value to the new item\r\n hiddenInput.value = selectedDesignUrl;\r\n\r\n updateImagePreview();\r\n }\r\n\r\n function updateImagePreview() {\r\n // Find selected amount and add to query string\r\n const checkedAmount = document.querySelector(`[name=\"${amountRadioGroupName}\"]:checked`) as HTMLInputElement;\r\n appendToQueryString(checkedAmount, amountName);\r\n\r\n // Update query string with current values from all other fields\r\n [].forEach.call(formInputs, input => {\r\n appendToQueryString(input);\r\n });\r\n\r\n // Set image src to api route with query params applied\r\n const serializedQueryString = queryStringElements.join(\"&\");\r\n const currentAltText = altTextElements.join(\", \");\r\n previewImage.src = `${imageApiRoute}?${serializedQueryString}`;\r\n previewImage.alt = currentAltText;\r\n queryStringElements = [];\r\n altTextElements = [];\r\n }\r\n\r\n function appendToQueryString(input: HTMLInputElement, paramName?: string) {\r\n // Get the query string param name from the preview field attribute value\r\n paramName = paramName == null ? input.getAttribute(formFieldAttribute) : paramName;\r\n const paramValue = input?.value;\r\n if (paramName && paramValue) {\r\n queryStringElements.push(`${paramName}=${paramValue}`);\r\n }\r\n\r\n if (paramName != imagePathInputName) {\r\n altTextElements.push((`${paramName}: ${paramValue}`).replace(/\"/g, \"'\"));\r\n }\r\n }\r\n}\r\n\r\ngiftCertificatePage();"],"sourceRoot":""}