/* selectbox */ $(function(){ //$("select[id^=select_id]").selectbox(); if ( Modernizr.touch ) { $('.btnPrint, .btnUrl, .zclip').hide(); } GNB(); LNB(); mobileUI(); initMasonry(); initHover(); badook(); moviePop(); siteMap(); photoRuleShow(); shinTab(); // title setting 추가 20160920 if ($('#docTitle').size() > 0) { var docVal = $('#docTitle').text(); document.title = '농심 신라면 ' + docVal; } else { var titVal = $('#pageTitle').text(); document.title = '농심 신라면 ' + titVal; } }); /* GNB */ function GNB(){ $("#gnb>li>a").bind('click focus', function(){ var $this = $(this); if( $(window).width() > 1119 ){ gnbMotion($this); return false; }else{ if ($(this).siblings('ul').size() > 0) { $(this).siblings('ul').slideToggle().parent().siblings().children('ul').slideUp(); return false; } } }); $('#header a').blur(function() { if($(window).width() > 1119){ setTimeout(function(){ if( !$('#header a').is(':focus') ) { gnbReturn(); } },10); } }); $("#gnb>li>a").hover(function() { var $this = $(this); if($(window).width() > 1119){ gnbMotion($this); } },function() { //$(this).stop(); },300); $('#container, #visual').mouseover(function() { if($(window).width() > 990){ gnbReturn(); } }); /*$("#gnb>li>ul>li>a").click(function(){ if ($(this).parent().find('ul').size() > 0) { if( $(window).width() >= 768 && $(window).width() < 990 ){ $(this).siblings('ul').slideToggle().parent().toggleClass('on').siblings().removeClass('on').children('ul').slideUp(); return false; } } });*/ $(window).resize(function(){ gnbReturn(); $(".gnb_wrap").removeAttr('style'); $("#gnb>li>ul>li").removeClass('on'); $("#gnb>li>ul>li>ul").removeAttr('style'); }); }; function gnbMotion(tar){ $("#gnb>li>ul").removeAttr('style'); $(".headerSlide").slideDown(350,function(){ //tar.parent().children("ul").stop().fadeIn(); tar.parent().children("ul").css({'top':70}); tar.parent().children("ul.shin_depth").css({'top':90}); // 추가 20160816 }); } function gnbReturn(){ $("#gnb>li>ul").removeAttr('style'); $(".headerSlide").stop().slideUp(400); } /* LNB */ function LNB(){ var $lnb = $(".lnb"); var lnbLink = $('.lnb a'); var current = $.trim($('.locate strong').text()); if($lnb.size() > 0){ /* var setUrl = '/' + $.url().segment(1) + '/' + $.url().segment(2); $('.lnb li>a').each(function() { if($(this).attr('href') == setUrl) { // depth1 인경우 바로 활성화 if( $(this).closest('li').hasClass('dep1')){ $(this).closest('li').addClass('on'); }else{ $(this).closest('ul').slideToggle(); $(this).closest('li.dep1').addClass('on'); $(this).closest('li').addClass('on'); } } });*/ lnbLink.each(function() { //console.log($(this).text()); if ( $(this).text() == current ) { $(this).parent().addClass('on'); if ( $(this).parent().parent().hasClass('dep2')) { $(this).parents('.dep2').parent().addClass('on'); } } }); var $on = $lnb.find(">li.on"); var idx = $on.index(); $on.children("ul").hide().show(500); if($(window).width() < 769){ $('#menu nav').show().delay(1000).slideUp(500); } $('#menu h1').click(function(){ if($(window).width() < 769){ $(this).toggleClass('on').next().slideToggle(500); } }); $lnb.find(">li>a").click(function(){ if( $(this).siblings("ul").size() > 0 ){ if($(this).parent().hasClass('on') == false){ $(this).next('ul').slideToggle(500).parent().addClass("on").siblings("li").removeClass("on").children('ul').slideUp(500); } return false; } }); $('#menu').mouseleave(function(){ if($(window).width() > 990){ $('.lnb>li').removeClass('on').children('ul').slideUp(500); $('.lnb>li').eq(idx).addClass('on').children('ul').stop().slideDown(500); } }); $('.lnb').blur(function(){ if($(window).width() > 990){ $('.lnb>li').removeClass('on').children('ul').slideUp(500); $('.lnb>li').eq(idx).addClass('on').children('ul').stop().slideDown(500); } }); $(window).resize(function(){ $("aside .dep2").removeAttr('style'); $("aside nav").removeAttr('style'); $("aside h1").removeClass('on'); }); } } /* mobile 왼쪽 GNB(#navG) */ function mobileUI(){ var $open = false; $("#navG").bind("click", function(){ if($open == false){ $(this).parents(".gnb_wrap").stop().animate({"left":"0px"}, 600, 'easeOutExpo'); $open = true; }else{ $(this).parents(".gnb_wrap").stop().animate({"left":"-184px"}, 600, 'easeOutExpo'); $open = false; } return false; }); }; /* iframe width */ function badook(){ if($("#badook").size() > 0){ $(window).resize(function(){ if( $(window).width() >= 974 ){ variable(); } if( $(window).width() < 975 ){ $("#badook").css("width","100%"); } }); } }; function variable(){ var Conwidth = $("#container").width(); var LnbWidth = $("aside").width(); var IframeW = Conwidth - 174; $("#badook").css("width", IframeW); } /*이미지 갤러리 배치*/ function initMasonry(){ if($('.gallery').size() > 0){ if($('body').hasClass('main') == false){ $('.gallery>ul').masonry({ itemSelector : '.item', columnWidth: 150, isAnimated: true, animationOptions: {easing: 'easeOutSine'} }); } } } /*이미지 갤러리 Hover*/ function initHover(){ $('.gallery>ul>li').hover(function () { $(this).addClass('hover'); },function () { $(this).removeClass('hover'); } ); $('.gallery>ul>li>a').focus(function () { $(this).parent().addClass('hover').siblings().removeClass('hover'); }); } /* 동영상 레이어팝업 */ function moviePop(){ $('.playM').click(function(ev) { ev.preventDefault(); var _this =$(this); var vCont = _this.attr('href'); var $target = $(vCont); try{ if(eval($target.attr('id')+"(this)") == false){ return false; } }catch(e){ } $('
').insertBefore($(this)); $('header, .headerSlide, .btn').addClass('swapIndex'); $(".section3 .closeGroup").stop().css("opacity","1"); $('#bgLayer').fadeTo('fast', 0.6, function() { $(vCont).show(0,function() {}); $('.popClose').click(function() { $('iframe').attr('src', $('iframe').attr('src')); $('#bgLayer').remove(); $('header, .headerSlide, .btn').removeClass('swapIndex'); $(this).parents('.layerpop').hide(300); }); }); }); }; /* 사이트맵 */ function siteMap(){ $('.sitemap').click(function(ev) { ev.preventDefault(); //$("#content").hide(); $(".headerSlide").hide(); var _this =$(this); var vCont = _this.attr('href'); var $target = $(vCont); try{ if(eval($target.attr('id')+"(this)") == false){ return false; } }catch(e){ } $('
').insertBefore($(this)); //$('header, .headerSlide, .btn ,#content').addClass('swapIndex'); $('#bgLayer').fadeTo('fast', 0.6, function() { $target.show(0,function() {}); $('.popClose').click(function() { $("#content").show(); $('#bgLayer').remove(); //$('.headerSlide, .btn, #content').removeClass('swapIndex'); $target.hide(300); }); }); }); }; /* 포토제닉 선정방법 */ function photoRuleShow(){ $(".openMethod").hide(); $(".method").click(function(){ $(".openMethod").show(500); return false; }); $(".closeMethod").click(function(){ $(".openMethod").hide(500); return false; }); }; /* 신라면 포토제닉 탭 */ function shinTab(){ $(".genicTab li").click(function(){ $(".genicTab li a").removeClass("active"); $(this).find("a").addClass("active"); }); $(".genicTab li:first-child").click(function(){ $(".genic1").show(); $(".genic2").hide(); }); $(".genicTab li:last-child").click(function(){ $(".genic1").hide(); $(".genic2").show(); }); return false; };