$(function() {
'use strict';
// global resolution variable
var $resolution_pc = 1200; // PC 분기점 (min-width 기준)
var $resolution_tablet = 992; // 태블릿 분기점 (min-width 기준)
var $resolution_mobile = 768; // 모바일 분기점 (min-width 기준)
// init
main_news_init();
navigation_init();
parallax_init();
navi_init();
footer_init();
objectFitImages();
main_swiper_init();
new_header_init();
breadcrumbs_init ();
mobile_header_init ();
quick_init();
// scroll handler
$(window).on('scroll', function() {
header_scroll();
animate_bg_init();
subhero_scroll();
}).scroll();
// page loading
function page_load_complete() {
var $loader = $('#page-loader');
$loader.find('.loader').fadeOut('slow', function() {
setTimeout(function() {
$loader.fadeOut('slow');
}, 100);
});
}
//mobile header
function mobile_header_init () {
var open_hamburger = $('.mobile-header-btn button');
var close_hamburger = $('.mobile-close-btn button');
var mobile_menu = $('.mobile-menu');
var mobile_nav = $('#mobile-nav > ul > li > a');
var mobile_subnav = $('#mobile-nav .subnav');
open_hamburger.on('click', function(e) {
e.preventDefault();
if(!mobile_menu.hasClass('open')) {
mobile_menu.addClass('open');
}
});
close_hamburger.on('click', function(e) {
e.preventDefault();
if(mobile_menu.hasClass('open')) {
mobile_menu.removeClass('open');
}
});
mobile_nav.on('click', function(e) {
e.preventDefault();
if(!$(this).hasClass('active')) {
mobile_nav.removeClass('active');
$(this).addClass('active');
mobile_subnav.stop().slideUp(300);
$(this).siblings('.subnav').stop().slideDown(300);
} else {
$(this).removeClass('active');
$(this).siblings('.subnav').stop().slideUp(300);
}
});
}
// breadcrumbs
function breadcrumbs_init () {
//#header .subnav .subnav-box li.index(0)
//#header .subnav .subnav-box li.index(1~*)
var nav_ul = $("#header .subnav .subnav-box ul");
var menus = [];
var current_link = location.pathname;
var idx = [];
var parent_link;
nav_ul.each(function(i) {
var aTags = $(this).find('a');
aTags.each(function(j){
if (current_link.indexOf($(this).attr('href')) != -1) {
idx = [i, j];
parent_link = nav_ul.eq(i).find('a').eq(0).attr('href');
}
});
menus.push(aTags);
});
if (parent_link) {
var html1 = "" + menus[idx[0]][0].text + "";
var html2 = "" + menus[idx[0]][idx[1]].text + "";
var breadcrumbs = $('#sub-hero ul li');
breadcrumbs.eq(1).html(html1);
breadcrumbs.eq(2).html(html2);
}
}
// quickmenu top button
function quick_init() {
$('#quick-menu .topBtn').on('click', function (e) {
e.preventDefault();
$('html, body').stop().animate({
scrollTop: 0
}, 500, 'easeInOutCubic');
});
}
//new header subanv
function new_header_init() {
var $header = $('#header');
$("#header .pc-header #nav > ul li").on('mouseenter', function() {
var idx = $(this).index();
$("#header .pc-header .subnav .img-box img").removeClass('on');
$("#header .pc-header .subnav .img-box img").eq(idx).addClass('on');
$header.addClass('sticky');
$header.find('.subnav').stop().slideDown(300);
$header.find('.subnav-bg').stop().slideDown(300);
});
$("#header .pc-header .subnav ul li").on('mouseenter', function() {
var idx = $(this).parents('.col-subnav').index();
$("#header .pc-header .subnav .img-box img").removeClass('on');
$("#header .pc-header .subnav .img-box img").eq(idx).addClass('on');
});
$header.on('mouseleave', function(e) {
$header.find('.subnav').stop().slideUp(300);
$header.find('.subnav-bg').stop().slideUp(300);
var scr = $(document).scrollTop();
if (scr <= $header.outerHeight()) {
$header.removeClass('sticky');
}
});
}
// main swiper init
function main_swiper_init() {
if ( $('.main-hero-section .swiper').length ) {
var $swiper = new Swiper('.main-hero-section .swiper', {
speed: 700,
slidesPerView: 1,
centeredSlides: true,
loop: true,
slideToClickedSlide: true,
navigation: {
nextEl: '.main-hero-section .next-btn',
prevEl: '.main-hero-section .prev-btn',
},
autoplay: {
delay: 4500
},
pagination: {
el: ".swiper-pagination"
}
});
}
};
// main hero init
function main_hero_init() {
var $hero = $('.main-hero-section');
if ( $hero.length ) {
var $interval = ( $hero.data('interval') ) ? $hero.data('interval') : 4000;
$hero.on('init', function(event, slick) {
$hero.find('.slick-current').removeClass('slick-active').addClass('reset-animation');
setTimeout(function() {
$hero.find('.slick-current').removeClass('reset-animation').addClass('slick-active');
}, 1);
});
$hero.slick({
autoplay: true,
autoplaySpeed: $interval,
speed: 600,
arrows: true,
dots: true,
lazyLoad: 'ondemand',
prevArrow: '',
nextArrow: ''
});
}
}
// main news init
function main_news_init() {
if ( $('.main-notice-section .output-list').length ) {
var $list = $('.main-notice-section .output-list');
var $article = $list.find('.board_output_1_tr');
if( $article.length ) {
var $column = $article.closest('.output-list').data('column'),
$html = '
\n',
$postURL = [],
$category = [],
$subject = [],
$content = [],
$date = [];
switch ($column) {
case 1:
$column = 12;
break;
case 2:
$column = 6;
break;
case 3:
$column = 4;
break;
case 4:
$column = 3;
break;
default:
$column = 4;
}
$article.each(function(i) {
var $this = $(this);
$subject[i] = $this.find('a').text();
$postURL[i] = $this.find('a').attr('href');
$date[i] = $this.find('>td:last-child').text();
$.ajax({
url: $postURL[i],
async: false,
cache: true,
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) {
$content[i] = $(data).find('#post_area').html().replace(/(<([^>]+)>)/ig,"");
$category[i] = $(data).find('.board_desc:last').text();
$html += '
\n';
$html += '
\n';
$html += '
' + $category[i] + '\n';
$html += '
\n';
$html += '
' + $content[i] + '
\n';
$html += '
' + $date[i] + '\n';
$html += '
\n';
$html += '
\n';
},
error: function(response) {
console.log(response);
}
});
i++;
});
$html += '
';
$list.after($html);
$list.remove();
}
}
}
// navigation init
function navigation_init() {
var $header = $('#header');
var $gnb = $('#header .gnb');
var $sidenav = $('#header .side-nav');
var $openBtn = $header.find('.btn-nav-open');
var $closeBtn = $header.find('.btn-nav-close');
var $navDimmed = $header.find('.nav-dimmed');
var $originalHeight = [];
$gnb.find('.menu-items > li').each(function() {
$originalHeight.push($(this).find('.subnav-wrap').outerHeight());
});
$gnb.find('.subnav-wrap').height(0);
$gnb.find('.menu-items > li').on('mouseenter', function() {
$(this).find('.subnav-wrap').stop(true, true).css({visibility:'visible', opacity:0}).animate({'height': $originalHeight[$(this).index()], 'opacity':1}, 350, 'easeOutCubic');
}).on('mouseleave', function() {
$gnb.find('.subnav-wrap').stop(true, true).animate({'height':0, 'opacity':0}, 200, function() {
$(this).css({visibility:'hidden'});
});
});
$sidenav.find('.menu-items > li').each(function() {
if ( $(this).find('.subnav').length ) $(this).addClass('has-child-menu');
});
function nav_open() {
$('body').addClass('nav-is-open');
$navDimmed.stop().fadeIn(350);
}
function nav_close() {
$('body').removeClass('nav-is-open');
$navDimmed.stop().fadeOut(350);
}
$openBtn.on('click', function() {
nav_open();
});
$closeBtn.on('click', function() {
nav_close();
});
$navDimmed.on('click', function() {
nav_close();
});
$sidenav.find('.menu-items > li > a').on('click', function(e) {
if ( $(this).siblings('.subnav').length ) {
e.preventDefault();
if ( !$(this).parent().hasClass('is-open') ) {
$sidenav.find('.menu-items > li.is-open').removeClass('is-open');
$sidenav.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 header
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');
}
}
// footer init
function footer_init() {
var $footer_size = $('#footer').outerHeight();
$('.footer-spacer').height($footer_size);
}
$('#footer .col-sitemap dl dt a').on('click', function(e) {
var $winWidth = $(window).width();
if ( $winWidth < $resolution_mobile ) {
if ( $(this).parent().next('dd').find('ul').length ) {
e.preventDefault();
if ( !$(this).closest('dl').hasClass('is-open') ) {
$('#footer .col-sitemap dl').removeClass('is-open');
$('#footer .col-sitemap dl dd').stop().slideUp(300);
$(this).closest('dl').addClass('is-open');
$(this).parent().next('dd').stop().slideDown(300);
} else {
$(this).closest('dl').removeClass('is-open');
$(this).parent().next('dd').stop().slideUp(300);
}
}
}
});
// main skills progressbar
function animate_progress_bar() {
$('.progress-group').each(function() {
var $percentage = $(this).data('percentage');
var $beforeCount = ($(this).find('.percent-text').text() == '') ? 0 : $(this).find('.percent-text').text();
$(this).addClass('active');
$(this).find('.percent-text').each(function() {
var $this = $(this);
$({Counter: $beforeCount}).animate({Counter: $percentage}, {
duration: 2000,
easing: 'swing',
step: function() {
$this.text(Math.ceil(this.Counter));
}
});
});
$(this).find('.percent').stop().animate({left: $percentage + '%'}, 2000);
$(this).find('.progress-wrap .bar').stop().animate({width: $percentage + '%'}, 2000);
});
}
if ( $('.progress-group').length ) {
var waypoint = new Waypoint({
element: $('.progress-group'),
handler: function(direction) {
animate_progress_bar();
},
offset: '100%'
});
}
// animated background effect
function animate_bg_init() {
var $elem = $('.animated-bg');
$elem.length && $elem.each(function() {
var $this = $(this),
$size = $this.outerHeight(),
$pos = $this.offset().top,
$calc = $size + $pos,
$scrollTop = $(window).scrollTop(),
$winHeight = $(window).outerHeight(),
$areaStart = $pos - $winHeight,
$areaEnd = $calc - $size / 2 - $winHeight / 2,
$factor = 0;
if ( $scrollTop >= $areaStart && $scrollTop <= $areaEnd ) {
var $scale = ($scrollTop - $areaStart) / ($areaEnd - $areaStart);
$factor = 0.7 + 0.3 * $scale, $factor >= 0.98 ? $factor = 1 : $factor < 0.7 && ($factor = 0.3), $this.css({
transform: 'matrix(' + $factor + ', 0, 0, 1, 0, 0)'
});
}
});
}
// main review slider
$(document).ready(function() {
if ( $('.main-animate-section02 .review-slider').length ) {
$('.main-animate-section02 .review-slider').slick({
dots: true,
arrows: false,
speed: 600,
adaptiveHeight: true
});
}
});
// main map function
$(document).ready(function() {
var $main_map = $('.main-map-section');
var $body = $('body');
$main_map.append($main_map.find('.visible-map').clone().removeClass('visible-map').addClass('hide-map'));
$('.main-map-section .btn-detail').on('click', function(e) {
e.preventDefault();
$body.addClass('fold-map');
setTimeout(function() {
$body.addClass('fixed-map');
}, 450);
});
$('.main-map-section .btn-close').on('click', function() {
$body.removeClass('fixed-map');
setTimeout(function() {
$body.removeClass('fold-map');
}, 450);
});
});
// dropdown init
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() {
var $this = $(this);
if ( $url.indexOf($(this).find('>a').attr('href')) > -1 && $(this).index() != 0 ) {
$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 && $(this).closest('li').index() != 0 ) {
$idx_main = $(this).parent().closest('li').index();
$idx_sub = $(this).index();
$(this).parent().addClass('is-active');
$(this).parent().closest('li').addClass('is-active');
}
});
});
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();
}
});
}
}
// sub hero scroll effect
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))});
}
}
}
// parallax init
function parallax_init() {
$('[data-parallax]').parallax();
}
// business review slider
$(document).ready(function() {
if ( $('.business-review-section .review-slider').length ) {
$('.business-review-section .review-slider').slick({
dots: true,
speed: 600,
adaptiveHeight: true
});
}
});
// justified gallery init
$(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 init
$(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');
}
}
});
}
});
/*********************************************
* board functions
*********************************************/
// 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]);
}
}
};
// categories to buttons
$(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 select option').each(function (i) {
$ca_name[i] = $(this).text();
$ca_link[i] = $(location).attr('pathname') + '?com_board_category_code=' + $(this).val();
$html += '- ' + $ca_name[i] + '
';
});
$html += '
';
$('.board-category').html($html);
$('.board-category ul li').each(function () {
var cate = $(this).find('a').attr('href').split('com_board_category_code=');
if (cate.length > 1 && cate[1] == $ca_current && $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]));
});
});
// image button to text button
$(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 btn-default2').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 btn-default2').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]);
}
});
});
// list board header attributes
$(document).ready(function() {
$('.att_title').each(function() {
$(this).attr('rel', $.trim($(this).text().replace(/\s/g,'')));
});
});
// product a type
$(document).ready(function(){
var arow = $(".type-a-row");
if (arow.length) {
arow.find(".bbsnewf5").each(function(i){
var $subject = $(this).find('tr').eq(1);
var $cate = $(this).find('tr').eq(2);
$(this).find('> table tr').not(':eq(0)').remove();
$(this).find('> table').append($cate).append($subject);
})
}
});
// product b type (overlay)
$(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 load handler
$(window).on('load', function() {
if ( $('#sub-hero').length ) $('#sub-hero').addClass('is-loaded');
page_load_complete();
});
// window resize handler
$(window).on('resize', function() {
footer_init();
});
});