17523934 * common.js 정리

* XE.checkboxToggleAll() 에서 options.wrapId를 options.wrap으로 element 객체를 받도록 변경
  * displayPopupMenu()을 XE안으로 옮김
  * chkPopupMenu()을 제거하고 jQuery.ready() 안으로 이동
  * setFixedPopupSize() 함수 수정. 크롬의 비정상 동작으로 창 크기를 잘못 조정하는 문제 잔존

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5068 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2008-12-14 04:18:01 +00:00
parent fb03b239bc
commit f19a281368

View file

@ -7,58 +7,259 @@
/* jQuery 참조변수($) 제거 */
if(jQuery) jQuery.noConflict();
/**
* @brief XE 공용 유틸리티 함수
* @namespace XE
*/
;(function($) {
window.XE = {
/**
* @brief 특정 name을 가진 체크박스들의 checked 속성 변경
* @param [itemName='cart',][options={checked:true, doClick:false}]
* @brief XE 공용 유틸리티 함수
* @namespace XE
*/
checkboxToggleAll : function() {
var itemName='cart', options={wrapId:'', checked:'toggle', doClick:false};
window.XE = {
loaded_popup_menus : new Array(),
addedDocument : new Array(),
/**
* @brief 특정 name을 가진 체크박스들의 checked 속성 변경
* @param [itemName='cart',][options={}]
*/
checkboxToggleAll : function() {
var itemName='cart';
var options = {
wrap : null,
checked : 'toggle',
doClick : false
};
switch(arguments.length) {
case 1:
if(typeof(arguments[0]) == "string") {
switch(arguments.length) {
case 1:
if(typeof(arguments[0]) == "string") {
itemName = arguments[0];
} else {
$.extend(options, arguments[0] || {});
}
break;
case 2:
itemName = arguments[0];
} else {
options = $.extend(options, arguments[0] || {});
$.extend(options, arguments[1] || {});
}
if(options.doClick == true) options.checked = null;
if(typeof(options.wrap) == "string") options.wrap ='#'+options.wrap;
if(options.wrap) {
var obj = $(options.wrap).find('input[name='+itemName+']:checkbox');
} else {
var obj = $('input[name='+itemName+']:checkbox');
}
if(options.checked == 'toggle') {
obj.each(function() {
$(this).attr('checked', ($(this).attr('checked')) ? false : true);
});
} else {
(options.doClick == true) ? obj.click() : obj.attr('checked', options.checked);
}
},
/**
* @brief 문서/회원 팝업 메뉴 출력
*/
displayPopupMenu : function(ret_obj, response_tags, params) {
var target_srl = params["target_srl"];
var menu_id = params["menu_id"];
var menus = ret_obj['menus'];
var html = "";
if(this.loaded_popup_menus[menu_id]) {
html = this.loaded_popup_menus[menu_id];
} else {
if(menus) {
var item = menus['item'];
if(typeof(item.length)=='undefined' || item.length<1) item = new Array(item);
if(item.length) {
for(var i=0;i<item.length;i++) {
var url = item[i].url;
var str = item[i].str;
var icon = item[i].icon;
var target = item[i].target;
var styleText = "";
var click_str = "";
if(icon) styleText = " style=\"background-image:url('"+icon+"')\" ";
switch(target) {
case "popup" :
click_str = " onclick=\"popopen(this.href,'"+target+"'); return false;\"";
break;
case "self" :
//click_str = " onclick=\"location.href='"+url+"' return false;\"";
break;
case "javascript" :
click_str = " onclick=\""+url+"; return false; \"";
url="#";
break;
default :
click_str = " onclick=\"window.open(this.href); return false;\"";
break;
}
html += '<li '+styleText+'><a href="'+url+'"'+click_str+'>'+str+'</a></li> ';
}
}
}
break;
case 2:
itemName = arguments[0];
options = $.extend(options, arguments[1] || {});
}
this.loaded_popup_menus[menu_id] = html;
}
if(options.doClick == true) options.checked = null;
if(options.wrapId) options.wrapId ='#'+options.wrapId+' ';
// 레이어 출력
if(html) {
var area = jQuery("#popup_menu_area").html('<ul>'+html+'</ul>');
var areaOffset = {top:params['page_y'], left:params['page_x']};
var obj = $(options.wrapId+'input[name='+itemName+']:checkbox');
if(area.outerHeight()+areaOffset.top > jQuery(window).height()+jQuery(window).scrollTop())
areaOffset.top = jQuery(window).height() - area.outerHeight() + jQuery(window).scrollTop();
if(area.outerWidth()+areaOffset.left > jQuery(window).width()+jQuery(window).scrollLeft())
areaOffset.left = jQuery(window).width() - area.outerWidth() + jQuery(window).scrollLeft();
if(options.checked == 'toggle') {
obj.each(function() {
$(this).attr('checked', ($(this).attr('checked')) ? false : true);
});
} else {
(options.doClick == true) ? obj.click() : obj.attr('checked', options.checked);
area.css({ visibility:"visible", top:areaOffset.top, left:areaOffset.left });
}
}
}
}
}) (jQuery);
/**
* jQuery 플러그인 로드
* 시험중
*/
$.getPlugin = function(name, options) {
$.loaded_plugin = new Array();
var version = '';
var defaults = {
version:'',
prefix:'jquery.',
path:'./common/js/jquery/'
};
var options = $.extend(defaults, options || {});
if(options.version) version = '-' + options.version;
$.ajax({
type: 'GET',
url : options.path + options.prefix + name + version + '.js',
cache : true,
async:false,
success : function() {
$.loaded_plugin[name] = {'version':options.version};
},
dataType : 'script'
});
}
}) (jQuery);
/* jQuery(document).ready() */
jQuery(function($) {
/* 팝업메뉴 레이어 생성 */
if(!$('#popup_menu_area').length) {
var menuObj = $('<div>')
.attr('id', 'popup_menu_area')
.css({visibility:'hidden', zIndex:9999});
$(document.body).append(menuObj);
}
/* 팝업메뉴 레이어 생성 */
if(!$('#popup_menu_area').length) {
var menuObj = $('<div>')
.attr('id', 'popup_menu_area')
.css({visibility:'hidden', zIndex:9999});
$(document.body).append(menuObj);
}
$(document).click(function(evt) {
var area = jQuery("#popup_menu_area");
if(!area.length) return;
// 이전에 호출되었을지 모르는 팝업메뉴 숨김
area.css('visibility', 'hidden');
var targetObj = $(evt.target);
if(!targetObj.length) return;
// obj의 nodeName이 div나 span이 아니면 나올대까지 상위를 찾음
if(targetObj.length && jQuery.inArray(targetObj.attr('nodeName'), ['DIV', 'SPAN', 'A']) == -1) targetObj = targetObj.parent();
if(!targetObj.length || jQuery.inArray(targetObj.attr('nodeName'), ['DIV', 'SPAN', 'A']) == -1) return;
// 객체의 className값을 구함
var class_name = targetObj.attr('className');
if(class_name.indexOf('_') <= 0) return;
// className을 분리
var class_name_list = class_name.split(' ');
var menu_id = '';
var menu_id_regx = /^([a-zA-Z]+)_([0-9]+)$/;
for(var i = 0, c = class_name_list.length; i < c; i++) {
if(menu_id_regx.test(class_name_list[i])) {
menu_id = class_name_list[i];
}
}
if(!menu_id) return;
// module명과 대상 번호가 없으면 return
var tmp_arr = menu_id.split('_');
var module_name = tmp_arr[0];
var target_srl = tmp_arr[1];
if(!module_name || !target_srl || target_srl < 1) return;
// action이름을 규칙에 맞게 작성
var action_name = "get" + module_name.substr(0,1).toUpperCase() + module_name.substr(1,module_name.length-1) + "Menu";
// 서버에 메뉴를 요청
var params = new Array();
params["target_srl"] = target_srl;
params["cur_mid"] = current_mid;
params["cur_act"] = current_url.getQuery('act');
params["menu_id"] = menu_id;
params["page_x"] = evt.pageX;
params["page_y"] = evt.pageY;
var response_tags = new Array("error","message","menus");
if(typeof(XE.loaded_popup_menus[menu_id]) != 'undefined') {
XE.displayPopupMenu(params, response_tags, params);
return;
}
show_waiting_message = false;
exec_xml(module_name, action_name, params, XE.displayPopupMenu, response_tags, params);
show_waiting_message = true;
});
/* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */
if($.browser.msie) {
$('select').each(function(i, sels) {
var disabled_exists = false;
var first_enable = new Array();
for(var j=0; j < sels.options.length; j++) {
if(sels.options[j].disabled) {
sels.options[j].style.color = '#CCCCCC';
disabled_exists = true;
}else{
first_enable[i] = (first_enable[i] > -1) ? first_enable[i] : j;
}
}
if(!disabled_exists) return;
sels.oldonchange = sels.onchange;
sels.onchange = function() {
if(this.options[this.selectedIndex].disabled) {
this.selectedIndex = first_enable[i];
/*
if(this.options.length<=1) this.selectedIndex = -1;
else if(this.selectedIndex < this.options.length - 1) this.selectedIndex++;
else this.selectedIndex--;
*/
} else {
if(this.oldonchange) this.oldonchange();
}
};
if(sels.selectedIndex >= 0 && sels.options[ sels.selectedIndex ].disabled) sels.onchange();
});
}
});
@ -70,7 +271,7 @@ String.prototype.getQuery = function(key) {
var idx = this.indexOf('?');
if(idx == -1) return null;
var query_string = this.substr(idx+1, this.length);
var args = {}
var args = {};
query_string.replace(/([^=]+)=([^&]*)(&|$)/g, function() { args[arguments[1]] = arguments[2]; });
var q = args[key];
@ -128,33 +329,6 @@ String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
/**
* @breif replace outerHTML
**/
function replaceOuterHTML(obj, html) {
if(obj.outerHTML) {
obj.outerHTML = html;
} else {
var dummy = xCreateElement("div");
xInnerHtml(dummy, html);
var parent = obj.parentNode;
while(dummy.firstChild) {
parent.insertBefore(dummy.firstChild, obj);
}
parent.removeChild(obj);
}
}
/**
* @breif get outerHTML
**/
function getOuterHTML(obj) {
if(obj.outerHTML) return obj.outerHTML;
var dummy = xCreateElement("div");
dummy.insertBefore(obj, dummy.lastChild);
return xInnerHtml(dummy);
}
/**
* @brief xSleep(micro time)
**/
@ -167,13 +341,12 @@ function xSleep(sec) {
}
}
/**
* @brief 주어진 인자가 하나라도 defined되어 있지 않으면 false return
**/
function isDef() {
for(var i=0; i<arguments.length; ++i) {
if(typeof(arguments[i])=="undefined") return false;
for(var i=0; i < arguments.length; ++i) {
if(typeof(arguments[i]) == "undefined") return false;
}
return true;
}
@ -192,8 +365,8 @@ function winopen(url, target, attribute) {
} catch(e) {
}
if(typeof(target)=='undefined') target = '_blank';
if(typeof(attribute)=='undefined') attribute = '';
if(typeof(target) == 'undefined') target = '_blank';
if(typeof(attribute) == 'undefined') attribute = '';
var win = window.open(url, target, attribute);
win.focus();
if(target != "_blank") winopen_list[target] = win;
@ -204,7 +377,7 @@ function winopen(url, target, attribute) {
* common/tpl/popup_layout.html이 요청되는 XE내의 팝업일 경우에 사용
**/
function popopen(url, target) {
if(typeof(target)=="undefined") target = "_blank";
if(typeof(target) == "undefined") target = "_blank";
winopen(url, target, "left=10,top=10,width=10,height=10,scrollbars=no,resizable=yes,toolbars=no");
}
@ -220,9 +393,12 @@ function sendMailTo(to) {
**/
function move_url(url, open_wnidow) {
if(!url) return false;
if(typeof(open_wnidow)=='undefined') open_wnidow = 'N';
if(open_wnidow=='N') open_wnidow = false;
else open_wnidow = true;
if(typeof(open_wnidow) == 'undefined') open_wnidow = 'N';
if(open_wnidow=='N') {
open_wnidow = false;
} else {
open_wnidow = true;
}
if(/^\./.test(url)) url = request_uri+url;
@ -231,11 +407,10 @@ function move_url(url, open_wnidow) {
} else {
location.href=url;
}
return false;
}
/**
* @brief 멀티미디어 출력용 (IE에서 플래쉬/동영상 주변에 점선 생김 방지용)
**/
@ -293,50 +468,37 @@ function zbxe_folder_close(id) {
jQuery("#folder_"+id).hide();
}
/**
* @brief 팝업의 경우 내용에 맞춰 윈도우의 크기를 조절해줌
* 팝업의 내용에 맞게 크기를 늘리는 것은... 쉽게 되지는 않음.. .
* popup_layout 에서 window.onload 자동 요청됨.
* @FIXME 크롬에서 resizeTo()후에 크기를 잘못 가져옴
* resizeTo() 후에 alert() 띄운 후에 체크하면 정상.
**/
function setFixedPopupSize() {
var bodyObj = jQuery('#popBody');
if(xGetElementById('popBody')) {
if(xHeight('popBody')>500) {
xGetElementById('popBody').style.overflowY = 'scroll';
xGetElementById('popBody').style.overflowX = 'hidden';
xHeight('popBody', 500);
if(bodyObj.length) {
if(bodyObj.height() > 500) {
bodyObj.css({ overflowY:'scroll', overflowX:'hidden', height:500 });
}
}
var w = xWidth("popup_content");
var h = xHeight("popup_content");
var wrapWidth = jQuery(document).width();
var wrapHeight = jQuery(document).height();
var obj_list = xGetElementsByTagName('div');
for(i=0;i<obj_list.length;i++) {
var ww = xWidth(obj_list[i]);
var id = obj_list[i].id;
if(id == 'waitingforserverresponse' || id == 'fororiginalimagearea' || id == 'fororiginalimageareabg') continue;
if(ww>w) w = ww;
}
window.resizeTo(wrapWidth, wrapHeight);
// 윈도우에서는 브라우저 상관없이 가로 픽셀이 조금 더 늘어나야 한다.
if(xUA.indexOf('windows')>0) {
if(xOp7Up) w += 10;
else if(xIE4Up) w += 10;
else w += 6;
}
window.resizeTo(w,h);
var w1 = jQuery(window).width();
var h1 = jQuery(window).height();
var h1 = xHeight(window.document.body);
window.resizeBy(0,h-h1);
// 크롬의 문제로 W, H 값을 따로 설정
// window.resizeBy(wrapWidth - w1, wrapHeight-h1);
window.resizeBy(wrapWidth - w1, 0);
window.resizeBy(0, wrapHeight-h1);
window.scrollTo(0,0);
window.scrollTo(0, 0);
}
/**
* @brief 추천/비추천,스크랩,신고기능등 특정 srl에 대한 특정 module/action을 호출하는 함수
**/
@ -361,7 +523,7 @@ function completeMessage(ret_obj) {
/* 언어코드 (lang_type) 쿠키값 변경 */
function doChangeLangType(obj) {
if(typeof(obj)=="string") {
if(typeof(obj) == "string") {
setLangType(obj);
} else {
var val = obj.options[obj.selectedIndex].value;
@ -386,20 +548,20 @@ function doDocumentPreview(obj) {
var content = editorGetContent(editor_sequence);
var win = window.open("","previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");
var win = window.open("", "previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");
var dummy_obj = xGetElementById("previewDocument");
var dummy_obj = jQuery("#previewDocument");
if(!dummy_obj) {
var fo_code = '<form id="previewDocument" target="previewDocument" method="post" action="'+request_uri+'">'+
'<input type="hidden" name="module" value="document" />'+
'<input type="hidden" name="act" value="dispDocumentPreview" />'+
'<input type="hidden" name="content" />'+
'</form>';
var dummy = xCreateElement("DIV");
xInnerHtml(dummy, fo_code);
window.document.body.insertBefore(dummy,window.document.body.lastChild);
dummy_obj = xGetElementById("previewDocument");
if(!dummy_obj.length) {
jQuery(
'<form id="previewDocument" target="previewDocument" method="post" action="'+request_uri+'">'+
'<input type="hidden" name="module" value="document" />'+
'<input type="hidden" name="act" value="dispDocumentPreview" />'+
'<input type="hidden" name="content" />'+
'</form>'
).appendTo(document.body);
dummy_obj = jQuery("#previewDocument")[0];
}
if(dummy_obj) {
@ -428,7 +590,7 @@ function doDocumentSave(obj) {
}
function completeDocumentSave(ret_obj) {
xGetElementsByAttribute('input', 'name', 'document_srl')[0].value = ret_obj['document_srl'];
jQuery('input[name=document_srl]').eq(0).val(ret_obj['document_srl']);
alert(ret_obj['message']);
}
@ -493,6 +655,18 @@ function transRGB2Hex(value) {
return hex;
}
/* 보안 로그인 모드로 전환 */
function toggleSecuritySignIn() {
var href = location.href;
if(/https:\/\//i.test(href)) location.href = href.replace(/^https/i,'http');
else location.href = href.replace(/^http/i,'https');
}
function reloadDocument() {
location.reload();
}
/**
*
* Base64 encode / decode
@ -636,66 +810,13 @@ var Base64 = {
}
/* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */
if(xIE4Up) {
xAddEventListener(window, 'load', activateOptionDisabled);
function activateOptionDisabled(evt) {
var sels = xGetElementsByTagName('select');
for(var i=0; i < sels.length; i++){
var disabled_exists = false;
var first_enable = new Array();
for(var j=0; j < sels[i].options.length; j++) {
if(sels[i].options[j].disabled) {
sels[i].options[j].style.color = '#CCCCCC';
disabled_exists = true;
}else{
first_enable[i] = first_enable[i]>-1? first_enable[i] : j;
}
}
if(!disabled_exists) continue;
sels[i].oldonchange = sels[i].onchange;
sels[i].onchange = function() {
if(this.options[this.selectedIndex].disabled) {
this.selectedIndex = first_enable[i];
/*
if(this.options.length<=1) this.selectedIndex = -1;
else if(this.selectedIndex < this.options.length - 1) this.selectedIndex++;
else this.selectedIndex--;
*/
} else {
if(this.oldonchange) this.oldonchange();
}
}
if(sels[i].selectedIndex >= 0 && sels[i].options[ sels[i].selectedIndex ].disabled) sels[i].onchange();
}
}
}
/* 보안 로그인 모드로 전환 */
function toggleSecuritySignIn() {
var href = location.href;
if(/https:\/\//i.test(href)) location.href = href.replace(/^https/i,'http');
else location.href = href.replace(/^http/i,'https');
}
function reloadDocument() {
location.reload();
}
/* ----------------------------------------------
* DEPRECATED
* 하위호환용으로 남겨 놓음
* ------------------------------------------- */
@ -703,43 +824,36 @@ if(typeof(resizeImageContents) == 'undefined') {
function resizeImageContents() {}
}
if(typeof(activateOptionDisabled) == 'undefined') {
function activateOptionDisabled() {}
}
objectExtend = jQuery.extend;
/**
* @brief 특정 Element의 display 옵션 토글
**/
function toggleDisplay(obj) {
jQuery('#'+obj).toggle();
function toggleDisplay(objId) {
jQuery('#'+objId).toggle();
}
/* 체크박스 선택 */
function checkboxSelectAll(form, name, option){
var value;
var fo_obj = xGetElementById(form);
for ( var i = 0 ; i < fo_obj.length ; i++ ){
if(typeof(option) == "undefined") {
var select_mode = fo_obj[i].checked;
if ( select_mode == 0 ){
value = true;
select_mode = 1;
}else{
value = false;
select_mode = 0;
}
}
else if(option == true) value = true
else if(option == false) value = false
function checkboxSelectAll(formObj, name, checked) {
var itemName = name;
var option = {};
if(typeof(formObj) != "undefined") option.wrap = formObj;
if(typeof(checked) != "undefined") option.checked = checked;
if(fo_obj[i].name == name) fo_obj[i].checked = value;
}
XE.checkboxToggleAll(itemName, option);
}
/* 체크박스를 실행 */
function clickCheckBoxAll(form, name) {
var fo_obj = xGetElementById(form);
for ( var i = 0 ; i < fo_obj.length ; i++ ){
if(fo_obj[i].name == name) fo_obj[i].click();
}
function clickCheckBoxAll(formObj, name) {
var itemName = name;
var option = { doClick:true };
if(typeof(formObj) != "undefined") option.wrap = formObj;
XE.checkboxToggleAll(itemName, option);
}
/**
@ -770,161 +884,24 @@ function open_calendar(fo_id, day_str, callback_func) {
popopen(url, 'Calendar');
}
/**
* @brief 이름, 게시글등을 클릭하였을 경우 팝업 메뉴를 보여주는 함수
**/
//xAddEventListener(window, 'load', createPopupMenu);
xAddEventListener(document, 'click', chkPopupMenu);
var loaded_popup_menus = new Array();
/* 멤버 팝업 메뉴 레이어를 생성하는 함수 (문서 출력이 완료되었을때 동작) */
function createPopupMenu(evt) {
if(!jQuery('#popup_menu_area').length) {
var menuObj = jQuery('<div>')
.attr('id', 'popup_menu_area')
.css({visibility:'hidden', zIndex:9999});
jQuery(document.body).append(menuObj);
}
}
/* 클릭 이벤트 발생시 이벤트가 일어난 대상을 검사하여 적절한 규칙에 맞으면 처리 */
function chkPopupMenu(evt) {
// 이전에 호출되었을지 모르는 팝업메뉴 숨김
var area = xGetElementById("popup_menu_area");
if(!area) return;
if(area.style.visibility != "hidden") area.style.visibility = "hidden";
// 이벤트 대상이 없으면 무시
var e = new xEvent(evt);
if(!e) return;
// 대상의 객체 구함
var obj = e.target;
if(!obj) return;
// obj의 nodeName이 div나 span이 아니면 나올대까지 상위를 찾음
if(obj && obj.nodeName != 'DIV' && obj.nodeName != 'SPAN' && obj.nodeName != 'A') obj = obj.parentNode;
if(!obj || (obj.nodeName != 'DIV' && obj.nodeName != 'SPAN' && obj.nodeName != 'A')) return;
// 객체의 className값을 구함
var class_name = obj.className;
if(!class_name) return;
// className을 분리
var class_name_list = class_name.split(' ');
var menu_id = '';
var menu_id_regx = /^([a-zA-Z]+)_([0-9]+)$/;
for(var i=0,c=class_name_list.length;i<c;i++) {
if(menu_id_regx.test(class_name_list[i])) {
menu_id = class_name_list[i];
}
}
if(!menu_id) return;
// module명과 대상 번호가 없으면 return
var tmp_arr = menu_id.split('_');
var module_name = tmp_arr[0];
var target_srl = tmp_arr[1];
if(!module_name || !target_srl || target_srl < 1) return;
// action이름을 규칙에 맞게 작성
var action_name = "get" + module_name.substr(0,1).toUpperCase() + module_name.substr(1,module_name.length-1) + "Menu";
// 서버에 메뉴를 요청
var params = new Array();
params["target_srl"] = target_srl;
params["cur_mid"] = current_mid;
params["cur_act"] = current_url.getQuery('act');
params["menu_id"] = menu_id;
params["page_x"] = e.pageX >0 ? e.pageX : GetObjLeft(obj);
params["page_y"] = e.pageY >0 ? e.pageY : GetObjTop(obj)+ xHeight(obj);
var response_tags = new Array("error","message","menus");
if(loaded_popup_menus[menu_id]) {
displayPopupMenu(params, response_tags, params);
return;
}
show_waiting_message = false;
exec_xml(module_name, action_name, params, displayPopupMenu, response_tags, params);
show_waiting_message = true;
}
function GetObjTop(obj) {
if(obj.offsetParent == document.body) return xOffsetTop(obj);
else return xOffsetTop(obj) + GetObjTop(obj.offsetParent);
}
function GetObjLeft(obj) {
if(obj.offsetParent == document.body) return xOffsetLeft(obj);
else return xOffsetLeft(obj) + GetObjLeft(obj.offsetParent);
}
var loaded_popup_menus = XE.loaded_popup_menus;
function createPopupMenu() {}
function chkPopupMenu() {}
function displayPopupMenu(ret_obj, response_tags, params) {
XE.displayPopupMenu(ret_obj, response_tags, params);
}
var target_srl = params["target_srl"];
var menu_id = params["menu_id"];
var menus = ret_obj['menus'];
var html = "";
function GetObjLeft(obj) {
return jQuery(obj).offset().left;
}
function GetObjTop(obj) {
return jQuery(obj).offset().top;
}
if(loaded_popup_menus[menu_id]) {
html = loaded_popup_menus[menu_id];
function replaceOuterHTML(obj, html) {
jQuery(obj).replaceWith(html);
}
} else {
if(menus) {
var item = menus['item'];
if(typeof(item.length)=='undefined' || item.length<1) item = new Array(item);
if(item.length) {
for(var i=0;i<item.length;i++) {
var url = item[i].url;
var str = item[i].str;
var icon = item[i].icon;
var target = item[i].target;
var styleText = "";
var click_str = "";
if(icon) styleText = " style=\"background-image:url('"+icon+"')\" ";
switch(target) {
case "popup" :
click_str = " onclick=\"popopen(this.href,'"+target+"'); return false;\"";
break;
case "self" :
//click_str = " onclick=\"location.href='"+url+"' return false;\"";
break;
case "javascript" :
click_str = " onclick=\""+url+"; return false; \"";
url="#";
break;
default :
click_str = " onclick=\"window.open(this.href); return false;\"";
break;
}
html += '<li '+styleText+'><a href="'+url+'"'+click_str+'>'+str+'</a></li> ';
}
}
}
loaded_popup_menus[menu_id] = html;
}
// 레이어 출력
if(html) {
var area = xGetElementById("popup_menu_area");
xInnerHtml(area, '<ul>'+html+'</ul>');
xLeft(area, params["page_x"]);
xTop(area, params["page_y"]);
if(xWidth(area)+xLeft(area)>xClientWidth()+xScrollLeft()) xLeft(area, xClientWidth()-xWidth(area)+xScrollLeft());
if(xHeight(area)+xTop(area)>xClientHeight()+xScrollTop()) xTop(area, xClientHeight()-xHeight(area)+xScrollTop());
area.style.visibility = "visible";
}
function getOuterHTML(obj) {
return jQuery(obj).html().trim();
}