/* * by @psyonline ( http://www.psyonline.kr/, majorartist@gmail.com ) */ 'use strict'; (function() { var $html = document.documentElement, $body = document.body, $scroller = document.querySelector('.scroller'), $header = document.querySelector('.header'), $navbox = document.querySelector('nav.navigation'), $footer = document.querySelector('.footer'), ismobile = (/(ip(ad|hone|od)|android)/i).test(navigator.userAgent), isie = (/(?:msie ([0-9]+)|rv:([0-9\.]+)\) like gecko)/i).test(navigator.userAgent), areawidth = window.innerWidth, areaheight = window.innerHeight, maxareaheight = areaheight, listeners = { mediachange: [], resize: [], scroll: [], wheel: [], bodyclick: [] }, currentmedia = '', headerreduced = false, wheeler = wheeler(), notransitionclassname = 'no-transition'; $html.classList.add(!ismobile ? 'hoverable' : 'touchable'); isie && $html.classList.add('ie'); window.addEventListener('resize', onresize); /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@¹è°æ»ö¿¡ µû¶ó ·Î°í»ö»ó ´Þ¸®Çϱâ À§ÇÑ Å×½ºÆ® ¼Ò½º ½ÃÀÛ */ window.addEventListener("scroll", function() { var header = document.querySelector(".header"); if (!header) return; var headerRect = header.getBoundingClientRect(); var headerHeight = headerRect.height; // ÇöÀç ·Î°í À§Ä¡ÀÇ ¹è°æ»öÀ» ºÐ¼® var backgroundColor = window.getComputedStyle(document.elementFromPoint(headerRect.left + headerRect.width / 2, headerRect.top + headerHeight / 2)).backgroundColor; // ¹è°æ»öÀÌ ¹àÀºÁö ¾îµÎ¿îÁö ÆÇ´Ü var rgb = backgroundColor.match(/\d+/g); if (rgb) { var brightness = (parseInt(rgb[0]) * 299 + parseInt(rgb[1]) * 587 + parseInt(rgb[2]) * 114) / 1000; if (brightness > 127) { // ¹àÀº ¹è°æÀÏ ¶§ document.querySelectorAll('.light-logo').forEach(function(logo) { logo.style.display = 'block'; }); document.querySelectorAll('.dark-logo').forEach(function(logo) { logo.style.display = 'none'; }); } else { // ¾îµÎ¿î ¹è°æÀÏ ¶§ document.querySelectorAll('.light-logo').forEach(function(logo) { logo.style.display = 'none'; }); document.querySelectorAll('.dark-logo').forEach(function(logo) { logo.style.display = 'block'; }); } } }); /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@¹è°æ»ö¿¡ µû¶ó ·Î°í»ö»ó ´Þ¸®Çϱâ À§ÇÑ Å×½ºÆ® ¼Ò½º ³¡ */ // page control var page = (function() { var $cover = createnode('div', 'page-cover'), $pagetitle = $header.querySelector('h2') || createnode('h2', '', '', $header), laststate, backstate, urlto; //createnode('header', 'header', '

'+ document.querySelector('h1 a').innerHTML, $cover); $cover.addEventListener('touchstart', preventdefault, false); $body.addEventListener('click', function(e) { listeners.bodyclick.forEach(function(handler) { handler(e); }); linkclick(e); }, false); // if ('scrollRestoration' in history) { history.scrollRestoration = 'manual'; // } document.addEventListener('scroll', preventdefault); window.addEventListener('popstate', poped); requestAnimationFrame(function() { setview($body.classList.contains('type-view')); initialize(true); }); Pace.on('done', oninitialize); function linkclick(e) { var target = e.target; while (target !== $body) { if (target.nodeName.toLowerCase() === 'a') { if (target.target !== '_blank') { go(target.getAttribute('href')); e.preventDefault(); } break; } target = target.parentNode; } } /*function go(url) { scroller.disabled = true; urlto = url; history.pushState({scrollyfrom: getscrolltop(), index: ++laststate.index}, '', url); cover(); }*/ function poped(e) { scroller.disabled = true; urlto = location.href.split('//gxlab.co.kr')[1] || location.pathname; cover(); } function back() { history.back(); } function cover() { wheeler.blocked = true; $body.appendChild($cover); $cover.style.opacity = 0; TweenMax.to($cover, 0.35, {opacity: 1, ease: Quad.easeOut, onComplete: clear}); } function clear() { nav.close(true); $html.classList.remove('displayed'); [].slice.call($scroller.children).forEach(function($child) { if (!(/(footer|script)/i).test($child.nodeName)) { removenode($child, true); } }); removenode(document.querySelector('.visual-full'), true); for (var name in listeners) { listeners[name].length = 0; } currentmedia = ''; page.initialized = false; load(); } function load() { Pace.restart(); Pace.track(function() { ajax(urlto, {onsuccess: onload}); }); } function onload(response) { var pagetitle = response.match(/class="header[\s\S]+h2>(.+)<\/h2/); if (pagetitle) { pagetitle = pagetitle[1]; // $pagetitle.classList[pagetitle === $pagetitle.innerHTML ? 'add' : 'remove']('fix'); $pagetitle.innerHTML = pagetitle; $header.appendChild($pagetitle); } else { removenode($pagetitle); } [].slice.call(createnode('div', '', response.match(/scroller[^"]*">([\s\S]+)