@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 2.76 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[45],{871:function(e,t){e.exports='<style>\n :host {\n width: 100%;\n height: 100%;\n }\n</style>\n\n<iframe id="frameID" width="100%" height="100%" style="border: none;"></iframe>'},913:function(e,t,i){i.r(t),i.d(t,"AuWidgetPreviewMockupSlider",function(){return s}),i.d(t,"widget",function(){return s});var t=i(0),r=i(1),a=i(2),n=i(160),i=i(871);let s=class extends n.c{async exportWidgetData(e){return{previewResourceUrl:this.previewResourceUrl}}async restoreWidgetFromData(e,t){this.previewResourceUrl=null==e?void 0:e.previewResourceUrl,this.emitChange()}updateParams(e){this._initIFrame(e.productId,e.productVersionId,e.productVariantId,e.stateId,e.previewSize.width,e.previewSize.height)}async createPreviewResource(){return this.previewResourceUrl=await this._element.createPreviewResource(),this.emitChange(),this.previewResourceUrl}async _initIFrame(e,t,i,r,a,n){var s,d=this.querySelectorShadow("#frameID"),c=d.contentWindow||d,d=d.contentDocument||c.document;0===d.head.innerHTML.length&&(c=await this.getScriptContent(),(s=d.createRange()).selectNode(d.head),s=s.createContextualFragment(c),d.head.appendChild(s)),0!==d.body.innerHTML.length&&(d.body.innerHTML=""),this._element=d.createElement("au-preview-mockup-slider"),this._element.token=this.auWizard.driver.backOffice.token,this._element.assetStorageUrl=this.auWizard.driver.backOffice.assetStorageUrl,this._element.backOfficeUrl=this.auWizard.driver.backOffice.backOfficeUrl,this._element.designAtomsApiUrl=this.auWizard.driver.backOffice.designAtomsApiUrl,Number(e)&&(this._element.productId=Number(e)),Number(t)&&(this._element.productVersionId=Number(t)),Number(i)&&(this._element.productVariantId=Number(i)),this._element.tenantId=this.auWizard.driver.backOffice.tenantId,this._element.userId=this.auWizard.driver.user.id,this._element.stateId=r,Number(a)&&(this._element.previewWidth=Number(a)),Number(n)&&(this._element.previewHeight=Number(n)),d.body.appendChild(this._element)}async getScriptContent(){let e=await(async()=>{let e="";if(this.driver.backOffice&&0!==this.driver.backOffice.tenantId){var t=r.a.ensureEndsWith(this.driver.backOffice.backOfficeUrl,"/")+"assets/preview-mockup-slider/dist/previewMockupSlider.html?t="+Date.now();try{e=await r.a.loadHtml(t)}catch(e){console.warn("Failed to load PreviewMockupSlider scripts from backend "+t)}}return e})();return e=""===e?await r.a.loadHtml(r.a.getPatchedUrl("static/preview-mockup-slider/previewMockupSlider.html?t="+Date.now())):e}};Object(t.a)([Object(a.c)(),Object(t.b)("design:type",String)],s.prototype,"previewResourceUrl",void 0),s=Object(t.a)([Object(a.a)("au-widget-preview-mockup-slider",i)],s)}}]);