; (function() { 'use strict'; // iPad and iPod detection var isiPad = function() { return (navigator.platform.indexOf("iPad") != -1); }; var isiPhone = function() { return ( (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) ); }; // Main Menu Superfish var mainMenu = function() { $('#wz08g-primary-menu').superfish({ delay: 0, animation: { opacity: 'show' }, speed: 'fast', cssArrows: true, disableHI: true }); }; // Parallax var parallax = function() { $(window).stellar(); }; // Offcanvas and cloning of the main menu var offcanvas = function() { var $clone = $('#wz08g-menu-wrap').clone(); $clone.attr({ 'id': 'offcanvas-menu' }); $clone.find('> ul').attr({ 'class': '', 'id': '' }); $('#wz08g-page').prepend($clone); // click the burger $('.js-wz08g-nav-toggle').on('click', function() { if ($('body').hasClass('wz08g-offcanvas')) { $('body').removeClass('wz08g-offcanvas'); } else { $('body').addClass('wz08g-offcanvas'); } }); $('#offcanvas-menu').css('height', $(window).height()); $(window).resize(function() { var w = $(window); $('#offcanvas-menu').css('height', w.height()); if (w.width() > 769) { if ($('body').hasClass('wz08g-offcanvas')) { $('body').removeClass('wz08g-offcanvas'); } } }); } // Click outside of the Mobile Menu var mobileMenuOutsideClick = function() { $(document).click(function(e) { var container = $("#offcanvas-menu, .js-wz08g-nav-toggle"); if (!container.is(e.target) && container.has(e.target).length === 0) { if ($('body').hasClass('wz08g-offcanvas')) { $('body').removeClass('wz08g-offcanvas'); } } }); }; // Animations var contentWayPoint = function() { var i = 0; $('.animate-box').waypoint(function(direction) { if (direction === 'down' && !$(this.element).hasClass('animated')) { i++; $(this.element).addClass('item-animate'); setTimeout(function() { $('body .animate-box.item-animate').each(function(k) { var el = $(this); setTimeout(function() { el.addClass('fadeInUp animated'); el.removeClass('item-animate'); }, k * 50, 'easeInOutExpo'); }); }, 100); } }, { offset: '85%' }); }; var stickyBanner = function() { var $stickyElement = $('.sticky-banner'); var sticky; if ($stickyElement.length) { sticky = new Waypoint.Sticky({ element: $stickyElement[0], offset: 0 }) } }; var goToTop = function() { $('.js-gotop').on('click', function(event) { event.preventDefault(); $('html, body').animate({ scrollTop: $('html').offset().top }, 500, 'easeInOutExpo'); return false; }); $(window).scroll(function() { var $win = $(window); if ($win.scrollTop() > 200) { $('.js-top').addClass('active'); } else { $('.js-top').removeClass('active'); } }); }; // Loading page var loaderPage = function() { $(".wz08g-loader").fadeOut("slow"); }; var sliderMain = function() { $('#cover-slider .flexslider').flexslider({ animation: "fade", slideshowSpeed: 5000, directionNav: true, start: function() { setTimeout(function() { $('.slider-text').removeClass('animated fadeInUp'); $('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp'); }, 500); }, before: function() { setTimeout(function() { $('.slider-text').removeClass('animated fadeInUp'); $('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp'); }, 500); } }); }; var tabs = function() { // Auto adjust height $('.gtco-tab-content-wrap').css('height', 0); var autoHeight = function() { setTimeout(function() { var tabContentWrap = $('.gtco-tab-content-wrap'), tabHeight = $('.gtco-tab-nav').outerHeight(), formActiveHeight = $('.tab-content.active').outerHeight(), totalHeight = parseInt(tabHeight + formActiveHeight + 90); tabContentWrap.css('height', totalHeight); $(window).resize(function() { var tabContentWrap = $('.gtco-tab-content-wrap'), tabHeight = $('.gtco-tab-nav').outerHeight(), formActiveHeight = $('.tab-content.active').outerHeight(), totalHeight = parseInt(tabHeight + formActiveHeight + 90); tabContentWrap.css('height', totalHeight); }); }, 100); }; autoHeight(); // Click tab menu $('.gtco-tab-nav a').on('click', function(event) { var $this = $(this), tab = $this.data('tab'); $('.tab-content') .addClass('animated-fast fadeOutDown'); $('.tab-content') .removeClass('active'); $('.gtco-tab-nav li').removeClass('active'); $this .closest('li') .addClass('active') $this .closest('.gtco-tabs') .find('.tab-content[data-tab-content="' + tab + '"]') .removeClass('animated-fast fadeOutDown') .addClass('animated-fast active fadeIn'); autoHeight(); event.preventDefault(); }); }; // Document on load. $(function() { mainMenu(); parallax(); offcanvas(); mobileMenuOutsideClick(); contentWayPoint(); stickyBanner(); goToTop(); loaderPage(); sliderMain(); //tabs(); }); $.fn.skipLayerPop = function(options) { options = $.extend({ skipDay: 1, keepDay: 'always', }, options); return this.each(function() { // 대상 참조 var $thisLayer = $(this), $layerId = $(this).attr('id'), $btn_popClose = $(this).find('.btn-close'), $skipCkbox = $(this).find('.skip-check'), cookiedata = document.cookie, fulldate = new Date(), nowYear = fulldate.getFullYear(), nowMonth = fulldate.getMonth() + 1, nowDate = fulldate.getDate(), nowHours = fulldate.getHours(), nowMinute = fulldate.getMinutes(); // nowMonth, nowDate, nowHours, nowMinute 두자리수로 변경 if (nowMonth <= 9) nowMonth = 0 + '' + nowMonth; if (nowDate <= 9) nowDate = 0 + '' + nowDate; if (nowHours <= 9) nowHours = 0 + '' + nowHours; if (nowMinute <= 9) nowMinute = 0 + '' + nowMinute; // 현재 년월일시분 var timeChk = Number(nowYear + '' + nowMonth + '' + nowDate + '' + nowHours + '' + nowMinute); if (options.keepDay === 'always') { skipLayer(); } else if (typeof(options.keepDay) === 'number') { if (timeChk <= options.keepDay) { skipLayer(); } else if (timeChk > options.keepDay) { $thisLayer.hide(); }; }; // 쿠키 확인후 창띄우기 & 닫기 function skipLayer() { if (cookiedata.indexOf($layerId + "=done") < 0) { $thisLayer.show(); $btn_popClose.on('click', function() { if ($skipCkbox.prop('checked')) { setCookie($layerId, "done", options.skipDay); $thisLayer.hide(); } else { $thisLayer.hide(); } }); } else { $thisLayer.hide(); } }; // 쿠키 설정 function setCookie(cookieName, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var cookieValue = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toGMTString()); document.cookie = cookieName + "=" + cookieValue; }; }); }; $('#layerPopup01').skipLayerPop({ skipDay: 1, }); $('#layerPopup02').skipLayerPop({ skipDay: 1, }); $('#layerPopup03').skipLayerPop({ skipDay: 1, }); }());