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+'
'; jQuery("body").append(popup_html); }); var confirmCallbackSend; var confirmCallbackCancel; var alertCallbackSend; var popupCallbackData; var select_menu = ""; var eventX = 0; var eventY = 0; function setPopupScrollEvent(){ jQuery(window).on({ 'mousewheel': function(e){ setPopupPosition(); },'scroll': function(e){ setPopupPosition(); } }) } function setPopupPosition(){ var popupObj = jQuery("#mb_pop_confirm"); popupObj.css('left',(jQuery(document).width()-popupObj.outerWidth())/2); popupObj.css('top',(jQuery(document).scrollTop()+(jQuery(window).height()-popupObj.outerHeight())/2)); popupObj = jQuery("#mb_pop_alert"); popupObj.css('left',(jQuery(document).width()-popupObj.outerWidth())/2); popupObj.css('top',(jQuery(document).scrollTop()+(jQuery(window).height()-popupObj.outerHeight())/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+'
'; showPopupBox("Confirm",pop_head,pop_body); } function showAlertPopup(response,send){ var code = ""; var message = ""; 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; 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){ 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(); }else if(type=="Info"){ popupID = "#mb_pop_info"; }else if(type=="Confirm"){ popupID = "#mb_pop_confirm"; }else{ popupID = "#mb_pop_alert"; } 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){ jQuery('#mb_pop_bg').height(jQuery(document).height()); jQuery("#mb_pop_bg").show(); } jQuery(popupID).show(); if(type=="Alert"){ jQuery("#mb_pop_alert_ok").focus(); }else if(type=="Confirm"){ jQuery("#mb_confirm_passwd").focus(); } } function getUserMenu(uid,pid){ var menu_options = "*"; if(select_menu==uid+"_"+pid){ select_menu = ""; hideInfoBox(); }else{ sendUserMenu(uid,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,option,event){ if(typeof(event)!=='undefined'){ eventX = event.clientX; eventY = event.clientY; } if(option=="*") option = "search,info,email,homepage,blog"; var param = "mode=user&board_action=menu&board_name="+mb_options["board_name"]+"&pid="+uid+"&option="+option+"&list_type="+mb_options["list_type"]; for(i=1;i<=mb_categorys.length;i++){ mb_categorys["value"+i] = jQuery("#"+mb_options["board_name"]+"_category"+i+" option:selected").val(); if(typeof(mb_categorys["value"+i])!='undefined' && mb_categorys["value"+i]!="") param = param+"&category"+i+"="+param["value"+i]; } 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() { jQuery(".input-focus").removeClass("input-focus"); jQuery("#mb_pop_confirm").hide(); jQuery("#mb_pop_bg").hide(); } function showAlertCallback(code,target_name) { hidePopupAlert(code,target_name); sendAlertCallbackData(); } function hidePopupAlert(code,target_name) { if(typeof(code)!=='undefined' && code!=='undefined'){ 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(); if(jQuery("#mb_pop_confirm").css('display')=='none') jQuery("#mb_pop_bg").hide(); } function sendAlertCallbackData() { if(alertCallbackSend) alertCallbackSend(); else alertCallbackSend = null; } function sendConfirmCallbackData() { if(confirmCallbackSend) confirmCallbackSend(popupCallbackData); else confirmCallbackSend = null; } function cancelConfirmCallbackData() { if(confirmCallbackCancel) confirmCallbackCancel(); else confirmCallbackCancel = null; }