/** * XFormsCalendarItem */ XFormsCalendarItem.prototype = new XFormsCaption; function XFormsCalendarItem (strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis, strFormat, strId, nNavindex, strRef, strRoundMode, nRoundPosition, strStyle, strTag, strVisibility, strUserDefineAttrib) { if (!strId) { return; } XFormsCaption.call(this, strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis, strFormat, strId, nNavindex, strRef, strRoundMode, nRoundPosition, strStyle, strTag, strVisibility, strUserDefineAttrib); /** * Attribute */ /** * Property */ this.label; }; XFormsCalendarItem.prototype.init = function () { XFormsCaption.prototype.init.call(this); this.label = this.m_heControl.innerHTML; }; /** * 여기부터 XFormsCalendar */ XFormsCalendar.prototype = new XFormsGroup; function XFormsCalendar (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex, strOverflow, strRef, strScroll, strShowEffect, bShowToday, strStyle, strTag, strVisibility) { if (!strId) { return; } XFormsGroup.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex, strOverflow, ""/*bPopup*/, strRef, strScroll, strShowEffect, strStyle, strTag, strVisibility); this.m_strChoosedPosition; /** * Attribute */ // 2011. 03. 19. 기능 추가 - 박현우 this.attribute["showtoday"] = String(bShowToday); /** * Property */ this.day; this.month; this.year; this.dayItem = new Array(); this.header; this.prevyear; this.prevmonth; this.nextmonth; this.nextyear; }; /** * Method */ XFormsCalendar.prototype.refresh = function () { this.makeCalendar(parseInt(this.year), parseInt(this.month), parseInt(this.day)); }; XFormsCalendar.prototype.item = function (nRow, nCol) { if (nCol == null) { for (var i = 0; i < 7; i++) { for (var j = 0; j < 7; j++) { if (document.getElementById("HE_" + this.id + ".item" + i + j).innerHTML == nRow) { nRow = i; nCol = j; break; } } if (nCol != null) { break; } } } return this.dayItem[nRow][nCol]; }; /** * TF System Method */ XFormsCalendar.prototype.init = function () { XFormsGroup.prototype.init.call(this); this.header = new XFormsCalendarHeader(this.id, "", "", "", Lan_Year + Lan_Month, "", "", "", "", false, "", "", this.id+".header", -1, "", "", "", "", "xforms:caption", "visible"); this.header.m_bDependentCtl = true; this.header.init(); this.prevyear = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".prevyear", -1, "", "", -1, false, "", "xforms:button", "visible"); this.prevyear.m_bDependentCtl = true; this.prevyear.init(); this.prevmonth = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".prevmonth", -1, "", "", -1, false, "", "xforms:button", "visible"); this.prevmonth.m_bDependentCtl = true; this.prevmonth.init(); this.nextmonth = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".nextmonth", -1, "", "", -1, false, "", "xforms:button", "visible"); this.nextmonth.m_bDependentCtl = true; this.nextmonth.init(); this.nextyear = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".nextyear", -1, "", "", -1, false, "", "xforms:button", "visible"); this.nextyear.m_bDependentCtl = true; this.nextyear.init(); this.calendaritem = new XFormsCalendarItem(this.id, "", "", "", "", "", "", "", "", false, "", "", this.id+".item", -1, "", "", "", "", "xforms:calendaritem", "visible"); this.calendaritem.m_bDependentCtl = true; this.calendaritem.init(); // TODO today기능 this.calendarToday = new XFormsCalendarToday(this.id, "", "", "", "", "", "", "", "", false, "", "", this.id+".today", -1, "", "", "", "", "xforms:calendartoday", "visible"); this.calendarToday.m_bDependentCtl = true; this.calendarToday.init(); if (!this.calendaritem.getSelectAttribute("background-color")) { this.calendaritem.setSelectAttribute("background-color", "#00008B"); } if (!this.calendaritem.getSelectAttribute("color") || this.calendaritem.getSelectAttribute("color") == "") { this.calendaritem.setSelectAttribute("color", "#FFFFFF"); } for (var i = 0; i < 7; i++) { var arTemp = new Array(); for (var j = 0; j < 7; j++) { arTemp[j] = new XFormsCell(this.id, j, this.id + ".item" + i + j, i, "xforms:calendaritem"); arTemp[j].setElement(this.calendaritem); arTemp[j].init(); } this.dayItem[i] = arTemp; } var objDate = new Date(); this.year = objDate.getFullYear().toString(); this.month = (objDate.getMonth()+1).toString(); this.day = objDate.getDate(); this.makeCalendar(parseInt(this.year), parseInt(this.month), parseInt(this.day)); var bShowToday = this.getAttribute("showtoday"); // showToday 설정 this.setShowToday(); this.resizeControl(); }; XFormsCalendar.prototype.setShowToday = function () { var heToday = document.getElementById("HE_" + this.id + ".today"); if (null == heToday) { return; } if ("true" == this.getAttribute("showtoday")) { var strMonth = (Number(this.month) < 10) ? "0" + this.month : String(this.month); var strDay = (Number(this.day) < 10) ? "0" + this.day : String(this.day); heToday.innerHTML = Lan_Today + " : " + this.year + "-" + strMonth + "-" + strDay; // item의 높이를 다시 설정해준다. for (var i=0; i nEndDay) { document.getElementById("HE_" + this.attribute["id"]+".item"+i+j).innerHTML = ""; } else { document.getElementById("HE_" + this.attribute["id"]+".item"+i+j).innerHTML = nInputDay; if (nDay == nInputDay) { this.chooseDate(i.toString()+j.toString()); } nInputDay = nInputDay + 1; } this.dayItem[i][j].label = this.dayItem[i][j].m_heControl.innerHTML; nIndex = nIndex + 1; } } }; XFormsCalendar.prototype.chooseDate = function (strPosition) { var objChoosedDate = document.getElementById("HE_" + this.attribute["id"]+".item"+strPosition); if (objChoosedDate.innerHTML == "" || strPosition.substring(0,1) == "0") { return; } if (this.m_strChoosedPosition != null) { var strBackgroundColor = this.calendaritem.attribute["background-color"]; if (!strBackgroundColor) { strBackgroundColor = "#ffffff"; } var strFontColor = this.calendaritem.attribute["color"]; if (!strFontColor) { strFontColor = "#000000"; } var objTempDate = document.getElementById("HE_" + this.attribute["id"]+".item"+this.m_strChoosedPosition); objTempDate.style.backgroundColor = strBackgroundColor; if (this.m_strChoosedPosition.substring(1,2) == "0") { objTempDate.style.color = "#FF0000"; } else if (this.m_strChoosedPosition.substring(1,2) == "6") { objTempDate.style.color = "#0000FF"; } else { objTempDate.style.color = strFontColor; } } this.day = objChoosedDate.innerHTML; this.m_strChoosedPosition = strPosition; objChoosedDate.style.backgroundColor = this.calendaritem.getSelectAttribute("background-color"); objChoosedDate.style.color = this.calendaritem.getSelectAttribute("color"); }; XFormsCalendar.prototype.moveCalendar = function (strMoveType) { // 기존의 선택 포지션 초기화 if (this.m_strChoosedPosition != null) { var objTempDate = document.getElementById("HE_" + this.attribute["id"]+".item"+this.m_strChoosedPosition); objTempDate.style.backgroundColor = this.calendaritem.attribute["background-color"]; if (this.calendaritem.attribute["color"]) { objTempDate.style.color = this.calendaritem.attribute["color"]; } else if (this.m_strChoosedPosition.substring(1,2) == "0") { objTempDate.style.color = "#FF0000"; } else if (this.m_strChoosedPosition.substring(1,2) == "6") { objTempDate.style.color = "#0000FF"; } else { objTempDate.style.color = "#000000"; } } this.m_strChoosedPosition = null; // 년/월을 변경하여 다시 생성 var strCurrentYear = document.getElementById("HE_" + this.attribute["id"]+"Year").innerHTML; var strCurrentMonth = document.getElementById("HE_" + this.attribute["id"]+"Month").innerHTML; if (strMoveType == "prevYear") { this.year = ((strCurrentYear)-1).toString(); this.month = strCurrentMonth; } else if (strMoveType == "nextYear") { this.year = (parseInt(strCurrentYear)+1).toString(); this.month = strCurrentMonth; } else if (strMoveType == "prevMonth") { if (strCurrentMonth == "1") { this.year = (parseInt(strCurrentYear)-1).toString(); this.month = "12"; } else { this.year = strCurrentYear; this.month = (parseInt(strCurrentMonth)-1).toString(); } } else if (strMoveType == "nextMonth") { if (strCurrentMonth == "12") { this.year = (parseInt(strCurrentYear)+1).toString(); this.month = "1"; } else { this.year = strCurrentYear; this.month = (parseInt(strCurrentMonth)+1).toString(); } } var objDate = new Date(); if (this.year == objDate.getFullYear().toString() && this.month == (objDate.getMonth()+1).toString()) { this.day = objDate.getDate().toString(); } else { this.day = ""; } this.makeCalendar(parseInt(this.year), parseInt(this.month), parseInt(this.day)); }; XFormsCalendar.prototype.setToday = function () { var objPresentTime = new Date(); this.day = objPresentTime.getDate().toString(); this.month = (objPresentTime.getMonth()+1).toString(); this.year = objPresentTime.getFullYear().toString(); this.refresh(); }; XFormsCalendar.prototype.onMouseDown = function (event) { XFormsGroup.prototype.onMouseDown.call(this, event); if (!this.disabled) { if (event.target.substring(0, this.id.length+5) == this.id+".item") { this.chooseDate(event.target.substring(this.id.length+5,this.id.length+7)); this.dispatch("ondayselect"); } else if (event.target == this.id+".today") { this.setToday(); this.dispatch("ondayselect"); } } }; XFormsCalendar.prototype.onClick = function (event) { XFormsGroup.prototype.onClick.call(this, event); if (!this.disabled) { var strPosition = this.m_strChoosedPosition; var bClickButton = false; if (event.target == this.id+".prevyear") { this.dispatch("onprevyear"); this.moveCalendar("prevYear"); bClickButton = true; } else if (event.target == this.id+".prevmonth") { this.dispatch("onprevmonth"); this.moveCalendar("prevMonth"); bClickButton = true; } else if (event.target == this.id+".nextmonth") { this.dispatch("onnextmonth"); this.moveCalendar("nextMonth"); bClickButton = true; } else if (event.target == this.id+".nextyear") { this.dispatch("onnextyear"); this.moveCalendar("nextYear"); bClickButton = true; } if (bClickButton) { this.setDeselect(strPosition); } } }; XFormsCalendar.prototype.setDeselect = function (strPosition) { var objChoosedDate = document.getElementById("HE_" + this.id + ".item" + strPosition); if (null != objChoosedDate) { var strBackgroundColor = this.calendaritem.attribute["background-color"]; if (!strBackgroundColor) { strBackgroundColor = "#ffffff"; } var strFontColor = this.calendaritem.attribute["color"]; if (!strFontColor) { strFontColor = "#000000"; } objChoosedDate.style.backgroundColor = strBackgroundColor; objChoosedDate.style.color = strFontColor; } }; XFormsCalendar.create = function (strParentId, clAttribute, strStyle) { // 메인노드 생성 var xnCalendar = XFormsCalendar.createMainNode(clAttribute); var heParent = document.getElementById("HE_"+strParentId); var objParent = document.allElement.item(strParentId); if (objParent instanceof XFormsInput || objParent instanceof XFormsGridCol) { xnCalendar.style.zIndex = 100; var heBody = document.getElementById("HE_body"); heBody.appendChild(xnCalendar); } else { heParent.appendChild(xnCalendar); } // 하위노드 생성 xnCalendar = XFormsCalendar.createSubNodes(xnCalendar, clAttribute); // object 생성 return XFormsCalendar.createObject(strParentId, xnCalendar, clAttribute, strStyle); }; XFormsCalendar.createMainNode = function (clAttribute) { var xnCalendar = document.createElement("div"); xnCalendar = XFormsCalendar.createAttribute(xnCalendar, clAttribute); return xnCalendar; }; XFormsCalendar.createSubNodes = function (xnCalendar, clAttribute) { // 상위의 아이디를 가져온다. var strId = clAttribute.item("id"); // 제목 부분 테이블 생성 var xnHeadTable = document.createElement("table"); if (clAttribute.exists("color")) { xnHeadTable.style.color = "#FFFFFF"; } if (!clAttribute.exists("cursor")) { xnHeadTable.style.cursor = "default"; } xnHeadTable.setAttribute("id", "HE_"+strId+".header"); xnHeadTable.cellPadding = 0; xnHeadTable.cellSpacing = 0; xnHeadTable.setAttribute("width", "100%"); xnHeadTable.setAttribute("height", "20%"); xnHeadTable.style.color = "#FFFFFF"; xnHeadTable.style.backgroundColor = "#0000FF"; xnHeadTable.style.tableLayout = "fixed"; var xnHeadTbody = document.createElement("tbody"); var xnHeadTr = document.createElement("tr"); var xnHeadTd1 = document.createElement("td"); xnHeadTd1.setAttribute("width", "17%"); xnHeadTd1.setAttribute("height", "100%"); xnHeadTd1.setAttribute("align", "right"); var xnPrevYear = document.createElement("button"); xnPrevYear.setAttribute("id", "HE_"+strId+".prevyear"); xnPrevYear.style.width = "25px"; xnPrevYear.style.height = "15px"; xnPrevYear.style.backgroundColor = "#D4D0C8"; xnPrevYear.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/prevYear.gif)"; xnPrevYear.style.backgroundRepeat = "no-repeat"; xnPrevYear.style.backgroundPosition = "center"; xnHeadTd1.appendChild(xnPrevYear); var xnHeadTd2 = document.createElement("td"); xnHeadTd2.setAttribute("width", "13%"); xnHeadTd2.setAttribute("height", "100%"); xnHeadTd2.setAttribute("align", "right"); var xnPrevMonth = document.createElement("button"); xnPrevMonth.setAttribute("id", "HE_"+strId+".prevmonth"); xnPrevMonth.style.width = "25px"; xnPrevMonth.style.height = "15px"; xnPrevMonth.style.backgroundColor = "#D4D0C8"; xnPrevMonth.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/prevMonth.gif)"; xnPrevMonth.style.backgroundRepeat = "no-repeat"; xnPrevMonth.style.backgroundPosition = "center"; xnHeadTd2.appendChild(xnPrevMonth); var xnHeadTd3 = document.createElement("td"); xnHeadTd3.setAttribute("id", "HE_"+strId+".header_TEXT"); xnHeadTd3.setAttribute("width", "40%"); xnHeadTd3.setAttribute("height", "100%"); xnHeadTd3.setAttribute("align", "center"); var xnHeadYear = document.createElement("span"); xnHeadYear.setAttribute("id", "HE_" + strId + "Year"); xnHeadTd3.appendChild(xnHeadYear); xnHeadTd3.innerHTML += Lan_Year; var xnHeadMonth = document.createElement("span"); xnHeadMonth.setAttribute("id", "HE_" + strId + "Month"); xnHeadTd3.appendChild(xnHeadMonth); xnHeadTd3.innerHTML += Lan_Month; var xnHeadTd4 = document.createElement("td"); xnHeadTd4.setAttribute("width", "13%"); xnHeadTd4.setAttribute("height", "100%"); var xnNextMonth = document.createElement("button"); xnNextMonth.setAttribute("id", "HE_"+strId+".nextmonth"); xnNextMonth.style.width = "25px"; xnNextMonth.style.height = "15px"; xnNextMonth.style.backgroundColor = "#D4D0C8"; xnNextMonth.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/nextMonth.gif)"; xnNextMonth.style.backgroundRepeat = "no-repeat"; xnNextMonth.style.backgroundPosition = "center"; xnHeadTd4.appendChild(xnNextMonth); var xnHeadTd5 = document.createElement("td"); xnHeadTd5.setAttribute("width", "17%"); xnHeadTd5.setAttribute("height", "100%"); var xnNextYear = document.createElement("button"); xnNextYear.setAttribute("id", "HE_"+strId+".nextyear"); xnNextYear.style.width = "25px"; xnNextYear.style.height = "15px"; xnNextYear.style.backgroundColor = "#D4D0C8"; xnNextYear.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/nextYear.gif)"; xnNextYear.style.backgroundRepeat = "no-repeat"; xnNextYear.style.backgroundPosition = "center"; xnHeadTd5.appendChild(xnNextYear); xnHeadTr.appendChild(xnHeadTd1); xnHeadTr.appendChild(xnHeadTd2); xnHeadTr.appendChild(xnHeadTd3); xnHeadTr.appendChild(xnHeadTd4); xnHeadTr.appendChild(xnHeadTd5); xnHeadTbody.appendChild(xnHeadTr); xnHeadTable.appendChild(xnHeadTbody); xnCalendar.appendChild(xnHeadTable); // 날짜 부분 테이블 생성 var xnBodyTable = document.createElement("table"); xnBodyTable.setAttribute("id", "HE_" + strId + ".item"); xnBodyTable.cellPadding = 0; xnBodyTable.cellSpacing = 0; xnBodyTable.setAttribute("width", "100%"); xnBodyTable.setAttribute("height", "80%"); xnBodyTable.onclick = function () {}; xnBodyTable.ondbclick = function () {}; xnBodyTable.onmousedown = function () {}; xnBodyTable.onmousemove = function () {}; xnBodyTable.onmouseup = function () {}; HtmlLib.setStyle(xnBodyTable, "cursor", "default"); HtmlLib.setStyle(xnBodyTable, "line-height", "13px"); var xnBodyTbody = document.createElement("tbody"); for (var i = 0; i < 7; i++) { var xnBodyTr = document.createElement("tr"); for (var j = 0; j < 7; j++) { var xnBodyTd = document.createElement("td"); xnBodyTd.setAttribute("id", "HE_" + strId + ".item"+i+j); xnBodyTd.setAttribute("width", "12.5%"); xnBodyTd.setAttribute("height", "12.5%"); xnBodyTd.setAttribute("align", "center"); if (j == 0) { HtmlLib.setStyle(xnBodyTd, "color", "#FF0000"); } else if (j == 6) { HtmlLib.setStyle(xnBodyTd, "color", "#0000FF"); } else { HtmlLib.setStyle(xnBodyTd, "color", "#000000"); } if (i == 0) { if (j == 0) { xnBodyTd.innerHTML = Lan_Sunday; } else if (j == 1) { xnBodyTd.innerHTML = Lan_Monday; } else if (j == 2) { xnBodyTd.innerHTML = Lan_Tuesday; } else if (j == 3) { xnBodyTd.innerHTML = Lan_Wednesday; } else if (j == 4) { xnBodyTd.innerHTML = Lan_Thursday; } else if (j == 5) { xnBodyTd.innerHTML = Lan_Friday; } else if (j == 6) { xnBodyTd.innerHTML = Lan_Saturday; } } xnBodyTr.appendChild(xnBodyTd); } xnBodyTbody.appendChild(xnBodyTr); } var heTodayTR = document.createElement("tr"); var heTodayTD = document.createElement("td"); heTodayTR.appendChild(heTodayTD); heTodayTD.setAttribute("colspan", "7"); heTodayTD.setAttribute("id", "HE_" + clAttribute.item("id") + ".today"); xnBodyTbody.appendChild(heTodayTR); // // TODO Today 넣기 // if ("true".equals(strShowToday)) // { // Node xnTodayTR = HtmlLib.createChild(xnBodyTbody, TagName.TR); // Node xnTodayTD = HtmlLib.createChild(xnTodayTR, TagName.TD); // HtmlLib.setAttribute(xnTodayTD, AttributeName.COLSPAN, "7"); // HtmlLib.setStyle(xnTodayTD, "height", strDayHeight); // HtmlLib.setAttribute(xnTodayTD, AttributeName.ID, "HE_" + strId + ".today"); // } xnBodyTable.appendChild(xnBodyTbody); xnCalendar.appendChild(xnBodyTable); return xnCalendar; }; XFormsCalendar.createObject = function (strParentId, xnCalendar, clAttribute, strStyle) { var strAlert = ""; var strHelp = ""; var strHint = ""; var strAccesskey = ""; var strBind = ""; var strClass = ""; var bDisabled = false; var strId = ""; var nNavindex = 9007199254740992; var strOverflow = ""; var strRef = ""; var strScroll = ""; var strShoweffect = ""; var bShowToday = ""; var strVisibility = "visible"; var strUserDefineAttrib = ""; for (var i=0; i