$(function(){ // 탭 메뉴 공통 $('ul.tabs').each(function(){ var $active, $content, $links = $(this).find('a'); $active = $links.first().addClass('on'); $content = $($active.attr('href')); $links.not(':first').each(function () { $($(this).attr('href')).hide(); }); $(this).on('click', 'a', function(e){ if($(this).attr('href')=='#write_reply' && document.cookie.indexOf("user[id]")<1){ alert('로그인 후 이용해주세요.'); location.href = '/login/'; return false; } $active.removeClass('on'); $content.hide(); $active = $(this); $content = $($(this).attr('href')); $active.addClass('on'); $content.show(); e.preventDefault(); }); }); // 검색 영역 $('a[href=#search_box]').click(function(){ $('#search_box .typ2').toggle(); $('#search_box input[type=search]').focus(); }); // 베스트 컨텐츠 열기 $('.best_more_show').click(function(){ $('.bect_li_show').removeClass('hide').addClass('show'); $(this).addClass('hide'); $('.bect_li').removeClass('show').addClass('hide') $('.best_more_hide').removeClass('hide').addClass('show') }); // 베스트 컨텐츠 닫기 $('.best_more_hide, .bect_cls').click(function(){ $('.bect_li_show').removeClass('show').addClass('hide'); $('.best_more_hide').addClass('hide'); $('.bect_li').removeClass('hide').addClass('show') $('.best_more_show').removeClass('hide').addClass('show') }); // 모달창 $('#modal_poll .btn_modal_close').click(function(){ // 모달 닫기 close_poll(this); }); // 2013-10-29 여준혁, 모달창 공통화 스크립트 $(window).bind('load, scroll', function(){ winScroll = $(this).scrollTop(); }); $('.m_modal .btn_modal_close').click(function(e){ modal_close(); e.preventDefault(); }); $('.modal_open').click(function(e){ // 모달 열기 공통 if($(this).attr('href')=='#modal_poll') $("body").prepend('
'); var $modal = $($(this).attr('href')); $modal.fadeIn(100); e.preventDefault(); }); $(document).on("click", ".upload_imgs button", function(){ var img = $(this).parent().find("img").attr("src"), last = img.lastIndexOf('/'), src = img.substr(last+1); fm.files.value = fm.files.value.replace(':::'+src+':::', ':::').replace(':::'+src, '').replace(src+':::', '').replace(src, ''); $(this).parent().parent().remove(); }); }); $(window).load(function(){ $('.flexslider').flexslider({ animation: "slide", slideshow: false }); }); function close_poll(obj) { if($("body").find(".background_black")) $(".background_black").remove(); $(obj).parents('.modal').fadeOut(100); } /* 모달 */ $(window).bind('load scroll resize',function(){ winScroll = $(this).scrollTop(); }); function modal_open(modalName) { // 모달 열기 공통 history.pushState(null, null, location.href); modal = $(modalName); // 모달창 ID값으로 열기 //modal = $(this).attr('href'); // 모달창 ID값으로 열기 //modalBody = $(modal).children('.modal_wrap'); // 실제 모달창 winScroll = $(this).scrollTop(); $(modal).stop().show(); $('body').addClass('modalFix').css('top',-winScroll); // 스크롤바 막고, 사이즈 고정 $('body').addClass('winFix'); // body에 스크롤바 } function modal_close() { // 모달 닫기 공통 //history.replaceState(null, null, ''); winTop = Math.abs(parseInt($('body').css('top'))); // 모달 닫을 시 현재 스크롤 위치값 반환 modal.hide(); $('body').removeClass('winFix'); $('body').removeClass('modalFix').css('top',''); $(window).scrollTop(winTop); winTop = 0; } //높이 가변화되는 모달 열고 닫기 function modal_open2(modalName) { var s_height=$(document).scrollTop(); modal = $(modalName); modalBody = $(modal).children('.modal_wrap'); $(modal).stop().show(); var height=modalBody.outerHeight(); var w_height=$(window).height(); var margin=(w_height-height)/2; //var marginL=modalBody.width()/2; modalBody.css({ "margin-top":margin, //"margin-left":-marginL, }); $("body").addClass("modalFix"); $("body").addClass("winFix"); $("body").css("top",-s_height); } function modal_close2(modalName) { winTop = Math.abs(parseInt($('body').css('top'))); modal = $(modalName); $('.m_modal').hide(); $("body").removeClass("modalFix").css("top"); $("body").removeClass("winFix"); $(window).scrollTop(winTop); winTop = 0; } $(".m_modal .btn_modal_close2, .m_modal .btn_ok2, .m_modal .btn_cancel2").click(function() { var modal=$(this).parents(".m_modal").attr("id"); modal_close2("#"+modal); });