var assistGoodNames = new Array(); var goodInfoList = new Array(); var goodItemInfoList = new Array(); //품목 try { document.execCommand("BackgroundImageCache", false, true);} catch(err) {} // 탭메뉴 공통적으로 사용 //ex) tabOn(1,1); function tabOn(tabid,a) { for (var i=1;i<=10;i++) { if(i<10){inn="0"+i;} else {inn=""+i;} tabMenu = document.getElementById("tab"+tabid+"m"+i); tabContent = document.getElementById("tab"+tabid+"c"+i); tabMore = document.getElementById("tab"+tabid+"more"+i); if (tabMenu) { //객체가존재하면 if (tabMenu.tagName=="IMG") { tabMenu.src = tabMenu.src.replace("_on.", "_off."); } //이미지일때 if (tabMenu.tagName=="A") { tabMenu.className=""; } //앵커일때 } if (tabContent) { tabContent.style.display="none"; } if (tabMore) { tabMore.style.display="none"; } } if(a<10){ann="0"+a;} else {ann=""+a;} tabMenu = document.getElementById("tab"+tabid+"m"+a); tabContent = document.getElementById("tab"+tabid+"c"+a); tabMore = document.getElementById("tab"+tabid+"more"+a); // alert(tabMenu.tagName); if (tabMenu) { //객체가존재하면 if (tabMenu.tagName=="IMG") { tabMenu.src = tabMenu.src.replace("_off.", "_on."); } //이미지일때 if (tabMenu.tagName=="A") { tabMenu.className="on"; } //앵커일때 } if (tabContent) { tabContent.style.display="block"; } if (tabMore) { tabMore.style.display="block"; } } function goContent(){ $('#contents').focus(); } function goMainContent(){ $('#contents').focus(); } $(document).ready(function(){ //이미지 롤오버 $(".overimg").mouseover(function (){ var file = $(this).attr('src').split('/'); var filename = file[file.length-1]; var path = ''; for(var i=0 ; i < file.length-1 ; i++){ path = ( i == 0 )?path + file[i]:path + '/' + file[i]; } $(this).attr('src',path+'/'+filename.replace('_off.','_on.')); }).mouseout(function(){ var file = $(this).attr('src').split('/'); var filename = file[file.length-1]; var path = ''; for(var i=0 ; i < file.length-1 ; i++){ path = ( i == 0 )?path + file[i]:path + '/' + file[i]; } $(this).attr('src',path+'/'+filename.replace('_on.','_off.')); }); // 메인화면 상단 자동완성 검색어 조회 $.ajax({ type:"POST", url:"/tprice/common/code/getAutoCompleteGoodNameList.do", dayaType:"json", success:function(data) { goodNameList = data.autoCompleteGoodNameList; $.each(goodNameList, function(i) { assistGoodNames.push(goodNameList[i].GOOD_NAME); goodInfoList[i] = new Array(); goodInfoList[i] = [goodNameList[i].GOOD_ID ,goodNameList[i].GOOD_NAME ,goodNameList[i].GOOD_SMLCLS_CODE ,goodNameList[i].GOOD_SMLCLS_NAME ,goodNameList[i].GOOD_MIDCLS_CODE ,goodNameList[i].GOOD_MIDCLS_NAME ,goodNameList[i].FILE_RGTN_SEQ ]; }); } ,failure:function(data) { } }); var $search = $('#schWord'); var $listBox = $('#autocomplete-list'); var $list = $listBox.find('ul'); // 입력 필드에서 검색어를 입력할 때마다 자동완성 목록을 업데이트 $search.on('input', function() { var query = $(this).val().toLowerCase(); $listBox.hide(); // 목록 숨기기 $list.empty(); // 목록 비우기 // 검색어가 있으면 저장된 데이터에서 자동완성 항목을 필터링 if (query) { var matches = assistGoodNames.filter(function(item) { return item.toLowerCase().includes(query); // 대소문자 구분 없이 필터링 }); if (matches.length > 0) { matches.forEach(function(item) { var $btn = $('').text(item); var $li = $('
  • ').append($btn); $list.append($li); }); $listBox.show(); // 목록 표시 } } }); /* // 목록 항목에 포커스를 주는 함수 function focusListItem(index) { var items = $list.children('li'); items.removeClass('focused'); // 이전 포커스를 제거 if (index >= 0 && index < items.length) { $(items[index]).addClass('focused'); } } */ /* 25.04 웹접근성 상품명입력 자동입력 변경 이승진 */ // 'Tab' 키를 눌러 목록 항목을 탐색 /* var selectedIndex = -1; let isTab = false; $search.on('keydown', function(e) { var items = $list.children('li'); var searchval = ""; if (e.key === 'Tab') { e.preventDefault(); // 기본 동작인 포커스 이동 막기 isTab = (e.key === 'Tab' && e.shiftKey); searchval = $("#schWord").val(); // alert(searchval); if(searchval == "" || searchval == null){ if(isTab){ $("#header .logo").focus(); return; }else{ $(".search input").focus(); return; } } if (e.shiftKey) { // 'Shift + Tab' 눌렀을 때 첫 번째 항목에서 벗어나면 입력 필드로 돌아감 if (selectedIndex === 0) { var items1 = $list.children('li'); items1.removeClass('focused'); // 이전 포커스를 제거 selectedIndex = -1; $listBox.hide(); // 목록 숨기기 $list.empty(); // 목록 비우기 $(".search input").val(""); $("#header .logo").focus(); return; } selectedIndex--; } else { // 마지막 항목에서 'Tab'을 눌렀을 때 입력 필드로 포커스 if (selectedIndex === items.length - 1) { var items2 = $list.children('li'); items2.removeClass('focused'); // 이전 포커스를 제거 $listBox.hide(); // 목록 숨기기 $list.empty(); // 목록 비우기 selectedIndex = -1; $(".search input").val(""); $(".search input").focus(); return; } selectedIndex++; } focusListItem(selectedIndex); // 포커스 이동 } else if (e.key === 'Enter') { // 선택된 항목을 입력 필드에 채우기 if (selectedIndex !== -1) { $search.val(items.eq(selectedIndex).text()); $listBox.hide(); // 목록 숨기기 $(".search input").focus(); } } isTab = false; }); */ // 항목 클릭 시, 선택한 항목을 입력 필드에 채우기 $list.on('click', 'li', function() { $search.val($(this).text()); $listBox.hide(); // 목록 숨기기 $("#btn_searchTop").focus(); }); // 초점 벗어나면 검색어 자동완성 숨기기 $('.logo a, kca a, .h_sitemap a, #close_search').on('focusin', function() { $listBox.hide(); }); // 검색어 자동완성 적용 /* 25.04 웹접근성 인증 리더기로 안된다고 해서 주석 이승진 $("#schWord").autocomplete({ source: assistGoodNames, select: function(event, ui) { $("#schWord").val(ui.item.value); return false; // 자동완성 목록이 닫히지 않도록 }, // focus: function () { // prevent value inserted on focus //자동완성 검색 키워를 입력하여 콤보박스 형태로 자동완성되었을때 //Key Down, Key Up 으로 선택시 입력 Text 박스에 입력한 //자동완성 키워드가 리셋되는 형상을 방지 하기위해 return false 함. //focus: function () 을 사용하지 않거나 사용하되 return true 를 하면 // 입력 Text 박스에 입력한 자동완성 키워드가 리셋 됨. // placeholder 도입으로 주석처리 by 황인환 2018-04-20 // 주석처리로 인해 키보드 조작이 안되서 다시 원복 by 황인환 2020-04-22 // return false; // }, open: function(){ var menu = $(".ui-menu"); var firstItem = $(".ui-menu-item:first-child"); setTimeout(function() { // firstItem.focus(); }, 2000); menu.on("focus",".ui-menu-item", function(){ menu.find(".ui-state-focus").removeClass("ui-state-focus"); $(this).addClass("ui-state-focus"); }); } }); // 'Tab' 키 이벤트 처리 $('#schWord').on('keydown', function(e) { if (e.key === 'Tab') { var activeItem = $('.ui-menu .ui-state-focus'); // 포커스된 항목 if (activeItem.length) { // Tab을 눌렀을 때 포커스된 항목을 선택 var selectedItem = activeItem.first(); $(this).val(selectedItem.text()); // 선택된 항목의 값으로 설정 e.preventDefault(); // 기본 동작인 탭 키 포커스 이동 막기 } } }); $('#schWord').keydown(function(key){ if(key.keyCode == 13) { $("#btn_searchTop").click(); } }); */ // 검색 버튼 $("#btn_searchTop").click(function(){ var goodName = $("#schWord").val(); var goodId = ""; var goodSmlclsCode = ""; var goodClassCode = ""; for(var i=0; ili>ul>li").length == 13){ $("#side_menu ul>li>ul>li").each(function(index){ var url = $(this).children("a").attr("href"); var goodClassCode = url.substr(url.length-9,9); var topRate = 198; topRate += index * 26; var innerHtml = ""; innerHtml += '
    '; innerHtml += ''; innerHtml += '
    '; $(this).append(innerHtml); }); } }, failure:function(data){} }); let isShiftTab = false; /* 25.04 웹접근성 인증 포커스 상태인 경우 상세메뉴 보이도록 처리 이승진 */ $("#side_menu ul ul li a").focus(function(){ $("#side_menu ul ul li a").parent().children('.side_goodItem').hide(); $(this).parent().children('.side_goodItem').show(); // 키보드 누를 때 Shift+Tab 확인 $(document).on('keydown', function(e) { isShiftTab = (e.key === 'Tab' && e.shiftKey); }); setTimeout(function() { $("#side_menu ul ul li:last-child div.side_goodItem li:last a").blur(function(){ if (!isShiftTab) { $("#side_menu ul ul li a").parent().children('.side_goodItem').hide(); } isShiftTab = false; }); }, 10) setTimeout(function() { $("#side_menu ul ul li:first a:first").blur(function(){ if (isShiftTab) { $("#side_menu ul ul li a").parent().children('.side_goodItem').hide(); } isShiftTab = false; }); }, 10) }); //품목 팝업 호버 $("#side_menu ul ul li").hover(function(){ $("div.side_goodItem:not(:animated)",this).slideDown(); },function(){ $("div.side_goodItem",this).hide(); }); /* ******************************************************************************** */ /* ******************************************************************************** */ // 2025 - PC/모바일 클래스명 추가 function deviceClass() { const width = window.innerWidth; if (width >= 1024) { $('body').removeClass('mobile').addClass('pc'); } else { $('body').removeClass('pc').addClass('mobile'); } } deviceClass(); $(window).on('resize', function() { deviceClass(); }); // 2025 - 서브 메뉴 $('#side_menu > ul > li').each(function() { //3차메뉴 있는 경우 if ($(this).find('ul').length > 0) { $(this).addClass('h3th'); } }); // 2025 - 서브 메뉴 이전요소 클래슴여 추가 if ($('#side_menu li.on').prev().length) { $('#side_menu li.on').prev().addClass('non'); } // 2025 - 모바일 검색 $('#open_search').click(function(){ $('.gnb').addClass('m_search'); $('#shadow_device').show(); $("html").css({"overflow":"hidden"}); return false; }); $('#close_search, #shadow_device, #m_close').click(function(){ m_searchClose(); }); $(window).resize(function(){ if ($(window).width() > 1024){ m_searchClose(); } }); // 2025 - 모바일 검색 숨기기 function m_searchClose() { $('.gnb').removeClass('m_search'); $('html, #shadow_device').removeAttr('style'); } // 2025 - 서브 sns 공유 $('.sns_open').click(function(){ $('.snsBox').show(); }); $('.sns_close').click(function(){ $('.snsBox').hide(); $('.sns_open').focus(); }); // 2025 - 탭메뉴(on 이전요소 클래스명 추가) $(document).on('click', '#tab_menu a', function(){ $('#tab_menu li').removeClass('non') var idx = $(this).closest('li').index() - 1; $('#tab_menu li').eq(idx).addClass('non') }); if ($('#tab_menu li.on').prev().length) { $('#tab_menu li.on').prev().addClass('non'); } // 2025 - 스크롤 반응형 function mContScroll() { if ($(window).width() < 1401){ $('.mCont_scroll6').attr('tabindex', 0); } if ($(window).width() < 1201){ $('.mCont_scroll3, .mCont_scroll5').attr('tabindex', 0); } } mContScroll(); $(window).resize(function(){ mContScroll(); }); // 2025 - 배너모음 $('#banner .slider').slick({ slidesToShow: 7, slidesToScroll: 1, infinite: true, autoplay:true, autoplaySpeed:3000, prevArrow: $('#banner .ctrl .prev'), nextArrow: $('#banner .ctrl .next'), responsive: [{ breakpoint: 1301, settings: {slidesToShow: 6} },{ breakpoint: 1201, settings: {slidesToShow: 5} },{ breakpoint: 1101, settings: {slidesToShow: 4} }] }); $('#banner .ctrl .stop').on('click', function() { $(this).hide(); $('#banner .slider').slick('slickPause'); $('#banner .ctrl .play').show().focus(); }); $('#banner .ctrl .play').on('click', function() { $(this).hide(); $('#banner .slider').slick('slickPlay'); $('#banner .ctrl .stop').show().focus(); }); // 탑 버튼 - 스크롤시 $(window).on('scroll', function(){ var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); var footer = $('#footer').offset().top; if(scrollTop > 200){ $('.footer_top').fadeIn(); } else { $('.footer_top').fadeOut(); } if(scrollTop + windowHeight > footer) { if ($(window).width() > 640){ var position = scrollTop + windowHeight - footer - 30; $('.footer_top').css('bottom', position + 'px'); } else { var position2 = scrollTop + windowHeight - footer - 20; $('.footer_top').css('bottom', position2 + 'px'); } } else { $('.footer_top').css('bottom', '20px'); } }); });