{"version":3,"sources":["webpack:///./src/feature/product-downloads/product-downloads.js","webpack:///./src/feature/product-downloads/product-sds-api-test.js","webpack:///./src/feature/product-downloads/product-sds-api.js","webpack:///./src/foundation/utilities/clearElementContent.js"],"names":["defaultSettings","prouductid","dev","endpoint","ProductDownloads","element","el","initDomCache","settings","Object","assign","parseSettings","fetchResults","productid","countryid","productSDSTest","initEvents","addEventListener","dom","sds","e","preventDefault","target","value","sdsList","sdsChange","cartDropdown","setCartDropdown","options","selectedIndex","clearCartDropdown","then","json","context","updateLinks","dropdownAddCart","removeAttribute","dropdownTarget","option","setAttribute","getAttribute","items","markup","itemArray","JSON","parse","forEach","item","isRequest","url","name","documentId","sectionId","filename","insertAdjacentHTML","BaseFeature","emulatedNetworkDelay","Promise","resolve","setTimeout","productSDS","path","fetch","response","clearElementContent","firstChild","removeChild"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,kBAAkB;AACvBC,aAAY,EADW;AAEvBC,MAAK,KAFkB;AAGvBC,WAAU;AAHa,CAAxB;;IAMqBC,gB;;;AACpB,2BAAYC,OAAZ,EAAqB;AAAA;;AAAA,kIACdA,OADc;;AAEpB,QAAKC,EAAL,GAAUD,OAAV;AACA,QAAKE,YAAL;AACA,QAAKC,QAAL,GAAgBC,OAAOC,MAAP,CAAc,EAAd,EAAkBV,eAAlB,EAAmC,MAAKW,aAAL,EAAnC,CAAhB;;AAEA;AACA,QAAKC,YAAL,GAAoB,CAAC,MAAKJ,QAAL,CAAcN,GAAf,GACnB;AAAA,UAAa,+BAAW,MAAKM,QAAL,CAAcL,QAAzB,EAAmC,MAAKK,QAAL,CAAcK,SAAjD,EAA4DC,SAA5D,CAAb;AAAA,GADmB,GAEnBC,iCAFD;;AAIA,QAAKC,UAAL;AAXoB;AAYpB;;;;+BAEY;AAAA;;AACZ,QAAKC,gBAAL,CAAsB,KAAKC,GAAL,CAASC,GAA/B,EAAoC,QAApC,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foundation/base/base';\r\nimport { productSDSTest } from './product-sds-api-test';\r\nimport { productSDS } from './product-sds-api';\r\nimport { clearElementContent } from '../../foundation/utilities/clearElementContent';\r\nimport { initBehaviors, destroyBehaviors, resetBehaviorNames } from '../../foundation/featureLoader';\r\n\r\nconst defaultSettings = {\r\n\tprouductid: '',\r\n\tdev: false,\r\n\tendpoint: ''\r\n};\r\n\r\nexport default class ProductDownloads extends BaseFeature {\r\n\tconstructor(element) {\r\n\t\tsuper(element);\r\n\t\tthis.el = element;\r\n\t\tthis.initDomCache();\r\n\t\tthis.settings = Object.assign({}, defaultSettings, this.parseSettings());\r\n\r\n\t\t// Fetch result from API depending on dev\r\n\t\tthis.fetchResults = !this.settings.dev ?\r\n\t\t\tcountryid => productSDS(this.settings.endpoint, this.settings.productid, countryid) :\r\n\t\t\tproductSDSTest;\r\n\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\tinitEvents() {\r\n\t\tthis.addEventListener(this.dom.sds, 'change', (e) => {\r\n\t\t\te.preventDefault();\r\n\t\t\tif (!e.target.value || !this.settings.productid) {\r\n\t\t\t\tclearElementContent(this.dom.sdsList);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tthis.sdsChange(e.target.value);\r\n\t\t});\r\n\r\n\t\tif (this.dom.cartDropdown) {\r\n\t\t\tthis.addEventListener(this.dom.cartDropdown, 'change', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\tif (e.target.value) {\r\n\t\t\t\t\tthis.setCartDropdown(e.target.options[e.target.selectedIndex]);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.clearCartDropdown();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tsdsChange(countryid) {\r\n\t\tclearElementContent(this.dom.sdsList);\r\n\t\tthis.fetchResults(countryid).then((json) => {\r\n\t\t\tdestroyBehaviors({ context: this.dom.sdsList });\r\n\t\t\tthis.updateLinks(json);\r\n\t\t});\r\n\t}\r\n\r\n\tclearCartDropdown() {\r\n\t\tthis.dom.dropdownAddCart.removeAttribute('data-id');\r\n\t\tthis.dom.dropdownAddCart.removeAttribute('data-name');\r\n\t\tthis.dom.dropdownAddCart.removeAttribute('data-section-id');\r\n\t\tthis.dom.dropdownAddCart.removeAttribute('data-section-name');\r\n\t\tthis.dom.dropdownAddCart.removeAttribute('data-filename');\r\n\t\tresetBehaviorNames({ context: this.dom.dropdownTarget });\r\n\t\tinitBehaviors({ context: this.dom.dropdownTarget });\r\n\t}\r\n\r\n\tsetCartDropdown(option) {\r\n\t\tthis.dom.dropdownAddCart.setAttribute('data-id', option.getAttribute('data-id'));\r\n\t\tthis.dom.dropdownAddCart.setAttribute('data-name', option.getAttribute('data-name'));\r\n\t\tthis.dom.dropdownAddCart.setAttribute('data-section-id', option.getAttribute('data-section-id'));\r\n\t\tthis.dom.dropdownAddCart.setAttribute('data-section-name', option.getAttribute('data-section-name'));\r\n\t\tthis.dom.dropdownAddCart.setAttribute('data-filename', option.getAttribute('data-filename'));\r\n\r\n\t\tresetBehaviorNames({ context: this.dom.dropdownTarget });\r\n\t\tinitBehaviors({ context: this.dom.dropdownTarget });\r\n\t}\r\n\r\n\tupdateLinks(items) {\r\n\t\tlet markup;\r\n\t\tconst itemArray = JSON.parse(items);\r\n\r\n\t\titemArray.forEach((item) => {\r\n\t\t\tif (item.isRequest === false) {\r\n\t\t\t\tmarkup = `\r\n\t\t\t\t\t
  • \r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t${item.name}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
  • `;\r\n\t\t\t} else {\r\n\t\t\t\tmarkup = `\r\n\t\t\t\t\t

    ${item.name}

    \r\n\t\t\t\t\t\r\n\t\t\t\t\t`;\r\n\t\t\t}\r\n\t\t\tthis.dom.sdsList.insertAdjacentHTML('beforeend', markup);\r\n\t\t\tresetBehaviorNames({ context: this.dom.sdsList });\r\n\t\t\tinitBehaviors({ context: this.dom.sdsList });\r\n\t\t});\r\n\t}\r\n\r\n\t// Get settings from data-attributes\r\n\tparseSettings() {\r\n\t\tconst settings = this.el.getAttribute('data-settings') || '{}';\r\n\t\treturn JSON.parse(settings);\r\n\t}\r\n}\r\n","const item = '[{\"name\":\"Capaâ„¢ 2101A (German)\",\"type\":\"download\",\"url\": \"#\",\"isRequest\": \"true\"}]';\r\n\r\nconst emulatedNetworkDelay = 250;\r\n\r\nexport function productSDSTest() {\r\n\treturn new Promise((resolve) => {\r\n\t\tsetTimeout(() => {\r\n\t\t\tresolve(\r\n\t\t\t\titem\r\n\t\t\t);\r\n\t\t}, emulatedNetworkDelay);\r\n\t});\r\n}\r\n","export function productSDS(endpoint, productid, countryid) {\r\n\tconst path = `${endpoint}?productid=${productid}&countryid=${countryid}`;\r\n\r\n\treturn new Promise((resolve) => {\r\n\t\tfetch(path).then((response) => {\r\n\t\t\tresponse.json().then((json) => {\r\n\t\t\t\tresolve(json);\r\n\t\t\t});\r\n\t\t});\r\n\t});\r\n}\r\n","export function clearElementContent(element) {\r\n\twhile (element.firstChild) element.removeChild(element.firstChild);\r\n}\r\n"],"sourceRoot":""}