PageSourceSearch

https://schoenmakerijhooijer.nl/wp-content/plugins/side-cart-woocommerce/assets/js/xoo-wsc-main.js?ver=2.4.5

js schoenmakerijhooijer.nl collected 2026-10-09 03:56:09 UTC 22,777 bytes, 937 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' ).add('html'),
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			}
118			else{
119				$activeEls.toggleClass(activeClass);
120			}
121
122			$(document.body).trigger( 'xoo_wsc_' + this.container + '_toggled', [ type ] );
123
124			this.notice.hideNotification();
125
126		}
127
128
129		block(){
130			this.$modal.addClass('xoo-wsc-loading');
131		}
132
133		unblock(){
134			this.$modal.removeClass('xoo-wsc-loading');
135		}
136
137
138		refreshMyFragments(){
139
140			if( xoo_wsc_params.refreshCart === "yes" && typeof wc_cart_fragments_params !== 'undefined' ){
141				$( document.body ).trigger( 'wc_fragment_refresh' );
142				return;
143			}
144
145			this.block();
146
147			$.ajax({
148				url: get_wcurl( 'xoo_wsc_refresh_fragments' ),
149				type: 'POST',
150				context: this,
151				data: {},
152				success: function( response ){
153					this.updateFragments(response);
154				},
155				complete: function(){
156					this.unblock();
157				}
158			})
159
160		}
161
162
163		updateCartCheckoutPage(){
164
165			//Refresh checkout page
166			if( isCheckoutPage ){
167				if( $( 'form.checkout' ).length === 0 ){
168					location.reload();
169					return;
170				}
171				$(document.body).trigger("update_checkout");
172			}
173
174			//Refresh Cart page
175			if( isCartPage ){
176				$(document.body).trigger("wc_update_cart");
177			}
178
179		}
180
181		updateFragments( response ){
182
183			console.log('updated');
184
185			if( response.fragments ){
186
187				$( document.body ).trigger( 'xoo_wsc_before_loading_fragments', [ response ] );
188
189				this.block();
190
191				//Set fragments
192		   		$.each( response.fragments, function( key, value ) {
193					$( key ).replaceWith( value );
194				});
195
196		   		if( typeof wc_cart_fragments_params !== 'undefined' && ( 'sessionStorage' in window && window.sessionStorage !== null ) ){
197
198		   			sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( response.fragments ) );
199					localStorage.setItem( wc_cart_fragments_params.cart_hash_key, response.cart_hash );
200					sessionStorage.setItem( wc_cart_fragments_params.cart_hash_key, response.cart_hash );
201
202					if ( response.cart_hash ) {
203						sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() );
204					}
205
206				}
207
208				$( document.body ).trigger( 'wc_fragments_refreshed' );
209
210				this.unblock();
211
212			}
213
214			if( xoo_wsc_params.refreshCart === "yes" && typeof wc_cart_fragments_params !== 'undefined' ){
215				this.block();
216				$( document.body ).trigger( 'wc_fragment_refresh' );
217				return;
218			}
219
220		}
221
222	}
223
224
225	class Cart extends Container{
226
227		constructor( $modal ){
228
229			super( $modal, 'cart' );
230
231			this.baseQty 		= 1;
232			this.qtyUpdateDelay = null;
233
234			this.refreshFragmentsOnPageLoad();
235			this.eventHandlers();
236			this.initSlider();
237
238		}
239
240
241		refreshFragmentsOnPageLoad(){
242			setTimeout(function(){
243				this.refreshMyFragments();
244			}.bind(this), xoo_wsc_params.fetchDelay )
245		}
246
247		eventHandlers(){
248
249			super.eventHandlers();
250
251			this.$modal.on( 'click', '.xoo-wsc-chng', this.toggleQty.bind(this) );
252			this.$modal.on( 'change', '.xoo-wsc-qty', this.changeInputQty.bind(this) );
253			this.$modal.on( 'click', '.xoo-wsc-undo-item', this.undoItem.bind(this) );
254			this.$modal.on( 'focusin', '.xoo-wsc-qty', this.saveQtyFocus.bind(this) );
255			this.$modal.on( 'click', '.xoo-wsc-smr-del', this.deleteIconClick.bind(this) );
256			this.$modal.on( 'click', '.xoo-wsch-close, .xoo-wsc-opac, .xoo-wsc-cart-close', this.closeCartOnClick.bind(this) );
257			this.$modal.on( 'click', '.xoo-wsc-basket', this.toggle.bind(this) );
258
259			$(document.body).on( 'xoo_wsc_cart_updated', this.updateCartCheckoutPage.bind(this) );
260			$(document.body).on( 'click', 'a.added_to_cart, .xoo-wsc-cart-trigger', this.openCart.bind(this) );
261			$(document.body).on( 'added_to_cart', this.addedToCart.bind(this) );
262
263			if( xoo_wsc_params.autoOpenCart === 'yes' && xoo_wsc_params.addedToCart === 'yes'){
264				this.openCart();
265			}
266
267			if( xoo_wsc_params.ajaxAddToCart === 'yes' ){
268				$(document.body).on( 'submit', 'form.cart', this.addToCartFormSubmit.bind(this) );
269			}
270
271			if( typeof wc_cart_fragments_params === 'undefined' ){
272				$( window ).on( 'pageshow' , this.onPageShow );
273			}
274
275			if( xoo_wsc_params.triggerClass ){
276				$(document.body).on( 'click', '.'+xoo_wsc_params.triggerClass, this.openCart.bind(this) );
277			}
278
279
280			if( isCheckoutPage || isCartPage ){
281				$(document.body).on( 'updated_shipping_method', this.refreshMyFragments.bind(this) );
282			}
283
284			//Animate shipping bar
285			$(document.body).on( 'xoo_wsc_before_loading_fragments', this.storeShippingBarWidth.bind(this) );
286
287		}
288
289
290		openCart(e){
291			if( e ){
292				e.preventDefault();
293				e.stopImmediatePropagation();
294			}
295			this.toggle('show');
296		}
297
298		addToCartFormSubmit(e){
299
300			var $form = $(e.currentTarget);
301
302			if( $form.closest('.product').hasClass('product-type-external') ) return;
303
304			e.preventDefault();
305
306			var $button  		= $form.find( 'button[type="submit"]'),
307				productData 	= $form.serializeArray(),
308				hasProductId 	= false;
309
310			//Check for woocommerce custom quantity code 
311			//https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/
312			$.each( productData, function( key, form_item ){
313				if( form_item.name === 'productID' || form_item.name === 'add-to-cart' ){
314					if( form_item.value ){
315						hasProductId = true;
316						return false;
317					}
318				}
319			})
320
321			//If no product id found , look for the form action URL
322			if( !hasProductId ){
323				var is_url = $form.attr('action').match(/add-to-cart=([0-9]+)/),
324					productID = is_url ? is_url[1] : false; 
325			}
326
327			// if button as name add-to-cart get it and add to form
328	        if( $button.attr('name') && $button.attr('name') == 'add-to-cart' && $button.attr('value') ){
329	            var productID = $button.attr('value');
330	        }
331
332	        if( productID ){
333	        	productData.push({name: 'add-to-cart', value: productID});
334	        }
335
336	        productData.push({name: 'action', value: 'xoo_wsc_add_to_cart'});
337
338			this.addToCartAjax( $button, productData );//Ajax add to cart
339		}
340
341
342		addToCartAjax( $button, productData ){
343
344			this.block();
345
346			$button.addClass('loading');
347
348			// Trigger event.
349			$( document.body ).trigger( 'adding_to_cart', [ $button, productData ] );
350
351			$.ajax({
352				url: get_wcurl( 'xoo_wsc_add_to_cart' ),
353				type: 'POST',
354				context: this,
355				data: $.param(productData),
356			    success: function(response){
357
358					if(response.fragments){
359						// Trigger event so themes can refresh other areas.
360						$( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $button ] );
361					}else{
362						window.location.reload();
363					}
364
365			    },
366			    complete: function(){
367			    	this.unblock();
368			    	$button
369			    		.removeClass('loading')
370			    		.addClass('added');
371			    }
372			})
373		}
374
375		addedToCart( e, response, hash, $button ){
376
377			this.updateFragments( { fragments: response } );
378
379			this.onCartUpdate();
380	
381			var _this = this;
382
383			this.flyToCart( $button, function(){
384				if( xoo_wsc_params.autoOpenCart === "yes" ){
385					setTimeout(function(){
386						_this.openCart();	
387					},20 )
388				}
389			} );
390		}
391
392
393		flyToCart( $atcEL, callback ){
394
395			var $basket = this.$modal.find('.xoo-wsc-basket').length ? this.$modal.find('.xoo-wsc-basket') : $(document.body).find('.xoo-wsc-sc-cont');
396
397			if( !$basket.length || xoo_wsc_params.flyToCart !== 'yes' ){
398				callback();
399				return;
400			}
401
402			var customDragImgClass 	= '',
403				$dragIMG 			= null,
404				$product 			= $atcEL.parents('.product');
405
406
407			//If has product container
408			if( $product.length ){
409
410				var $productGallery = $product.find('.woocommerce-product-gallery');
411
412				if( customDragImgClass && $product.find( customDragImgClass ).length ){
413					$dragIMG = $product.find( customDragImgClass );
414				}
415				else if( $product.find( 'img[data-xooWscFly="fly"]' ).length ){
416					if( $productGallery.length ){
417						$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"]' )
418					}
419					else{
420						$dragIMG = $product.find( 'img[data-xooWscFly="fly"]' );
421					}
422				}
423				else if( $productGallery.length ){
424					$dragIMG = $productGallery;
425				}
426				else{
427					$dragIMG = $product;
428				}
429
430			}
431			else if( customDragImgClass ){
432				var moveUp = 4;
433				for ( var i = moveUp; i >= 0; i-- ) {
434					var $foundImg = $atcEL.parent().find( customDragImgClass );
435					if( $foundImg.length ){
436						$dragIMG = $foundImg;
437						return false;
438					}
439				}
440			}
441
442
443			if( !$dragIMG || !$dragIMG.length ){
444				callback();
445				return;
446			}
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 - 10,
458		            'left': $basket.offset().left - 10,
459		            'width': 75,
460		            'height': 75
461		        }, 1000, 'easeInOutExpo' );
462	        
463	        setTimeout(function () {
464	        	callback()
465	        }, 1500 );
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		initSlider(){
663
664			if( !$.isFunction( $.fn.lightSlider ) ) return;
665
666			$('ul.xoo-wsc-sp-slider').lightSlider({
667				item: 1,
668			});
669			
670		}
671
672	}
673
674	
675
676	class Slider extends Container{
677
678		constructor( $modal ){
679
680			super( $modal, 'slider' );
681
682			if( xoo_wsc_params.sliderAutoClose ) this.noticeSection = 'cart';
683
684			this.eventHandlers();
685
686			this.shipping = xoo_wsc_params.shippingEnabled ? Shipping.init( this ) : null;
687		}
688
689		eventHandlers(){
690
691			super.eventHandlers();
692
693
694			$( document.body ).on( 'click', '.xoo-wsc-toggle-slider', this.triggerSlider.bind(this) );
695			$( document.body ).on( 'xoo_wsc_cart_toggled', this.closeSliderOnCartClose.bind(this) );
696
697			if( xoo_wsc_params.sliderAutoClose ){
698				$( document.body ).on( 'xoo_wsc_coupon_applied xoo_wsc_shipping_calculated updated_shipping_method xoo_wsc_coupon_removed', this.closeSlider.bind(this) );
699			}
700
701			this.$modal.on( 'submit', 'form.xoo-wsc-sl-apply-coupon', this.submitCouponForm.bind(this) );
702			this.$modal.on( 'click', '.xoo-wsc-coupon-apply-btn', this.applyCouponFromBtn.bind(this) );
703			$(document.body).on( 'click', '.xoo-wsc-remove-coupon', this.removeCoupon.bind(this) );
704		}
705
706
707		removeCoupon(e){
708
709			e.preventDefault();
710
711			var $removeEl 	= $(e.currentTarget),
712				coupon 		= $removeEl.data('code'),
713				formData 	= {
714					coupon: coupon,
715				};
716
717			this.block();	
718
719			$.ajax( {
720				url: get_wcurl( 'xoo_wsc_remove_coupon' ),
721				type: 'POST',
722				context: this,
723				data: this.setAjaxData( formData, cart.$modal.find( $removeEl ).length ? 'cart' : 'slider' ),
724				success: function( response ) {
725					this.updateFragments(response);
726				},
727				complete: function() {
728					this.unblock();
729					this.updateCartCheckoutPage();
730					$( document.body ).trigger( 'xoo_wsc_coupon_removed' );
731				}
732			} );
733		}
734
735		onCartUpdate(){
736			super.onCartUpdate();
737			this.toggleContent();
738		}
739
740		closeSlider(){
741			this.toggle('hide');
742		}
743
744
745		applyCouponFromBtn(e){
746			this.applyCoupon( $(e.currentTarget).val() );
747		}
748
749		submitCouponForm(e){
750
751			e.preventDefault();
752
753			var $form = $(e.currentTarget);
754
755			this.applyCoupon( $form.find('input[name="xoo-wsc-slcf-input"]').val() );
756
757		}
758
759
760		closeSliderOnCartClose(e){
761
762			var $this = $(e.currentTarget); 
763
764			if( !cart.$modal.hasClass('xoo-wsc-cart-active') ){
765				this.toggle('hide');
766			}
767
768		}
769
770
771		triggerSlider(e){
772
773			var $toggler 	= $(e.currentTarget),
774 				slider 		= $toggler.data('slider');
775
776			if( slider === 'shipping' && isCheckoutPage ){
777				this.notice.add( xoo_wsc_params.strings.calculateCheckout, 'error' );
778				this.notice.showNotification();
779				return;
780			}
781
782
783			this.$modal.attr( 'data-slider', slider );
784			
785			this.toggle();
786
787			this.toggleContent();
788		}
789
790
791		toggleContent(){
792
793			var activeSlider = '';
794
795			$('.xoo-wsc-sl-content').hide();
796			
797			var activeSlider 	= this.$modal.attr('data-slider'),
798				$toggleEl 		= $('.xoo-wsc-sl-content[data-slider="'+activeSlider+'"]');
799	
800			if( $toggleEl.length ) $toggleEl.show();
801
802			$( document.body ).trigger( 'xoo_wsc_slider_data_toggled', [activeSlider] );
803		}
804
805
806		applyCoupon( coupon ){
807
808			if( !coupon ){
809				this.notice.add( xoo_wsc_params.strings.couponEmpty, 'error' );
810				this.notice.showNotification();
811				return;
812			}
813
814			this.block();
815
816			var formData = {
817				'action': 'xoo_wsc_apply_coupon'
818			}
819
820			$.ajax( {
821				url: get_wcurl('xoo_wsc_apply_coupon'),
822				type: 'POST',
823				context: this,
824				data: this.setAjaxData( formData ),
825				success: function( response ) {
826					this.updateFragments(response);
827				},
828				complete: function() {
829					this.unblock();
830					this.updateCartCheckoutPage();
831					$( document.body ).trigger( 'xoo_wsc_coupon_applied' );
832				}
833			} );
834
835		}
836
837	}
838
839	
840
841	var Shipping = {
842
843		init: function( slider ){
844			slider.$modal.on( 'change', 'input.xoo-wsc-shipping-method', this.shippingMethodChange );
845			slider.$modal.on( 'submit', 'form.woocommerce-shipping-calculator', this.shippingCalculatorSubmit );
846			slider.$modal.on( 'click', '.shipping-calculator-button', this.toggleCalculator );
847			$(document.body).on( 'wc_fragments_refreshed wc_fragments_loaded xoo_wsc_slider_data_toggled', this.initSelect2 );
848		},
849
850		toggleCalculator: function(e){
851
852			e.preventDefault();
853			e.stopImmediatePropagation();
854
855			$(this).siblings('.shipping-calculator-form').slideToggle();
856			$( document.body ).trigger( 'country_to_state_changed' );
857		},
858
859		shippingCalculatorSubmit: function(e){
860
861			e.preventDefault();
862			e.stopImmediatePropagation();
863
864			var $form = $(this);
865
866			slider.block();
867
868			// Provide the submit button value because wc-form-handler expects it.
869			$( '<input />' )
870				.attr( 'type', 'hidden' )
871				.attr( 'name', 'calc_shipping' )
872				.attr( 'value', 'x' )
873				.appendTo( $form );
874
875			var formData = $form.serialize();
876
877			// Make call to actual form post URL.
878			$.ajax( {
879				url: get_wcurl( 'xoo_wsc_calculate_shipping' ),
880				type: 'POST',
881				context: this,
882				data: slider.setAjaxData(formData),
883				success: function( response ) {
884					slider.updateFragments(response);
885				},
886				complete: function() {
887					slider.unblock();
888					slider.updateCartCheckoutPage();
889					$( document.body ).trigger( 'xoo_wsc_shipping_calculated' );
890				}
891			} );
892
893		},
894
895		shippingMethodChange: function(e){
896
897			e.preventDefault();
898			e.stopImmediatePropagation();
899
900			var shipping_methods = {};
901
902			slider.block();
903
904			$( 'select.shipping_method, :input[name^=xoo-wsc-shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
905				shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
906			} );
907
908			var formData = {
909				shipping_method: shipping_methods
910			}
911
912			$.ajax( {
913				type:     'POST',
914				url:      get_wcurl( 'xoo_wsc_update_shipping_method' ),
915				data:     slider.setAjaxData( formData ),
916				success:  function( response ) {
917					slider.updateFragments(response);
918				},
919				complete: function() {
920					slider.unblock();
921					slider.updateCartCheckoutPage();
922					$( document.body ).trigger( 'updated_shipping_method' );
923				}
924			} );
925
926		},
927
928		initSelect2: function(e){
929			$( document.body ).trigger( 'country_to_state_changed' );
930		},
931	}
932
933
934	var cart 	= new Cart( $('.xoo-wsc-modal') ),
935		slider 	= new Slider( $('.xoo-wsc-slider-modal') );
936
937})

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.