PageSourceSearch

https://www.arielhouse.ie/wp-content/themes/avviowpcms2-arielhouse…/js/booking-panel-v4.js?ver=1675086390

js arielhouse.ie collected 2026-10-07 11:56:51 UTC 6,380 bytes, 213 lines download raw bytes

1
2var bookingEngineURL = '/';
3if (typeof $BEURL !== 'undefined') bookingEngineURL = $BEURL;
4
5
6var months = [ "January", "February", "March", "April", "May", "June",
7        "July", "August", "September", "October", "November", "December" ];
8
9var datepickersInitialized = false;
10
11
12function openCloseBP(open) {
13	open = (typeof open !== 'undefined') ? open : false;
14
15	if(open) {
16		$('.booking-panel').css('display', '');
17		setTimeout(function(){ // timeout bug fix for mac safari
18			$('.booking-panel').removeClass('hidden').addClass('visible');
19		}, 100);
20	} else {
21		$('.booking-panel').removeClass('visible').addClass('hidden');
22	}
23}
24
25function initializeDatepickers() {
26	var checkinField = $('.booking-panel #bp_ci_date'),
27		checkoutField = $('.booking-panel #bp_co_date'),
28		ciDay = $('.booking-panel #ci_d'),
29		ciMonth =  $('.booking-panel #ci_m'),
30		coDay = $('.booking-panel #co_d'),
31		coMonth =  $('.booking-panel #co_m');
32
33	var defaultDate = new Date;
34	defaultDate.setHours(0,0,0,0);
35	var defaultDate2 = new Date;
36	defaultDate2.setHours(0,0,0,0);
37	defaultDate2.setDate(defaultDate2.getDate() + 1);
38
39	$.datepicker.setDefaults({
40		dateFormat: 'dd MM yy'
41	});
42
43	var checkinDate = defaultDate;
44	var checkoutDate = defaultDate2;
45
46	checkinField.datepicker({
47		beforeShow: function(textbox, instance){
48			$('.booking-panel .booking-section.section-arrive').append($('#ui-datepicker-div'));
49		},
50		onSelect: function() {
51			checkinDate = checkinField.datepicker('getDate');
52			checkoutDate = checkoutField.datepicker('getDate');
53
54			if (checkinDate >= checkoutDate) {
55				checkoutDate = new Date(checkinDate.getTime());
56				checkoutDate.setDate(checkoutDate.getDate() + 1);
57
58				checkoutField.datepicker('setDate', checkoutDate);
59			}
60		},
61		beforeShowDay: function(date) {
62			extraClass = '';
63
64			if(date.getTime() === checkoutDate.getTime()) {
65				extraClass = 'checkout-date-selected';
66			} else if (date.getTime() < checkoutDate.getTime() && date.getTime() > checkinDate.getTime()) {
67				extraClass = 'in-stay-range';
68			}
69
70			return [true, extraClass, ''];
71		},
72		format: 'dd MM yy',
73		minDate: defaultDate
74	});
75	checkinField.datepicker('setDate', defaultDate);
76
77	checkoutField.datepicker({
78		beforeShow: function(textbox, instance){
79			$('.booking-panel .booking-section.section-depart').append($('#ui-datepicker-div'));
80		},
81		onSelect: function() {
82			checkinDate = checkinField.datepicker('getDate');
83			checkoutDate = checkoutField.datepicker('getDate');
84
85			if (checkinDate >= checkoutDate) {
86				checkinDate = new Date(checkoutDate.getTime());
87				checkinDate.setDate(checkinDate.getDate() - 1);
88
89				checkinField.datepicker('setDate', checkinDate);
90			}
91		},
92		beforeShowDay: function(date) {
93			extraClass = '';
94
95			if(date.getTime() === checkinDate.getTime()) {
96				extraClass = 'checkin-date-selected';
97			} else if (date.getTime() < checkoutDate.getTime() && date.getTime() > checkinDate.getTime()) {
98				extraClass = 'in-stay-range';
99			}
100
101			return [true, extraClass, ''];
102		},
103		format: 'dd MM yy',
104		minDate: defaultDate2
105	});
106	checkoutField.datepicker('setDate', defaultDate2);
107
108	populateDatepicker(checkinField, ciDay, ciMonth);
109	populateDatepicker(checkoutField, coDay, coMonth);
110
111	$('#bp_ci_date').datepicker( 'option' , 'onClose', function() {
112		populateDatepicker(checkinField, ciDay, ciMonth);
113		populateDatepicker(checkoutField, coDay, coMonth);
114	} );
115
116	$('#bp_co_date').datepicker( 'option' , 'onClose', function() {
117		populateDatepicker(checkinField, ciDay, ciMonth);
118		populateDatepicker(checkoutField, coDay, coMonth);
119	} );
120
121	return true;
122}
123
124function populateDatepicker(datepicker, day_div, month_div) {
125	var date = $(datepicker).datepicker('getDate'),
126
127	day  = date.getDate(),
128	month = date.getMonth() + 1,
129	year =  date.getFullYear();
130	monthName = months[month - 1];
131
132	$(day_div).text(day);
133	$(month_div).text(monthName);
134	//console.log(day + '-' + monthName + '-' + year);
135}
136
137
138(function($) {
139
140	// Initialize booking panels visible on load (not panel/popup)
141	if($('.booking-panel').hasClass('initialize-datepickers-on-load')) datepickersInitialized = initializeDatepickers();
142
143	// Handle open/close events for QB panel
144	$('body').on('click', '.booking-panel', function(e) {
145		e.stopPropagation();
146	})
147	.on('click', '.booking-panel-trigger', function(e) {
148		if($(window).width() > 1199) { // On mobile just navigate to BE
149			e.preventDefault();
150			if($('.booking-panel').hasClass('hidden')) {
151				openCloseBP(true);
152			} else {
153				openCloseBP(false);
154			}
155			e.stopPropagation();
156		}
157	})
158	.on('click', function(e) {
159		if(!$(e.target).closest('.ui-datepicker-header, .ui-datepicker-calendar').length) openCloseBP(false);
160	});
161
162	// Handle click events for booking panel
163	$('body').on('click', '.booking-panel-submit', function(e) {
164		if($(window).width() > 1199) { // On mobile just navigate to BE
165			e.preventDefault();
166			$('.booking-form').trigger('submit');
167		}
168	});
169
170	// Handle submit events for BP form
171	$('.booking-form').on('submit', function(e) {
172		e.preventDefault();
173		e.stopPropagation();
174
175		var checkinDate = $('.booking-panel #bp_ci_date').datepicker('getDate');
176		var checkoutDate = $('.booking-panel #bp_co_date').datepicker('getDate');
177
178		var oneDay = 1000*60*60*24;
179
180		var checkinDateMS = checkinDate.getTime();
181		var checkoutDateMS = checkoutDate.getTime();
182
183		var nights = checkoutDateMS - checkinDateMS;
184		nights = Math.round(nights / oneDay);
185
186		var promoCode = '';//$('.booking-panel #bp_promo').val();
187
188		var bookingLink = bookingEngineURL;
189
190		if(promoCode.length) {
191			bookingLink += 'index.php?av=promo&fw_submitted=1';
192			bookingLink += '&promotionCode=' + promoCode;
193		} else {
194			bookingLink += 'results.php?av=search';
195		}
196
197		bookingLink += '&checkin=' + checkinDate.getFullYear() + '-' + (checkinDate.getMonth() + 1) + '-' + checkinDate.getDate();
198		bookingLink += '&nights=' + nights;
199		// bookingLink += '&nights=' + nightsField.val();
200
201		if(typeof(ga) !== 'undefined' && typeof ga.getAll === 'function') {
202			var tracking;
203
204			var gaAll = ga.getAll();
205			if (gaAll.length) tracking = '&' + gaAll[0].get("linkerParam");
206
207			bookingLink += tracking;
208		}
209
210		window.location = bookingLink;
211	});
212
213})(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.