{"version":3,"sources":["before.js","single.js","after.js"],"names":["$","OpalWoocommerceSingleProduct","_this","this","_classCallCheck","initSlideProduct","Product_Style_4","window","resize","_createClass","key","value","SingleSlider","lightbox","length","attr","removeClass","index","className","match","join","flexslider","selector","animation","controlNav","directionNav","slideshow","smoothHeight","itemMargin","start","slider","console","log","currentSlide","prev","count","next","touch","find","after","width","$cart","detach","insertBefore","$fbtProducts","priceAt","totalPrice","parseFloat","data","on","id","val","closest","toggleClass","currentPrice","hasClass","addClass","$product_ids","each","$button","$singleBtn","url","ajaxurl","dataType","method","action","error","location","currentURL","success","response","wc_add_to_cart_params","cart_redirect_after_add","cart_url","number","n","parseInt","price_decimals","toFixed","rgx","test","x1","replace","thousand","x2","currency_pos","currency","jQuery"],"mappings":"8XAAA,SAAAA,GCiKA,IDjKA,WCCA,QAAAC,KAAA,GAAAC,GAAAC,IAAAC,iBAAAD,KAAAF,GAEAE,KAAAE,mBACAF,KAAAG,kBACAN,EAAAO,QAAAC,OAAA,WDLAN,EAAAI,oBAAA,MAAAG,cAAAR,IAAAS,IAAA,mBAAAC,MAAA,WCCA,GAAAC,GAAAZ,EAAA,iIAWAa,EAAAb,EAAA,0DAVAa,GAAAC,QACAD,EAAAE,KAAA,+BAAA,MAGAH,EAAAI,YAAA,SAAAC,EAAAC,GACA,OAAAA,EAAAC,MAAA,wDAAAC,KAAA,OACAC,YAYAC,SAAA,4EDpBAC,UAAA,QAAAC,YAAA,EAAAC,cAAA,ECWAC,WAAA,EACAC,cAAA,EACAC,WAAA,EACAf,OAAAA,EACAgB,MAAA,SAAAC,GAcAC,QAAAC,IAAAF,EAAAG,aAZArB,IAAAA,GAAAA,EAAAA,aAAAA,GAAAA,EAAAA,MAAAA,EAAAA,EAAAA,aAAAA,EACAsB,EAAA,GAAAJ,EAAAG,aAAAH,EAAAK,MAAAL,EAAAG,YACAG,GAAAA,EAAA,GAAA,IAAAA,EAAAA,EACAd,EAAAA,EAAAA,GAAAA,IAAAA,EAAAA,EACAC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A,cACA,MAAAA,GAAA,IAAAW,cDzJArF,OEAAsF","file":"single.js","sourcesContent":["(function ($) {","class OpalWoocommerceSingleProduct {\n constructor() {\n //this.productTogerther();\n this.initSlideProduct();\n this.Product_Style_4();\n $(window).resize(() => {\n this.Product_Style_4();\n })\n }\n\n initSlideProduct() {\n let SingleSlider = $('.single-product.woocommerce-single-style-3 div.product .images,.single-product.woocommerce-single-style-7 div.product .images');\n let lightbox = $('.single-product .woocommerce-product-gallery__image > a');\n if (lightbox.length) {\n lightbox.attr(\"data-elementor-open-lightbox\", \"no\");\n }\n\n SingleSlider.removeClass(function (index, className) {\n return (className.match(/(^|\\s)woocommerce-product-gallery--columns-\\S+/g) || []).join(' ');\n }).flexslider({\n selector: '.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image',\n animation: 'slide',\n controlNav: true,\n directionNav: true,\n slideshow: false,\n smoothHeight: false,\n itemMargin: 0,\n touch: true,\n start: function (slider) {\n console.log(slider.currentSlide);\n let next = slider.currentSlide + 1 == slider.count ? 1 : slider.currentSlide + 2,\n prev = slider.currentSlide == 0 ? slider.count : slider.currentSlide;\n next = next < 10 ? '0' + next : next;\n prev = prev < 10 ? '0' + prev : prev;\n SingleSlider.find('.flex-control-nav').attr('data-next', next);\n SingleSlider.find('.flex-control-nav').attr('data-prev', prev);\n },\n after: function (slider) {\n console.log(slider.currentSlide);\n let next = slider.currentSlide + 1 == slider.count ? 1 : slider.currentSlide + 2,\n prev = slider.currentSlide == 0 ? slider.count : slider.currentSlide;\n next = next < 10 ? '0' + next : next;\n prev = prev < 10 ? '0' + prev : prev;\n SingleSlider.find('.flex-control-nav').attr('data-next', next);\n SingleSlider.find('.flex-control-nav').attr('data-prev', prev);\n },\n });\n }\n\n Product_Style_4() {\n let $cart = $('.single-product.woocommerce-single-style-4 .woocommerce-cart-inner');\n if ($cart.length) {\n if ($(window).width() < 1200) {\n $cart.detach().insertBefore('.product_meta');\n } else {\n $cart.detach().appendTo('.woocommerce-cart');\n }\n }\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);"]}