{"version":3,"sources":["webpack:///./widgets/productItemCarouselWidget.js"],"names":["CLS","ProductItemCarouselWidget","element","_classCallCheck","this","$el","$","$title","find","concat","$subTitle","$content","$certifiedIcon","$bgImg","id","data","prodApi","getValues","key","value","_this","options","utils","getApiDefaultOptions","fetch","encodeURIComponent","then","response","json","carouselProd","css","image","attr","url","designers","length","html","title","isCertified"],"mappings":"y3BAGA,IACMA,EAAM,4BAECC,EAAyB,WAarC,O,EAZA,SAAAA,EAAYC,I,4FAASC,CAAA,KAAAF,GAEpBG,KAAKC,IAAMC,EAAEJ,GACbE,KAAKG,OAASH,KAAKC,IAAIG,KAAK,IAADC,OAAKT,EAAG,WACnCI,KAAKM,UAAYN,KAAKC,IAAIG,KAAK,IAADC,OAAKT,EAAG,cACtCI,KAAKO,SAAWP,KAAKC,IAAIG,KAAK,IAADC,OAAKT,EAAG,aACrCI,KAAKQ,eAAiBR,KAAKC,IAAIG,KAAK,IAADC,OAAKT,EAAG,mBAC3CI,KAAKS,OAAST,KAAKC,IAAIG,KAAK,IAADC,OAAKT,EAAG,WACnCI,KAAKU,GAAKV,KAAKC,IAAIU,KAAK,MACxBX,KAAKY,QAAUZ,KAAKC,IAAIU,KAAK,WAC7BX,KAAKa,c,EAEN,EAAAC,IAAA,YAAAC,MACA,WAAY,IAAAC,EAAA,KACLC,EAAUC,IAAMC,uBAEtBC,MAAM,GAADf,OAAIL,KAAKY,QAAO,QAAAP,OAAOgB,mBAAmBrB,KAAKU,KAAOO,GAASK,MAAK,SAACC,GACzE,OAAOA,EAASC,UACdF,MAAK,SAACE,GACRR,EAAKS,aAAeD,EAEpBR,EAAKP,OAAOiB,IAAI,mBAAoB,OAASV,EAAKS,aAAaE,MAAQ,KACvEX,EAAKT,SAASqB,KAAK,OAAQZ,EAAKS,aAAaI,KACzCb,EAAKS,aAAaK,WAAad,EAAKS,aAAaK,UAAUC,OAC9Df,EAAKb,OAAO6B,KAAKhB,EAAKS,aAAaK,UAAU,IAG7Cd,EAAKb,OAAO6B,KAAK,KAElBhB,EAAKV,UAAU0B,KAAKhB,EAAKS,aAAaQ,OAEnCjB,EAAKS,aAAaS,aACpBlB,EAAKR,eAAekB,IAAI,UAAW,iB,0FAjCD,I","file":"53.js","sourcesContent":["import utils from '../utils';\n\n// CONSTANTS are all caps.\nconst NS = 'ProductItemCarouselWidget';\nconst CLS = 'productItemCarouselWidget';\n\nexport class ProductItemCarouselWidget {\n\tconstructor(element) {\n\t\t// $el is the widget node return by the loadProductItemCarouselWidget function\n\t\tthis.$el = $(element);\n\t\tthis.$title = this.$el.find(`.${CLS}-title`);\n\t\tthis.$subTitle = this.$el.find(`.${CLS}-subtitle`);\n\t\tthis.$content = this.$el.find(`.${CLS}-content`);\n\t\tthis.$certifiedIcon = this.$el.find(`.${CLS}-certifiedIcon`);\n\t\tthis.$bgImg = this.$el.find(`.${CLS}-imgBg`);\n\t\tthis.id = this.$el.data('id');\n\t\tthis.prodApi = this.$el.data('prodApi');\n\t\tthis.getValues();\n\t}\n\t// get the data from API\n\tgetValues() {\n\t\tconst options = utils.getApiDefaultOptions();\n\n\t\tfetch(`${this.prodApi}?id=${encodeURIComponent(this.id)}`, options).then((response) => {\n\t\t\treturn response.json();\n\t\t}).then((json) => {\n\t\t\tthis.carouselProd = json;\n\t\t\t// replace the data into the corresponding location\n\t\t\tthis.$bgImg.css(\"background-image\", \"url(\" + this.carouselProd.image + \")\");\n\t\t\tthis.$content.attr(\"href\", this.carouselProd.url);\n\t\t\tif (this.carouselProd.designers && this.carouselProd.designers.length) {\n\t\t\t\tthis.$title.html(this.carouselProd.designers[0]);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tthis.$title.html(\" \")\n\t\t\t}\n\t\t\tthis.$subTitle.html(this.carouselProd.title);\n\t\t\t// check if this product is woolmark certified\n\t\t\tif(this.carouselProd.isCertified){\n\t\t\t\tthis.$certifiedIcon.css(\"display\", \"block\");\n\t\t\t}\n\t\t});\n\t}\n}\n"],"sourceRoot":""}