1var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),Preview;(function(Preview){var UI;(function(UI){var AccordionController=function(_super){function AccordionController(){var _this=_super.call(this)||this;return _this.route("/product/edit/loadField/:forceLoad",_this.load),_this.route("/product/accordion/load/field/for/carousal/:forceLoad",_this.load),_this.route("/product/edit/select/:source/:name",_this.select),_this.route("/product/edit/updateView/:source/:name",_this.update),_this.route("/product/edit/deSelect",_this.deSelect),_this.route("/product/edit/addDesignObject/:source/:name/:index",_this.add),_this.route("/product/edit/removeDesignObject/:source/:name",_this.remove),_this.route("/accordion/setFirstObjectAsActive",_this.setFirstObjectAsActive),_this.route("/accordion/setUserSelectedDOAsActive",_this.setUserSelectedDOAsActive),_this.route("/accordion/moveToPosition/:name/:index",_this.moveToPosition),_this.route("/accordion/refresh/:name",_this.refresh),_this.route("/product/edit/removeAllDesignObject/:source/:name",_this.removeDesignObjects),_this.route("/product/edit/updatedesignObjectView/:source/:name",_this.updatedesignObject),_this}return __extends(AccordionController,_super),AccordionController.prototype.init=function(){this.accordion=application.getComponent("Accordion")},AccordionController.prototype.load=function(){this.accordion.render()},AccordionController.prototype.select=function(event){var parameters=event.parameters;parameters.source!="accordion"&&this.accordion.select(parameters.name)},AccordionController.prototype.deSelect=function(){this.accordion.deSelectDo()},AccordionController.prototype.setUserSelectedDOAsActive=function(){this.accordion.setUserSelectedDOAsActive()},AccordionController.prototype.setFirstObjectAsActive=function(){this.accordion.setFirstObjectAsActive()},AccordionController.prototype.moveToPosition=function(event){var parameters=event.parameters,index=parseInt(parameters.index);this.accordion.moveToPosition(parameters.name,index)},AccordionController.prototype.add=function(event){var parameters=event.parameters;this.accordion.add(parameters.name);this.accordion.select(parameters.name)},AccordionController.prototype.update=function(event){var parameters=event.parameters;this.accordion.resizeEl(parameters.name)},AccordionController.prototype.updatedesignObject=function(event){var parameters=event.parameters;this.accordion.resizeEldesignObject(parameters.name)},AccordionController.prototype.remove=function(event){var parameters=event.parameters;this.accordion.remove(parameters.name)},AccordionController.prototype.removeDesignObjects=function(event){var parameters=event.parameters;this.accordion.removeDesignObjects(parameters.name)},AccordionController.prototype.refresh=function(event){var parameters=event.parameters;this.accordion.refresh(parameters.name)},AccordionController}(Controller),Accordion;UI.AccordionController=AccordionController;application.addController(new AccordionController);Accordion=function(){function Accordion(){}return Accordion.prototype.init=function(){var _this=this;this.container=$("#area-accordion");$("#area-accordion--caption").hide();this.$controls=$(".control-panel");this.$controlsmobile=$(".mobile-canvas-column-left");this.view=application.getView("EditProduct");this.product=application.getModel("Product");this.canvasTabs=application.getComponent("CanvasTabs",[]);this.$templates=[];this.container.on("mousedown",".accordion-el",function(){application.triggerApplicationEvent("/product/canvasTabs/select/1/false")});return this.container.sortable({axis:"y",items:"li",cursor:"default",placeholder:"placeHolder",tolerance:"pointer",containment:"#area-accordion",handle:".drag-container",start:function(event,ui){ui.item.addClass("borderDrag")},stop:function(event,ui){ui.item.removeClass("borderDrag");var index=_this.container.find("li").index(ui.item),ln=_this.product.designObjectService.getAll().length,name=ui.item.data("view").name,moved=_this.sort(name,ln-index-1);!moved||ln<=1?_this.container.sortable("cancel"):(_this.select(name),_this.product.fieldsService.incrementCurrentFieldVersion(),application.triggerApplicationEvent("/product/edit/updateView/accordion/"+name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+name),application.triggerApplicationEvent("/product/edit/select/accordion/"+name))}}),this},Accordion.prototype.render=function(){var dos,i,designObject;for(this.activeEl=null,this.container.children().remove(),dos=this.product.designObjectService.getAll(),this.$controls.empty(),this.$controlsmobile.empty(),$("#emptyFieldMsg").hide(),this.product.fieldsService.isLocked()?($("#lockedFieldMsg").show(),$("#area-accordion").hide(),$("#area-accordion--caption").hide(),$(".control-panel").hide(),$("#add-content-buttons").hide(),$(".bg-color-container").hide(),$(".template-area-accordion-control").hide(),$("#area-accordion--caption .layer-title").hide()):($("#area-accordion").show(),$("#area-accordion--caption").show(),$(".control-panel").show(),$("#lockedFieldMsg").hide(),$(".bg-color-container").show(),$(".template-area-accordion-control").show(),$("#area-accordion--caption .layer-title").show(),this.userCanAddTextOrImage()?$("#add-content-buttons").show():($("#add-content-buttons").hide(),this.hideControlsForCMSJobPreview()),!this.product.designObjectService.hasCustomObjects()&&this.userCanAddTextAndImage()&&$("#emptyFieldMsg").show()),i=0;i<dos.length;i++)(designObject=dos[i],designObject.hidden)||this.renderSingle(designObject);$("#tab-accordion .simplebar-content-wrapper").scroll(function(){$(".sp-container.sp-light.sp-clear-enabled.sp-palette-buttons-disabled.sp-initial-disabled.full-spectrum:not(.sp-hidden)").find(".sp-cancel").trigger("click")});this.update()},Accordion.prototype.renderSingle=function(designObject){var type=designObject.type,componentName="Accordion"+(designObject.locked?"Locked":"")+$.capilaliseFirstLetter(type),templateName=this.getTemplateName(designObject),template=$("#"+templateName);template.length<1&&console.log("Template was not found! Name: {0} , Do Type: {1}".format(templateName,type));application.getComponent(componentName,[]).init(designObject,template,this).render()},Accordion.prototype.refresh=function(name){this.render();this.select(name)},Accordion.prototype.userCanAddTextOrImage=function(){if(this.product.previewRestriction.canUserAddImageOrText()){var cf=this.product.fieldsService.getCurrent();return!(_.contains(cf.deny,"image")&&_.contains(cf.deny,"text")&&_.contains(cf.deny,"bgcolor"))}return!1},Accordion.prototype.userCanAddTextAndImage=function(){if(this.product.previewRestriction.canUserAddImageOrText()){var cf=this.product.fieldsService.getCurrent();return!(_.contains(cf.deny,"image")||_.contains(cf.deny,"text")||_.contains(cf.deny,"bgcolor"))}return!1},Accordion.prototype.getTemplateName=function(designObject){var type=designObject.type,templateName="template-area-accordion-";return designObject.locked&&($("#emptyFieldMsg").hide(),templateName+="locked-"),templateName+type},Accordion.prototype.deSelect=function(){application.triggerApplicationEvent("/product/edit/deselect")},Accordion.prototype.deSelectDo=function(){this.activeEl&&this.activeEl.deSelect();this.activeEl=null},Accordion.prototype.select=function(name){var des,id,liElement,uploadDialogue;presets.isReadOnly||this.container.find("li#"+name).hasClass("active")||(this.container.find("li .textarea").each(function(){$(this).blur()}),this.deSelectDo(),des=this.product.designObjectService.get(name),presets.productDesign.CurrentDesignObjectName=name,id="#"+$.normaliseId(name),liElement=this.container.find(id),des.locked?(application.triggerApplicationEvent("/product/productTabs/select/1"),liElement.addClass("active"),uploadDialogue=application.getComponent("UploadDialogue"),uploadDialogue.closeCallback=null,uploadDialogue.close(),$(".control-panel").hide(),$("#area-accordion--caption").hide(),$("#area-accordion--caption .layer-title").hide(),$(".template-area-accordion-control").hide(),setTimeout(function(){liElement.find("textarea").focus()},100)):liElement.data("view").renderControl(),this.product.fieldsService.isLocked()&&($("#lockedFieldMsg").show(),$("#area-accordion").hide(),$("#area-accordion--caption").hide(),$(".control-panel").attr("style","border-bottom: 0px;").hide(),$("#add-content-buttons").hide(),$(".bg-color-container").hide(),$(".template-area-accordion-control").hide(),$("#area-accordion--caption .layer-title").hide()))},Accordion.prototype.update=function(){for(var designObject,id,dos=this.product.designObjectService.getAll(),elCount=this.container.find("li").length,accordionIndex=elCount,visibleDo=0,i=0;i<dos.length;i++){if(designObject=dos[i],designObject.hidden)continue;else accordionIndex=accordionIndex-1,visibleDo++;id="#"+$.normaliseId(designObject.name);this.container.find(id).data("view")&&this.container.find(id).data("view").update(accordionIndex)}visibleDo>=1?$("#area-accordion--caption").show():$("#area-accordion--caption").hide()},Accordion.prototype.updateAlldesignObjects=function(){for(var designObject,id,dos=this.product.designObjectService.getAll(),elCount=this.container.find("li").length,accordionIndex=elCount,visibleDo=0,i=0;i<dos.length;i++){if(designObject=dos[i],designObject.hidden)continue;else accordionIndex=accordionIndex-1,visibleDo++;id="#"+$.normaliseId(designObject.name);this.container.find(id).data("view").update(accordionIndex)}visibleDo>=1?$("#area-accordion--caption").show():$("#area-accordion--caption").hide()},Accordion.prototype.resizeEl=function(name){var el,id;(application.triggerApplicationEvent("/product/edit/HideContextMenu"),el=this.product.designObjectService.get(name),el)&&(id="#"+$.normaliseId(name),el.type.IsImage()&&!el.locked&&this.container.find(id).data("view").checkDimensions())},Accordion.prototype.resizeEldesignObject=function(name){var el,id;(application.triggerApplicationEvent("/product/edit/HideContextMenu"),el=this.product.designObjectService.getdesignObjects(name),el)&&(id="#"+$.normaliseId(name),el.type.IsImage()&&!el.locked&&this.container.find(id).data("view").checkDimensions())},Accordion.prototype.add=function(name){var designObject=this.product.designObjectService.get(name),element=application.getComponent("Accordion"+$.capilaliseFirstLetter(designObject.type),[]);element.init(designObject,$("#template-area-accordion-"+designObject.type),this);element.render();this.update()},Accordion.prototype.sort=function(name,index){var validPosition=this.product.designObjectService.validatePosition(index,name);return validPosition?(this.product.designObjectService.relocateTo(name,index),this.update(),!0):!1},Accordion.prototype.remove=function(name){var designObject=this.product.designObjectService.get(name);designObject&&(designObject.isBranding&&(this.product.fieldsService.getCurrent().skipbrand=!0),this.product.designObjectService.remove(name),this.container.find("#"+name).remove(),application.triggerApplicationEvent("/quality/check/fieldbyindex/"+this.product.fieldsService.getCurrentEditableFieldId()),this.update())},Accordion.prototype.removeDesignObjects=function(name){this.product.designObjectService.removeDesignObjects(name);this.container.find("#"+name).remove()},Accordion.prototype.setUserSelectedDOAsActive=function(){var currentField=this.product.fieldsService.getCurrent(),currentFieldIndex=this.product.fieldsService.indexOf(currentField),DOs=this.product.fieldsService.getDesignObjectByFieldIndex(currentFieldIndex,presets.productDesign.CurrentDesignObjectName);presets.productDesign.CurrentDesignObjectName===""||DOs==null?this.makeActiveDesignObject(!0):this.makeActiveDesignObject(!1)},Accordion.prototype.setFirstObjectAsActive=function(){this.makeActiveDesignObject(!0)},Accordion.prototype.makeActiveDesignObject=function(isTheFirstOne){if(!presets.isReadOnly&&this.canvasTabs.getActive()!==0){var name=isTheFirstOne?this.container.find("li:not(.locked)").first().attr("id"):presets.productDesign.CurrentDesignObjectName;name&&(this.select(name),application.triggerApplicationEvent("/product/edit/select/accordion/"+name))}},Accordion.prototype.moveToPosition=function(name,index){var _this=this;this.sort(name,index)&&(this.product.fieldsService.incrementCurrentFieldVersion(),application.triggerApplicationEvent("/product/edit/updateView/accordion/"+name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+name),application.triggerApplicationEvent("/product/edit/select/accordion/"+name),setTimeout(function(){_this.container.scrollTo(_this.container.find("li.active"),"slow");application.triggerApplicationEvent("/product/edit/updateView/accordion/"+name);application.triggerApplicationEvent("/product/edit/showloader/accordion/"+name)},100))},Accordion.prototype.hideControlsForCMSJobPreview=function(){$(".bg-color-container").hide();$(".template-area-accordion-control").hide();$(".control-panel").hide();$("#area-accordion--caption .layer-title").hide();$(".copy-design").hide()},Accordion}();UI.Accordion=Accordion;application.addComponent(new Accordion,"Accordion")})(UI=Preview.UI||(Preview.UI={}))})(Preview||(Preview={})),function(Preview){var UI;(function(UI){var accordionElBase=function(){function accordionElBase(){}return accordionElBase.prototype.baseInit=function(designObject,$template,accordion){this.name=designObject.name;this._designObject=designObject;this._view=accordion.view;this._designObjectService=accordion.product.designObjectService;this._$template=$template;this._accordion=accordion;this.product=application.getModel("Product");var isBuyer=this.product.previewRestriction.isBuyer();return this.templateData={name:$.normaliseId(designObject.name),label:$.htmlDecode(designObject.label),src:this._designObjectService.getCurrentThumbUrl(designObject),frameId:designObject.frameId,isBuyer:isBuyer},this},accordionElBase.prototype.baseRender=function(){var _this=this,self=this,$html=application.getFromTemplate(this._$template,self);$html.find("button[rel='up'],button[rel='down']").mouseup(function(){var rel=$(this).attr("rel").replace("tr-",""),$liAr=self._accordion.container.find("li"),index=$liAr.length-$liAr.index(self._$html)-1;(rel!="down"||index)&&(rel!="up"||index!=$liAr.length-1)&&(index=rel=="up"?index+1:index-1,self._accordion.sort(self.name,index))&&(self.product.fieldsService.incrementCurrentFieldVersion(),application.triggerApplicationEvent("/product/edit/updateView/accordion/"+self.name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+self.name),application.triggerApplicationEvent("/product/edit/select/accordion/"+self.name))});$html.find("div[rel='handle']").on("mousedown",function(){(_this.product.fieldsService.incrementCurrentFieldVersion(),_this._accordion.activeEl&&_this._accordion.activeEl.name==_this.name)||(_this._accordion.select(_this.name),application.triggerApplicationEvent("/product/edit/updateView/accordion/"+_this.name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+_this.name),application.triggerApplicationEvent("/product/edit/select/accordion/"+_this.name))});return this._accordion.container.prepend($html),this._$html=$html,this.$controls=$(".control-panel"),this},accordionElBase.prototype.remove=function(){var removeObjectEvent="/product/designobject/remove/{0}"+this.name;application.triggerApplicationEvent(removeObjectEvent)},accordionElBase.prototype.baseUpdate=function(newIndex){var liAr=this._accordion.container.find("li"),index=liAr.index(this._$html);
1index!=newIndex&&$(liAr[newIndex]).before(this._$html);newIndex==0?this._$html.find("button[rel='up']").addClass("disable"):this._$html.find("button[rel='up']").removeClass("disable");newIndex==liAr.length-1?this._$html.find("button[rel='down']").addClass("disable"):this._$html.find("button[rel='down']").removeClass("disable")},accordionElBase.prototype.renderControl=function(){var controllType,accordionControlName,templateControlName,previewSizeChangeComponent,controlMigration;this._accordion.activeEl=this;controllType=this._designObject.type;(controllType==="montage"||controllType==="collage"||controllType==="calendar")&&(controllType="image");accordionControlName="Accordion{0}Control".format($.capilaliseFirstLetter(controllType));templateControlName="#template-area-accordion-{0}-control".format(controllType);this.controls=application.getComponent(accordionControlName,[]).init(this._designObject,this._designObjectService,$(templateControlName),this).render();this.makeActive();previewSizeChangeComponent=application.getComponent("PreviewSizeChange");previewSizeChangeComponent.init();previewSizeChangeComponent.isMobileMode(presets.productDesign.ScreenWidth)&&(controlMigration=application.getComponent("ControlsMigration"),controlMigration.init(),controlMigration.migrateAccordionToMobile())},accordionElBase.prototype.makeActive=function(){this._$html.addClass("active")},accordionElBase.prototype.baseDeSelect=function(){this.$controls.empty();this._$html.removeClass("active")},accordionElBase}();UI.accordionElBase=accordionElBase})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={})),function(Preview){var UI;(function(UI){var AccordionElControlBase=function(){function AccordionElControlBase(){}return AccordionElControlBase.prototype.baseRender=function(){var _this=this,self=this,$html=application.getFromTemplate(this._$template,self),sensitivity,moveSensitivity,migrationComponent,timer;self.product=application.getModel("Product");this.qualityService=application.getModel("QualityService");this.ruler=application.getComponent("Ruler");sensitivity=self.product.fieldsService.getMoveSensitivity();moveSensitivity=sensitivity?Number(sensitivity):2;self._designObjectService.setMoveStep(presets.productDesign.transform.moveSteps[moveSensitivity]);self._designObjectService.setRotateStep(presets.productDesign.transform.rotateSteps[moveSensitivity]);self._designObjectService.setResizeStep(presets.productDesign.transform.resizeSteps[moveSensitivity]);migrationComponent=application.getComponent("ControlsMigration");self._designObject.type=="image"?($html.find(".repeat-pattern-dev").css("display",""),this.$width=$html.find("#js-repeat-editwidth"),this.$height=$html.find("#js-repeat-editheigth"),this.$btnApply=$html.find("#btnapplyrepeatpattern"),this.$unit=$html.find("#jsunit"),this.$unit.text(this.ruler.getUnitString()),self.disabledCopydesignallsidesBtn()):$html.find(".repeat-pattern-dev").css("display","none");self._designObject.type=="collage"||self._designObject.type=="montage"?$html.find("#effect-removebg").hide():$html.find("#effect-removebg").show();migrationComponent.init();migrationComponent.removeSellerControls();$html.on("mouseup","button[rel^='tr-'], a[rel^='tr-']",function(){var rel=$(this).attr("rel").replace("tr-",""),product,name,imageSize;rel=="aieditor"?application.triggerApplicationEvent("/product/edit/replace/aieditor/"+self._designObject.name):(product=application.getModel("Product"),product.fieldsService.incrementCurrentFieldVersion(),name=self._designObject.name,self._designObjectService.transform(name,rel),application.triggerApplicationEvent("/quality/check/designobject/"+name),application.triggerApplicationEvent("/quality/display/fieldbyindex/{0}".format(self.product.fieldsService.getCurrentEditableFieldId())),application.triggerApplicationEvent("/product/edit/updateView/accordion/"+name),application.triggerApplicationEvent("/product/edit/select/accordion/"+name),self.getGtmAction(rel),self._designObject.type=="image"&&(imageSize=self.qualityService.GetImageSizeStruct(self._designObject,self.product.fieldsService.getCurrent(),self.ruler.getUnitString()),self.$width.val(imageSize.width),self.$height.val(imageSize.height)),$("div.bc.bc-effects.hide-tooltip, div.move-step.hide-tooltip, div.nudge.hide-tooltip, .button-control .bc.hide-tooltip, div.text-alignment.hide-tooltip, div.bc.bc-patterns.hide-tooltip").removeClass("hide-tooltip"),application.triggerApplicationEvent("/product/selectField/displayHideControls"))});$html.find("div.move-step div.slider").slider({orientation:"horizontal",range:"min",min:0,max:5,step:1,value:moveSensitivity,slide:function(event,ui){_this.product.fieldsService.setMoveSensitivity(ui.value.toString());_this._designObjectService.setMoveStep(presets.productDesign.transform.moveSteps[ui.value]);_this._designObjectService.setRotateStep(presets.productDesign.transform.rotateSteps[ui.value]);_this._designObjectService.setResizeStep(presets.productDesign.transform.resizeSteps[ui.value])}});$html.find("div.move-step").on("mouseenter","a#open-help-move-step",function(){timer=setTimeout(function(){$html.find("div.help-move-step").show()},50)}).on("mouseleave","a#open-help-move-step",function(){clearTimeout(timer);$html.find("div.help-move-step").hide()});return this.product.previewRestriction.canShowDesignerOptions()&&(this._designObject.type=="text"&&($html=this.wireText($html)),this._designObject.type=="image"&&($html=this.wireImage($html))),this._designObject.frameId&&this.product.previewRestriction.canAccordionControlBeAvailable()&&this._designObject.locked&&($html.find("button[rel='tr-rotate-cw']").hide(),$html.find("button[rel='tr-rotate-ccw']").hide(),$html.find("#rotateCaption").hide(),$html.find("div.toolbar-button-labels div:nth-child(3)").hide()),this._accordionEl.$controls.html($html),window.innerWidth<=990&&migrationComponent.AddSellerControltoMobileOption(),$html},AccordionElControlBase.prototype.wireImage=function($html){var sellerControlls=application.getFromTemplate($("#template-area-accordion-image-seller-controlls"),this),sellerOptionsHandler=new UI.SellerFrameLockOptions(this._designObject,sellerControlls,!1);return $html.append(sellerControlls)},AccordionElControlBase.prototype.wireText=function($html){var sellerControlls=application.getFromTemplate($("#template-area-accordion-text-seller-controlls"),this),sellerOptionsHandler=new UI.SellerFrameLockOptions(this._designObject,sellerControlls,!0);return $("<div><\/div>").append($html).append(sellerControlls)},AccordionElControlBase.prototype.wireImagePatterns=function(){var _this=this;if(this._designObject.frameId&&this.product.previewRestriction.isBuyer()){this._$html.find(".pattern_icon-btn").hide();return}this._$html.find(".pattern_icon-btn").on("mousedown",function(e){var pattern,imageSize;e.stopPropagation();_this._$html.find("div.select-effect").hide();_this._$html.find("div.pattern_popup").show();$("div.bc.bc-effects, div.move-step, div.nudge, .button-control .bc, div.text-alignment, div.bc.bc-patterns").addClass("hide-tooltip");pattern=_this._designObject.pattern;pattern||(pattern="Center");_this._$html.find(".pattern_popup .selected").removeClass("selected");_this._$html.find(".pattern_popup .tr-Pattern-{0}".format(pattern)).parent().addClass("selected");_this._designObject.type=="image"&&(_this.$unit.text(_this.ruler.getUnitString()),imageSize=_this.qual
1ityService.GetImageSizeStruct(_this._designObject,_this.product.fieldsService.getCurrent(),_this.ruler.getUnitString()),_this.$width.val(imageSize.width),_this.$height.val(imageSize.height),_this.disabledCopydesignallsidesBtn())});this._$html.find(".pattern_popup a[rel*='tr-']").on("mousedown",function(e){e.stopPropagation();$(this).parent().siblings().removeClass("selected");$(this).parent().addClass("selected")});this._$html.find(".closepattern").on("mousedown",function(e){e.stopPropagation();$("div.bc.bc-effects.hide-tooltip, div.move-step.hide-tooltip, div.nudge.hide-tooltip, .button-control .bc.hide-tooltip, div.text-alignment.hide-tooltip, div.bc.bc-patterns.hide-tooltip").removeClass("hide-tooltip");_this._$html.find("div.pattern_popup").hide()});this._$html.find("#btnapplyrepeatpattern").on("mousedown",function(e){e.stopPropagation();var IsCopyAllSides=$("#copydesignallsides").is(":checked");IsCopyAllSides&&(application.triggerApplicationEvent("/product/dropdown/designCopyToSelectedField/555"),_this.getGtmAction("copydesign"));_this._$html.find("div.pattern_popup").hide()});this._$html.find("#js-repeat-editwidth").on("keyup",function(e){var newHeight,product,name;(e.stopPropagation(),newHeight=_this.getHeightOrWidth(_this.$width.val(),!0),_this.setvalue(_this.$height,newHeight),_this.isInputValid())&&(product=application.getModel("Product"),product.fieldsService.incrementCurrentFieldVersion(),_this.setTheDesignObjectSize(_this.$height.val(),_this.$width.val(),_this.ruler.getUnitString()),_this.checkTheQuality(),name=_this._designObject.name,application.triggerApplicationEvent("/product/edit/updateView/accordion/"+name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+name),application.triggerApplicationEvent("/product/edit/select/accordion/"+name))});this._$html.find("#js-repeat-editheigth").on("keyup",function(e){var newWidth,product,name;(e.stopPropagation(),newWidth=_this.getHeightOrWidth(_this.$height.val(),!1),_this.setvalue(_this.$width,newWidth),_this.isInputValid())&&(product=application.getModel("Product"),product.fieldsService.incrementCurrentFieldVersion(),_this.setTheDesignObjectSize(_this.$height.val(),_this.$width.val(),_this.ruler.getUnitString()),_this.checkTheQuality(),name=_this._designObject.name,application.triggerApplicationEvent("/product/edit/updateView/accordion/"+name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+name),application.triggerApplicationEvent("/product/edit/select/accordion/"+name))});this._$html.find(".repeat-pattern-dev").on("mousedown",function(e){e.stopPropagation()});this._$html.find("ul.select-effect-ul").on("mouseup",function(e){$(e.target).closest("div").parent().hasClass("pattern_popup")||($("div.bc.bc-effects.hide-tooltip, div.move-step.hide-tooltip, div.nudge.hide-tooltip, .button-control .bc.hide-tooltip, div.text-alignment.hide-tooltip, div.bc.bc-patterns.hide-tooltip").removeClass("hide-tooltip"),_this._$html.find("div.select-effect").hide())});$(document).on("mousedown",function(){_this._$html.find("div.select-effect").hide()})},AccordionElControlBase.prototype.getGtmAction=function(transform){var gtmAction="";switch(transform){case"scale-minus":gtmAction="Click: Image zoom out";break;case"scale-plus":gtmAction="Click: Image zoom in";break;case"rotate-ccw":gtmAction="Click: Image rotated left";break;case"rotate-cw":gtmAction="Click: Image rotated right";break;case"fill":gtmAction="Click: Image auto fill";break;case"fit":gtmAction="Click: Image auto fit";break;case"north":gtmAction="Click: image move up";break;case"east":gtmAction="Click: image move rigth";break;case"south":gtmAction="Click: image move down";break;case"west":gtmAction="Click: image move left";break;case"centre":gtmAction="Click: image center";break;case"Black-White":gtmAction="Click: effect > black & white";break;case"Colour":gtmAction="Click: effect > normal";break;case"Pattern-Center":gtmAction="Click: pattern > no repeat";break;case"Pattern-Basic":gtmAction="Click: pattern > basic";break;case"Pattern-HalfDrop":gtmAction="Click: pattern > halfdrop";break;case"Pattern-Mirror":gtmAction="Click: pattern > mirror";break;case"mirror":gtmAction="Click: effect > mirror";break;case"Outline-0":gtmAction="Click: no text outline";case"Outline-1":gtmAction="Click: text outline > border ";case"Outline-3":gtmAction="Click: text outline > shadow ";break;case"copydesign":gtmAction="CopyDesign:Pattern apply to all. Width:"+this.$width.val()+" Height:"+this.$height.val()}gtmAction!=""&&window.pushCreationStudioToGTM(gtmAction)},AccordionElControlBase.prototype.getHeightOrWidth=function(length,isWidth){var ar=1,originalWidth=this._designObject.owidth,originalHeight=this._designObject.oheight,temp;return((Math.abs(this._designObject.rotationangle)===90||Math.abs(this._designObject.rotationangle)===270)&&(temp=originalWidth,originalWidth=originalHeight,originalHeight=temp),ar=originalWidth>originalHeight?originalHeight/originalWidth:originalWidth/originalHeight,isWidth&&originalWidth<originalHeight)?length/ar:isWidth&&originalWidth>originalHeight?length*ar:originalWidth>originalHeight?length/ar:length*ar},AccordionElControlBase.prototype.setTheDesignObjectSize=function(heightLength,widthLength,unit){var currentfield=this.product.fieldsService.getCurrent(),dpi=this.product.fieldsService.getCurrentDPI(),wpx=Math.round(this.getPixcelSize(widthLength,unit,dpi)),hpx=Math.round(this.getPixcelSize(heightLength,unit,dpi)),percentWidth=wpx/(currentfield.printw*currentfield.editablefield.width),percentHeight=hpx/(currentfield.printh*currentfield.editablefield.height);this._designObjectService.setSize(this._designObject,percentWidth,percentHeight);application.triggerApplicationEvent("/product/edit/updateView/CanvasTabs/tabcanvas");application.triggerApplicationEvent("/product/edit/showloader/accordianel/designobsize");application.triggerApplicationEvent("/product/edit/select/designObject/"+this._designObject.name);application.triggerApplicationEvent("/accordion/setUserSelectedDOAsActive")},AccordionElControlBase.prototype.checkTheQuality=function(){var field=this.product.fieldsService.getCurrent(),fieldindex=this.product.fieldsService.indexOf(field);application.triggerApplicationEvent("/quality/check/designobject/{0}".format(this._designObject.name));application.triggerApplicationEvent("/quality/display/updatedimension/{0}/{1}".format(fieldindex,this._designObject.name))},AccordionElControlBase.prototype.isInputValid=function(){var decimal=/^[-+]?[0-9]+\.[0-9]+$/,integer=/^\d+$/;if(!this.$width.val().match(decimal)&&!this.$width.val().match(integer)||!this.$height.val().match(decimal)&&!this.$height.val().match(integer))return this.$btnApply.attr("disabled",!0),!1;if(this.$width.val()>5e3||this.$height.val()>5e3)return!1;var minCM=2,unit=this.ruler.getUnitString(),widthInCm=this.convertToCM(this.$width.val(),unit),heightInCm=this.convertToCM(this.$height.val(),unit);return widthInCm<minCM||heightInCm<minCM?!1:(this.$btnApply.attr("disabled",!1),!0)},AccordionElControlBase.prototype.setvalue=function(control,val){val%1<1&&(val=Math.round(val*100)/100);control.val(val)},AccordionElControlBase.prototype.convertToCM=function(length,unit){switch(unit){case"inch":return length*2.54;case"cm":return length;case"meter":return length*100;
1case"yard":return length*2.54*36}},AccordionElControlBase.prototype.getPixcelSize=function(length,unit,dpi){switch(unit){case"inch":return length*dpi;case"cm":return length/2.54*dpi;case"meter":return length*100/2.54*dpi;case"yard":return length*dpi*36}},AccordionElControlBase.prototype.disableApplyButton=function(){var pattern=this._designObject.pattern;pattern?this.$btnApply.prop("disabled",!1):this.$btnApply.prop("disabled",!0)},AccordionElControlBase.prototype.disabledCopydesignallsidesBtn=function(){var cnt=this.product.fieldsService.getTotalCarousalFieldCnt();!cnt||cnt<=1?$("#copydesignallsides").prop("disabled",!0).prop("checked",!1):$("#copydesignallsides").prop("disabled",!1).prop("checked",!0)},AccordionElControlBase}();UI.AccordionElControlBase=AccordionElControlBase})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={})),function(Preview){var UI;(function(){var AccordionLockedImage=function(){function AccordionLockedImage(){this.name="";this._designObject=null;this._$template=null;this._$html=null;this._accordion=null;this._view=null;this._designObjectService=null;this.templateData=null;this.product=null}return AccordionLockedImage.prototype.init=function(designObject,$template,accordion){return this.name=designObject.name,this._designObject=designObject,this._view=accordion.view,this._designObjectService=accordion.product.designObjectService,this._$template=$template,this._accordion=accordion,this.product=application.getModel("Product"),this.templateData={name:$.normaliseId(designObject.name),text:designObject.name,label:$.htmlDecode(designObject.label),src:designObject.predefined?presets.productDesign.designTemplates.path+designObject.image.id:this._designObjectService.getCurrentThumbUrl(designObject)},this},AccordionLockedImage.prototype.render=function(){var _this=this;return this._$html=application.getFromTemplate(this._$template,this),this._accordion.container.prepend(this._$html),this._$html.find("button.replace-image").mouseup(function(e){e.stopPropagation();application.triggerApplicationEvent("/product/edit/replace/image/"+_this.name)}),this},AccordionLockedImage.prototype.baseUpdate=function(newIndex){var liAr=this._accordion.container.find("li"),index=liAr.index(this._$html);index!=newIndex&&$(liAr[newIndex]).before(this._$html);newIndex==0?this._$html.find("a[rel='up']").addClass("disable"):this._$html.find("a[rel='up']").removeClass("disable");newIndex==liAr.length-1?this._$html.find("a[rel='down']").addClass("disable"):this._$html.find("a[rel='down']").removeClass("disable")},AccordionLockedImage.prototype.update=function(newIndex){this.baseUpdate(newIndex)},AccordionLockedImage}();application.addComponent(AccordionLockedImage,"AccordionLockedImage")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={})),function(Preview){var UI;(function(){var AccordionLockedText=function(){function AccordionLockedText(){this.name="";this._designObject=null;this._$template=null;this._$html=null;this._$textbox=null;this._accordion=null;this.templateData=null;this.product=null}return AccordionLockedText.prototype.init=function(designObject,$template,accordion){return this.name=designObject.name,this._designObject=designObject,this._$template=$template,this._accordion=accordion,this.product=application.getModel("Product"),this.templateData={name:$.normaliseId(this._designObject.name),label:$.htmlDecode(this._designObject.label),text:this._designObject.text.value},this.fontService=application.getModel("FontService"),this},AccordionLockedText.prototype.render=function(){var _this=this,$html=application.getFromTemplate(this._$template,this),isMobile;this._accordion.container.prepend($html);this._$html=$html;this._$textbox=this._$html.find("textarea");this._$textbox.attr("placeholder",presets.productDesign.text.defaultText);var confirmBtn=this._$html.find("button"),validateText=function(){_this._$textbox.val(_this.fontService.removeSomeEmojiChars(_this._$textbox.val()));application.triggerApplicationEvent("/quality/checkanddisplay/lockedtext/{0}".format(_this._designObject.name))},updatePreview=function(){_this._designObject.text.value!=$.htmlEncode(_this._$textbox.val())&&(_this.product.fieldsService.incrementCurrentFieldVersion(),_this._designObject.text.value=$.htmlEncode(_this._$textbox.val()),_this._designObject.frameId&&_this._designObject.text.value?application.triggerApplicationEvent("/text/font/justupdatethetext/"+_this._designObject.name):(application.triggerApplicationEvent("/product/edit/updateView/accordion/"+_this._designObject.name),application.triggerApplicationEvent("/product/edit/showloader/accordion/"+_this._designObject.name)))};confirmBtn.on("click",validateText);confirmBtn.on("click",updatePreview);return isMobile=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()),isMobile||(this._$textbox.bindWithDelay("keyup paste cut",validateText,1e3),this._$textbox.bindWithDelay("keyup paste cut copy",updatePreview,1e3)),this._$textbox.focus(function(){var canvasTextEL=$("#D"+$(this).parent().parent().parent().attr("id"));canvasTextEL.length>0&&(application.triggerApplicationEvent("/product/edit/deselect"),canvasTextEL.addClass("PreDefinedTextAreaHighlight"),$(this).parent().parent().parent().addClass("active"));$(this).select()}),this._$textbox.blur(function(){var canvasTextEL=$("#D"+$(this).parent().parent().parent().attr("id"));canvasTextEL.length>0&&(canvasTextEL.removeClass("PreDefinedTextAreaHighlight"),$(this).parent().parent().parent().removeClass("active"))}),this._$textbox.bind("input",function(){_this._$textbox.val(_this.fontService.removeSomeEmojiChars(_this._$textbox.val()))}),validateText(),this},AccordionLockedText.prototype.update=function(){this._$html.find(".textarea").length>0&&this._$html.find(".textarea").val().length>20?this._$html.find(".warning").addClass("ui-warning"):this._$html.find(".warning").removeClass("ui-warning")},AccordionLockedText}();application.addComponent(AccordionLockedText,"AccordionLockedText")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.
1setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var AccordionImage=function(_super){function AccordionImage(){var _this=_super.call(this)||this;return _this.name="",_this._designObject=null,_this._$template=null,_this._$html=null,_this.$controls=null,_this.controls=null,_this._accordion=null,_this._view=null,_this._designObjectService=null,_this.templateData=null,_this}return __extends(AccordionImage,_super),AccordionImage.prototype.init=function(designObject,$template,accordion){var self=this;return self.baseInit(designObject,$template,accordion),self},AccordionImage.prototype.render=function(){return this.baseRender(),self},AccordionImage.prototype.deSelect=function(){this.baseDeSelect()},AccordionImage.prototype.update=function(newIndex){this.baseUpdate(newIndex);this.checkDimensions()},AccordionImage.prototype.checkDimensions=function(){application.triggerApplicationEvent("/quality/check/designobject/"+name)},AccordionImage}(UI.accordionElBase);application.addComponent(AccordionImage,"AccordionImage")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var AccordionImageControl=function(_super){function AccordionImageControl(){var _this=_super.call(this)||this;return _this._designObject=null,_this._$template=null,_this._$html=null,_this._accordionEl=null,_this._designObjectService=null,_this.templateData=null,_this}return __extends(AccordionImageControl,_super),AccordionImageControl.prototype.init=function(designObject,designObjectService,$template,accordionEl){return this._designObject=designObject,this._designObjectService=designObjectService,this._$template=$template,this._accordionEl=accordionEl,this.templateData={name:designObject.name,type:designObject.type,src:designObjectService.getCurrentThumbUrl(designObject)},this},AccordionImageControl.prototype.render=function(){return this._$html=this.baseRender(),this.wireImageEffects(),this.wireImagePatterns(),this},AccordionImageControl.prototype.wireImageEffects=function(){var _this=this;this._$html.find(".effects_icon-btn").on("mousedown",function(e){e.stopPropagation();_this._$html.find("div.select-effect").hide();_this._$html.find("div.effects_popup").show();$("div.bc.bc-effects, div.move-step, div.nudge, .button-control .bc, div.text-alignment, div.bc.bc-patterns").addClass("hide-tooltip");var treatment=_this._designObject.treatment;_this._$html.find(".selected").removeClass("selected");_this._$html.find(".effects_popup .tr-{0}".format(treatment)).parent().addClass("selected")});this._$html.find(".effects_popup a[rel*='tr-']").on("mousedown",function(e){e.stopPropagation();$(this).parent().siblings().removeClass("selected");$(this).parent().addClass("selected")});this._$html.find(".closeeffects").on("mousedown",function(e){e.stopPropagation();_this._$html.find("div.effects_popup").hide()});$(document).on("mousedown",function(e){!$("div.select-effect").is(":visible")||$(e.target).prop("tagName").toLowerCase()=="h2"&&$(e.target).parent().hasClass("select-effect-wrapper")||($("div.bc.bc-effects.hide-tooltip, div.move-step.hide-tooltip, div.nudge.hide-tooltip, .button-control .bc.hide-tooltip, div.text-alignment.hide-tooltip, div.bc.bc-patterns.hide-tooltip").removeClass("hide-tooltip"),_this._$html.find("div.select-effect").hide())})},AccordionImageControl}(UI.AccordionElControlBase);application.addComponent(AccordionImageControl,"AccordionImageControl")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.
1setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var AccordionText=function(_super){function AccordionText(){var _this=_super.call(this)||this;return _this.name="",_this._designObject=null,_this._$template=null,_this._$html=null,_this.$controls=null,_this.controls=null,_this._accordion=null,_this._view=null,_this._designObjectService=null,_this.templateData=null,_this}return __extends(AccordionText,_super),AccordionText.prototype.init=function(designObject,$template,accordion){var self=this;return self.baseInit(designObject,$template,accordion),self},AccordionText.prototype.render=function(){return this.baseRender(),self},AccordionText.prototype.deSelect=function(){this.controls.deSelect();this.baseDeSelect()},AccordionText.prototype.update=function(newIndex){application.getModel("Product").fieldsService.incrementCurrentFieldVersion();this._$html.find(".text-preview").text($.htmlDecode(this._designObject.text.value));typeof newIndex!="undefined"&&this.baseUpdate(newIndex)},AccordionText}(UI.accordionElBase);application.addComponent(AccordionText,"AccordionText")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var AccordionTextControl=function(_super){function AccordionTextControl(){var _this=_super.call(this)||this;return _this._designObject=null,_this.dialogue=null,_this._$template=null,_this._$html=null,_this._$textbox=null,_this._accordionEl=null,_this._designObjectService=null,_this.templateData=null,_this}return __extends(AccordionTextControl,_super),AccordionTextControl.prototype.init=function(designObject,designObjectService,$template,accordionEl){return this._designObject=designObject,this.dialogue=application.getComponent("Dialogue"),this._fontService=application.getModel("FontService"),this._designObjectService=designObjectService,this._$template=$template,this._accordionEl=accordionEl,this.templateData={id:designObject.id,text:designObject.text.value},this},AccordionTextControl.prototype.render=function(){var _this=this,self=this,imgSelectdata,imgSelectHdata,selectedHex,textColor,numberTextBoxdata;this._$html=this.baseRender();this._$textbox=this._accordionEl.$controls.find("textarea");imgSelectdata={templateData:{selected:self._designObject.text.font.face,height:"170px",basePath:presets.productDesign.text.fonts.path,cellWidth:"275px",cellHeight:"45px",data:presets.productDesign.text.fonts.library},change:function(key){var fontParams=presets.productDesign.text.fonts.library[key][0];self._designObject.text.font.face=key;self._designObject.text.font.style=fontParams;application.triggerApplicationEvent("/text/font/adjustbox/"+self._designObject.name);window.pushCreationStudioToGTM("Chnage font size:"+key)}};application.getComponent("ImageSelect").init(imgSelectdata,this._$html.find(".fonts")).render();$(".text-control .fonts").on("click",function(){$(".select-a-font .dropdown").addClass("font-family--open");$(".font-family--open").show()});imgSelectHdata={change:function(key){_this._designObject.text.align=key;application.triggerApplicationEvent("/text/font/updateAlignment/"+_this._designObject.name);application.triggerApplicationEvent("/product/edit/updateView/accordion/"+_this._designObject.name);application.triggerApplicationEvent("/product/edit/select/accordion/"+_this._designObject.name)},templateData:{selected:self._designObject.text.align}};application.getComponent("ImageSelectHorizontal").init(imgSelectHdata,this._$html.find(".text-alignment")).render();selectedHex="";textColor=this._designObject.text.color;selectedHex=$.hex(textColor.red);selectedHex+=$.hex(textColor.green);selectedHex+=$.hex(textColor.blue);var chooseButtonText=$(application.getFromTemplate($("#colorpicker-choosecolor"),{templateData:{}})),cancelButtonText=$(application.getFromTemplate($("#colorpicker-cancelcolorselection"),{templateData:{}})),data={change:function(vl){var textColor2=self._designObject.text.color;vl=vl||"ffffff";textColor2.red=parseInt(vl.substring(0,2),16);textColor2.green=parseInt(vl.substring(2,4),16);textColor2.blue=parseInt(vl.substring(4,6),16);application.triggerApplicationEvent("/product/edit/updateView/accordion/"+self._designObject.name);application.triggerApplicationEvent("/product/edit/select/accordion/"+self._designObject.name)},templateData:{selectedHex:selectedHex,selected:this._designObject.text.color,disabledCopyDesign:!0},chooseText:chooseButtonText[0].innerHTML,cancelText:cancelButtonText[0].innerHTML};
1return application.getComponent("BgColorPicker").init(data,this._$html.find(".color-picker")).render(),numberTextBoxdata={value:this._designObject.text.font.size,sizes:this._fontService.getSuggestedFontSizes(),name:this._designObject.name},application.getComponent("FontSizeDropdown",[numberTextBoxdata,this._$html.find(".font-size"),this._fontService]).init().render(),this.wireTextEdit(),this.wireOutline(),this.wireImagePatterns(),this},AccordionTextControl.prototype.wireTextEdit=function(){var _this=this;this._accordionEl.$controls.find(".edit-text-box").on("click",function(){application.triggerApplicationEvent("/product/edit/replace/text/"+_this._designObject.name)});this._accordionEl.$controls.find(".remove-text-mobile").on("click",function(){application.triggerApplicationEvent("/product/designobject/remove/"+_this._designObject.name)})},AccordionTextControl.prototype.wireOutline=function(){var _this=this,ctrl=this._accordionEl.$controls;ctrl.find(".outline_popup").hide();ctrl.find("button.outline_icon").on("mousedown",function(e){$(".mobile-canvas-column-left").find(".outline_popup").length>0&&(ctrl=$(".mobile-canvas-column-left"));e.stopPropagation();$("div.bc.bc-effects, div.move-step, div.nudge, .button-control .bc, div.text-alignment, div.bc.bc-patterns").addClass("hide-tooltip");ctrl.find("div.select-effect").hide();ctrl.find("div.outline_popup").show();application.triggerApplicationEvent("/track/event/Design/TextOutline");var ol=_this._designObject.text.outline,type=application.getModel("FontService").getOutlineId(ol.alpha,ol.width),ss=ctrl.find("a[rel='tr-Outline-{0}']".format(type)).parent();ss.siblings().removeClass("selected");ss.addClass("selected")});ctrl.find("a[rel*='tr-Outline']").on("mousedown",function(e){e.stopPropagation();$(this).parent().siblings().removeClass("selected");$(this).parent().addClass("selected")});ctrl.find(".outline_popup").on("mousedown",function(e){e.stopPropagation()});ctrl.find("a.closeoutline").on("click",function(){ctrl.find("div.outline_popup").hide()});$(document).on("mousedown",function(e){!$("div.select-effect").is(":visible")||$(e.target).prop("tagName").toLowerCase()=="h2"&&$(e.target).parent().hasClass("select-effect-wrapper")||($("div.bc.bc-effects.hide-tooltip, div.move-step.hide-tooltip, div.nudge.hide-tooltip, .button-control .bc.hide-tooltip, div.text-alignment.hide-tooltip, div.bc.bc-patterns.hide-tooltip").removeClass("hide-tooltip"),ctrl.find("div.select-effect").hide());ctrl.find(".font-family--open").hide()})},AccordionTextControl.prototype.deSelect=function(){},AccordionTextControl}(UI.AccordionElControlBase);application.addComponent(AccordionTextControl,"AccordionTextControl")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var AccordionMontage=function(_super){function AccordionMontage(){var _this=_super.call(this)||this;return _this.name="",_this._designObject=null,_this._$template=null,_this._$html=null,_this.$controls=null,_this.controls=null,_this._accordion=null,_this._view=null,_this._designObjectService=null,_this.templateData=null,_this}return __extends(AccordionMontage,_super),AccordionMontage.prototype.init=function(designObject,$template,accordion){var self=this;return self.baseInit(designObject,$template,accordion),self},AccordionMontage.prototype.render=function(){var self=this;self.baseRender();self._$html.find("button.editmontage").on("click",function(){presets.useNewMontage?application.triggerApplicationEvent("/product/edit/add/newmontage"):application.triggerApplicationEvent("/product/edit/add/montage")});self._$html.find("span.pencilmontage").on("click",function(){application.triggerApplicationEvent("/product/edit/add/newmontage");presets.useNewMontage?application.triggerApplicationEvent("/product/edit/add/newmontage"):application.triggerApplicationEvent("/product/edit/add/montage")});return self},AccordionMontage.prototype.deSelect=function(){this.baseDeSelect()},AccordionMontage.prototype.update=function(newIndex){this.baseUpdate(newIndex);this.checkDimensions()},AccordionMontage.prototype.checkDimensions=function(){application.triggerApplicationEvent("/quality/check/designobject/"+name)},AccordionMontage}(UI.accordionElBase);application.addComponent(AccordionMontage,"AccordionMontage")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.
1setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var AccordionCollage=function(_super){function AccordionCollage(){var _this=_super.call(this)||this;return _this.name="",_this._designObject=null,_this._$template=null,_this._$html=null,_this.$controls=null,_this.controls=null,_this._accordion=null,_this._view=null,_this._designObjectService=null,_this.templateData=null,_this}return __extends(AccordionCollage,_super),AccordionCollage.prototype.init=function(designObject,$template,accordion){var self=this;return self.baseInit(designObject,$template,accordion),self},AccordionCollage.prototype.render=function(){var self=this;self.baseRender();self._$html.find("button.editmontage").on("click",function(){application.triggerApplicationEvent("/product/edit/add/newmontage")});self._$html.find("span.pencilmontage").on("click",function(){application.triggerApplicationEvent("/product/edit/add/newmontage")});return self},AccordionCollage.prototype.deSelect=function(){this.baseDeSelect()},AccordionCollage.prototype.update=function(newIndex){this.baseUpdate(newIndex);this.checkDimensions()},AccordionCollage.prototype.checkDimensions=function(){application.triggerApplicationEvent("/quality/check/designobject/"+name)},AccordionCollage}(UI.accordionElBase);application.addComponent(AccordionCollage,"AccordionCollage")})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),function(Preview){var UI;(function(UI){var ImageSizeChangeController=function(_super){function ImageSizeChangeController(){var _this=_super.call(this)||this;return _this.route("/product/edit/editSizeModal/:name",_this.editSizeModal),_this}return __extends(ImageSizeChangeController,_super),ImageSizeChangeController.prototype.init=function(){this.sizeChangeComponent=new ImageSizeChange},ImageSizeChangeController.prototype.editSizeModal=function(event){var _this=this,DOName=event.parameters.name,product=application.getModel("Product"),designObject=product.designObjectService.getByName(DOName),modal=$("#md-edit-size").modal(function(){_this.sizeChangeComponent.shouldUpdateSize?_this.sizeChangeComponent.updateDimension():_this.sizeChangeComponent.retriveOriginalDimension()});this.sizeChangeComponent.initialize(designObject,product.designObjectService,modal);window.pushCreationStudioToGTM("Image: Open update dimensions popup")},ImageSizeChangeController}(Controller),ImageSizeChange;UI.ImageSizeChangeController=ImageSizeChangeController;application.addController(new ImageSizeChangeController);ImageSizeChange=function(){function ImageSizeChange(){}return ImageSizeChange.prototype.initialize=function(designObject,designObjectServive,modal){this.shouldUpdateSize=!1;this.desingObject=designObject;this.desinObjectService=designObjectServive;this.$modalEditSize=modal;this.$width=this.$modalEditSize.find("#js-md-editWidth");this.$height=this.$modalEditSize.find("#js-md-editHeight");this.$btnOk=this.$modalEditSize.find(".ok_btn_pop");this.$btnClose=this.$modalEditSize.find(".cancel_btn_pop");this.$unit=this.$modalEditSize.find(".js-unit");this.qualityService=application.getModel("QualityService");this.product=application.getModel("Product");this.ruler=application.getComponent("Ruler");this.setUnitSpan();this.setWidthHeightControls();this.registerEvents();this.checkTheQuality()},ImageSizeChange.prototype.setUnitSpan=function(){this.$unit.text(this.ruler.getUnitString())},ImageSizeChange.prototype.widthChange=function(){var newHeight=this.getHeightOrWidth(this.$width.val(),!0);(this.setvalue(this.$height,newHeight),this.isInputValid())&&(this.setTheDesignObjectSize(this.$height.val(),this.$width.val(),this.ruler.getUnitString()),this.checkTheQuality(),window.pushCreationStudioToGTM("Image: update dimensions width: "+this.$width.val()))}
1,ImageSizeChange.prototype.heightChange=function(){var newWidth=this.getHeightOrWidth(this.$height.val(),!1);(this.setvalue(this.$width,newWidth),this.isInputValid())&&(this.setTheDesignObjectSize(this.$height.val(),this.$width.val(),this.ruler.getUnitString()),this.checkTheQuality(),window.pushCreationStudioToGTM("Image: update dimensions height: "+this.$height.val()))},ImageSizeChange.prototype.setvalue=function(control,val){val%1<1&&(val=Math.round(val*100)/100);control.val(val)},ImageSizeChange.prototype.setTheDesignObjectSize=function(heightLength,widthLength,unit){var currentfield=this.product.fieldsService.getCurrent(),dpi=this.product.fieldsService.getCurrentDPI(),wpx=Math.round(this.getPixcelSize(widthLength,unit,dpi)),hpx=Math.round(this.getPixcelSize(heightLength,unit,dpi)),percentWidth=wpx/(currentfield.printw*currentfield.editablefield.width),percentHeight=hpx/(currentfield.printh*currentfield.editablefield.height);this.desinObjectService.setSize(this.desingObject,percentWidth,percentHeight);application.triggerApplicationEvent("/product/edit/updateView/CanvasTabs/tabcanvas");application.triggerApplicationEvent("/product/edit/showloader/accordinimg/designobsize");application.triggerApplicationEvent("/product/edit/select/designObject/"+this.desingObject.name);application.triggerApplicationEvent("/accordion/setUserSelectedDOAsActive")},ImageSizeChange.prototype.updateDimension=function(){this.setTheDesignObjectSize(this.$height.val(),this.$width.val(),this.ruler.getUnitString())},ImageSizeChange.prototype.retriveOriginalDimension=function(){this.setTheDesignObjectSize(this.originalSize.height,this.originalSize.width,this.ruler.getUnitString())},ImageSizeChange.prototype.setWidthHeightControls=function(){var imageSize=this.qualityService.GetImageSizeStruct(this.desingObject,this.product.fieldsService.getCurrent(),this.ruler.getUnitString());this.$width.val(imageSize.width);this.$height.val(imageSize.height);this.originalSize={width:imageSize.width,height:imageSize.height}},ImageSizeChange.prototype.getPixcelSize=function(length,unit,dpi){switch(unit){case"inch":return length*dpi;case"cm":return length/2.54*dpi;case"meter":return length*100/2.54*dpi;case"yard":return length*dpi*36}},ImageSizeChange.prototype.convertToCM=function(length,unit){switch(unit){case"inch":return length*2.54;case"cm":return length;case"meter":return length*100;case"yard":return length*2.54*36}},ImageSizeChange.prototype.getHeightOrWidth=function(length,isWidth){var ar=1,originalWidth=this.desingObject.owidth,originalHeight=this.desingObject.oheight,temp;return((Math.abs(this.desingObject.rotationangle)===90||Math.abs(this.desingObject.rotationangle)===270)&&(temp=originalWidth,originalWidth=originalHeight,originalHeight=temp),ar=originalWidth>originalHeight?originalHeight/originalWidth:originalWidth/originalHeight,isWidth&&originalWidth<originalHeight)?length/ar:isWidth&&originalWidth>originalHeight?length*ar:originalWidth>originalHeight?length/ar:length*ar},ImageSizeChange.prototype.registerEvents=function(){var _this=this;this.unbindAllRegisteredEvents();this.restrictWidthAndHeight();this.$width.on("input",function(){_this.widthChange()});this.$height.on("input",function(){_this.heightChange()});this.widthChange();this.heightChange();this.$btnOk.on("click",function(){_this.isInputValid()&&(_this.setTheDesignObjectSize(_this.$height.val(),_this.$width.val(),_this.ruler.getUnitString()),_this.shouldUpdateSize=!0,_this.updateTheView(),_this.close(),window.pushCreationStudioToGTM("Image: save update dimensions"))});this.$btnClose.on("click",function(){_this.setTheDesignObjectSize(_this.originalSize.height,_this.originalSize.width,_this.ruler.getUnitString());_this.close()});this.$modalEditSize.keypress(function(e){e.keyCode===13&&_this.isInputValid()&&(_this.shouldUpdateSize=!0,_this.close())});this.$modalEditSize.find(".md-close").click(function(){_this.setTheDesignObjectSize(_this.originalSize.height,_this.originalSize.width,_this.ruler.getUnitString());_this.close()})},ImageSizeChange.prototype.updateTheView=function(){var field=this.product.fieldsService.getCurrent(),fieldindex=this.product.fieldsService.indexOf(field);this.product.fieldsService.getFieldByIndex(fieldindex).editablefield.version++;this.product.fieldsService.getFieldByIndex(fieldindex).editablefield.isModified=!0},ImageSizeChange.prototype.close=function(){this.unbindAllRegisteredEvents();this.$modalEditSize.closeModal()},ImageSizeChange.prototype.unbindAllRegisteredEvents=function(){this.$width.unbind();this.$height.unbind();this.$btnClose.unbind();this.$btnOk.unbind();this.$modalEditSize.find(".md-close").unbind()},ImageSizeChange.prototype.checkTheQuality=function(){var field=this.product.fieldsService.getCurrent(),fieldindex=this.product.fieldsService.indexOf(field);application.triggerApplicationEvent("/quality/check/designobject/{0}".format(this.desingObject.name));application.triggerApplicationEvent("/quality/display/updatedimension/{0}/{1}".format(fieldindex,this.desingObject.name))},ImageSizeChange.prototype.isQualityAndInputValid=function(){return this.$modalEditSize.find(".qualitymsg--ok").css("display")==="block"&&this.isInputValid()},ImageSizeChange.prototype.isInputValid=function(){var decimal=/^[-+]?[0-9]+\.[0-9]+$/,integer=/^\d+$/;if(!this.$width.val().match(decimal)&&!this.$width.val().match(integer)||!this.$height.val().match(decimal)&&!this.$height.val().match(integer))return this.$btnOk.attr("disabled",!0),!1;if(this.$width.val()>5e3||this.$height.val()>5e3)return!1;var minCM=2,unit=this.ruler.getUnitString(),widthInCm=this.convertToCM(this.$width.val(),unit),heightInCm=this.convertToCM(this.$height.val(),unit);return widthInCm<minCM||heightInCm<minCM?!1:(this.$btnOk.attr("disabled",!1),!0)},ImageSizeChange.prototype.restrictWidthAndHeight=function(){var specialKeys=[];specialKeys.push(8);specialKeys.push(46);specialKeys.push(13);this.$width.bind("keypress",function(e){var keyCode=e.which?e.which:e.keyCode;return keyCode>=48&&keyCode<=57||specialKeys.indexOf(keyCode)!==-1});this.$height.bind("keypress",function(e){var keyCode=e.which?e.which:e.keyCode;return keyCode>=48&&keyCode<=57||specialKeys.indexOf(keyCode)!==-1})},ImageSizeChange}();UI.ImageSizeChange=ImageSizeChange})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={})),function(Preview){var UI;(function(UI){var SellerFieldSettings=function(){function SellerFieldSettings(){this.$container=$("#seller-field-settings")}return SellerFieldSettings.prototype.init=function(){this.product=application.getModel("Product");this.currentField=this.product.fieldsService.getCurrent();this.$image=this.$container.find("input[name='image']");this.$container.find("input[name='image']").prop("checked",_.indexOf(this.currentField.deny,"image")===-1);this.$text=this.$container.find("input[name='text']");this.$container.find("input[name='text']").prop("checked",_.indexOf(this.currentField.deny,"text")===-1);this.$bgColor=this.$container.find("input[name='bgcolor']");this.$container.find("input[name='bgcolor']").prop("checked",_.indexOf(this.currentField.deny,"bgcolor")===-1);application.triggerApplicationEvent("/preview/preselectedbgcolors/render");this.eventRegistration()},SellerFieldSettings.prototype.eventRegistration=function(){var self=this;this.$container.find("input").on("change",function(){var name=$(this).prop("name");self.$container.find("input[name='{0}']".format(name)).is(":checked")?(self.currentField.deny=_.without(self.currentField.deny,name),name==="bgcolor"&&self.$container.find(".bgColors").show()):(self.currentField.deny=_.union(self.currentField.deny,name),name==="bgcolor"&&self.$container.find(".bgColors").hide());application.triggerApplicationEvent("/product/edit/updatePreview")})},SellerFieldSettings}(),SellerFrameLockOptions;application.addComponent(new SellerFieldSettings,"SellerFieldSettings");SellerFrameLockOptions=function(){function SellerFrameLockOptions(designObject,sellerControls,isText){this.designObject=designObject;this.$sellerControls=sellerControls;this.isText=isText;this.initialize()}return SellerFrameLockOptions.prototype.initialize=function(){this.isText?(this.$frameIt=this.$sellerControls.find("input[name='lock']"),this.$lock=this.$sellerControls.find("input[name='readonly']")):(this.$frameIt=this.$sellerControls.find("input[name='frameit']"),this.$lock=this.$sellerControls.find("input[name='lock']"));this.product=application.getModel("Product");var frame=this.product.frameService.getFrame(this.designObject.frameId);this.$frameIt.prop("checked",!!frame);this.isText?this.$lock.prop("checked",frame?frame.readOnly:!1):this.$lock.prop("checked",frame?frame.locked:!1);this.$lable=this.$sellerControls.find("input[name='label']");this.$lable.val($.htmlDecode(this.designObject.label));this.eventRegistration()},SellerFrameLockOptions.prototype.eventRegistration=function(){var _this=this;this.$lable.bindWithDelay("keyup paste cut",{},function(){_this.designObject.label=$.htmlEncode(_this.$lable.val());application.triggerApplicationEvent("/product/edit/updatePreview")},1e3);this.$frameIt.on("change",function(){_this.$frameIt.is(":checked")?(_this.product.frameService.defineFrame(_this.designObject.name),_this.product.fieldsService.incrementCurrentFieldVersion(),_this.correctAngle()):(_this.$lock.prop("checked",!1),_this.product.frameService.deleteFrame(_this.designObject.name));application.triggerApplicationEvent("/product/edit/updateView/accordion/"+_this.designObject.name);application.triggerApplicationEvent("/product/edit/showloader/accordion/"+_this.designObject.name)});this.$lock.on("change",function(){_this.designObject.frameId||_this.$frameIt.is(":checked")||(_this.product.frameService.defineFrame(_this.designObject.name),_this.$frameIt.prop("checked",!0));var currentFrame=_this.product.frameService.getFrame(_this.designObject.frameId);_this.isText?currentFrame.readOnly=_this.$lock.is(":checked"):currentFrame.locked=_this.$lock.is(":checked");_this.$frameIt.prop("disabled",currentFrame.locked);_this.product.designObjectService.transform(_this.designObject.name,"Pattern-Center");application.triggerApplicationEvent("/product/edit/updatePreview")})},SellerFrameLockOptions.prototype.correctAngle=function(){var angle=this.designObject.centerRotation;angle!==0&&angle!==90&&angle!==180&&angle!==270&&this.product.designObjectService.transform(this.designObject.name,"rotate-ccw")},SellerFrameLockOptions}();UI.SellerFrameLockOptions=SellerFrameLockOptions})(UI=Preview.UI||(Preview.UI={}))}(Preview||(Preview={}));var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){return extendStatics=Object.
1setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])},extendStatics(d,b)};return function(d,b){function __(){this.constructor=d}if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}(),__awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})},__generator=this&&this.__generator||function(thisArg,body){function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;(y=0,t)&&(op=[op[0]&2,t.value]);switch(op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}t[2]&&_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),"throw":verb(1),"return":verb(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g},Preview;(function(Preview){var UI;(function(UI){var DropdownWithPopupController=function(_super){function DropdownWithPopupController(){var _this=_super.call(this)||this;return _this.route("/product/DropdownWithPopup/showpopup/:optionId",_this.showpopup),_this.route("/product/DropdownWithPopup/showpopup/:optionId/:optionName",_this.showpopup),_this.route("/product/DropdownWithPopup/showOptionDetails/:optionValueId",_this.showOptionDetails),_this.route("/product/DropdownWithPopup/hideOptionDetails",_this.hideOptionDetails),_this.route("/product/DropdownWithPopup/selectOptionValue/:optionValueId",_this.selectOptionValue),_this}return __extends(DropdownWithPopupController,_super),DropdownWithPopupController.prototype.init=function(){this.dropdownWithPopup=application.getComponent("DropdownWithPopup");this.dropdownWithPopup.init()},DropdownWithPopupController.prototype.showpopup=function(event){var tabid=$("#product-tabs").tabs("option","selected"),optionId,optionName;tabid==1&&$("#product-tabs").find("a[href='#tab-options']").click();optionId=event.parameters.optionId;optionName=event.parameters.optionName;presets&&(presets.productId.toString()==="1473"||presets.productId.toString()==="1469")?this.dropdownWithPopup.showFabricOptionsPopup(optionId,optionName):(optionId&&$("#modalTitle").text(optionName),this.dropdownWithPopup.showpopup(optionId));window.pushCreationStudioToGTM("Click: Help me decide")},DropdownWithPopupController.prototype.showOptionDetails=function(event){var optionValueId=event.parameters.optionValueId;this.dropdownWithPopup.showOptionDetails(optionValueId)},DropdownWithPopupController.prototype.hideOptionDetails=function(){this.dropdownWithPopup.hideOptionDetails()},DropdownWithPopupController.prototype.selectOptionValue=function(event){var optionValueId=event.parameters.optionValueId;this.dropdownWithPopup.selectOptionValue(optionValueId)},DropdownWithPopupController}(Controller),DropdownWithPopup;UI.DropdownWithPopupController=DropdownWithPopupController;application.addController(new DropdownWithPopupController);DropdownWithPopup=function(){function DropdownWithPopup(){this.selectorSelectOption="select[name='OptionsDropdownWithPopup']";this.selectorWallpaperTypeOption="select[name='Options']";this.selectorDetailsDescription="#optionValueDetail-Description";this.selectorDetailsImage=".product-options-fabric-left";this.selectorDetailsHelpMe=".product-options-fabric--block";this.selectorWrapper="#selectfabric__wrapper";this.wallpaperTypeHelpModal="#wallpaper-details-container"}return DropdownWithPopup.prototype.init=function(){var _this=this,self=this,optionSelect,isValid,fabrictype;if(self.shownOptionValue=null,optionSelect=$(self.selectorSelectOption),optionSelect){if(optionSelect.attr("disabled")!=undefined){optionSelect.remove("change");return}if(optionSelect.change(function(){var element=$(this);self.onSelectChanged(element,!0)}),isValid=self.GetIsValidSelect(),self.showOrHideOnSelection(isValid),isValid)self.onSelectChanged(optionSelect,!1);fabrictype=self.getUrlParameter("fabrictype");fabrictype!=null&&setTimeout(function(){_this.selectOptionValue(fabrictype)},200)}},DropdownWithPopup.prototype.getUrlParameter=function(sParam){for(var sPageURL=decodeURIComponent(window.location.search.substring(1)),sURLVariables=sPageURL.split("&"),sParameterName,i=0;i<sURLVariables.length;i++)if(sParameterName=sURLVariables[i].split("="),sParameterName[0]===sParam)return sParameterName[1]===undefined?!0:sParameterName[1]},DropdownWithPopup.prototype.initSearch=function(){var self=this;$(".fabric-popup-search").on("change keyup paste",function(){self.search()})},DropdownWithPopup.prototype.search=function(){var searchVal=$(".fabric-popup-search").val().trim();searchVal?(searchVal=searchVal.toLowerCase(),$(".selectfabric__li").each(function(){var li=$(this),text=li.data("text").toString().toLowerCase(),properties=li.data("properties").toString().toLowerCase();text.indexOf(searchVal)>=0||properties.indexOf(searchVal)>=0?li.show():li.hide()})):$(".selectfabric__li").each(function(){$(this).show()})},DropdownWithPopup.prototype.showOrHideOnSelection=function(isValid){var hideIfNotSelected=$(".hide-if-notselected");hideIfNotSelected&&(isValid?hideIfNotSelected.show():hideIfNotSelected.hide())},DropdownWithPopup.prototype.GetIsValidSelect=function(){var self=this,isValid=!0;return $(self.selectorSelectOption+" option:selected").each(function(index,element){var systemName=String($(element).data("systemname"));self.IsNoOptionSelected(systemName)&&(isValid=!1)}),isValid},DropdownWithPopup.prototype.IsNoOptionSelected=function(systemName){return systemName==="NoOptionSelected"},DropdownWithPopup.prototype.onSelectChanged=function(element,isDropDownChangeEvent){var self=this,newValue=element.val();newValue&&self.loadOptionValueDetails(newValue,isDropDownChangeEvent)},DropdownWithPopup.prototype.loadOptionValueDetails=function(optionValueId){var self=this,dataDetail
1s;optionValueId&&(dataDetails={optionValueId:optionValueId},$.ajax({url:"/estore/PreviewHelp/OptionValueDetails",type:"GET",data:dataDetails,success:function(result){var data=result,selectItem_1,image,zoomedImage,isValid;data&&($(self.selectorDetailsDescription).html(data.Description),selectItem_1=$(self.selectorSelectOption),image=$("#img-fabric-left"),image&&data.ImageUrl?image.each(function(index,element){element.src=data.ImageUrl;element.alt=data.SystemName;selectItem_1&&selectItem_1.data("chosen")&&($(self.selectorDetailsImage).show(),$(self.selectorDetailsDescription).show(),$(self.selectorDetailsHelpMe).show(),$(".product-options-fabric-wrapper").removeClass("no-fabric-img"))}):selectItem_1&&selectItem_1.data("chosen")&&($(self.selectorDetailsImage).hide(),$(self.selectorDetailsDescription).html("").hide(),$(self.selectorDetailsHelpMe).hide(),$(".product-options-fabric-wrapper").addClass("no-fabric-img")),zoomedImage=$(".zoomed-image"),zoomedImage.length>0&&data.ImageUrl&&zoomedImage.each(function(index,element){element.src=data.ImageUrl;element.alt=data.SystemName}),isValid=!self.IsNoOptionSelected(data.SystemName),self.showOrHideOnSelection(isValid))},error:function(){$(self.selectorDetailsDescription).html("");self.showOrHideOnSelection(!1)}}))},DropdownWithPopup.prototype.hideIconsForFabricType=function(optionValue,isDropDownChangeEvent){var selecteditem=$(".optionvalue-icon span.selected").attr("data-optvalue"),opVal,isFirstItemNeedToClick;optionValue!=null?($(".optionvalue-icon:has(span)").hide(),opVal=optionValue.split("|"),$(".optionvalue-icon span").each(function(index,item){opVal.indexOf($(item).data("optvalue").toString())>-1?$(item).parent().hide():$(item).parent().show()}),selecteditem&&opVal.indexOf(selecteditem)>-1&&(selecteditem=undefined)):$(".optionvalue-icon:has(span)").show();isDropDownChangeEvent&&(isFirstItemNeedToClick=!0,selecteditem&&$(".optionvalue-icon span:visible").each(function(index,item){$(item).data("optvalue")==selecteditem&&($(item).click(),isFirstItemNeedToClick=!1)}),isFirstItemNeedToClick&&$(".optionvalue-icon:has(span:visible)").first().click())},DropdownWithPopup.prototype.showpopup=function(optionId){var self=this,selectedOptionValueId,data;optionId&&(self.ModelWrapper=$("#md-preview-option-dropdownwithpopup"),self.ModelWrapper.modal(function(){}),selectedOptionValueId=$(".product-option-help").find("select.preview-product-option").val(),selectedOptionValueId||(selectedOptionValueId=$("select.preview-product-option").val()),self.shownOptionValue!=selectedOptionValueId&&(data={optionId:optionId,selectedOptionValueId:selectedOptionValueId},$.ajax({url:"/estore/PreviewHelp/OptionValuesListPopup",type:"GET",data:data,success:function(result){$(self.selectorWrapper).html(result);self.shownOptionValue=selectedOptionValueId;self.initSearch()},error:function(){$(self.selectorWrapper).html("")}})))},DropdownWithPopup.prototype.showOptionDetails=function(optionValueId){var self=this,dataDetails;optionValueId&&(dataDetails={optionValueId:optionValueId},$.ajax({url:"/estore/PreviewHelp/OptionValueDetailsPopup",type:"GET",data:dataDetails,success:function(result){$(".selectfabric__li").removeClass("active-selection");$(".selectfabric__li."+optionValueId).addClass("active-selection");$("#selectfabric__content").html(result);self.displayOptionDetails();self.shownOptionValue=optionValueId},error:function(){$("#selectfabric__content").html("")}}));$(".selectfabric__li").removeClass("selectfabric__p")},DropdownWithPopup.prototype.displayOptionDetails=function(){var self=this;self.IsOptionDetailsVisible=!0;self.IsMobile&&($(".selectfabric__menu").addClass("hiddenunder700"),$(".selectfabric__menu").removeClass("visibleunder700"),$(".selectfabric__content").addClass("visibleunder700"),$(".selectfabric__content").removeClass("hiddenunder700"))},DropdownWithPopup.prototype.hideOptionDetails=function(){var self=this;self.IsOptionDetailsVisible=!1;self.IsMobile&&($(".selectfabric__menu").removeClass("hiddenunder700"),$(".selectfabric__menu").addClass("visibleunder700"),$(".selectfabric__content").removeClass("visibleunder700"),$(".selectfabric__content").addClass("hiddenunder700"))},DropdownWithPopup.prototype.jumpToDesktopView=function(){var self=this;self.IsMobile=!1;$(".selectfabric__menu").removeClass("visibleunder700");$(".selectfabric__menu").removeClass("hiddenunder700");$(".selectfabric__content").removeClass("visibleunder700");$(".selectfabric__content").removeClass("hiddenunder700")},DropdownWithPopup.prototype.jumpToMobileView=function(){var self=this;self.IsMobile=!0;
1self.IsOptionDetailsVisible?self.displayOptionDetails():self.hideOptionDetails()},DropdownWithPopup.prototype.selectOptionValue=function(optionValueId){var self=this,selectItem;optionValueId&&(selectItem=$(self.selectorSelectOption),selectItem&&(selectItem.val(optionValueId),selectItem.data("chosen")&&selectItem.trigger("chosen:updated"),selectItem.change&&selectItem.change(),self.ModelWrapper&&self.ModelWrapper.closeModal(),setTimeout(function(){application.triggerApplicationEvent("/product/edit/hidepreviewloader/dropdownpopup")},3e3)))},DropdownWithPopup.prototype.initFabricOptions=function(optionId,optionName){return __awaiter(this,void 0,void 0,function(){var popupElement,_this=this;return __generator(this,function(){return $("head").append('<script type="text/javascript" src="/Scripts/FabricOptions/polyfills.js"><\/script>'),$("head").append('<script type="text/javascript" src="/Scripts/FabricOptions/main.js"><\/script>'),$("head").append('<link rel="stylesheet" href="/Scripts/FabricOptions/styles.css" type="text/css" />'),popupElement=document.createElement("contrado-fabric-options"),popupElement.setAttribute("option-id",optionId),popupElement.setAttribute("option-name",optionName),popupElement.addEventListener("selection",function(event){_this.selectFabricOptionValue(event.detail)}),$("#fabric-option-container").append(popupElement),this.popupRef=popupElement,[2]})})},DropdownWithPopup.prototype.showFabricOptionsPopup=function(optionId,optionName){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(_a){switch(_a.label){case 0:return optionId?($("body").addClass("fabric-popup--open"),!this.popupRef)?[3,1]:($("#fabric-option-container").show(),[3,3]):[2];case 1:return[4,this.initFabricOptions(optionId.toString(),optionName)];case 2:_a.sent();$("#fabric-option-container").show();_a.label=3;case 3:return[2]}})})},DropdownWithPopup.prototype.hideFabricOptionsPopup=function(){$("#fabric-option-container").hide();$("body").removeClass("fabric-popup--open")},DropdownWithPopup.prototype.selectFabricOptionValue=function(optionValueId){if(optionValueId){var selectItem=$(this.selectorSelectOption);selectItem&&(selectItem.val(optionValueId),selectItem.data("chosen")&&selectItem.trigger("chosen:updated"),selectItem.change&&selectItem.change())}this.hideFabricOptionsPopup()},DropdownWithPopup}();UI.DropdownWithPopup=DropdownWithPopup;application.addComponent(new DropdownWithPopup,"DropdownWithPopup")})(UI=Preview.UI||(Preview.UI={}))})(Preview||(Preview={}))
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.