PageSourceSearch

https://www.laminierapattaya.com/wp-content/themes/pro-theme-sequo…/assets/js/bookingform_popin.js?ver=1.0.1

js laminierapattaya.com collected 2026-09-26 13:53:37 UTC 11,603 bytes, 299 lines download raw bytes

1(function ($) {
2    function addZ(n) {
3        return n < 10 ? '0' + n : '' + n;
4    }
5    $.fn.serializeObject = function () {
6        var o = {};
7        var a = this.serializeArray();
8        $.each(a, function () {
9            if (o[this.name] !== undefined) {
10                if (!o[this.name].push) {
11                    o[this.name] = [o[this.name]];
12                }
13                o[this.name].push(this.value || '');
14            } else {
15                o[this.name] = this.value || '';
16            }
17        });
18        return o;
19    };
20
21    $(document).ready(function () {
22        //// bars
23        var dp = $('#inline-datepicker , #inline-datepicker_placeholder');
24        var today = new Date();
25
26        // update the hidden inputs
27        function update_inputs(arrival_date, departure_date, num_of_nights) {
28            // vars
29            var fromday = 0;
30            var frommonth = 0;
31            var fromyear = 0;
32            var today = 0;
33            var tomonth = 0;
34            var toyear = 0;
35            if (typeof num_of_nights !== 'undefined') {
36                $('input[name=nb_nights]').val(num_of_nights);
37            }
38            if (typeof arrival_date !== 'undefined' && arrival_date != false) {
39                fromday = ((new Date(arrival_date)).getDate() < 10 ? '0' : '') + (new Date(arrival_date)).getDate();
40                frommonth = ((new Date(arrival_date)).getMonth() < 9 ? '0' : '') + ((new Date(arrival_date)).getMonth() + 1);
41                fromyear = (new Date(arrival_date)).getFullYear();
42            }
43            if (typeof departure_date !== 'undefined' && departure_date != false) {
44                today = ((new Date(departure_date)).getDate() < 10 ? '0' : '') + (new Date(departure_date)).getDate();
45                tomonth = ((new Date(departure_date)).getMonth() < 9 ? '0' : '') + ((new Date(departure_date)).getMonth() + 1);
46                toyear = (new Date(departure_date)).getFullYear();
47            }
48
49            // i update the hidden fields for the QS form
50            $('input[name=fromday]').val(fromday);
51            $('input[name=frommonth]').val(frommonth);
52            $('input[name=fromyear]').val(fromyear);
53
54            // i update the hidden fields for departure date
55            $('input[name=today]').val(today);
56            $('input[name=tomonth]').val(tomonth);
57            $('input[name=toyear]').val(toyear);
58
59        }
60
61        //Adults
62
63        $('select[name=adults]').val(hotel_minadults);
64
65        $('select[name=adults]').on('change', function () {
66            $('input[name=adulteresa]').val($(this).val());
67        });
68
69        //Children
70
71        $(window).load(function () {
72            $('select[name=children]').val(hotel_minchildren);
73            //children ages
74            showChildren();
75            //update input
76            childrenAges();
77        });
78
79        $('select[name=children]').on('change', function () {
80            $('input[name=enfantresa]').val($(this).val());
81            //children ages
82            showChildren();
83            //update input
84            childrenAges();
85        });
86
87
88        $('.bf_select-child').on('change', function () {
89            childrenAges();
90        });
91
92        //procode
93        $('input[name=promocode]').on('change', function () {
94            $('input[name=AccessCode]').val($(this).val());
95        });
96
97
98        function showChildren() {
99            var booking = $('#bookingform');
100            var select_wrap = $('.section-nb_children');
101            var children_ages_wrap = $('.col.section-children_ages');
102            var child_age = children_ages_wrap.find('.section-children_age');
103            var close = booking.find('.close');
104            var itemToShow = $('select[name=children]').val();
105
106
107            //show children
108            if (itemToShow > 0) {
109                booking.addClass('children_ages_visible');
110                child_age.hide();
111                children_ages_wrap.show();
112                select_wrap.addClass('children_ages_visible');
113                child_age.each(function (index) {
114                    if (index < itemToShow) {
115                        $(this).show();
116                    }
117                });
118                centerBookingform();
119            } else {
120                children_ages_wrap.hide();
121                select_wrap.removeClass('children_ages_visible');
122                booking.removeClass('children_ages_visible');
123                centerBookingform();
124            }
125
126        }
127
128
129        function childrenAges() {
130            var child_sels = $('.bf_select-child');
131            var num_children = $('select[name=children]').val();
132            var values = new Array;
133            child_sels.each(function (k) {
134                var val = $(this).val();
135                if (val != '' && k <= num_children - 1) {
136                    values.push(val);
137                }
138            });
139            $('input[name=childrenAges1]').val(values.toString());
140        }
141
142        function get_arrival_date() {
143            var fromday = jQuery('input[name=fromday]').val();
144            var frommonth = jQuery('input[name=frommonth]').val();
145            var fromyear = jQuery('input[name=fromyear]').val();
146            return new Date(fromyear, parseInt(frommonth) - 1, fromday, 0, 0, 0, 0);
147        }
148
149        function get_departure_date() {
150            var today = jQuery('input[name=today]').val();
151            var tomonth = jQuery('input[name=tomonth]').val();
152            var toyear = jQuery('input[name=toyear]').val();
153            return new Date(toyear, parseInt(tomonth) - 1, today, 0, 0, 0, 0);
154        }
155
156        function build_datepicker_period(dateText, inst) {
157            var form = jQuery('#booking_form_container');
158            var num_of_nights;
159            prv = cur;
160            cur = (new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)).getTime();
161            if (prv == -1 || prv == cur) {
162                form.addClass('on-selection').removeClass('selection-finished');
163                prv = cur;
164                var selected_date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay);
165                var tomorrow = new Date(selected_date.getTime() + 86400000);
166                update_inputs(selected_date.getTime(), false, 0);
167                $('#inline-datepicker_placeholder').datepicker("setDate", tomorrow);
168
169            } else {
170                form.removeClass('on-selection').addClass('selection-finished');
171                num_of_nights = Math.abs(Math.round(( cur - prv ) / (24 * 60 * 60 * 1000)));
172                update_inputs(Math.min(prv, cur), Math.max(prv, cur), num_of_nights);
173                prv = -1;
174                cur = -1;
175                $('#inline-datepicker_placeholder').datepicker("setDate", new Date(Math.min(prv, cur)));
176            }
177        }
178
179
180        function init_datepickers(arrival_date, departure_date) {
181            // vars
182            var today = new Date().getTime() + hotel_delay * 86400000;
183            var tomorrow = new Date(today + hotel_minstay * 86400000);
184            if (typeof(hotel_opendate) !== 'undefined' && hotel_opendate !== '') {
185                var opendate_pcs = hotel_opendate.split("/");
186                var opendate = new Date(opendate_pcs[2], opendate_pcs[0] - 1, opendate_pcs[1]);
187                if (opendate.getTime() >= today) {
188                    today = opendate;
189                    tomorrow = new Date(opendate.getTime() + hotel_minstay * 86400000);
190                    tomorrow = new Date(tomorrow);
191                }else{
192                    today = new Date(today);
193                }
194            }else{
195                today = new Date(today);
196            }
197            // initialize inputs
198            update_inputs(today.getTime(), tomorrow.getTime());
199            window._date_format = 'dd MM yy';
200
201            window.cur = -1;
202            window.prv = -1;
203
204            var nb_months = $(window).width() < 768 ? 1 : 2;
205
206            // init the datepicker
207            dp.datepicker({
208                numberOfMonths: nb_months,
209                'minDate': today,
210                firstDay: first_day,
211                beforeShowDay: function (date) {
212                    var _class = '';
213                    var _arrival_date = get_arrival_date().getTime();
214                    var _departure_date = get_departure_date().getTime();
215                    if (date.getTime() == _arrival_date) {
216                        _class = 'date-range-selected checkin-date';
217                    } else if (date.getTime() == _departure_date) {
218                        _class = 'date-range-selected checkout-date';
219                    } else if (date.getTime() > _arrival_date && date.getTime() < _departure_date) {
220                        _class = 'date-range-selected';
221                    } else {
222                        _class = '';
223                    }
224
225                    return [true, _class];
226                },
227                onSelect: build_datepicker_period,
228                onUpdateDatepicker: function () {
229                    dpA11y(dp);
230                }
231            });
232        }
233
234
235        function openCloseBf() {
236            $('#bookingform .close').on('click', function () {
237                $('#bookingform_wrap').fadeOut();
238                $('html').removeClass('no_scroll');
239                $('#main_wrapper > *').removeAttr('inert');
240                $('body > *:not(#main_wrapper, #bookingform_wrap)').removeAttr('inert');
241                var buttonOnSlideshow = $('.slideshow_container a.open_booking:visible');
242
243                if( buttonOnSlideshow.length > 0 && $(window).scrollTop() < window_height ) {
244                    buttonOnSlideshow.focus();
245                }else if(!is_mobile){
246                    $('.open_booking:visible > a').focus();
247                }else{
248                    $('#mobile_bar a.open_booking:visible').focus();
249                }
250            });
251            $('.open_booking').on('click', function () {
252                $('#bookingform_wrap').appendTo('body');
253                $('#bookingform_wrap').fadeIn();
254                $('#main_wrapper > *').attr('inert', '');
255                $('body > *:not(#main_wrapper, #bookingform_wrap)').attr('inert', '');
256                $('#bookingform .close').focus();
257                centerBookingform();
258            });
259            $('#bookingform').on('keydown', function (e) {
260                if (e.keyCode == 27) {
261                    $('#bookingform_wrap').fadeOut();
262                    $('html').removeClass('no_scroll');
263                    $('#main_wrapper > *').removeAttr('inert');
264                    $('body > *:not(#main_wrapper, #bookingform_wrap)').removeAttr('inert');
265                    $('.open_booking:visible > a, a.open_booking:visible').focus();
266
267                }
268            });
269        }
270
271        function centerBookingform() {
272            var wrap = $('#bookingform_wrap');
273            var bookingform = $('#bookingform');
274            var wrap_height = wrap.outerHeight();
275            var bookingform_height = bookingform.outerHeight();
276            if (bookingform_height < wrap_height) {
277                bookingform.css({
278                    'margin-top': (wrap_height - bookingform_height) / 2
279                });
280            } else {
281                wrap.css({
282                    'overflow': 'auto'
283                });
284                bookingform.css({
285                    'margin-top': 0
286                });
287
288            }
289        }
290
291        //START ME UP
292        init_datepickers();
293        //OPEN CLOSE BF
294        openCloseBf();
295
296    }); // END DOM READY
297
298})(jQuery);
299

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.