{"version":3,"sources":["webpack:///./widgets/woolLabImageBlock.js"],"names":["CLS","WoolLabImageBlock","el","_classCallCheck","this","$el","$","id","data","$btnAddToMoodboard","find","concat","getMoodboardsApi","addToMoodboardApi","createMoodboardApi","$image","featureMoodboardsEnabled","handleButtons","initFeatureFlags","key","value","hide","_this","on","e","target","hasClass","displaySaveToMoodboardModal","modalWidget","require","Handlebars","registerPartial","precompiled","Function","precompile","template","document","body","append","getSaveToMoodboardModalTemplate","$modal","modalData","selectedItems","attr","itemType","WoolLabSaveToMoodboardModalBlock","modal","css","addClass","remove"],"mappings":"o4BAEA,IACMA,EAAM,oBAGCC,EAAiB,WAgB5B,O,EAfD,SAAAA,EAAYC,I,4FAAIC,CAAA,KAAAF,GACfG,KAAKF,GAAKA,EACVE,KAAKC,IAAMC,EAAEJ,GACbE,KAAKG,GAAKH,KAAKC,IAAIG,KAAK,MACxBJ,KAAKK,mBAAqBL,KAAKC,IAAIK,KAAK,IAADC,OAAKX,EAAG,uBAC/CI,KAAKQ,iBAAmBR,KAAKC,IAAIG,KAAK,oBACtCJ,KAAKS,kBAAoBT,KAAKC,IAAIG,KAAK,qBACvCJ,KAAKU,mBAAqBV,KAAKC,IAAIG,KAAK,sBACxCJ,KAAKW,OAASX,KAAKC,IAAIK,KAAK,IAADC,OAAKX,EAAG,WAGnCI,KAAKY,yBAA2BZ,KAAKC,IAAIG,KAAK,4BAE9CJ,KAAKa,gBACLb,KAAKc,qB,EACL,EAAAC,IAAA,mBAAAC,MAED,WACMhB,KAAKY,0BAETZ,KAAKK,mBAAmBY,SAEzB,CAAAF,IAAA,gBAAAC,MAED,WAAgB,IAAAE,EAAA,KACflB,KAAKC,IAAIkB,GAAG,SAAS,SAACC,GACjBlB,EAAEkB,EAAEC,QAAQC,SAAS,GAADf,OAAIX,EAAG,wBAC9BsB,EAAKK,mCAGP,CAAAR,IAAA,kCAAAC,MAED,WACO,IAAIQ,EAAcC,EAAQ,KAEhCC,IAAWC,gBAAgB,mCAAoCH,GAE/D,IAOII,EAAc,IAAIC,SAAS,UAAYH,IAAWI,WAPvC,8JAOG,GAClB,OAAOJ,IAAWK,SAASH,KAC3B,CAAAb,IAAA,8BAAAC,MAED,WACCd,EAAE8B,SAASC,MAAMC,OAAOlC,KAAKmC,mCAC7B,IAAIC,EAASlC,EAAE,qCAEXmC,EAAY,GAChBA,EAAU7B,iBAAmBR,KAAKQ,iBAClC6B,EAAU5B,kBAAoBT,KAAKS,kBACnC4B,EAAU3B,mBAAqBV,KAAKU,mBACpC2B,EAAUC,cAAgB,CAACtC,KAAKW,OAAO4B,KAAK,QAC5CF,EAAUG,SAAU,QAEpB,IAAIC,mCAAiCL,EAAO,GAAIC,GAEhDD,EAAOM,MAAM,QACbxC,EAAE,QAAQyC,IAAI,gBAAiB,KAC/BP,EAAOO,IAAI,UAAW,KAEtBP,EAAOjB,GAAG,kBAAkB,WAE3BjB,EAAE,mBAAmB0C,SAAS,SAG/BR,EAAOjB,GAAG,mBAAmB,WAC5BiB,EAAOS,SACP3C,EAAE,QAAQyC,IAAI,gBAAiB,Y,0FAzEJ,I","file":"28.js","sourcesContent":["import {WoolLabSaveToMoodboardModalBlock} from './woolLabSaveToMoodboardModalBlock';\n\nconst NS = 'WoolLabImageBlock';\nconst CLS = 'woolLabImageBlock';\nimport Handlebars from 'handlebars';\n\nexport class WoolLabImageBlock {\n\tconstructor(el) {\n\t\tthis.el = el;\n\t\tthis.$el = $(el);\n\t\tthis.id = this.$el.data('id');\n\t\tthis.$btnAddToMoodboard = this.$el.find(`.${CLS}-btnAddToMoodboard`);\n\t\tthis.getMoodboardsApi = this.$el.data('getMoodboardsApi');\n\t\tthis.addToMoodboardApi = this.$el.data('addToMoodboardApi');\n\t\tthis.createMoodboardApi = this.$el.data('createMoodboardApi');\n\t\tthis.$image = this.$el.find(`.${CLS}-image`)//.attr(src)\n\n\t\t// Feature flag\n\t\tthis.featureMoodboardsEnabled = this.$el.data('featureMoodboardsEnabled');\n\n\t\tthis.handleButtons();\n\t\tthis.initFeatureFlags();\n\t}\n\n\tinitFeatureFlags() {\n\t\tif (!this.featureMoodboardsEnabled) {\n\t\t\t// Hide moodboard button\n\t\t\tthis.$btnAddToMoodboard.hide();\n\t\t}\n\t}\n\n\thandleButtons() {\n\t\tthis.$el.on('click', (e) => {\n\t\t\tif ($(e.target).hasClass(`${CLS}-btnAddToMoodboard`)) {\n\t\t\t\tthis.displaySaveToMoodboardModal();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetSaveToMoodboardModalTemplate() {\n let modalWidget = require('../../partials/widgets/woolLabSaveToMoodboardModalBlock.hbs');\n\n\t\tHandlebars.registerPartial('woolLabSaveToMoodboardModalBlock', modalWidget);\n\n\t\tlet template = `\n\t\t\t{{> woolLabSaveToMoodboardModalBlock\n\t\t\t\twg=\"woolLabSaveToMoodboardModalBlock\"\n\t\t\t\tns=\"WoolLabSaveToMoodboardModalBlock\"\n\t\t\t}}\n\t\t`;\n\n\t\tlet precompiled = new Function('return ' + Handlebars.precompile(template))();\n\t\treturn Handlebars.template(precompiled);\n\t}\n\n\tdisplaySaveToMoodboardModal() {\n\t\t$(document.body).append(this.getSaveToMoodboardModalTemplate());\n\t\tlet $modal = $('#woolLabSaveToMoodboardModalBlock');\n\n\t\tlet modalData = {};\n\t\tmodalData.getMoodboardsApi = this.getMoodboardsApi;\n\t\tmodalData.addToMoodboardApi = this.addToMoodboardApi;\n\t\tmodalData.createMoodboardApi = this.createMoodboardApi;\n\t\tmodalData.selectedItems = [this.$image.attr('src')];\n\t\tmodalData.itemType ='image';\n\n\t\tnew WoolLabSaveToMoodboardModalBlock($modal[0], modalData);\n\n\t\t$modal.modal('show');\n\t\t$('body').css('padding-right', '0');\n\t\t$modal.css('padding', '0');\n\n\t\t$modal.on('shown.bs.modal', () => {\n\t\t\t// need to manually add \"in\" class so backdrop can display properly due to IDS override\n\t\t\t$('.modal-backdrop').addClass('in');\n\t\t});\n\n\t\t$modal.on('hidden.bs.modal', () => {\n\t\t\t$modal.remove();\n\t\t\t$('body').css('padding-right', '');\n\t\t});\n\t}\n}\n\n\n"],"sourceRoot":""}