PageSourceSearch

https://xkcolumbia.com/wp-content/plugins/car-wash-booking-system/script/jquery.cbs-plugin.js?ver=7.1.2

js xkcolumbia.com collected 2026-10-07 00:54:14 UTC 43,979 bytes, 1,354 lines download raw bytes

1/******************************************************************************/
2/******************************************************************************/
3
4;(function($,doc,win) 
5{
6	"use strict";
7	
8	/**************************************************************************/
9	
10	var CBSPlugin=function(object,option)
11	{
12		/**********************************************************************/
13		
14		var $self=this;
15		var $this=$(object);
16		var $option=option;
17		
18		var prevWidth=0;
19		
20		/**********************************************************************/
21
22		this.build=function() 
23		{
24			$this.find('.cbs-form-field').bind('click',function()
25			{
26				$(this).children(':input').focus();
27			});
28			
29			$self.prepare();
30		};
31		
32		/**********************************************************************/
33		/**********************************************************************/
34		
35		this.prepare=function()
36		{
37			$self.setWidthClass();
38			
39			$self.toogleServiceHeader(0);
40			
41			$this.on('click','.cbs-location-list>li',function(e)
42			{
43				e.preventDefault();
44				window.location.href=$(this).find('a.cbs-location-url').attr('href');
45			});
46			
47			$this.on('click','.cbs-scroll-to-next-step .cbs-vehicle-list>li, .cbs-scroll-to-next-step .cbs-package-list>li>.cbs-button-box>.cbs-button, .cbs-scroll-to-next-step table.cbs-calendar .cbs-calendar-data a:not(.cbs-calendar-data-button-more)',function(e) 
48			{
49				//exception: deselect package
50				if($(this).closest('ul.cbs-package-list').length && 
51					$(this).closest('li.cbs-state-selected').length)
52					return;
53				
54				var $nextStep = $(this).closest('.cbs-scroll-to-next-step')
55					.next('.cbs-main-list-item:not(.cbs-main-list-item-navigation-list)');
56				if($nextStep.length)
57					$.scrollTo($nextStep,{offset:-60});
58			});
59			
60			$this.on('change','.cbs-location-drop-down>select',function(e) 
61			{
62				e.preventDefault();
63				var value=$(this).attr('value');
64				if(value.length)
65					window.location.href=value;
66			});
67			
68			$this.on('click','.cbs-vehicle-list>li',function(e) 
69			{
70				e.preventDefault();
71				
72				$self.setButtonSelected(this,null,false,false);
73				
74				var vehicleId=$self.getSelectedVehicleList();
75				
76				$self.createPackage(vehicleId);
77				$self.createCalendar();
78			});
79			
80			$this.on('click','.cbs-package-list>li>.cbs-button-box>.cbs-button',function(e) 
81			{
82                if($(this).attr('href')=='#')
83                {
84                    e.preventDefault();
85
86                    $self.setButtonSelected($(this).parents('li:first'),null,true,false);
87
88                    var vehicleId=$self.getSelectedVehicleList();
89                    var packageId=$self.getSelectedPackageList();
90
91                    $self.toogleServiceHeader(packageId);
92
93                    $self.createService(vehicleId,packageId);
94                    $self.createCalendar();
95                }
96			});	
97			
98			$this.on('click','.cbs-service-list>li>.cbs-button-box>.cbs-button',function(e) 
99			{
100				e.preventDefault();
101				
102				$self.setButtonSelected($(this).parents('li:first'),null,true,true);
103				
104				var i=0;
105				var serviceId=[];
106				
107				$(this).parents('.cbs-service-list').children('li.cbs-state-selected').each(function()
108				{			
109					serviceId.push($self.getValueFromClass($(this),'cbs-service-id-'));
110				});
111				
112				var vehicleId=$self.getSelectedVehicleList();
113				var packageId=$self.getSelectedPackageList();
114				
115				$self.createCost(vehicleId,packageId,serviceId);
116				$self.createCalendar();
117			});	
118			
119			$this.on('click','.cbs-button-service-more',function(e) 
120			{
121				e.preventDefault();
122				$(this).prev('ul').toggleClass('cbs-state-to-hidden');
123				$(this).children('span').toggleClass('cbs-state-hidden');
124			});
125			
126			$this.on('click','.cbs-more-link',function(e) 
127			{
128				e.preventDefault();
129				$(this).parent().next().toggleClass('cbs-state-hidden');
130				$(this).children('span').toggleClass('cbs-state-hidden');
131			});
132			
133			$this.on('click','table.cbs-calendar .cbs-calendar-data a:not(.cbs-calendar-data-button-more)',function(e) 
134			{
135				e.preventDefault();
136				$self.setButtonSelected($(this).parent('li'),$(this).parents('.cbs-calendar-data').find('li'),true,false);
137				
138				var selected=$this.find('table.cbs-calendar .cbs-calendar-data li.cbs-state-selected');
139				
140				if(selected.length===1)
141				{
142					var index=selected.parents('td:first').index();
143					var date=$this.find('.cbs-calendar-subheader th:eq('+index+')').attr('data-date-full');
144
145					$this.find('.cbs-booking-summary-date h5 span:first').html(date);
146					$this.find('.cbs-booking-summary-time h5 span:first').html(selected.text());
147					
148					$this.find('.cbs-booking-summary-date h5 span+span').css({'display':'none'});
149					$this.find('.cbs-booking-summary-time h5 span+span').css({'display':'none'});
150				}
151				else
152				{
153					$this.find('.cbs-booking-summary-date h5 span:first').html('');
154					$this.find('.cbs-booking-summary-time h5 span:first').html('');	
155					
156					$this.find('.cbs-booking-summary-date h5 span+span').css({'display':'inline'});
157					$this.find('.cbs-booking-summary-time h5 span+span').css({'display':'inline'});
158				}
159			});	
160			
161			$this.on('click','table.cbs-calendar .cbs-calendar-data a.cbs-calendar-data-button-more',function(e) 
162			{
163				e.preventDefault();
164				$(this).parent('li').parent('ul').toggleClass('cbs-state-to-hidden');
165				$(this).children('span').toggleClass('cbs-state-hidden');
166			});
167			
168			$this.on('click','.cbs-main-list-item-navigation-list .cbs-button-section-prev',function(e) 
169			{
170				e.preventDefault();
171				
172				var $buttonPrev=$(this),
173					$buttonNext=$buttonPrev.next('.cbs-button'),
174					$activeSection=$('.cbs-main-list-item:not(.cbs-main-list-item-navigation-list):visible'),
175					$prevSection=$activeSection.prevAll('.cbs-main-list-item:not(.cbs-state-disable):first');
176				
177				if($prevSection.length)
178				{
179					$buttonNext.removeClass('cbs-state-hidden');
180					if($prevSection.hasClass('cbs-first-step'))
181						$buttonPrev.addClass('cbs-state-hidden');
182					
183					$activeSection.addClass('cbs-state-hidden');
184					$prevSection.removeClass('cbs-state-hidden');
185					$self.calculateCalendarColumnWidth();
186					$.scrollTo($prevSection,{offset:-120});
187				}
188			});
189			
190			$this.on('click','.cbs-main-list-item-navigation-list .cbs-button-section-next',function(e) 
191			{
192				e.preventDefault();
193				
194				var $buttonNext=$(this),
195					$buttonPrev=$buttonNext.prev('.cbs-button'),
196					$activeSection=$('.cbs-main-list-item:not(.cbs-main-list-item-navigation-list):visible'),
197					$nextSection=$activeSection.nextAll('.cbs-main-list-item:not(.cbs-state-disable):first');
198				
199				if($nextSection.length)
200				{
201					$buttonPrev.removeClass('cbs-state-hidden');
202					if($nextSection.hasClass('cbs-last-step'))
203						$buttonNext.addClass('cbs-state-hidden');
204					
205					$activeSection.addClass('cbs-state-hidden');
206					$nextSection.removeClass('cbs-state-hidden');
207					$self.calculateCalendarColumnWidth();
208					$.scrollTo($nextSection,{offset:-120});
209				}
210				
211			});
212			
213			$this.on('click','.cbs-form-checkbox',function(e)
214            {
215                var text=$(this).next('input[type="hidden"]');
216                var value=parseInt(text.val())===1 ? 0 : 1;
217                
218                if(value===1) $(this).addClass('cbs-state-selected');
219                else $(this).removeClass('cbs-state-selected');
220                
221                text.val(value).trigger('change');
222            });
223			
224			$this.children('form').bind('submit',function()
225			{
226				var data={};
227				
228				data.action='cbs_create_booking';
229				
230				data.locationId=$option.locationId;
231				
232				data.dateId=$self.getSelectedDateTime();
233				data.vehicleId=$self.getSelectedVehicleList();
234				data.packageId=$self.getSelectedPackageList();
235				data.serviceId=$self.getSelectedServiceList();
236				data.couponCode=$self.getCouponCode();
237				data.formAgreement=$self.getFormAgreement();
238				data.gratuity=$('.cbs-main-list-item-booking input[name="gratuity"]').val();
239				data.serviceLocation=$('.cbs-main-list-item-booking select[name="service_location"]').val();
240				
241				data.clientFirstName=$('.cbs-main-list-item-booking input[name="client_first_name"]').val();
242				data.clientSecondName=$('.cbs-main-list-item-booking input[name="client_second_name"]').val();
243				data.clientCompanyName=$('.cbs-main-list-item-booking input[name="client_company_name"]').val();
244				data.clientVehicle=$('.cbs-main-list-item-booking input[name="client_vehicle"]').val();
245				data.clientEmailAddress=$('.cbs-main-list-item-booking input[name="client_email_address"]').val();
246				data.clientPhoneNumber=$('.cbs-main-list-item-booking input[name="client_phone_number"]').val();
247				data.clientMessage=$('.cbs-main-list-item-booking textarea[name="client_message"]').val();
248				
249				data.clientAddressStreet=$('.cbs-main-list-item-booking input[name="client_address_street"]').val();
250				data.clientAddressPostCode=$('.cbs-main-list-item-booking input[name="client_address_post_code"]').val();
251				data.clientAddressCity=$('.cbs-main-list-item-booking input[name="client_address_city"]').val();
252				data.clientAddressState=$('.cbs-main-list-item-booking input[name="client_address_state"]').val();
253				data.clientAddressCountry=$('.cbs-main-list-item-booking input[name="client_address_country"]').val();
254				
255				data.registerUser=$('.cbs-register input[name="register_user"]').val();
256				data.username=$('.cbs-main-list-item-booking input[name="register_username"]').val();
257				data.password=$('.cbs-main-list-item-booking input[name="register_password"]').val();
258				data.passwordCheck=$('.cbs-main-list-item-booking input[name="register_password_check"]').val();
259				
260				data.paymentType=$('.cbs-main-list-item-booking select[name="payment_type"]').val();
261				
262				$self.post(data,$self.createBookingResponse);
263				
264				return(false);
265			});
266			
267			$this.on('click','.cbs-calendar-header-arrow-left',function(e)
268			{
269				var advancePeriod=parseInt($(this).attr('data-advance-period'));
270				$self.moveCalendar(e,-advancePeriod);
271			});
272			
273			$this.on('click','.cbs-calendar-header-arrow-right',function(e)
274			{
275				var advancePeriod=parseInt($(this).attr('data-advance-period'));
276				$self.moveCalendar(e,advancePeriod);
277			});
278			
279			$this.on('click','.cbs-calendar-header-month-arrow-left',function(e)
280			{
281				$self.moveCalendarMonth(e,-1);
282			});
283			
284			$this.on('click','.cbs-calendar-header-month-arrow-right',function(e)
285			{
286				$self.moveCalendarMonth(e,1);
287			});
288			
289			$this.on('change','.cbs-register input[name="register_user"]',function(e)
290			{
291				$('.cbs-main-list-item-booking .cbs-form-field-username').toggleClass('cbs-state-hidden');
292				$('.cbs-main-list-item-booking .cbs-form-field-password').toggleClass('cbs-state-hidden');
293				$('.cbs-main-list-item-booking .cbs-form-field-password-check').toggleClass('cbs-state-hidden');
294			});
295			
296			$this.on('click','.cbs-log-in',function(e)
297			{
298				e.preventDefault();
299				
300				var usernameOrEmail=$('.cbs-main-list-item-booking input[name="username_or_email"]').val();
301				var password=$('.cbs-main-list-item-booking input[name="password"]').val();
302				var vehicleId=$self.getSelectedVehicleList();
303				var packageId=$self.getSelectedPackageList();
304				
305				$self.createUserContactDetails(usernameOrEmail,password,vehicleId,packageId);
306			});
307			
308			$this.on('click','.cbs-create-login-form',function(e)
309			{
310				e.preventDefault();
311				
312				var notice=$('.cbs-notice-contact-details');
313				notice.css('display','none');
314				
315				if($('.cbs-main-list-item-contact-details .cbs-login-form').length)
316					return(false);
317				
318				$self.createLoginForm();
319			});
320			
321			$this.on('click','.cbs-create-contact-details-form',function(e)
322			{
323				e.preventDefault();
324				
325				var notice=$('.cbs-notice-contact-details');
326				notice.css('display','none');
327				
328				var vehicleId=$self.getSelectedVehicleList();
329				var packageId=$self.getSelectedPackageList();
330				
331				if($('.cbs-main-list-item-client-details .cbs-order-form').length)
332					return(false);
333				
334				$self.createContactDetailsForm(vehicleId,packageId);
335				
336			});
337			
338			$this.on('click', '.cbs-update-user-contact-details',function(e)
339			{
340				e.preventDefault();
341				
342				$self.updateUserContactDetails();
343			})
344			
345			$this.find('.cbs-to-tab').tabs({
346				beforeActivate: function(e,ui)
347				{
348					if($(ui.newTab).find('a[href*="user-log-out"]').length)
349					{
350						e.preventDefault();
351						$self.userLogOut();
352					}
353					
354				}
355			});
356			
357			$this.on('click','.cbs-coupon-code a.cbs-show-coupon',function(e)
358			{
359				e.preventDefault();
360				$this.find('input[type="text"],a.cbs-button-apply-coupon').css('display', 'inline-block');
361			});
362			
363			$this.on('click','.cbs-main-list-item-booking .cbs-coupon-code a.cbs-button-apply-coupon',function(e)
364			{
365				e.preventDefault();
366				$this.find('.cbs-main-list-item-booking .cbs-coupon-code div').hide();
367				
368				var serviceId=[];
369				
370				$('.cbs-service-list').children('li.cbs-state-selected').each(function()
371				{			
372					serviceId.push($self.getValueFromClass($(this),'cbs-service-id-'));
373				});
374				
375				var vehicleId=$self.getSelectedVehicleList();
376				var packageId=$self.getSelectedPackageList();	
377				var couponCode=$self.getCouponCode();
378				
379				$self.applyCoupon(vehicleId,packageId,serviceId,couponCode);
380			});
381		};
382		
383		/**********************************************************************/
384		
385		this.toogleServiceHeader=function(packageId)
386		{			
387			if($this.hasClass('cbs-location-content-type-3'))
388			{
389				var header=$this.find('.cbs-main-list-item-service-list .cbs-main-list-item-section-header-header');
390				var subheader=$this.find('.cbs-main-list-item-service-list .cbs-main-list-item-section-header-subheader');
391					
392				var element=[header.find('span:eq(0)'),header.find('span:eq(1)'),subheader.find('span:eq(0)'),subheader.find('span:eq(1)')];
393					
394				if(packageId===0)
395				{
396					element[0].removeClass('cbs-state-hidden');
397					element[2].removeClass('cbs-state-hidden');
398					
399					element[1].addClass('cbs-state-hidden');
400					element[3].addClass('cbs-state-hidden');
401				}
402				else
403				{
404					element[1].removeClass('cbs-state-hidden');
405					element[3].removeClass('cbs-state-hidden');
406					
407					element[0].addClass('cbs-state-hidden');
408					element[2].addClass('cbs-state-hidden');				
409				}
410			}	
411		};
412		
413		/**********************************************************************/
414		
415		this.createBookingResponse=function(response)
416		{
417			var notice=$('.cbs-notice-main');
418			var noticeIcon=notice.children('.cbs-notice-icon');
419			
420			notice.removeClass('cbs-notice-error cbs-notice-success');
421			noticeIcon.removeClass('cbs-meta-icon-error cbs-meta-icon-success');
422			
423			if(response.error===0) 
424			{	
425				notice.addClass('cbs-notice-success');
426				noticeIcon.addClass('cbs-meta-icon-success');
427			}
428			else 
429			{	
430				notice.addClass('cbs-notice-error');
431				noticeIcon.addClass('cbs-meta-icon-error');
432			}
433
434			notice.find('.cbs-notice-text').html(response.notice.text);
435			notice.find('.cbs-notice-header').html(response.notice.header);
436			
437			notice.css('display','block');
438			
439			
440			if((parseInt(response.error)===0) && (parseInt(response.reset)===1)) 
441			{
442				if($('#cbs-user-details').length)
443				{
444					$this.find('.cbs-main-list-item-booking #cbs-current-order input[name="client_first_name"]').val($this.find('.cbs-main-list-item-booking #cbs-user-details input[name="update_client_first_name"]').val());
445					$this.find('.cbs-main-list-item-booking #cbs-current-order input[name="client_second_name"]').val($this.find('.cbs-main-list-item-booking #cbs-user-details input[name="update_client_second_name"]').val());
446					$this.find('.cbs-main-list-item-booking #cbs-current-order input[name="client_company_name"]').val($this.find('.cbs-main-list-item-booking #cbs-user-details input[name="update_client_company_name"]').val());
447					$this.find('.cbs-main-list-item-booking #cbs-current-order input[name="client_vehicle"]').val($this.find('.cbs-main-list-item-booking #cbs-user-details input[name="update_client_vehicle"]').val());
448					$this.find('.cbs-main-list-item-booking #cbs-current-order input[name="client_email_address"]').val($this.find('.cbs-main-list-item-booking #cbs-user-details input[name="update_client_email_address"]').val());
449					$this.find('.cbs-main-list-item-booking #cbs-current-order input[name="client_phone_number"]').val($this.find('.cbs-main-list-item-booking #cbs-user-details input[name="update_client_phone_number"]').val());
450					$this.find('.cbs-main-list-item-booking #cbs-current-order textarea[name="client_message"]').val('');
451				}
452				else
453				{
454					$this.find('.cbs-main-list-item-booking').find('input[type="password"],input[type="text"],textarea').val('') 
455					$this.find('.cbs-main-list-item-booking').find('input[type="checkbox"]').prop('checked',false);
456				}
457				
458				$this.find('.cbs-vehicle-list>li:first-child').trigger('click');
459				$self.createCalendar(0);
460				$self.toogleServiceHeader();
461			}
462			
463			$.scrollTo($this,{offset:-120});
464			
465			if(parseInt(response.error,10)===0)
466			{
467				switch(response.payment_type)
468				{
469					case 'cash':
470						
471						if(typeof(response.thank_you_page_url_address)!=='undefined')
472							window.location.href=response.thank_you_page_url_address;
473		
474					break;
475
476					case 'paypal':
477
478						var form=$this.find('form[name="cbs-form-paypal"]');
479						
480						for(var i in response.form)
481							form.find('input[name="'+i+'"]').val(response.form[i]);
482
483						$this.find('form[name="cbs-form-paypal"]')[0].submit();
484
485					break;
486
487					case 'stripe':
488
489						$.getScript('https://js.stripe.com/v3/',function() 
490						{								
491							var stripe=Stripe(response.stripe_publishable_key);
492
493							stripe.redirectToCheckout(
494							{
495								sessionId:response.stripe_session_id
496							}).then(function(result) 
497							{
498
499							});
500						});
501
502					break;
503
504					case 'woocommerce':
505
506						window.location.href=response.woocommerce_checkout_url;
507
508					break;					
509
510					default:
511				}
512			}
513		};
514		
515		/**********************************************************************/
516		
517		this.moveCalendar=function(event,step)
518		{
519			event.preventDefault();
520			
521			var calendarBox=$this.find('.cbs-calendar-table-wrapper');
522			var calendar=calendarBox.find('.cbs-calendar');
523			var columnActive=Math.abs($('th.cbs-active').index());
524			var visibleColumns=parseInt($this.find('input[name="cbs-calendar-column-count"]').val());
525			var hiddenColumns;
526			var calendarStep;
527			var activeColumnStep;
528			
529			if(Math.abs(step)<=visibleColumns)
530				calendarStep=step;
531			else
532				calendarStep=(step>0 ? visibleColumns : -visibleColumns);
533			
534			if(calendarStep>0)
535			{
536				if($self.isVisibleColumn('last'))
537				{
538					$self.createCalendar(calendarStep);
539					return;
540				}
541			}
542			else
543			{
544				if($self.isVisibleColumn('first'))
545				{
546					$self.createCalendar(calendarStep);
547					return;
548				}
549			}
550			
551			if((columnActive===6) && (calendarStep>0)) return;
552			if((columnActive===0) && (calendarStep<0)) return;
553			
554			if(calendarStep>0)
555			{
556				//count the number of hidden columns on the right side
557				hiddenColumns=7-calendar.find('th:visible:last').index()-1;
558			}
559			else
560			{
561				//count the number of hidden columns on the left side
562				hiddenColumns=calendar.find('th:visible:first').index();
563			}
564			
565			if(Math.abs(calendarStep)>hiddenColumns)
566				activeColumnStep=(calendarStep>0 ? hiddenColumns : -hiddenColumns);
567			else
568				activeColumnStep=calendarStep;
569
570			columnActive+=activeColumnStep;
571			
572			calendar.find('th').removeClass('cbs-active');
573			calendar.find('th:eq('+columnActive+')').addClass('cbs-active');
574			
575			$self.hideCalendarColumn();
576		};
577		
578		/**********************************************************************/
579		
580		this.moveCalendarMonth=function(event,step)
581		{
582			event.preventDefault();
583			
584			$self.createCalendarMonth(step);
585			return;
586		};
587		
588		/**********************************************************************/
589		
590		this.hideCalendarColumn=function()
591		{
592			var j=0,tag=['th','td'];
593			var calendarBox=$this.find('.cbs-calendar-table-wrapper');
594			var calendar=calendarBox.find('.cbs-calendar');
595			
596			var columnActive=calendar.find('th.cbs-active').index();
597			var columnCount=parseInt($this.find('input[name="cbs-calendar-column-count"]').val());
598			
599			$(tag).each(function(i)
600			{
601				calendar.find(tag[i]).css('display','none');
602				
603				for(j=columnActive;j<(columnActive+columnCount);j++)
604					calendar.find(tag[i]+':eq('+j+')').css('display','table-cell');
605			});
606			
607			$self.manageCalendarHeader();
608		};
609		
610		/**********************************************************************/
611		
612		this.isVisibleColumn=function(number)
613		{
614			var calendarBox=$this.find('.cbs-calendar-table-wrapper');
615			var calendar=calendarBox.find('.cbs-calendar');
616			
617			if((calendar.find('th:first').css('display')!=='none') && (number==='first')) return(true);
618			if((calendar.find('th:last').css('display')!=='none') && (number==='last')) return(true);
619			
620			return(false);
621		};
622		
623		/**********************************************************************/
624		/**********************************************************************/
625		
626		this.getSelectedVehicleList=function()
627		{
628			var list=$this.find('.cbs-vehicle-list>li.cbs-state-selected');
629			
630			if(list.length!==1) return(0);
631			
632			return($self.getValueFromClass(list[0],'cbs-vehicle-id-'));
633		};
634		
635		/**********************************************************************/
636		
637		this.getSelectedPackageList=function()
638		{
639			var list=$this.find('.cbs-package-list>li.cbs-state-selected');
640			
641			if(list.length!==1) return(0);
642			
643			return($self.getValueFromClass(list[0],'cbs-package-id-'));
644		};
645		
646		/**********************************************************************/
647		
648		this.getSelectedServiceList=function()
649		{
650			var data=[];
651			
652			var list=$this.find('.cbs-service-list>li.cbs-state-selected');
653			
654			list.each(function()
655			{
656				data.push($self.getValueFromClass($(this),'cbs-service-id-'));
657			});
658			
659			return(data);
660		};	
661		
662		/**********************************************************************/
663		
664		this.getSelectedDateTime=function()
665		{
666			var list=$this.find('.cbs-date-list>li.cbs-state-selected');
667			
668			if(list.length!==1) return('');
669			
670			return($self.getValueFromClass(list[0],'cbs-date-id-'));			
671		};
672		
673		/**********************************************************************/
674		
675		this.getCouponCode=function()
676		{
677			var coupon=$('.cbs-main-list-item-booking input[name="coupon_code"]');
678			
679			if(coupon.length)
680				return(coupon.val());
681			else
682				return('');			
683		};
684		
685		/**********************************************************************/
686		
687		this.getFormAgreement=function()
688		{
689			var data={};
690			
691			var formAgreement=$('.cbs-agreement input[name^="form_agreement_"]');
692			formAgreement.each(function()
693			{
694				data[$(this).attr('name')]=$(this).val();
695			});
696			
697			return(data);
698		};
699		
700		/**********************************************************************/
701		/**********************************************************************/
702		
703		this.createPackage=function(vehicleId)
704		{
705			var data={};
706			
707			data.action=$this.hasClass('cbs-template-public') ? 'cbs_create_package' : 'cbs_create_vehicle_package';
708			
709			data.vehicleId=vehicleId;
710			data.locationId=$option.locationId;
711			
712            data.packageButtonURL=$this.data('package-button-url');
713            
714			$self.post(data,function(response)
715			{
716				$self.createPackageResponse(response);
717			});
718		};
719		
720		/**********************************************************************/
721		
722		this.createPackageResponse=function(response)
723		{
724			var serviceListItem=$this.find('.cbs-main-list-item-service-list');
725			var packageListItem=$this.find('.cbs-main-list-item-package-list');
726			
727			serviceListItem.removeClass('cbs-state-disable');
728			if(!response.serviceCount) serviceListItem.addClass('cbs-state-disable');
729			
730			packageListItem.removeClass('cbs-state-disable');
731			if(!response.packageCount) packageListItem.addClass('cbs-state-disable');
732			
733			packageListItem.children('.cbs-main-list-item-section-content').html(response.package);
734			serviceListItem.children('.cbs-main-list-item-section-content').html(response.service);
735			
736			$this.find('.cbs-booking-summary-date h5 span:first').html('');
737			$this.find('.cbs-booking-summary-date h5 span+span').css({'display':'block'});
738			$this.find('.cbs-booking-summary-time h5 span:first').html('');
739			$this.find('.cbs-booking-summary-time h5 span+span').css({'display':'block'});
740			$this.find('.cbs-booking-summary-duration>h5>span:eq(0)').html('0');
741			$this.find('.cbs-booking-summary-duration>h5>span:eq(2)').html('0');
742			$this.find('.cbs-booking-summary-price>h5>span.cbs-booking-summary-price-value').html('0.00');
743			$('.cbs-main-list-item-booking input[name="coupon_code"]').val('').trigger('blur');
744		};
745		
746		/**********************************************************************/
747		/**********************************************************************/
748		
749		this.createCalendar=function(step)
750		{
751            if($this.find('.cbs-main-list-item-calendar').length!==1) return;
752            
753			var data={};
754			
755			data.action='cbs_create_calendar';
756			
757			data.step=step;
758			data.locationId=$option.locationId;
759
760			data.packageId=$self.getSelectedPackageList();
761			data.serviceId=$self.getSelectedServiceList();
762			data.vehicleId=$self.getSelectedVehicleList();
763			
764			data.startDate=$self.getValueFromClass($this.find('.cbs-calendar .cbs-calendar-subheader th.cbs-active'),'cbs-date-id-');
765			
766			$self.post(data,function(response)
767			{
768				$self.createCalendarResponse(response);
769			});					
770		};
771		
772		/**********************************************************************/
773		
774		this.createCalendarResponse=function(response)
775		{
776			if(response.error===1) return; 
777			
778			$this.find('.cbs-booking-summary-date h5 span:first').html('');
779			$this.find('.cbs-booking-summary-time h5 span:first').html('');
780					
781			$this.find('.cbs-booking-summary-date h5 span+span').css({'display':'block'});
782			$this.find('.cbs-booking-summary-time h5 span+span').css({'display':'block'});
783			
784			$this.find('.cbs-main-list-item-calendar .cbs-main-list-item-section-content').html(response.calendar);
785			$self.calculateCalendarColumnWidth();
786		};
787		
788		/**********************************************************************/
789		
790		this.createCalendarMonth=function(step)
791		{
792            if($this.find('.cbs-main-list-item-calendar').length!==1) return;
793            
794			var data={};
795			
796			data.action='cbs_create_calendar_month';
797			
798			data.step=step;
799			data.locationId=$option.locationId;
800
801			data.packageId=$self.getSelectedPackageList();
802			data.serviceId=$self.getSelectedServiceList();
803			data.vehicleId=$self.getSelectedVehicleList();
804			
805			data.startDate=$self.getValueFromClass($this.find('.cbs-calendar .cbs-calendar-subheader th.cbs-active'),'cbs-date-id-');
806			
807			$self.post(data,function(response)
808			{
809				$self.createCalendarMonthResponse(response);
810			});					
811		};
812		
813		/**********************************************************************/
814		
815		this.createCalendarMonthResponse=function(response)
816		{
817			if(response.error===1) return; 
818			
819			$this.find('.cbs-booking-summary-date h5 span:first').html('');
820			$this.find('.cbs-booking-summary-time h5 span:first').html('');
821					
822			$this.find('.cbs-booking-summary-date h5 span+span').css({'display':'block'});
823			$this.find('.cbs-booking-summary-time h5 span+span').css({'display':'block'});
824			
825			$this.find('.cbs-main-list-item-calendar .cbs-main-list-item-section-content').html(response.calendar);
826			$self.calculateCalendarColumnWidth();
827		};
828		
829		/**********************************************************************/
830		/**********************************************************************/		
831		
832		this.createCost=function(vehicleId,packageId,serviceId)
833		{
834			var data={};
835			
836			data.action='cbs_create_cost';
837			
838			data.vehicleId=vehicleId;
839			data.packageId=packageId;
840			data.serviceId=serviceId.join('.');
841			data.locationId=$option.locationId;
842			
843			$self.post(data,function(response)
844			{
845				$self.createCostResponse(response);
846			});		
847		};
848		
849		/**********************************************************************/
850		
851		this.createCostResponse=function(response)
852		{
853			$self.displayDuration(response.cost.duration_unit,response.cost.duration.hour,response.cost.duration.minute);	
854			
855			$this.find('.cbs-booking-summary-price>h5>span.cbs-booking-summary-price-value').html(response.cost.price.unit+'.'+response.cost.price.decimal);
856			
857			$('.cbs-main-list-item-booking input[name="coupon_code"]').val('').trigger('blur');
858		};
859		
860		/**********************************************************************/
861		
862		this.displayDuration=function(unit,hour,minute)
863		{
864			if(parseInt(unit,10)===1)
865			{
866				$this.find('.cbs-booking-summary-duration>h5>span:eq(2),.cbs-booking-summary-duration>h5>span:eq(3)').removeClass('cbs-hidden');
867				$this.find('.cbs-booking-summary-duration>h5>span:eq(0)').html(hour);
868				$this.find('.cbs-booking-summary-duration>h5>span:eq(2)').html(minute);
869			}
870			else
871			{
872				if(parseInt(minute,10)===0)
873				{
874					$this.find('.cbs-booking-summary-duration>h5>span:eq(2),.cbs-booking-summary-duration>h5>span:eq(3)').addClass('cbs-hidden');
875					$this.find('.cbs-booking-summary-duration>h5>span:eq(0)').html(hour);
876				}
877				else
878				{
879					$this.find('.cbs-booking-summary-duration>h5>span:eq(2),.cbs-booking-summary-duration>h5>span:eq(3)').removeClass('cbs-hidden');
880					$this.find('.cbs-booking-summary-duration>h5>span:eq(0)').html(hour);
881					$this.find('.cbs-booking-summary-duration>h5>span:eq(2)').html(minute);				
882				}
883			}			
884		};
885		
886		/**********************************************************************/
887		/**********************************************************************/
888		
889		this.createUserContactDetails=function(usernameOrEmail,password,vehicleId,packageId)
890		{
891			var data={};
892			
893			data.action='cbs_create_user_contact_details';
894			
895			data.usernameOrEmail=usernameOrEmail;
896			data.password=password;
897			data.vehicleId=vehicleId;
898			data.packageId=packageId;
899			data.locationId=$option.locationId;
900			
901			$self.post(data,function(response)
902			{
903				$self.createUserContactDetailsResponse(response);
904			});
905		};
906		
907		/**********************************************************************/
908		
909		this.createUserContactDetailsResponse=function(response)
910		{
911			var notice=$('.cbs-notice-contact-details');
912			var noticeIcon=notice.children('.cbs-notice-icon');
913			
914			notice.removeClass('cbs-notice-error cbs-notice-success');
915			noticeIcon.removeClass('cbs-meta-icon-error cbs-meta-icon-success');
916			
917			if(response.error===0)
918			{
919				$('.cbs-main-list-item-contact-details').html(response.client_details);
920				
921				$('.cbs-main-list-item-contact-details .cbs-to-tab').tabs({
922				beforeActivate: function(e,ui)
923				{
924					if($(ui.newTab).find('a[href*="user-log-out"]').length)
925					{
926						e.preventDefault();
927						$self.userLogOut();
928					}
929				}
930			});
931				
932				$('.cbs-create-login-form').parent().addClass('cbs-state-hidden');
933				notice.addClass('cbs-notice-success');
934				noticeIcon.addClass('cbs-meta-icon-success');
935			}
936			else
937			{
938				notice.addClass('cbs-notice-error');
939				noticeIcon.addClass('cbs-meta-icon-error');
940			}
941			
942			notice.find('.cbs-notice-header').html(response.header);
943			notice.find('.cbs-notice-text').html(response.message);
944			
945			notice.css('display','block');
946		};
947		
948		/**********************************************************************/
949		
950		this.userLogOut=function()
951		{
952			var data={};
953			data.action='cbs_user_log_out';
954			$self.post(data,function(response)
955			{
956				$self.userLogOutResponse(response);
957			});
958		};
959		
960		/**********************************************************************/
961		
962		this.userLogOutResponse=function(response)
963		{
964			var notice=$('.cbs-notice-contact-details');
965			var noticeIcon=notice.children('.cbs-notice-icon');
966			
967			notice.removeClass('cbs-notice-error cbs-notice-success');
968			noticeIcon.removeClass('cbs-meta-icon-error cbs-meta-icon-success');
969			
970			notice.addClass('cbs-notice-success');
971			noticeIcon.addClass('cbs-meta-icon-success');
972			
973			notice.find('.cbs-notice-header').html(response.header);
974			notice.find('.cbs-notice-text').html(response.message);
975			
976			$('.cbs-main-list-item-contact-details').html('');
977			$('.cbs-create-login-form').parent().removeClass('cbs-state-hidden');
978		};
979		
980		/**********************************************************************/
981		
982		this.createLoginForm=function()
983		{
984			var data={};
985			
986			data.action='cbs_create_login_form';
987			
988			$self.post(data,function(response)
989			{
990				$self.createLoginFormResponse(response);
991			});
992		};
993		
994		/**********************************************************************/
995		
996		this.createLoginFormResponse=function(response)
997		{
998			if(response.error===0)
999			{
1000				$('.cbs-main-list-item-contact-details').html(response.login_form);
1001			}
1002		};
1003		
1004		/**********************************************************************/
1005		
1006		this.createContactDetailsForm=function(vehicleId,packageId)
1007		{
1008			var data={};
1009			
1010			data.action='cbs_create_contact_details_form';
1011			
1012			data.vehicleId=vehicleId;
1013			data.packageId=packageId;
1014			data.locationId=$option.locationId;
1015			
1016			$self.post(data,function(response)
1017			{
1018				$self.createContactDetailsFormResponse(response);
1019			});
1020		};
1021		
1022		/**********************************************************************/
1023		
1024		this.createContactDetailsFormResponse=function(response)
1025		{
1026			if(response.error===0)
1027			{
1028				$('.cbs-main-list-item-contact-details').html(response.order_form);
1029			}
1030		};
1031		
1032		/**********************************************************************/
1033		
1034		this.updateUserContactDetails=function()
1035		{
1036			var data={};
1037			
1038			data.action='cbs_update_user_contact_details';
1039			
1040			data.updateClientFirstName=$('.cbs-main-list-item-booking input[name="update_client_first_name"]').val();
1041			data.updateClientSecondName=$('.cbs-main-list-item-booking input[name="update_client_second_name"]').val();
1042			data.updateClientCompanyName=$('.cbs-main-list-item-booking input[name="update_client_company_name"]').val();
1043			data.updateClientVehicle=$('.cbs-main-list-item-booking input[name="update_client_vehicle"]').val();
1044			data.updateClientEmailAddress=$('.cbs-main-list-item-booking input[name="update_client_email_address"]').val();
1045			data.updateClientPhoneNumber=$('.cbs-main-list-item-booking input[name="update_client_phone_number"]').val();
1046			data.updateClientMessage=$('.cbs-main-list-item-booking textarea[name="update_client_message"]').val();
1047
1048			data.updateClientAddressStreet=$('.cbs-main-list-item-booking input[name="update_client_address_street"]').val();
1049			data.updateClientAddressPostCode=$('.cbs-main-list-item-booking input[name="update_client_address_post_code"]').val();
1050			data.updateClientAddressCity=$('.cbs-main-list-item-booking input[name="update_client_address_city"]').val();
1051			data.updateClientAddressState=$('.cbs-main-list-item-booking input[name="update_client_address_state"]').val();
1052			data.updateClientAddressCountry=$('.cbs-main-list-item-booking input[name="update_client_address_country"]').val();
1053			
1054			$self.post(data,function(response)
1055			{
1056				$self.updateUserContactDetailsResponse(response);
1057			});
1058		}
1059		
1060		/**********************************************************************/
1061		
1062		this.updateUserContactDetailsResponse=function(response)
1063		{
1064			var notice=$('.cbs-notice-contact-details');
1065			var noticeIcon=notice.children('.cbs-notice-icon');
1066			
1067			notice.removeClass('cbs-notice-error cbs-notice-success');
1068			noticeIcon.removeClass('cbs-meta-icon-error cbs-meta-icon-success');
1069			
1070			if(response.error===0)
1071			{
1072				notice.addClass('cbs-notice-success');
1073				noticeIcon.addClass('cbs-meta-icon-success');
1074			}
1075			else
1076			{
1077				notice.addClass('cbs-notice-error');	
1078				noticeIcon.addClass('cbs-meta-icon-error');
1079			}
1080			
1081			notice.find('.cbs-notice-header').html(response.header);
1082			notice.find('.cbs-notice-text').html(response.message);
1083			
1084			notice.css('display','block');
1085		};
1086		
1087		/**********************************************************************/
1088		/**********************************************************************/
1089		
1090		this.applyCoupon=function(vehicleId,packageId,serviceId,couponCode)
1091		{
1092			var data={};
1093			
1094			data.action='cbs_create_cost';
1095			
1096			data.vehicleId=vehicleId;
1097			data.packageId=packageId;
1098			data.serviceId=serviceId.join('.');
1099			data.couponCode=couponCode;
1100			data.locationId=$option.locationId;
1101			
1102			$self.post(data,function(response)
1103			{
1104				$self.applyCouponResponse(response,couponCode);
1105			});		
1106		};
1107		
1108		/**********************************************************************/
1109		
1110		this.applyCouponResponse=function(response,couponCode)
1111		{
1112			$self.displayDuration(response.cost.duration_unit,response.cost.duration.hour,response.cost.duration.minute);
1113			
1114			$this.find('.cbs-booking-summary-price>h5>span.cbs-booking-summary-price-value').html(response.cost.price.unit+'.'+response.cost.price.decimal);
1115			
1116			if(couponCode.length)
1117			{
1118				if(response.cost.coupon_active)
1119					$this.find('.cbs-main-list-item-booking .cbs-coupon-code .cbs-coupon-code-success').show();
1120				else
1121					$this.find('.cbs-main-list-item-booking .cbs-coupon-code .cbs-coupon-code-failure').show();
1122			}
1123		};
1124		
1125		/**********************************************************************/
1126		/**********************************************************************/
1127		
1128		this.createService=function(vehicleId,packageId)
1129		{
1130			var data={};
1131			
1132			data.action='cbs_create_service';
1133			
1134			data.vehicleId=vehicleId;
1135			data.packageId=packageId;
1136			data.locationId=$option.locationId;
1137			
1138			$self.post(data,function(response)
1139			{
1140				$self.createServiceResponse(response);
1141			});		
1142		};
1143		
1144		/**********************************************************************/
1145		
1146		this.createServiceResponse=function(response)
1147		{
1148			var serviceListItem=$this.find('.cbs-main-list-item-service-list');
1149			
1150			serviceListItem.removeClass('cbs-state-disable');
1151			
1152			if(!response.serviceCount) serviceListItem.addClass('cbs-state-disable');
1153			
1154			serviceListItem.children('.cbs-main-list-item-section-content').html(response.service);
1155			
1156			$self.displayDuration(response.cost.duration_unit,response.cost.duration.hour,response.cost.duration.minute);
1157			
1158			$this.find('.cbs-booking-summary-price>h5>span.cbs-booking-summary-price-value').html(response.cost.price.unit+response.cost.price.separator+response.cost.price.decimal);
1159			
1160			$('.cbs-main-list-item-booking input[name="coupon_code"]').val('').trigger('blur');
1161		};
1162		
1163		/**********************************************************************/
1164		/**********************************************************************/
1165		
1166		this.setButtonSelected=function(object,group,unchecked,multiple)
1167		{
1168			object=$(object);
1169			
1170			if(!unchecked)
1171			{
1172				if(object.hasClass('cbs-state-selected')) return;
1173			}
1174			
1175			if(!multiple)
1176			{
1177				if(group===null) group=object.siblings();
1178				group.removeClass('cbs-state-selected');
1179			}
1180			
1181			object.toggleClass('cbs-state-selected');
1182		};
1183		
1184		/**********************************************************************/
1185		
1186		this.getValueFromClass=function(object,pattern)
1187		{
1188			try
1189			{
1190				var reg=new RegExp(pattern);
1191				var className=$(object).attr('class').split(' ');
1192
1193				for(var i in className)
1194				{
1195					if(reg.test(className[i]))
1196						return(className[i].substring(pattern.length));
1197				}
1198			}
1199			catch(e) {}
1200
1201			return(false);		
1202		};	
1203		
1204		/**********************************************************************/
1205		
1206		this.post=function(data,callback)
1207		{
1208			$self.preloader(true);
1209			
1210			data.pageId=$option.pageId;
1211			
1212			$.post(pluginOption.config.ajaxurl,data,function(response)
1213			{ 
1214				$self.preloader(false);
1215				callback(response); 
1216			},'json');
1217		};
1218		
1219		/**********************************************************************/
1220		
1221		this.preloader=function(state)
1222		{
1223			var preloader=$('#cbs-preloader');
1224			
1225			if(preloader.length!==1) return;
1226			
1227			var counter=parseInt(preloader.attr('data-counter'),10);
1228			if(isNaN(counter)) counter=0;
1229			
1230			if(state)
1231			{
1232				counter++;
1233				preloader.addClass('cbs-state-enable');
1234			}
1235			else
1236			{
1237				counter--;
1238				if(counter===0) preloader.removeClass('cbs-state-enable');
1239			}
1240			
1241			preloader.attr('data-counter',counter);
1242		};
1243		
1244		/**********************************************************************/
1245		
1246		this.setWidthClass=function()
1247		{
1248			var width=$this.parent().width();
1249			
1250			var className=null;
1251			var classPrefix='cbs-width-';
1252			
1253			if(width>=1170) className='1170';
1254			else if(width>=960) className='960';
1255			else if(width>=768) className='768';
1256			else if(width>=480) className='480';
1257			else if(width>=300) className='300';
1258			else if(width>=0) className='0';
1259			
1260			var oldClassName=$self.getValueFromClass($this,classPrefix);
1261			if(oldClassName!==false) $this.removeClass(classPrefix+oldClassName);
1262			
1263			$this.addClass(classPrefix+className);
1264			
1265			if($self.prevWidth!==width)
1266			{
1267				$self.prevWidth=width;
1268				$self.calculateCalendarColumnWidth();
1269			}
1270			
1271			setTimeout($self.setWidthClass,500);
1272		};
1273		
1274		/**********************************************************************/
1275		
1276		this.calculateCalendarColumnWidth=function()
1277		{
1278			var calendarBox=$this.find('.cbs-calendar-table-wrapper');
1279			var calendar=calendarBox.find('table');
1280			
1281			calendarBox.width('');
1282			calendar.width('');
1283			
1284			var calendarWidth=calendarBox.width();
1285			
1286			var columnCount=parseInt(calendarBox.find('input[name="cbs-calendar-column-count"]').val());
1287			var columnWidth=140;
1288			
1289			columnCount=Math.floor(calendarWidth/columnWidth);
1290			if(columnCount===0) columnCount=1;
1291			
1292			var calendarHeader=$this.find('.cbs-calendar-table-wrapper table th');
1293
1294			calendarHeader.removeClass('cbs-active');
1295			calendarHeader.first().addClass('cbs-active');
1296			
1297			calendarBox.width(calendarBox.parent().width()+1);
1298			calendarBox.find('input[name="cbs-calendar-column-count"]').val(columnCount);
1299			
1300			$self.hideCalendarColumn();
1301		};
1302		
1303		/**********************************************************************/
1304		
1305		this.manageCalendarHeader=function()
1306		{
1307			var calendar=$this.find('.cbs-calendar-table-wrapper .cbs-calendar');
1308			var calendarHeaderCaption=$this.find('.cbs-calendar-header-caption');
1309		
1310			var columnActive=calendar.find('th.cbs-active').index();
1311			var columnCount=parseInt($this.find('input[name="cbs-calendar-column-count"]').val());
1312		
1313			var monthNumber=[];
1314		
1315			for(var i=columnActive;i<(columnActive+columnCount);i++)
1316			{
1317				var date=$self.getValueFromClass(calendar.find('th:eq('+i+')'),'cbs-date-id-');
1318				if(date===false) continue;
1319				var month=date.substring(2,4);
1320				monthNumber.push(month);
1321			}
1322			
1323			monthNumber=jQuery.unique(monthNumber);
1324		
1325			calendarHeaderCaption.children('span').css('display','none');
1326		
1327			if(monthNumber.length>1)
1328				calendarHeaderCaption.children('span.cbs-calendar-month-number-0').css('display','inline');
1329			
1330			for(var i in monthNumber)
1331			{
1332				var month=parseInt(monthNumber[i],10);
1333				if(!isNaN(month))
1334					calendarHeaderCaption.children('span.cbs-calendar-month-number-'+monthNumber[i]).css('display','inline');
1335			}
1336		};
1337		
1338		/**********************************************************************/
1339	};
1340	
1341	/**************************************************************************/
1342	
1343	$.fn.CBSPlugin=function(option) 
1344	{
1345		var plugin=new CBSPlugin(this,option);
1346		plugin.build();
1347	};
1348	
1349	/**************************************************************************/
1350
1351})(jQuery,document,window);
1352
1353/******************************************************************************/
1354/******************************************************************************/

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.