/* * Name: KEPCO * Part: JavaScript for ui & plug-in * Author : pk.choi */ (function($){ // jQuery.noConfict(); $(document).ready(function() { srchTab(); /* * Part: 약관동의 외부페이지로드 */ $('#requestAgreeBox').loadExternalPage({ path:'/kepco/front/html/CY/F/A/CYFAPP001.html #wrap' }); /* * Part: 모달레이어팝업 */ var $focusTarget; $(this).on('click', '.modal_trigger, .allMenu .modal_trigger', function (event) { //prevent default action (hyperlink) event.preventDefault ? event.preventDefault() : event.returnValue = false; // event.preventDefault(); //Get clicked link href var href = $(this).attr("href") + " #wrapPop"; $focusTarget = $(this); var isAllMenu = ($(this).parent().hasClass('allmenu')) ? true : false; var minWidth = (!$('.museum').hasClass('on')) ? 995 : 1410; if ($('.modal_overlay').length > 0) { // .modal_overlay exists // alert('modal_overlay exists already'); $('.modal_overlay').css({"min-width":minWidth}).show(); $('.close_box a').focus(); if($('.modal_content').length == 0){ $('body').append(''); } } else { //.modal_overlay does not exist - create and insert (runs 1st time only) //create HTML markup for lightbox window var lightbox = ''; //insert lightbox HTML into page $('body').append(lightbox); $(".modal_overlay").css({ "zIndex":9999, "width":$(window).width(), "height":$(document).height(), "min-width":minWidth, "opacity":"0.7" }); } if ($('.modal_content').children().length > 0) { // .modal_content's children exists $('.modal_content').show(); $('.modal_content').find('input').eq(0).focus().select(); } else{ $('.modal_content').show(); $('.modal_content').load(href,function() { // var objCont = $(this).find('#wrapPop'); var objCont = $(this); var objWidth = objCont.find('#wrapPop').outerWidth(); var objHeight = objCont.find('#wrapPop').outerHeight(); var maxH = 520; //popContainer의 내용이 보여지는 영역 기준높이 var topH = 56; //상단 타이틀 영역 높이 if(isAllMenu){ objWidth = 610; objHeight = 740; } objCont.css({ "position":"fixed", "zIndex":10000, "width":objWidth, "height":objHeight, "marginLeft":-objWidth/2, "marginTop":-objHeight/2}); //objHeight 가 기준높이보다 클때 popContainer에 scroll,높이값 설정 후 //modal_content의 marginTop 재설정 if(!isAllMenu){ if(objHeight >= maxH + topH) { $('.modal_content .popContainer').css({ "overflow-x":"hidden", "overflow-y":"scroll", "height":maxH }); $('.modal_content').css({ "marginTop":-(maxH + topH)/2 }); } objCont.find('input').eq(0).focus().select(); $('.close_box a').focus(); } $('.close_box a').focus(); //좌석배치도(확대보기) setSeatLayout($('#popBody')); }); } }); //레이어팝업닫기 $(this).on('click', 'dl.popLayout.lpop dd.close_box a', function () { $('.modal_overlay').hide(); $('.modal_content').empty().hide(); if($focusTarget) $focusTarget.focus(); return false; }); //레이업팝업 포커스 2015-04-02 수정 $(this).on('focusin', 'dl.popLayout.lpop dd.close_box a', function () { $(this).keydown(function(e){ if(e.keyCode==9){ var cnt = $("#wrapPop").find("a").length; if ( cnt== 1){ $("#wrapPop").attr("tabindex","0").focus(); return false; } if(e.shiftKey){ } else { $("#wrapPop").find("a:first").focus(); return false; } } }); }); //브라우저 리사이즈시 모달레이어 너비,높이조정 $(window).resize(function(){ if ($('.modal_overlay').length > 0) { if($('.modal_overlay').is(':visible')){ $('.modal_overlay') .css("width", $(window).width()) .css("height", $(document).height()); } } }); /* * Part: 윈도우팝업닫기 */ $('dl.popLayout dd.close_box a, dl.popLayout a.close_wpop').bind('click', function () { popClose(); return false; }); /* * Part: FAQ 리스트 토글 */ $('.faq_box dl dt>a').bind('click', function () { if($(this).parent().hasClass('on')){ $(this).parent().removeClass('on'); $(this).parent().next().removeClass('on'); }else{ $('.faq_box dl dt').removeClass('on'); $('.faq_box dl dd').removeClass('on'); $(this).parent().addClass('on'); $(this).parent().next().addClass('on'); } return false; }); /* * Part: 주변맛집 지도로 찾기 */ $('.store_box').on("mouseenter focusin", function(e) { $(this).find('.text_sec').addClass('on'); }).on("mouseleave focusout", function(e) { $(this).find('.text_sec').removeClass('on'); }); /* * Part: 공연전시 > 좌석배치도 */ function setSeatLayout($parent_id){ if($parent_id.find('.seat_layout').length == 0) return; var seatRowTypes1 = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S']; var seatRowTypes2 = ['A','B','C','D','E','F','G','H','I']; var $pos1row = $parent_id.find('.seat_layout .bg.pos1 .row_type1'); var $pos2row = $parent_id.find('.seat_layout .bg.pos2 .row_type1'); var $pos1row2 = $parent_id.find('.seat_layout .bg.pos1 .row_type2 ul'); var $view1 = $parent_id.find('.seat_layout .bg.pos1 .view'); var $view2 = $parent_id.find('.seat_layout .bg.pos2 .view'); //1층 $pos1row.attr("id", function(i) { return "row"+seatRowTypes1[i]; }); $pos1row.find('li a.on').on('click', function () { $view1.attr('class','view pos1_'+$(this).parent().parent().attr('id')+$(this).html()); //console.log('1층 ' + $(this).parent().parent().attr('id') + '열_' + $(this).html()); return false; }); //1층 장애인석 $pos1row2.attr("id", function(i) { return "row"+seatRowTypes1[seatRowTypes1.length-1]+i+"_2"; }); $pos1row2.find('li a.on').on('click', function () { $view1.attr('class','view pos1_'+$(this).parent().parent().parent().parent().attr('id')); return false; }); //2층 $pos2row.attr("id", function(i) { return "row"+seatRowTypes2[i]; }); $pos2row.find('li a.on').on('click', function () { $view2.attr('class','view pos2_'+$(this).parent().parent().attr('id')+$(this).html()); //console.log('2층 ' + $(this).parent().parent().attr('id') + '열_' + $(this).html()); return false; }); } setSeatLayout($('#content')); /* tab 메뉴 활성화 표시 2015.04.20 민승우 */ var tabLayer = $(".wrap_tab"); var tabOnTitle = tabLayer.find("li.on > a").text(); var tabOnTitle2 = tabLayer.find("li.sub_on > a").text(); tabLayer.find("li").each(function(){ var tabOffTitle = $(this).find("a").text(); $(this).find("a").attr("title",tabOffTitle); }); tabLayer.find("li.on").children("a").attr("title",""+ tabOnTitle +"(현재페이지)"); tabLayer.find("li.sub_on").children("a").attr("title",""+ tabOnTitle2 +"(현재페이지)"); /* table tab 메뉴 활성화 표시 2015.04.20 민승우 */ var tableTab = $(".tab_table"); var tableTabOnTitle = tableTab.find("td.on > a").text(); tableTab.find("td").each(function(){ var tableTabOffTitle = $(this).find("a").text(); $(this).find("a").attr("title",tableTabOffTitle); }); tableTab.find("td.on > a").attr("title",""+ tableTabOnTitle +"(선택됨)"); tableTab.find("table").removeAttr("summary");//레이아이웃용 테이블이기때문에 삭제함 2015.04.20 민승우 추가수정 tableTab.find("caption").remove();//레이아이웃용 테이블이기때문에 삭제함 2015.04.20 민승우 추가수정 });//end : document ready /* * Part: loadExternalPage plug-in */ $.fn.loadExternalPage = function(options){ var defaults = { path:'' }, settings = $.extend({}, defaults, options); this.each(function(){ // var $this = $(this); //Default Action $(this).load(settings.path); }); return this; }; })(jQuery); /*통합검색 탭*/ var srchTab = function(){ var objTabSearch = $('.tab_search'); var objTabSearchLi = $('.tab_search li'); var objTabSearchA = $('.tab_search li a'); var objSrchResult = $('.srch_result'); objSrchResult.not(':eq(0)').hide(); objTabSearchA.click(function(){ var intLiIndex = $(this).parent().index(); /*해당 탭 스타일 변경*/ objTabSearchLi.removeClass('on'); $(this).parent().addClass('on'); /*클릭 시 해당 탭 이미지 변경*/ var strClass = $(this).parent().attr('class'); objTabSearch.find('ul').removeClass(); objTabSearch.find('ul').addClass(strClass); /*해당 탭 내용 보여주기*/ objSrchResult.hide(); objSrchResult.eq(intLiIndex).show(); }); }; //----------------------------------------------- /***** WINDOW POPUP ALIGN CENTER *****/ //----------------------------------------------- function open_window(name, url, w, h, toolbar, menubar, statusbar, scrollbar, resizable, loc_box) { toolbar_str = toolbar ? 'yes' : 'no'; menubar_str = menubar ? 'yes' : 'no'; statusbar_str = statusbar ? 'yes' : 'no'; scrollbar_str = scrollbar ? 'yes' : 'no'; resizable_str = resizable ? 'yes' : 'no'; var left = 0; var top = 0; left = (screen.availWidth - w) / 2; top = (screen.availHeight - h) / 2; win = window.open(url, name, 'left='+left+',top='+top+',width='+w+',height='+h+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str); //win.focus(); } /* POPUP CLOSE */ function popClose(){ if(navigator.appVersion.indexOf("MSIE 6") != -1){ window.opener = window.location.href; self.close(); }else { parent.window.open('about:blank','_self').close(); } } //------------------------------------ /***** 레이어 변환 *****/ //------------------------------------ function ch_layer(hidden , show){ var hl = document.getElementById(hidden); var sl = document.getElementById(show); hl.style.display = "none"; sl.style.display = ""; } //------------------------------------ /***** browser detect *****/ //------------------------------------ function detectBrowser(){ var browser = navigator.appName; var agent = navigator.userAgent; var b_version = navigator.appVersion; var reg; var obj; if(agent.indexOf("Chrome") != -1) { browser = "Chrome"; reg = /Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent); b_version = new Number(RegExp.$1); } else if(agent.indexOf("MSIE") != -1) { browser = "Microsoft Internet Explorer"; reg = /MSIE (\d+\.\d+);/.test(navigator.userAgent); b_version = new Number(RegExp.$1); } else if(agent.indexOf("Firefox") != -1) { browser = "Firefox"; reg = /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent); b_version = new Number(RegExp.$1); } else if(agent.indexOf("Opera") != -1) { browser = "Opera"; reg = /Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent); b_version = new Number(RegExp.$1); } else if(agent.indexOf("Safari") != -1) { browser = "Safari"; reg = /Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent); b_version = new Number(RegExp.$1); } obj = {'browser':browser ,'agent':agent ,'b_version':b_version}; return obj; }