{"version":3,"sources":["before.js","single.js","after.js"],"names":["$","OpalWoocommerceSingleProduct","_classCallCheck","this","_createClass","key","value","$fbtProducts","length","priceAt","find","$button","totalPrice","parseFloat","data","on","id","val","closest","toggleClass","currentPrice","hasClass","addClass","removeClass","each","$product_ids","attr","$singleBtn","currentURL","window","location","href","url","ajaxurl","method","action","success","response","dataType","document","body","trigger","error","number","toFixed","price_decimals","x","split","x1","x2","decimal","rgx","test","replace","thousand","n","currency_pos","currency","jQuery"],"mappings":"8XAAA,SAAAA,GC8GA,ID9GA,WCCA,QAAAC,KAAAC,gBAAAC,KAAAF,GDDA,MAAAG,cAAAH,IAAAI,IAAA,mBAAAC,MAAA,WCCA,GAAAC,GAAAP,EAAA,0BAEA,MAAAO,EAAAC,QAAA,GAAA,CAUA,GAAAC,GAAAF,EAAAG,KAAA,8CARAC,EAAAJ,EAAAG,KAAA,2BAUAE,EAAAC,WAAAN,EAAAG,KAAA,mBAAAI,KAAA,SACAP,GAAAO,KAAA,YDhBAP,EAAAO,KAAA,YAAAP,EAAAO,KAAA,WAAAP,EAAAO,KAAA,kBCoBAP,EAAAO,KAAA,eAEAP,GAAAG,KAAA,wBAAAK,GAAA,SAAA,WAZA,GAAAC,GAAAhB,EAAAG,MAAAc,KACAjB,GAAAG,MAAAe,QAAA,MAAAC,YAAA,UACA,IAAAC,GAAAP,WAAAb,EAAAG,MAAAe,QAAA,MAAAR,KAAA,kBAAAI,KAAA,SACAd,GAAAG,MAAAe,QAAA,MAAAG,SAAA,YAAAd,EAAAG,KAAA,gBAAAM,GAAAM,SAAA,aAAAV,GAAAQ,IAAAb,EAAAG,KAAA,gBAAAM,GAAAO,YAAA,aAAAX,GAAAQ,EASAb,IAAAA,GAAAA,GACAA,GAAAG,KAAA,oBAAAc,KAAA,WACAxB,EAAAA,MAAAA,SAAAA,aACAyB,GAAA,IAAAzB,EAAAG,MAAAO,KAAA,wBAAAO,SAKAN,EAAAe,KAAA,QAAAD,GAEAb,EAAAA,KAAAA,KAAAA,aAAAA,MAIAL,EAAAA,GAAAA,QAAAA,2CAAAA,WACA,GAAAoB,GAAA3B,EAAAG,KACAsB,GAAAA,SAAAA,UAEA,IAAAG,GAAAC,OAAAC,SAAAC,IAEApB,GAAAA,MAaAqB,IAAAC,QAXAxB,SAAAA,OACAyB,OAAA,OAaApB,MAXAqB,OAAA,kCACA5B,YAAAA,EAAAA,KAAAA,UAEAoB,MAAAA,WAaAE,OAAAC,SAAAF,GAEAQ,QAAA,SAAAC,GAXArC,GAAAA,mBAAAA,wBACAgC,QAAAA,sBAAAA,wBAEAE,YADAI,OAAAA,SAAAA,sBAAAA,SAEAtC,GAAAuC,SAAAC,MAAAC,QAAA,kBAIAC,EAAAA,SAAAA,MAAAA,GAAAA,yBAAAA,WACAb,EAAAA,YAAAA,sBD/DAxB,IAAA,eAAAC,MAAA,SCyEAN,GACAA,GAAAA,GAAAA,CACA2B,IAAAA,SAAAA,gBAAAA,EAAAA,CACAgB,EAAAA,EAAAC,QAAAC,gBAAA,ED5EA,KC8EA,GAAAC,GAAAH,EAAAI,MAAA,KAxBAC,EAAAF,EAAA,GA2BAG,EAAAH,EAAAtC,OAAA,EAAA0C,QAAAJ,EAAA,GAAA,GAEAK,EAAA,eDnFAA,EAAAC,KAAAJ,IAAAA,EAAAA,EAAAK,QAAAF,EAAA,KAAAG,SAAA,KCuFAC,GAAAP,EAAAC,EAGA,OAAAO,cAEA,IAAA,OACA,MAAAC,UAAAF,CAEA,KAAA,QAWA,MAAAA,GAAAE,QARA,KAAA,aAWA,MAAAA,UAAA,IAAAF,CAPA,KAAA,cACA,MAAAA,GAAA,IAAAE,cDvGAxD,OEAAyD","file":"single.js","sourcesContent":["(function ($) {"," class OpalWoocommerceSingleProduct {\n constructor() {\n //this.productTogerther();\n }\n\n //product Together Select\n productTogerther(){\n\n var $fbtProducts = $('.opal-frequently-bought');\n\n if ( $fbtProducts.length <= 0 ) {\n return;\n }\n var priceAt = $fbtProducts.find('.otf-total-price .woocommerce-Price-amount'),\n $button = $fbtProducts.find('.otf_add_to_cart_button'),\n totalPrice = parseFloat($fbtProducts.find('#otf-data_price').data('price')),\n currency = $fbtProducts.data('currency'),\n thousand = $fbtProducts.data('thousand'),\n decimal = $fbtProducts.data('decimal'),\n price_decimals = $fbtProducts.data('price_decimals'),\n currency_pos = $fbtProducts.data('currency_pos');\n\n $fbtProducts.find('input[type=checkbox]').on('change', function () {\n let id = $(this).val();\n $(this).closest('li').toggleClass('uncheck');\n let currentPrice = parseFloat($(this).closest('li').find('.product-price').data('price'));\n if ($(this).closest('li').hasClass('uncheck')) {\n $fbtProducts.find('#fbt-product-' + id).addClass('un-active');\n totalPrice -= currentPrice;\n\n } else {\n $fbtProducts.find('#fbt-product-' + id).removeClass('un-active');\n totalPrice += currentPrice;\n }\n\n let $product_ids = '0';\n $fbtProducts.find('.product-list li').each(function () {\n if (!$(this).hasClass('uncheck')) {\n $product_ids += ',' + $(this).find('input[type=checkbox]').val();\n }\n });\n\n $button.attr('value', $product_ids);\n\n priceAt.html( this.formatNumber( totalPrice) );\n });\n\n // Add to cart ajax\n $fbtProducts.on('click', '.otf_add_to_cart_button.ajax_add_to_cart', function() {\n var $singleBtn = $(this);\n $singleBtn.addClass('loading');\n\n var currentURL = window.location.href;\n\n $.ajax({\n url : ajaxurl,\n dataType: 'json',\n method : 'post',\n data : {\n action : 'otf_woocommerce_fbt_add_to_cart',\n product_ids: $singleBtn.attr('value')\n },\n error : function() {\n window.location = currentURL;\n },\n success : function(response) {\n if ( typeof wc_add_to_cart_params !== 'undefined' ) {\n if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) {\n window.location = wc_add_to_cart_params.cart_url;\n return;\n }\n }\n\n $(document.body).trigger('updated_wc_div');\n $(document.body).on('wc_fragments_refreshed', function() {\n $singleBtn.removeClass('loading');\n });\n\n }\n });\n\n });\n\n }\n\n formatNumber(number) {\n let n = number;\n if (parseInt(price_decimals) > 0) {\n number = number.toFixed(price_decimals) + '';\n var x = number.split('.');\n var x1 = x[0],\n x2 = x.length > 1 ? decimal + x[1] : '';\n var rgx = /(\\d+)(\\d{3})/;\n while (rgx.test(x1)) {\n x1 = x1.replace(rgx, '$1' + thousand + '$2');\n }\n\n n = x1 + x2\n }\n\n\n switch (currency_pos) {\n case 'left' :\n return currency + n;\n break;\n case 'right' :\n return n + currency;\n break;\n case 'left_space' :\n return currency + ' ' + n;\n break;\n case 'right_space' :\n return n + ' ' + currency;\n break;\n }\n }\n\n}\n\nnew OpalWoocommerceSingleProduct();","})(jQuery);"]}