$(document).ready(function () { $(window).scroll(function() { var sclTop = $(this).scrollTop(); if (sclTop > 10) { $('#header').addClass('changed'); } else {$('#header').removeClass('changed');} }); }) $(document).ready(function () { var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf('safari') != -1) { if (ua.indexOf('chrome') > -1) { // Chrome $("body").addClass("chrome") } else { // Safari $("body").addClass("safari") } } var header = $("header"), langButton = $(".langBox"), menuOpen = $(".menuOpen"), menuClose = $(".menuClose"), allMenu = $(".allMenu"), snb = $("#snb"), animation = $(".animation"), address = $(".address"); $(window).on("load scroll", function () { var scrollTop = $(this).scrollTop(); animation.each(function () { var animationTop = $(this).offset().top; if (scrollTop >= animationTop - 600) { $(this).addClass("on"); } }) }); animation.each(function () { var delay = $(this).data("delay"); $(this).css({ "transition-delay": delay }) }); // snb header.find("#gnb > li").clone().appendTo($("#snb, #fnb")); snb.children("li").each(function () { $(this).find(".depth2").appendTo($(this)); }); // language langButton.on("click", function () { $(this).toggleClass("on"); $(this).find("ul").stop().slideToggle(); }); // menu menuOpen.on("click", function () { header.addClass("menuOn"); allMenu.stop().fadeIn(); allMenu.addClass("on"); }) menuClose.on("click", function () { header.removeClass("menuOn"); allMenu.stop().fadeOut(); allMenu.removeClass("on"); }) // desktop function initEvent_pc(val) { console.log(val); header.find(".depth1 > li").on("mouseenter mouseleave", function (e) { var type = e.type, depth2 = $(this).find(".depth2"); if (type == "mouseenter") { $(this).addClass("white"); depth2.addClass("on"); } else if (type == "mouseleave") { $(this).removeClass("white"); depth2.removeClass("on"); } }); }; // mobile function initEvent_m(val) { console.log(val); }; function hdlr_switch(val) { if (val > 1200) { initEvent_pc(val); } else { initEvent_m(val); }; }; $(window).on("load resize", function () { var doc_width = $(window).width(); hdlr_switch(doc_width); if (doc_width > 961) { snb.children("li").find("img").remove(); } else { snb.children("li").children("a").off(); snb.children("li").children("a").on("click", function (e) { var depth2 = $(this).siblings(".depth2"); if (depth2.length) { e.preventDefault(); depth2.stop().slideToggle(); $("#snb > li > a").not(this).siblings("ul").stop().slideUp(); $(this).closest("li").toggleClass("on") snb.children("li").children("a").not(this).closest("li").removeClass("on"); } }); snb.children("li").each(function () { var arrow = $(""); if(!$(this).children("a").find("img").length) { arrow.appendTo($(this).children("a")); } }) } }); });