PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | assets/js/trip-search-shortcode.js +31 -0 3.0.13 → 3.0.16 View file →
@@ -267,8 +267,13 @@
267 267 }
268 268 }
269 269 }
270 270
271 + var dateInput = document.querySelector('.yatra-search-date-input');
272 + if (dateInput && dateInput.value && /^\d{4}-\d{2}-\d{2}$/.test(dateInput.value)) {
273 + filters.available_date = dateInput.value;
274 + }
275 +
271 276 var listing = getListingUrl();
272 277 var url;
273 278 try {
274 279 url = new URL(listing);
@@ -305,8 +310,34 @@
305 310 });
306 311 }
307 312 }
308 313
314 + // Upgrade the native date field to the same flatpickr picker used on the
315 + // checkout/booking page, for a consistent, styled calendar. Fully guarded:
316 + // with no flatpickr (or on mobile, where the native picker is already good)
317 + // the native <input type="date"> is left working untouched. The submitted
318 + // value stays ISO (Y-m-d) so the search URL and back-end are unchanged.
319 + function initTripSearchDatePicker() {
320 + var input = document.querySelector('.yatra-search-date-input');
321 + if (!input || input.dataset.yatraFp === '1') return;
322 + if (typeof window.flatpickr === 'undefined') return;
323 + var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent || '');
324 + if (isMobile) return; // native mobile date UI is already good; leave it
325 + input.dataset.yatraFp = '1';
326 + // Switch off the native date UI so flatpickr is the only picker; the
327 + // value stays ISO (Y-m-d) via dateFormat, so runTripSearch() and the
328 + // back-end see the same format as before.
329 + try { input.type = 'text'; } catch (e) {}
330 + window.flatpickr(input, {
331 + dateFormat: 'Y-m-d',
332 + minDate: input.getAttribute('min') || 'today',
333 + defaultDate: input.value || null,
334 + allowInput: false,
335 + disableMobile: true
336 + });
337 + }
338 +
309 339 initHorizontalSearchDropdowns();
310 340 initDurationSlider();
311 341 initSearchFunctionality();
342 + initTripSearchDatePicker();
312 343 });