var windowWidth=$(window).width(),windowHeight=$(window).height();function displayOverlay(){$(".dialog").each(function(){if($(this).css("z-index")>0&&"none"!=$(this).css("display"))return $(this).parents(".dialog").show(),$(".overlay").show(),!1})}function loadDTs(){$.ajax({url:"/custom-tools/des-dt-server.aspx?IDD="+designID+"&IDDT="+designTemplateID,cache:!1,success:function(o){$("#printSide").html(o)}})}function popout(o){mmClose(!1,this),$(o).fadeIn()}function openOptionDialog(o){mmClose(!1,o),$(".overlay").fadeIn("fast"),$(o).addClass("displayBlock").removeClass("displayNone")}function openToolsDialog(o){mmClose(!1,o),$(o).addClass("designerPage__leftColumn--show"),$(".overlay").fadeIn("fast")}function loadColours(){$.ajax({url:"/custom-tools/des-colour-server.aspx?PID="+productID+"&PMID="+productionMethodID,cache:!1,success:function(o){""!==o&&($("#colours").html(o),$("#colours a").length>0&&0==productSizeID&&(document.getElementById("OOSColourID"+productColourID)?(productColourID=document.getElementsByName("availableColourID")[0].value,loadSizes()):document.getElementById("availableColourID"+productColourID)||disableBuyBtn("Lo lamentamos, el color que has seleccionado no está disponible para este producto")))}})}function loadPMs(){$.ajax({url:"/custom-tools/des-productionmethod-server-2.aspx?PID="+productID+"&PMID="+productionMethodID,cache:!1,success:function(o){$(".designerTools__printMethod").html(o)}})}function changePM(o){$(".zoomIn").off(),productionMethodID!=o&&(dirtyPreview(!0),makeDirty,productionMethodID=o,$("#currentPrintType").html($("#printType"+productionMethodID).html()),$(".PMIcon").attr("src","/t-shirt-studio-artwork/designer/tools/print-option-"+o+".png"),previewLoading(),$.ajax({url:"/designertools/updateproductionmethod.aspx?IDP="+productID+"&IDD="+designID+"&IDPM="+o,cache:!1,success:function(o){var e=o.split("-");templateThemeID=e[0],designTemplateID=e[1],loadDTs(),loadDesignTools(!0),loadColours()}}))}function loadDesignTools(o){$.ajax({url:"/custom-tools/des-tool-server.aspx?DID="+designID+"&DTID="+designTemplateID+"&PID="+productID+"&PMID="+productionMethodID,cache:!1,success:function(e){$("#customTools").html(e),layoutID=$("#currentLayoutID").text(),showLayouts(),loadLayouts(layoutCatID),syncUpload(),$('[name="cleanText"]').val(""),addPlaceHolders(),o||preview()}})}function changeTT(vIDTT){0==arguments.length&&(vIDTT=$("#mugPrintPositionSelect").val()),$(".zoomIn").off(),templateThemeID!=vIDTT&&$.ajax({url:"/designertools/updateTemplateTheme.aspx?IDD="+designID+"&IDTTO="+templateThemeID+"&IDTTN="+vIDTT+"&IDP="+productID+"&IDPM="+productionMethodID,cache:!1,success:function(res){eval("dirtyDT.DT"+res+" = "+Math.random()),designTemplateID=res,mainViewIndex=0,loadViews(),templateThemeID=vIDTT,loadDTs(),loadMobileDTs(),loadDesignTools(),makeDirtyIfEdit()}})}function loadLayouts(o){layoutCatID=o,$.ajax({url:"/custom-tools/des-layout-server2.aspx?PMID="+productionMethodID+"&DTID="+designTemplateID+"&PID="+productID+"&CID="+o,cache:!1,success:function(o){$("#myLayouts").html(o)}})}function showLayouts(){$.ajax({url:"/custom-tools/des-layout-category-server.aspx?PMID="+productionMethodID+"&DTID="+designTemplateID+"&PID="+productID+"&CID="+layoutCatID,cache:!1,success:function(o){$("#layoutCategory").html(o)}})}function loadAssets(o,e){$.ajax({url:"/custom-tools/des-session-asset-server2.aspx?LID="+e+"&EID="+o+"&DTID="+designTemplateID+"&DID="+designID,cache:!1,success:function(e){$("#sessionAssets"+o).html(e),Modernizr.filereader||($("#fileupload"+o).attr("onclick","return false;"),$("#uploadBox").hide(),$("#sessionAssets"+o).append(""+"Disculpa, este artículo está solo disponible en Internet Explorer versión 10 y superior, Firefox, Chrome y Safari"+""))}})}function imageAdd(o,e,t){openOptionDialog("#sessionAssetContainer"+o)}function resizeImg(o,e){var t;void 0===e&&(e=!1),(objQ=$(o)).removeClass("landscape portrait"),t=o.height/o.width$varInsertaraqui$edit"),loadImageCrop(o,e)),preview()}$(window).resize(function(){$(".overlay").hide(),$(window).width()>600?($("#customTools").show(),$("#colours").show(),$(".dialog").each(function(){if($(this).css("z-index")>0&&"none"!=$(this).css("display")&&("customTools"!=$(this).attr("id")||"colours"!=$(this).attr("id")))return $(".overlay").show(),!1})):displayOverlay()});var uploads=[],preventClose=!1;function doUpload(o,e){$.each($("#fileupload"+o)[0].files,function(t,s){var a=guid();uploads.push({uid:a,filename:s.name}),addSA(a,s.name);var n=new FormData;n.append("fileToUpload",s);var r=new XMLHttpRequest;r.upload.addEventListener("progress",function(o){ulProgress(o,a)},!1),r.addEventListener("load",function(t){ulComplete(t,a,e,o)},!1),r.addEventListener("error",function(o){ulFailed(o,a)},!1),r.addEventListener("abort",function(o){ulCanceled(o,a)},!1),r.open("POST","/imageupload/Uploadhandler.ashx"),r.send(n)}),$("#fileupload"+o).wrap("
").closest("form").get(0).reset(),$("#fileupload"+o).unwrap()}function ulProgress(o,e){if(o.lengthComputable){var t=Math.round(100*o.loaded/o.total);$(".progress"+e).css("width",t+"%")}}function ulComplete(o,e,t,s){ulPop(e);var a=JSON.parse(o.target.responseText).files[0],n=a.Result;$(".uid"+e).remove(),-1==n.toLowerCase().indexOf("Error")?($(".sessionAssets>div:first-child").each(function(){$(this).after($('
'+a.Name+'
'))}),openImage(a.Result,s,t)):alert(n)}function ulFailed(o,e){ulPop(e),alert("Ha habido un error al intentar cargar el archivo.")}function ulCanceled(o,e){ulPop(e),alert("La carga ha sido cancelada por el usuario o se ha desconectado el navegador.")}function ulPop(o){uploads=$.grep(uploads,function(e,t){return e.uid!=o})}function addSA(o,e){$(".sessionAssets>div:first-child").after($('
'+e+'
'))}function imageDel(o,e){$.ajax({url:"/designertools/DeleteUpload.aspx?IDD="+designID+"&IDDT="+e+"&IDLE="+o,cache:!1,success:function(){$("#addImage"+o).attr("src","https://images.tshirtstudio.com/designer/tools/image-add3.png"),$("#imgToolBtnCtr"+o).html('upload'),makeDirty(),preview()}}),mmClose()}function defaultCropSection(o,e,t){var s=o[0].width/2-o.parent().width()/2,a=o[0].height/2-o.parent().height()/2,n=s+o.parent().width(),r=a+o.parent().height(),i={setSelect:[s,a,n,r]};o.Jcrop(i,function(){window["jcropAPI"+e]=this})}function setupJCrop(o,e,t){$.ajax({url:"/custom-tools/des-crop-server.aspx?DTID="+t+"&EID="+e+"&DID="+designID+"&LID="+layoutID,cache:!1,success:function(t){var s=jQuery.parseJSON(t);s.setSelect&&(s.setSelect[0]*=o[0].width,s.setSelect[1]*=o[0].height,s.setSelect[2]*=o[0].width,s.setSelect[3]*=o[0].height),o.Jcrop(s,function(){window["jcropAPI"+e]=this})}})}function loadImageCrop(o,e){$("#CropTarget"+o).one("load",function(){var t=$("#CropTarget"+o);$("#ImgCon"+o).removeAttr("style"),t.parent().width(),t[0].width,t.parent().height(),t[0].height,setupJCrop(t,o,e)}),$("#setCropBtn"+o).off("click").on("click",function(){updateCrop(o,e)}),$("#resetCropBtn"+o).off("click").on("click",function(){resetCrop(o,e)}),window["jcropAPI"+o]&&window["jcropAPI"+o].destroy(),0!=slickUploadFileID?"new.tshirtstudio"==window.location.hostname.substring(0,window.location.hostname.lastIndexOf("."))?$("#CropTarget"+o).attr("src","https://testsessionassets.blob.core.windows.net/"+sessionID+"/"+slickUploadFileID+"-"+sessionID+"x200.png"+cloudToken+"&R="+Math.random()):$("#CropTarget"+o).attr("src","https://sessionassets.blob.core.windows.net/"+sessionID+"/"+slickUploadFileID+"-"+sessionID+"x200.png"+cloudToken+"&R="+Math.random()):$("#CropTarget"+o).attr("src","/showUploadThumb.aspx?ID_D="+designID+"&ID_E="+o+"&ID_DT="+e+"&mH=200&mW=300&inS=1&R="+Math.random())}function imageCrop(o,e,t){openOptionDialog("#cropContainer"+e)}function resetCrop(o,e){mmClose(),$.ajax({url:"/designertools/CropImage.aspx?IDD="+designID+"&IDDT="+e+"&IDLE="+o+"&xx=1",cache:!1,success:function(){window["jcropAPI"+o]&&window["jcropAPI"+o].destroy(),setupJCrop($("#CropTarget"+o),o,e),dirtyPreview(),makeDirtyIfEdit(),preview()}})}function updateCrop(o,e){if(area=window["jcropAPI"+o].tellSelect()){var t=$("#CropTarget"+o);(area.x2-area.x)*(area.y2-area.y)==0&&(area.x=0,area.x2=t.width(),area.y=0,area.y2=t.height()),$.ajax({url:"/designertools/CropImage.aspx?IDD="+designID+"&IDDT="+e+"&IDLE="+o+"&X="+area.x/t.width()+"&Y="+area.y/t.height()+"&X2="+area.x2/t.width()+"&Y2="+area.y2/t.height(),cache:!1,success:function(){dirtyPreview(),makeDirtyIfEdit(),preview()}}),mmClose()}}function addPlaceHolders(){$("[placeholder]").focus(function(){var o=$(this);o.val()==o.attr("placeholder")&&(o.val(""),o.removeClass("placeholder"))}).blur(function(){var o=$(this);(""==o.val()||o.val()==o.attr("placeholder"))&&(o.addClass("placeholder"),o.val(o.attr("placeholder")))}).blur().parents("form").submit(function(){$(this).find("[placeholder]").each(function(){var o=$(this);o.val()==o.attr("placeholder")&&o.val("")})})}function displayTabContent(o,e,t){$("#textToolsContainer"+o+" .modalContent__tabContent, #assetToolsContainer"+o+" .modalContent__tabContent, #sessionAssetContainer"+o+" .modalContent__tabContent").removeClass("modalContent__tabContent--show"),$("#textToolsContainer"+o+" .modalContent__tab, #assetToolsContainer"+o+" .modalContent__tab, #sessionAssetContainer"+o+" .modalContent__tab").removeClass("modalContent__tabOn"),$(t).addClass("modalContent__tabOn"),$(e).addClass("modalContent__tabContent--show")}function showTextDialog(o,e,t){$("#textToolsContainer"+o+" .dialogBody, #assetToolsContainer"+o+" .dialogBody, #sessionAssetContainer"+o+" .dialogBody").hide(),$("#textToolsContainer"+o+" .modalContent__tab, #assetToolsContainer"+o+" .modalContent__tab, #sessionAssetContainer"+o+" .modalContent__tab").removeClass("modalContent__tabOn"),$(t).addClass("modalContent__tabOn"),$(e).show()}function loadFonts(o,e,t,s){$.ajax({url:"/custom-tools/des-font-server2.aspx?PID="+productID+"&PMID="+productionMethodID+"&LID="+t+"&LEID="+o+"&DLID="+e+"&FID="+s,cache:!1,success:function(e){$("#fontContainer"+o).html(e)}})}function changeFont(o,e,t){$(".zoomIn").off(),$("#fontContainer"+e+" .fontSelected").removeClass("fontSelected"),$("#fontContainer"+e+" .font"+o).parent().addClass("fontSelected"),$.ajax({url:"/designertools/updatefont.aspx?IDDL="+t+"&IDLE="+e+"&IDF="+o,cache:!1,success:function(){dirtyPreview(),makeDirtyIfEdit(),preview()}}),mmClose()}function loadFontColours(o,e,t,s){$.ajax({url:"/custom-tools/des-font-colour-server2.aspx?PID="+productID+"&PMID="+productionMethodID+"&LID="+s+"&LEID="+o+"&DLID="+e+"&CC="+t+"&PCID="+productColourID,cache:!1,success:function(e){$("#fontColourContainer"+o).html(e)}})}function changeFontColour(o,e,t){$(".zoomIn").off(),$.ajax({url:"/designertools/updatefontcolour.aspx?IDDL="+t+"&IDLE="+e+"&FC="+o,cache:!1,success:function(){dirtyPreview(),makeDirtyIfEdit(),preview()}}),mmClose()}function loadOutlineColours(o,e,t,s){$.ajax({url:"/custom-tools/des-font-stroke-colour-server2.aspx?PMID="+productionMethodID+"&LID="+s+"&LEID="+o+"&DLID="+e+"&CC="+t+"&PCID="+productColourID,cache:!1,success:function(e){$("#fontOutlineContainer"+o).html(e)}})}function changeOutlineColour(o,e,t){$(".zoomIn").off(),$.ajax({url:"/designertools/updatefontstrokecolour.aspx?IDDL="+t+"&IDLE="+e+"&SC="+o,cache:!1,success:function(){dirtyPreview(),makeDirtyIfEdit(),preview()}}),mmClose()}function loadImageAssets(o,e,t,s){$.ajax({url:"/custom-tools/des-image-asset-server2.aspx?LID="+s+"&EID="+o+"&DTID="+designTemplateID+"&DID="+designID+"&DLID="+e+"&AGID="+t,cache:!1,success:function(e){$("#assetContainer"+o).html(e)}})}function loadImageColours(o,e,t,s){$.ajax({url:"/custom-tools/des-item-colour-server2.aspx?PID="+productID+"&PMID="+productionMethodID+"&LID="+s+"&LEID="+o+"&DLID="+e+"&CC="+t,cache:!1,success:function(e){$("#assetColourContainer"+o).html(e)}})}function popSpinner(o,e){return $(o).append($('
')),loadingAnim("popSpinner",e)}function loadPreview(){$("#preview-Img").attr("src","/designertools/PreviewYouDesign.aspx?IDD="+designID+"&R="+eval("dirtyDT.DT"+designTemplateID)+"&IDDT="+designTemplateID+"&IDC="+productColourID+"&LeftRight="+LeftRight+"&Center="+verticalCenter+"&Zoom=2"),$("#preview-Img").attr("Style","margin-top:-"+mainViewIndex+"%;")}