{"version":3,"sources":["webpack:///./widgets/newsroomBlock.js"],"names":["CLS","NewsroomBlock","$el","_this","_classCallCheck","this","$","$cards","find","concat","$cardCheckboxInputs","on","event","$card","currentTarget","$checkbox","isChecked","prop","attr","toggleBtnDownloadDisabled","preventDefault","stopPropagation","$btnDownload","downloadSelected","key","value","filter","length","removeAttr","count","each","_index","element","$element","src","val","setTimeout","downloader","document","createElement","setAttribute","body","appendChild","click","removeChild"],"mappings":"i2BAAA,IACMA,EAAM,gBAECC,EAAa,WA6BxB,O,EA5BD,SAAAA,EAAYC,GAAK,IAAAC,EAAA,M,4FAAAC,CAAA,KAAAH,GAChBI,KAAKH,IAAMI,EAAEJ,GAEbG,KAAKE,OAASF,KAAKH,IAAIM,KAAK,IAADC,OAAKT,EAAG,UACnCK,KAAKK,oBAAsBL,KAAKE,OAAOC,KAAK,IAADC,OAAKT,EAAG,yBAEnDK,KAAKE,OAAOI,GAAG,SAAS,SAACC,GACxB,IAAIC,EAAQP,EAAEM,EAAME,eAChBC,EAAYF,EAAML,KAAK,IAADC,OAAKT,EAAG,yBAC9BgB,GAAaD,EAAUE,KAAK,WAChCF,EAAUE,KAAK,UAAWD,GAE1BH,EAAMK,KAAK,cAAeF,GAC1Bb,EAAKgB,+BAGNd,KAAKK,oBAAoBC,GAAG,gBAAgB,SAACC,GAC5CA,EAAMQ,iBACNR,EAAMS,qBAGPhB,KAAKiB,aAAejB,KAAKH,IAAIM,KAAK,IAADC,OAAKT,EAAG,mBAEzCK,KAAKiB,aAAaX,GAAG,SAAS,WAC7BR,EAAKoB,sBAGNlB,KAAKc,8B,EACL,EAAAK,IAAA,4BAAAC,MAED,WACoBpB,KAAKK,oBAAoBgB,OAAO,YAAYC,OAC5C,EAClBtB,KAAKiB,aAAaM,WAAW,YAE7BvB,KAAKiB,aAAaJ,KAAK,WAAY,cAEpC,CAAAM,IAAA,mBAAAC,MAED,WACC,IAAII,EAAQ,EAEZxB,KAAKK,oBAAoBgB,OAAO,YAAYI,MAAK,SAACC,EAAQC,GACzD,IAAIC,EAAW3B,EAAE0B,GACjBH,IAEA,IAAIK,EAAMD,EAASE,MAEnBC,YAAW,WACV,IAAIC,EAAaC,SAASC,cAAc,KAExCF,EAAWG,aAAa,OAAQN,GAChCG,EAAWG,aAAa,WAAY,IACpCF,SAASG,KAAKC,YAAYL,GAC1BA,EAAWM,QACXL,SAASG,KAAKG,YAAYP,KACxB,IAAMR,W,0FAzDc,I","file":"50.js","sourcesContent":["const NS = 'NewsroomBlock';\nconst CLS = 'newsroomBlock';\n\nexport class NewsroomBlock {\n\tconstructor($el) {\n\t\tthis.$el = $($el);\n\n\t\tthis.$cards = this.$el.find(`.${CLS}-card`);\n\t\tthis.$cardCheckboxInputs = this.$cards.find(`.${CLS}-card-checkbox-input`);\n\n\t\tthis.$cards.on('click', (event) => {\n\t\t\tlet $card = $(event.currentTarget);\n\t\t\tlet $checkbox = $card.find(`.${CLS}-card-checkbox-input`);\n\t\t\tlet isChecked = !$checkbox.prop('checked');\n\t\t\t$checkbox.prop('checked', isChecked);\n\n\t\t\t$card.attr('data-active', isChecked);\n\t\t\tthis.toggleBtnDownloadDisabled();\n\t\t});\n\n\t\tthis.$cardCheckboxInputs.on('change click', (event) => {\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t});\n\n\t\tthis.$btnDownload = this.$el.find(`.${CLS}-btn--download`);\n\n\t\tthis.$btnDownload.on('click', () => {\n\t\t\tthis.downloadSelected();\n\t\t});\n\n\t\tthis.toggleBtnDownloadDisabled();\n\t}\n\n\ttoggleBtnDownloadDisabled() {\n\t\tlet checkedItems = this.$cardCheckboxInputs.filter(':checked').length;\n\t\tif (checkedItems > 0) {\n\t\t\tthis.$btnDownload.removeAttr('disabled');\n\t\t} else {\n\t\t\tthis.$btnDownload.attr('disabled', 'disabled');\n\t\t}\n\t}\n\n\tdownloadSelected() {\n\t\tlet count = 0;\n\n\t\tthis.$cardCheckboxInputs.filter(':checked').each((_index, element) => {\n\t\t\tlet $element = $(element);\n\t\t\tcount++;\n\n\t\t\tlet src = $element.val();\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tlet downloader = document.createElement('a');\n\n\t\t\t\tdownloader.setAttribute('href', src);\n\t\t\t\tdownloader.setAttribute('download', '');\n\t\t\t\tdocument.body.appendChild(downloader);\n\t\t\t\tdownloader.click();\n\t\t\t\tdocument.body.removeChild(downloader);\n\t\t\t}, 500 * count);\n\t\t});\n\t}\n}\n"],"sourceRoot":""}