/*------------------------------------------------------------------------------ * 1. ÆÄÀϸí: ui.js * 2. ¼³ ¸í: UI Á¶Àý°ú °ü·ÃµÈ ÇÔ¼ö¸¦ Á¤ÀÇÇÑ´Ù. * 3. ÀÇÁ¸¼º: form.js, ui.js * 4. ÀÛ¼ºÀÚ: * 5. ÀÛ¼ºÀÏ: 2006.10.17. -----------------------------------------------------------------------------*/ /* 2007.05.10 * Object(¹öư)ÀÇ Å¬·¡½º¸¦ Åä±Û·Î normal°ú over·Î ¹Ù²ãÁØ´Ù. */ function toggleButtonClassName(btnElement) { var normalClassName = "normal"; var overClassName = "over"; if (btnElement.className == normalClassName) { Element.removeClassName(btnElement, normalClassName); Element.addClassName(btnElement, overClassName); } else if (btnElement.className == overClassName){ Element.removeClassName(btnElement, overClassName); Element.addClassName(btnElement, normalClassName); } } // ¸ñ·Ï¿¡¼­ ¼±ÅÃµÈ ¿ä¼ÒÀÇ ÇÏÀ̶óÀÌÆ® »ö»ó var SELECTED_BG_COLOR = "#99CCFF"; /** * ÇØ´ç objectÀÇ ÀÚ½Ä ³ëµåÀÇ ½ºÅ¸ÀÏÀ» ¸ðµÎ ÁöÁ¤ »ö»óÀ¸·Î ¹Ù²Û´Ù. * */ function changeAllChildNodesColor(obj, color) { if (obj != null) { var size = obj.childNodes.length; for (i = 0; i < size; i++) { var childEl = obj.childNodes[i]; // Not Recursive! try { childEl.style.background = color; } catch (doNotApplyStyle) {} } } } /** * ÁÖ¾îÁø ³ôÀ̸¦ È­¸éÀÇ °¡¿îµ¥ ³õ±âÀ§ÇÑ * Top À§Ä¡ °ªÀ» µ¹·Á ÁØ´Ù. */ function calcTopForCenter(height) { return ( screen.height - height ) / 2; } /** * ÁÖ¾îÁø ÆøÀ» È­¸éÀÇ °¡¿îµ¥ ³õ±â À§ÇÑ * Left À§Ä¡ °ªÀ» µ¹·Á ÁØ´Ù. */ function calcLeftForCenter(width) { return ( screen.width - width ) / 2; } /** * ´ëÈ­ âÀ» ¶ç¿î´Ù. */ function showDialog(name, url, width, height, option) { option = "width=" + width + ",height=" + height + ",alwaysRaised=yes" + ",dependent=yes" + (option == undefined || option.length == 0 ? "" : "," + option); return showWindow(name, url, width, height, option); } /** * À©µµ¿ì¸¦ ÁÖ¾îÁø ÁÂÇ¥¿¡ ¶ç¿î´Ù. À§Ä¡°¡ ÁÖ¾îÁöÁö ¾ÊÀ¸¸é * À©µµ¿ì°¡ È­¸é °¡¿îµ¥ ¿Àµµ·Ï ¶ç¿î´Ù. */ function showWindow(name, url, width, height, option, topPx, leftPx) { if ( ! topPx ) topPx = calcTopForCenter(height); if ( ! leftPx ) leftPx = calcLeftForCenter(width); var win = window.open(url, name, option); win.moveTo(leftPx, topPx); if ( win ) win.focus(); return win; } /** * ¸Þ¼¼Áö âÀ» ¶ç¿ö ÁÖ¾îÁø ¸Þ¼¼Áö¸¦ º¸¿© ÁØ´Ù. */ function showMessage(msg) { alert(msg); } /** * System ¸Þ¼¼Áö¸¦ º¸¿© ÁØ´Ù. */ function showSysMessage(msg) { alert("System ¸Þ¼¼Áö: " + msg); } /** * ÁÖ¾îÁø Select °´Ã¼ÀÇ °ªÀ» Input °´Ã¼¿¡ ¼¼ÆÃÇϰí * ´ÙÀ½ ÀÔ·Â Ç׸ñÀ¸·Î ³Ñ¾î°£´Ù. */ function setSelectedValueAndMoveNext(moveOrderIdList, selectObj, inputObj) { ref(inputObj).value = getSelectedValue(selectObj); moveNext(moveOrderIdList, ref(inputObj).id); } /** * ´ÙÀ½ Ç׸ñÀ¸·Î À̵¿ÇÑ´Ù. * À̵¿½Ã disable »óÅÂÀ̰ųª, º¸ÀÌÁö ¾Ê´Â »óÅÂ(display: none)À̸é * ÀÌ Ç׸ñÀº °Ç³Ê ¶è´Ù. * * @param moveOrderIdList À̵¿ÇÒ Ç׸ñÀÇ ID ¹è¿­. * @param currentPositionId ÇöÀç À§Ä¡ ID. ¹è¿­¿¡¼­ ÀÌ ID ´ÙÀ½ ID·Î À̵¿ÇÑ´Ù. */ function moveNext(moveOrderIdList, currentPositionId) { var index = indexInArray(moveOrderIdList, currentPositionId); if ( index == -1 ) alert("ID " + currentPositionId + "´Â À̵¿ ¸ñ·Ï(moveOrderIdList)¿¡ ¾ø½À´Ï´Ù."); var nextIndex = -1; var i = (index + 1) % moveOrderIdList.length; for ( var count = 0; count < moveOrderIdList.length; count++, i = ((++i) % moveOrderIdList.length) ) { var obj = ref(moveOrderIdList[i]); if ( obj != undefined && obj != null && ! obj.disabled ) { nextIndex = i; break; } } //alert(index + " -> " + nextIndex + " : " + moveOrderIdList[nextIndex]); if ( nextIndex > -1 ) { ref(moveOrderIdList[nextIndex]).focus(); ref(moveOrderIdList[nextIndex]).select(); } } /** * ´­·ÁÁø Key°¡ EnterÀ̸é * ´ÙÀ½ Ç׸ñÀ¸·Î À̵¿ÇÑ´Ù. */ function moveNextIfEnter(moveOrderIdList, currentId) { if ( event.keyCode == 13 ) { moveNext(moveOrderIdList, currentId); } event.returnValue = ( event.keyCode != 13 ); } function moveNextIfCtrlEnter(moveOrderIdList, currentId) { if ( event.keyCode == 13 && event.ctrlKey ) { moveNext(moveOrderIdList, currentId); } event.returnValue = ! ( event.keyCode == 13 && event.ctrlKey ); } /** * ÁÖ¾îÁø FormÀÇ ¿ä¼Ò Áß¿¡ valid.requiredÀÇ °ªÀÌ trueÀÎ * Ç׸ñÀ» Ç¥½ÃÇÑ´Ù. */ function markRequiredInput(form) { for ( var i = 0; i < form.elements.length; i++ ) { var elem = form.elements[i]; if ( ! elem.disabled && ! elem.readOnly ) { if ( elem.getAttribute("valid.required") == "true" ) { elem.style.backgroundColor = "#FFFFCC"; } } } } /** * ÁÖ¾îÁø Form¿¡ Á¤ÀÇµÈ Element¸¦ µÚÁ®¼­ * ÆíÁý °¡´ÉÇÑ Text³ª TextAreaÀÎ °æ¿ì * Focus¸¦ ÁÖ¾úÀ» ¶§¿Í ÀÒ¾úÀ» ¶§ÀÇ Ã³¸® Çڵ鷯¸¦ * ¼³Á¤ÇÑ´Ù. ±âº» °ªÀ¸·Î Å׵θ®¸¦ »¡°£»öÀ¸·Î Çß´Ù°¡ * ¿ø·¡´ë·Î µ¹¸®´Â Çڵ鷯°¡ ¼¼ÆÃµÈ´Ù. */ function setFocusAndBlurAction(form, focusAction, blurAction) { /* Á¤Àǰ¡ ¾È µÇ¾î ÀÖÀ¸¸é ±âº» °ªÀ» ³Ö´Â´Ù. */ if ( focusAction == undefined ) focusAction = setBorderRed; if ( blurAction == undefined ) blurAction = restoreBorderColor; for ( var i = 0; i < form.elements.length; i++ ) { var elem = form.elements[i]; //alert(elem.type); if ( elem.type != undefined && ( elem.type == "text" || elem.type == "textarea" || elem.type == "password" ) && ! elem.disabled && ! elem.readOnly ) { elem.attachEvent("onfocus", baseOnFocusHandler); elem.attachEvent("onfocus", focusAction); elem.attachEvent("onblur" , blurAction ); } } } /** * Focus À̺¥Æ® ¹ß»ý½Ã ±âº»ÀûÀ¸·Î °É ÇÔ¼ö */ function baseOnFocusHandler() { var eventSrc = event.srcElement; /* À̺¥Æ® ¹ß»ýÇÑ Ç׸ñÀÇ °ªÀÌ ¼±ÅÃµÈ »óŰ¡ µÇ°Ô ÇÑ´Ù. */ eventSrc.select(); } /** * Event°¡ ¹ß»ýÇÑ °´Ã¼ÀÇ Å׵θ®¸¦ »¡°£¼±À¸·Î ¹Ù²Û´Ù. */ function setBorderRed() { var eventSrc = event.srcElement; oldBorderValue = eventSrc.style.border; eventSrc.style.border = "1px solid #CCCCCC"; } /** * Blur À̺¥Æ®°¡ ¹ß»ýÇÑ Å׵θ®ÀÇ »ö»óÀ» ¿ø·¡´ë·Î * µ¹·Á³õ´Â´Ù. */ function restoreBorderColor() { var eventSrc = event.srcElement; eventSrc.style.borderColor = ""; } // 1024x768 ÇØ»óµµ¿¡¼­ Main ¿µ¿ª¿¡ ÇÊ¿äÇÑ ÃÖ¼Ò ³ôÀ̰ª var MIN_MAIN_HEIGHT = 494; /** * ÁÖ¾îÁø °íÁ¤ ³ôÀ̸¦ °í·ÁÇßÀ» ¶§ Main È­¸é ¿µ¿ªÀÇ * º¯ÇÒ ¼ö ÀÖ´Â ¿µ¿ª ³ôÀÌ °ªÀ» µ¹·Á ÁØ´Ù. */ function getVarHeightOfMain(minVarHeight) { var clientHeight = document.body.clientHeight; var fixHeight = MIN_MAIN_HEIGHT - minVarHeight; /* º¯°æµÉ ³ôÀÌ °ªÀ» ±¸ÇÑ´Ù. */ var varHeight = Math.max(MIN_MAIN_HEIGHT, clientHeight) - fixHeight; return varHeight; } /** * È®ÀÎâÀ» ¶ç¿îÈÄ ÂüÀ̸é, path·Î À̵¿ÇÑ´Ù. * */ function confirmation(path, message) { if (confirm(message)){ document.location.href = path; } } function center_popup(page,name,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'; var w = window.open(page,name,settings); return w; }