// var swiper = new Swiper(".swiper-wrap", { // observer: true, // observeParents: true, // slidesPerView: 'auto', // grabCursor: true, // centeredSlides: true, // slideToClickedSlide : true, // 해당 슬라이드 클릭시 슬라이드 위치로 이동 // pagination: { // el: ".swiper-reservation-pagination", // clickable: true, // }, // navigation: { // nextEl: ".swiper-hours-button-next", // prevEl: ".swiper-hours-button-prev", // }, // breakpoints: { // 1025: { // spaceBetween: 20, // }, // 768: { // spaceBetween: 20, // }, // 560: { // spaceBetween: 15, // }, // 0: { // spaceBetween: 15, // }, // }, // }); /* 탭링크 */ $(".tab-link").click(function () { var tab_id = $(this).attr("data-type"); $(".tab-link").removeClass("on"); $(".tab-content").removeClass("on"); $(this).addClass("on"); $("#" + tab_id).addClass("on"); }); (function ($) { "use strict"; $.fn.initSwiper = function (options) { // 옵션에 기본값을 주는 간단한 방법입니다. var settings = $.extend( { // 옵션의 기본 값입니다. useClass: ".swiper-wrap", initialSlide: 0, }, options ); var useClass = settings.useClass; var initialIndex = settings.initialSlide; /* 이용자시간선택 슬라이드 */ var $swiperSelector = $(useClass); $swiperSelector.each(function (index) { var $this = $(this); var swiper = new Swiper(useClass, { observer: true, observeParents: true, slidesPerView: 'auto', grabCursor: true, centeredSlides: true, slideToClickedSlide : true, // 해당 슬라이드 클릭시 슬라이드 위치로 이동 initialSlide: initialIndex, // loop: true, pagination: { el: ".swiper-reservation-pagination", clickable: true, }, navigation: { nextEl: ".swiper-hours-button-next", prevEl: ".swiper-hours-button-prev", }, breakpoints: { 1025: { spaceBetween: 20, }, 768: { spaceBetween: 20, }, 560: { spaceBetween: 15, }, 0: { spaceBetween: 15, }, }, on: { slideChangeTransitionStart : function(info) { //이벤트 또는 조건문으로 이용하면 된다. // console.log(info.realIndex); let current_data = $('.current_year').data(); let current_year = current_data.year; let current_month = current_data.month; let real_idx = info.realIndex; // 2024-05-04 cy.hwang 10이하 일자경우 0이 안붙어 DB검색오류 let current_day = real_idx + 1; current_day = current_day < 10 ? '0'+current_day:current_day; let dates = current_year + '-' + current_month + '-' + current_day; // index를 받아 날짜로 바꾸기 위해 +1 처리 // let currentDate = new Date(dates); // console.log(real_idx); //console.log(dates); checkDatetime(dates); }, }, }); }); /* 이용자시간선택 end */ }; //fn END })(jQuery); $(".datepicker-wrap").click(function () { $(this).find(".datepicker").datepicker("show"); }); function newDatepicker() { $.datepicker.setDefaults({ dateFormat: 'yy-mm-dd' //Input Display Format 변경 ,showOtherMonths: true //빈 공간에 현재월의 앞뒤월의 날짜를 표시 ,showMonthAfterYear:true //년도 먼저 나오고, 뒤에 월 표시 //,changeYear: true //콤보박스에서 년 선택 가능 //,changeMonth: true //콤보박스에서 월 선택 가능 ,showOn: "both" //button:버튼을 표시하고,버튼을 눌러야만 달력 표시 ^ both:버튼을 표시하고,버튼을 누르거나 input을 클릭하면 달력 표시 ,buttonImage: "/assets/wavepark/img/my/calendar.png" //버튼 이미지 경로 ,buttonImageOnly: true //기본 버튼의 회색 부분을 없애고, 이미지만 보이게 함 ,buttonText: "선택" //버튼에 마우스 갖다 댔을 때 표시되는 텍스트 ,yearSuffix: "." //달력의 년도 부분 뒤에 붙는 텍스트 ,monthNamesShort: ['01','02','03','04','05','06','07','08','09','10','11','12'] //달력의 월 부분 텍스트 ,monthNames: ['01','02','03','04','05','06','07','08','09','10','11','12'] //달력의 월 부분 Tooltip 텍스트 ,dayNamesMin: ['일','월','화','수','목','금','토'] //달력의 요일 부분 텍스트 ,dayNames: ['일요일','월요일','화요일','수요일','목요일','금요일','토요일'] //달력의 요일 부분 Tooltip 텍스트 ,minDate: "0M" //최소 선택일자(-1D:하루전, -1M:한달전, -1Y:일년전) ,maxDate: "+6M" //최대 선택일자(+1D:하루후, -1M:한달후, -1Y:일년후) ,beforeShow: function(input, inst) { // console.log(input); var i_offset = $('.select-calendar').offset(); console.log(i_offset); setTimeout(function() { // inst.dpDiv.css({ top: i_offset.top + $(input).outerHeight(), left: i_offset.left }); inst.dpDiv.css({ top: i_offset.top + $(input).outerHeight() }); }, 0); } ,onSelect: function(dateString) { // console.log(dateString); CreatCalendar(dateString); } }); $(".datepicker").datepicker(); $('#ui-datepicker-div').addClass('notranslate'); } $(function(){ // 페이지 시작과 함께 달력 생성 CreatCalendar(); }); // 달력 이전달, 다음달 클릭 시 기존 달력 삭제 후 현재 달력 재설정 $(document).on("click", ".movedate.prev, .movedate.next", function () { console.log('1') // 사용하지 않을 경우 클릭 되지 않도록 if ($(this).hasClass("disabled") === true) { return false; } var selectdate = $(this).data("selectdate"); CreatCalendar(selectdate); }); function CreatCalendar(selectdate = '') { const datepickersElement = $('#creatcalendar_wrap'); const calendarUrls = "/operatinghours/CreatCalendar?selectdate=" + selectdate; datepickersElement.empty(); $.post(calendarUrls, function (data) { var codes = JSON.parse(data); if (data) { // console.log('datas : ', data); // index를 위해 -1 처리 let initialIndex = parseInt(codes.indexDay) - 1; // console.log('days ', initialIndex); datepickersElement.append(codes.outHtml); // 시간대 출력 시 스와이프 기능 구현 - 비동기 생성 datepickersElement.initSwiper({ useClass: ".swiper-wrap", initialSlide: initialIndex, }); newDatepicker(); // 2024-05-04 cy.hwang 중복실행으로 오류 //checkDatetime(selectdate); } }); } function checkDatetime(dates) { // let surf_opentime = '09:00'; // let surf_close_time = '18:00'; // let costa_opentime = '09:00'; // let costa_close_time = '18:00'; // console.log(dates); let surf_opentime = 'Close'; let surf_close_time = 'Close'; let costa_opentime = 'Close'; let costa_close_time = 'Close'; const calendarUrls = "/operatinghours/ajaxDateCheck?dates=" + dates; console.log(calendarUrls); $.post(calendarUrls, function (data) { var codes = JSON.parse(data); console.log(codes); if (data) { if(codes.status == 'time_false') { // console.log(surf_opentime); $('.surfdate > .time').text(surf_opentime); $('.costadate > .time').text(costa_opentime); // $('.surfdate > .time').text(surf_opentime + ' - ' + surf_close_time); // $('.costadate > .time').text(costa_opentime + ' - ' + costa_close_time); } else { surf_opentime = codes.surf_time ? codes.surf_time.open_time : surf_opentime; surf_close_time = codes.surf_time ? codes.surf_time.close_time : surf_close_time; costa_opentime = codes.costa_time ? codes.costa_time.open_time : costa_opentime; costa_close_time = codes.costa_time ? codes.costa_time.close_time : costa_close_time; if(surf_opentime == 'Close') { $('.surfdate > .time').text(surf_opentime); } else { $('.surfdate > .time').text(surf_opentime + ' - ' + surf_close_time); } if(costa_opentime == 'Close') { $('.costadate > .time').text(costa_opentime); } else { $('.costadate > .time').text(costa_opentime + ' - ' + costa_close_time); } } // let initialIndex = parseInt(codes.indexDay) - 1; // console.log(initialIndex); // datepickersElement.append(codes.outHtml); // // 시간대 출력 시 스와이프 기능 구현 - 비동기 생성 // datepickersElement.initSwiper({ // useClass: ".swiper-wrap", // initialSlide: initialIndex, // }); } }); }