{"version":3,"sources":["before.js","single.js","after.js"],"names":["$","OpalWoocommerceSingleProduct","_this","this","_classCallCheck","document","ready","initSlideProduct","window","resize","on","singleProductGalleryImages","_createClass","key","value","_this2","lightbox","length","attr","productVerticalSlider","setTimeout","$slider","vertical_height","height","child_height","slidesToShow","each","i","e","has_slider","not","slick","rtl","infinite","vertical","verticalSwiping","$widthwrap","find","width","css","display","$fbtProducts","priceAt","$image","totalPrice","parseFloat","data","id","val","closest","toggleClass","currentPrice","hasClass","addClass","removeClass","$product_ids","$button","$singleBtn","url","ajaxurl","dataType","product_ids","success","response","wc_add_to_cart_params","cart_redirect_after_add","method","n","number","parseInt","price_decimals","x","split","x1","x2","decimal","currency_pos","currency","jQuery"],"mappings":"8XAAA,SAAAA,GC6JA,ID7JA,WCEA,QAAAC,KAAA,GAAAC,GAAAC,IAAAC,iBAAAD,KAAAF,GAEAD,EAAAK,UAAAC,MAAA,WACAJ,EAAAK,qBDLAP,EAAAQ,QAAAC,OAAA,WCEAP,EAAAK,qBAAAP,EAAA,gCAAAU,GAAA,gCAAA,WAUAR,EAAAS,+BDZA,MAAAC,cAAAX,IAAAY,IAAA,6BAAAC,MAAA,WCMA,GAAAC,GAAAZ,KAEAa,EAAAhB,EAAA,0DACAgB,GAAAC,QAWAD,EAAAE,KAAA,+BAAA,MAPAlB,EAAA,4DACAiB,SAWAd,KAAAgB,wBDzBAnB,EAAAQ,QAAAC,OAAA,WAAAM,EAAAI,8BAAAN,IAAA,wBAAAC,MAAA,WCoBAE,GAAAA,GAAAA,EAAAA,QAAAA,SAAAA,MACAI,YAAA,WAcA,GAAAC,GAAArB,EAAA,iFAZAsB,EAAAtB,EAAA,mFAAAuB,SACAC,EAAA,EACAC,EAAA,EACAzB,GAAAA,CAEAA,GAAA,wDAAA0B,KAAA,SAAAC,EAAAC,GAEA,IADAJ,GAAA,IACAF,ED9BA,MAAAG,GAAAE,EAAAE,GAAA,GAAA,ICoCAR,EAAAS,IAAA,sBAAAC,OACAC,IAA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,EAAAA,KACAa,GAAAJ,SAAA,UACAZ,IAAAA,GAAAA,OAAAA,SAAAA,IACAG,GAAAA,MACAc,IAAAC,QACAC,SAAA,OACAnB,OAAAA,OACAK,MACAS,OAAAA,kCACAM,YAAAJ,EAAAvC,KAAA,UAEAsC,MAAAA,WACAd,OAAAA,SAAAA,GAEAoB,QAAA,SAAAC,GACAtB,GAAAA,mBAAAA,wBACA,QAAAuB,sBAAAC,wBAEA,YADAR,OAAAA,SAAAA,sBAAAA,SAIAG,GAAAA,SAAAA,MAAAA,QAAAA,kBACAM,EAAAA,SAAAA,MAAAA,GAAAA,yBAAAA,WACApB,EAAAA,YAAAA,sBDzHAjC,IAAA,eAAAC,MAAA,SCgIAgD,GACA,GAAAK,GAAAC,CACA,IAAAC,SAAAC,gBAAA,EAAA,CACA9D,EAAAA,EAAAA,QAAAA,gBAAAA,EAKAR,KAJA,GAAAuE,GAAAH,EAAAI,MAAA,KACAC,EAAAF,EAAA,GACAG,EAAAH,EAAAtD,OAAA,EAAA0D,QAAAJ,EAAA,GAAA,GACAvE,EAAAA,eACAA,EAAAA,KAAAA,IACAyD,EAAAA,EAAAA,QAAAA,EAAAA,KAAAA,SAAAA,KAEAU,GAAAM,EAAAC,EAEA,OAAAE,cACA,IAAA,OD9IA,MAAAC,UAAAV,CAAA,KAAA,QCiJA,MAAAA,GAAAU,QAEAT,KAAAA,aACA,MAAAS,UAAA,IAAAV,CACA,KAAA,cAEA,MAAAA,GAAA,IAAAU,cDvJA5E,OEAA6E","file":"single.js","sourcesContent":["(function ($) {","class OpalWoocommerceSingleProduct {\n\n constructor() {\n //this.productTogerther();\n $(document).ready(() => {\n this.initSlideProduct();\n });\n $(window).resize(() => {\n this.initSlideProduct();\n })\n\n $('.woocommerce-product-gallery').on('wc-product-gallery-after-init', () => {\n this.singleProductGalleryImages();\n });\n }\n\n singleProductGalleryImages() {\n\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 let $vertical = $('.woocommerce-single-style-1 .woocommerce-product-gallery');\n if ($vertical.length) {\n this.productVerticalSlider();\n $(window).resize( () => {\n this.productVerticalSlider();\n })\n }\n }\n\n productVerticalSlider() {\n var rtl = $('body').hasClass('rtl');\n setTimeout(function () {\n var $slider = $('.woocommerce-single-style-1 .woocommerce-product-gallery .flex-control-thumbs');\n let vertical_height = $('.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:eq(0)').height();\n let child_height = 0,\n slidesToShow = 1;\n let has_slider = false;\n\n $('.woocommerce-product-gallery .flex-control-thumbs li').each(function (i, e) {\n child_height += 90;\n if (child_height > vertical_height) {\n slidesToShow = i;\n has_slider = true;\n return false;\n }\n });\n\n $slider.not('.slick-initialized').slick({\n rtl: rtl,\n infinite: false,\n slidesToShow: slidesToShow,\n vertical: true,\n verticalSwiping: true,\n });\n\n if (has_slider) {\n $slider.slick('slickSetOption', 'slidesToShow', slidesToShow);\n }else {\n $slider.slick('unslick');\n }\n\n }, 200);\n }\n\n\n initSlideProduct() {\n let $slider = $('.single-product div.product .images'),\n $widthwrap = $slider.find('.flex-viewport').width(),\n $image = $slider.find('.woocommerce-product-gallery__image > a');\n $image.css({\n 'max-width': $widthwrap,\n 'display' : 'block'\n })\n }\n\n //product Together Select\n productTogerther() {\n var $fbtProducts = $('.opal-frequently-bought');\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 $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 } else {\n $fbtProducts.find('#fbt-product-' + id).removeClass('un-active');\n totalPrice += currentPrice;\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 $button.attr('value', $product_ids);\n priceAt.html(this.formatNumber(totalPrice));\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 var currentURL = window.location.href;\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 $(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 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 = x1 + x2\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\nnew OpalWoocommerceSingleProduct();","})(jQuery);"]}