616 lines
22 KiB
JavaScript
616 lines
22 KiB
JavaScript
$(document).ready(function(){
|
|
|
|
/* 상단 메뉴 Fixed */
|
|
$( window ).scroll(function() {
|
|
var TopVal = $( window ).scrollTop();
|
|
var TopFixed1 = 300;
|
|
var TopFixed2 = 303;
|
|
if( TopFixed1 <= TopVal){
|
|
$("#header").removeClass("scroll_off");
|
|
$("#header").addClass("scroll_on");
|
|
$(".nav-wrap").removeClass("scroll_off");
|
|
$(".nav-wrap").addClass("scroll_on");
|
|
}else{
|
|
$("#header").removeClass("scroll_on");
|
|
$("#header").addClass("scroll_off");
|
|
$(".nav-wrap").removeClass("scroll_on");
|
|
$(".nav-wrap").addClass("scroll_off");
|
|
}
|
|
});
|
|
|
|
//접근성
|
|
$('.location-box .loc li').append('<span class="ir">다음</span>');
|
|
$('.location-box .loc li.on *').remove('');
|
|
$('.location .inner .row-top .arr img').attr('alt','');
|
|
|
|
|
|
/* 인기자료 탭메뉴 */
|
|
(function ($) {
|
|
$(".tab ul.tabs").addClass("active").find("> li:eq(0)").addClass("current");
|
|
$(".tab ul.tabs li a").click(function (g) {
|
|
var tab = $(this).closest(".tab"),
|
|
index = $(this).closest("li").index();
|
|
|
|
tab.find("ul.tabs > li").removeClass("current");
|
|
$(this).closest("li").addClass("current");
|
|
|
|
tab.find(".tab_content")
|
|
.find("div.tabs_item")
|
|
.not("div.tabs_item:eq(" + index + ")")
|
|
//.hide();
|
|
tab.find(".tab_content")
|
|
.find("div.tabs_item:eq(" + index + ")")
|
|
.show();
|
|
g.preventDefault();
|
|
});
|
|
})(jQuery);
|
|
|
|
// 즐겨찾기 토글버튼
|
|
$('.data.detail .inner .row-top .center .right .con-1 button.favorit').click(function(){
|
|
$('.data.detail .inner .row-top .center .right .con-1 button.favorit').toggleClass('on');
|
|
});
|
|
|
|
/* 푸터 관련사이트 */
|
|
$(".family_site").click(function(){
|
|
$(this).toggleClass("on");
|
|
$(this) .find(".site_depth").slideToggle("fast");
|
|
});
|
|
|
|
/* 로그인 팝업 */
|
|
$(".login-btn").click(function(){
|
|
$(".pop-login").fadeIn();
|
|
});
|
|
$(".pop-login .login-close").click(function(){
|
|
$(".pop-login").fadeOut();
|
|
});
|
|
|
|
/* 로그인 연결 팝업 */
|
|
$(".login-connect-btn").click(function(){
|
|
$(".pop-login-connect").fadeIn();
|
|
});
|
|
$(".pop-login-connect .login-close").click(function(){
|
|
$(".pop-login-connect").fadeOut();
|
|
});
|
|
|
|
/* 로그인 연결 패스워드 팝업 */
|
|
$(".login-password-btn").click(function(){
|
|
$(".pop-login-password").fadeIn();
|
|
});
|
|
$(".pop-login-password .login-close").click(function(){
|
|
$(".pop-login-password").fadeOut();
|
|
});
|
|
|
|
// 회원가입 셀렉트박스
|
|
function birthdaySelectBox() {
|
|
var now = new Date();
|
|
var year = now.getFullYear();
|
|
var mon = (now.getMonth() + 1) > 9 ? ''+(now.getMonth() + 1) : '0'+(now.getMonth() + 1);
|
|
var day = (now.getDate()) > 9 ? ''+(now.getDate()) : '0'+(now.getDate());
|
|
// 년도
|
|
for(var i = 1900 ; i <= year ; i++) {
|
|
$('#birth_yy').append('<option value="' + i + '">' + i + '년</option>');
|
|
}
|
|
|
|
// 월별
|
|
for(var i=1; i <= 12; i++) {
|
|
var mm = i > 9 ? i : "0"+i ;
|
|
$('#birth_mm').append('<option value="' + mm + '">' + mm + '월</option>');
|
|
}
|
|
|
|
// 일별
|
|
for(var i=1; i <= 31; i++) {
|
|
var dd = i > 9 ? i : "0"+i ;
|
|
$('#birth_dd').append('<option value="' + dd + '">' + dd+ '일</option>');
|
|
}
|
|
};
|
|
|
|
// 스크롤 탑 버튼
|
|
$(window).scroll(function () {
|
|
var $window = $(window);
|
|
var $document = $(document);
|
|
var $footer = $("#footer");
|
|
var $scrollBtn = $("#btn-go-top");
|
|
var $scrollCartBtn = $(".btn-cart-top");
|
|
|
|
$scrollBtn.on("click", function () {
|
|
$("html, body").stop().animate(
|
|
{
|
|
scrollTop: 0,
|
|
},
|
|
600
|
|
);
|
|
return false;
|
|
});
|
|
|
|
btnXPosition();
|
|
$window.resize(function () {
|
|
btnXPosition();
|
|
});
|
|
|
|
// top버튼 x좌표설정
|
|
function btnXPosition() {
|
|
var rightPosition = ($document.width() - 1756) / 2;
|
|
|
|
// X position
|
|
if ($document.width() > 1756) {
|
|
//$scrollBtn.css('right', rightPosition);
|
|
$scrollBtn.css("right", "25px");
|
|
} else {
|
|
$scrollBtn.css("right", "25px");
|
|
}
|
|
}
|
|
|
|
// $scrollCartBtn 관련 스크립트 추가
|
|
$window.on("scroll", function () {
|
|
if ($window.scrollTop() < $document.height() - $window.height() - $footer.outerHeight() + 37) {
|
|
$scrollBtn.addClass("go-top-fix");
|
|
$scrollCartBtn.addClass("go-cart-fix");
|
|
} else {
|
|
$scrollBtn.removeClass("go-top-fix");
|
|
$scrollCartBtn.removeClass("go-cart-fix");
|
|
}
|
|
|
|
if ($window.scrollTop() < $window.height() / 3) {
|
|
$scrollBtn.addClass("go-top-hide");
|
|
$scrollCartBtn.addClass("go-cart-hide");
|
|
} else {
|
|
$scrollBtn.removeClass("go-top-hide");
|
|
$scrollCartBtn.removeClass("go-cart-hide");
|
|
}
|
|
});
|
|
});
|
|
|
|
// 상세검색 팝업 - 문화원정보 선택영역 초기작업 메서드 분리
|
|
jQuery(function($) {
|
|
// 상세검색 팝업 열기
|
|
$('.btn-search-detail').on('click', function () {
|
|
// 클릭 시, 컨텐츠 로딩되도록 처리 (2021.10.20 NLIB 추가) : 시작
|
|
gfn_layerPopWithClass("/search/getDetailedSearchFormPopup.do", "popup pop-advanced-search");
|
|
// 클릭 시, 컨텐츠 로딩되도록 처리 (2021.10.20 NLIB 추가) : 종료
|
|
});
|
|
});
|
|
|
|
// 회원가입 체크박스
|
|
$('input.sex[type="checkbox"]').bind('click',function() {
|
|
$('input.sex[type="checkbox"]').not(this).prop("checked", false);
|
|
});
|
|
|
|
// 회원가입 체크박스
|
|
$('input.ser-chk1[type="checkbox"]').bind('click',function() {
|
|
$('input.ser-chk1-1[type="checkbox"]').not(this).prop("checked", true);
|
|
|
|
if($("input.ser-chk1").prop("checked")){
|
|
$("input.ser-chk1-1[type=checkbox]").prop("checked",true);
|
|
}else{
|
|
$("input.ser-chk1-1[type=checkbox]").prop("checked",false);
|
|
}
|
|
});
|
|
|
|
// 회원가입 체크박스
|
|
$('input.ser-chk2[type="checkbox"]').bind('click',function() {
|
|
$('input.ser-chk2-2[type="checkbox"]').not(this).prop("checked", true);
|
|
|
|
if($("input.ser-chk2").prop("checked")){
|
|
$("input.ser-chk2-2[type=checkbox]").prop("checked",true);
|
|
}else{
|
|
$("input.ser-chk2-2[type=checkbox]").prop("checked",false);
|
|
}
|
|
});
|
|
|
|
// 소장자료 디테일 목차정보
|
|
$('.down-btn').append('<span class="ir">펼치기</span>');
|
|
$('.down-btn').click(function(){
|
|
if($('.down-btn').hasClass('on') === false) {
|
|
$(this).addClass('on');
|
|
$('.h-down').css('height','auto');
|
|
$('.down-btn .ir').text('접기');
|
|
} else {
|
|
$(this).removeClass('on');
|
|
$('.h-down').css('height','');
|
|
$('.down-btn .ir').text('펼치기');
|
|
}
|
|
});
|
|
|
|
// 공유하기 팝업
|
|
$('.share').click(function(){
|
|
$('.pop-sharing').fadeIn();
|
|
$("#p_link-copy").focus();
|
|
});
|
|
// 닫기
|
|
$('.pop-sharing .btn-close-pop').on('click', function () {
|
|
$('.pop-sharing').fadeOut();
|
|
});
|
|
|
|
// 비밀번호 변경 팝업
|
|
$('.pop-change-btn').click(function(){
|
|
$('.pop-change').fadeIn();
|
|
});
|
|
// 닫기
|
|
$('.change-close, .close').on('click', function () {
|
|
$('.pop-change').fadeOut();
|
|
});
|
|
|
|
// 필터 팝업
|
|
$('.filter-btn').click(function(){
|
|
$('.article-side').fadeIn();
|
|
});
|
|
// 닫기
|
|
$('.filter-close').on('click', function () {
|
|
$('.article-side').fadeOut();
|
|
});
|
|
|
|
// 검색 닫기
|
|
$('.search-close').on('click', function () {
|
|
$('.search-wrap').hide();
|
|
$('.nav-wrap').show();
|
|
});
|
|
|
|
/* 메인 메뉴 반응형 */
|
|
jQuery(function ($) {
|
|
$.fn.responsivenav = function (args) {
|
|
// Default settings
|
|
var defaults = {
|
|
responsive: true,
|
|
width: 1400, // Responsive width
|
|
button: $(this).attr("id") + "-button", // Menu button id
|
|
animation: {
|
|
// Menu animation
|
|
effect: "slide", // Accepts 'slide' or 'fade'
|
|
show: 0,
|
|
hide: 0,
|
|
},
|
|
selected: "selected", // Selected class
|
|
arrow: "downarrow", // Dropdown arrow class
|
|
};
|
|
var settings = $.extend(defaults, args);
|
|
// Initialize the menu and the button
|
|
init($(this).attr("id"), settings.button);
|
|
|
|
function init(menuid, buttonid) {
|
|
setupMenu(menuid, buttonid);
|
|
// Add a handler function for the resize and orientationchange event
|
|
$(window).bind("resize orientationchange", function () {
|
|
resizeMenu(menuid, buttonid);
|
|
});
|
|
// Trigger initial resize
|
|
resizeMenu(menuid, buttonid);
|
|
}
|
|
|
|
function setupMenu(menuid, buttonid) {
|
|
var $mainmenu = $("#" + menuid + ">ul");
|
|
var $headers = $mainmenu.find("ul").parent();
|
|
// Add dropdown arrows
|
|
$headers.each(function (i) {
|
|
var $curobj = $(this);
|
|
$curobj.children("a:eq(0)").append('<span class="' + settings.arrow + '"></span>');
|
|
});
|
|
|
|
if (settings.responsive) {
|
|
// Menu button click event
|
|
// Displays top-level menu items
|
|
$("#" + buttonid).click(function (e) {
|
|
e.preventDefault();
|
|
|
|
if (isSelected($("#" + buttonid))) {
|
|
// Close menu
|
|
collapseChildren("#" + menuid);
|
|
animateHide($("#" + menuid), $("#" + buttonid));
|
|
} else {
|
|
// Open menu
|
|
animateShow($("#" + menuid), $("#" + buttonid));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function resizeMenu(menuid, buttonid) {
|
|
var $ww = document.body.clientWidth;
|
|
// Add mobile class to elements for CSS use
|
|
// instead of relying on media-query support
|
|
if ($ww > settings.width || !settings.responsive) {
|
|
$("#" + menuid).removeClass("mobile");
|
|
$("#" + buttonid).removeClass("mobile");
|
|
} else {
|
|
$("#" + menuid).addClass("mobile");
|
|
$("#" + buttonid).addClass("mobile");
|
|
}
|
|
|
|
var $headers = $("#" + menuid + ">ul")
|
|
.find("ul")
|
|
.parent();
|
|
|
|
$headers.each(function (i) {
|
|
var $curobj = $(this);
|
|
var $link = $curobj.children("a:eq(0)");
|
|
var $subul = $curobj.find("ul:eq(0)");
|
|
|
|
// Unbind events
|
|
$curobj.unbind("mouseenter mouseleave");
|
|
$link.unbind("click");
|
|
animateHide($curobj.children("ul:eq(0)"));
|
|
|
|
if ($ww > settings.width || !settings.responsive) {
|
|
// Full menu
|
|
$curobj.hover(
|
|
function (e) {
|
|
var $targetul = $(this).children("ul:eq(0)");
|
|
|
|
var $dims = { w: this.offsetWidth, h: this.offsetHeight, subulw: $subul.outerWidth(), subulh: $subul.outerHeight() };
|
|
var $istopheader = $curobj.parents("ul").length == 1 ? true : false;
|
|
$subul.css($istopheader ? {} : { top: 0 });
|
|
var $offsets = { left: $(this).offset().left, top: $(this).offset().top };
|
|
var $menuleft = $istopheader ? 0 : $dims.w;
|
|
$menuleft = $offsets.left + $menuleft + $dims.subulw > $(window).width() ? ($istopheader ? -$dims.subulw + $dims.w : -$dims.w) : $menuleft;
|
|
$targetul.css({ left: $menuleft + "px", width: $dims.subulw + "px" });
|
|
|
|
animateShow($targetul);
|
|
},
|
|
function (e) {
|
|
var $targetul = $(this).children("ul:eq(0)");
|
|
animateHide($targetul);
|
|
}
|
|
);
|
|
} else {
|
|
// Compact menu
|
|
$link.click(function (e) {
|
|
e.preventDefault();
|
|
|
|
var $targetul = $curobj.children("ul:eq(0)");
|
|
if (isSelected($curobj)) {
|
|
collapseChildren($targetul);
|
|
animateHide($targetul);
|
|
} else {
|
|
//collapseSiblings($curobj);
|
|
animateShow($targetul);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
collapseChildren("#" + menuid);
|
|
|
|
if (settings.responsive && isSelected($("#" + buttonid))) {
|
|
//collapseChildren('#'+menuid);
|
|
$("#" + menuid).hide();
|
|
$("#" + menuid).removeAttr("style");
|
|
$("#" + buttonid).removeClass(settings.selected);
|
|
}
|
|
}
|
|
|
|
function collapseChildren(elementid) {
|
|
// Closes all submenus of the specified element
|
|
var $headers = $(elementid).find("ul");
|
|
$headers.each(function (i) {
|
|
if (isSelected($(this).parent())) {
|
|
animateHide($(this));
|
|
}
|
|
});
|
|
}
|
|
|
|
function collapseSiblings(element) {
|
|
var $siblings = element.siblings("li");
|
|
$siblings.each(function (i) {
|
|
collapseChildren($(this));
|
|
});
|
|
}
|
|
|
|
function isSelected(element) {
|
|
return element.hasClass(settings.selected);
|
|
}
|
|
|
|
function animateShow(menu, button) {
|
|
if (!button) {
|
|
var button = menu.parent();
|
|
}
|
|
|
|
button.addClass(settings.selected);
|
|
|
|
if (settings.animation.effect == "fade") {
|
|
menu.fadeIn(settings.animation.show);
|
|
$(".BG").fadeIn("fast");
|
|
} else if (settings.animation.effect == "slide") {
|
|
menu.slideDown(settings.animation.show);
|
|
$(".BG").fadeIn("fast");
|
|
} else {
|
|
menu.show();
|
|
menu.removeClass("hide");
|
|
}
|
|
}
|
|
|
|
function animateHide(menu, button) {
|
|
if (!button) {
|
|
var button = menu.parent();
|
|
}
|
|
|
|
if (settings.animation.effect == "fade") {
|
|
menu.fadeOut(settings.animation.hide, function () {
|
|
menu.removeAttr("style");
|
|
button.removeClass(settings.selected);
|
|
$(".BG").fadeOut("fast");
|
|
});
|
|
} else if (settings.animation.effect == "slide") {
|
|
menu.slideUp(settings.animation.hide, function () {
|
|
menu.removeAttr("style");
|
|
button.removeClass(settings.selected);
|
|
$(".BG").fadeOut("fast");
|
|
});
|
|
} else {
|
|
menu.hide();
|
|
menu.addClass("hide");
|
|
menu.removeAttr("style");
|
|
button.removeClass(settings.selected);
|
|
}
|
|
}
|
|
$(".BG").click(function () {
|
|
$(".BG").fadeOut("fast");
|
|
$("#primary-nav.mobile").hide();
|
|
$("#primary-nav-button").removeClass("selected");
|
|
});
|
|
};
|
|
});
|
|
|
|
jQuery(function ($) {
|
|
$("#primary-nav").responsivenav();
|
|
$("#top-nav").responsivenav({ responsive: false });
|
|
|
|
// 모바일
|
|
$(".mo_menu").click(function () {
|
|
// $(this).toggleClass("show");
|
|
if ($(this).hasClass("show")) {
|
|
$(this).removeClass("show");
|
|
} else {
|
|
$(".mo_menu").removeClass("show");
|
|
$(this).addClass("show");
|
|
}
|
|
});
|
|
|
|
$("#primary-nav-button").on("click", function () {
|
|
$(".mo-nav-wrap").toggleClass("show");
|
|
$(".wrap .nav-wrap .inner").toggleClass("mo_show");
|
|
$(".wrap .nav-wrap .inner .left").fadeToggle();
|
|
$("#mo_search_icon").fadeToggle(0);
|
|
});
|
|
|
|
$("#mo_search_icon").click(function () {
|
|
$(".wrap header .inner .search-wrap").slideDown();
|
|
$(".wrap .nav-wrap").css("display", "none");
|
|
});
|
|
|
|
$("h2.blind .search-close").click(function () {
|
|
$(".wrap header .inner .search-wrap").slideUp();
|
|
$(".wrap .nav-wrap").css("display", "block");
|
|
});
|
|
|
|
$(".btn_filter").on("click", function () {
|
|
$(".article-side").fadeIn();
|
|
$("html,body").addClass("no-scroll");
|
|
});
|
|
|
|
$(".filter-close").click(function () {
|
|
$(".article-side").fadeOut();
|
|
$("html,body").removeClass("no-scroll");
|
|
});
|
|
});
|
|
/* 메인 메뉴 반응형 end */
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 검색 필터 관련
|
|
$(document).ready(function() {
|
|
// depth-1 열고 닫기
|
|
$('.filter-tit .btn-toggle').on('click', function() {
|
|
if($(this).text() == '닫기') {
|
|
$(this).text('열기');
|
|
$(this).parent('.filter-tit').siblings('.filter-list').stop().slideUp();
|
|
$('.filter .btn-toggle-more').css('display','none');
|
|
} else {
|
|
$(this).text('닫기');
|
|
$(this).parent('.filter-tit').siblings('.filter-list').stop().slideDown();
|
|
$('.filter .btn-toggle-more').css('display','block');
|
|
}
|
|
});
|
|
|
|
// depth-2 열고 닫기
|
|
$('.filter .depth-1 .btn-toggle').on('click', function () {
|
|
var _this = $(this).parents('li').index();
|
|
if ($(this).text() == '닫기') {
|
|
$(this).text('열기');
|
|
$(this).siblings('.check').find('.tab-name').trigger("click");
|
|
} else {
|
|
$(this).text('닫기');
|
|
$(this).siblings('.check').find('.tab-name').trigger("click");
|
|
}
|
|
});
|
|
|
|
$('.filter-wrap .tab-name').on('click', function() {
|
|
if ($('body').hasClass('pop-filter')) {
|
|
$(this).parents('.depth-1').removeClass('on');
|
|
}
|
|
});
|
|
|
|
//더보기 버튼
|
|
$('.filter .btn-toggle-more').on('click', function() {
|
|
if($(this).text() == '더보기') {
|
|
$(this).text('접기');
|
|
$(this).addClass('on');
|
|
$(this).siblings('.filter-list').children('ul').children('li').css('display', 'block');
|
|
} else {
|
|
$(this).text('더보기');
|
|
$(this).removeClass('on');
|
|
$(this).siblings('.filter-list').children('ul').children('li').each(function () {
|
|
if($(this).index() > 3) {
|
|
$(this).css('display','none');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// 하위 리스트 보기
|
|
$(".filter-wrap .depth-1 .check input").each(function () {
|
|
var tabLabel = $(this).next().text();
|
|
if ($(this).parents(".depth-1").siblings(".depth-2").length > 0) {
|
|
//하위 조건이 있을 경우만 버튼 생성
|
|
$(this)
|
|
.parent(".check")
|
|
.append('<button type="button" class="tab-name">' + tabLabel + "<span class='ir'>펼치기</span></button>");
|
|
}
|
|
|
|
$(this)
|
|
.siblings(".tab-name")
|
|
.on("click", function () {
|
|
var _this = $(this).parents("li").index();
|
|
|
|
$(this).parents("li").siblings("li").find(".depth-1").removeClass("on");
|
|
if (!$("body").hasClass("pop-filter")) {
|
|
if ($(this).parents(".depth-1").hasClass("on")) {
|
|
$(this).parents(".depth-1").removeClass("on");
|
|
$('.tab-name .ir').text('펼치기');
|
|
} else {
|
|
$(this).parents(".depth-1").addClass("on");
|
|
$('.tab-name .ir').text('접기');
|
|
}
|
|
} else {
|
|
$(this).parents(".depth-1").addClass("on");
|
|
$('.tab-name .ir').text('접기');
|
|
}
|
|
|
|
// 줄구분용 data 추가
|
|
$(".pop-culture-center .line-1").data("idx", "1");
|
|
$(".pop-culture-center .line-2").data("idx", "2");
|
|
$(".pop-culture-center .line-3").data("idx", "3");
|
|
|
|
target = $(".pop-filter li.line-" + $(this).parents("li").data("idx") + "");
|
|
size = $(this).parents("div.depth-1").next().outerHeight() + 50;
|
|
$(".line-1 , .line-2, .line-3").attr("style", "");
|
|
// 여기
|
|
target.css("height", size);
|
|
});
|
|
|
|
$(this).change(function () {
|
|
var _this = $(this).parents("li").index();
|
|
if ($(this).is(":checked")) {
|
|
$(this).parents(".depth-1").next().stop().slideDown(0);
|
|
$(this).parents(".depth-1").addClass("on");
|
|
$(this).parents("li").siblings("li").find(".depth-1").children(".btn-toggle").text("열기");
|
|
$(this).parents("li").find(".depth-1").children(".btn-toggle").text("닫기");
|
|
$(this).parents("li").siblings("li").find(".depth-1").next().stop().slideUp(0);
|
|
$(this).parents("li").siblings("li").find(".depth-1").removeClass("on");
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".filter-wrap .depth-2 input").change(function () {
|
|
if ($(this).is(":checked")) {
|
|
$(this).parents(".depth-2").siblings(".depth-1").find("input").prop("checked", true);
|
|
} else {
|
|
if ($(this).parents(".depth-2").find("input:checked").length <= 0) {
|
|
$(this).parents(".depth-2").siblings(".depth-1").find("input").prop("checked", false);
|
|
}
|
|
}
|
|
});
|
|
}); |