// // I.N.UIX Global UI // // 리사이즈 감지 var term = 0, timer = null; $(window).on('load resize', function () { clearTimeout(timer); timer = setTimeout(_modeDetect, term); term = 300; }); var _mode; function _modeDetect() { var widthScreen = $(window).width(); var beforeMode = _mode; if (widthScreen > 1024) { _mode = 'pc'; } else if (widthScreen >= 768) { _mode = 'tablet'; } else { _mode = 'mobile'; } } //초기 디바이스 확인용 함수 실행 _modeDetect(); // 탭메뉴 $(document).ready(function () { $('.tab-list .on a').each(function () { var tg = $(this).attr('href'); if (tg !== '#' && tg !== '#;' && tg.charAt(0) === '#') { $(tg + '.tab-content').css('display', 'block'); } }); $('.tab-list a').on('click', function (e) { var tg = $(this).attr('href'); if (!$(this).closest('.tab-menu').hasClass('tab-not-active')) { $(this).parent('li').addClass('on').siblings('li').removeClass('on'); } if (tg === '#' || tg === '' || tg === '#;') { e.preventDefault(); } else if (tg.charAt(0) === '#') { if ($(tg).hasClass('tab-content')) { $(tg).show().siblings('.tab-content').hide(); e.preventDefault(); } else { console.log('콘텐츠가 없습니다.'); } } }); }); // URL 해시 탭 활성화 $(window).on('load', function () { var tab = $('.tab-menu1 a[href="' + location.hash + '"]'); // setTimeout(function () {}, 100); if (tab.length > 0) { $('body, html').animate({ scrollTop: 0 }, 0); } }).on('load hashchange', function () { $('.tab-menu1 a[href="' + location.hash + '"]').click(); }); // 게시판 등록 : 파일첨부 $(function () { var fileTarget = $('.form-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).next('.file-name').val(filename); }); $('.file-attatch-item .file-name').on('click', function () { $(this).prev('.form-file').click(); }); }); // 데이트피커 setTimeout(function () { $('.form-datepicker').each(function () { setDatepicker($(this)); }).on('click', function () { openCalendar($(this)); }); }, 200); function removeDatepicker() { if ($('#inseq-datepicker').length > 0) { $('#inseq-datepicker').remove(); } } $(document).on('click', '.btn-datepicker', function (e) { e.preventDefault(); openCalendar($(this).prev()); }); function setDatepicker(obj) { $(obj).wrap(''); if ($(obj).hasClass('full')) { $(obj).parent('.datepicker').addClass('full'); } $(obj).after(''); } // 체크박스 전체선택 $(document).ready(function () { $('input[data-check-all]').change(function () { var objData = $(this).data('check-all'); $('input[data-check-item="' + objData + '"]').prop("checked", $(this).prop("checked")); }); // 항목 개별선택 후 전체선택 상태 동기화 $('input[data-check-item]').change(function () { var objName = $(this).data('check-item'); var allObj = $('input[type=checkbox][data-check-all="' + objName + '"]'); if ($(this).prop("checked")) { checkBoxLength = $('input[type=checkbox][data-check-item="' + objName + '"]').length; checkedLength = $('input[type=checkbox][data-check-item="' + objName + '"]:checked').length; if (checkBoxLength == checkedLength) { allObj.prop("checked", true); } else { allObj.prop("checked", false); } } else { allObj.prop("checked", false); } }); }); // 모달 레이어 $(function () { $('.modal-popup.show').each(function () { openModal($(this), null); }); // URL 해시 레이어 활성화 var hash = location.hash; if (!(hash === '#' || hash === '' || hash === '#;')) { setTimeout( function () { if ($(hash).hasClass('modal-popup')) openModal(hash); }, 300); } }); var modalOpener = null; $(document).on('click', 'a.js-layer-open', function (e) { var tg = $(this).attr('href'); openModal(tg, $(this)); e.preventDefault(); }).on('click', '.modal-popup .btn-close-popup, .modal-popup .dimed', function () { if (!$(this).hasClass('not-close')) { var target = $(this).closest('.modal-popup').attr('id'); closeModal('#' + target, modalOpener); } }).on('keydown', '.modal-popup .popup-inner', function (e) { if ($('.popup-inner').is(e.target) && e.keyCode == 9 && e.shiftKey) { // shift + tab e.preventDefault(); $(this).find('.btn-close-popup').focus(); } }).on('keydown', '.modal-popup .btn-close-popup', function (e) { if (e.keyCode == 9 && !e.shiftKey) { // tab e.preventDefault(); $(this).closest('.popup-inner').attr('tabindex', '0').focus(); $(this).unbind('keydown').keydown(); } }); function openModal(_target, _opener) { if ($(_target).length > 0) { modalOpener = _opener; $(_target).appendTo('body'); bodyScroll(true, $('body').width()); $('body').addClass('modal-open'); setTimeout(function () { $(_target).addClass('show').removeClass('hide'); }, 100); setTimeout(function () { $('.popup-inner', _target).attr('tabindex', '0').focus(); $(_target).scrollTop(0); }, 300); } } function closeModal(_target, _opener) { var tg = $(_target); if (tg.hasClass('show')) { if ($('.modal-popup.show').length == 1) { bodyScroll(false); } tg.addClass('hide').removeClass('show'); var modalOpener = $(_opener); if (modalOpener.length) { modalOpener.focus(); } // 레이어 해시 제거 history.pushState('', document.title, window.location.pathname + window.location.search); } else { alert('닫을 레이어를 올바로 지정해 주세요. \n closeModal(\'#레이어아이디\')') } } var modalScrollTop; function bodyScroll(_status, _orgWidth) { var $fixedModal = $('body'); if (_status) { $fixedModal.addClass('modal-open'); var scrollbarWidth = $('body').width() - _orgWidth; if (scrollbarWidth > 0) { $fixedModal.css({ 'margin-right': scrollbarWidth }); $('.fixed-header #header').css({ 'right': scrollbarWidth }); } } else { $fixedModal.removeClass('modal-open'); $fixedModal.css({ 'margin-right': '', }); $('.fixed-header #header').css({ 'right': '', }); } } // 윈도우 팝업 오픈 var popOpenBtn = null; function openWindow(_obj, popName, w, h, _opener) { var popW = 900; var popH = 600; var myUrl = _obj; if (typeof _obj !== 'string') { if ($(_obj).prop('tagName') === 'A') { popOpenBtn = $(_obj); myUrl = $(_obj).attr('href'); } else if (_opener) { popOpenBtn = $(_opener); } } if (w) popW = w; if (h) popH = h; var left = window.screenX + (window.outerWidth - popW) / 2; var top = window.screenY + (window.outerHeight - popH) / 2; window.open(myUrl, popName, 'width=' + popW + ', height=' + popH + ', left=' + left + ', top=' + top + ', scrollbars=yes'); } function closeWindow() { if (window.opener != null) { window.opener.openerFocus(); } window.close(); } function openerFocus() { if (popOpenBtn != null) { $(popOpenBtn).focus(); popOpenBtn = null; } } // 리사이즈 감지 var term = 0, timer = null; $(window).on('load resize', function () { clearTimeout(timer); timer = setTimeout(_modeDetect, term); term = 300; }); var _mode; function _modeDetect() { var widthScreen = $(window).width(); var beforeMode = _mode; if (widthScreen > 1024) { _mode = 'pc'; } else if (widthScreen >= 768) { _mode = 'tablet'; } else { _mode = 'mobile'; } } //초기 디바이스 확인용 함수 실행 _modeDetect(); // // 레이아웃 // // 모바일 검색 여닫기 $(document).on('click', '.btn-search-open', function (e) { e.preventDefault(); $('body').addClass('global-search-opened'); $('#global-search').slideDown('fast').find('input[type=text].form-control').focus(); }).on('click', '.btn-search-close', function (e) { e.preventDefault(); $('body').removeClass('global-search-opened'); $('#global-search').slideUp('fast'); $('.btn-search-open').focus(); }); // 전체메뉴 $(document).on('click', '.btn-allmenu-open', function (e) { e.preventDefault(); allmenuControl('open', $(this)); }).on('click', '.btn-allmenu-close', function (e) { e.preventDefault(); let opener = $allmenuOpener ? $allmenuOpener : $('.btn-allmenu-open'); allmenuControl('close', opener); }); var $allmenuOpener = null; function allmenuControl(_status, _opener) { $allmenuOpener = $(_opener); if (_status == 'open') { $('body').toggleClass('allmenu-opened'); } else if (_status == 'close') { $('body').removeClass('allmenu-opened'); $allmenuOpener.focus(); } } $(document).on('click', '.allmenu-list>li>a', function (e) { e.preventDefault(); if (_mode != 'pc') { $(this).next('ul').stop().slideToggle('fast').parent('li').toggleClass('active') .siblings('li').removeClass('active').children('ul').stop().slideUp('fast'); } }); $(document).on('click', '.allmenu-list>li:eq(2)>ul>li>a', function (e) { e.preventDefault(); if (_mode != 'pc') { $(this).next('ul').stop().slideToggle('fast').parent('li').toggleClass('active') .siblings('li').removeClass('active').children('ul').stop().slideUp('fast'); } }); $(document).on('click', '.faq-list dt a', function (e) { e.preventDefault(); $(this).parent('dt').toggleClass('on').next('dd').stop().slideToggle('fast').siblings('dd').stop().slideUp('fast'); $(this).parent('dt').siblings('dt').removeClass('on'); }); // 데이터 상품 카드 $(document).ready(function () { $('.score .star').each(function () { var score = $(this).text(); $(this).addClass('score-' + score); }); }); // 맨 위로 (function toTop() { $(window).scroll(function () { if ($(this).scrollTop() > 320) { $('#btn-totop').addClass('show'); } else { $('#btn-totop').removeClass('show'); } }); $(document).on('click', '#btn-totop', function (e) { e.preventDefault(); if ($('.floating-nav').length) { $('.floating-nav li:first-child a').click(); } else { $('body, html').animate({ scrollTop: 0 }, 300); } }); })();