jQuery.browser = {}; (function () { jQuery.browser.msie = false; jQuery.browser.version = 0; if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) { jQuery.browser.msie = true; jQuery.browser.version = RegExp.$1; } })(); jQuery.browser = {}; (function () { jQuery.browser.msie = false; jQuery.browser.version = 0; if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) { jQuery.browser.msie = true; jQuery.browser.version = RegExp.$1; } })(); $(function () { $(".menu-list, .awe-navigation-responsive").click(function (e) { $(".toggle-menu-responsive").click(); }); }); $(function () { $(".menu-list, .awe-navigation-responsive").click(function (e) { $(".toggle-menu-responsive").click(); }); }); $(function () { $("#scroll-top").click(function (e) { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera e.preventDefault(); }); }); $(document).ready(function () { $('.search-month').unbind().click(function () { $('.search-month .far').toggleClass('fa-square fa-check-square font-weight-bold'); $('.chkSearchByMonth input[type=checkbox]').click(); }); $('.fa-search').click(function () { $('.btn-search').click(); }); $('.div-city .txtCity').click(function () { $(this).blur(); window.scrollTo(0, 305); }); $('.pax-number input').click(function () { $(this).blur(); }); LoadDataFromLocalStorage('data-search'); SelectCity(); SelectDate(); CheckDate(); SetLunarDate(); SetPaxNumber(); SwitchCity(); $('.txtDate').change(function () { $(this).parents('.col-date').find('.lunar-date').html(GetLunarDateShort($(this).val())); if ($('.txtDateTo').val().length > 0) { $('.date-remove').show(); } }); $('.date-remove').click(function () { $(this).parents('.col-date').find('.lunar-date').text(''); $('.txtDateTo').val(''); $(this).hide(); }); $('.depdate-remove').click(function () { var today = new Date(); today.setHours(0, 0, 0, 0); var dateFrom = today; dateFrom.setDate(dateFrom.getDate() + 3); $('.txtDateFrom').val(ShowDate(dateFrom)).change(); $('.date-remove').click(); }); if ($('.txtDateTo').val().length > 0) { $('.date-remove').show(); } else { $('.date-remove').hide(); } $('.btn-search').click(function () { SaveDataToLocalStorage('#search-box', 'data-search'); }); $('body').on('click','#cphTop_ctl02_btnSearch', function(e){ var check_1 = $('#txtDepartureAirportCode').val(); var check_2 = $('#txtArrivalAirportCode').val(); if(check_1 == check_2){ e.preventDefault(); alert('Vui lòng chọn chuyến đi và chuyến đến khác nhau!'); return; }else{ } }) }); function CheckDate() { var today = new Date(); today.setHours(0, 0, 0, 0); if ($('.txtDateFrom').datepickerlunar("getDate") < today) { var dateFrom = today; dateFrom.setDate(dateFrom.getDate() + 3); $('.txtDateFrom').val(ShowDate(dateFrom)); } if ($('.txtDateTo').val().length > 5 && $('.txtDateTo').datepickerlunar("getDate") < today) $('.txtDateTo').val(''); } function SwitchCity() { $('.icon-switch').click(function () { var city = $('.div-departure-city .txtCity').val(); var airport = $('.div-departure-city .txtAirportCode').val(); $('.div-departure-city .txtCity').val($('.div-arrival-city .txtCity').val()); $('.div-departure-city .txtAirportCode').val($('.div-arrival-city .txtAirportCode').val()); $('.div-arrival-city .txtCity').val(city); $('.div-arrival-city .txtAirportCode').val(airport); }); } function SetPaxNumber() { $('.pax-number select').change(function () { //alert($(this).find('option:selected').val()); var $val = parseInt($(this).val()); if ($(this).hasClass('cboInfant')) { var $adt = parseInt($('.cboAdult').val()); if ($adt < $val) { ShowMessage("Số lượng Em bé phải nhỏ hơn hoặc bằng người lớn"); $(this).val($adt).change(); } } else if ($(this).hasClass('cboAdult')) { var $inf = parseInt($('.cboInfant').val()); if ($inf > $val) { ShowMessage("Số lượng Em bé phải nhỏ hơn hoặc bằng người lớn"); $($(".cboInfant")).val($val).change(); } } }); } function SetPaxNumberV2() { $('.pax-number .far').click(function () { var input = $(this).parent().find('input'); var val = parseInt(input.val()); if ($(this).hasClass('fa-minus')) { var min = 0; if (input.hasClass('txtAdult')) min = 1; val = Math.max(min, val - 1); } else { var max = 100; if (input.hasClass('txtInfant')) { max = parseInt($('.txtAdult').val()); if (val === max) ShowMessage("Số lượng Em bé phải nhỏ hơn hoặc bằng người lớn"); } val = Math.min(max, val + 1); } input.val(val); if (parseInt($('.txtAdult').val()) < parseInt($('.txtInfant').val())) { $('.txtInfant').val($('.txtAdult').val()); } if ($(".txtChild").val() !== "0") { $(".txtChild").css({ 'color': '#495057' }); } if ($(".txtInfant").val() !== "0") { $(".txtInfant").css({ 'color': '#495057' }); } }); } function SetLunarDate() { $('.txtDate').each(function () { $(this).parents('.col-date').find('.lunar-date').html(GetLunarDateShort($(this).val())); }); } function SelectDate() { $('.txtDateFrom, .txtDateTo').datepickerlunar({ dateFormat: 'dd/mm/yy', numberOfMonths: 3, minDate: 0, onChangeMonthYear: function (year, month, datepicker) { var isReturn = $(this).hasClass('txtDateTo'); setTimeout(function () { if (isReturn) { datepicker.dpDiv[0].innerHTML = datepicker.dpDiv[0].innerHTML.replace(/Tháng/g, "Ngày về tháng: ").replace('/ ', '/'); } else { datepicker.dpDiv[0].innerHTML = datepicker.dpDiv[0].innerHTML.replace(/Tháng/g, "Ngày đi tháng: ").replace('/ ', '/'); } }, 0); }, beforeShow: function (input, datepicker) { var isReturn = $(this).hasClass('txtDateTo'); setTimeout(function () { if (isReturn) { datepicker.dpDiv[0].innerHTML = datepicker.dpDiv[0].innerHTML.replace(/Tháng/g, "Ngày về tháng: ").replace('/ ', '/'); } else { datepicker.dpDiv[0].innerHTML = datepicker.dpDiv[0].innerHTML.replace(/Tháng/g, "Ngày đi tháng: ").replace('/ ', '/'); } }, 0); } }); $('.txtDateTo').datepickerlunar('option', 'minDate', $('.txtDateFrom').datepickerlunar("getDate")); $('.txtDateFrom').change(function () { $('.txtDateTo').datepickerlunar('option', 'minDate', $(this).datepickerlunar("getDate")); }); //-------------------------------------------- $(".lunar-date").click(function () { $(this).parent().find(".txtDate").datepickerlunar('show'); }); $(".ui-datepicker-prev span").on('click', function () { console.log('arf') }); } function SelectCity() { ShowDialogCity(); $('.div-city-list li p').click(function () { $(this).parents('.div-city').find('.txtCity').val($(this).text()); $(this).parents('.div-city').find('.txtAirportCode').val($(this).attr('airportcode')); $('.div-city-list').css('display', 'none'); if ($(this).parents('.div-city').hasClass('div-departure-city')) $('.div-arrival-city').click(); else $('.txtDateFrom').datepickerlunar('show'); }); } function ShowDialogCity() { var $win = $(window); var $box = $(".div-departure-city"); var $box2 = $(".div-arrival-city"); var $item = $('.div-city-list li p, .div-city-list li p span'); $win.on("click.Bst", function (event) { if (event.target.className.indexOf("icon-switch") !== -1) return; if ($item.is(event.target)) { } else { if (($box.has(event.target).length === 0 && !$box.is(event.target)) || event.target.className.indexOf('fa-times') !== -1) { $box.find('.div-city-list').hide(); } else { $box.find('.div-city-list').show(); $box.find('input').focus(); } if (($box2.has(event.target).length === 0 && !$box2.is(event.target)) || event.target.className.indexOf('fa-times') !== -1) { $box2.find('.div-city-list').hide(); } else { $box2.find('.div-city-list').show(); $box2.find('input').focus(); } } }); } function ShowMessage(vMessage, vClass = '') { $("#lblMessage").html(vMessage); ShowMessageDefault(vClass); } function ShowMessageAndReload(vMessage) { $("#lblMessage").text(vMessage); $("#lblMessage").attr('data-reload', '1'); ShowMessageDefault(); } function ShowMessageDefault(vClass = '') { $(".message-footer span").hide().filter(".click").show(); if (vClass !== '') $("#pnlMessage").addClass(vClass); $("#pnlMessage").show().addClass("active"); } function HideMessage() { if ($("#lblMessage").attr('data-reload') !== undefined) location.reload(); $("#lblMessage").text(""); $("#pnlMessage").attr('class', '').hide(); } $(document).ready(function () { if ($('#lblMessage').text().trim().length > 5) { ShowMessageDefault(); } }); $(document).ready(function () { $('#div-route-popular').owlCarousel({ loop: true, autoplay: true, margin: 10, nav: true, responsive: { 0: { items: 2 }, 600: { items: 3 }, 1000: { items: 5 } } }); }); $(document).ready(function () { if ($('.txtAutoSuggestDep').length > 0) { $('.txtAutoSuggestDep').typeahead("destroy").typeahead( { hint: true, highlight: true, minLength: 0 }, { displayKey: 'Name', name: 'toPlaces', source: function (query, syncResults) { if (!isBlank(query)) { mainQuery = query; matcher(query, airportSuggestions, syncResults); } else { syncResults([]); // Tránh hiển thị nếu chưa nhập gì } }, templates: { header: '