jQuery( document ).ready(function() { //팝업 태그를 body에 추가 var popup_html = ""; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; popup_html = popup_html+'
'; jQuery("body").append(popup_html); }); var confirmCallbackSend; var confirmCallbackCancel; var alertCallbackSend; var popupCallbackData; var select_menu = ""; var eventX = 0; var eventY = 0; var scrollMode = true; var popupMode = "popup"; function setPopupScrollEvent(){ jQuery(window).on({ 'mousewheel': function(e){ if(scrollMode) setPopupPosition("scroll"); },'scroll': function(e){ if(scrollMode) setPopupPosition("scroll"); } }) } function setPopupPosition(mode){ if(typeof(mode)!=='undefined' && mode=="scroll" && jQuery("#mb_pop_bg").css('display')=='none') return; var pHeight = 100; var nWidth = jQuery(window).width(); var nHeight = jQuery(window).height(); if(mb_options["device_type"]=="mobile") pHeight = 20; var popupObj = jQuery("#mb_pop_confirm"); popupObj.css('left',(nWidth-popupObj.outerWidth())/2); popupObj.css('top',(jQuery(document).scrollTop()-pHeight+((nHeight-popupObj.outerHeight())/2))); popupObj = jQuery("#mb_pop_alert"); popupObj.css('left',(nWidth-popupObj.outerWidth())/2); popupObj.css('top',(jQuery(document).scrollTop()-pHeight+((nHeight-popupObj.outerHeight())/2))); popupObj = jQuery("#mb_pop_info"); popupObj.css('left',(nWidth-popupObj.outerWidth())/2); popupObj.css('top',((jQuery(document).scrollTop()+((nHeight-popupObj.outerHeight())/2)))); popupObj = jQuery("#mb_pop_html"); if(popupObj.height()>=nHeight || popupObj.outerWidth()>=nWidth){ popupObj.css('position','fixed'); if(mb_options["device_type"]=="mobile") popupObj.css('width',"100%"); popupObj.css('height',"100%"); if(popupObj.height()>=nHeight){ popupObj.css('top',0); }else{ popupObj.css('top',(jQuery(document).scrollTop()-pHeight+((nHeight-popupObj.outerHeight())/2))); } popupObj.css('left',(nWidth-popupObj.outerWidth())/2); scrollMode = false; jQuery('body').css('overflow-y','hidden'); }else{ popupObj.css('position','absolute'); popupObj.css('top',(jQuery(document).scrollTop()-pHeight+((nHeight-popupObj.outerHeight())/2))); popupObj.css('left',(nWidth-popupObj.outerWidth())/2); } } setPopupScrollEvent(); function showConfirmPopup(message,data,send,cancel) { popupCallbackData = data; confirmCallbackSend = send; if(typeof(cancel)==='undefined') confirmCallbackCancel = hidePopupBox; else confirmCallbackCancel = cancel; //위치 설정 var pop_head = ''; var pop_body = ''; if(typeof(data)!=='undefined' && typeof(data.type)!=='undefined' && data.type=="passwd"){ pop_head = '
'+message+'
'; pop_body = pop_body+'
'; pop_body = pop_body+'
'; pop_body = pop_body+'
'; }else{ pop_head = '

Message

'+message+'

'; } pop_body = pop_body+'
'; pop_body = pop_body+''+mb_languages["btn_cancel"]+''; pop_body = pop_body+''+mb_languages["btn_ok"]+''; pop_body = pop_body+'
'; if(typeof(data)!=='undefined'){ if(typeof(data.head)!=='undefined') pop_head = data.head; if(typeof(data.body)!=='undefined') pop_body = data.body; } showPopupBox("Confirm",pop_head,pop_body); } function showAlertPopup(response,send){ if(!response || typeof(response)==='undefined') return; var code = ""; var message = ""; var target_name = ""; if(typeof(send)==='undefined') alertCallbackSend = null; else alertCallbackSend = send; if(typeof(response.code)!=='undefined') code = response.code; if(typeof(response.message)!=='undefined') message = response.message; if(typeof(response.target_name)!=='undefined') target_name = response.target_name; if(message=="") return; var pop_head = '

Message

'+message+'

'; var pop_body = ''; pop_body = pop_body+'
'; pop_body = pop_body+''+mb_languages["btn_ok"]+''; pop_body = pop_body+'
'; showPopupBox("Alert",pop_head,pop_body); } function showPopupBox(type,head,body,data,mode){ if(typeof(mode)!=='undefined' && mode!=''){ popupMode = mode; }else{ popupMode = "popup"; } scrollMode = true; initLoadingBox(); var popupID = "#mb_pop_confirm"; if(type=="Alert"){ popupID = "#mb_pop_alert"; if(jQuery("#mb_pop_bg").css('display')=='none') jQuery("#mb_pop_confirm").hide(); setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-open"); }, 1); }else if(type=="Info"){ popupID = "#mb_pop_info"; }else if(type=="Confirm"){ popupID = "#mb_pop_confirm"; setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-open"); }, 1); }else if(type=="Html"){ popupID = "#mb_pop_html"; }else{ popupID = "#mb_pop_alert"; setTimeout(function(){ jQuery(popupID).addClass("mb-ani-pop-open"); }, 1); } if(typeof(data)==='undefined') data = {}; if(typeof(data.position)==='undefined') data.position = "center"; if(typeof(data.bg)==='undefined') data.bg = true; if(typeof(data.eventX)==='undefined') data.eventX = 0; if(typeof(data.eventY)==='undefined') data.eventY = 0; jQuery(popupID+"_head").html(head); jQuery(popupID+"_body").html(body); var adminbarHeight = jQuery("#wpadminbar").height(); if(adminbarHeight==null || typeof(adminbarHeight)==='undefined') adminbarHeight = 0; if(data.position=="click"){ jQuery(popupID).css("top",parseInt((data.eventY+jQuery(document).scrollTop()-adminbarHeight)/10)*10-7); jQuery(popupID).css("left",parseInt(data.eventX/10)*10+30); }else{ setPopupPosition(); } if(data.bg) showPopupBG(); jQuery(popupID).show(); if(type=="Alert"){ jQuery("#mb_pop_alert_ok").focus(); }else if(type=="Confirm"){ jQuery("#mb_confirm_passwd").focus(); } } function initLoadingBox(){ jQuery("#mb_pop_html_head").html(""); jQuery("#mb_pop_html_body").html(""); } function showLoadingBox(){ showPopupBox("Html",'','
Loading
'); } function hideLoadingBox(){ initLoadingBox(); if(jQuery("#mb_pop_alert").css('display')=='none' && jQuery("#mb_pop_confirm").css('display')=='none'){ jQuery("#mb_pop_bg").hide(); } } function showPopupBG(){ hideInfoBox(); jQuery('#mb_pop_bg').height(jQuery(document).height()); jQuery("#mb_pop_bg").show(); } function getUserMenu(uid,pid){ var menu_options = "*"; if(select_menu==uid+"_"+pid){ select_menu = ""; hideInfoBox(); }else{ sendUserMenu(uid,pid,menu_options,event); select_menu = uid+"_"+pid; } } function showUserMenu(data){ var menu_head = data["head"]; var menu_body = ""; var menu_foot = data["foot"]; menu_head = menu_head+'
'+data["user"]["name"]+'
'; menu_body = ''; showPopupBox("Info","",('
'+menu_head+menu_body+menu_foot+"
"),{"position":"click","bg":false,"eventX":eventX,"eventY":eventY}); } } function sendUserMenu(uid,board_pid,option,event){ if(typeof(event)!=='undefined'){ eventX = event.clientX; eventY = event.clientY; } if(option=="*") option = "search,info,email,homepage,blog"; var param = "board_name="+mb_options["board_name"]+"&option="+option+"&list_type="+mb_options["list_type"]+"&page="+mb_options["page"]; if(jQuery('#'+mb_options["board_name"]+'_form_board_search')) param += "&"+jQuery('#'+mb_options["board_name"]+'_form_board_search').serialize(); param += "&mode=user&board_action=menu"+"&pid="+uid+"&board_pid="+board_pid; sendDataRequest(mb_urls["template_api"], param, sendUserMenuHandler); } function sendUserMenuHandler(response, state){ if(response.state == "success"){ showUserMenu(response.data); }else{ showAlertPopup(response); } } function hideInfoBox() { jQuery("#mb_pop_info").hide(); } function hidePopupBox() { confirmCallbackSend = null; jQuery(".input-focus").removeClass("input-focus"); jQuery("#mb_pop_info").hide(); jQuery("#mb_pop_html").hide(); jQuery("#mb_pop_confirm").hide(); jQuery("#mb_pop_confirm").removeClass("mb-ani-pop-open"); jQuery("#mb_pop_alert").removeClass("mb-ani-pop-open"); jQuery("#mb_pop_bg").hide(); if(!scrollMode){ jQuery('body').css('overflow-y','auto'); scrollMode = true; } popupMode = "popup"; } function showAlertCallback(code,target_name) { hidePopupAlert(code,target_name); sendAlertCallbackData(); } function hidePopupAlert(code,target_name) { if(popupMode=="modal") return; if(typeof(code)!=='undefined' && code!=='undefined'){ if(confirmCallbackSend) jQuery("#mb_pop_confirm").show(); if(code.substr(0,2)=="12"){ //입력 관련 에러일 경우 포커스 설정 var target; if(jQuery("#mb_pop_confirm").css('display')!='none'){ if(target_name!="") target = jQuery("#mb_confirm_form").find("input[name="+target_name+"]"); }else{ target = document.getElementsByName(target_name); } jQuery(".input-focus").removeClass("input-focus"); if(typeof(target)!=='undefined'){ jQuery(target).addClass("input-focus"); jQuery(target).focus(); } } }else{ jQuery(".input-focus").focus(); } jQuery("#mb_pop_alert").hide(); jQuery("#mb_pop_alert").removeClass("mb-ani-pop-open"); jQuery("#mb_pop_html").hide(); jQuery("#mb_pop_info").hide(); if(jQuery("#mb_pop_confirm").css('display')=='none'){ jQuery("#mb_pop_bg").hide(); initLoadingBox(); } if(!scrollMode){ jQuery('body').css('overflow-y','auto'); scrollMode = true; } popupMode = "popup"; } function sendAlertCallbackData() { if(alertCallbackSend) alertCallbackSend(); else alertCallbackSend = null; } function sendConfirmCallbackData() { showLoadingBox(); jQuery("#mb_pop_confirm").hide(); if(confirmCallbackSend) confirmCallbackSend(popupCallbackData); else confirmCallbackSend = null; } function cancelConfirmCallbackData() { confirmCallbackSend = null; if(confirmCallbackCancel) confirmCallbackCancel(); else confirmCallbackCancel = null; }