From 202f6392a86f4c1fda8eb3752570e1310f4ea2da Mon Sep 17 00:00:00 2001 From: bnu Date: Wed, 10 Dec 2008 02:37:30 +0000 Subject: [PATCH] =?UTF-8?q?17523934=20*=20r5047=20=EC=9D=B4=EC=A0=84?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=90=98=EB=8F=8C=EB=A6=AC=EA=B3=A0=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5052 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- common/js/common.js | 615 ++++++++++++++++++++------------------------ 1 file changed, 283 insertions(+), 332 deletions(-) diff --git a/common/js/common.js b/common/js/common.js index a781244c7..a87a97d43 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -50,6 +50,18 @@ window.XE = { }) (jQuery); +/* jQuery(document).ready() */ +jQuery(function($) { + /* 팝업메뉴 레이어 생성 */ + if(!$('#popup_menu_area').length) { + var menuObj = $('
') + .attr('id', 'popup_menu_area') + .css({visibility:'hidden', zIndex:9999}); + $(document.body).append(menuObj); + } +}); + + /** * @brief location.href에서 특정 key의 값을 return @@ -87,7 +99,7 @@ String.prototype.setQuery = function(key, val) { for(var i in args) { if( !args.hasOwnProperty(i) ) continue; var arg = args[i]; - if(!arg || !arg.toString().trim()) continue; + if(!arg.toString().trim()) continue; q_list[q_list.length] = i+'='+arg; } @@ -116,6 +128,45 @@ 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) + **/ +function xSleep(sec) { + sec = sec / 1000; + var now = new Date(); + var sleep = new Date(); + while( sleep.getTime() - now.getTime() < sec) { + sleep = new Date(); + } +} + /** * @brief 주어진 인자가 하나라도 defined되어 있지 않으면 false return @@ -183,71 +234,7 @@ function move_url(url, open_wnidow) { return false; } -/** - * @brief 특정 Element의 display 옵션 토글 - **/ -function toggleDisplay(obj, display_type) { - var obj = xGetElementById(obj); - if(!obj) return; - if(!obj.style.display || obj.style.display != 'none') { - obj.style.display = 'none'; - } else { - if(display_type) obj.style.display = display_type; - else obj.style.display = ''; - } -} -/* jQuery의 extend. */ -/* TODO:jQuery 등 자바스크립트 프레임웍 차용시 대체 가능하면 제거 대상 */ -objectExtend = function() { - // copy reference to target object - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; - - // Handle a deep copy situation - if ( target.constructor == Boolean ) { - deep = target; - target = arguments[1] || {}; - // skip the boolean and the target - i = 2; - } - - // Handle case when target is a string or something (possible in deep copy) - if ( typeof target != "object" && typeof target != "function" ) - target = {}; - - // extend jQuery itself if only one argument is passed - if ( length == i ) { - target = this; - --i; - } - - for ( ; i < length; i++ ) - // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) - // Extend the base object - for ( var name in options ) { - var src = target[ name ], copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) - continue; - - // Recurse if we're merging object values - if ( deep && copy && typeof copy == "object" && !copy.nodeType ) - target[ name ] = objectExtend( deep, - // Never move original objects, clone them - src || ( copy.length != null ? [ ] : { } ) - , copy ); - - // Don't bring in undefined values - else if ( copy !== undefined ) - target[ name ] = copy; - - } - - // Return the modified object - return target; -}; /** * @brief 멀티미디어 출력용 (IE에서 플래쉬/동영상 주변에 점선 생김 방지용) @@ -259,15 +246,13 @@ function displayMultimedia(src, width, height, options) { wmode : 'transparent', allowScriptAccess : 'sameDomain', quality : 'high', - flashvars : '' + flashvars : '', + autostart : false }; - if(options) { - var autostart = (options.autostart) ? 'true' : 'false'; - delete(options.autostart); - } - - var params = objectExtend(defaults, options || {}); + var params = jQuery.extend(defaults, options || {}); + var autostart = (params.autostart && params.autostart != 'false') ? 'true' : 'false'; + delete(params.autostart); var clsid = ""; var codebase = ""; @@ -294,6 +279,22 @@ function displayMultimedia(src, width, height, options) { document.writeln(html); } +/** + * @brief 에디터에서 사용되는 내용 여닫는 코드 (고정, zbxe용) + **/ +function zbxe_folder_open(id) { + jQuery("#folder_open_"+id).hide(); + jQuery("#folder_close_"+id).show(); + jQuery("#folder_"+id).show(); +} +function zbxe_folder_close(id) { + jQuery("#folder_open_"+id).show(); + jQuery("#folder_close_"+id).hide(); + jQuery("#folder_"+id).hide(); +} + + + /** * @brief 팝업의 경우 내용에 맞춰 현 윈도우의 크기를 조절해줌 * 팝업의 내용에 맞게 크기를 늘리는 것은... 쉽게 되지는 않음.. ㅡ.ㅜ @@ -334,165 +335,7 @@ function setFixedPopupSize() { window.scrollTo(0,0); } -/** - * @brief 이름, 게시글등을 클릭하였을 경우 팝업 메뉴를 보여주는 함수 - **/ -xAddEventListener(window, 'load', createPopupMenu); -xAddEventListener(document, 'click', chkPopupMenu); -var loaded_popup_menus = new Array(); - -/* 멤버 팝업 메뉴 레이어를 생성하는 함수 (문서 출력이 완료되었을때 동작) */ -function createPopupMenu(evt) { - var area = xGetElementById("popup_menu_area"); - if(area) return; - area = xCreateElement("div"); - area.id = "popup_menu_area"; - area.style.visibility = 'hidden'; - area.style.zIndex = 9999; - document.body.appendChild(area); -} - -/* 클릭 이벤트 발생시 이벤트가 일어난 대상을 검사하여 적절한 규칙에 맞으면 처리 */ -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;i0 ? 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); -} - -function 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 = ""; - - if(loaded_popup_menus[menu_id]) { - html = 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'+str+' '; - } - } - } - loaded_popup_menus[menu_id] = html; - } - - // 레이어 출력 - if(html) { - var area = xGetElementById("popup_menu_area"); - xInnerHtml(area, '
    '+html+'
'); - 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"; - } -} /** * @brief 추천/비추천,스크랩,신고기능등 특정 srl에 대한 특정 module/action을 호출하는 함수 @@ -514,19 +357,7 @@ function completeMessage(ret_obj) { location.reload(); } -/** - * @brief 날짜 선택 (달력 열기) - **/ -function open_calendar(fo_id, day_str, callback_func) { - if(typeof(day_str)=="undefined") day_str = ""; - var url = "./common/tpl/calendar.php?"; - if(fo_id) url+="fo_id="+fo_id; - if(day_str) url+="&day_str="+day_str; - if(callback_func) url+="&callback_func="+callback_func; - - popopen(url, 'Calendar'); -} /* 언어코드 (lang_type) 쿠키값 변경 */ function doChangeLangType(obj) { @@ -628,7 +459,6 @@ function viewSkinInfo(module, skin) { } - /* 관리자가 문서를 관리하기 위해서 선택시 세션에 넣음 */ var addedDocument = new Array(); function doAddDocumentCart(obj) { @@ -856,107 +686,33 @@ function toggleSecuritySignIn() { else location.href = href.replace(/^http/i,'https'); } -/* 하위호환성 문제 */ -if(typeof(resizeImageContents) == 'undefined') -{ - function resizeImageContents() {} -} - function reloadDocument() { location.reload(); } -/* -------------------------- - * XE 2.0에서 제거될 함수 - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - * -------------------------- */ -/** - * @brief 에디터에서 사용되는 내용 여닫는 코드 (고정, zbxe용) - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - **/ -function zbxe_folder_open(id) { - jQuery("#folder_open_"+id).hide(); - jQuery("#folder_close_"+id).show(); - jQuery("#folder_"+id).show(); -} -function zbxe_folder_close(id) { - jQuery("#folder_open_"+id).show(); - jQuery("#folder_close_"+id).hide(); - jQuery("#folder_"+id).hide(); + + + +/* ---------------------------------------------- + * 하위호환용으로 남겨 놓음 + * ------------------------------------------- */ + +if(typeof(resizeImageContents) == 'undefined') { + function resizeImageContents() {} } +objectExtend = jQuery.extend; + /** - * @brief 에디터에서 사용하되 내용 여닫는 코드 (zb5beta beta 호환용으로 남겨 놓음) - * This feature has been DEPRECATED and REMOVED as of XE 2.0. + * @brief 특정 Element의 display 옵션 토글 **/ -function svc_folder_open(id) { - jQuery("#_folder_open_"+id).hide(); - jQuery("#_folder_close_"+id).show(); - jQuery("#_folder_"+id).show(); -} -function svc_folder_close(id) { - jQuery("#_folder_open_"+id).show(); - jQuery("#_folder_close_"+id).hide(); - jQuery("#_folder_"+id).hide(); +function toggleDisplay(obj) { + jQuery('#'+obj).toggle(); } -/** - * @breif replace outerHTML - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - **/ -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 - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - **/ -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) - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - **/ -function xSleep(sec) { - sec = sec / 1000; - var now = new Date(); - var sleep = new Date(); - while( sleep.getTime() - now.getTime() < sec) { - sleep = new Date(); - } -} - -/* 체크박스를 실행 - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - */ -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(); - } -} - -/* 체크박스 선택 - * This feature has been DEPRECATED and REMOVED as of XE 2.0. - */ +/* 체크박스 선택 */ function checkboxSelectAll(form, name, option){ var value; var fo_obj = xGetElementById(form); @@ -976,4 +732,199 @@ function checkboxSelectAll(form, name, option){ if(fo_obj[i].name == name) fo_obj[i].checked = value; } +} + +/* 체크박스를 실행 */ +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(); + } +} + +/** + * @brief 에디터에서 사용하되 내용 여닫는 코드 (zb5beta beta 호환용으로 남겨 놓음) + **/ +function svc_folder_open(id) { + jQuery("#_folder_open_"+id).hide(); + jQuery("#_folder_close_"+id).show(); + jQuery("#_folder_"+id).show(); +} +function svc_folder_close(id) { + jQuery("#_folder_open_"+id).show(); + jQuery("#_folder_close_"+id).hide(); + jQuery("#_folder_"+id).hide(); +} + +/** + * @brief 날짜 선택 (달력 열기) + **/ +function open_calendar(fo_id, day_str, callback_func) { + if(typeof(day_str)=="undefined") day_str = ""; + + var url = "./common/tpl/calendar.php?"; + if(fo_id) url+="fo_id="+fo_id; + if(day_str) url+="&day_str="+day_str; + if(callback_func) url+="&callback_func="+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('
') + .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;i0 ? 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); +} + +function 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 = ""; + + if(loaded_popup_menus[menu_id]) { + html = 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'+str+' '; + } + } + } + loaded_popup_menus[menu_id] = html; + } + + // 레이어 출력 + if(html) { + var area = xGetElementById("popup_menu_area"); + xInnerHtml(area, '
    '+html+'
'); + 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"; + } } \ No newline at end of file