{"version":3,"sources":["productDetail.js"],"names":["$","returnUrl","document","getElementById","dataset","nameId","availabilityDateInput","tempAvailabilityDate","availabilityDate","handler","value","window","location","on","e","which","preventDefault","registerPikaday","tooltip","trigger","target","originalTitle","ajax","method","url","itemNumber","siteId","success","response","pricing","map","item","price","Intl","NumberFormat","style","currency","format","customerPrice","quantityPriceBreak","join","attr","find","each","i","this","text","hide","prop","keyup","$row","closest","$submitButton","val","$plantRow","quantity","minQuantity","modifiedMinQty","parseInt","quantityBundle","futureAvDate","finalDate","alert","pairs","search","slice","split","result","forEach","pair","decodeURIComponent","promoCode","headers","Accept","Content-Type","type","data","JSON","stringify","wantDate","promotionalcode","complete","mousemove","click","print","event","currentTarget","modal","reload"],"mappings":"AAAAA,EAAE,WACE,IAAIC,EAAYC,SAASC,eAAe,kBAAkBC,QAAQH,UAC9DI,EAASH,SAASC,eAAe,kBAAkBC,QAAQC,OAG3DC,EAAwBJ,SAASC,eAAe,qBAChDI,EAAuBD,EAAsBF,QAAQI,iBAuBzD,SAASC,IACL,IAAID,EAAmBN,SAASC,eAAe,qBAAqBO,MACpEC,OAAOC,SAAW,mBAAqBP,EAAS,qBAAuBG,EAAmB,cAAgBP,EAxB9GK,EAAsBI,MAAQH,EAE9BP,EAAE,uBAAuBa,GAAG,QAAS,WACjCJ,MAGJT,EAAE,iBAAiBa,GAAG,UAAW,SAAUC,GACvB,KAAZA,EAAEC,QACFD,EAAEE,iBACFP,OAkBMQ,gBAAgBR,GAG9BT,EAAE,2BAA2BkB,UAE7B,IAAIV,EAAmBN,SAASC,eAAe,qBAAqBO,MAEpEV,EAAE,8BAA8BkB,QAAQ,CACpCC,QAAS,WAGbnB,EAAE,2BAA2Ba,GAAG,aAAc,SAAsBC,GACzB,KAAnCA,EAAEM,OAAOhB,QAAQiB,eACjBrB,EAAEsB,KAAK,CACHC,OAAQ,MACRC,IAAK,6BAA+BhB,EAAmB,IAAMM,EAAEM,OAAOhB,QAAQqB,WAAa,IAAMX,EAAEM,O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EADML,EAAEc,EAAEwE,eAAenC,QAAQ,qBACpBT,KAAK,oBAAoBI,OAE1C9C,EAAEsB,KAAK,cAAgBjB,EAAQ,CAC3BmE,QAAS,CACLC,OAAU,mBACVC,eAAgB,oBAEpBC,KAAM,OAENhD,QAAS,SAAUC,GACfjB,OAAOC,SAAS4E","file":"productDetail.min.js","sourcesContent":["$(function () {\r\n var returnUrl = document.getElementById('product-detail').dataset.returnUrl;\r\n var nameId = document.getElementById('product-detail').dataset.nameId;\r\n\r\n // HACK: browser BFcache is breaking the back button here\r\n var availabilityDateInput = document.getElementById('availability-date');\r\n var tempAvailabilityDate = availabilityDateInput.dataset.availabilityDate;\r\n availabilityDateInput.value = tempAvailabilityDate;\r\n\r\n $('#filter-search-icon').on('click', function () {\r\n handler();\r\n });\r\n\r\n $('#filter-input').on('keydown', function (e) {\r\n if (e.which === 13) {\r\n e.preventDefault();\r\n handler();\r\n }\r\n });\r\n\r\n // the Index view and Detail view both have an AvailabilityDate input.\r\n // if a user clicks into the Detail view and changes the value of the\r\n // AvailabilityDate input, that new date has to be reflected on the previous\r\n // Index view.\r\n // that won't work if the user presses the back button in their browser, so\r\n // i added a \"Back to Index\" link that will carry the new AvailabilityDate\r\n // back to the Index view.\r\n // the handler function below provides the same functionality if the user\r\n // navigates back to the Index by using the Search input.\r\n function handler() {\r\n var availabilityDate = document.getElementById('availability-date').value;\r\n window.location = '/Product/Detail/' + nameId + '?availabilityDate=' + availabilityDate + \"&returnUrl=\" + returnUrl;\r\n };\r\n\r\n var pikaday = registerPikaday(handler);\r\n\r\n // initialize tooltips\r\n $('[data-toggle=\"tooltip\"]').tooltip();\r\n\r\n var availabilityDate = document.getElementById('availability-date').value;\r\n\r\n $('input[name=quantity-input]').tooltip({\r\n trigger: \"manual\"\r\n });\r\n\r\n $('[data-toggle=\"tooltip\"]').on('mouseenter', function tooltipHover(e) {\r\n if (e.target.dataset.originalTitle === '') {\r\n $.ajax({\r\n method: 'GET',\r\n url: '/Product/GetBucketPricing/' + availabilityDate + '/' + e.target.dataset.itemNumber + '/' + e.target.dataset.siteId,\r\n success: function (response) {\r\n \r\n function makeRow(item) {\r\n var formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });\r\n var price = formatter.format(item.customerPrice);\r\n return 'Quantity: ' + item.quantityPriceBreak + ' Price: ' + price + '';\r\n }\r\n var pricing = '' + response.map(makeRow).join('') + '
';\r\n $(e.target).attr('data-original-title', pricing).tooltip('show');\r\n }\r\n });\r\n }\r\n });\r\n\r\n var $row = $('.product-detail');\r\n $row.find('.plant-row').each(function (i) {\r\n var availability = $(this).find('.qty-available').text();\r\n if (availability === '0') {\r\n $(this).find('.quantity-row').hide();\r\n }\r\n });\r\n\r\n $('.product-detail input[type=\"submit\"]').prop('disabled', true);\r\n $('.product-detail input[name=\"quantity-input\"]').keyup(function (e) {\r\n var $row = $(e.target).closest('.plant-row');\r\n var $submitButton = $($row.find('input[type=\"submit\"]'));\r\n if ($(this).val() !== '') {\r\n $submitButton.prop('disabled', false);\r\n } else {\r\n $submitButton.prop('disabled', true);\r\n }\r\n });\r\n\r\n $('.add-to-cart').on('click', function (e) {\r\n var $parent = $(this).closest('.tabs-container');\r\n var $plantRow = $(this).closest('.plant-row');\r\n var itemNumber = $plantRow.find('.item-number').text();\r\n var quantity = $plantRow.find('input[name=quantity-input]').val();\r\n var minQuantity = $plantRow.find('.min-quantity').text();\r\n var modifiedMinQty = parseInt(minQuantity);\r\n var quantityBundle = $plantRow.find('.quantity-bundle').text();\r\n var futureAvDate = $plantRow.find('.future-av-date').text();\r\n\r\n var finalDate = futureAvDate !== '' ? futureAvDate : availabilityDate;\r\n\r\n if (!(minQuantity === '0')) {\r\n if (quantity < modifiedMinQty) {\r\n alert('This product requires a minimum quantity of ' + minQuantity + '.');\r\n return false;\r\n }\r\n }\r\n\r\n if (!(quantityBundle === '1')) {\r\n if (!(quantity % quantityBundle === 0)) {\r\n alert('This product comes in bundles of ' + quantityBundle + '. Please enter a multiple of ' + quantityBundle + '.');\r\n return false;\r\n }\r\n }\r\n\r\n var pairs = location.search.slice(1).split('&');\r\n var result = [];\r\n pairs.forEach(function (pair) {\r\n pair = pair.split('=');\r\n if (!pair) return null;\r\n result[pair[0]] = decodeURIComponent(pair[1] || '');\r\n });\r\n var promoCode = result.promoCode;\r\n var siteId = $plantRow.find('.site-key').text();\r\n\r\n $plantRow.find('input[name=quantity-input]').each(function () {\r\n if (!$(this).val()) {\r\n $(this).tooltip(\"show\");\r\n return false;\r\n }\r\n });\r\n\r\n $.ajax('/Order/AddItemToCart', {\r\n headers: {\r\n 'Accept': 'application/json',\r\n 'Content-Type': 'application/json'\r\n },\r\n type: 'POST',\r\n data: JSON.stringify({\r\n itemNumber: itemNumber,\r\n wantDate: finalDate,\r\n quantity: quantity,\r\n siteId: siteId,\r\n promotionalcode: promoCode\r\n }),\r\n complete: $('.quantity-input').val(''),\r\n })\r\n });\r\n $('.quantity-input').mousemove(function (e) {\r\n $(this).tooltip(\"hide\");\r\n });\r\n});\r\n\r\n$('.print-button').click(function () {\r\n window.print('.print-div');\r\n});\r\n\r\n$('.triggerImage').click(function (event) {\r\n var url = $(event.currentTarget).data('image');\r\n $('#imageModal img').attr('src', url);\r\n $('#imageModal').modal('show');\r\n});\r\n\r\n$('.fav-true').on('click', function (e) {\r\n var row = $(e.currentTarget).closest('.favorite-product');\r\n var nameId = row.find('.favorite-nameId').text();\r\n\r\n $.ajax('/Favorites/' + nameId, {\r\n headers: {\r\n 'Accept': 'application/json',\r\n 'Content-Type': 'application/json'\r\n },\r\n type: 'DELETE',\r\n\r\n success: function (response) {\r\n window.location.reload();\r\n }\r\n });\r\n});\r\n\r\n$('.fav-false').on('click', function (e) {\r\n var row = $(e.currentTarget).closest('.favorite-product');\r\n var nameId = row.find('.favorite-nameId').text();\r\n\r\n $.ajax('/Favorites/' + nameId, {\r\n headers: {\r\n 'Accept': 'application/json',\r\n 'Content-Type': 'application/json'\r\n },\r\n type: 'POST',\r\n\r\n success: function (response) {\r\n window.location.reload();\r\n }\r\n });\r\n});"]}