/* 공통 초기화 기능 */ let mySlidePopSwiper; $(document).ready(function() { processPopup(); //2024.07.23 팝업관련 추가 //Swiper 슬라이드 팝업 mySlidePopSwiper = new Swiper('#slide-popup > .swiper', { direction: 'horizontal', effect: 'fade', slidesPerView: 1, // 보여질 슬라이더수 }); //좌우버튼 $('#slide-popup .btn-prev').on('click', function (e) { e.preventDefault(); // 이벤트 객체의 preventDefault 메소드를 실행하면 기본 동작이 취소된다 mySlidePopSwiper.slidePrev() // return false ; // ie9 이하 버전에서는 event.returnValue를 false로 해야 한다. }) $('#slide-popup .btn-next').on('click', function (e) { e.preventDefault(); //이벤트 객체의 preventDefault 메소드를 실행하면 기본 동작이 취소된다 mySlidePopSwiper.slideNext() //return false ; // ie9 이하 버전에서는 event.returnValue를 false로 해야 한다. }); }); var POPUP_URL = "/component/popup/ND_selectOpenPopup.do"; var LAYER_URL = "/component/popup/ND_selectOpenLayer.do"; // 문서 로드가 끝나면 실행되어 팝업을 종류에 맞게 생성한다. var processPopup = function() { var layerCnt = 0; if(opPopupConfigList && opPopupConfigList.length > 0) { for(var i = 0 ; i < opPopupConfigList.length ; i++) { var popupConf = opPopupConfigList[i]; var cookieName = popupConf.cookiePrefix + popupConf.sn; var value = Cookies.get(cookieName); if(!value || popupConf.popupCycle == "3040") { switch(popupConf.popupTy) { case "1010": opShowPopup(popupConf); break; case "1020": opShowLayer(popupConf); layerCnt++; break; case "1030": opShowExpand(popupConf); break; default: break; } } } //2024.07.22 추가 if(layerCnt > 0) { $("#slide-popup").addClass("visible"); if(document.getElementById('slide-popup')){ if ('scrollRestoration' in history) { history.scrollRestoration = 'manual'; //새로고침해도 자동 스크롤 기억하여 팝업영역 밖으로 이동하는 내용 수정 } //document.getElementById('slide-popup').scrollIntoView({ behavior: 'smooth' }); //팝업영역으로 화면 이동(새로고침하면 이코드때문에 위로 갔다가 스크롤 기억된 위치로 다시감..) } } } }; // 팝업 오픈 var opShowPopup = function(popupConf) { var option = "chrome, centerscreen, dependent=yes, left="+ popupConf.leftLc +", top="+ popupConf.upendLc +","; option += "width="+ popupConf.widthSize +", height="+ popupConf.vrticlSize +", "; option += "dialog=yes, modal=yes, location=0, status=0, menubar=0, toolbar=0, "; // 스크롤 여부 if(popupConf.scrollAt == "Y"){ option += "scrollbars=yes, "; }else{ option += "scrollbars=no, "; } // 리사이징 여부 if(popupConf.resizingAt == "Y"){ option += "resizable=yes"; }else{ option += "resizable=no"; } var href = POPUP_URL + "?sn=" + popupConf.sn; var popupOpenWin = window.open(href, "opShowPopup"+ popupConf.sn, option); if (popupOpenWin != null) { popupOpenWin.focus(); } return false; }; // 레이어 오픈 var opShowLayer = function(popupConf) { //2024.07.22 수정전 코드 //var style = "style=\"z-index:10000;position: absolute; top: "+popupConf.upendLc+"px; left: "+popupConf.leftLc+"px; width: "+popupConf.widthSize+"px; height: "+popupConf.vrticlSize+"px;\""; //var layerWin = "
"; //$("body").prepend(layerWin); //2024.07.22 수정후 코드 var layerWin = '
'; $("#slide-popup .swiper .swiper-wrapper").prepend(layerWin); var params = { sn : popupConf.sn }; $("#opShowPopup"+popupConf.sn).load(LAYER_URL, params, function(responseTxt, statusTxt, response) { if(statusTxt == "success") { } else { } }); }; // 상단 펼침 var opShowExpand = function(popupConf) { var style = "style=\"display:none; z-index:10000; clear: both; margin :2px auto; width: "+popupConf.widthSize+"px; \""; var layerWin = "
"; $("body").prepend(layerWin); var params = { sn : popupConf.sn }; $("#opShowPopup"+popupConf.sn).load(LAYER_URL, params, function(responseTxt, statusTxt, response) { if(statusTxt == "success") { $(this).slideDown( "slow", function() { }); } else { } }); }; // 팝업 레이어 접두어 var prefixPopupLayerId = "opShowPopup"; /* 부모창으로 URL 이동하고 창닫기 */ var opPopupParent = function(aObj) { var href = $(aObj).attr("href"); if(href) { location.href = href; } opHidePopupLayer(aObj); }; /* 새창을 열어 URL 이동하고 창닫기 */ var opPopupCloseWin = function(aObj) { var href = $(aObj).attr("href"); if(href) { var option = "chrome, centerscreen, dependent=yes, dialog=yes, modal=yes, "; option += "resizable=yes, scrollbars=yes, location=yes, status=yes, menubar=yes, toolbar=yes"; var newPopupWin = window.open(href, "opPopupWin", option); newPopupWin.focus(); } opHidePopupLayer(aObj); }; /* 새창을 열어 URL 이동하고 창유지 */ var opPopupWin = function(aObj) { var href = $(aObj).attr("href"); if(href) { var option = "chrome, centerscreen, dependent=yes, dialog=yes, modal=yes, "; option += "resizable=yes, scrollbars=yes, location=yes, status=yes, menubar=yes, toolbar=yes"; var newPopupWin = window.open(href, "opPopupCloseWin", option); newPopupWin.focus(); } }; // 현재 클릭된 오브젝트의 팝업 레이어를 hide 시킨다. var opHidePopupLayer = function(clickEl) { var $popupLayerSn = null; var $targetEl = $(clickEl); while(!$popupLayerSn) { $popupLayerSn = opFindPopupLayerId($targetEl); $targetEl = $targetEl.parent(); } $("#"+prefixPopupLayerId+$popupLayerSn).hide(); }; // 현재 POP 내용의 레이어 ID를 찾는다. var opFindPopupLayerId = function($child) { var $parent = $child.parent(); var parentId = $parent.attr("id"); if(parentId && parentId.indexOf(prefixPopupLayerId) === 0) { var len = prefixPopupLayerId.length; return parentId.substring(len); } return null; };; var opPopupConfigList = {}