var $window = $(window);
// Warning Duplicate IDs
$('[id]').each(function() {
var ids = $('[id="' + this.id + '"]');
if (ids.length > 1 && ids[0] == this)
console.warn('Multiple IDs #' + this.id);
});
$(".tiles-a ul li").slice(0, 4).show();
$("#loadMore").on("click", function(e) {
e.preventDefault();
$(".tiles-a ul li:hidden").slice(0, 4).slideDown();
if ($(".tiles-a ul li:hidden").length == 0) {
// $("#loadMore").text("No Content").addClass("noContent");
$('#loadMore').hide();
}
});
$('.slick-wrap').slick({
centerMode: true,
slidesToShow: 5,
autoplaySpeed: 2000,
autoplay: true,
slidesToScroll: 5,
infinite: true,
responsive: [{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
infinite: true,
}
},
]
});
$('.slick-wrap-2').slick({
centerMode: true,
slidesToShow: 3,
autoplaySpeed: 2000,
autoplay: true,
slidesToScroll: 3,
infinite: true,
responsive: [{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
}
},
{
breakpoint: 768,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
infinite: true,
}
},
]
});
function checkWidth() {
var windowsize = $window.width();
if (windowsize <= 992) {
var margT = $('.content-body .container').outerWidth(true) - $('.content-body .container').outerWidth();
var paddT = $('.content-body .container').innerWidth() - $('.content-body .container').width();
var wTable = windowsize - margT - paddT;
$('.content-body .standard-page tr').attr('style', 'width: ' + wTable + 'px;');
} else {
var wTable = 'auto';
$('.content-body .standard-page tr').attr('style', 'width: ' + wTable + 'px;');
}
}
checkWidth();
$(window).resize(checkWidth);
$('.table-custom').css('overflow', 'auto');
$('.table-custom').css('height', '500px');
$('.table-custom table').attr('id', 'tableDV');
$('.table-custom table').attr('class', 'table table-striped mb-20');
$('.table-custom table').css('width', '100%');
$('#tableDV').attr('style', 'border-collapse: collapse; width: 100%;');
$('.table-striped>tbody>tr:nth-of-type(1)').css('position', 'sticky');
$('.table-striped>tbody>tr:nth-of-type(1)').css('top', '0');
$('.table-striped>tbody>tr:nth-of-type(1)').css('z-index', '1');
$('.table-striped>tbody>tr:nth-of-type(1)').css('background', '#eee');
// dang ky kham
$('#submitDangKyKham').click(function() {
if (!$('#modal-select-kp').val()) {
Alert.error('Vui lòng chọn chuyên khoa.', 'Error', { displayDuration: 3000 });
$('#modal-select-kp').focus();
return false;
}
if (!$('#modal-select-bs').val()) {
Alert.error('Vui lòng chọn bác sĩ.', 'Error', { displayDuration: 3000 });
$('#modal-select-bs').focus();
return true;
}
if (!$('#modal-ngay-kham').val()) {
Alert.error('Vui lòng chọn ngày khám.', 'Error', { displayDuration: 3000 });
$('#modal-ngay-kham').focus();
return true;
}
if (!$('textarea[name="van-de-sk"]').val()) {
Alert.error('Vui lòng nhập tình trạng sức khoẻ.', 'Error', { displayDuration: 3000 });
$('textarea[name="van-de-sk"]').focus();
return true;
}
$('#_submitDangKyKham').click();
});
// hoan thanh dky
$('#hoan-thanh-dky').click(function() {
if (!$('.modal-ho-ten input').val()) {
Alert.error('Vui lòng nhập họ và tên.', 'Error', { displayDuration: 3000 });
$('.modal-ho-ten input').focus();
return true;
}
var txtphone = $.trim($('.modal-sdt input').val());
var checkPhone = phonenumber(txtphone);
if (checkPhone === false) {
Alert.error('Vui lòng nhập đúng số điện thoại.', 'Error', { displayDuration: 3000 });
$('.modal-sdt input').focus();
return true;
}
if (!$('.modal-ngay-sinh input').val()) {
Alert.error('Vui lòng chọn ngày sinh.', 'Error', { displayDuration: 3000 });
$('.modal-ngay-sinh input').focus();
return true;
}
$('#_hoan-thanh-dky').click();
});
function phonenumber(inputtxt) {
return /^(0?)(3[2-9]|5[6|8|9]|7[0|6-9]|8[0-6|8|9]|9[0-4|6-9])[0-9]{7}$/.test(inputtxt);
if (isVNPNumber1(inputtxt) || isVNPNumber2(inputtxt) || isVNPNumber3(inputtxt)) {
return true;
} else {
return false;
}
}
function isVNPNumber1(number) {
return /([0-9]{8})\b/.test(number);
}
function isVNPNumber2(number) {
return /([0-9]{9})\b/.test(number);
}
function isVNPNumber3(number) {
return /([0-9]{10})\b/.test(number);
}
$(document).on('change', '#modal-select-kp', function() {
var id = $(this).val();
if (id) {
if ($('#datHenBs').val() == 'false') {
searchAjaxModal(id);
}
} else {
$('#modal-select-bs').html('');
}
});
function searchAjaxModal(departmentId) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: '/tim-bac-si-search',
type: 'POST',
dataType: "json",
data: {
'departmentId': departmentId,
'modal': true
},
beforeSend: function() {
$("#overlay").fadeIn(300);
},
success: function(data, status) {
setTimeout(function() {
$("#overlay").fadeOut(300);
}, 500);
if (data) {
$('#modal-select-bs').html(data);
} else {
$('#modal-select-bs').html('');
}
},
error: function(xhr, desc, err) {
setTimeout(function() {
$("#overlay").fadeOut(300);
}, 500);
Alert.error('Đã xảy ra lỗi, vui lòng thử lại!', 'Error', { displayDuration: 3000 });
}
});
}
$('.datepicker').datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 0), ''];
},
dateFormat: 'dd/mm/yy',
changeYear: true,
changeMonth: true,
minDate: 0,
yearRange: "-100:+1",
}).val();
$('.datepicker-birthDay').datepicker({
dateFormat: 'dd/mm/yy',
changeYear: true,
changeMonth: true,
yearRange: "-100:+0",
}).val();
// $('.timepicker').timepicker({
// timeFormat: 'h:mm p',
// interval: 30,
// minTime: '7:30am',
// maxTime: '3:30pm',
// defaultTime: false,
// startTime: '07:30',
// dynamic: false,
// dropdown: true,
// scrollbar: false
// });
$('.action-button-open').click(function() {
$(this).hide();
$('.action-button-close').show();
$('.action-blocks').show();
});
$('.action-button-close').click(function() {
$(this).hide();
$('.action-button-open').show();
$('.action-blocks').hide();
});
window.onscroll = function() {
scrollFunction();
};
function scrollFunction() {
if (
document.body.scrollTop > 255 ||
document.documentElement.scrollTop > 255
) {
// show
$('#action-scroll').show();
} else {
$('#action-scroll').hide();
// hide
}
}