/** * js/front.js */ $(document).ready(function() { setTimeout(function () { $("#visual").addClass("active"); $(".mainSect").addClass("active"); }); $('.btn_up_layer').click(function(){ $("html, body").animate({scrollTop:0}, 'slow'); return false; }); // 스크롤이 설정한 높이 이상 내려갔을때 스타일추가하기 if ($(window).width() > 0) { $(window).on("scroll",function(ev){ if($(window).scrollTop() > 50 ) { $('#header').addClass('bg_on'); $('.c--btn').addClass('active'); $('.btn_up_layer').addClass('active'); } else{ $('#header').removeClass('bg_on'); $('.c--btn').removeClass('active'); $('.btn_up_layer').removeClass('active'); } return false; }); } /* Toggle 모바일 동시 사용위해 클릭시 메뉴열리는 형태로 변경 */ $(".sMenu").click(function(){ $(this).children(".lnbSub").stop().slideToggle(300); if ($(this).css('backgroundImage').indexOf('up') != -1) { $('.bg').length > 0 ? $(this).css('backgroundImage', 'url(/images/layout/arrow_t_down.png)') : $(this).css('backgroundImage', 'url(/images/layout/arrow_t_down.png)') } else { $('.bg').length > 0 ? $(this).css('backgroundImage', 'url(/images/layout/arrow_t_up.png)') : $(this).css('backgroundImage', 'url(/images/layout/arrow_t_up.png)') } }); }); /* end */ $(function () { gnb(); classToggle(); fileUpload(); // fileupload $(this).find('.nice-select').niceSelect(); // selectbox scrollTopMov(); bodyScrollNone(); subMenuToggle(); main_grid(); accordion(); //checkbox All checked allChecker('.chk-all'); allChecker('.chk-all1'); allChecker('.chk-all2'); allChecker('.chk-all3'); }); //xscroll $(window).on('load', function(){ xScroll('.x-scroll'); kScroll('.k-scroll'); // scroll bar true }); // iscroll outerwidth function calcWidth(target) { var $target = $(target); $target.each(function(){ var child = $(this).children(), width = 0; child.each(function(){ width += $(this).outerWidth(true); }); $(this).css('width', width); }); } // iscroll function xScroll(obj) { var $obj = $(obj), tabs = $obj.find('.tabs'); if ( $(obj).length <= 0 ) { return } else { $(window).resize(function(){ calcWidth(tabs); }); calcWidth(tabs); new IScroll(obj , { scrollX : true, scrollY : false, mouseWheel : false, autoCenterScroll : true, bounce : true }); } } // iscroll function kScroll(obj) { var $obj = $(obj), tabs = $obj.find('.tabs'); if ( $(obj).length <= 0 ) { return } else { $(window).resize(function(){ calcWidth(tabs); }); calcWidth(tabs); new IScroll(obj , { scrollX : true, scrollY : false, mouseWheel : false, autoCenterScroll : true, bounce : true, scrollbars: true }); } } // file upload function fileUpload() { var obj = $('.inputfile-wrap'); if (obj.length <= 0) return; var fileTarget = obj.find('input[type=file]'); fileTarget.on('change', function(){ if (window.FileReader) { var filename = $(this)[0].files[0].name; } else { var filename = $(this).val().split('/').pop().split('\\').pop(); } $(this).siblings('input[type=text]').val(filename); }); } // class toggle function classToggle() { $('[data-toggle="class-toggle"]').find('button, a').click(function(){ var li = $(this).closest('li'); var lis = li.siblings('li'); var wraps = $(this).closest($('[data-toggle="class-toggle"]')); var toggleSelf = wraps.data('toggle-self'); var toggleClass = wraps.data('toggle-class'); var className = toggleClass === undefined ? 'active' : toggleClass; if (toggleSelf){ if (li.hasClass(className)){ li.removeClass(className); } else { lis.removeClass(className); li.addClass(className); } } else { lis.removeClass(className); li.addClass(className); } }); } // gnb pc nav function gnb() { $('#gnb #gnb1_ul').hover(function(){ $('#gnb').addClass('on'); $('.gnb2_ul').css('display','block'); //$('.header_mask').addClass('active'); setTimeout(function(){ $('.gnb2_ul').addClass('on'); },200); }, function(){ $('#gnb').removeClass('on'); $('.gnb2_ul').css('display','none'); $('.gnb2_ul').removeClass('on'); //$('.header_mask').removeClass('active'); }) // gnb pc nav End //gnb active //$("#gnb .gnb1_li").each(function(){ // if ($(this).children("a").text() == $(".location .depth_1").text() ){ //$(this).children("a").css("color","#f03844"); //$(this).children("a").css("border-bottom","1px solid #f03844"); // } //}); // GNB End } // accordion function accordion() { var wrap = $('.ui-accordion'), list = wrap.find('li'), title = wrap.find('.accord-title'), toggle = title.find('.btn-toggle'); if(wrap.length <= 0) return; // 접근성 대응 list.each(function(){ var $btn = $(this).find('.accord-title .btn-toggle'), $content = $(this).find('.accord-cont'), id = $(this).index(); $btn.attr({ 'id' : 'accord-toggle' + id, 'aria-controls' : 'accord-cont' + id }); $content.attr({ 'id' : 'accord-cont' + id, 'role' : 'region', 'aria-labelledby' : 'accord-toggle' + id }) }); toggle.click(function(){ var li = $(this).parent('.accord-title').parent('li'), cont = $(this).parent('.accord-title').siblings('.accord-cont'), blind = $(this).find('.blind'); if (li.hasClass('open')) { $(this).attr('aria-expanded', 'false'); cont.slideUp(); li.removeClass('open'); blind.text('상세보기'); } else { $(this).attr('aria-expanded', 'true'); cont.slideDown(); li.addClass('open'); blind.text('닫기'); } }); } // tab function uiTab() { var tab = '[data-evt="tab"]'; $(document).on('click', tab + ' a', function (e) { e.preventDefault(); var $this = $(this), id = $this.attr('href'), $target = $('[data-id=' + id + ']'), $siblings = $this.parents('li').siblings('').find('a'); $siblings.each(function () { var id = $(this).attr('href'); $(this).parents('li').removeClass('active'); $('[data-id=' + id + ']').hide(); }); $this.parents('li').addClass('active'); $target.show(); return false; }); if ( tab.length <= 0 ) return; $(tab).find('a').each(function(){ var tg = $(this).attr('href'); $('[data-id="'+tg+'"]').hide(); }); $(tab + ' > li:first-child a').click(); } // 모바일 바디 스크롤방지 - olibu function bodyScrollNone() { var posY; $(".mOpener").on("click", function(e){ posY = $(window).scrollTop(); $("html, body").addClass("not_scroll"); $(".mMenu").css("display","block"); //$(".cont").css("top",-posY); }); $(".closer").on("click", function(){ $("html, body").removeClass("not_scroll"); // $(".mMenu").css("display","none"); posY = $(window).scrollTop(posY); }); $(".mask").on("click", function(){ $("html, body").removeClass("not_scroll"); // $(".mMenu").css("display","none"); posY = $(window).scrollTop(posY); }); } // 스크롤 앵커이동 function scrollTopMov() { if (jQuery(window).width() > 1160) { $('a.ps').click(function(){ $('html, body').animate({ scrollTop: $( $.attr(this, 'href') ).offset().top - 60 }, 500); return false; }); } else{ $('a.ps').click(function(){ $('html, body').animate({ scrollTop: $( $.attr(this, 'href') ).offset().top - 60 }, 500); return false; }); } } /* Toggle */ function subMenuToggle() { $('.submenuM').on('click', function(){ $(this).siblings('.submenu_toggle').stop().slideToggle(); }) } function main_grid() { var $grid = $('.grid').imagesLoaded(function() { $('.gallery__wrapper').masonry({ itemSelector: '.grid' }); }); } // checkbox all check function allChecker(input) { var $input = $(input), name = $input.attr('name'); $input.on('change', function () { var $this = $(this); if ($this.prop("checked")) { $('input[name=' + name + ']').prop("checked", true); } else { $('input[name=' + name + ']').prop("checked", false); } }); $('input[name=' + name + ']').each(function () { var $this = $(this); $this.on('change', function () { var total = $('input[name=' + name + ']').length; var chked = $('input[name=' + name + ']:checked').not($input).length + 1; if (chked == total) { $input.prop("checked", true); } else { $input.prop("checked", false); } }); }); }