PageSourceSearch

https://putnik.com/wp-content/plugins/tourmaster/room/tourmaster-room.js?ver=1b57489fa3c0138c96bd4638481ed171

js putnik.com collected 2026-10-06 11:11:33 UTC 60,068 bytes, 1,337 lines download raw bytes

1(function($){
2	"use strict";
3
4	// Detect Mobile Device
5	var tourmaster_mobile = false;
6	if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/BlackBerry/i) ||
7		navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/Windows Phone/i) ){ 
8		tourmaster_mobile = true; 
9	}else{ 
10		tourmaster_mobile = false; 
11	}
12
13	// Detect Screen
14	var tourmaster_display = 'desktop';
15	if( typeof(window.matchMedia) == 'function' ){
16		$(window).on('load resize', function(){
17			if( window.matchMedia('(max-width: 419px)').matches ){
18				tourmaster_display = 'mobile-portrait';
19			}else if( window.matchMedia('(max-width: 767px)').matches ){
20				tourmaster_display = 'mobile-landscape'
21			}else if( window.matchMedia('(max-width: 999px)').matches ){
22				tourmaster_display = 'tablet'
23			}else{
24				tourmaster_display = 'desktop';
25			}
26		});
27	}else{
28		$(window).on('load resize', function(){
29			if( $(window).innerWidth() <= 419 ){
30				tourmaster_display = 'mobile-portrait';
31			}else if( $(window).innerWidth() <= 767 ){
32				tourmaster_display = 'mobile-landscape'
33			}else if( $(window).innerWidth() <= 999 ){
34				tourmaster_display = 'tablet'
35			}else{
36				tourmaster_display = 'desktop';
37			}
38		});
39	}	
40
41    function tourmaster_get_form_array_data( object, name, value ){
42        var name_match = name.match(/^[A-Za-z\-\_]+/);
43        if( name_match ){
44            if( typeof(object[name_match[0]]) != 'object' ){
45                object[name_match[0]] = {};
46            }
47            var last_name = name.replace(name_match[0], '');
48            object[name_match[0]] = tourmaster_get_form_array_data(object[name_match[0]], last_name, value);
49        }else{
50            var array_match = name.match(/\[(\d+)\]/);
51            if( array_match ){
52                if( typeof(object[array_match[1]]) != 'object' ){
53                    object[array_match[1]] = {};
54                }
55                var last_name = name.replace(array_match[1], '');
56                object[array_match[1]] = tourmaster_get_form_array_data(object[array_match[1]], last_name, value);
57            }else{
58                return value;
59            }
60        }
61
62        return object;
63    } 
64    function tourmaster_get_form_data( form ){
65		var ret = {};
66
67		form.find('input[name], select[name], textarea[name]').each(function(){
68			var key = $(this).attr('name');
69			var value;
70
71			if( $(this).is('[type="checkbox"]') ){
72				var value = $(this).is(':checked')? $(this).val(): 0;
73			}else if( $(this).is('[type="radio"]') ){
74				if( $(this).is(':checked') ){
75					var value = $(this).val();
76				}else{
77					return;
78				}
79			}else{
80				var value = $(this).val();
81			}
82
83			if( (key.lastIndexOf('[]') == (key.length - 2)) ){
84				key = key.substr(0, key.length - 2);
85				if( typeof(ret[key]) != 'object' ){
86					ret[key] = []
87				}
88
89				ret[key].push(value);
90			}else{
91                ret = tourmaster_get_form_array_data(ret, $(this).attr('name'), value);	
92				// ret[$(this).attr('name')] = value;
93			}
94		});	
95
96		return ret;
97	}
98
99	// tour booking bar
100	function tourmaster_room_booking_ajax( ajax_url, ajax_settings, ajax_data ){
101
102		var ajax_settings = $.extend({
103			beforeSend: function( jqXHR, settings ){},
104			error: function( jqXHR, textStatus, errorThrown ){
105
106				// print error message for debug purpose
107				console.log(jqXHR, textStatus, errorThrown);
108			},
109			success: function( data ){ 
110				// console.log('success', data); 
111			}
112		}, ajax_settings);
113
114		var ajax_data = $.extend({
115			action: '',
116		}, ajax_data);
117
118		$.ajax({
119			type: 'POST',
120			url: ajax_url,
121			data: ajax_data,
122			dataType: 'json',
123			beforeSend: ajax_settings.beforeSend,
124			error: ajax_settings.error,
125			success: ajax_settings.success
126		});
127	}   
128
129    // single review
130    $.fn.tourmaster_room_single_review = function(){
131        var review_section = $(this);
132        var review_filter = $(this).find('#tourmaster-single-review-filter');
133        var review_content = $(this).find('#tourmaster-single-review-content');
134
135        // bind the filter
136        var sort_by = review_filter.find('[data-sort-by]');
137
138        sort_by.click(function(){
139            if( $(this).hasClass('tourmaster-active') ) return false;
140
141            $(this).addClass('tourmaster-active').siblings('[data-sort-by]').removeClass('tourmaster-active');
142            tourmaster_room_get_review_ajax({
143                'action': 'get_single_room_review',
144                'room_id': review_content.attr('data-room-id'),
145                'sort_by': $(this).attr('data-sort-by'),
146            }, review_content);
147        });
148
149        review_content.on('click', '[data-paged]', function(){
150            tourmaster_room_get_review_ajax({
151                'action': 'get_single_room_review',
152                'room_id': review_content.attr('data-room-id'),
153                'paged': $(this).attr('data-paged'),
154                'sort_by': sort_by.filter('.tourmaster-active').attr('data-sort-by'),
155            }, review_content, review_section);
156        });
157
158    }
159    function tourmaster_room_get_review_ajax( ajax_data, content_section, scroll_to = null ){
160        content_section.animate({opacity: 0.2}, 200);
161
162        $.ajax({
163            type: 'POST',
164            url: content_section.attr('data-ajax-url'),
165            data: ajax_data,
166            dataType: 'json',
167            error: function( jqXHR, textStatus, errorThrown ){
168
169                content_section.animate({opacity: 1}, 200);
170
171                // print error message for debug purpose
172                console.log(jqXHR, textStatus, errorThrown);
173            },
174            success: function( data ){
175
176                if( typeof(data.content) != 'undefined' ){
177                    var old_height = content_section.outerHeight();
178                    content_section.html(data.content);
179
180                    var new_height = content_section.outerHeight();
181                    content_section.css({'height': old_height});
182                    content_section.animate({height: new_height}, 200 , function(){
183                        content_section.css({height: 'auto'});
184                    });
185                }	
186
187                content_section.animate({opacity: 1}, 200);
188
189                if( scroll_to != null ){
190                    $('body, html').animate({'scrollTop': scroll_to.offset().top - 150 });
191                }
192
193            }
194        });
195    }	
196
197    $.fn.tourmaster_room_amount_selection = function(){
198
199        $(this).each(function(){
200            var display = $(this).find('.tourmaster-custom-amount-display');
201            var option_wrap = $(this).find('.tourmaster-custom-amount-selection-wrap');
202            
203            var label = $(this).find('.tourmaster-custom-amount-display .tourmaster-tail');
204            var items = $(this).find('.tourmaster-custom-amount-selection-item');
205
206            function set_amount_selection_label(){
207                label.html('');
208                items.each(function(){
209                    var amount_input = $(this).find('input');
210                    var amount_text = $(this).attr('data-label')? $(this).attr('data-label') + ' ': '';
211                    amount_text += amount_input.val();
212
213                    label.append('<span class="tourmaster-space" ></span>');
214                    label.append(amount_text);
215                });
216            }
217
218            items.on('click', '.tourmaster-plus, .tourmaster-minus', function(){
219                var amount_item = $(this).closest('.tourmaster-custom-amount-selection-item');
220                var amount_text = $(this).siblings('.tourmaster-amount');
221                var amount_input = amount_item.find('input');
222                var amount = parseInt(amount_input.val());
223
224                if( $(this).hasClass('tourmaster-plus') ){
225                    amount_input.val(amount + 1)
226                    amount_text.html(amount + 1);
227                }else if( $(this).hasClass('tourmaster-minus') ){
228                    amount_input.val(amount - 1)
229                    amount_text.html(amount - 1);
230                }
231                amount_input.trigger('change');
232
233                set_amount_selection_label();
234            });
235
236            // click display event
237            display.on('click', function(){
238                display.addClass('tourmaster-active');
239                option_wrap.fadeIn(150);
240            });
241
242            // close amount box when clicking outside the element
243            $(document).on('click', function(e){
244                if( !display.hasClass('tourmaster-active') ) return;
245                if( $(e.target).closest(display).length ) return;
246                if( $(e.target).closest(option_wrap).length ) return;
247
248                display.removeClass('tourmaster-active');
249                option_wrap.fadeOut(150);
250            });
251            
252        }); // amount selection
253
254    }
255
256    $(document).ready(function(){
257
258        var body = $('body');
259        var login_lb = $('[data-tmlb-id="room-proceed-without-login"]');
260
261        // search filter
262        body.on('click', '.tourmaster-room-search-tax-wrap .tourmaster-close-filter', function(){
263            var content_fitler = $(this).parent('.tourmaster-label').siblings('.tourmaster-filter');
264
265            if( $(this).hasClass('tourmaster-active') ){
266                $(this).removeClass('tourmaster-active');
267                content_fitler.slideDown(150);
268            }else{
269                $(this).addClass('tourmaster-active');
270                content_fitler.slideUp(150);
271            }
272        });
273
274        // initiate cart button
275        var cart_button = $('#tourmaster-room-navigation-checkout-button').each(function(){
276            var cart_wrap = $(this).closest('.tourmaster-room-navigation-checkout-wrap');
277            var cart_items = $(this).siblings('.tourmaster-room-cart-item-wrap');
278            var checkout_button = cart_items.find('.tourmaster-checkout-button');
279
280            cart_items.on('click', '.tourmaster-remove', function(){
281                var index = $(this).closest('li').index();
282                var cart_cookie = tourmaster_read_cookie('tourmaster-room-cart');
283                if( cart_cookie != '' ){
284                    cart_cookie = JSON.parse(cart_cookie);
285                }else{
286                    cart_cookie = [];
287                }
288                cart_cookie.splice(index, 1);
289                tourmaster_set_cookie('tourmaster-room-cart', JSON.stringify(cart_cookie), 31536000);
290
291                $(this).closest('li').slideUp(50, function(){ $(this).remove(); });
292                if( cart_cookie.length == 0 ){
293                    cart_wrap.removeClass('tourmaster-active');
294                    cart_button.html(cart_button.attr('data-label') + '<span class="tourmaster-count">0</span>');
295                }
296            });
297
298            $(this).on('clear', function(){
299                cart_wrap.removeClass('tourmaster-active');
300                cart_button.html(cart_button.attr('data-label') + '<span class="tourmaster-count">0</span>');
301            }); 
302
303            $(this).on('click', function(){
304                if( cart_wrap.hasClass('tourmaster-active') ) return false;
305            });
306
307            // check if login before proceeding
308            if( login_lb.length ){
309                checkout_button.on('click', function(){
310
311                    var lb_content = login_lb.clone();
312
313                    // check for social login plugin
314                    if( lb_content.find('.nsl-container-block').length > 0 ){
315                        lb_content.find('.nsl-container-block').replaceWith(login_lb.find('.nsl-container-block').clone(true));
316                    }
317
318                    // change link ot cart link
319                    lb_content.find('input[name="redirect_to"]').each(function(){
320                        $(this).val($(this).val().replace('type=booking', 'type=cart'));
321                    });
322                    lb_content.find('.tourmaster-continue-button').each(function(){
323                        $(this).attr('href', $(this).attr('href').replace('type=booking', 'type=cart'));
324                    });
325                    lb_content.find('.tourmaster-register-button').each(function(){
326                        $(this).attr('href', $(this).attr('href').replace('redirect=room-payment', 'redirect=room-payment-cart'));
327                    });
328                    
329                    tourmaster_lightbox(lb_content);
330
331                    return false;
332                });
333            }
334        });
335        
336
337        // change booking tab
338        if( body.hasClass('single-room') ){
339
340            body.find('.tourmaster-room-booking-bar-wrap').each(function(){
341                var title_wrap = $(this).find('.tourmaster-room-booking-bar-title');
342                var content_wrap = $(this).find('.tourmaster-room-booking-bar-content');
343    
344                title_wrap.on('click', '[data-room-tab]', function(){
345                    var tab_id = $(this).attr('data-room-tab');
346                    $(this).addClass('tourmaster-active').siblings().removeClass('tourmaster-active');
347    
348                    var target_tab = content_wrap.find('[data-room-tab="' + tab_id + '"]');
349                    target_tab.siblings().hide().removeClass('tourmaster-active');
350                    target_tab.addClass('tourmaster-active').fadeIn(150);
351                });
352            });
353
354            body.find('#tourmaster-room-booking-form').each(function(){
355
356                // change room amount
357                $(this).on('change', 'input[name="room_amount"]', function(){
358                    var room_amount = parseInt($(this).val());
359                    var guest_selection = $(this).closest('.tourmaster-room-amount-selection').siblings('.tourmaster-room-booking-guest-selection');
360                    var current_guest_selection = guest_selection.children().length;
361
362                    if( room_amount == 1 ){
363                        guest_selection.addClass('tourmaster-one');
364                    }else{
365                        guest_selection.removeClass('tourmaster-one');
366                    }
367
368                    if( current_guest_selection < room_amount ){
369                        for( var i = current_guest_selection + 1; i <= room_amount; i++ ){
370                            var template = guest_selection.children().first().clone();
371                            template.find('.tourmaster-number').html(i);
372                            template.css('display', 'none');
373                            guest_selection.append(template);
374                            template.slideDown(150);
375                            template.tourmaster_room_amount_selection();    
376                        }
377                    }else{
378                        guest_selection.children().each(function(index){
379                            console.log(index);
380                            if( room_amount < index + 1 ){
381                                console.log(1);
382                                $(this).slideUp(150, function(){ $(this).remove() });
383                            }
384                        });
385                    }
386                    guest_selection.children().each(function(index){
387                        
388                    });
389                    var template = guest_selection.children().first();
390
391                    
392                });
393                
394                var booking_area = $(this).closest('.tourmaster-room-booking-bar-wrap');
395                
396                // booking summary area
397                function bind_booking_bar_summary(content_area, cart_row, form, input_data){
398                    content_area.find('.tourmaster-go-back').on('click', function(){
399                        content_area.remove();
400                        booking_area.fadeIn(150);
401                    });
402
403                    content_area.on('click', '.tourmaster-add-to-cart', function(){
404
405                        // set cookie
406                        var cart_cookie = tourmaster_read_cookie('tourmaster-room-cart');
407                        if( cart_cookie != '' ){
408                            cart_cookie = JSON.parse(cart_cookie);
409                        }else{
410                            cart_cookie = [];
411                        }
412                        cart_cookie.push(input_data);
413                        tourmaster_set_cookie('tourmaster-room-cart', JSON.stringify(cart_cookie), 31536000);
414                        
415                        var current_time = (new Date()).getTime();
416                        tourmaster_set_cookie('tourmaster-room-current-id', '', current_time);
417
418                        // animation
419                        $(this).html($(this).attr('data-complete')).addClass('tourmaster-active').css('opacity', 0);
420                        $(this).animate({opacity: 1}, {duration: 150});
421                        setTimeout(function(){ 
422                            content_area.remove();
423                            booking_area.fadeIn(150);
424                        }, 2000);
425
426                        // add item to cart
427                        if( cart_button.length ){
428                            var cart_wrap = cart_button.closest('.tourmaster-room-navigation-checkout-wrap');
429                            var cart_items = cart_button.siblings('.tourmaster-room-cart-item-wrap');
430                            cart_items.find('ul').append(cart_row);
431                            cart_wrap.addClass('tourmaster-active');
432
433                            cart_button.find('.tourmaster-count').html(cart_cookie.length);
434                            cart_button.html(cart_button.attr('data-checkout-label') + '<span class="tourmaster-count">' + cart_cookie.length + '</span>');
435                
436                        }
437                    });
438
439                    content_area.on('click', '.tourmaster-checkout', function(){
440                        tourmaster_set_cookie('tourmaster-room-booking-detail', JSON.stringify(input_data), 31536000);
441
442                        var current_time = (new Date()).getTime();
443                        tourmaster_set_cookie('tourmaster-room-current-id', '', current_time);
444
445                        // check if login before proceeding
446                        if( login_lb.length ){
447                            var lb_content = login_lb.clone();
448
449                            // check for social login plugin
450                            if( lb_content.find('.nsl-container-block').length > 0 ){
451                                lb_content.find('.nsl-container-block').replaceWith(login_lb.find('.nsl-container-block').clone(true));
452                            }
453
454                            tourmaster_lightbox(lb_content);
455
456                            return false;
457                        }else{
458                            window.location.href = form.attr('action');
459                        }
460                        
461                    });
462                }
463
464                // submit input
465                $(this).on('click', 'input[type="submit"]', function(){
466
467                    var submit_button = $(this);
468                    if( submit_button.hasClass('tourmaster-now-loading') ) return false;
469                    submit_button.addClass('tourmaster-now-loading');
470
471                    var error = $(this).siblings('.tourmaster-room-booking-submit-error');
472                    error.slideUp(200, function(){ $(this).remove() });
473
474                    var form = $(this).closest('form');
475                    var input_data = tourmaster_get_form_data(form);
476                    
477                    tourmaster_room_booking_ajax(form.attr('data-ajax-url'), {
478                        success: function( data ){
479                            if( typeof(data) != 'undefined' ){
480                                if( data.status == 'success' ){
481                                    booking_area.hide();
482
483                                    var content_area = $(data.content).css('display', 'none');
484                                    content_area.insertAfter(booking_area);
485                                    content_area.fadeIn(150);
486                                    bind_booking_bar_summary(content_area, data.cart_row, form, input_data);
487                                }else if( data.status == 'failed' ){
488                                    var error_message = $('<div class="tourmaster-room-booking-submit-error" ></div>');
489                                    error_message.append(data.message);
490                                    error_message.css('display', 'none');
491                                    error_message.insertBefore(submit_button);
492                                    error_message.slideDown(150);
493
494                                    console.log(data);
495                                }
496                                
497                            }
498
499                            submit_button.removeClass('tourmaster-now-loading');
500                        }
501                    }, {
502                        action: form.attr('data-action'),
503                        data: input_data
504                    });
505
506                    return false;
507                });
508
509            });
510
511        }
512
513        // on single room
514        if( body.hasClass('single-room')){
515
516            // submit booking form
517            $('#tourmaster-enquiry-form').find('input[type="submit"]').click(function(){
518                if( $(this).hasClass('tourmaster-now-loading') ){ return false; }
519
520                var form = $(this).closest('form');
521                var form_button = $(this);
522                var message_box = form.find('.tourmaster-enquiry-form-message').not('.tourmaster-enquiry-term-message');
523
524                var condition_accepted_input = form.find('[name="tourmaster-require-acceptance"]');
525                if( condition_accepted_input.length && !condition_accepted_input.is(':checked') ){
526                    condition_accepted_input.siblings('.tourmaster-enquiry-form-message').slideDown(150);
527                    return false;
528                }else{
529                    condition_accepted_input.siblings('.tourmaster-enquiry-form-message').slideUp(150);
530                }
531
532                var validate = true;
533                form.find('input[data-required], select[data-required], textarea[data-required]').each(function(){
534                    if( !$(this).val() ){
535                        validate = false;
536                    }
537                });
538
539                if( !validate ){
540                    if( form.attr('data-validate-error') ){
541                        message_box.removeClass('tourmaster-success').addClass('tourmaster-failed');
542                        message_box.html(form.attr('data-validate-error'));
543                        message_box.slideDown(300);
544                    }
545                }else{
546
547                    message_box.slideUp(300);
548                    form_button.addClass('tourmaster-now-loading');
549
550                    $.ajax({
551                        type: 'POST',
552                        url: form.attr('data-ajax-url'),
553                        data: { action: form.attr('data-action'), data: tourmaster_get_form_data(form) },
554                        dataType: 'json',
555                        error: function( jqXHR, textStatus, errorThrown ){
556                            // print error message for debug purpose
557                            console.log(jqXHR, textStatus, errorThrown);
558                        },
559                        success: function( data ){
560                            if( typeof(grecaptcha) != 'undefined' ){
561                                form.find('#g-recaptcha-response').val('gdlr-verfied');
562                            }
563                            
564                            form_button.removeClass('tourmaster-now-loading');
565
566                            if( typeof(data.message) != 'undefined' ){
567                                if( data.status == 'success' ){
568                                    form.find('input[name], textarea[name], select[name]').not('[name="tour-id"]').val('');
569                                    message_box.removeClass('tourmaster-failed').addClass('tourmaster-success');
570                                }else{
571                                    message_box.removeClass('tourmaster-success').addClass('tourmaster-failed');
572                                }
573
574                                message_box.html(data.message);
575                                message_box.slideDown(300);
576                            }
577                            
578                        }
579                    });
580                }
581
582                return false;
583            });
584
585            // single review
586            $('#tourmaster-room-single-review').tourmaster_room_single_review();
587        }
588        
589        // amount selection
590        $('.tourmaster-room-amount-selection').tourmaster_room_amount_selection();
591
592        
593        // custom datepicker
594        $('.tourmaster-custom-datepicker-wrap').each(function(){
595
596            var dp_wrap = $(this);
597            var dp_parent = dp_wrap.closest('.tourmaster-room-date-selection');
598            var start_date_wrap = dp_wrap.siblings('.tourmaster-custom-start-date');
599            var start_date_input = start_date_wrap.find('[name="start_date"]');
600            var start_date_label = start_date_wrap.find('.tourmaster-tail');
601            var end_date_wrap = dp_wrap.siblings('.tourmaster-custom-end-date');
602            var end_date_input = end_date_wrap.find('[name="end_date"]');
603            var end_date_label = end_date_wrap.find('.tourmaster-tail');
604
605            var step = 1;
606            var date_format = dp_wrap.attr('data-date-format');
607
608            var start_date = start_date_input.val()? new Date(start_date_input.val() + 'T00:00:00'): '';
609            var end_date = end_date_input.val()? new Date(end_date_input.val() + 'T00:00:00'): '';
610            if( dp_parent.attr('data-avail-date') ){
611                var avail_date = dp_parent.attr('data-avail-date').split(',');
612                var min_date = new Date(avail_date[0] + 'T00:00:00');
613                var max_date = new Date(avail_date[avail_date.length-1] + 'T00:00:00');
614            }else{
615                var avail_date = false;
616                if( !start_date ){
617                    var min_date = new Date(dp_parent.attr('data-current-date') + 'T00:00:00');
618                }else{
619                    var min_date = start_date;
620                }
621                var max_date = null;
622            }
623
624            var dp_title = $(this).children('.tourmaster-custom-datepicker-title');
625            var dp_val;
626            if( start_date && end_date ){
627                dp_val = {
628                    'start_date': $.datepicker.formatDate('yy-mm-dd', start_date),
629                    'start_label': $.datepicker.formatDate(date_format, start_date),
630                    'end_date': $.datepicker.formatDate('yy-mm-dd', end_date),
631                    'end_label': $.datepicker.formatDate(date_format, end_date)
632                };
633            }else{
634                dp_val = {
635                    'start_date': '',
636                    'start_label': '',
637                    'end_date': '',
638                    'end_label': ''
639                };
640            }
641
642            var min_night_stay = parseInt(dp_parent.attr('data-min-night-stay'));
643
644            function set_dp_title(){
645                dp_title.html(dp_val.start_label + ' - ' + dp_val.end_label);
646            }
647            function close_dp(){
648                dp_parent.removeClass('tourmaster-active');
649                dp_wrap.fadeOut(150);
650            }
651            function set_dp_location(){
652                dp_wrap.css({ 'right': '', 'left': '' });
653                
654                if( dp_parent.is('.tourmaster-vertical, .tourmaster-mobile') ){
655                    if( step == 1 ){
656                        dp_wrap.css('top', start_date_wrap.outerHeight());
657                    }else if( step == 2 ){
658                        dp_wrap.css('top', '');
659                    }
660                }else{
661                    dp_wrap.css('top', '');
662                }
663
664                // check left position
665                if( dp_wrap.offset().left + dp_wrap.outerWidth() > $(window).width() ){
666                    dp_wrap.css({ 'right': '0', 'left': 'auto' });
667                }
668            }
669
670            // initiate calendar
671            var next_end_date_avail = true;
672            var number_of_months = dp_parent.hasClass('tourmaster-horizontal')? 2: 1;
673            var dp = dp_wrap.find('.tourmaster-custom-datepicker-calendar').datepicker({
674                numberOfMonths: number_of_months,
675                stepMonths: 1,
676                minDate: min_date,
677                maxDate: max_date,
678                defaultDate: start_date,
679                changeMonth: true,
680                changeYear: true,
681
682                // determine selectable date
683                beforeShowDay: function(date){
684                    
685                    var tmp_date  = date.getFullYear() + '-';
686                    tmp_date += ('0' +(date.getMonth() + 1)).slice(-2) + '-';
687                    tmp_date += ('0' + date.getDate()).slice(-2);
688
689                    var selectable = true;
690
691                    if( step == 1 ){
692                        if( avail_date && avail_date.indexOf(tmp_date) < 0 ){
693                            selectable = false;
694                        }
695
696                        if( start_date && end_date ){
697                            if( date.getTime() == start_date.getTime() ){
698                                next_end_date_avail = true;
699                                return [selectable, 'tourmaster-start', ''];
700                            }else if( date.getTime() == end_date.getTime() ){
701                                return [selectable, 'tourmaster-end', ''];
702                            }else if( date.getTime() > start_date.getTime() && date.getTime() < end_date.getTime() ){
703                                return [selectable, 'tourmaster-interval', ''];
704                            }
705                        }
706
707                    }else if( step == 2 ){
708
709                        if( !next_end_date_avail ){
710                            selectable = false;
711                        }
712                        if( avail_date && avail_date.indexOf(tmp_date) < 0 ){
713                            next_end_date_avail = false;
714                        }
715
716                        if( date.getTime() < start_date.getTime() ){
717                            return [false, '', ''];
718                        }else if( date.getTime() == start_date.getTime() ){
719                            next_end_date_avail = true;
720                            return [false, 'tourmaster-start', ''];
721                        }else if( date.getTime() == end_date.getTime() ){
722                            return [selectable, 'tourmaster-end', ''];
723                        }else if( date.getTime() > start_date.getTime() && date.getTime() < end_date.getTime() ){
724                            return [selectable, 'tourmaster-interval', ''];
725                        }
726
727                    }
728                    
729                    return [selectable, '', ''];
730                },
731
732                // for date range
733                onSelect: function( dateText, inst ){
734                    var selected_date = inst.selectedYear + '-';
735                    selected_date += ('0' +(inst.selectedMonth + 1)).slice(-2) + '-';
736                    selected_date += ('0' + inst.selectedDay).slice(-2);
737
738                    // start date
739                    if( step == 1 ){
740                        start_date = new Date(selected_date + 'T00:00:00');
741                        dp_val.start_date = $.datepicker.formatDate('yy-mm-dd', start_date)
742                        dp_val.start_label = $.datepicker.formatDate(date_format, start_date);
743                        start_date_input.val(dp_val.start_date);
744                        start_date_label.html(dp_val.start_label);
745
746                        end_date = new Date(start_date.getTime() + 86400000 * min_night_stay);
747                        dp_val.end_date = $.datepicker.formatDate('yy-mm-dd', end_date);
748                        dp_val.end_label = $.datepicker.formatDate(date_format, end_date);
749                        end_date_input.val(dp_val.end_date);
750                        end_date_label.html(dp_val.end_label);
751
752                        step = 2;
753                        set_dp_location();
754                        
755                    // end date
756                    }else if( step == 2 ){
757                        end_date = new Date(selected_date + 'T00:00:00');
758                        dp_val.end_date = $.datepicker.formatDate('yy-mm-dd', end_date);
759                        dp_val.end_label = $.datepicker.formatDate(date_format, end_date);
760                        end_date_input.val(dp_val.end_date);
761                        end_date_label.html(dp_val.end_label);
762                            
763                        step = 1;
764
765                        if( dp_parent.is('.tourmaster-vertical, .tourmaster-mobile') ){
766                            close_dp();
767                        }
768                    }
769
770                    dp_parent.addClass('tourmaster-selected');
771                    dp_parent.attr('data-step', step);
772                    set_dp_title();
773                },
774                
775            }); // tourmaster-custom-datepicker-wrap
776            set_dp_title();
777
778            // click display event
779            dp_wrap.siblings('.tourmaster-custom-start-date').on('click', function(){
780                step = 1;
781                dp_parent.addClass('tourmaster-active');
782                dp_wrap.fadeIn(150);
783                dp_parent.attr('data-step', step);
784                set_dp_location();
785
786                dp.datepicker('refresh');
787            });
788            dp_wrap.siblings('.tourmaster-custom-end-date').on('click', function(){
789                step = 2;
790                dp_parent.addClass('tourmaster-active');
791                dp_wrap.fadeIn(150);
792                dp_parent.attr('data-step', step);
793                set_dp_location();
794
795                dp.datepicker('refresh');
796            });
797
798            // close datepicker when clicking outside the element
799            dp_wrap.on('click', '.tourmaster-custom-datepicker-close', function(){
800                close_dp();
801            });
802            $(document).on('click', function(e){
803                if( !dp_parent.hasClass('tourmaster-active') ) return;
804                if( $(e.target).is('.ui-datepicker-prev, .ui-datepicker-next') ) return;
805                if( !$(e.target).closest('.tourmaster-custom-start-date, .tourmaster-custom-end-date, .tourmaster-custom-datepicker-wrap').length ){
806                    close_dp();
807                }
808            });
809
810            // resize action
811            $(window).on('load resize', function(){
812                if( dp_parent.hasClass('tourmaster-horizontal') ){
813                    if( tourmaster_mobile || tourmaster_display == 'mobile-landscape' || tourmaster_display == 'mobile-portrait' ){
814                        if( !dp_parent.hasClass('tourmaster-mobile') ){
815                            dp_parent.addClass('tourmaster-mobile');
816                            dp.datepicker('option', 'numberOfMonths', 1);
817                        }
818                    }else{
819                        if( dp_parent.hasClass('tourmaster-mobile') ){
820                            dp_parent.removeClass('tourmaster-mobile');
821                            dp.datepicker('option', 'numberOfMonths', number_of_months);
822                        }
823                    }
824                }
825                
826            });
827        }); // custom datepicker.
828
829        // payment only page
830        $('#tourmaster-room-payment-display-page').each(function(){
831            
832            var payment_page = $(this);
833            
834            var step_wrap = $(this).find('.tourmaster-room-payment-step');
835            var step3_wrap = payment_page.find('#tourmaster-step3-wrap');
836            var step4_wrap = payment_page.find('#tourmaster-step4-wrap');
837
838            var price_sidebar = $(this).find('.tourmaster-room-price-sidebar');
839            var pay_full_amount = true;
840
841            function change_step( step ){
842                step_wrap.attr('data-step', step);
843                step_wrap.children().removeClass('tourmaster-active');
844                step_wrap.children().slice(0, step).addClass('tourmaster-active');
845            }
846            function display_errors(elem, message){
847                var error_html = $('<div class="tourmaster-error-message" ></div>').html(message);
848                error_html.insertBefore(elem);
849                error_html.slideDown(150);
850            }
851            
852            // select type
853            price_sidebar.on('click', '.tourmaster-room-pay-type-item', function(){
854                var deposit_amount_wrap = $(this).closest('.tourmaster-room-pay-type').siblings('.tourmaster-deposit-amount');
855                $(this).addClass('tourmaster-active').siblings().removeClass('tourmaster-active');
856
857                if( $(this).hasClass('tourmaster-deposit') ){
858                    pay_full_amount = false;
859                    deposit_amount_wrap.slideDown(150);
860                }else if( $(this).hasClass('tourmaster-full') ){
861                    pay_full_amount = true;
862                    deposit_amount_wrap.slideUp(150);
863                }
864            });
865
866            // pay now
867            price_sidebar.on('click', '.tourmaster-pay-now', function(){
868                
869                $(this).siblings('.tourmaster-error-message').slideUp(150, function(){ $(this).remove(); });
870
871                var term_service = price_sidebar.find('[name="term-and-service"]');
872                if( term_service.length ){
873                    if( !term_service.is(':checked') ){
874                        display_errors($(this), term_service.attr('data-error'));
875                        return;
876                    }
877                }
878
879                var payment_method = $(this).closest('.tourmaster-room-payment-method-wrap').find('.tourmaster-payment-selection').val();
880
881                // pay for the room
882                if( $(this).hasClass('tourmaster-now-loading') ) return;
883                $(this).addClass('tourmaster-now-loading');
884
885                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
886                    success: function(data){
887                        if( payment_method == 'paypal' && data.payment_content ){
888                            body.append(data.payment_content);
889                        }else if( data.payment_content ){
890                            var content = $('<div class="tourmaster-room-payment-lb" ></div>').html(data.payment_content);
891                            tourmaster_lightbox(content);
892
893                            content.on('payment_complete', function(){
894                                step3_wrap.hide();
895                                step4_wrap.fadeIn(150);
896                                change_step(4);
897
898                                var current_time = (new Date()).getTime();
899                                tourmaster_set_cookie('tourmaster-room-current-id', '', current_time);
900
901                                $(this).closest('.tourmaster-lightbox-wrapper').trigger('lightbox_close');
902                            });
903                        }
904                        $(this).removeClass('tourmaster-now-loading');
905                    }
906                }, {
907                    action: 'tourmaster_room_payd_now',
908                    'tid': payment_page.attr('data-tid'),
909                    'pay_full_amount': pay_full_amount,
910                    'payment_method': payment_method
911                });
912            });
913
914            // pay woocommerce
915            step3_wrap.on('click', '.tourmaster-pay-woocommerce', function(){
916                
917                $(this).siblings('.tourmaster-error-message').slideUp(1
91750, function(){ $(this).remove(); });
918
919                var term_service = step3_wrap.find('[name="term-and-service"]');
920                if( term_service.length ){
921                    if( !term_service.is(':checked') ){
922                        display_errors($(this), term_service.attr('data-error'));
923                        return;
924                    }
925                }
926                
927                // book the room
928                if( $(this).hasClass('tourmaster-now-loading') ) return;
929                $(this).addClass('tourmaster-now-loading');
930
931                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
932                    success: function(data){
933                        // do something here
934                        if( typeof(data.redirect_url) != 'undefined' ){
935                            window.location.replace(data.redirect_url);
936                        }
937                        
938                        $(this).removeClass('tourmaster-now-loading');
939                    }
940                }, {
941                    action: 'tourmaster_room_payd_woocommerce',
942                    'tid': payment_page.attr('data-tid'),
943                });
944            });
945
946        });
947
948        // if on room payment page
949        $('#tourmaster-room-payment-page').each(function(){
950            var payment_page = $(this);
951            var step_wrap = $(this).find('.tourmaster-room-payment-step');
952            var step2_wrap = payment_page.find('#tourmaster-step2-wrap');
953            var step3_wrap = payment_page.find('#tourmaster-step3-wrap');
954            var step4_wrap = payment_page.find('#tourmaster-step4-wrap');
955
956            var service_form = payment_page.find('.tourmaster-room-service-form');
957            var price_sidebar = $(this).find('.tourmaster-room-price-sidebar-wrap');
958            
959            var booking_details = JSON.parse(payment_page.attr('data-booking-details'));
960            var last_coupon_code = '';
961            
962            var pay_full_amount = true;
963
964            function change_step( step ){
965                step_wrap.attr('data-step', step);
966                step_wrap.children().removeClass('tourmaster-active');
967                step_wrap.children().slice(0, step).addClass('tourmaster-active');
968            }
969
970            // step 2
971            // remove booking
972            service_form.on('click', '.tourmaster-room-remove-room', function(){
973                var i = $(this).attr('data-i');
974                var j = $(this).attr('data-j');
975
976                tourmaster_front_confirm_box({
977                    head: service_form.attr('data-remove-head'),
978                    text: service_form.attr('data-remove-text'),
979                    sub: service_form.attr('data-remove-sub'),
980                    yes: service_form.attr('data-remove-yes'),
981                    no: service_form.attr('data-remove-no'), 
982                    success: function(){
983                        if( payment_page.attr('data-type') == 'cart' ){
984                            var bd = tourmaster_read_cookie('tourmaster-room-cart');
985                            bd = JSON.parse(bd);
986
987                            if( parseInt(bd[i]['room_amount']) <= 1 ){
988                                bd.splice(i, 1);
989                            }else{
990                                bd[i]['room_amount'] = parseInt(bd[i]['room_amount']) - 1;
991                                bd[i]['adult'].splice(j, 1);
992                                bd[i]['children'].splice(j, 1);
993                            }
994
995                            tourmaster_set_cookie('tourmaster-room-cart', JSON.stringify(bd), 31536000);
996                        }else{
997                            tourmaster_set_cookie('tourmaster-room-booking-detail', '', 31536000);
998                        }
999
1000                        window.location.reload();
1001                    }
1002                });
1003
1004                return false;
1005            });
1006
1007            // service selection
1008            function set_service_input(checkbox, input_box){
1009                if( checkbox.is(':checked') ){
1010                    input_box.val(1);
1011                    if( input_box.is('[type="text"]') ){
1012                        input_box.prop('disabled', false);
1013                    }
1014                }else{
1015                    input_box.val('');
1016                    if( input_box.is('[type="text"]') ){
1017                        input_box.prop('disabled', true);
1018                    }
1019                }
1020            }
1021            service_form.find('input[type="checkbox"]').each(function(){
1022                var checkbox = $(this);
1023                var input_box = $(this).closest('.tourmaster-service').find('input[type="text"], input[type="hidden"]');
1024                set_service_input(checkbox, input_box);
1025            });
1026            service_form.on('change', 'input[type="checkbox"]', function(){
1027                var checkbox = $(this);
1028                var input_box = $(this).closest('.tourmaster-service').find('input[type="text"], input[type="hidden"]');
1029                set_service_input(checkbox, input_box);
1030            });
1031            service_form.on('change', tourmaster_debounce(function(){
1032                var form_data = tourmaster_get_form_data(service_form);
1033
1034                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
1035                    success: function(data){
1036                        console.log(data);
1037
1038                        // update price sidebar
1039                        if( data.price_sidebar ){
1040                            var price_sidebar_content = $(data.price_sidebar);
1041                            price_sidebar_content.find('.tourmaster-room-coupon-code').val(last_coupon_code);
1042                            price_sidebar.children('.tourmaster-room-price-sidebar').replaceWith(price_sidebar_content);
1043                        }
1044
1045                        // update service price
1046                        if( data.service_prices ){
1047                            var i = 0, j = 0;
1048                            service_form.find('.tourmaster-room-price-summary-block').each(function(){
1049                                $(this).find('.tourmaster-service-total .tourmaster-tail').each(function(){
1050                                    if( data.service_prices[i][j] ){
1051                                        $(this).html(data.service_prices[i][j]);
1052                                    }
1053                                    j++;
1054                                });
1055
1056                                i++; j = 0;
1057                            });
1058                        }
1059                        
1060                    }
1061                }, {
1062                    action: 'tourmaster_room_service_selected',
1063                    data: { 
1064                        'services': form_data['service'],
1065                        'booking_details': booking_details
1066                    }
1067                });
1068
1069            }, 1000));
1070
1071            // checking coupon
1072            price_sidebar.on('input change', '.tourmaster-room-coupon-code', tourmaster_debounce(function(e){
1073                var coupon_input = $(this);
1074                var coupon_code = coupon_input.val();
1075                if( coupon_code == last_coupon_code ) return;
1076                
1077                last_coupon_code = coupon_code;
1078                if( coupon_code == '' ) return;
1079
1080                coupon_input.siblings('.tourmaster-message').fadeOut(100, function(){ $(this).remove(); });
1081
1082                if( coupon_code ){
1083                    tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
1084                        success: function(data){
1085                            var message = $('<div class="tourmaster-message" ></div>').html(data.message).css('display', 'none');
1086                            message.insertAfter(coupon_input);
1087                            message.fadeIn(100);
1088                        }
1089                    }, {
1090                        action: 'tourmaster_room_check_coupon_code',
1091                        data: { 'coupon_code': coupon_code }
1092                    });
1093                }
1094			}, 1000));
1095
1096            // price breakdown
1097            step2_wrap.on('click', '.tourmaster-price-breakdown-title', function(){
1098                var content = $(this).find('.tourmaster-room-single-price-breakdown');
1099                tourmaster_lightbox(content.clone());
1100            });
1101
1102            // go to step 3
1103            price_sidebar.on('click', '.tourmaster-step2-checkout', function(){
1104                var payment_button = $(this);
1105                if( payment_button.hasClass('tourmaster-now-loading') ) return;
1106                payment_button.addClass('tourmaster-now-loading');
1107
1108                var service_form_data = tourmaster_get_form_data(service_form);
1109                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
1110                    success: function(data){
1111                        step2_wrap.hide();
1112                        step3_wrap.fadeIn(150);
1113                        step3_wrap.find('.tourmaster-room-sidebar-summary-wrap').html(data.price_sidebar);
1114                        change_step(3);
1115                    }
1116                }, {
1117                    action: 'tourmaster_room_checkout_step',
1118                    data: { 
1119                        'coupon_code': price_sidebar.find('.tourmaster-room-coupon-code').val(),
1120                        'services': service_form_data['service'],
1121                        'booking_details': booking_details,
1122                    }
1123                });
1124            });
1125
1126            // step 3
1127            var contact_form = step3_wrap.find('.tourmaster-room-contact-detail-wrap');
1128
1129            function display_errors(elem, message){
1130                var error_html = $('<div class="tourmaster-error-message" ></div>').html(message);
1131                error_html.insertBefore(elem);
1132                error_html.slideDown(150);
1133            }
1134            function get_booking_data(){
1135                var service_form_data = tourmaster_get_form_data(service_form);
1136                var contact_info = tourmaster_get_form_data(contact_form);
1137                var required_billing = contact_form.find('.tourmaster-payment-billing-separate').is(':checked');
1138                
1139                contact_info['required-billing'] = required_billing;
1140                
1141                return { 
1142                    'coupon_code': price_sidebar.find('.tourmaster-room-coupon-code').val(),
1143                    'services': service_form_data['service'],
1144                    'booking_details': booking_details,
1145                    'contact_info': contact_info
1146                }
1147            }
1148            function validate_contact_form(){
1149
1150                // validate required fields
1151                var validate = true;
1152                var required_billing = contact_form.find('.tourmaster-payment-billing-separate').is(':checked');
1153                contact_form.find('input[data-required], select[data-required], textarea[data-required]').each(function(){
1154                    if( !required_billing && $(this).is('[name^="billing_"]') ) return;
1155                    if( !$(this).val() ){ validate = false; }
1156                });
1157
1158                return validate;
1159            }
1160            function clear_cart(){
1161                var current_time = (new Date()).getTime();
1162                if( payment_page.attr('data-type') == 'cart' ){
1163                    tourmaster_set_cookie('tourmaster-room-cart', '', current_time);
1164                }
1165                tourmaster_set_cookie('tourmaster-room-booking-detail', '', current_time);
1166                tourmaster_set_cookie('tourmaster-room-current-id', '', current_time);
1167                cart_button.trigger('clear');
1168            }
1169            
1170            step3_wrap.on('change', '.tourmaster-payment-billing-separate', function(){
1171                var billing_wrap = $(this).closest('.tourmaster-payment-billing-separate-wrap').siblings('.tourmaster-room-payment-billing-wrap');
1172
1173                if( $(this).is(':checked') ){
1174                    billing_wrap.slideDown(300);
1175                }else{
1176                    billing_wrap.slideUp(300);
1177                }
1178            });
1179
1180            step3_wrap.on('click', '.tourmaster-room-pay-type-item', function(){
1181                var deposit_amount_wrap = $(this).closest('.tourmaster-room-pay-type').siblings('.tourmaster-deposit-amount');
1182                $(this).addClass('tourmaster-active').siblings().removeClass('tourmaster-active');
1183
1184                if( $(this).hasClass('tourmaster-deposit') ){
1185                    pay_full_amount = false;
1186                    deposit_amount_wrap.slideDown(150);
1187                }else if( $(this).hasClass('tourmaster-full') ){
1188                    pay_full_amount = true;
1189                    deposit_amount_wrap.slideUp(150);
1190                }
1191            });
1192
1193            // book and pay later
1194            step3_wrap.on('click', '.tourmaster-pay-later', function(){
1195                
1196                $(this).siblings('.tourmaster-error-message').slideUp(150, function(){ $(this).remove(); });
1197
1198                var term_service = step3_wrap.find('[name="term-and-service"]');
1199                if( term_service.length ){
1200                    if( !term_service.is(':checked') ){
1201                        display_errors($(this), term_service.attr('data-error'));
1202                        return;
1203                    }
1204                }
1205
1206                var validate = validate_contact_form();
1207                if( !validate ){
1208                    display_errors($(this), step3_wrap.attr('data-required-error'));
1209                    return false;
1210                }
1211                
1212                // book the room
1213                if( $(this).hasClass('tourmaster-now-loading') ) return;
1214                $(this).addClass('tourmaster-now-loading');
1215
1216                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
1217                    success: function(data){
1218                        step3_wrap.hide();
1219                        step4_wrap.fadeIn(150);
1220                        change_step(4);
1221
1222                        $(this).removeClass('tourmaster-now-loading');
1223
1224                        // clear cart
1225                        clear_cart();
1226                    }
1227                }, {
1228                    action: 'tourmaster_room_pay_later',
1229                    data: get_booking_data()
1230                });
1231            });
1232            
1233            // pay now
1234            step3_wrap.on('click', '.tourmaster-pay-now', function(){
1235
1236                $(this).siblings('.tourmaster-error-message').slideUp(150, function(){ $(this).remove(); });
1237
1238                var term_service = step3_wrap.find('[name="term-and-service"]');
1239                if( term_service.length ){
1240                    if( !term_service.is(':checked') ){
1241                        display_errors($(this), term_service.attr('data-error'));
1242                        return;
1243                    }
1244                }
1245
1246                var validate = validate_contact_form();
1247                if( !validate ){
1248                    display_errors($(this), step3_wrap.attr('data-required-error'));
1249                    return false;
1250                }
1251
1252                var payment_method = $(this).closest('.tourmaster-room-payment-method-wrap').find('.tourmaster-payment-selection').val();
1253
1254                // book the room
1255                if( $(this).hasClass('tourmaster-now-loading') ) return;
1256                $(this).addClass('tourmaster-now-loading');
1257
1258                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
1259                    success: function(data){
1260                        if( payment_method == 'paypal' && data.payment_content ){
1261                            body.append(data.payment_content);
1262                        }else if( data.payment_content ){
1263                            var content = $('<div class="tourmaster-room-payment-lb" ></div>').html(data.payment_content);
1264                            tourmaster_lightbox(content);
1265                            if( typeof(data.order_id) != 'undefined' ){
1266                                tourmaster_set_cookie('tourmaster-room-current-id', data.order_id, 31536000);
1267                            }
1268
1269                            content.on('payment_complete', function(){
1270                                step3_wrap.hide();
1271                                step4_wrap.fadeIn(150);
1272                                change_step(4);
1273
1274                                $(this).closest('.tourmaster-lightbox-wrapper').trigger('lightbox_close');
1275                                clear_cart();
1276                            });
1277                        }
1278                        $(this).removeClass('tourmaster-now-loading');
1279                    }
1280                }, {
1281                    action: 'tourmaster_room_pay_now',
1282                    data: get_booking_data(),
1283                    'pay_full_amount': pay_full_amount,
1284                    'payment_method': payment_method
1285                });
1286            });
1287
1288            // pay woocommerce
1289            step3_wrap.on('click', '.tourmaster-pay-woocommerce', function(){
1290                
1291                $(this).siblings('.tourmaster-error-message').slideUp(1
129150, function(){ $(this).remove(); });
1292
1293                var term_service = step3_wrap.find('[name="term-and-service"]');
1294                if( term_service.length ){
1295                    if( !term_service.is(':checked') ){
1296                        display_errors($(this), term_service.attr('data-error'));
1297                        return;
1298                    }
1299                }
1300
1301                var validate = validate_contact_form();
1302                if( !validate ){
1303                    display_errors($(this), step3_wrap.attr('data-required-error'));
1304                    return false;
1305                }
1306                
1307                // book the room
1308                if( $(this).hasClass('tourmaster-now-loading') ) return;
1309                $(this).addClass('tourmaster-now-loading');
1310
1311                tourmaster_room_booking_ajax(payment_page.attr('data-ajax-url'), {
1312                    success: function(data){
1313                        // do something here
1314                        if( typeof(data.redirect_url) != 'undefined' ){
1315                            window.location.replace(data.redirect_url);
1316                        }
1317                        
1318                        $(this).removeClass('tourmaster-now-loading');
1319
1320                        // clear cart
1321                        clear_cart();
1322                    }
1323                }, {
1324                    action: 'tourmaster_room_pay_woocommerce',
1325                    data: get_booking_data()
1326                });
1327            });
1328
1329        });
1330    });
1331
1332    $(window).on('load', function(){
1333
1334
1335    });
1336
1337})(jQuery);

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.