PageSourceSearch

https://classicamalficoast.com/wp-content/themes/BookYourTravel/js/tours.js?ver=8.05

js classicamalficoast.com collected 2026-09-26 20:14:14 UTC 37,809 bytes, 839 lines download raw bytes

1/*jslint browser: true*/ /*jslint long:true*/ /*jslint for:true*/ /*global bookyourtravel_scripts*/ /*global bookyourtravel_extra_items*/ /*global jQuery*/ /*jslint this:true */ /*global window*/ /*global BYTAjax*/ /*global console*/
2
3(function ($) {
4
5    "use strict";
6
7    var bookyourtravel_tours;
8
9    $(document).ready(function () {
10        bookyourtravel_tours.init();
11    });
12
13    bookyourtravel_tours = {
14        init: function () {
15            if ($(".tour-booking-form-calendar .booking_form_controls_holder").length > 0) {
16                bookyourtravel_tours.initBookingRequestObject();
17
18                $(".toggle_breakdown").off("click");
19                $(".toggle_breakdown").on("click", function (e) {
20                    if ($(".price_breakdown_row").hasClass("hidden")) {
21                        $(".price_breakdown_row").removeClass("hidden");
22                        if (window.enableExtraItems) {
23                            $(".price_breakdown_row").show("");
24                        } else {
25                            $(".price_breakdown_row:not(.extra_items_breakdown_row)").show();
26                        }
27                        $(".toggle_breakdown").html(window.hidePriceBreakdownLabel);
28                    } else {
29                        $(".price_breakdown_row").addClass("hidden");
30                        $(".price_breakdown_row").hide();
31                        $(".toggle_breakdown").html(window.showPriceBreakdownLabel);
32                    }
33
34                    e.preventDefault();
35                });
36
37                $(".booking-commands").hide();
38
39                $(".extra_item_quantity").uniform();
40
41                $(".radio").on(
42                    "click.uniform",
43                    function (ignore) {
44                        if ($(this).find("span").hasClass("checked")) {
45                            $(this).find("input").attr("checked", true);
46                        } else {
47                            $(this).find("input").attr("checked", false);
48                        }
49                    }
50                );
51
52                bookyourtravel_tours.bindResetButton();
53                bookyourtravel_tours.bindNextButton();
54                bookyourtravel_tours.bindCancelButton();
55
56                if (window.enableExtraItems) {
57                    bookyourtravel_extra_items.bindExtraItemsQuantitySelect();
58                    bookyourtravel_extra_items.buildExtraItemsTable();
59                }
60
61                $("#booking-form-calendar .loading").parent().show();
62                $(".booking_form_controls_holder").hide();
63
64                bookyourtravel_tours.populateAvailableTourDates(bookyourtravel_tours.checkPreselectedTourDateAndPopulateAccordingly, true, true);
65            }
66
67            if ($("[data-tour-id]").length > 0) {
68                bookyourtravel_tours.populateTourPrices();
69            }
70
71            if ($("[data-location-id]").length > 0 && $("[data-min-price-type='tour']").length > 0) {
72                bookyourtravel_scripts.populateLocationPrices("tour");
73            }
74        },
75        populateTourPrices: function () {
76            if ($("[data-tour-id]").length > 0) {
77                var tourItems = $("[data-tour-id]");
78                $.each(tourItems, function () {
79                    var tourId = parseInt($(this).data("tour-id"));
80                    var price = 0;
81
82                    if ($("[data-tour-id='" + tourId + "'] .price .amount").length > 0) {
83                        $("[data-tour-id='" + tourId + "'] .price .amount").html("");
84                        $("[data-tour-id='" + tourId + "'] .price .curr").html("");
85
86                        var dataObj = {
87                            "action": "tour_load_min_price_ajax_request",
88                            "start_date": window.requestedDateFrom,
89                            "end_date": window.requestedDateTo,
90                            "tour_id": tourId,
91                            "nonce": BYTAjax.nonce
92                        };
93
94                        $.ajax({
95                            url: BYTAjax.slimajaxurl,
96                            data: dataObj,
97                            success: function (data) {
98                                price = JSON.parse(data);
99                                if (price !== undefined && price > 0) {
100                                    $("[data-tour-id='" + tourId + "'] .item_price").show();
101                                    $("[data-tour-id='" + tourId + "'] .price .curr").html(window.currencySymbol);
102                                    $("[data-tour-id='" + tourId + "'] .price .amount").html(bookyourtravel_scripts.formatPriceOnly(price));
103                                } else {
104                                    $("[data-tour-id='" + tourId + "'] .item_price").hide();
105                                }
106                            },
107                            error: function (errorThrown) {
108                                console.log(errorThrown);
109                            }
110                        });
111                    }
112                });
113            }
114        },
115        initBookingRequestObject: function () {
116
117            if (!window.bookingRequest || window.bookingRequest === undefined || window.bookingRequest.length === 0) {
118                window.bookingRequest = {};
119            }
120
121            window.bookingRequest.extraItems = {};
122            window.bookingRequest.adults = 1;
123            window.bookingRequest.children = 0;
124            window.bookingRequest.units = 1;
125            window.bookingRequest.people = 1;
126            window.bookingRequest.extraItemsTotalPrice = 0;
127            window.bookingRequest.totalTourOnlyPrice = 0;
128            window.bookingRequest.totalPrice = 0;
129            window.bookingRequest.totalDays = window.tourDurationDays;
130            window.bookingRequest.selectedDate = null;
131            window.bookingRequest.selectedTime = null;
132            window.bookingRequest.maxAllowedPeople = 1;
133        },
134        bindTourDropDowns: function () {
135
136            var countOffset = window.bookingRequest.maxAllowedPeople - window.bookingRequest.adults 
136- window.bookingRequest.children;
137            var maxAdultCount = window.bookingRequest.adults + countOffset;
138            if (maxAdultCount < window.bookingRequest.adults) {
139                maxAdultCount = parseInt(window.bookingRequest.adults);
140            } else if (maxAdultCount > window.bookingRequest.maxAllowedPeople) {
141                maxAdultCount = parseInt(window.bookingRequest.adults);
142            }
143
144            $("#booking_form_adults").unbind();
145            $("#booking_form_adults").find("option").remove();
146            var i = 1;
147            for (i = 1; i <= maxAdultCount; i += 1) {
148                $("<option " + (
149                    i === window.bookingRequest.adults
150                    ? "selected"
151                    : ""
152                ) + ">").val(i).text(i).appendTo("#booking_form_adults");
153            }
154
155            $("#booking_form_adults").on("change", function (ignore) {
156                if (parseInt($(this).val()) !== window.bookingRequest.adults) {
157                    window.bookingRequest.adults = parseInt($(this).val());
158                    $("span.adults_text").html(window.bookingRequest.adults);
159                    window.bookingRequest.people = window.bookingRequest.adults + window.bookingRequest.children;
160
161                    bookyourtravel_tours.bindTourDropDowns();
162                    bookyourtravel_tours.buildRatesTable();
163                }
164            });
165
166            countOffset = window.bookingRequest.maxAllowedPeople - window.bookingRequest.adults - window.bookingRequest.children;
167            var maxChildrenCount = window.bookingRequest.children + countOffset;
168            if (maxChildrenCount < window.bookingRequest.children) {
169                maxChildrenCount = parseInt(window.bookingRequest.children);
170            } else if (maxChildrenCount > window.bookingRequest.maxAllowedPeople) {
171                maxChildrenCount = parseInt(window.bookingRequest.children);
172            }
173
174            $("#booking_form_children").unbind();
175            $("#booking_form_children").find("option").remove();
176            $("<option selected>").val(0).text(0).appendTo("#booking_form_children");
177            var j = 1;
178            for (j = 1; j <= maxChildrenCount; j += 1) {
179                $("<option " + (
180                    j === window.bookingRequest.children
181                    ? "selected"
182                    : ""
183                ) + ">").val(j).text(j).appendTo("#booking_form_children");
184            }
185
186            $("#booking_form_children").on("change", function (ignore) {
187                if (parseInt($(this).val()) !== window.bookingRequest.children) {
188                    window.bookingRequest.children = parseInt($(this).val());
189                    $("span.children_text").html(window.bookingRequest.children);
190                    bookyourtravel_tours.bindTourDropDowns();
191                    bookyourtravel_tours.buildRatesTable();
192                }
193            });
194
195            $("#booking_form_children").val(window.bookingRequest.children);
196            $("#booking_form_adults").val(window.bookingRequest.adults);
197
198            $("#booking_form_adults").uniform();
199            $("#booking_form_children").uniform();
200
201            window.bookingRequest.people = window.bookingRequest.adults + window.bookingRequest.children;
202        },
203        checkPreselectedTourDateAndPopulateAccordingly: function () {
204            if (window.bookingRequest.requestedDateFrom && window.availableTourDates && window.availableTourDates.indexOf(window.bookingRequest.requestedDateFrom) >= 0) {
205                var dateFrom = bookyourtravel_scripts.convertLocalToUTC(new Date(window.bookingRequest.requestedDateFrom));
206                var timeFrom = Date.UTC(dateFrom.getFullYear(), dateFrom.getMonth(), dateFrom.getDate());
207                bookyourtravel_tours.selectTourDate(timeFrom, window.bookingRequest.requestedDateFrom);
208            }
209
210            $("#booking-form-calendar .loading").parent().hide();
211            $(".booking_form_controls_holder").show();
212            bookyourtravel_tours.bindTourDatePicker();
213        },
214        populateAvailableTourDates: function (callDelegate, skipLoaderStart, skipLoaderEnd) {
215
216            if (!skipLoaderStart) {
217                $("#booking-form-calendar .loading").parent().show();
218                $(".booking_form_controls_holder").hide();
219            }
220
221            var dateArray = [];
222            window.availableTourDates = [];
223            var startDate = new Date();
224
225            var dataObj = {
226                "action": "tour_available_dates_ajax_request",
227                "tour_id": window.tourId,
228                "month": window.currentMonth,
229                "year": window.currentYear,
230                "start_date": (startDate.getFullYear() + "-" + (startDate.getMonth() + 1) + "-" + startDate.getDate()),
231                "month_range": window.calendarMonthRows * window.calendarMonthCols,
232                "nonce": BYTAjax.nonce
233            };
234
235            $.ajax({
236                url: BYTAjax.slimajaxurl,
237                data: dataObj,
238                success: function (datesJson) {
239
240                    var retrievedEntries = JSON.parse(datesJson);
241
242                    var i = 0;
243                    for (i = 0; i < retrievedEntries.length; i += 1) {
244                        if (retrievedEntries[i].the_date !== null) {
245                            dateArray.push(retrievedEntries[i].the_date);
246                        }
247                    }
248
249                    window.availableTourDates = dateArray;
250
251                    if (window.availableTourDates.length > 0) {
252                        if (callDelegate !== undefined) {
253                            callDelegate();
254                        }
255
256                        if (!skipLoaderEnd) {
257                            $(".booking_form_controls_holder").show();
258                            $("#booking-form-calendar .loading").parent().hide();
259                        }
260                    } else {
261                        $(".no-availability").show();
262                        $("#booking-form-calendar .loading").parent().hide();
263                    }
264                },
265                error: function (errorThrown) {
266                    console.log(errorThrown);
267                }
268            });
269        },
270        bindNextButton: function () {
271
272            $(".book-tour-proceed").unbind("click");
273            $(".book-tour-proceed").on("click", function (event) {
274
275                if (!window.tourIsReservationOnly && window.useWoocommerceForCheckout) {
276                    bookyourtravel_tours.addProductToCart();
277                } else {
278
279                    $("#booking-form-calendar .loading").parent().show();
280
281                    bookyourtravel_tours.showTourBookingForm();
282
283                    $("#booking-form-calendar .loading").parent().hide();
284                }
285
286                event.preventDefault();
287            });
288        },
289        destroyDatePicker: function () {
290            if ($(".booking_form_datepicker") !== undefined) {
291                $(".booking_form_datepicker").datepicker("destroy");
292            }
293        },
294        resetTheForm: function () {
295
296            // bookyourtravel_tours.destroyDatePicker();
297
298            $("html, body").animate({
299                scrollTop: $("#booking-form-calendar").offset().top
300            }, 500);
301
302            $(".booking_form_datepicker").hide();
303
304            if (window.bookingRequest.selectedTime && window.bookingRequest.selectedTime > 0) {
305                delete window.bookingRequest;
306            }
307
308            bookyourtravel_tours.initBookingRequestObject();
309            bookyourtravel_tours.bindTourDropDowns();
310
311            $("#selected_date").val("");
312            $(".extra_item_quantity").val("0");
313            $("#tour_date_span").html("");
314            $("#tour_date").val("");
315            $(".dates_row").hide();
316            $(".price_row").hide();
317            $(".booking-commands").hide();
318            $("table.booking_price_breakdown tbody").html("");
319
320            $(".reservation_total").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalTourOnlyPrice));
321            $(".extra_items_total").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.extraItemsTotalPrice));
322            $(".total_price").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalPrice));
323            $(".confirm_total_price_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalPrice));
324
325            $("table.extra_items_price_breakdown tbody").html("");
326
327            // bookyourtravel_tours.bindTourDatePicker();
328            bookyourtravel_tours.refreshDatePicker();
329        },
330        bindResetButton: function () {
331            $(".book-tour-reset").unbind("click");
332            $(".book-tour-reset").on("click", function (event) {
333                event.preventDefault();
334                bookyourtravel_tours.resetTheForm();
335            });
336        },
337        bindCancelButton: function () {
338            $("#cancel-tour-booking, .close-btn").unbind("click");
339            $("#cancel-tour-booking, .close-btn").on("click", function (event) {
340                $(".modal").hide();
341                bookyourtravel_tours.hideTourBookingForm();
342                bookyourtravel_tours.showTourScreen();
343                bookyourtravel_tours.resetTheForm();
344                $("#tour-booking-form .error-summary").hide();
345                $("#tour-booking-form label.error").hide();
346                $("#tour-booking-form input.error").removeClass("error");
347                $("#tour-booking-form input, #tour-booking-form textarea").val("");
348
349                event.preventDefault();
350            });
351        },
352        showTourScreen: function () {
353            $(".section-" + window.postType + "-content").show();
354            if ($(".inner-nav li.active").length > 0) {
355                var tabAnchor = $(".inner-nav li.active a");
356                var tabUrl = tabAnchor.attr("href");
357                var hashbang = tabUrl.substring(tabUrl.indexOf("#") + 1);
358                var anch = $(".inner-nav li a[href=#" + hashbang + "]");
359                if (anch.length > 0) {
360                    if (anch.parent().length > 0) {
361                        $(".inner-nav li").removeClass("active");
362                        anch.parent().addClass("active");
363                        $(".tab-content").hide();
364                        $(".tab-content#" + hashbang).show();
365                    }
366                }
367            }
368        },
369        showTourBookingForm: function () {
370
371            $("body").addClass("modal-open");
372
373            var adults = (
374                (window.bookingRequest.adults !== undefined && window.bookingRequest.adults)
375                ? window.bookingRequest.adults
376                : "1"
377            );
378
379            var children = (
380                (window.bookingRequest.children !== undefined && window.bookingRequest.children)
381                ? window.bookingRequest.children
382                : "0"
383            );
384
385            $(".booking_form_tour_name_p").html(window.tourTitle);
386            $(".booking_form_adults_p").html(adults);
387            $(".booking_form_children_p").html(children);
388            $(".booking_form_tour_date_p").html(window.bookingRequest.selectedDate);
389            $(".booking_form_reservation_total_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalTourOnlyPrice));
390            $(".booking_form_extra_items_total_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.extraItemsTotalPrice));
391            $(".booking_form_total_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalPrice));
392
393            $(".section-" + window.postType + "-content").hide();
394
395            $(".tour-booking-section").show();
396
397            if (window.tourIsReservationOnly || !window.useWoocommerceForCheckout) {
398
399                $("#tour-booking-form").validate({
400                    onkeyup: false,
401                    ignore: [],
402                    invalidHandler: function (ignore, validator) {
403                        var errors = validator.numberOfInvalids();
404                        if (errors) {
405                            var message = (
406                                errors === 1
407                                ? window.formSingleError
408                                : window.formMultipleError.format(errors)
409                            );
410
411                            $("#tour-booking-form div.error-summary div p").html(message);
412                            $("#tour-booking-form div.error-summary").show();
413                        } else {
414                            $("#tour-booking-form div.error-summary").hide();
415                            $(".error").hide();
416                        }
417
418                        $(".booking-section").animate({
419                            scrollTop: $("#tour-booking-form div.error-summary").offset().top - 100
420                        }, 500);
421                    },
422                    errorPlacement: function (error, element) {
423                        if ($(element).attr("type") === "checkbox") {
424                            error.appendTo($(element).closest("div").parent());
425                            $(element).closest("div").addClass("error");
426                        } else {
427                            error.insertAfter(element);
428                        }
429                    },
430                    success: function (error, element) {
431                        if ($(element).attr("type") === "checkbox") {
432                            $(element).closest("div").removeClass("error");
433                        }
434                        error.remove();
435                    },
436                    submitHandler: function () {
437                        bookyourtravel_tours.processBooking();
438                    }
439                });
440
441                $("#submit-tour-booking").on('click', function (e) {
442                    e.preventDefault();
443                    if ($("#tour-booking-form").valid()) {
444                        $("#tour-booking-form").submit();
445                    }
446                });
447
448                $.each(window.bookingFormFields, function (ignore, field) {
449
450                    if (field.hide !== "1" && field.id !== null && field.id.length > 0) {
451                        var $input = null;
452                        if (field.type === "text" || field.type === "email") {
453                            $input = $("#tour-booking-form").find("input[name=" + field.id + "]");
454                        } else if (field.type === "textarea") {
455                            $input = $("#tour-booking-form").find("textarea[name=" + field.id + "]");
456                        } else if (field.type === "checkbox") {
457                            $input = $("#tour-booking-form").find("input[name=" + field.id + "]");
458                        } else if (field.type === "select") {
459                            $input = $("#tour-booking-form").find("select[name=" + field.id + "]");
460                        }
461
462                        if ($input !== null && $input !== undefined) {
463                            if (field.required === "1") {
464                                $input.rules("add", {
465                                    required: true,
466                                    messages: {
467                                        required: window.bookingFormRequiredError
468                                    }
469                                });
470                            }
471                            if (field.type === "email") {
472                                $input.rules("add", {
473                                    email: true,
474                                    messages: {
475                                        required: window.bookingFormEmailError
476                                    }
477                                });
478                            }
479                        }
480                    }
481                });
482            }
483
484            if (!window.tourIsReservationOnly && window.useWoocommerceForCheckout) {
485                $("html, body").animate({
486                    scrollTop: $("#booking-form-calendar").offset().top
487                }, 500);
488            }
489        },
490        hideTourBookingForm: function () {
491            $("body").removeClass("modal-open");
492            $(".tour-booking-section").hide();
493        },
494        showTourConfirmati
494onForm: function () {
495            $(".tour-confirmation-section").show();
496        },
497        bindTourDatePicker: function () {
498            if ($(".booking_form_datepicker") !== undefined) {
499                $(".booking_form_datepicker").datepicker({
500                    dateFormat: window.datepickerDateFormat,
501                    numberOfMonths: [window.calendarMonthRows, window.calendarMonthCols],
502                    minDate: 0,
503                    onSelect: function (dateText, inst) {
504                        var selectedTime = Date.UTC(inst.currentYear, inst.currentMonth, inst.currentDay);
505                        bookyourtravel_tours.selectTourDate(selectedTime, dateText);
506                        $("#booking-form-calendar .loading").parent().hide();
507                    },
508                    onChangeMonthYear: function (year, month, ignore) {
509
510                        window.currentMonth = month;
511                        window.currentYear = year;
512                        window.currentDay = 1;
513
514                        bookyourtravel_tours.populateAvailableTourDates(bookyourtravel_tours.refreshDatePicker);
515                    },
516                    beforeShowDay: function (d) {
517                        var dUtc = Date.UTC(d.getFullYear(), d.getMonth(), d.getDate());
518
519                        var selectedTime = null;
520
521                        if ($("#tour_date").val()) {
522                            selectedTime = parseInt($("#tour_date").val());
523                        }
524
525                        if (window.availableTourDates) {
526                            var dateTextToCompare = d.getFullYear() + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2);
527
528                            if (dUtc === selectedTime) {
529                                return [false, "dp-hightlight dp-highlight-selected"];
530                            }
531                            if ($.inArray(dateTextToCompare, window.availableTourDates) === -1) {
532                                return [false, "ui-datepicker-unselectable ui-state-disabled"];
533                            }
534
535                            return [true, "dp-highlight"];
536                        }
537
538                        return [false, ""];
539                    }
540
541                });
542            }
543        },
544        processBooking: function () {
545            if (window.bookingRequest !== undefined) {
546                $(".booking_form_controls_holder, .booking-commands .book-tour-proceed").hide();
547                $("#booking-form-calendar .loading").parent().show();
548
549                var selectedDate = bookyourtravel_tours.getSelectedTourDate();
550                var tourDate = selectedDate.getFullYear() + "-" + (selectedDate.getMonth() + 1) + "-" + selectedDate.getDate();
551
552                var dataObj = {
553                    "action": "tour_process_booking_ajax_request",
554                    "user_id": window.currentUserId,
555                    "tour_id": window.tourId,
556                    "adults": window.bookingRequest.adults,
557                    "children": window.bookingRequest.children,
558                    "extra_items": window.bookingRequest.extraItems,
559                    "tour_date": tourDate,
560                    "nonce": BYTAjax.nonce
561                };
562
563                $.each(window.bookingFormFields, function (ignore, field) {
564                    if (field.hide !== "1") {
565                        dataObj[field.id] = $("#" + field.id).val();
566                        $(".confirm_" + field.id + "_p").html($("#" + field.id).val());
567                    }
568                });
569
570                $(".confirm_tour_name_p").html(window.tourTitle);
571                $(".confirm_tour_name_div").addClass("one-half");
572
573                $(".confirm_adults_p").html(window.bookingRequest.adults);
574                $(".confirm_children_p").html(window.bookingRequest.children);
575                $(".confirm_tour_date_p").html(window.bookingRequest.selectedDate);
576
577                if ($(".confirm_reservation_total_p").length > 0) {
578                    $(".confirm_reservation_total_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalTourOnlyPrice));
579                }
580                if ($(".confirm_extra_items_total_p").length > 0) {
581                    $(".confirm_extra_items_total_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.extraItemsTotalPrice));
582                }
583                $(".confirm_total_price_p").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalPrice));
584
585                bookyourtravel_tours.hideTourBookingForm();
586                bookyourtravel_tours.showTourConfirmationForm();
587
588                $.ajax({
589                    url: BYTAjax.ajaxurl,
590                    data: dataObj,
591                    success: function (ignore) {
592                        // This outputs the result of the ajax request
593                        $("div.error div p").html("");
594                        $("div.error").hide();
595
596                        $(".booking_form_controls_holder, .booking-commands .book-tour-proceed").show();
597                        $("#booking-form-calendar .loading").parent().hide();
598                    },
599                    error: function (errorThrown) {
600                        console.log(errorThrown);
601                    }
602                });
603            }
604        },
605        buildRatesTable: function () {
606            var selectedTime = bookyourtravel_tours.getSelectedTourTime();
607
608            $(".price_row").show();
609            $.uniform.update(".extra_item_quantity");
610
611            $("table.booking_price_breakdown tbody").html("");
612
613            if (selectedTime) {
614
615                $("#booking-form-calendar .loading").parent().show();
616
617                $(".reservation_total").html(bookyourtravel_scripts.getSmallLoaderHtml());
618                $(".total_price").html(bookyourtravel_scripts.getSmallLoaderHtml());
619                $(".extra_items_total").html(bookyourtravel_scripts.getSmallLoaderHtml());
620
621                window.bookingRequest.totalPrice = 0;
622                window.bookingRequest.totalTourOnlyPrice = 0;
623
624                bookyourtravel_tours.buildRatesTableStructure();
625                bookyourtravel_tours.buildRateRow(selectedTime);
626            }
627        },
628        buildRatesTableStructure: function () {
629
630            $("table.booking_price_breakdown thead").html("");
631            $("table.booking_price_breakdown tfoot").html("");
632
633            var colCount = 2;
634
635            var headerRow = "";
636            headerRow += "<tr class='rates_head_row'>";
637            headerRow += "<th>" + window.dateLabel + "</th>";
638
639            if (!window.tourIsPricePerGroup) {
640                headerRow += "<th>" + window.adultCountLabel + "</th>";
641                headerRow += "<th>" + window.pricePerAdultLabel + "</th>";
642                headerRow += "<th>" + window.childCountLabel + "</th>";
643                headerRow += "<th>" + window.pricePerChildLabel + "</th>";
644                colCount = 6;
645            }
646
647            headerRow += "<th>" + window.pricePerDayLabel + "</th>";
648
649            $("table.booking_price_breakdown thead").append(headerRow);
650
651            var footerRow = "";
652
653            footerRow += "<tr>";
654            footerRow += "<th colspan='" + (colCount - 1) + "'>" + window.priceTotalLabel + "</th>";
655            footerRow += "<td class='reservation_total'>" + bookyourtravel_scripts.formatPrice(0) + "</td>";
656            footerRow += "</tr>";
657
658            $("table.booking_price_breakdown tfoot").append(footerRow);
659        },
660        buildRateRow: function (tourTime) {
661            var tourDate = bookyourtravel_scripts.convertLocalToUTC(new Date(tourTime));
662            var theDate = tourDate.getFullYear() + "-" + (tourDate.getMonth() + 1) + "-" + tourDate.getDate();
663
664            var pricePerPeriod = 0;
665            var childPricePerPeriod = 0;
666            var totalPricePerPeriod = 0;
667            var children = window.bookingRequest.children;
668            var adults = window.bookingRequest.adults;
669            var tableRow = "";
670
671            var dataObj = {
672                "action": "tour_get_day_price_ajax_request",
673                "tour_id": window.tourId,
674                "the_date": theDate,
675                "nonce": BYTAjax.nonce
676            };
677
678            $.ajax({
679                url: BYTAjax.slimajaxurl,
680                data: dataObj,
681                success: function (data) {
682                    var price_data = JSON.parse(data);
683
684                    if (price_data && price_data.regular_price) {
685
686                        window.bookingRequest.maxAllowedPeople = price_data.running_available_total - price_data.booked_places;
687                        bookyourtravel_tours.bindTourDropDowns();
688
689                        tableRow += "<tr>";
690                        tableRow += "<td>" + $.datepicker.formatDate(window.datepickerDateFormat, tourDate) + "</td>";
691
692                        pricePerPeriod = parseFloat(price_data.regular_price);
693                        childPricePerPeriod = parseFloat(price_data.regular_price_child);
694
695                        if (!window.tourIsPricePerGroup) {
696                            tableRow += "<td>" + adults + "</td>";
697                            tableRow += "<td>" + bookyourtravel_scripts.formatPrice(pricePerPeriod) + "</td>";
698                            tableRow += "<td>" + window.bookingRequest.children + "</td>";
699                            tableRow += "<td>" + bookyourtravel_scripts.formatPrice(childPricePerPeriod) + "</td>";
700                        }
701
702                        if (!window.tourIsPricePerGroup) {
703                            totalPricePerPeriod = (pricePerPeriod * adults) + (childPricePerPeriod * children);
704                        } else {
705                            totalPricePerPeriod = pricePerPeriod;
706                        }
707
708                        tableRow += "<td>" + bookyourtravel_scripts.formatPrice(totalPricePerPeriod) + "</td>";
709
710                        window.bookingRequest.totalPrice += totalPricePerPeriod;
711                        window.bookingRequest.totalTourOnlyPrice += totalPricePerPeriod;
712
713                        tableRow += "</tr>";
714
715                        bookyourtravel_extra_items.recalculateExtraItemTotals(window.bookingRequest.totalTourOnlyPrice);
716
717                        $("table.booking_price_breakdown tbody").append(tableRow);
718
719                        if ($("table.booking_price_breakdown").data("tablesorter") === null || $("table.booking_price_breakdown").data("tablesorter") === undefined) {
720                            $("table.booking_price_breakdown").tablesorter({
721                                debug: false,
722                                dateFormat: window.datepickerDateFormat, // "ddmmyyyy",
723                                sortList: [[0, 0]]
724                            });
725                        }
726
727                        $("table.booking_price_breakdown").trigger("update");
728                        $("table.booking_price_breakdown").trigger("sorton", [[[0, 0]]]);
729
730                        $("table.responsive").trigger("updated");
731
732                        $(".reservation_total").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalTourOnlyPrice));
733                        $(".total_price").html(bookyourtravel_scripts.formatPrice(window.bookingRequest.totalPrice));
734
735                        bookyourtravel_tours.bindNextButton();
736                        bookyourtravel_tours.bindCancelButton();
737
738                        $("#booking-form-calendar .loading").parent().hide();
739                        $(".booking-commands").show();
740                        $(".booking-commands .book-tour-proceed").show();
741                    }
742                }
743            });
744        },
745        addProductToCart: function () {
746
747            $(".booking_form_controls_holder, .booking-commands .book-tour-proceed").hide();
748            $("#booking-form-calendar .loading").parent().show();
749
750            $("html, body").animate({
751                scrollTop: $("#booking-form-calendar").offset().top - 100
752            }, 500);
753
754            var selectedDate = bookyourtravel_tours.getSelectedTourDate();
755            var tourDate = selectedDate.getFullYear() + "-" + (selectedDate.getMonth() + 1) + "-" + selectedDate.getDate();
756
757            var dataObj = {
758                "action": "tour_booking_add_to_cart_ajax_request",
759                "user_id": window.currentUserId,
760                "tour_id": window.tourId,
761                "adults": window.bookingRequest.adults,
762                "children": window.bookingRequest.children,
763                "extra_items": window.bookingRequest.extraItems,
764                "tour_date": tourDate,
765                "nonce": BYTAjax.nonce
766            };
767
768            $.each(window.bookingFormFields, function (ignore, field) {
769                if (field.hide !== "1") {
770                    dataObj[field.id] = $("#" + field.id).val();
771                }
772            });
773
774            $.ajax({
775                url: BYTAjax.ajaxurl,
776                data: dataObj,
777                success: function (ignore) {
778                    $("#booking-form-calendar .redirect-notice").show();
779                    $("#booking-form-calendar .loading").parent().hide();
780                    $("#booking-form-calendar .booking-commands").hide();
781                    bookyourtravel_scripts.redirectToCart();
782                },
783                error: function (errorThrown) {
784                    console.log(errorThrown);
785                }
786            });
787        },
788        getSelectedTourTime: function () {
789            if ($("#tour_date").val()) {
790                return parseInt($("#tour_date").val());
791            }
792            return null;
793        },
794        getSelectedTourDate: function () {
795            if ($("#tour_date").val()) {
796                return bookyourtravel_scripts.convertLocalToUTC(new Date(parseInt($("#tour_date").val())));
797            }
798            return null;
799        },
800        selectTourDate: function (time, dateText) {
801
802            bookyourtravel_tours.initBookingRequestObject();
803
804            $("div.error.step1-error div p").html("");
805            $("div.error.step1-error").hide();
806            $(".price_breakdown").show();
807            $("table.booking_price_breakdown tbody").html("");
808
809            $(".dates_row").show();
810            $(".price_row").show();
811
812            $("#tour_date").val(time);
813            $("#tour_date_span").html(dateText);
814            $("#duration_days_span").html(window.tourDurationDays);
815            $("#duration_days").val(window.tourDurationDays);
816
817            window.bookingRequest.selectedTime = time;
818            window.bookingRequest.selectedDate = dateText;
819
820            bookyourtravel_extra_items.bindRequiredExtraItems();
821            bookyourtravel_tours.buildRatesTable();
822
823            $("html, body").animate({
824                scrollTop: $(".price_row").first().offset().top
825            }, 1000);
826
827        },
828        refreshDatePicker: function () {
829
830            if ($(".booking_form_datepicker") !== undefined) {
831                $(".booking_form_datepicker").datepicker("refresh");
832                $(".booking_form_datepicker").show();
833            }
834
835            $("#booking-form-calendar .loading").parent().hide();
836        }
837    };
838
839}(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.