$(function() { 'use strict'; // 해상도 분기점 전역변수 var $resolution_pc = 1200; var $resolution_tablet = 992; var $resolution_mobile = 768; // 초기화 main_hero_init(); latest_article_init(); partner_banner_init(); navigation_init(); parallax_init(); navi_init(); objectFitImages(); // 스크롤 이벤트 $(window).on('scroll', function() { header_scroll(); footer_init(); subhero_scroll(); }).scroll(); // IE 패럴랙스 스크롤 렉 방지 if ( navigator.userAgent.match(/Trident\/7\./) ) { $('body').on('mousewheel', function() { event.preventDefault(); var wheelDelta = event.wheelDelta; var currentScrollPosition = window.pageYOffset; window.scrollTo(0, currentScrollPosition - wheelDelta); }); } // 메인 롤링이미지 function main_hero_init() { if ( $('.main-hero-section').length ) { var $interval = ( $('.main-hero-section').data('interval') ) ? $('.main-hero-section').data('interval') : 4000; $('.main-hero-section .hero-slider').slick({ autoplay: true, autoplaySpeed: $interval, speed: 600, arrows: true, dots: true, lazyLoad: 'ondemand', prevArrow: $('.main-hero-section .slick-arrows .btn-prev'), nextArrow: $('.main-hero-section .slick-arrows .btn-next') }); } } // 메인 최근게시물 전체보기 버튼 세팅 function latest_article_init() { var $btn = $('.main-latest-section .btn-more'); $btn.attr('href', $('.main-latest-section .tab-pane:eq(0)').data('url')); $('.main-latest-section .tab-article li a').on('click', function() { var $idx = $(this).parent().index(); $btn.attr('href', $('.main-latest-section .tab-pane:eq(' + $idx + ')').data('url')); }); } // 메인 파트너 배너 세팅 function partner_banner_init() { if ( $('.partner-slider').length ) { $('.partner-slider').slick({ autoplay: true, autoplaySpeed: 2000, speed: 600, slidesToShow: 10, slidesToScroll: 1, arrows: true, dots: true, prevArrow: '', nextArrow: '', responsive: [ { breakpoint: 1199, settings: { slidesToShow: 6 } }, { breakpoint: 991, settings: { slidesToShow: 4 } }, { breakpoint: 767, settings: { slidesToShow: 2 } } ] }); } } // 내비게이션 세팅 function navigation_init() { var $header = $('#header'); var $openBtn = $header.find('.btn-nav-open'); var $closeBtn = $header.find('.btn-nav-close'); var $navDimmed = $header.find('.nav-dimmed'); $header.find('.menu-items > li').each(function() { if ( $(this).find('.subnav').length ) $(this).addClass('has-child-menu'); }); function nav_open() { $openBtn.attr('aria-expanded','true'); $navDimmed.stop().fadeIn(350); } function nav_close() { $openBtn.attr('aria-expanded','false'); $navDimmed.stop().fadeOut(350); } $openBtn.on('click', function() { nav_open(); }); $closeBtn.on('click', function() { nav_close(); }); $navDimmed.on('click', function() { nav_close(); }); $header.find('.menu-items > li > a').on('click', function(e) { if ( $(this).siblings('.subnav').length ) { e.preventDefault(); if ( !$(this).parent().hasClass('is-open') ) { $header.find('.menu-items > li.is-open').removeClass('is-open'); $header.find('.subnav').stop().slideUp(300); $(this).parent().addClass('is-open'); $(this).siblings('.subnav').stop().slideDown(300); } else { $(this).parent().removeClass('is-open'); $(this).siblings('.subnav').stop().slideUp(300); } } }); } // sticky 헤더 function header_scroll() { var $header = $('#header'); var $scrTop = $(window).scrollTop(); if ( $scrTop >= $header.outerHeight() ) { if ( !$header.hasClass('sticky') ) $header.addClass('sticky'); } else { $header.removeClass('sticky'); } } // 푸터 세팅 function footer_init() { var $scroll_btn = $('#btn-to-top'); var $header_size = $('#header').outerHeight(); var $footer_pos = $('#footer').offset().top - $(window).height(); var $scrTop = $(window).scrollTop(); if ( $scrTop >= $header_size && $scrTop < $footer_pos ) { $scroll_btn.addClass('show'); } else { $scroll_btn.removeClass('show'); } $scroll_btn.on('click', function() { $('html, body').stop().animate({scrollTop:0}, 600); }); } // 서브페이지 드롭다운 내비게이션 연동 function navi_init() { var $gnb = $('#header .gnb'); var $dropdown = []; var $url = $(location).attr('href'); var $idx_main = 0; var $idx_sub = 0; var $dropdown_html = []; $('.dropdown-nav-section .dropdown-wrap').each(function(i) { $dropdown[i] = $(this); i++; }); $gnb.find('.menu-items').children().each(function() { if ( $url.indexOf($(this).find('>a').attr('href')) > -1 ) { $idx_main = $(this).index(); $(this).addClass('is-active is-open'); $(this).find('.subnav').show(); } $(this).find('.subnav > li').each(function() { if ( $url.indexOf($(this).find('>a').attr('href')) > -1 ) { $idx_main = $(this).closest('.has-child-menu').index(); $idx_sub = $(this).index(); $(this).addClass('is-active'); $(this).closest('.has-child-menu').addClass('is-active is-open'); $(this).parent().show(); } }); }); if ( $('.dropdown-nav-section .dropdown-wrap').length ) { $dropdown_html[0] = ''; $dropdown_html[1] = ''; $gnb.find('.menu-items').children().each(function() { var $link = $(this).find('>a').attr('href'); var $name = $(this).find('>a').text(); $dropdown_html[0] += '
  • ' + $name + '
  • '; }); $gnb.find('.menu-items').children().eq($idx_main).find('.subnav > li').each(function() { var $link = $(this).find('>a').attr('href'); var $name = $(this).find('>a').text(); $dropdown_html[1] += '
  • ' + $name + '
  • '; }); $dropdown[0].find('.dropdown').append($dropdown_html[0]); $dropdown[1].find('.dropdown').append($dropdown_html[1]); $dropdown[0].find('.dropdown').children().eq($idx_main).addClass('is-active'); $dropdown[1].find('.dropdown').children().eq($idx_sub).addClass('is-active'); $dropdown[0].find('>a').text($dropdown[0].find('.is-active').text()); $dropdown[1].find('>a').text($dropdown[1].find('.is-active').text()); function dropdown_close() { $('.dropdown-nav-section .dropdown-wrap > a').attr('aria-expanded', 'false'); $('.dropdown-nav-section .dropdown-wrap > .dropdown').stop().slideUp(300); } $('.dropdown-nav-section .dropdown-wrap > a').on('click', function(e) { e.preventDefault(); if ( $(this).attr('aria-expanded') != 'true' ) { dropdown_close(); $(this).attr('aria-expanded', 'true'); $(this).siblings('.dropdown').stop().slideDown(300); } else { $(this).attr('aria-expanded', 'false'); $(this).siblings('.dropdown').stop().slideUp(300); } }); $(document).on('click touchend', function(e) { if ( !$(e.target).is('.dropdown-nav-section .dropdown-wrap > a') ) { dropdown_close(); } }); } } // 서브비주얼 스크롤시 효과 function subhero_scroll() { if ( $('#sub-hero').length ) { var $target = $('#sub-hero .caption-cell'); var $scrTop = $(window).scrollTop(); var $factor = 5; if ($scrTop <= $('#sub-hero').outerHeight()) { $target.css({'opacity':1 - (0.025 * ($scrTop / $factor))}); } } } // 패럴랙스 초기화 function parallax_init() { $('[data-parallax]').parallax(); } // 사업분야 고객이용후기 슬라이더 $(document).ready(function() { if ( $('.review-slider').length ) { $('.review-slider').slick({ dots: true, speed: 600, adaptiveHeight: true }); } }); // 제품소개 (페이지형) 갤러리 $(document).ready(function() { if ( $('.justify-gallery-row').length ) { var $gallery = $('.justify-gallery-row'); $gallery.magnificPopup({ delegate: 'a', type: 'image', mainClass: 'mfp-fade', removalDelay: 300, gallery: { enabled: true, navigateByImgClick: true, preload: [0, 1] } }); $gallery.justifiedGallery({ rowHeight: 400, margins: 10 }); } }); // FAQ 기능 $(document).ready(function () { if ($('.faq-list').length) { var $faq_article = $('.faq-list .titdesign'); if($faq_article.length) { var $answerRows = ''; var $answer = []; var $answerURL = []; $faq_article.each(function(i) { var $this = $(this); $answerURL[i] = $this.find('a').attr('href'); $.ajax({ url: $answerURL[i], async: false, cache: false, dataType: 'html', type: 'GET', contentType: 'application/x-www-form-urlencoded;charset=euc-kr', beforeSend: function(jqXHR) { jqXHR.overrideMimeType('application/x-www-form-urlencoded;charset=euc-kr'); }, success: function(data) { $answer[i] = $(data).find('#post_area').html(); $answerRows += ''; $answerRows += ''; $answerRows += 'A'; $answerRows += '
    ' + $answer[i] + '
    '; $answerRows += ''; $answerRows += ''; $this.after($answerRows); $answerRows = ''; }, error: function(response) { console.log(response); } }) i++; }); } $('.faq-list .bbsnewf5 a').on('click', function (e) { if ( !$(".board_admin_bgcolor").length ) { e.preventDefault(); if (!$(this).closest('tr').hasClass('is-open')) { $('.faq-list .answer-row').addClass('hide'); $('.faq-list .is-open').removeClass('is-open'); $(this).closest('tr').addClass('is-open'); $(this).closest('tr').next('.answer-row').removeClass('hide'); } else { $(this).closest('tr').removeClass('is-open'); $(this).closest('tr').next('.answer-row').addClass('hide'); } } }); } }); /********************************************* * 게시판 관련 스크립트 *********************************************/ // get parameter var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } }; // 카테고리 버튼화 처리 $(document).ready(function () { if ($('.board-category').length) { if ($('.board-category').find('select').length) { var $ca_link = []; var $ca_name = []; var $ca_current = getUrlParameter('com_board_category_code'); var $html = ''; $('.board-category').html($html); $('.board-category ul li').each(function () { if ($(this).find('a').attr('href').indexOf($ca_current) > -1 && $ca_current != '') $(this).addClass('is-active'); }); if (!$('.board-category .is-active').length) $('.board-category ul li:first-child').addClass('is-active'); } else { $('.board-category').remove(); } } $('.gallery_etc').each(function() { $(this).html($.trim($(this).text().replace('[','').replace(']','').split(':')[1])); }); }); // 이미지버튼 텍스트버튼 처리 $(document).ready(function () { var $btn_keywords = ['삭제', '이동', '복사', '글쓰기', '검색', '이전', '목록보기', '다음', '수정', '작성완료', '취소', '스팸신고', '답글쓰기', '댓글달기']; var $btn_type_input = $("input[type=image]"), $btn_type_img = $("img"); $btn_type_input.each(function () { var $src = $(this).attr('src'); if ($src.indexOf('search.gif') > -1) { $(this).before(''); $(document).on('click', '#btn-search', function () { $(this).next('input[type=image]').trigger('click'); }); $(this).hide(); } if ($src.indexOf('confirm.gif') > -1) { $(this).before(''); $(this).hide(); } if ($src.indexOf('comment_write.gif') > -1) { $(this).before(''); $(document).on('click', '#btn-comment-write', function () { $(this).next('input[type=image]').trigger('click'); }); $(this).hide(); } }); $btn_type_img.each(function () { var $src = $(this).attr('src'); var $event = $(this).attr('onclick'); if ($src.indexOf('btn_sdel.gif') > -1) { $(this).before(""); $(this).remove(); } if ($src.indexOf('move.gif') > -1) { $(this).before(""); $(this).remove(); } if ($src.indexOf('copy.gif') > -1) { $(this).before(""); $(this).remove(); } if ($src.indexOf('prev.gif') > -1) { $(this).parent().addClass('btn btn-default').text($btn_keywords[5]); } if ($src.indexOf('list.gif') > -1) { $(this).parent().addClass('btn btn-secondary').text($btn_keywords[6]); } if ($src.indexOf('next.gif') > -1) { $(this).parent().addClass('btn btn-default').text($btn_keywords[7]); } if ($src.indexOf('spam.gif') > -1) { $(this).before(''); $(this).remove(); } if ($src.indexOf('modify.gif') > -1) { $(this).parent().addClass('btn btn-warning').text($btn_keywords[8]); } if ($src.indexOf('delete.gif') > -1) { $(this).parent().addClass('btn btn-warning').text($btn_keywords[0]); } if ($src.indexOf('reply.gif') > -1) { $(this).parent().addClass('btn btn-secondary').text($btn_keywords[12]); } if ($src.indexOf('write.gif') > -1) { $(this).parent().addClass('btn btn-secondary').text($btn_keywords[3]); } if ($src.indexOf('btn_confirm.gif') > -1) { $(this).parent().addClass('btn btn-primary btn-lg').text($btn_keywords[9]); } if ($src.indexOf('cancel.gif') > -1) { $(this).parent().addClass('btn btn-secondary btn-lg').text($btn_keywords[10]); } }); }); // 리스트 게시판 헤더 처리 $(document).ready(function() { $('.att_title').each(function() { $(this).attr('rel', $.trim($(this).text().replace(/\s/g,''))); }); }); // 제품소개 B 타입 (오버레이) $(document).ready(function() { if ( $('.type-b-row').length ) { var $subject = []; var $category = []; $('.type-b-row .bbsnewf5').each(function(i) { var $markup = ''; $subject[i] = $(this).find('.gallery_title').text(); $category[i] = $(this).find('.gallery_etc').text(); $markup = '
    '; $markup += '
    '; $markup += '
    '; $markup += '

    ' + $category[i] + '

    '; $markup += '

    ' + $subject[i] + '

    '; $markup += '
    '; $markup += '
    '; $markup += '
    '; $(this).find('> table tr').not(':eq(0)').remove(); $(this).find('> table tr').eq(0).find('a').append($markup); }); } }); // 윈도우 로드 이벤트 $(window).on('load', function() { if ( $('#sub-hero').length ) $('#sub-hero').addClass('is-loaded'); $('body').addClass('__load'); }); /* ================================================ * MAIN - NUMBERING ANIMATION (18-12-20 ADD) ================================================ */ var $counted = false; $(window).bind('scroll', function() { if($('.main-count-section').length) { var $counterOffset = $('.main-count-section').offset().top - window.innerHeight; var $scrollTop = $(this).scrollTop(); if($counted == false && $scrollTop >= $counterOffset) { $('.count-info h3').each(function() { var _this = $(this), countTo = _this.data('count'); _this.addClass('__show'); $({ countNum: _this.text() }).animate({ countNum: countTo }, { duration: 2000, easing: 'swing', step: function() { _this.text(Math.ceil(this.countNum).toLocaleString('en')); }, complete: function() { _this.text(Math.ceil(this.countNum).toLocaleString('en')); } }); }); $counted = true; } } }); });