456 lines
16 KiB
JavaScript
456 lines
16 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");
|
|
}
|
|
});
|
|
|
|
/* 메인 메뉴 반응형 */
|
|
jQuery(function($) {
|
|
$.fn.responsivenav = function(args) {
|
|
// Default settings
|
|
var defaults = {
|
|
responsive: true,
|
|
width: 768, // Responsive width
|
|
button: $(this).attr('id')+'-button', // Menu button id
|
|
animation: { // Menu animation
|
|
effect: 'slide', // Accepts 'slide' or 'fade'
|
|
show: 150,
|
|
hide: 100
|
|
},
|
|
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});
|
|
});
|
|
/* 메인 메뉴 반응형 end */
|
|
|
|
/* 인기자료 탭메뉴 */
|
|
(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);
|
|
|
|
/* 푸터 관련사이트 */
|
|
$(".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();
|
|
});
|
|
|
|
// scroll top button
|
|
$(window).scroll(function() {
|
|
var $window = $(window);
|
|
var $document = $(document);
|
|
var $footer = $('#footer');
|
|
var $scrollBtn = $('#btn-go-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');
|
|
}
|
|
}
|
|
|
|
$window.on('scroll', function () {
|
|
if ($window.scrollTop() < $document.height() - $window.height() - $footer.outerHeight() + 37) {
|
|
$scrollBtn.addClass('go-top-fix');
|
|
} else {
|
|
$scrollBtn.removeClass('go-top-fix');
|
|
}
|
|
|
|
if ($window.scrollTop() < ($window.height() / 3)) {
|
|
$scrollBtn.addClass('go-top-hide');
|
|
} else {
|
|
$scrollBtn.removeClass('go-top-hide');
|
|
}
|
|
});
|
|
});
|
|
|
|
// 상세검색 팝업 - 문화원정보 선택영역 초기작업 메서드 분리
|
|
jQuery(function($) {
|
|
var depth2H = 0;
|
|
$('.pop-advanced-search .depth1-check input').each(function () {
|
|
|
|
if ($(this).is(":checked")) { // 활성화 line에 높이 잡아주기
|
|
$('.depth1').removeClass('on');
|
|
$(this).parents('.depth1').addClass('on');
|
|
depth2H = $(this).parents('.depth1-check').next('.depth2').outerHeight();
|
|
$(this).parents('.line').siblings('.line').attr('style', '');
|
|
$(this).parents('.line').height(depth2H + 50);
|
|
}
|
|
|
|
var tabLabel = $(this).next().text();
|
|
$(this).parent('.depth1-check').append('<button type="button" class="tab-name">'+tabLabel+'</button>');
|
|
|
|
$(this).siblings('.tab-name').on('click', function() {
|
|
$('.depth1').removeClass('on');
|
|
$(this).parents('.depth1').addClass('on');
|
|
depth2H = $(this).parents('.depth1-check').next('.depth2').outerHeight();
|
|
$('.line').attr('style', '');
|
|
$(this).parents('.line').height(depth2H + 50);
|
|
});
|
|
|
|
});
|
|
|
|
$('.pop-advanced-search .depth2 input').change(function() {
|
|
if ($(this).is(':checked')) {
|
|
$(this).parents('.depth2').siblings('.depth1-check').find('input').prop('checked', true);
|
|
} else {
|
|
if ($(this).parents('.depth2').find('input:checked').length <= 0) {
|
|
$(this).parents('.depth2').siblings('.depth1-check').find('input').prop('checked', false);
|
|
}
|
|
}
|
|
});
|
|
|
|
// 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');
|
|
}
|
|
});
|
|
|
|
// 상세검색 팝업 열기
|
|
$('.btn-search-detail').on('click', function () {
|
|
//$('.pop-advanced-search').fadeIn();
|
|
//$('html,body').addClass('no-scroll');
|
|
fn_layerPop('${pageContext.request.contextPath}/search/getDetailedSearchFormPopup.do');
|
|
});
|
|
|
|
//팝업닫기버튼 클릭
|
|
$('.btn-close-pop').on('click', function () {
|
|
$(this).parents('.popup').fadeOut();
|
|
$('html,body').removeClass('no-scroll');
|
|
});
|
|
});
|
|
|
|
// 회원가입 셀렉트박스
|
|
jQuery(function($) {
|
|
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++) {
|
|
$('#year').append('<option value="' + i + '">' + i + '년</option>');
|
|
}
|
|
|
|
// 월별
|
|
for(var i=1; i <= 12; i++) {
|
|
var mm = i > 9 ? i : "0"+i ;
|
|
$('#month').append('<option value="' + mm + '">' + mm + '월</option>');
|
|
}
|
|
|
|
// 일별
|
|
for(var i=1; i <= 31; i++) {
|
|
var dd = i > 9 ? i : "0"+i ;
|
|
$('#day').append('<option value="' + dd + '">' + dd+ '일</option>');
|
|
}
|
|
$("#year > option[value="+year+"]").attr("selected", "true");
|
|
$("#month > option[value="+mon+"]").attr("selected", "true");
|
|
$("#day > option[value="+day+"]").attr("selected", "true");
|
|
});
|
|
|
|
// 회원가입 체크박스
|
|
$('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);
|
|
}
|
|
});
|
|
|
|
}); |