var EZwidth, EZoffsetX, EZEnabled, bigimg; String.prototype.replaceAll = function(target, replacement) { return this.split(target).join(replacement); }; jQuery(document).ready(function($) { $('#pinfo_360_button').click(function() { open_presentation($(this).attr('data-360'),800,700); }); // $('.pinfo-top-copy').html($('.pinfo-top').html() // .replaceAll('id="','id="copy-') // .replaceAll('itemprop=','data-itemprop=') // .replaceAll('itemscope=','data-itemscope=') // .replaceAll('itemtype=','data-itemtype=') // ); bindCopyStarOnPinfo(); // bindCopyTimerPriceOnPinfo(); countdownStart(); bigimg = $('#images'), thumbs = $('#pinfo-thumbs'); var initialSlide = typeof bigimg.attr('data-initial-slide') != 'undefined' ? bigimg.attr('data-initial-slide') : 0; bigimg.slick({ slidesToShow: 1, slidesToScroll: 1, adaptiveHeight: true, arrows: false, infinite: false, fade: true, cssEase: 'ease', responsive: [ { breakpoint: 480, settings: { fade: false } } ] }); thumbs.slick({ arrows: true, slidesToShow: dget('pinfo-thumbs','items',true), infinite: false, draggable: false, vertical: dget('pinfo-thumbs','vertical',true) === 1 ? true : false, responsive: [ { breakpoint: 480, settings: { arrows: true, vertical: false } } ] }); thumbs.on('click','.slick-slide', function() { var index = thumbs.find('.thumb').index(this); bigimg.slick('slickGoTo',index, false); }); $('#img_Prev, #img_Next').on('click', function() { var t = $(this).attr('id').split('_')[1]; bigimg.slick('slick'+t); }); if(initialSlide > 0) bigimg.slick('slickGoTo', initialSlide, true); //showMobileInfo(); zoomConfig(); //$(window).on('resize', showMobileInfo); $(window).on('viewport_changed', function() { zoomConfig(); initZoom(true); }); bigimg.on('beforeChange',syncGallery); bigimg.trigger('beforeChange',[bigimg,0,0]); if(dget('rc_pid','is-set') == '1') inventorySet(dget('rc_pid','id')); else inventory(dget('rc_pid','id')); //inventory(dget('rc_pid','id')); if(dget('rc_pid','sell-type') == '1') { buy_quantity_sum($('#buy_quantity_input'),$('#buy_quantity_prive')); } initZoom(); lightbox.option({ showImageNumberLabel: false }); $(document).on('shown.bs.collapse', '.tabs-container .panel-group', function(e,e2,e3) { var target = $(e.target) if($(document).scrollTop() > target.prev().offset().top) { $(document).scrollTop(target.prev().offset().top) } }) }); function countdownStart() { jQuery('.pinfo-description').each(function(i,el) { if(jQuery(el).find('.pinfo-price .price_cutdown').length > 0) { var timeEl = jQuery(el).find('.pinfo-price .price_cutdown span').last(), displayEl = timeEl.prev(), time = timeEl.text(), countdownDate = new Date(time*1000).getTime() // Update the count down every 1 second var x = setInterval(function() { // Get todays date and time var now = new Date().getTime(); // Find the distance between now an the count down date var distance = countdownDate - now; // Time calculations for days, hours, minutes and seconds var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); hours = hours > 9 ? hours : '0' + hours; minutes = minutes > 9 ? minutes : '0' + minutes; seconds = seconds > 9 ? seconds : '0' + seconds; // Display the result in the element with id="demo" displayEl[0].innerHTML = days + " dni " + hours + ":" + minutes + ":" + seconds; // If the count down is finished, write some text if (distance < 0) { clearInterval(x); displayEl[0].innerHTML = "EXPIRED"; } }, 1000); } }) } function syncGallery(e,slick,current,next) { initZoom(current,next); var idx_last = jQuery('#images').find('.slick-slide').length - 1; if(next === 0) { jQuery('#img_Prev').fadeOut('fast'); } else { jQuery('#img_Prev').fadeIn('fast'); } if(next === idx_last) { jQuery('#img_Next').fadeOut('fast'); } else { jQuery('#img_Next').fadeIn('fast'); } var thumbs = jQuery('#pinfo-thumbs'); thumbs.slick('slickGoTo',next,false); /* if(thumbs.find('.thumb').eq(next).is('.slick-active') == false) { var tvis = thumbs.find('.thumb').filter('.slick-active'); if(next < tvis.first().data('slick-index')) { thumbs.slick('slickPrev'); } if(next > tvis.last().data('slick-index')) { thumbs.slick('slickNext'); } }*/ } /* function showMobileInfo() { if(viewport_check.is_in(['xs','sm'])) { if(jQuery('#pinfo-topinfo').length > 0) return; var topinfo = jQuery('
') topinfo.prepend(jQuery('.pinfo-price').clone()); topinfo.prepend('
'); jQuery('.pinfo-rating').children().prependTo(topinfo.find('.pinfo-rating')); topinfo.prepend(jQuery('.pinfo-name').clone()); topinfo.find('ul').append(jQuery('.pinfo-producer-photo').clone()); jQuery('.pinfo-gallery').before(topinfo); jQuery('.pinfo-description .pinfo-price, .pinfo-description .pinfo-name, .pinfo-description .pinfo-producer-photo').hide(); } else { if(viewport_check.previous() === 'xs' || viewport_check.previous() === 'sm') { jQuery('#pinfo-topinfo .pinfo-rating').children().prependTo(jQuery('.pinfo-description').children('.pinfo-rating')); } jQuery('#pinfo-topinfo').remove(); jQuery('.pinfo-description .pinfo-price, .pinfo-description .pinfo-name, .pinfo-description .pinfo-producer-photo').removeAttr('style'); } } */ function zoomConfig() { if(dget('rc_pid','zoom') !== true) { EZEnabled = false; return; } EZEnabled = true; EZwidth = jQuery('.pinfo-description').outerWidth(), EZoffsetX = parseFloat(jQuery('.pinfo-description').css('margin-left').replace('px','')); if(viewport_check.is_in(['xs','sm'])) { EZEnabled = false; } } function initZoom(current,next) { var loadEZ =function() { var imgElement = newEZ[0]; var naturalWidth = newEZ[0].naturalWidth || newEZ[0].width; var scaleWidth = newEZ.width(); if(scaleWidth >= naturalWidth) { return; } newEZ.elevateZoom({ zoomWindowWidth: EZwidth, zoomWindowOffetx: EZoffsetX, borderSize: 1 }); } if(current !== next || current === true) { var oldEZ = (current === true) ? jQuery('#images').find('.slick-active').find('img') : jQuery('#images').find('.slide').eq(current).find('img'); jQuery('.zoomContainer').remove(); oldEZ.removeData('elevateZoom'); oldEZ.removeData('zoomImage'); } if((next !== undefined || current === true) && EZEnabled === true) { var newEZ = (current === true) ? jQuery('#images').find('.slick-active').find('img') : jQuery('#images').find('.slide').eq(next).find('img'); if(newEZ !== undefined ) { if(newEZ[0] != undefined && newEZ[0].complete==true) { loadEZ(); } else { jQuery(newEZ).load(loadEZ); } } } } (function () { var viewPriceOldC = document.getElementById('viewPriceOldC'); if(viewPriceOldC){ var viewPriceOld = document.getElementById('viewPriceOld'); if(viewPriceOld) { let observer = new MutationObserver(e => { var priceSale = document.querySelector('.rc-page-pinfo div.price_sale'); if(priceSale) { priceSale.style.opacity = 0; } }); observer.observe(viewPriceOld, { childList: true, }); } } })();