PageSourceSearch

https://topdoghealth.com/wp-content/cache/flying-press/ad8cf5632962.xoo-wsc-main.js

js topdoghealth.com collected 2026-09-25 21:45:51 UTC 17,213 bytes, 82 lines download raw bytes

1jQuery(document).ready(function($){var isCartPage=xoo_wsc_params.isCart=='1',isCheckoutPage=xoo_wsc_params.isCheckout=='1';var get_wcurl=function(endpoint){return xoo_wsc_params.wc_ajax_url.toString().replace('%%endpoint%%',endpoint)};class Notice{constructor($modal){this.$modal=$modal;this.timeout=null}
2add(notice,type='success',clearPrevious=!0){var $noticeCont=this.$modal.find('.xoo-wsc-notice-container');if(clearPrevious){$noticeCont.html('')}
3var noticeHTML=type==='success'?xoo_wsc_params.html.successNotice.toString().replace('%s%',notice):xoo_wsc_params.html.errorNotice.toString().replace('%s%',notice);$noticeCont.html(noticeHTML)}
4showNotification(){var $noticeCont=this.$modal.find('.xoo-wsc-notice-container');if(!$noticeCont.length||$noticeCont.children().length===0)return;$noticeCont.slideDown();clearTimeout(this.timeout);this.timeout=setTimeout(function(){$noticeCont.slideUp('slow',function(){})},xoo_wsc_params.notificationTime)}
5hideNotification(){this.$modal.find('.xoo-wsc-notice-container').hide()}}
6class Container{constructor($modal,container){this.$modal=$modal;this.container=container||'cart';this.notice=new Notice(this.$modal)}
7eventHandlers(){$(document.body).on('wc_fragments_refreshed updated_checkout',this.onCartUpdate.bind(this))}
8onCartUpdate(){this.unblock();this.notice.showNotification()}
9setAjaxData(data,noticeSection){var ajaxData={container:this.container,noticeSection:noticeSection||this.noticeSection||this.container,isCheckout:isCheckoutPage,isCart:isCartPage}
10if(typeof data==='object'){$.extend(ajaxData,data)}else{var serializedData=data;$.each(ajaxData,function(key,value){serializedData+=('&'+key+'='+value)})
11ajaxData=serializedData}
12return ajaxData}
13toggle(type){var $activeEls=this.$modal.add('body').add('html'),activeClass='xoo-wsc-'+this.container+'-active';if(type==='show'){$activeEls.addClass(activeClass)}else if(type==='hide'){$activeEls.removeClass(activeClass);this.notice.hideNotification()}else{$activeEls.toggleClass(activeClass)}
14$(document.body).trigger('xoo_wsc_'+this.container+'_toggled',[type])}
15block(){this.$modal.addClass('xoo-wsc-loading')}
16unblock(){this.$modal.removeClass('xoo-wsc-loading')}
17refreshMyFragments(){if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){$(document.body).trigger('wc_fragment_refresh');return}
18this.block();$.ajax({url:get_wcurl('xoo_wsc_refresh_fragments'),type:'POST',context:this,data:{},success:function(response){this.updateFragments(response)},complete:function(){this.unblock()}})}
19updateCartCheckoutPage(){if(isCheckoutPage){if($('form.checkout').length===0){location.reload();return}
20$(document.body).trigger("update_checkout")}
21if(isCartPage){$(document.body).trigger("wc_update_cart")}}
22updateFragments(response){if(response.fragments){$(document.body).trigger('xoo_wsc_before_loading_fragments',[response]);this.block();$.each(response.fragments,function(key,value){$(key).replaceWith(value)});if(typeof wc_cart_fragments_params!=='undefined'&&('sessionStorage' in window&&window.sessionStorage!==null)){sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(response.fragments));localStorage.setItem(wc_cart_fragments_params.cart_hash_key,response.cart_hash);sessionStorage.setItem(wc_cart_fragments_params.cart_hash_key,response.cart_hash);if(response.cart_hash){sessionStorage.setItem('wc_cart_created',(new Date()).getTime())}}
23$(document.body).trigger('wc_fragments_refreshed');this.unblock()}
24if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){this.block();$(document.body).trigger('wc_fragment_refresh');return}}}
25class Cart extends Container{constructor($modal){super($modal,'cart');this.baseQty=1;this.qtyUpdateDelay=null;this.refreshFragmentsOnPageLoad();this.eventHandlers();this.initSlider()}
26refreshFragmentsOnPageLoad(){setTimeout(function(){this.refreshMyFragments()}.bind(this),xoo_wsc_params.fetchDelay)}
27eventHandlers(){super.eventHandlers();this.$modal.on('click','.xoo-wsc-chng',this.toggleQty.bind(this));this.$modal.on('change','.xoo-wsc-qty',this.changeInputQty.bind(this));this.$modal.on('click','.xoo-wsc-undo-item',this.undoItem.bind(this));this.$modal.on('focusin','.xoo-wsc-qty',this.saveQtyFocus.bind(this));this.$modal.on('click','.xoo-wsc-smr-del',this.deleteIconClick.bind(this));this.$modal.on('click','.xoo-wsch-close, .xoo-wsc-opac, .xoo-wsc-cart-close',this.closeCartOnClick.bind(this));this.$modal.on('click','.xoo-wsc-basket',this.toggle.bind(this));$(document.body).on('click','.xoo-wsc-ecl',this.emptyCart.bind(this));$(document.body).on('xoo_wsc_cart_updated',this.updateCartCheckoutPage.bind(this));$(document.body).on('click','a.added_to_cart, .xoo-wsc-cart-trigger',this.openCart.bind(this));$(document.body).on('added_to_cart',this.addedToCart.bind(this));if(xoo_wsc_params.autoOpenCart==='yes'&&xoo_wsc_params.addedToCart==='yes'){this.openCart()}
28if(xoo_wsc_params.ajaxAddToCart==='yes'){$(document.body).on('submit','form.cart',this.addToCartFormSubmit.bind(this))}
29if(typeof wc_cart_fragments_params==='undefined'){$(window).on('pageshow',this.onPageShow)}
30if(isCheckoutPage||isCartPage){$(document.body).on('updated_shipping_method',this.refreshMyFragments.bind(this))}
31$(document.body).on('xoo_wsc_before_loading_fragments',this.storeShippingBarWidth.bind(this))}
32openCart(e){if(e){e.preventDefault()}
33this.toggle('show')}
34addToCartFormSubmit(e){var $form=$(e.currentTarget);if($form.closest('.product').hasClass('product-type-external'))return;e.preventDefault();var $button=$form.find('button[type="submit"]'),productData=$form.serializeArray(),hasProductId=!1;$.each(productData,function(key,form_item){if(form_item.name==='productID'||form_item.name==='add-to-cart'){if(form_item.value){hasProductId=!0;return!1}}})
35if(!hasProductId&&$form.attr('action')){var is_url=$form.attr('action').match(/add-to-cart=([0-9]+)/),productID=is_url?is_url[1]:!1}
36if($button.attr('name')&&$button.attr('name')=='add-to-cart'&&$button.attr('value')){var productID=$button.attr('value')}
37if(productID){productData.push({name:'add-to-cart',value:productID})}
38productData.push({name:'action',value:'xoo_wsc_add_to_cart'});this.addToCartAjax($button,productData)}
39addToCartAjax($button,productData){this.block();$button.addClass('loading');$(document.body).trigger('adding_to_cart',[$button,productData]);$.ajax({url:get_wcurl('xoo_wsc_add_to_cart'),type:'POST',context:this,data:$.param(productData),success:function(response){if(response.fragments){$(document.body).trigger('added_to_cart',[response.fragments,response.cart_hash,$button])}else{window.location.reload()}},complete:function(){this.unblock();$button.removeClass('loading').addClass('added')}})}
40addedToCart(e,response,hash,$button){this.updateFragments({fragments:response});this.onCartUpdate();$(document.body).trigger('xoo_wsc_cart_updated',[response]);var _this=this;this.flyToCart($button,function(){if(xoo_wsc_params.autoOpenCart==="yes"){setTimeout(function(){_this.openCart()},20)}})}
41flyToCart($atcEL,callback){var $basket=this.$modal.find('.xoo-wsc-basket').length?this.$modal.find('.xoo-wsc-basket'):$(document.body).find('.xoo-wsc-sc-cont');if(!$basket.length||xoo_wsc_params.flyToCart!=='yes'||!$atcEL||!$atcEL.length){callback();return}
42var customDragImgClass=xoo_wsc_params.productFlyClass,$dragIMG=null,$product=$atcEL.
42closest('.product');if($product.length){$product=$($product[0]);var $productGallery=$product.find('.woocommerce-product-gallery');if(customDragImgClass&&$product.find(customDragImgClass).length){$dragIMG=$product.find(customDragImgClass)}else if($product.find('img[data-xooWscFly="fly"]').length){if($productGallery.length){$dragIMG=$productGallery.find('.flex-active-slide img[data-xooWscFly="fly"]').length?$productGallery.find('.flex-active-slide img[data-xooWscFly="fly"]'):$productGallery.find('img[data-xooWscFly="fly"]')}else{$dragIMG=$product.find('img[data-xooWscFly="fly"]')}}else if($productGallery.length){$dragIMG=$productGallery}else{$dragIMG=$product}}else if(customDragImgClass){var moveUp=4;for(var i=moveUp;i>=0;i--){var $foundImg=$atcEL.parent().find(customDragImgClass);if($foundImg.length){$dragIMG=$foundImg;return!1}}}
43if(!$dragIMG||!$dragIMG.length){callback();return}
44$dragIMG=$dragIMG.eq(0);var $imgclone=$dragIMG.clone().offset({top:$dragIMG.offset().top,left:$dragIMG.offset().left}).addClass('xoo-wsc-fly-animating').appendTo($('body')).animate({'top':$basket.offset().top-20,'left':$basket.offset().left-20,'width':75,'height':75},parseInt(xoo_wsc_params.flyToCartTime),'easeInOutExpo');setTimeout(function(){callback()},parseInt(xoo_wsc_params.flyToCartTime));$imgclone.animate({'width':0,'height':0},function(){$(this).detach()})}
45toggleQty(e){var $toggler=$(e.currentTarget),$input=$toggler.siblings('.xoo-wsc-qty');if(!$input.length)return;var baseQty=this.baseQty=parseFloat($input.val()),step=parseFloat($input.attr('step')),action=$toggler.hasClass('xoo-wsc-plus')?'add':'less',newQty=action==='add'?baseQty+step:baseQty-step;$input.val(newQty).trigger('change')}
46changeInputQty(e){this.notice.hideNotification();var $_this=this,$input=$(e.currentTarget),newQty=parseFloat($input.val()),step=parseFloat($input.attr('step')),min=parseFloat($input.attr('min')),max=parseFloat($input.attr('max')),invalid=!1,message=!1;
46if(isNaN(newQty)||newQty<0||newQty<min){invalid=!0}else if(newQty>max){invalid=!0;message=xoo_wsc_params.strings.maxQtyError.replace('%s%',max)}else if((newQty%step)!==0){invalid=!0;message=xoo_wsc_params.strings.stepQtyError.replace('%s%',step)}
47if(invalid){$input.val(this.baseQty);if(message){this.notice.add(message,'error');this.notice.showNotification()}
48return}
49$input.val(newQty);clearTimeout(this.qtyUpdateDelay);this.qtyUpdateDelay=setTimeout(function(){$_this.updateItemQty($input.parents('.xoo-wsc-product').data('key'),newQty)},xoo_wsc_params.qtyUpdateDelay)}
50updateItemQty(cart_key,qty){if(!cart_key||qty===undefined)return;this.block();var bodyPosition=this.$modal.find('.xoo-wsc-body').length?this.$modal.find('.xoo-wsc-body').scrollTop():!1;var formData={cart_key:cart_key,qty:qty}
51$.ajax({url:get_wcurl('xoo_wsc_update_item_quantity'),type:'POST',context:this,data:this.setAjaxData(formData),success:function(response){this.updateFragments(response);$(document.body).trigger('xoo_wsc_quantity_updated',[response]);$(document.body).trigger('xoo_wsc_cart_updated',[response]);if(bodyPosition!==!1){this.$modal.find('.xoo-wsc-body').scrollTop(bodyPosition)}
52this.unblock()}})}
53closeCartOnClick(e){e.preventDefault();this.toggle('hide')}
54saveQtyFocus(e){this.baseQty=$(e.currentTarget).val()}
55onPageShow(e){if(e.originalEvent.persisted){this.refreshMyFragments();$(document.body).trigger('wc_fragment_refresh')}}
56deleteIconClick(e){this.updateItemQty($(e.currentTarget).parents('.xoo-wsc-product').data('key'),0)}
57undoItem(e){var $undo=$(e.currentTarget),formData={cart_key:$undo.data('key')}
58this.block();$.ajax({url:get_wcurl('xoo_wsc_undo_item'),type:'POST',context:this,data:this.setAjaxData(formData),success:function(response){this.updateFragments(response);$(document.body).trigger('xoo_wsc_item_restored',[response]);$(document.body).trigger('xoo_wsc_cart_updated',[response]);this.unblock()}})}
59storeShippingBarWidth(e){var $bar=$(document.body).find('.xoo-wsc-sb-bar > span');if(!$bar.length)return;this.shippingBarWidth=$bar.prop('style').width}
60onCartUpdate(){super.onCartUpdate();this.animateShippingBar();this.initSlider();this.showBasket()}
61showBasket(){var $basket=$('.xoo-wsc-basket'),show=xoo_wsc_params.showBasket;if(show==="always_show"){$basket.show()}else if(show==="hide_empty"){if(this.$modal.find('.xoo-wsc-product').length){$basket.show()}else{$basket.hide()}}else{$basket.hide()}}
62animateShippingBar(){if(isCartPage||isCheckoutPage)return;var $bar=$(document.body).find('.xoo-wsc-sb-bar > span');if(!$bar.length||!this.shippingBarWidth)return;var newWidth=$bar.prop('style').width;$bar.width(this.shippingBarWidth).animate({width:newWidth},400,'linear')}
63emptyCart(){this.block();$.ajax({url:get_wcurl('xoo_wsc_empty_cart'),type:'POST',context:this,data:{},success:function(response){this.updateFragments(response);$(document.body).trigger('xoo_wsc_cart_emptied');$(document.body).trigger('xoo_wsc_cart_updated',[response])},complete:function(){this.unblock()}})}
64initSlider(){if(!$.isFunction($.fn.lightSlider))return;$('ul.xoo-wsc-sp-slider').lightSlider({item:1,})}}
65class Slider extends Container{constructor($modal){super($modal,'slider');if(xoo_wsc_params.sliderAutoClose)this.noticeSection='cart';this.eventHandlers();this.shipping=xoo_wsc_params.shippingEnabled?Shipping.init(this):null}
66eventHandlers(){super.eventHandlers();$(document.body).on('click','.xoo-wsc-toggle-slider',this.triggerSlider.bind(this));$(document.body).on('xoo_wsc_cart_toggled',this.closeSliderOnCartClose.bind(this));if(xoo_wsc_params.sliderAutoClose){$(document.body).on('xoo_wsc_coupon_applied xoo_wsc_shipping_calculated updated_shipping_method xoo_wsc_coupon_removed',this.closeSlider.bind(this))}
67this.$modal.on('submit','form.xoo-wsc-sl-apply-coupon',this.submitCouponForm.bind(this));this.$modal.on('click','.xoo-wsc-coupon-apply-btn',this.applyCouponFromBtn.bind(this));$(document.body).on('click','.xoo-wsc-remove-coupon',this.removeCoupon.bind(this))}
68removeCoupon(e){e.preventDefault();var $removeEl=$(e.currentTarget),coupon=$removeEl.data('code'),formData={coupon:coupon};this.block();$.ajax({url:get_wcurl('xoo_wsc_remove_coupon'),type:'POST',context:this,data:this.setAjaxData(formData,cart.$modal.find($removeEl).length?'cart':'slider'),success:function(response){this.updateFragments(response)},complete:function(){this.unblock();this.updateCartCheckoutPage();$(document.body).trigger('xoo_wsc_coupon_removed')}})}
69onCartUpdate(){super.onCartUpdate();this.toggleContent()}
70closeSlider(){this.toggle('hide')}
71applyCouponFromBtn(e){this.applyCoupon($(e.currentTarget).val())}
72submitCouponForm(e){e.preventDefault();var $form=$(e.currentTarget);this.applyCoupon($form.find('input[name="xoo-wsc-slcf-input"]').val())}
73closeSliderOnCartClose(e){var $this=$(e.currentTarget);if(!cart.$modal.hasClass('xoo-wsc-cart-active')){this.toggle('hide')}}
74triggerSlider(e){var $toggler=$(e.currentTarget),slider=$toggler.data('slider');if(slider==='shipping'&&isCheckoutPage){this.notice.add(xoo_wsc_params.str
74ings.calculateCheckout,'error');this.notice.showNotification();return}
75this.$modal.attr('data-slider',slider);this.toggle();this.toggleContent()}
76toggleContent(){var activeSlider='';$('.xoo-wsc-sl-content').hide();var activeSlider=this.$modal.attr('data-slider'),$toggleEl=$('.xoo-wsc-sl-content[data-slider="'+activeSlider+'"]');if($toggleEl.length)$toggleEl.show();$(document.body).trigger('xoo_wsc_slider_data_toggled',[activeSlider])}
77applyCoupon(coupon){if(!coupon){this.notice.add(xoo_wsc_params.strings.couponEmpty,'error');this.notice.showNotification();return}
78this.block();var formData={'coupon':coupon,}
79$.ajax({url:get_wcurl('xoo_wsc_apply_coupon'),type:'POST',context:this,data:this.setAjaxData(formData),success:function(response){this.updateFragments(response)},complete:function(){this.unblock();this.updateCartCheckoutPage();$(document.body).trigger('xoo_wsc_coupon_applied')}})}}
80var Shipping={init:function(slider){slider.$modal.on('change','input.xoo-wsc-shipping-method',this.shippingMethodChange);slider.$modal.on('submit','form.woocommerce-shipping-calculator',this.shippingCalculatorSubmit);slider.$modal.on('click','.shipping-calculator-button',this.toggleCalculator);$(document.body).on('wc_fragments_refreshed wc_fragments_loaded xoo_wsc_slider_data_toggled',this.initSelect2)},toggleCalculator:function(e){e.preventDefault();e.stopImmediatePropagation();$(this).siblings('.shipping-calculator-form').slideToggle();$(document.body).trigger('country_to_state_changed')},shippingCalculatorSubmit:function(e){e.preventDefault();e.stopImmediatePropagation();var $form=$(this);slider.block();$('<input />').attr('type','hidden').attr('name','calc_shipping').attr('value','x').appendTo($form);var formData=$form.serialize();$.ajax({url:get_wcurl('xoo_wsc_calculate_shipping'),type:'POST',context:this,data:slider.setAjaxData(formData),success:function(response){slider.updateFragments(response)},complete:function(){slider.unblock();slider.updateCartCheckoutPage();$(document.body).trigger('xoo_wsc_shipping_calculated')}})},shippingMethodChange:function(e){e.preventDefault();e.stopImmediatePropagation();var shipping_methods={};slider.block();$('select.shipping_method, :input[name^=xoo-wsc-shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]').each(function(){shipping_methods[$(this).data('index')]=$(this).val()});var formData={shipping_method:shipping_methods,}
81$.ajax({type:'POST',url:get_wcurl('xoo_wsc_update_shipping_method'),data:slider.setAjaxData(formData),success:function(response){slider.updateFragments(response)},complete:function(){slider.unblock();slider.updateCartCheckoutPage();$(document.body).trigger('updated_shipping_method')}})},initSelect2:function(e){$(document.body).trigger('country_to_state_changed')},}
82var cart=new Cart($('.xoo-wsc-modal')),slider=new Slider($('.xoo-wsc-slider-modal'))})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.