{"version":3,"names":[],"mappings":"","sources":["myplugin-frontend-script.js"],"sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i 0) {\n productType = \"variable\";\n productId = $(this).parent().find(\"input[name=product_id]\").val();\n } else {\n productType = \"simple\";\n productId = $(this).val();\n }\n\n if (productId != \"\") {\n var data = {\n action: \"aadp_imported_product_redirect_to_amzon\",\n product_id: productId,\n product_type: productType\n };\n var request = ajaxHelper.ajax(data);\n request.done(function (response) {\n if (response !== \"\") {\n window.location.href = response;\n } else {\n alert(\"Error occured, Contact support!\");\n }\n }).fail(function (xhr, status, error) {\n //Ajax request failed.\n alert(\"Error occured, Contact support!\");\n });\n } else {\n alert(\"Error occured, Contact support!\");\n }\n });\n }\n\n $(document).on(\"click\", \".checkout-button\", function (e) {\n e.preventDefault();\n $(this).append(\"

Processing...

\");\n var data = {\n action: \"aadp_cart_to_amazon_cart_url\"\n };\n var request = ajaxHelper.ajax(data);\n request.done(function (response) {\n for (var i = 0; i < response.length; i++) {\n window.open(response[i], \"_blank\");\n }\n });\n });\n }\n\n var store;\n $(\"#aadp-search-input\").on(\"keypress\", function (e) {\n // $('.aadp-loader').show();\n if (e.which == 13 || e.keyCode == 13) {\n e.preventDefault();\n var keyWord = $(this).val().trim();\n\n if (keyWord != \"\") {\n store = $(\"#store-country\").val();\n var department = $(\"#department\").val();\n var page = 1;\n var url = store + \"s?k=\" + keyWord + \"&i=\" + department;\n aadp_search_products(url, store);\n }\n }\n });\n $(\"#aadp-search-btn\").on(\"click\", function (e) {\n e.preventDefault();\n var keyWord = $(\"#aadp-search-input\").val().trim();\n\n if (keyWord != \"\") {\n store = $(\"#store-country\").val();\n var department = $(\"#department\").val();\n var url = store + \"s?k=\" + keyWord + \"&i=\" + department;\n aadp_search_products(url, store);\n }\n });\n $(document).on(\"change\", \"#store-country\", function (e) {\n e.preventDefault();\n $(\"#department\").hide();\n $(\".buttonload\").remove();\n $(\"#department\").after('');\n store = $(this).val();\n var data = {\n store: store,\n action: \"get_department\"\n };\n var request = ajaxHelper.ajax(data);\n request.done(function (response) {\n // console.log(response);\n $(\"#department\").empty();\n $(\".buttonload\").remove();\n $(\"#department\").append(response);\n $(\"#department\").show();\n });\n });\n var variation;\n $(document).on(\"click\", \".aadp-affiliate-view-details\", function (e) {\n e.preventDefault();\n $(\"#exampleModalCenter\").remove();\n var btn = $(this);\n var product = btn.attr(\"data-product-link\");\n var productTitle = btn.parents(\".card\").children(\".card-body\").children(\".card-title\").text();\n var productImg = btn.parents(\".card\").children(\"a\").children(\"img\").attr(\"src\");\n var data = {\n nonce: myplugin_frontend_script.nonce,\n action: \"aadp_affiliate_view_details\",\n request: product,\n title: productTitle,\n img: productImg\n }; // console.log(data);\n\n var request = ajaxHelper.ajax(data);\n request.done(function (response) {\n // console.log(response);\n variation = response.variation;\n btn.after(response.template); // $('.aadp-loader').hide();\n\n $(\"#exampleModalCenter\").modal(\"show\");\n $(\".xzoom, .xzoom-gallery\").xzoom({\n tint: \"#333\",\n Xoffset: 15\n });\n }).fail(function (jqXHR, textStatus) {\n // console.log(response);\n // console.log(jqXHR);\n // console.log(textStatus);\n if (textStatus == \"error\") {\n var modal = '
' + '
' + '
' + '
' + '
' + ' \" + \"
\" + '
' + ' Currently unavailable' + \" \" + \"

\" + \"
\" + \"
\" + \"
\" + \"
\";\n $(\"body\").append(modal);\n $(\"#exampleModalCenter\").modal(\"show\");\n }\n });\n });\n var asin;\n $(document).on(\"change\", \".attribute\", function (e) {\n var select = $(\".attribute\");\n var selectedVariation = [];\n\n for (var i = 0; i < select.length; i++) {\n selectedVariation.push(parseInt($(select[i]).val()));\n } // console.log(selectedVariation);\n // console.log(selectedVariation.includes(NaN));\n\n\n var checkVariation = selectedVariation.includes(NaN);\n\n if (checkVariation == false) {\n asin = getKeyselectedVariation(variation, selectedVariation); // console.log(asin);\n\n if (asin != false) {\n var variationLink = store + \"dp/\" + asin + \"?th=1&psc=1\";\n $(\"#sendRequestBtn\").attr(\"data-product-link\", variationLink);\n var data = {\n nonce: myplugin_frontend_script.nonce,\n action: \"change_variation\",\n variationLink: variationLink\n }; // console.log(data);\n\n var request = ajaxHelper.ajax(data);\n request.done(function (response) {\n // console.log(response);\n $(\"#tabbed_image_gallery\").empty();\n $(\"#variation-price\").empty();\n $(\"#tabbed_image_gallery\").append(response.galleryTab);\n $(\".xzoom, .xzoom-gallery\").xzoom({\n tint: \"#333\",\n Xoffset: 15\n });\n $(\".aadp-availability\").empty();\n $(\"#variation-price\").empty();\n $(\"#variation-price\").append(response.price);\n });\n } else {\n $(\".aadp-availability\").empty();\n $(\".aadp-availability\").append(\"Currently Unavailable\");\n }\n }\n });\n\n var getKeyselectedVariation = function getKeyselectedVariation(obj, selectedVariation) {\n var returnKey = false;\n $.each(obj, function (key, info) {\n if (arraysEqual(info, selectedVariation) == true) {\n returnKey = key;\n return false;\n }\n });\n return returnKey;\n };\n\n function arraysEqual(a1, a2) {\n /* WARNING: arrays must not contain {objects} or behavior may be undefined */\n return JSON.stringify(a1) == JSON.stringify(a2);\n }\n\n $(document).on(\"click\", \"#aadp-add-to-cart\", function (e) {\n e.preventDefault();\n var site_tag = $(this).attr(\"aadp-affiliate-tag\");\n var quantity = $(\"#quantity\").val();\n\n if ($(\".attribute\").length > 0) {\n if (asin != false) {\n var amazonCartLink = store + \"/gp/aws/cart/add.html?AssociateTag=\" + site_tag + \"&ASIN.1=\" + asin + \"&Quantity.1=\" + quantity;\n window.open(amazonCartLink, \"_blank\");\n }\n } else {\n var singleProductAsin = $(this).attr(\"data-asin\");\n var amazonCartLink = store + \"/gp/aws/cart/add.html?AssociateTag=\" + site_tag + \"&ASIN.1=\" + singleProductAsin + \"&Quantity.1=\" + quantity;\n window.open(amazonCartLink, \"_blank\");\n }\n }); // var store;\n\n function aadp_search_products(url, store) {\n var req_data = {\n nonce: myplugin_frontend_script.nonce,\n action: \"search_product\",\n store: store,\n url: url\n }; // console.log(req_data);\n\n var request = ajaxHelper.ajax(req_data);\n request.done(function (response) {\n // console.log(response);\n $(\"#aadp-import-product\").empty();\n $(\"#aadp-import-product\").append(response.data);\n $(\"html,body\").animate({\n scrollTop: $(\"#aadp-import-product\").offset().top\n }, \"slow\");\n });\n }\n\n if ($(\".aadp_searc_amazon\")) {\n $(\".aadp_searc_amazon\").parent().removeClass(\"entry-content\").addClass(\"container\");\n }\n });\n});\n\n},{}]},{},[1]);\n"],"file":"myplugin-frontend-script.js"}