$(document).ready(function() { $(window).scroll(function() { if ($("#header").offset().top > 50) { $("#header").addClass("stk_mz"); $('#header').stop().animate({top : '-30px'}, 350, 'easeOutQuad'); $('#header .logo').stop().animate({marginTop : '10px'}, 350, 'easeOutQuad'); $('#header .global_nav').stop().animate({marginTop : '10px'}, 350, 'easeOutQuad'); $('#header #menu').stop().animate({marginTop : '8px'}, 350, 'easeOutQuad'); } else { $("#header").removeClass("stk_mz"); $('#header').stop().animate({top : '0px'}, 350, 'easeOutQuad'); $('#header .logo').stop().animate({marginTop : '0px'}, 350, 'easeOutQuad'); $('#header .global_nav').stop().animate({marginTop : '0px'}, 350, 'easeOutQuad'); $('#header #menu').stop().animate({marginTop : '0px'}, 350, 'easeOutQuad'); } }); }); $(function() { $.fn.goTop = function() { $(this).hide().removeAttr("href"); if ($(window).scrollTop() != "0") { $(this).stop().fadeIn(500); } var scrolling = $(this); $(window).scroll(function() { if ($(window).scrollTop() == "0") { $(scrolling).fadeOut(150) } else { $(scrolling).fadeIn(300) } }); $(this).click(function() { $("html, body").animate({ scrollTop: 0 }, "1000") }) } }); $(function() { $("#gotop").goTop(); } ); $('body').removeClass("over_height"); ;(function(window) { 'use strict'; var GNB = {}, FILE_NAME = 'M_debug.gnb.js', $ = window.jQuery || window.$ || null, _this = GNB; if( !window.M_debug ) { window.M_debug = {}; console.error( FILE_NAME + ' >> window.M_debug Not Found!!' ); }; window.M_debug.GNB = window.M_debug.GNB || GNB; GNB.$gnb = null; GNB.$dp1 = null; GNB.$dp2 = null; GNB.$dp2Conatiner = null; GNB.$gnbM = null; GNB.$gnbMopen = null; GNB.$gnbMclose = null; GNB.$gnbMaskclose = null; GNB.$gnbMdp1 = null; GNB.$share = null; GNB._isFirst = true; GNB._isOver = false; GNB._timeOutId = null; GNB._duration = 500; GNB._aniDuration = 200; GNB._idxDp1 = null; GNB._idxDp2 = null; var MOBILE_WIDTH = 1000; var Util = { getPageLocation : function( url ) { DEBUG.log( FILE_NAME + ' > Util > getPageLocation > url : ' + url ); DEBUG.log( FILE_NAME + ' > Util > getPageLocation > host : ' + location.host + ' , href : ' + location.href ); if( url ) { return Fishingtree.location.getPageLocation( url ); }; return location.href.split( location.host )[ 1 ]; } }; GNB.setEvents = function() { this.$dp1.mouseover(function(event) { event.preventDefault(); var idx = $(this).index(), gnbIdx = $(this).data( 'gnb' ); _this._isOver = true; _this.$dp1.removeClass( 'on' ); $(this).addClass( 'on' ); _this.$dp2.find( 'li' ).removeClass( 'on' ); var $target = _this.$dp2Conatiner.children( 'ul[data-gnb="' + gnbIdx + '"]' ); if( $target.length ) { var pos = $target.data( 'pos' ); if( $( window ).width() >= MOBILE_WIDTH ) { _this.$dp2Conatiner.slideDown(); _this.$dp2Conatiner.children( 'ul' ).show(); }; _this.$dp2Conatiner.children( 'ul' ).eq( 0 ).stop().animate( { 'margin-top' : pos }, _this._aniDuration, function() { }); } else { _this.$dp2Conatiner.slideUp(); _this.$dp2Conatiner.children( 'ul' ).hide(); }; }); this.$dp1.mouseleave(function(event) { event.preventDefault(); var idx = $(this).index(); _this._isOver = false; clearTimeout( _this._timeOutId ); _this._timeOutId = setTimeout( _this.setPageLocation, _this._duration ); }); this.$dp1.click(function(event) { var idx = $(this).index(), gnbIdx = $(this).data( 'gnb' ); var $target = _this.$dp2Conatiner.children( 'ul[data-gnb="' + gnbIdx + '"]' ); if( !$target.length ) { DEBUG.log( FILE_NAME + ' > Gnb > setEvents > 1µª½º ¸Þ´º Ŭ¸¯ : 2µª½º ¸Þ´º°¡ ¾ø´Â °æ¿ì href °ªÀ¸·Î À̵¿' ); } else { if( $(this).children( 'a' ).attr( 'href' ) == '#' ) { event.preventDefault(); DEBUG.log( FILE_NAME + ' > Gnb > setEvents > 1µª½º ¸Þ´º Ŭ¸¯ : href °ªÀÌ "#" ÀÏ °æ¿ì preventDefault' ); } } }); this.$dp2.find( 'li' ).mouseover(function(event) { event.preventDefault(); _this._isOver = true; $(this).siblings( 'li' ).removeClass( 'on' ); $(this).addClass( 'on' ); }); this.$dp2.find( 'li' ).mouseleave(function(event) { event.preventDefault(); _this._isOver = false; clearTimeout( _this._timeOutId ); _this._timeOutId = setTimeout( _this.setPageLocation, _this._duration ); }); this.$gnbMopen.click(function(event) { event.preventDefault(); _this.$gnbM.css( { 'left' : '-100%' }); _this.$gnbM.show(); _this.$gnbM.animate( { 'left' : 0 }, _this._aniDuration, function() { }); $('body').addClass("over_height"); $(".bg_mask").css({"height":"200%"}).fadeIn(200); }); this.$gnbMclose.click(function(event) { event.preventDefault(); _this.$gnbM.animate( { 'left' : '-100%' }, _this._aniDuration, function() { _this.$gnbM.hide(); _this.$gnbM.css( { 'left' : 0 }); }); $('body').removeClass("over_height"); $(".bg_mask").fadeOut(100); }); this.$gnbMaskclose.click(function(event) { event.preventDefault(); _this.$gnbM.animate( { 'left' : '-100%' }, _this._aniDuration, function() { _this.$gnbM.hide(); _this.$gnbM.css( { 'left' : 0 }); }); $('body').removeClass("over_height"); $(".bg_mask").fadeOut(100); }); this.$gnbMdp1.click(function(event) { var $li = $(this).closest( 'li' ), $mdp2 = $li.find( 'ul > li' ); $li.siblings( 'li' ).children( 'ul' ).slideUp(); $li.children( 'ul' ).slideDown(); if( !$mdp2.length ) { DEBUG.log( FILE_NAME + ' > Gnb > setEvents > Mobile 1µª½º ¸Þ´º : 2µª½º ¸Þ´º°¡ ¾ø´Â °æ¿ì href °ªÀ¸·Î À̵¿' ); } else { if( $(this).children( 'a' ).attr( 'href' ) == '#' ) { event.preventDefault(); DEBUG.log( FILE_NAME + ' > Gnb > setEvents > Mobile 1µª½º ¸Þ´º : 1µª½ºÀÇ href °ªÀÌ "#" ÀÏ °æ¿ì preventDefault' ); } } }); }; GNB.setPageLocation = function() { var page = Util.getPageLocation(), $target = null; DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > ¸Þ´º È°¼ºÈ­¸¦ À§ÇÑ ±âÁØ Page °ª : ' + page ); $.each(_this.$dp2.find( 'li' ), function(index, val) { var $ul = $(this).closest( 'ul' ), href = $(this).children( 'a' ).attr( 'href' ); if( href.indexOf( page, 0 ) > -1 ) { _this._idxDp2 = $(this).index(); _this._idxDp1 = $ul.data( 'gnb' ); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > 2µª½º ¸Þ´º °ª ±âÁØ Ã¼Å© idx : ' + _this._idxDp1 + ' / ' + _this._idxDp2 ); return; }; }); $.each(_this.$dp1, function(index, val) { var href = $(this).children( 'a' ).attr( 'href' ); if( href.indexOf( page, 0 ) > -1 ) { _this._idxDp1 = $(this).data( 'gnb' ); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > 1µª½º ¸Þ´º °ª ±âÁØ Ã¼Å© idx : ' + _this._idxDp1 ); return; }; }); if( _this._isOver ) { return; }; $target = _this.$dp1.filter('[data-gnb="' + _this._idxDp1 + '"]'); if( _this._idxDp1 != null && $target.length ) { $target.trigger( 'mouseover' ); $target.addClass( 'on' ); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > 1µª½º ¸Þ´º È°¼ºÈ­ : ' , $target ); } else { _this.$dp1.removeClass( 'on' ); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > 1µª½º ¸Þ´º ºñÈ°¼ºÈ­' ); }; $target = _this.$dp2.filter('[data-gnb="' + _this._idxDp1 + '"]'); if( _this._idxDp2 != null && $target.length ) { $target = $target.children( 'li' ).eq( _this._idxDp2 ); $target.trigger( 'mouseover' ); $target.addClass( 'on' ); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > 2µª½º ¸Þ´º È°¼ºÈ­ : ' , $target ); } else { _this.$dp2.find( 'li' ).removeClass( 'on' ); _this.$dp2Conatiner.slideUp(); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > 2µª½º ¸Þ´º ºñÈ°¼ºÈ­' ); }; // Gnb - Mobile - 1µª½º ¸Þ´º È°¼ºÈ­ if( _this._idxDp1 != null && _this.$gnbMdp1.eq( _this._idxDp1 ).length ) { $target = _this.$gnbMdp1.eq( _this._idxDp1 ); $target.trigger( 'click' ); $target.closest( 'li' ).addClass( 'on' ); DEBUG.log( FILE_NAME + ' > Gnb > setPageLocation > ¸ð¹ÙÀÏ 1µª½º ¸Þ´º È°¼ºÈ­ : ' , $target ); // Gnb - Mobile - 2µª½º ¸Þ´º È°¼ºÈ­ var $mdp2 = $target.closest( 'li' ).find( 'ul > li' ); $mdp2.eq( _this._idxDp2 ).addClass( 'on' ); }; }; GNB.resize = function() { var winWidth = $( window ).width(); //console.log(this._idxDp2) if( winWidth <= MOBILE_WIDTH ) { DEBUG.log( FILE_NAME + ' > GNB.resize Mobile' ); if( this._idxDp1 == 1 || this._idxDp1 == 2 || this._idxDp1 == 3 || this._idxDp1 == 4 ) { this.$dp2Conatiner.hide(); } this.$gnb.children( 'div.top' ).find( '*[data-view="share"]' ).hide(); } else { DEBUG.log( FILE_NAME + ' > GNB.resize Wide' ); this.$gnbM.hide(); if( this._idxDp1 == 1 || this._idxDp1 == 2 || this._idxDp1 == 3 || this._idxDp1 == 4 ) { this.$dp2Conatiner.show(); } } }; GNB.init = function() { this.$gnb = $( '.gnb' ); this.$dp1 = this.$gnb.children( 'div.dp1' ).find( 'li' ); this.$dp2Conatiner = this.$gnb.children( 'div.dp2' ); this.$dp2 = this.$gnb.children( 'div.dp2' ).find( 'ul' ); this.$gnbM = this.$gnb.children( 'div.mz_menu' ); this.$gnbMopen = this.$gnb.find( 'div.top > a.menu' ); this.$gnbMclose = this.$gnbM.children( 'a.close' ); this.$gnbMaskclose = $( '.bg_mask' ); this.$gnbMdp1 = this.$gnbM.find( 'ul > li > span' ); this.setEvents(); this.setPageLocation(); this.setShareEvents(); this.resize(); $( window ).resize(function(event) { _this.resize(); }); }; $(document).ready(function() { GNB.init(); }); }(window));