/* common.js 파일 */ let navScrollers; let gJJY_SLIDER_VIEWPORT = 0; let gJJY_SLIDER_LEFT = 0; let gJJY_SLIDER_PREV = 0; let gJJY_SLIDER_NEXT = 0; $(document).ready(function(){ $('#main-menu').smartmenus( {subMenusMaxWidth: "100%"} ); $('.flexslider').flexslider({ animation: "slide", start: function(slider){ //$('body').removeClass('loading'); } }); calc_jts_viewport_width(); $("#jjy-tag-slider > div.jts-common > span.slide-prev").on("mousedown touchstart", function(event){ gJJY_SLIDER_PREV = setInterval(move_left_jts_viewport, 1); }).on("mouseup mouseout touchend", function(event){ clearInterval(gJJY_SLIDER_PREV); }); $("#jjy-tag-slider > div.jts-common > span.slide-next").on("mousedown touchstart", function(event){ gJJY_SLIDER_NEXT = setInterval(move_right_jts_viewport, 1); }).on("mouseup mouseout touchend", function(event){ clearInterval(gJJY_SLIDER_NEXT); }); $("div.jjy-tag-slider > div.jts-viewport").swipe({ //Generic swipe handler for all directions swipeLeft:function(event, direction, distance, duration, fingerCount, fingerData) { console.log("swipeLeft:dir="+direction+",dis="+distance); }, swipeRight:function(event, direction, distance, duration, fingerCount, fingerData) { console.log("swipeRight:dir="+direction+",dis="+distance); }, excludedElements: "button, input, select, textarea" // Here your list of excluded elements ... }); $(window).on("resize", function(event){ let gWindowWidth = $(this).width(); let gViewportWidth = $(".jjy-header-top").width(); let gViewportLeft = 0; let gSearchboxLeft = 0; let gMenuWidth = 0; let gLogoWidth = $(".nav-brand").outerWidth(); let gCurtainWidth = $("div.jjy-menu-curtain").width(); let gCurtainMenuWidth = 0; let gMainImageRatio = 334.0 / 1260.0; let gMainSlideHeight = 334; //console.log("gViewportWidth="+gViewportWidth); gMenuWidth = gViewportWidth - gLogoWidth; $("#jjy-main-menu-layer").css("width", gMenuWidth+"px"); if (gViewportWidth >= 1260){ gViewportLeft = (gWindowWidth - gViewportWidth) / 2; gSearchboxLeft = (gWindowWidth - gViewportWidth) / 2; gMainSlideHeight = 334; } else if ((gViewportWidth < 1260) && (gViewportWidth >= 1000)){ gMainSlideHeight = gMainImageRatio * gViewportWidth; } else { gMainSlideHeight = gMainImageRatio * gViewportWidth; } $("#jjy-main-menu-layer").css("left", gViewportLeft+"px"); $("#jjy-main-menu-layer").css("padding-left", gLogoWidth+"px"); $(".jjy-detail-search").css("width", gViewportWidth+"px"); $(".jjy-detail-search").css("left", gViewportLeft+"px"); // 1260 ~ 1000; // $("#jjy-main-menu-layer"). gCurtainMenuWidth = gViewportWidth - gLogoWidth; $("div.jjy-menu-curtain > div:first-child").width(gLogoWidth); $("div.jjy-menu-curtain > div:last-child").width(gCurtainMenuWidth); $("div.main-slider").css("width", gViewportWidth+"px").css("height", gMainSlideHeight + "px"); $("ul.jjy-main-menu > li").each(function(index, item){ var nLeftOfThis = $(this).offset().left; var nWidth = $(this).width(); var nOffsetLeft = $(this).children("a").offset().left; var nLeftMostOffset = $("ul.jjy-main-menu").offset().left; var nLeft = (nOffsetLeft - nLeftOfThis) / 2; //nWidth = nWidth - nLeft; $('div.jjy-menu-curtain > div:last-child > div:eq('+index+')').css("margin-left", nLeft+"px").css("width", (nWidth - nLeft)+"px"); }); }); $(window).trigger("resize"); $("ul.jjy-main-menu").on("mouseover", function(event){ $("div.jjy-menu-curtain").stop().slideDown('fast'); }); $("ul.jjy-main-menu").on("mouseout", function(event){ $("div.jjy-menu-curtain").stop().slideUp('fast'); }); $("ul.jjy-main-menu > li").on("mouseover", function(event){ var n = $(this).index(); var nWidth = $(this).width(); var nOffsetLeft = $(this).children("a").offset().left; var nLeftMostOffset = $("ul.jjy-main-menu").offset().left; var nLeft = nOffsetLeft - nLeftMostOffset + 295; $('.jjy-main-menu .img_chk').eq(n).css('display','block').css("left", nLeft+"px"); }); $("ul.jjy-main-menu > li").on("mouseout", function(event){ $('.jjy-main-menu .img_chk').css('display','none'); }); $("div.jjy-menu-curtain").on("mouseover", function(event){ $("div.jjy-menu-curtain").stop().slideDown('fast'); }); $("div.jjy-menu-curtain").on("mouseout", function(event){ $("div.jjy-menu-curtain").stop().slideUp('fast'); }); $("#user-info").on("click", function(event){ $(".jjy-user-info-popup").toggleClass('hide'); }); $('body').on('click', function(e){ var $tgPoint = $(e.target); var $popCallBtn = $tgPoint.hasClass('user-info') var $popArea = $tgPoint.hasClass('jjy-user-info-popup') if ( !$popCallBtn && !$popArea ) { $('.jjy-user-info-popup').addClass('hide'); } }); $("#user-info-m").on("click", function(event){ $(".jjy-user-info-popup-m").toggleClass('hide'); }); $('body').on('click', function(e){ var $tgPoint = $(e.target); var $popCallBtn = $tgPoint.hasClass('user-info-m') var $popArea = $tgPoint.hasClass('jjy-user-info-popup-m') if ( !$popCallBtn && !$popArea ) { $('.jjy-user-info-popup-m').addClass('hide'); } }); setTimeout(window_resize, 500); }); function window_resize(){ $(window).trigger("resize"); } function calc_jts_viewport_width(){ $("#jjy-tag-slider > div.jts-viewport > ul > li").each(function(index, item){ gJJY_SLIDER_VIEWPORT += $(this).outerWidth(true); }); $("#jjy-tag-slider > div.jts-viewport > ul").css("width", gJJY_SLIDER_VIEWPORT+"px"); } function move_left_jts_viewport(){ gJJY_SLIDER_LEFT = parseInt($("#jjy-tag-slider > div.jts-viewport > ul").css("left")); let nOffset = parseInt($("#jjy-tag-slider > div.jts-viewport").width() - $("#jjy-tag-slider > div.jts-viewport > ul").width()); gJJY_SLIDER_LEFT -= 1; if (gJJY_SLIDER_LEFT > nOffset){ $("#jjy-tag-slider > div.jts-viewport > ul").css("left", gJJY_SLIDER_LEFT+"px"); } } function move_right_jts_viewport(){ gJJY_SLIDER_LEFT = parseInt($("#jjy-tag-slider > div.jts-viewport > ul").css("left")); let nOffset = $("#jjy-tag-slider > div.jts-viewport").width() - $("#jjy-tag-slider > div.jts-viewport > ul").width(); gJJY_SLIDER_LEFT += 1; if (gJJY_SLIDER_LEFT <= 0){ $("#jjy-tag-slider > div.jts-viewport > ul").css("left", gJJY_SLIDER_LEFT+"px"); } } number_format = function(pNumber){ let nNumber = parseInt(pNumber); return nNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); } float_format = function(pNumber){ let nNumber = parseFloat(pNumber); return nNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); }