PageSourceSearch

https://fioriecolori.it/wp-content/plugins/woocommerce-side-cart-premium/assets/js/xoo-wsc-main.js?ver=3.1

js fioriecolori.it collected 2026-10-05 23:46:15 UTC 23,397 bytes, 960 lines download raw bytes

1jQuery(document).ready(function($){
2
3	var isCartPage 		= xoo_wsc_params.isCart == '1',
4		isCheckoutPage 	= xoo_wsc_params.isCheckout == '1';
5
6	var get_wcurl = function( endpoint ) {
7		return xoo_wsc_params.wc_ajax_url.toString().replace(
8			'%%endpoint%%',
9			endpoint
10		);
11	};
12
13
14	class Notice{
15
16		constructor( $modal ){
17			this.$modal = $modal;
18			this.timeout = null;
19		}
20
21		add( notice, type = 'success', clearPrevious = true ){
22
23			var $noticeCont = this.$modal.find('.xoo-wsc-notice-container');
24
25			if( clearPrevious ){
26				$noticeCont.html('');
27			}
28
29			var noticeHTML = type === 'success' ? xoo_wsc_params.html.successNotice.toString().replace( '%s%', notice ) : xoo_wsc_params.html.errorNotice.toString().replace( '%s%', notice );
30
31			$noticeCont.html( noticeHTML );
32
33		}
34
35		showNotification(){
36
37			var $noticeCont = this.$modal.find('.xoo-wsc-notice-container');
38
39			if( !$noticeCont.length || $noticeCont.children().length === 0 ) return;
40
41			$noticeCont.slideDown();
42			
43			clearTimeout(this.timeout);
44
45			this.timeout = setTimeout(function(){
46				$noticeCont.slideUp('slow',function(){
47					//$noticeCont.html('');
48				});
49			},xoo_wsc_params.notificationTime )
50
51		}
52
53		hideNotification(){
54			this.$modal.find('.xoo-wsc-notice-container').hide();
55		}
56	}
57
58
59	class Container{
60
61		constructor( $modal, container ){
62			this.$modal 	= $modal;
63			this.container 	= container || 'cart';
64			this.notice 	= new Notice( this.$modal );
65		}
66
67		eventHandlers(){
68			$(document.body).on( 'wc_fragments_refreshed updated_checkout', this.onCartUpdate.bind(this) );
69		}
70
71		onCartUpdate(){
72			this.unblock();
73			this.notice.showNotification();
74		}
75
76		setAjaxData( data, noticeSection ){
77
78			var ajaxData = {
79				container: this.container,
80				noticeSection: noticeSection || this.noticeSection || this.container,
81				isCheckout: isCheckoutPage,
82				isCart: isCartPage
83			}
84
85
86			if( typeof data === 'object' ){
87
88				$.extend( ajaxData, data );
89
90			}
91			else{
92
93				var serializedData = data;
94
95				$.each( ajaxData, function( key, value ){
96					serializedData += ( '&'+key+'='+value );
97				} )
98		
99				ajaxData = serializedData;
100
101			}
102
103			return ajaxData;
104		}
105
106
107		toggle( type ){
108
109			var $activeEls 	= this.$modal.add( 'body' ),
110				activeClass = 'xoo-wsc-'+ this.container +'-active';
111
112			if( type === 'show' ){
113				$activeEls.addClass(activeClass);
114			}
115			else if( type === 'hide' ){
116				$activeEls.removeClass(activeClass);
117				this.notice.hideNotification();
118			}
119			else{
120				$activeEls.toggleClass(activeClass);
121			}
122
123			$(document.body).trigger( 'xoo_wsc_' + this.container + '_toggled', [ type ] );
124
125		}
126
127
128		block(){
129			this.$modal.addClass('xoo-wsc-loading');
130		}
131
132		unblock(){
133			this.$modal.removeClass('xoo-wsc-loading');
134		}
135
136
137		refreshMyFragments(){
138
139			if( xoo_wsc_params.refreshCart === "yes" && typeof wc_cart_fragments_params !== 'undefined' ){
140				$( document.body ).trigger( 'wc_fragment_refresh' );
141				return;
142			}
143
144			this.block();
145
146			$.ajax({
147				url: get_wcurl( 'xoo_wsc_refresh_fragments' ),
148				type: 'POST',
149				context: this,
150				data: {},
151				success: function( response ){
152					this.updateFragments(response);
153				},
154				complete: function(){
155					this.unblock();
156				}
157			})
158
159		}
160
161
162		updateCartCheckoutPage(){
163
164			//Refresh checkout page
165			if( isCheckoutPage ){
166				if( $( 'form.checkout' ).length === 0 ){
167					location.reload();
168					return;
169				}
170				$(document.body).trigger("update_checkout");
171			}
172
173			//Refresh Cart page
174			if( isCartPage ){
175				$(document.body).trigger("wc_update_cart");
176			}
177
178		}
179
180		updateFragments( response ){
181
182			if( response.fragments ){
183
184				$( document.body ).trigger( 'xoo_wsc_before_loading_fragments', [ response ] );
185
186				this.block();
187
188				//Set fragments
189		   		$.each( response.fragments, function( key, value ) {
190					$( key ).replaceWith( value );
191				});
192
193		   		if( typeof wc_cart_fragments_params !== 'undefined' && ( 'sessionStorage' in window && window.sessionStorage !== null ) ){
194
195		   			sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( response.fragments ) );
196					localStorage.setItem( wc_cart_fragments_params.cart_hash_key, response.cart_hash );
197					sessionStorage.setItem( wc_cart_fragments_params.cart_hash_key, response.cart_hash );
198
199					if ( response.cart_hash ) {
200						sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() );
201					}
202
203				}
204
205				$( document.body ).trigger( 'wc_fragments_refreshed' );
206
207				this.unblock();
208
209			}
210
211			if( xoo_wsc_params.refreshCart === "yes" && typeof wc_cart_fragments_params !== 'undefined' ){
212				this.block();
213				$( document.body ).trigger( 'wc_fragment_refresh' );
214				return;
215			}
216
217		}
218
219	}
220
221
222	class Cart extends Container{
223
224		constructor( $modal ){
225
226			super( $modal, 'cart' );
227
228			this.baseQty 		= 1;
229			this.qtyUpdateDelay = null;
230
231			this.refreshFragmentsOnPageLoad();
232			this.eventHandlers();
233			this.initSlider();
234
235		}
236
237
238		refreshFragmentsOnPageLoad(){
239			setTimeout(function(){
240				this.refreshMyFragments();
241			}.bind(this), xoo_wsc_params.fetchDelay )
242		}
243
244		eventHandlers(){
245
246			super.eventHandlers();
247
248			this.$modal.on( 'click', '.xoo-wsc-chng', this.toggleQty.bind(this) );
249			this.$modal.on( 'change', '.xoo-wsc-qty', this.changeInputQty.bind(this) );
250			this.$modal.on( 'click', '.xoo-wsc-undo-item', this.undoItem.bind(this) );
251			this.$modal.on( 'focusin', '.xoo-wsc-qty', this.saveQtyFocus.bind(this) );
252			this.$modal.on( 'click', '.xoo-wsc-smr-del', this.deleteIconClick.bind(this) );
253			this.$modal.on( 'click', '.xoo-wsch-close, .xoo-wsc-opac, .xoo-wsc-cart-close', this.closeCartOnClick.bind(this) );
254			this.$modal.on( 'click', '.xoo-wsc-basket', this.toggle.bind(this) );
255
256			$( document.body ).on( 'click', '.xoo-wsc-ecl', this.emptyCart.bind(this) );
257
258			$(document.body).on( 'xoo_wsc_cart_updated', this.updateCartCheckoutPage.bind(this) );
259			$(document.body).on( 'click', 'a.added_to_cart, .xoo-wsc-cart-trigger', this.openCart.bind(this) );
260			$(document.body).on( 'added_to_cart', this.addedToCart.bind(this) );
261
262			if( xoo_wsc_params.autoOpenCart === 'yes' && xoo_wsc_params.addedToCart === 'yes'){
263				this.openCart();
264			}
265
266			if( xoo_wsc_params.ajaxAddToCart === 'yes' ){
267				$(document.body).on( 'submit', 'form.cart', this.addToCartFormSubmit.bind(this) );
268			}
269
270			if( typeof wc_cart_fragments_params === 'undefined' ){
271				$( window ).on( 'pageshow' , this.onPageShow );
272			}
273
274
275			if( isCheckoutPage || isCartPage ){
276				$(document.body).on( 'updated_shipping_method', this.refreshMyFragments.bind(this) );
277			}
278
279			//Animate shipping bar
280			$(document.body).on( 'xoo_wsc_before_loading_fragments', this.storeShippingBarWidth.bind(this) );
281
282		}
283
284
285		openCart(e){
286			if( e ){
287				e.preventDefault();
288			}
289			this.toggle('show');
290		}
291
292		addToCartFormSubmit(e){
293
294			var $form = $(e.currentTarget);
295
296			if( $form.closest('.product').hasClass('product-type-external') ) return;
297
298			e.preventDefault();
299
300			var $button  		= $form.find( 'button[type="submit"]'),
301				productData 	= $form.serializeArray(),
302				hasProductId 	= false;
303
304			//Check for woocommerce custom quantity code 
305			//https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/
306			$.each( productData, function( key, form_item ){
307				if( form_item.name === 'productID' || form_item.name === 'add-to-cart' ){
308					if( form_item.value ){
309						hasProductId = true;
310						return false;
311					}
312				}
313			})
314
315			//If no product id found , look for the form action URL
316			if( !hasProductId && $form.attr('action') ){
317				var is_url = $form.attr('action').match(/add-to-cart=([0-9]+)/),
318					productID = is_url ? is_url[1] : false; 
319			}
320
321			// if button as name add-to-cart get it and add to form
322	        if( $button.attr('name') && $button.attr('name') == 'add-to-cart' && $button.attr('value') ){
323	            var productID = $button.attr('value');
324	        }
325
326	        if( productID ){
327	        	productData.push({name: 'add-to-cart', value: productID});
328	        }
329
330	        productData.push({name: 'action', value: 'xoo_wsc_add_to_cart'});
331
332			this.addToCartAjax( $button, productData );//Ajax add to cart
333		}
334
335
336		addToCartAjax( $button, productData ){
337
338			this.block();
339
340			$button.addClass('loading');
341
342			// Trigger event.
343			$( document.body ).trigger( 'adding_to_cart', [ $button, productData ] );
344
345			$.ajax({
346				url: get_wcurl( 'xoo_wsc_add_to_cart' ),
347				type: 'POST',
348				context: this,
349				data: $.param(productData),
350			    success: function(response){
351
352					if(response.fragments){
353						// Trigger event so themes can refresh other areas.
354						$( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $button ] );
355					}else{
356						window.location.reload();
357					}
358
359			    },
360			    complete: function(){
361			    	this.unblock();
362			    	$button
363			    		.removeClass('loading')
364			    		.addClass('added');
365			    }
366			})
367		}
368
369		addedToCart( e, response, hash, $button ){
370
371			this.updateFragments( { fragments: response } );
372
373			this.onCartUpdate();
374
375			$(document.body).trigger( 'xoo_wsc_cart_updated', [response] );
376	
377			var _this = this;
378
379			this.flyToCart( $button, function(){
380				if( xoo_wsc_params.autoOpenCart === "yes" ){
381					setTimeout(function(){
382						_this.openCart();	
383					},20 )
384				}
385			} );
386		}
387
388
389		flyToCart( $atcEL, callback ){
390
391			var $basket = this.$modal.find('.xoo-wsc-basket').length ? this.$modal.find('.xoo-wsc-basket') : $(document.body).find('.xoo-wsc-sc-cont');
392
393			if( !$basket.length || xoo_wsc_params.flyToCart !== 'yes' || !$atcEL || !$atcEL.length ){
394				callback();
395				return;
396			}
397
398			var customDragImgClass 	= xoo_wsc_params.productFlyClass,
399				$dragIMG 			= null,
400				$product 			= $atcEL.closest('.product');
401
402
403			//If has product container
404			if( $product.length ){
405
406				$product = $($product[0]);
407
408				var $productGallery = $product.find('.woocommerce-product-gallery');
409
410				if( customDragImgClass && $product.find( customDragImgClass ).length ){
411					$dragIMG = $product.find( customDragImgClass );
412				}
413				else if( $product.find( 'img[data-xooWscFly="fly"]' ).length ){
414					if( $productGallery.length ){
415						$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"]' )
416					}
417					else{
418						$dragIMG = $product.find( 'img[data-xooWscFly="fly"]' );
419					}
420				}
421				else if( $productGallery.length ){
422					$dragIMG = $productGallery;
423				}
424				else{
425					$dragIMG = $product;
426				}
427
428			}
429			else if( customDragImgClass ){
430				var moveUp = 4;
431				for ( var i = moveUp; i >= 0; i-- ) {
432					var $foundImg = $atcEL.parent().find( customDragImgClass );
433					if( $foundImg.length ){
434						$dragIMG = $foundImg;
435						return false;
436					}
437				}
438			}
439
440
441			if( !$dragIMG || !$dragIMG.length ){
442				callback();
443				return;
444			}
445
446			$dragIMG = $dragIMG.eq(0);
447
448			var $imgclone = $dragIMG
449				.clone()
450	    		.offset({
451		            top: $dragIMG.offset().top,
452		            left: $dragIMG.offset().left
453		        })
454	        	.addClass( 'xoo-wsc-fly-animating' )
455	            .appendTo( $('body') )
456	            .animate({
457	            	'top': $basket.offset().top - 20,
458		            'left': $basket.offset().left - 20,
459		            'width': 75,
460		            'height': 75
461		        }, parseInt( xoo_wsc_params.flyToCartTime ), 'easeInOutExpo' );
462	        
463	        setTimeout(function () {
464	        	callback()
465	        }, parseInt( xoo_wsc_params.flyToCartTime ) );
466
467	        $imgclone.animate({
468	        	'width': 0,
469	        	'height': 0
470	        }, function () {
471	        	$(this).detach();
472	        });
473
474		}
475
476
477		toggleQty(e){
478
479			var $toggler 	= $(e.currentTarget),
480				$input 		= $toggler.siblings('.xoo-wsc-qty');
481
482			if( !$input.length ) return;
483
484			var baseQty = this.baseQty = parseFloat( $input.val() ),
485				step 	= parseFloat( $input.attr('step') ),
486				action 	= $toggler.hasClass( 'xoo-wsc-plus' ) ? 'add' : 'less',
487				newQty 	= action === 'add' ? baseQty + step : baseQty - step;
488
489			
490			$input.val(newQty).trigger('change');
491
492		}
493
494		changeInputQty(e){
495
496			this.notice.hideNotification();
497
498			var $_this	= this,
499 				$input 	= $(e.currentTarget),
500				newQty 	= parseFloat( $input.val() ),
501				step 	= parseFloat( $input.attr('step') ),
502				min 	= parseFloat( $input.attr('min') ),
503				max 	= parseFloat( $input.attr('max') ),
504				invalid = false,
505				message = false;
506
507
508			//Validation
509			
510			if( isNaN( newQty )  || newQty < 0 || newQty < min  ){
511				invalid = true;
512			}
513			else if( newQty > max ){
514				invalid = true;
515				message = xoo_wsc_params.strings.maxQtyError.replace( '%s%', max );
516			}
517			else if( ( newQty % step ) !== 0 ){
518				invalid = true;
519				message = xoo_wsc_params.strings.stepQtyError.replace( '%s%', step );
520			}
521			
522			//Set back to default quantity
523			if( invalid ){
524				$input.val( this.baseQty );
525				if( message ){
526					this.notice.add( message, 'error' );
527					this.notice.showNotification();
528				}
529				return;
530			}
531
532			//Update
533			$input.val( newQty );
534
535			clearTimeout( this.qtyUpdateDelay );
536
537			this.qtyUpdateDelay = setTimeout(function(){
538				$_this.updateItemQty( $input.parents('.xoo-wsc-product').data('key'), newQty )
539			}, xoo_wsc_params.qtyUpdateDelay );
540			
541			
542		}
543
544		updateItemQty( cart_key, qty ){
545
546			if( !cart_key || qty === undefined ) return;
547
548			this.block();
549
550			var formData = {
551				cart_key: cart_key,
552				qty: qty
553			}
554
555			$.ajax({
556				url: get_wcurl( 'xoo_wsc_update_item_quantity' ),
557				type: 'POST',
558				context: this,
559				data: this.setAjaxData(formData),
560				success: function(response){
561					this.updateFragments( response );
562					$(document.body).trigger( 'xoo_wsc_quantity_updated', [response] );
563					$(document.body).trigger( 'xoo_wsc_cart_updated', [response] );
564					this.unblock();
565				}
566
567			})
568		}
569
570
571		closeCartOnClick(e){
572			e.preventDefault();
573			this.toggle( 'hide' );
574		}
575
576
577		saveQtyFocus(e){
578			this.baseQty = $(e.currentTarget).val();
579		}
580
581
582		onPageShow(e){
583			if ( e.originalEvent.persisted ) {
584				this.refreshMyFragments();
585				$( document.body ).trigger( 'wc_fragment_refresh' );
586			}
587		}
588
589		deleteIconClick(e){
590			this.updateItemQty( $( e.currentTarget ).parents('.xoo-wsc-product').data('key'), 0 );
591		}
592
593		undoItem(e){
594
595			var $undo 		= $(e.currentTarget),
596				formData 	= {
597					cart_key: $undo.data('key')
598				}
599
600			this.block();
601
602			$.ajax({
603				url: get_wcurl('xoo_wsc_undo_item'),
604				type: 'POST',
605				context: this,
606				data: this.setAjaxData(formData),
607				success: function(response){
608					this.updateFragments( response );
609					$(document.body).trigger( 'xoo_wsc_item_restored', [response] );
610					$(document.body).trigger( 'xoo_wsc_cart_updated', [response] );
611					this.unblock();
612				}
613
614			})
615		}
616
617		storeShippingBarWidth( e ){
618			var $bar = $(document.body).find( '.xoo-wsc-sb-bar > span' );
619			if( !$bar.length ) return;
620			this.shippingBarWidth = $bar.prop('style').width;
621		}
622
623		onCartUpdate(){
624			super.onCartUpdate();
625			this.animateShippingBar();
626			this.initSlider();
627			this.showBasket();
628		}
629
630		showBasket(){
631
632			var $basket = $('.xoo-wsc-basket'),
633				show 	= xoo_wsc_params.showBasket;
634
635			if( show === "always_show" ){
636				$basket.show();	
637			}
638			else if( show === "hide_empty" ){
639				if( this.$modal.find('.xoo-wsc-product').length ){
640					$basket.show();
641				}
642				else{
643					$basket.hide();
644				}
645			}
646			else{
647				$basket.hide();
648			}
649		}
650
651		animateShippingBar(){
652			if( isCartPage || isCheckoutPage ) return;
653			var $bar = $(document.body).find( '.xoo-wsc-sb-bar > span' );
654			if( !$bar.length || !this.shippingBarWidth ) return;
655			var newWidth = $bar.prop('style').width;
656			$bar
657				.width( this.shippingBarWidth )
658				.animate({ width: newWidth }, 400, 'linear')
659		}
660
661
662		emptyCart(){
663
664			this.block();
665
666			$.ajax({
667				url: get_wcurl( 'xoo_wsc_empty_cart' ),
668				type: 'POST',
669				context: this,
670				data: {},
671			    success: function(response){
672			    	
673					this.updateFragments( response );
674					// Trigger event.
675					$( document.body ).trigger( 'xoo_wsc_cart_emptied' );
676					$(document.body).trigger( 'xoo_wsc_cart_updated', [response] );
677			    },
678			    complete: function(){
679			    	this.unblock();
680			    }
681			})
682		}
683
684
685		initSlider(){
686
687			if( !$.isFunction( $.fn.lightSlider ) ) return;
688
689			$('ul.xoo-wsc-sp-slider').lightSlider({
690				item: 1,
691			});
692			
693		}
694
695	}
696
697	
698
699	class Slider extends Container{
700
701		constructor( $modal ){
702
703			super( $modal, 'slider' );
704
705			if( xoo_wsc_params.sliderAutoClose ) this.noticeSection = 'cart';
706
707			this.eventHandlers();
708
709			this.shipping = xoo_wsc_params.shippingEnabled ? Shipping.init( this ) : null;
710		}
711
712		eventHandlers(){
713
714			super.eventHandlers();
715
716
717			$( document.body ).on( 'click', '.xoo-wsc-toggle-slider', this.triggerSlider.bind(this) );
718			$( document.body ).on( 'xoo_wsc_cart_toggled', this.closeSliderOnCartClose.bind(this) );
719
720			if( xoo_wsc_params.sliderAutoClose ){
721				$( document.body ).on( 'xoo_wsc_coupon_applied xoo_wsc_shipping_calculated updated_shipping_method xoo_wsc_coupon_removed', this.closeSlider.bind(this) );
722			}
723
724			this.$modal.on( 'submit', 'form.xoo-wsc-sl-apply-coupon', this.submitCouponForm.bind(this) );
725			this.$modal.on( 'click', '.xoo-wsc-coupon-apply-btn', this.applyCouponFromBtn.bind(this) );
726			$(document.body).on( 'click', '.xoo-wsc-remove-coupon', this.removeCoupon.bind(this) );
727		}
728
729
730		removeCoupon(e){
731
732			e.preventDefault();
733
734			var $removeEl 	= $(e.currentTarget),
735				coupon 		= $removeEl.data('code'),
736				formData 	= {
737					coupon: coupon
738				};
739
740			this.block();	
741
742			$.ajax( {
743				url: get_wcurl( 'xoo_wsc_remove_coupon' ),
744				type: 'POST',
745				context: this,
746				data: this.setAjaxData( formData, cart.$modal.find( $removeEl ).length ? 'cart' : 'slider' ),
747				success: function( response ) {
748					this.updateFragments(response);
749				},
750				complete: function() {
751					this.unblock();
752					this.updateCartCheckoutPage();
753					$( document.body ).trigger( 'xoo_wsc_coupon_removed' );
754				}
755			} );
756		}
757
758		onCartUpdate(){
759			super.onCartUpdate();
760			this.toggleContent();
761		}
762
763		closeSlider(){
764			this.toggle('hide');
765		}
766
767
768		applyCouponFromBtn(e){
769			this.applyCoupon( $(e.currentTarget).val() );
770		}
771
772		submitCouponForm(e){
773
774			e.preventDefault();
775
776			var $form = $(e.currentTarget);
777
778			this.applyCoupon( $form.find('input[name="xoo-wsc-slcf-input"]').val() );
779
780		}
781
782
783		closeSliderOnCartClose(e){
784
785			var $this = $(e.currentTarget); 
786
787			if( !cart.$modal.hasClass('xoo-wsc-cart-active') ){
788				this.toggle('hide');
789			}
790
791		}
792
793
794		triggerSlider(e){
795
796			var $toggler 	= $(e.currentTarget),
797 				slider 		= $toggler.data('slider');
798
799			if( slider === 'shipping' && isCheckoutPage ){
800				this.notice.add( xoo_wsc_params.strings.calculateCheckout, 'error' );
801				this.notice.showNotification();
802				return;
803			}
804
805
806			this.$modal.attr( 'data-slider', slider );
807			
808			this.toggle();
809
810			this.toggleContent();
811		}
812
813
814		toggleContent(){
815
816			var activeSlider = '';
817
818			$('.xoo-wsc-sl-content').hide();
819			
820			var activeSlider 	= this.$modal.attr('data-slider'),
821				$toggleEl 		= $('.xoo-wsc-sl-content[data-slider="'+activeSlider+'"]');
822	
823			if( $toggleEl.length ) $toggleEl.show();
824
825			$( document.body ).trigger( 'xoo_wsc_slider_data_toggled', [activeSlider] );
826		}
827
828
829		applyCoupon( coupon ){
830
831			if( !coupon ){
832				this.notice.add( xoo_wsc_params.strings.couponEmpty, 'error' );
833				this.notice.showNotification();
834				return;
835			}
836
837			this.block();
838
839			var formData = {
840				'coupon': coupon,
841			}
842
843			$.ajax( {
844				url: get_wcurl('xoo_wsc_apply_coupon'),
845				type: 'POST',
846				context: this,
847				data: this.setAjaxData( formData ),
848				success: function( response ) {
849					this.updateFragments(response);
850				},
851				complete: function() {
852					this.unblock();
853					this.updateCartCheckoutPage();
854					$( document.body ).trigger( 'xoo_wsc_coupon_applied' );
855				}
856			} );
857
858		}
859
860	}
861
862	
863
864	var Shipping = {
865
866		init: function( slider ){
867			slider.$modal.on( 'change', 'input.xoo-wsc-shipping-method', this.shippingMethodChange );
868			slider.$modal.on( 'submit', 'form.woocommerce-shipping-calculator', this.shippingCalculatorSubmit );
869			slider.$modal.on( 'click', '.shipping-calculator-button', this.toggleCalculator );
870			$(document.body).on( 'wc_fragments_refreshed wc_fragments_loaded xoo_wsc_slider_data_toggled', this.initSelect2 );
871		},
872
873		toggleCalculator: function(e){
874
875			e.preventDefault();
876			e.stopImmediatePropagation();
877
878			$(this).siblings('.shipping-calculator-form').slideToggle();
879			$( document.body ).trigger( 'country_to_state_changed' );
880		},
881
882		shippingCalculatorSubmit: function(e){
883
884			e.preventDefault();
885			e.stopImmediatePropagation();
886
887			var $form = $(this);
888
889			slider.block();
890
891			// Provide the submit button value because wc-form-handler expects it.
892			$( '<input />' )
893				.attr( 'type', 'hidden' )
894				.attr( 'name', 'calc_shipping' )
895				.attr( 'value', 'x' )
896				.appendTo( $form );
897
898			var formData = $form.serialize();
899
900			// Make call to actual form post URL.
901			$.ajax( {
902				url: get_wcurl( 'xoo_wsc_calculate_shipping' ),
903				type: 'POST',
904				context: this,
905				data: slider.setAjaxData(formData),
906				success: function( response ) {
907					slider.updateFragments(response);
908				},
909				complete: function() {
910					slider.unblock();
911					slider.updateCartCheckoutPage();
912					$( document.body ).trigger( 'xoo_wsc_shipping_calculated' );
913				}
914			} );
915
916		},
917
918		shippingMethodChange: function(e){
919
920			e.preventDefault();
921			e.stopImmediatePropagation();
922
923			var shipping_methods = {};
924
925			slider.block();
926
927			$( 'select.shipping_method, :input[name^=xoo-wsc-shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
928				shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
929			} );
930
931			var formData = {
932				shipping_method: shipping_methods,
933			}
934
935			$.ajax( {
936				type:     'POST',
937				url:      get_wcurl( 'xoo_wsc_update_shipping_method' ),
938				data:     slider.setAjaxData( formData ),
939				success:  function( response ) {
940					slider.updateFragments(response);
941				},
942				complete: function() {
943					slider.unblock();
944					slider.updateCartCheckoutPage();
945					$( document.body ).trigger( 'updated_shipping_method' );
946				}
947			} );
948
949		},
950
951		initSelect2: function(e){
952			$( document.body ).trigger( 'country_to_state_changed' );
953		},
954	}
955
956
957	var cart 	= new Cart( $('.xoo-wsc-modal') ),
958		slider 	= new Slider( $('.xoo-wsc-slider-modal') );
959
960})

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.