{"version":3,"sources":["wallpaperinstore.js"],"names":["imageAspectRatio","imageWidth","imageHeight","imageId","imageDpi","selectedProduct","cartDescription","cropper","imageEl","document","querySelector","thumbsMediaEl","cartNotes","getElementById","productIDEl","addEventListener","event","value","JSON","stringify","detail","getImageData","wW","wallWidth","wH","wallHeight","tEntityIDEl","mediaUrlEl","mediaIDEl","productTitleEl","orderQuantityEl","cartPriceEl","xWallEl","yWallEl","setWallWidth","materialEl","setWallHeight","sellingPriceEl","setMaterial","regularPriceEl","cardButtonEl","cartDescriptionEl","quantityEl","JObjectEl","JObject","parse","jsEntityEl","jsEntity","regPrice","price","i","Products","length","IsFeatured","sId","sObject","quantity","material","printArea","userAspectRatio","undefined","recalculate","parseInt","selectedProductByAttribute","dataset","attributeid","setQuantity","updateWallpaperView","getImage","getParameterByName","setAspectRatio","contData","getContainerData","setCropBoxData","height","width","SellingPrice","Math","round","Number","EPSILON","toFixed","IsInSale","RegularPrice","innerHTML","concat","regularprice","sellingprice","options","selectedIndex","text","cartdescription","isNaN","disabled","setAllValues","calculatedSellingPrice","updateJsonLD","callback","url","window","location","origin","$","ajax","cache","type","content","dataType","data","success","d","mediaLibraryMedia","attr","Url","AltText","Title","ID","title","AspectRatio","OriginalWidth","OriginalHeight","OriginalDpi","Cropper","aspectRatio","movable","zoomable","zoomOnTouch","zoomOnWheel","cropBoxResizable","toggleDragModeOnDblclick","minCropBoxWidth","minCropBoxHeight","autoCropArea","toastr","error","message","at","v","callBack","jo","j","EntityAttributeID","EntityAttributeValueID","ProductID","tEntityID","protocol","host"],"mappings":"AAAA,aAgDA,IA9CA,IAIIA,iBAAkBC,WAAYC,YAAaC,QAASC,SAsCpDC,gBACAC,gBA3CAC,QAAU,KACRC,QAAUC,SAASC,cAAc,SAAS,EAC1CC,cAAgBF,SAASC,cAAc,cAAc,EAGrDE,UAAYH,SAASI,eAAe,WAAW,EAK/CC,aAJNN,QAAQO,iBAAiB,OAAQ,SAACC,GAC9BJ,UAAUK,MAAQC,KA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AgBb,MAAQuC,SACxBzB,YAAYd,MAAQgC,KACxB,CA3JAkB,oBAAmB","file":"wallpaperinstore.es5.min.js","sourcesContent":["\"use strict\";\r\n\r\nlet cropper = null\r\nconst imageEl = document.querySelector(\".sImage\")\r\nconst thumbsMediaEl = document.querySelector(\".thumbsMedia\") // wrapper(s) for display images\r\n\r\nlet imageAspectRatio, imageWidth, imageHeight, imageId, imageDpi\r\nconst cartNotes = document.getElementById(\"cartNotes\")\r\nimageEl.addEventListener(\"crop\", (event) => {\r\n cartNotes.value = JSON.stringify(event.detail) + JSON.stringify(cropper.getImageData()) + JSON.stringify({wW: wallWidth, wH: wallHeight})\r\n});\r\n\r\nconst productIDEl = document.querySelector(\"#productID\")\r\nconst tEntityIDEl = document.querySelector(\"#tEntityID\")\r\nconst mediaUrlEl = document.querySelector(\"#mediaUrl\")\r\nconst mediaIDEl = document.querySelector(\"#mediaID\")\r\nconst productTitleEl = document.querySelector(\"#productTitle\")\r\nconst orderQuantityEl = document.querySelector(\"#orderQuantity\")\r\nconst cartPriceEl = document.querySelector(\"#cartPrice\")\r\n\r\nconst xWallEl = document.querySelector(\"#xWall\")\r\nxWallEl.addEventListener(\"change\", setWallWidth)\r\n\r\nconst yWallEl = document.querySelector(\"#yWall\")\r\nyWallEl.addEventListener(\"change\", setWallHeight)\r\n\r\nconst materialEl = document.querySelector(\"#printingMaterial\")\r\nmaterialEl.addEventListener(\"change\", setMaterial)\r\n\r\nconst sellingPriceEl = document.querySelector(\".sellingPrice\")\r\nconst regularPriceEl = document.querySelector(\".regularPrice\")\r\n\r\nconst cardButtonEl = document.querySelector(\".cardButton\")\r\nconst cartDescriptionEl = document.querySelector(\".cartDescription\")\r\nconst quantityEl = document.querySelector(\".qty-text\")\r\n\r\nconst JObjectEl = document.querySelector(\"#product_JObject\")\r\nconst JObject = JSON.parse(JObjectEl.value)\r\n\r\nconst jsEntityEl = document.querySelector(\"#jsEntity\")\r\nconst jsEntity = JSON.parse(jsEntityEl.value)\r\n\r\nlet regPrice = 0\r\nlet price = 0\r\nlet selectedProduct\r\nlet cartDescription\r\n\r\n// find and set as default selected product the IsFeatured\r\nfor (var i = 0; i < jsEntity.Products.length; i++) {\r\n if (jsEntity.Products[i].IsFeatured) {\r\n selectedProduct = jsEntity.Products[i]\r\n //console.log(selectedProduct)\r\n //console.log(JObject)\r\n }\r\n}\r\n\r\nlet wallWidth = xWallEl.value,\r\n wallHeight = yWallEl.value,\r\n quantity = quantityEl.value,\r\n material = materialEl.value\r\nlet sId, sObject\r\n\r\n// minimum values in cm\r\nif (wallWidth == undefined)\r\n wallWidth = 100\r\nif (wallHeight == undefined)\r\n wallHeight = 100\r\nlet printArea = 1 // minimum value\r\nlet userAspectRatio = wallWidth / wallHeight\r\n\r\nupdateWallpaperView()\r\n\r\n\r\nfunction setWallWidth() {\r\n wallWidth = xWallEl.value\r\n recalculate()\r\n}\r\n\r\nfunction setWallHeight() {\r\n wallHeight = yWallEl.value\r\n recalculate()\r\n}\r\n\r\nfunction setMaterial() {\r\n material = parseInt(materialEl.value)\r\n let attributeID = parseInt(materialEl.dataset.attributeid)\r\n //console.log(\"attributeID \" + attributeID)\r\n selectedProductByAttribute(attributeID, material, recalculate)\r\n //recalculate()\r\n}\r\n//quantity.addEventListener(\"change\", setQuantity) does not work. Instead onchange added to the element\r\nfunction setQuantity() {\r\n quantity = quantityEl.value\r\n recalculate()\r\n}\r\n\r\nfunction updateWallpaperView() {\r\n // get shutterstock id from query string and get the image via ajax\r\n sId = getParameterByName(\"sId\")\r\n getImage(sId, recalculate)\r\n}\r\n\r\n// Recalculate price on user inputs\r\nfunction recalculate() {\r\n userAspectRatio = wallWidth / wallHeight\r\n if (userAspectRatio > 0) {\r\n if (cropper) {\r\n \r\n cropper.setAspectRatio(userAspectRatio)\r\n var contData = cropper.getContainerData(); //Get container data\r\n cropper.setCropBoxData({ height: contData.height, width: contData.width }) //set data\r\n }\r\n }\r\n //console.log(\"userAspectRatio: \" + userAspectRatio)\r\n printArea = (wallWidth / 100) * (wallHeight / 100)\r\n if (printArea < 1)\r\n printArea = 1 // minimum\r\n\r\n price = selectedProduct.SellingPrice * printArea * quantity\r\n price = (Math.round((price + Number.EPSILON) * 100) / 100).toFixed(2)\r\n //console.log(price)\r\n\r\n if (selectedProduct.IsInSale) {\r\n regPrice = selectedProduct.RegularPrice * printArea * quantity\r\n regPrice = (Math.round((regPrice + Number.EPSILON) * 100) / 100).toFixed(2)\r\n regularPriceEl.innerHTML = `${regPrice} \\u20AC`\r\n sellingPriceEl.dataset.regularprice = (regPrice / quantity).toFixed(2)\r\n }\r\n else {\r\n regularPriceEl.innerHTML = ``\r\n sellingPriceEl.dataset.regularprice = 0\r\n }\r\n\r\n sellingPriceEl.innerHTML = price + '\\u20AC'\r\n sellingPriceEl.dataset.price = price\r\n sellingPriceEl.dataset.sellingprice = (price / quantity).toFixed(2)\r\n\r\n cartDescription = materialEl.options[materialEl.selectedIndex].text + \" (\" + wallWidth + \" x \" + wallHeight +\") \" + printArea.toFixed(2) + \"m2 X \" + selectedProduct.SellingPrice + \"\\u20AC/m2 \" \r\n cartDescriptionEl.innerHTML = cartDescription\r\n cartDescriptionEl.dataset.cartdescription = cartDescription\r\n if (price == 0 || price == undefined || isNaN(price)) \r\n cardButtonEl.disabled = true\r\n else\r\n cardButtonEl.disabled = false\r\n setAllValues()\r\n let calculatedSellingPrice = (price / quantity).toFixed(2)\r\n updateJsonLD(selectedProduct, jsEntity, calculatedSellingPrice)\r\n}\r\n\r\n// get shutterstock image and assign it to img element\r\nfunction getImage(sId, callback) {\r\n var url = window.location.origin + \"/ImageBank/GetImageBankItem\"\r\n $.ajax({\r\n cache: false,\r\n type: \"GET\",\r\n url: url,\r\n content: \"application/json; charset=utf-8\",\r\n dataType: \"json\",\r\n data: {\r\n sId: sId\r\n },\r\n success: function (d) {\r\n if (d.success) {\r\n sObject = JSON.parse(d.data);\r\n window.mediaLibraryMedia = sObject; // for updateJsonLD helper function\r\n $(\".sImage\").attr(\"src\", sObject.Url);\r\n $(\".sImage\").attr(\"alt\", sObject.AltText);\r\n thumbsMediaEl.innerHTML = `