{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./assets/src/js/compare-models.js","webpack:///./assets/src/js/modules/site-modal.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","CompareModels","modalBtn","document","getElementById","this","selectedModels","compareLimit","compareOptions","querySelectorAll","modal","SiteModal","id","addEventListener","validateSelection","open","map","option","event","checked","syncSelectedModels","setSelectedModels","updateComparisonTable","preventDefault","arr","model","nameAttr","getAttribute","a","indexOf","push","element","elementNameAttr","min","max","alert","window","length","comparisonTable","querySelector","thList","th","index","modelId","tdList","isVisible","classList","add","remove","td","options","callbacks","onOpen","onClose","modalDiv","isOpen","previousElementInFocus","onResize","closeSelectors","disableOverlayClick","btn","close","onDocumentModalKeyUp","toggleBtn","keyCode","focus","contentDiv","altContentDiv","div","style","height","offsetHeight","updateHeight","resetFocus","setPreviousElementInFocus","activeElement"],"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,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,W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,QACP/C,KAAK+C,SAEP/C,KAAKqE,0BAA0BvE,SAASwE,eACxCtE,KAAKiD,SAASW,QACd5D,KAAKmE,mB,eA7EY7D","file":"compare-models.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, no-unused-vars */\nimport SiteModal from './modules/site-modal';\n\nexport default class CompareModels {\n constructor() {\n const modalBtn = document.getElementById('compare-models-modal-btn');\n if (modalBtn === null) {\n return;\n }\n\n this.selectedModels = [];\n this.compareLimit = 3;\n this.compareOptions = document.querySelectorAll('.product-compare-set input[type=\"checkbox\"]');\n this.modal = new SiteModal({\n id: 'compare-awning-models-modal',\n });\n\n modalBtn.addEventListener('click', () => {\n if (this.validateSelection(0, this.compareLimit)) {\n this.modal.open();\n }\n });\n [].map.call(this.compareOptions, option => (\n option.addEventListener('click', (event) => {\n if (!option.checked) {\n this.syncSelectedModels(option);\n this.setSelectedModels();\n this.updateComparisonTable();\n return;\n }\n if (!this.validateSelection(100, this.compareLimit - 1)) {\n event.preventDefault();\n } else {\n this.syncSelectedModels(option);\n this.setSelectedModels();\n this.updateComparisonTable();\n }\n })\n ));\n }\n\n setSelectedModels() {\n const arr = [];\n [].map.call(this.compareOptions, (model) => {\n const nameAttr = model.getAttribute('name');\n if (model.checked && arr.indexOf(nameAttr) === -1) {\n arr.push(nameAttr);\n }\n });\n this.selectedModels = arr;\n }\n\n syncSelectedModels(element) {\n const elementNameAttr = element.getAttribute('name');\n [].map.call(this.compareOptions, (model) => {\n const nameAttr = model.getAttribute('name');\n if (nameAttr === elementNameAttr && model !== element) {\n model.checked = element.checked;\n }\n });\n }\n\n validateSelection(min, max) {\n // console.log(`${this.selectedModels.length}/${this.compareLimit}`);\n const { alert } = window;\n if (this.selectedModels.length === min) {\n alert('Please select a model to compare.');\n return false;\n } else if (this.selectedModels.length > max) {\n alert(`You can only compare up to ${this.compareLimit} models at a time.`);\n return false;\n }\n return true;\n }\n\n updateComparisonTable() {\n // Get all elements\n const comparisonTable = document.querySelector('.table-comparison');\n const thList = comparisonTable.querySelectorAll('th');\n // Find the index the th w/ data-modelid that match selectedModels\n // Ignore the first\n [].map.call(thList, (th, index) => {\n const modelId = th.getAttribute('data-modelid');\n const tdList = comparisonTable.querySelectorAll(`td:nth-child(${index + 1})`);\n let isVisible = false;\n if (this.selectedModels.indexOf(modelId) === -1 && modelId !== null) {\n th.classList.add('hidden');\n } else {\n th.classList.remove('hidden');\n isVisible = true;\n }\n // Show all elements that match that index, hide the others\n [].map.call(tdList, (td) => {\n if (isVisible) {\n td.classList.remove('hidden');\n } else {\n td.classList.add('hidden');\n }\n });\n });\n }\n}\nconst compareModels = new CompareModels();\n/* eslint-enable no-console, no-unused-vars */\n","/* eslint-disable no-console */\nexport default class SiteModal {\n constructor(options) {\n if (!options.callbacks) {\n options.callbacks = {};\n }\n this.onOpen = options.callbacks.onOpen;\n this.onClose = options.callbacks.onClose;\n this.modalDiv = document.querySelector(`#${options.id}`);\n this.isOpen = false;\n this.previousElementInFocus = null;\n // Modal events\n window.addEventListener('resize', this.onResize.bind(this));\n const closeSelectors = `.close-btn, #modal-refine-btn, .close-modal-btn${options.disableOverlayClick ? '' : ', .modal-overlay'}`;\n [].map.call(this.modalDiv.querySelectorAll(closeSelectors), btn => btn.addEventListener('click', this.close.bind(this)));\n document.addEventListener('keyup', this.onDocumentModalKeyUp.bind(this));\n // Add open to toggleBtn\n if (options.toggleBtn) {\n options.toggleBtn.addEventListener('click', this.open.bind(this));\n }\n }\n\n onDocumentModalKeyUp(event) {\n if (event.keyCode === 27 && this.isOpen) {\n this.close(); /* eslint-disable-line no-use-before-define */\n }\n }\n\n setPreviousElementInFocus(element) {\n this.previousElementInFocus = element;\n }\n\n resetFocus() {\n if (this.previousElementInFocus) {\n this.previousElementInFocus.focus();\n }\n }\n\n updateHeight() {\n if (!this.isOpen) {\n return;\n }\n // Check both .modal-content and .modal-alternate-content\n const contentDiv = this.modalDiv.querySelector('.modal-content:not(.hidden)');\n const altContentDiv = this.modalDiv.querySelector('.modal-alternate-content:not(.hidden)');\n const div = contentDiv !== null ? contentDiv : altContentDiv;\n if (div) {\n this.modalDiv.querySelector('.modal-panel').style.height = `${div.offsetHeight + 30}px`;\n }\n }\n\n onResize() {\n if (!this.isOpen) {\n return;\n }\n this.updateHeight();\n }\n\n close() {\n this.isOpen = false;\n if (this.onClose) {\n this.onClose();\n }\n this.modalDiv.classList.remove('modal-visible');\n this.resetFocus();\n }\n\n open(event) {\n if (event) {\n event.preventDefault();\n }\n this.isOpen = true;\n this.modalDiv.classList.add('modal-visible');\n if (this.onOpen) {\n this.onOpen();\n }\n this.setPreviousElementInFocus(document.activeElement);\n this.modalDiv.focus();\n this.updateHeight();\n }\n}\n/* eslint-enable no-console */\n"],"sourceRoot":""}