/* * 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); // 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]+)