Date.prototype.format = function(form) {
if (!this.valueOf()) return " ";
var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
var current = this;
return form.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function(form) {
switch (form) {
case "yyyy": return current.getFullYear();
case "yy": return (current.getFullYear() % 1000).zf(2); // 2자리
case "MM": return (current.getMonth() + 1).zf(2);
case "dd": return current.getDate().zf(2);
case "E": return weekName[current.getDay()];
case "HH": return current.getHours().zf(2);
case "hh": return ((h = current.getHours() % 12) ? h : 12).zf(2);
case "mm": return current.getMinutes().zf(2);
case "ss": return current.getSeconds().zf(2);
case "a/p": return current.getHours() < 12 ? "오전" : "오후";
default: return form;
}
});
};
String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;};
String.prototype.zf = function(len){return "0".string(len - this.length) + this;};
Number.prototype.zf = function(len){return this.toString().zf(len);};
$(function(){
var date = new Date();
var startDt = new Date();
var endDt = new Date();
var link = '#a', subALink = '#a', subBLink = '#a';
var target = '_self', subATarget = '_self', subBTarget = '_self';
$.each(dataList, function(index, item){
startDt = item.startDate;
endDt = item.endDate;
if(typeof(item.link) != 'undefined'){link = item.link}
if(typeof(item.subA) != 'undefined'){subALink = item.subA}
if(typeof(item.subB) != 'undefined'){subBLink = item.subB}
if(item.target == 'Y'){target = '_blank'}
else { target = '_self'; }
if(item.subATarget == '새창열림'){subATarget = '_blank'}
if(item.subBTarget == '새창열림'){subBTarget = '_blank'}
if( typeof(startDt) != 'undefined' && typeof(endDt) != 'undefined' ){
// 현재날짜가 설정기간에 속할 때
if( startDt <= date.format('yyyy-MM-dd HH:mm') && date.format('yyyy-MM-dd HH:mm') <= endDt ){
/*html = '
';
} else {
html = '
';
$('.top-banner-swiper .swiper-wrapper').append(html);
}
}
})
});
// top banner layer open (footer에 iframe 세팅되어 있음)
function fncLayerOpen(src){
if(src.indexOf('announcement-of-successful-candidates-and-printing-bill') > -1){
$("#popupTitle").text("각 대학원 합격자 발표 및 고지서 출력");
$('.popup-student-recruitment #student-recruitment').attr('title','각 대학원 합격자 발표 및 고지서 출력')/*접근성용*/
}else if(src.indexOf('graduate-student-recruitment-guide') > -1){
$("#popupTitle").text("각 대학원 학생 모집 안내");
$('.popup-student-recruitment #student-recruitment').attr('title','각 대학원 학생 모집 안내')/*접근성용*/
}else{
}
console.log($(this));
//$(this).prepend("
test
")
$('#student-recruitment').attr('src', src);
$('.popup-student-recruitment').attr('style', 'display:block');
$('.popup-student-recruitment .b-js-popup').attr('style', 'display:block');
// Set tabindex attribute to 0 to make it focusable
$('.grad-guide-box:first-of-type').attr('tabindex', '0');
/*확인용*/
/*$('.b-popup-box').attr('tabindex', '0').show().focus();
$('.js-popup-close').click(function(){
$this.find('a').focus();
})*/
// Set focus after a short delay (e.g., 100 milliseconds)
setTimeout(function () {
$('.grad-guide-box:first-of-type').focus();
}, 100);
$('.footer-wrap').addClass('on');
$('html,body').addClass('all-fixed');
console.log("hi");
}
$(document).ready(function(){
if(dataList.length == 0){ //dataList 없는 경우에
$("header").addClass("no-banner");
}else{
var mainTopBannerSwiper;
setTimeout(function(){
mainTopBannerSwiper = new Swiper('.top-banner-swiper', {
loop: false,
slidesPerView: useFixed ? '2' : '3',
speed: 500,
autoplay: {
delay: 5000,
disableOnInteraction: false,
},
pagination: {
el: '.top-banner-pagination',
type: 'bullets',
clickable: true,
},
navigation: {
prevEl: '.top-banner-prev',
nextEl: '.top-banner-next',
},
breakpoints: {
1024: {
slidesPerView: useFixed ? '1' : '2',
},
640: {
slidesPerView: '1'
}
}
});
if(topBannerAutoPlay == 'N' &&$('body').find('.top-banner-wrap').length != 0) {
mainTopBannerSwiper.autoplay.stop();
} else {
// 슬라이드 autoplay 제어
$('.top-banner-swiper').mouseenter(function() {
mainTopBannerSwiper.autoplay.stop();
});
$('.top-banner-swiper').mouseleave(function() {
mainTopBannerSwiper.autoplay.start();
});
}
}, 300)
$('.btn-banner').on('click', function() {
var $parentLi = $(this).parent('li');
var isOpen = $parentLi.hasClass('open');
$parentLi.toggleClass('open');
$('.btn-banner-wrap').toggleClass('open');
$('.top-banner-box').toggleClass('open').slideToggle();
// 텍스트 토글
var buttonText = isOpen ? '탑배너 버튼 열기' : '탑배너 버튼 닫기';
$(this).attr("title", buttonText);
$(this).find("span").text(buttonText).attr("title", buttonText);
mainTopBannerSwiper.update();
});
$('.btn-banner-close').click(function(){
$('.top-banner-box').slideUp();
// 텍스트 토글
$('.btn-banner').attr("title", "탑배너 버튼 열기").find("span").text("탑배너 버튼 열기").attr("title", "탑배너 버튼 열기");
});
/* 메인에서만 배너 연 채로 노출 */
/* 배너 없을 경우, 닫은채로 노출 기능 추가 - 24.08.27 */
setTimeout(function(){
if($('body').hasClass('main') && $('.top-banner-box .swiper-slide').length > 0) {
$('.btn-banner').parent('li').addClass('open');
$('.btn-banner-wrap, .top-banner-box').addClass('open').slideDown();
// 초기 텍스트 설정
$('.btn-banner').attr("title", "탑배너 버튼 닫기").find("span").text("탑배너 버튼 닫기").attr("title", "탑배너 버튼 닫기");
}
}, 100);
// 배너 등록 데이터 없을 경우, 버튼 클릭 불가 처리
setTimeout(function(){
if($('.top-banner-box .swiper-slide').length == 0) {
$('.btn-banner').css({'pointer-events' : 'none'});
}
}, 100);
$("[data-window-popup=open]").click(function(e){
var popupX = (document.body.offsetWidth / 2) - (200 / 2) // 만들 팝업창 좌우 크기의 1/2 만큼 보정값으로 빼주었음
var popupY= (window.screen.height / 2) - (300 / 2);
//창 오픈
window.open($(this).attr('href'), '템플릿 가져오기' , 'width=580px,height=860px,scrollbars=yes,left='+ popupX + ', top='+ popupY);
return false;
})
$("a").click(function(e){
if($(this).attr('target') == "_self"){
console.log($(this).attr('href'));
location.href=$(this).attr('href');
return false;
}
})
}
// 고정용 슬라이드
if($('.top-banner-box').hasClass('use-fixed') && $('.top-banner-swiper').find('.swiper-slide.fixed-slide').length > 0) {
var fixedSlide = $('.top-banner-swiper').find('.swiper-slide.fixed-slide:eq(0)')
$('.swiper-fixed-container').append(fixedSlide.clone());
$('.swiper-fixed-container').find('.swiper-slide').removeClass('pc-hide')
// 모바일 고정 배너 가장 앞 슬라이드로 순서 변경
var fixedSlideMobile = $('.top-banner-swiper').find('.swiper-slide.fixed-slide:eq(0)');
fixedSlideMobile.prependTo($('.top-banner-box .swiper-wrapper'))
}
});