$(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_hero_init();
sub_hero_init();
main_news_init();
main_interior_init();
navigation_init();
parallax_init();
navi_init();
footer_init();
objectFitImages();
body_part_init();
// scroll handler
$(window).on('scroll', function () {
animate_bg_init();
quick_scroll();
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);
});
}
// 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: false,
dots: true,
lazyLoad: 'ondemand',
prevArrow: '',
nextArrow: ''
});
}
}
// main hero init
function sub_hero_init() {
var $shero = $('.sub-hero-section');
if ($shero.length) {
var $interval = ($shero.data('interval')) ? $shero.data('interval') : 4000;
$shero.on('init', function (event, slick) {
$shero.find('.slick-current').removeClass('slick-active').addClass('reset-animation');
setTimeout(function () {
$shero.find('.slick-current').removeClass('reset-animation').addClass('slick-active');
}, 1);
});
$shero.slick({
autoplay: true,
autoplaySpeed: $interval,
speed: 600,
arrows: false,
dots: false,
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: 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) {
$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();
}
}
}
// main interior init
function main_interior_init() {
var $largeSlider = $(".main-interior-slider");
var $thumbs = $(".main-interior-thumbs");
var syncedSecondary = true;
$largeSlider
.owlCarousel({
items: 1,
slideSpeed: 10000,
nav: true,
autoplay: true,
dots: false,
loop: true,
smartSpeed: 600,
fluidSpeed: 600,
navSpeed: 600,
responsiveRefreshRate: 200,
navText: ['', ''],
})
.on("changed.owl.carousel", syncPosition);
$thumbs
.on("initialized.owl.carousel", function () {
$thumbs
.find(".owl-item")
.eq(0)
.addClass("current");
})
.owlCarousel({
items: 6,
dots: true,
nav: false,
margin: 5,
smartSpeed: 600,
fluidSpeed: 600,
navSpeed: 600,
slideBy: 6,
responsiveRefreshRate: 100,
responsive: {
0: {
items: 2
},
768: {
items: 3
},
1024: {
items: 6
}
}
})
.on("changed.owl.carousel", syncPosition2);
function syncPosition(el) {
//if loop is set to false, then you have to uncomment the next line
//var current = el.item.index;
//to disable loop, comment this block
var count = el.item.count - 1;
var current = Math.round(el.item.index - el.item.count / 2 - 0.5);
if (current < 0) {
current = count;
}
if (current > count) {
current = 0;
}
//to this
$thumbs
.find(".owl-item")
.removeClass("current")
.eq(current)
.addClass("current");
var onscreen = $thumbs.find(".owl-item.active").length - 1;
var start = $thumbs
.find(".owl-item.active")
.first()
.index();
var end = $thumbs
.find(".owl-item.active")
.last()
.index();
if (current > end) {
$thumbs.data("owl.carousel").to(current, 100, true);
}
if (current < start) {
$thumbs.data("owl.carousel").to(current - onscreen, 100, true);
}
}
function syncPosition2(el) {
if (syncedSecondary) {
var number = el.item.index;
$largeSlider.data("owl.carousel").to(number, 100, true);
}
}
$thumbs.on("click", ".owl-item", function (e) {
e.preventDefault();
var number = $(this).index();
$largeSlider.data("owl.carousel").to(number, 300, true);
});
}
// navigation init
function navigation_init() {
var scrollTopBtn = $('#btnToTop');
var gnbNav = $('#gnb > li');
var gnbMobile = $('#header nav');
var gnbToggle = $('#nav-toggle');
var gnbMask = $('#header .nav-overlay');
var headerInit = function () {
gnbNav.each(function () {
if ($(this).find('.subnav').length) $(this).addClass('has-subdepth');
});
};
/* sticky header */
var stickyHeader = function () {
var window_w = $(window).width();
var header = $('#header');
var header_h = header.find('.header-top').outerHeight();
var scrollTop = $(window).scrollTop();
if (window_w > 991) {
if (scrollTop >= header_h) {
if (!header.hasClass('sticky')) {
header.addClass('sticky');
}
} else {
header.removeClass('sticky');
}
} else {
header.removeClass('sticky');
}
};
/* gnb active */
var activeGnb = function () {
var url = $(location).attr('href');
gnbNav.each(function () {
if (url.indexOf($(this).find('>a').attr('href')) > -1) $(this).addClass('is-active');
});
console.log($('#header').find('.is-active').length);
if (!$('#header').find('.is-active').length) gnbNav.eq(0).addClass('is-active');
};
activeGnb();
/* show gnb */
var showGnb = function () {
gnbToggle.addClass('open');
gnbMobile.stop().slideDown(600, 'easeOutQuint');
gnbMask.stop().fadeIn(600);
};
/* hide gnb */
var hideGnb = function () {
gnbToggle.removeClass('open');
gnbMobile.stop().slideUp(600, 'easeOutQuint');
gnbMask.stop().fadeOut(600);
};
/* hamburger button */
gnbToggle.click(function () {
$('#header .member-wrapper').removeClass('open');
if (!$(this).hasClass('open')) {
showGnb();
} else {
hideGnb();
}
});
gnbMask.click(function () {
hideGnb();
});
$(window).on('scroll', function () {
stickyHeader();
});
}
// 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);
});
});
// quickmenu scroll
function quick_scroll() {
var $quick = $('#quickmenu');
var $is_sticky = $('#header').attr('class');
var $winWidth = $(window).width();
var $pos;
$is_sticky == 'sticky' ? $pos = 220 : $pos = 354;
if ($winWidth >= 1300) {
$quick.stop().animate({
top: $(window).scrollTop() + $pos + 'px'
}, 400);
}
}
// quickmenu top button
function quick_init() {
$('#quickmenu .btn-to-top').on('click', function (e) {
e.preventDefault();
$('html, body').stop().animate({
scrollTop: 0
}, 500, 'easeInOutCubic');
});
}
// 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 () {
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]));
});
});
// 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').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]);
}
});
});
// list board header attributes
$(document).ready(function () {
$('.att_title').each(function () {
$(this).attr('rel', $.trim($(this).text().replace(/\s/g, '')));
});
});
// 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);
});
}
});
// 부위별 증상
function body_part_init() {
$('.sub4-sec .tabList-list > li').on('click', function() {
var $item = $(this).data('tab-select');
$(this).parent().children().removeClass('active');
$(this).addClass('active');
$('.sub4-sec .tabList-content > div').hide();
$('.sub4-sec .tabList-content > div[data-tab-item=' + $item + ']').stop().fadeIn(300);
});
}
// 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();
});
});