// 페이지 이동
function go_page(url) {
document.location.href = decodeURIComponent(url);
return false;
}
// 검색창
function tsearch_submit(f) {
if (f.stx.value.length < 2) {
alert("검색어는 두글자 이상 입력하십시오.");
f.stx.select();
f.stx.focus();
return false;
}
f.action = f.url.value;
return true;
}
// a태그에 해쉬태그 클릭시 스크롤
function hash_scroll(e) {
$(e).click(function(){
$('html,body').animate({scrollTop:0 + $(this.hash).offset().top});
});
}
// 메뉴 링크에 #태그 있을 경우 메뉴 on
function url_hash_menu_on() {
const $btns = document.querySelectorAll('#menu .sub-a, #sub-menu .sub-a, #m-menu .depth2-a');
let hash = window.location.hash;
if(hash){
$btns.forEach(function(e) {
let on = e.closest('.on');
let url = e.getAttribute('href');
if(on == e) {
e.dataset.real = 'myself';
} else if(on != e && on == e.parentElement) {
e.dataset.real = 'parent';
} else {
e.dataset.real = '';
}
if(url.includes('#')) {
if(url.includes(hash)) {
on.classList.add('on');
} else {
on.classList.remove('on');
}
e.addEventListener('click', function() {
for(var i=0; i<$btns.length; i++) {
if(url == $btns[i].getAttribute('href')) {
if($btns[i].dataset.real == 'myself') {
$btns[i].classList.add('on');
} else if($btns[i].dataset.real == 'parent') {
$btns[i].parentElement.classList.add('on');
console.log($btns[i].parentElement);
}
} else {
if($btns[i].dataset.real == 'myself') {
$btns[i].classList.remove('on');
} else if($btns[i].dataset.real == 'parent') {
$btns[i].parentElement.classList.remove('on');
}
}
}
});
}
});
}
}
// 오늘하루 창닫기
function day_pop_closed(e) {
var cookieid = $(e).closest('.modal').attr('id');
Cookies.set('No-'+cookieid, '1', { expires: 1 });
setTimeout(function () {
$(e).parents('#' + cookieid).modal('hide');
}, 200);
return false;
}
// 개인정보처리방침 등 팝업 버튼
function site_info_btn(btns) {
const $body = document.querySelector("body");
let $bottom, footer, agree, in_btns = '';
if(!btns) { //버튼 지정안하면 푸터버튼 작동
in_btns = false;
$bottom = document.getElementById('bottom');
footer = $bottom.querySelector('.footer');
btns = footer.querySelectorAll('.site-link button');
btns.forEach( function(btn) {
btns_click(btn);
});
} else {
in_btns = true;
agree = '
');
content = content[1].split('');
}
});
return content[0];
}
function swiper_slide_add(el, num) {
const $swiperWrapper = el.querySelectorAll(".swiper-wrapper");
if(!num) num = 5;
$swiperWrapper.forEach(function(wrap) {
let $swiperSlides = wrap.querySelectorAll(".swiper-slide");
let i = $swiperSlides.length;
let j = 0;
if(i == 0) return true;
while(j
num) {
wrap.lastElementChild.remove();
}
});
}
// 드래그 금지
function scroll_impossible(el) {
$(el).on('scroll touchmove mousewheel', function(e) {
e.preventDefault();
e.stopPropagation();
return false;
});
}
// 드래그 가능
function scroll_possible(el) {
$(el).off('scroll touchmove mousewheel');
}
// 숫자롤링
function count_rolling(e) {
$(e).each(function(index) {
var $this = $(this);
var countFrom = $this.attr('data-from');
var countTo = $this.attr('data-count');
var comma_no = $this.attr('data-nocomma');
var speed = Math.floor($this.attr('data-duration'));
var delay = Math.floor($this.attr('data-delay'));
var isComma = /^[0-9]+\.?[0-9]+$/;
var num = '';
$({ val: countFrom }).delay(delay).animate({ val: countTo }, {
duration: speed,
easing:'linear',
step: function() {
if(isComma.test(countFrom)) {
num = numberCommas(parseFloat(this.val).toFixed(1));
} else {
num = numberCommas(Math.floor(this.val));
}
$this.text(num);
},
complete: function() {
if (Number.isInteger(this.val)){
num = numberCommas(Math.floor(this.val));
} else {
num = numberCommas(this.val.toFixed(1));
}
$this.text(num);
}
});
function numberCommas(x) {
if(comma_no != '1') {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
} else {
return x;
}
}
});
}
// 서브페이지 서브메뉴까지 자동 스크롤
function subpage_scroll() {
var $subpg = $('.is-subpage');
var $submenu = $subpg.find('#sub-menu');
if($subpg && $submenu.offset() && ($(window).scrollTop() < $submenu.offset().top) && !$('body').hasClass('no_scroll')) {
var t = $submenu.offset().top;
setTimeout(function () {
$('html, body').animate({scrollTop:0+t});
}, 300);
}
}
// 풀페이지
function fullpage_act(page, $anchors, $nav, $nav_position, $speed, $scrollBar=false, $effect=false) {
if(!$speed) $speed = 1000;
var isAutoHeightMode = false;
var $header = $(page).find('.section .header');
var $body = $('body');
$body.addClass('fullpage');
if($effect == true) {
function class_add() {
if ($(window).width() > 1024 && $(window).height() > 800) {
$(page).addClass('fullpage-effect');
} else {
$(page).removeClass('fullpage-effect');
}
}
class_add();
$(window).on('resize', function() {
class_add();
});
}
$header.each(function() {
var $header_obj = $(this).children();
$header_obj.each(function(i, e) {
if(!$(e).data('ani-name')) {
$(e).data('ani-name', 'fadeInUp');
}
$(e).css({'animation-delay':i*150+'ms'}).addClass('animated').addClass( $(e).data('ani-name') );
});
});
$(page).fullpage({
autoScrolling: true,
css3: true,
scrollingSpeed: $speed,
anchors: $anchors,
verticalCentered: false,
scrollBar: $scrollBar,
fitToSection: false,
navigation: true,
navigationPosition: $nav_position,
navigationTooltips: $nav,
bigSectionsDestination: 'top',
slidesNavigation: false,
slidesNavPosition: 'top',
controlArrows: false,
responsiveWidth: 1024,
responsiveHeight: 800,
responsiveSlides: true,
onLeave: function(index, nextIndex) {
var $sections = $(page + ' .section');
var $next = $sections.eq(nextIndex - 1);
var $header = $next.find('.header');
var $numbering = $next.find('.count-num');
if (!isAutoHeightMode) {
$header.each(function() {
var $header_obj = $(this).children();
$header_obj.each(function(i, e) {
if(!$(e).data('ani-name')) {
$(e).data('ani-name', 'fadeInUp');
}
$(e).css({'visibility':'hidden', 'animation-delay':''}).removeClass('animated').removeClass( $(e).data('ani-name') );
setTimeout(function () {
$(e).css({'visibility':'visible', 'animation-delay':i*50+'ms'}).addClass('animated').addClass( $(e).data('ani-name') );
}, 1000);
});
});
if($(page).hasClass('fullpage-effect')) {
$next.prevAll().css({'top':'-50%'});
$next.nextAll().css({'top':'100%'});
$next.css({'top':'0'});
$('#top').removeClass('bg');
if($next.attr('id') == 'bottom') {
var h = Math.ceil($next.innerHeight());
$next.css({'top':'calc(100vh - '+h+'px)'});
$('#top').addClass('bg');
}
if($next.hasClass('top-white')) {
$('#top').addClass('bg');
}
}
}
if($next.hasClass('white-')) {
$body.addClass('no-bg');
} else {
$body.removeClass('no-bg');
}
if($numbering) count_rolling($numbering);
if(nextIndex != '1') {
$body.addClass('scrolled').removeClass('not-scrolled');
} else {
$body.removeClass('scrolled').addClass('not-scrolled');
}
},
afterRender: function() {
$(page + ' .section').css({'visibility':'visible', 'top':''});
}
});
var sec_objs = $(page).find('.section');
function section_option() {
sec_objs.each(function() {
var $this = $(this);
if ($(window).width() <= 1024 || $(window).height() <= 800) {
$this.addClass('fp-auto-height');
isAutoHeightMode = true;
} else {
$this.removeClass('fp-auto-height');
isAutoHeightMode = false;
}
if($this.attr('id') == 'bottom') {
$this.addClass('fp-auto-height');
}
});
}
$(window).on('resize', function() {
section_option();
});
section_option();
if (isAutoHeightMode) {
$.fn.fullpage.moveTo(1, 0);
$('html, body').animate({ scrollTop: '0px' }, 0);
} else {
if(window.location.hash) {
var url = window.location.pathname + window.location.search;
history.scrollRestoration = "manual";
history.pushState("", "", url);
$.fn.fullpage.moveTo(1, 0);
}
}
if($(page).hasClass('fullpage-effect')) {
$('.go-top').click(function() {
$.fn.fullpage.moveTo(1, 0);
});
}
}
// ScrollReveal
window.sr = ScrollReveal({
reset: false,
distance: '100px',
easing: 'ease',
viewFactor: 0.3
});
window.addEventListener('DOMContentLoaded', function() {
// Index Page
sr.reveal('#main-slide1', { delay: 0 });
sr.reveal('.pg-main .reveal', { reset: true });
sr.reveal('.pg-main .reveal-once', { reset: false });
// Sub Pages
sr.reveal('.page-content .reveal', { reset: true });
sr.reveal('.page-content .reveal-once', { reset: false });
const $body = document.querySelector('body');
const $top = document.getElementById('top');
const $bottom = document.getElementById('bottom');
const $page = document.getElementById('page');
// Effect
setTimeout(function() {
$body.classList.add('load-on');
site_info_btn();
}, 200);
// Editor
let $page_class = $page.classList.value;
if($page_class.includes('board-') && $page.querySelector('.view-box')) {
$page.querySelector('.view-box').classList.add('ck-content');
}
// Favorite
$('#favorite').on('click', function(e) {
var bookmarkURL = window.location.href;
var bookmarkTitle = document.title;
var triggerDefault = false;
if (window.sidebar && window.sidebar.addPanel) {
// Firefox version < 23
window.sidebar.addPanel(bookmarkTitle, bookmarkURL, '');
} else if ((window.sidebar && (navigator.userAgent.toLowerCase().indexOf('firefox') > -1)) || (window.opera && window.print)) {
// Firefox version >= 23 and Opera Hotlist
var $this = $(this);
$this.attr('href', bookmarkURL);
$this.attr('title', bookmarkTitle);
$this.attr('rel', 'sidebar');
$this.off(e);
triggerDefault = true;
} else if (window.external && ('AddFavorite' in window.external)) {
// IE Favorite
window.external.AddFavorite(bookmarkURL, bookmarkTitle);
} else {
// WebKit - Safari/Chrome
alert((navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Cmd' : 'Ctrl') + '+D 키를 눌러 즐겨찾기에 등록하실 수 있습니다.');
}
return triggerDefault;
});
// Main mouse scroll
$('#main-mouse-scroll').click(function(){
var h = $(window).height();
$(window).on('resize', function() {
h = $(window).height();
});
$('html,body').animate({scrollTop:h});
if($('body').hasClass('fullpage')) $.fn.fullpage.moveTo(2);
});
// Popup
$('.hd_pops').draggable().css({"cursor":"move"});
$('.modal[id*="-popup"]').draggable();
$('.modal[id*="-popup"]').find('.closed').css({"cursor":"move"});
$('.hd_pops').each(function(index){
$(this).addClass('pop_fadein').css({"animation-delay":(index+1) * 600 + "ms"});
});
if($('.hd_pops').length > 0) {
$('#hd_pop').show();
$('.hd_pops').click(function(){
$(this).each(function(){
if($(this).is(':visible') != true && $('.hd_pops').not($(this)).is(':visible') != true) {
$('#hd_pop').hide();
}
});
});
}
var $grid = $('#hd_pop').imagesLoaded( function() {
$grid.masonry({
itemSelector: '.hd_pops',
gutter: 10,
horizontalOrder: true,
stagger: 500,
columnWidth: 1,
});
});
var pop_objs = $('#center-popup, #right-popup');
pop_objs.each(function(i, e) {
var thisid = $(e).attr('id');
var $autoH = false;
if (Cookies.get('No-'+thisid) === '1') return;
if(thisid.includes('center') == false) {
$(e).modal({
backdrop: false
});
} else {
$('body').css({'overflow':'visible'});
}
if(thisid == 'center-popup') {
$autoH = true;
}
var opts = {};
if ( $(e).find('.swiper-slide').length > 1 ) {
opts = {
loop: true,
speed:2000,
autoplay: {
delay: 3000,
disableOnInteraction: true
},
pagination: {
el: '#'+thisid+' .pg',
clickable: true
},
navigation: {
prevEl: '#'+thisid+' .prev',
nextEl: '#'+thisid+' .next'
},
autoHeight: $autoH,
}
} else {
opts = {
allowTouchMove: false,
}
}
var SW;
setTimeout(function () {
$(e).modal('show');
SW = new Swiper('#'+thisid+' .swiper-container', opts);
}, 200);
var rid = getRandomID();
$(window).on('resize', function () {
waitForFinalEvent(function () {
SW.update();
}, 500, rid);
});
$(e).find('.swiper-slide').each(function() {
var href = $(this).data('href');
var self = $(this).data('self');
target = '';
if(self == '2') {
target = 'target="_blank"';
}
if(href) {
if(!href.includes('https://') || !href.includes('http://')) {
href = 'http://' + href;
}
$(this).prepend('');
$(this).append('');
}
});
$('.modal-backdrop').click(function () {
$(e).modal('hide');
});
});
$('.modal').on('hidden.bs.modal', function (e) {
$(this).find('iframe').attr('src', '');
});
// Family Site
const family_site = document.querySelectorAll('.family-box');
family_site.forEach(function(e) {
let btn = e.querySelector('.family-btn');
let parent = btn.parentElement;
btn.addEventListener("click", function() {
parent.classList.toggle('on');
});
});
// Tooltip
$('body').tooltip({
selector: "[data-toggle='tooltip']",
items: ""
});
// Go button
$('.at-go .go-top').click(function() {
$('html, body').animate({ scrollTop: '0px' }, 500);
});
// Scroll add Class
var lastScroll = 0;
var scrolling;
window.addEventListener("scroll", function() {
let scrollTop = window.scrollY;
let document_h = document.innerHeight;
let window_h = window.innerHeight;
let scrollBottom = scrollTop + window_h;
// 스크롤 최상단보다 아래
if (scrollTop > 0) {
$body.classList.add('scrolled');
} else {
$body.classList.remove('scrolled');
}
// 스크롤 최하단보다 약간 위
if (scrollTop >= document_h - window_h - 150) {
$body.classList.add('scroll-bt-up');
} else {
$body.classList.remove('scroll-bt-up');
}
// 스크롤 최하단
if (document_h == scrollBottom) {
$body.classList.add('scroll-bt');
} else {
$body.classList.remove('scroll-bt');
}
// 스크롤 올릴때
if(scrollTop <= lastScroll) {
$body.classList.add('scroll-up');
} else {
$body.classList.remove('scroll-up');
}
if(scrollTop == 0) $body.classList.remove('scroll-up');
lastScroll = scrollTop;
// 스크롤중일때
$body.classList.add('scroll-ing');
clearTimeout(scrolling);
scrolling = setTimeout(() => {
scrolling = undefined;
if(scrolling == undefined) {
$body.classList.remove('scroll-ing');
}
}, 500);
});
// Tab
$('.tab-btn').each(function(){
tab($(this), 0);
function tab(e, num){
var num = num || 0;
var menu = $(e).children();
var con = $(e).siblings('.tab-con').children();
var select = $(menu).eq(num);
var i = num;
select.addClass('on');
con.eq(num).addClass('on');
menu.click(function(){
if(select!==null){
select.removeClass('on');
con.removeClass('on');
}
select = $(this);
i = $(this).index();
select.addClass('on');
con.eq(i).addClass('on');
var srcs = con.eq(i).find('.scr-el, .scr-el-one, .scrs');
srcs.each(function(index, el) {
$(el).removeClass('active');
setTimeout(function() {
if($(el).offset().top <= $(window).height() + $(window).scrollTop()) {
$(el).addClass('active');
}
}, 200);
$(el).css({'transition-delay': '', 'transition-duration': ''});
if($(el).hasClass('scrs')) {
$(el).find('.scr-delay').css({'transition-delay':'', 'transition-duration':''});
}
});
});
}
});
// Iframe
$(".smarteditor2").next("iframe").on("load", function() {
var $this = $(this);
var head = $this.contents().find("head");
var css = '