XFormsCalendar.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. /**
  2. * XFormsCalendarItem
  3. */
  4. XFormsCalendarItem.prototype = new XFormsCaption;
  5. function XFormsCalendarItem (strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis,
  6. strFormat, strId, nNavindex, strRef, strRoundMode, nRoundPosition, strStyle, strTag, strVisibility, strUserDefineAttrib)
  7. {
  8. if (!strId)
  9. {
  10. return;
  11. }
  12. XFormsCaption.call(this, strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis,
  13. strFormat, strId, nNavindex, strRef, strRoundMode, nRoundPosition, strStyle, strTag, strVisibility, strUserDefineAttrib);
  14. /**
  15. * Attribute
  16. */
  17. /**
  18. * Property
  19. */
  20. this.label;
  21. };
  22. XFormsCalendarItem.prototype.init = function ()
  23. {
  24. XFormsCaption.prototype.init.call(this);
  25. this.label = this.m_heControl.innerHTML;
  26. };
  27. /**
  28. * 여기부터 XFormsCalendar
  29. */
  30. XFormsCalendar.prototype = new XFormsGroup;
  31. function XFormsCalendar (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex,
  32. strOverflow, strRef, strScroll, strShowEffect, bShowToday, strStyle, strTag, strVisibility)
  33. {
  34. if (!strId)
  35. {
  36. return;
  37. }
  38. XFormsGroup.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex,
  39. strOverflow, ""/*bPopup*/, strRef, strScroll, strShowEffect, strStyle, strTag, strVisibility);
  40. this.m_strChoosedPosition;
  41. /**
  42. * Attribute
  43. */
  44. // 2011. 03. 19. 기능 추가 - 박현우
  45. this.attribute["showtoday"] = String(bShowToday);
  46. /**
  47. * Property
  48. */
  49. this.day;
  50. this.month;
  51. this.year;
  52. this.dayItem = new Array();
  53. this.header;
  54. this.prevyear;
  55. this.prevmonth;
  56. this.nextmonth;
  57. this.nextyear;
  58. };
  59. /**
  60. * Method
  61. */
  62. XFormsCalendar.prototype.refresh = function ()
  63. {
  64. this.makeCalendar(parseInt(this.year), parseInt(this.month), parseInt(this.day));
  65. };
  66. XFormsCalendar.prototype.item = function (nRow, nCol)
  67. {
  68. if (nCol == null)
  69. {
  70. for (var i = 0; i < 7; i++)
  71. {
  72. for (var j = 0; j < 7; j++)
  73. {
  74. if (document.getElementById("HE_" + this.id + ".item" + i + j).innerHTML == nRow)
  75. {
  76. nRow = i;
  77. nCol = j;
  78. break;
  79. }
  80. }
  81. if (nCol != null)
  82. {
  83. break;
  84. }
  85. }
  86. }
  87. return this.dayItem[nRow][nCol];
  88. };
  89. /**
  90. * TF System Method
  91. */
  92. XFormsCalendar.prototype.init = function ()
  93. {
  94. XFormsGroup.prototype.init.call(this);
  95. this.header = new XFormsCalendarHeader(this.id, "", "", "", Lan_Year + Lan_Month, "", "", "", "", false, "", "", this.id+".header", -1, "", "", "", "", "xforms:caption", "visible");
  96. this.header.m_bDependentCtl = true;
  97. this.header.init();
  98. this.prevyear = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".prevyear", -1, "", "", -1, false, "", "xforms:button", "visible");
  99. this.prevyear.m_bDependentCtl = true;
  100. this.prevyear.init();
  101. this.prevmonth = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".prevmonth", -1, "", "", -1, false, "", "xforms:button", "visible");
  102. this.prevmonth.m_bDependentCtl = true;
  103. this.prevmonth.init();
  104. this.nextmonth = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".nextmonth", -1, "", "", -1, false, "", "xforms:button", "visible");
  105. this.nextmonth.m_bDependentCtl = true;
  106. this.nextmonth.init();
  107. this.nextyear = new XFormsButton(this.id, "", "", "", "", "", false, "", "", false, false, "", "", "", this.id+".nextyear", -1, "", "", -1, false, "", "xforms:button", "visible");
  108. this.nextyear.m_bDependentCtl = true;
  109. this.nextyear.init();
  110. this.calendaritem = new XFormsCalendarItem(this.id, "", "", "", "", "", "", "", "", false, "", "", this.id+".item", -1, "", "", "", "", "xforms:calendaritem", "visible");
  111. this.calendaritem.m_bDependentCtl = true;
  112. this.calendaritem.init();
  113. // TODO today기능
  114. this.calendarToday = new XFormsCalendarToday(this.id, "", "", "", "", "", "", "", "", false, "", "", this.id+".today", -1, "", "", "", "", "xforms:calendartoday", "visible");
  115. this.calendarToday.m_bDependentCtl = true;
  116. this.calendarToday.init();
  117. if (!this.calendaritem.getSelectAttribute("background-color"))
  118. {
  119. this.calendaritem.setSelectAttribute("background-color", "#00008B");
  120. }
  121. if (!this.calendaritem.getSelectAttribute("color") || this.calendaritem.getSelectAttribute("color") == "")
  122. {
  123. this.calendaritem.setSelectAttribute("color", "#FFFFFF");
  124. }
  125. for (var i = 0; i < 7; i++)
  126. {
  127. var arTemp = new Array();
  128. for (var j = 0; j < 7; j++)
  129. {
  130. arTemp[j] = new XFormsCell(this.id, j, this.id + ".item" + i + j, i, "xforms:calendaritem");
  131. arTemp[j].setElement(this.calendaritem);
  132. arTemp[j].init();
  133. }
  134. this.dayItem[i] = arTemp;
  135. }
  136. var objDate = new Date();
  137. this.year = objDate.getFullYear().toString();
  138. this.month = (objDate.getMonth()+1).toString();
  139. this.day = objDate.getDate();
  140. this.makeCalendar(parseInt(this.year), parseInt(this.month), parseInt(this.day));
  141. var bShowToday = this.getAttribute("showtoday");
  142. // showToday 설정
  143. this.setShowToday();
  144. this.resizeControl();
  145. };
  146. XFormsCalendar.prototype.setShowToday = function ()
  147. {
  148. var heToday = document.getElementById("HE_" + this.id + ".today");
  149. if (null == heToday)
  150. {
  151. return;
  152. }
  153. if ("true" == this.getAttribute("showtoday"))
  154. {
  155. var strMonth = (Number(this.month) < 10) ? "0" + this.month : String(this.month);
  156. var strDay = (Number(this.day) < 10) ? "0" + this.day : String(this.day);
  157. heToday.innerHTML = Lan_Today + " : " + this.year + "-" + strMonth + "-" + strDay;
  158. // item의 높이를 다시 설정해준다.
  159. for (var i=0; i<this.dayItem.length; i++)
  160. {
  161. var arWeek = this.dayItem[i];
  162. for (var j=0;j<arWeek.length; j++)
  163. {
  164. var objDay = arWeek[j];
  165. objDay.m_heControl.style.height = "12.5%";
  166. }
  167. }
  168. heToday.style.textAlign = "center";
  169. heToday.style.height = "12.5%";
  170. heToday.style.cursor = "hand";
  171. }
  172. else
  173. {
  174. heToday.parentNode.removeChild(heToday);
  175. }
  176. // this.m_heControl.appendChild(heToday);
  177. };
  178. XFormsCalendar.prototype.applyDefaultStyle = function ()
  179. {
  180. XFormsGroup.prototype.applyDefaultStyle.call(this);
  181. // Calendar Default Style
  182. if (!this.attribute["border-width"])
  183. {
  184. this.m_heControl.style.borderWidth = "1px";
  185. }
  186. if (!this.attribute["border-style"])
  187. {
  188. this.m_heControl.style.borderStyle = "solid";
  189. }
  190. };
  191. XFormsCalendar.prototype.makeCalendar = function (nYear, nMonth, nDay)
  192. {
  193. var objCalendarHeader = this.children.item(this.id+".header");
  194. objCalendarHeader.attribute["text"] = nYear + Lan_Year + nMonth + Lan_Month;
  195. document.getElementById("HE_" + this.attribute["id"]+"Year").innerHTML = nYear;
  196. document.getElementById("HE_" + this.attribute["id"]+"Month").innerHTML = nMonth;
  197. var objStartDate = new Date(nYear, nMonth-1, 1);
  198. var nStartWeekday = objStartDate.getDay();
  199. var strMonthDays = "312831303130313130313031";
  200. var strEndDay = strMonthDays.substring(((nMonth-1)*2), ((nMonth-1)*2+2));
  201. if ((nMonth == 2) && (((nYear%4 == 0) && (nYear%100 != 0)) || (nYear%400 == 0))) // 2월의 경우 별도로 마지막날 계산
  202. {
  203. strEndDay = "29";
  204. }
  205. var nEndDay = parseInt(strEndDay);
  206. var nIndex = 0;
  207. var nInputDay = 1;
  208. for (var i = 1; i < 7; i++)
  209. {
  210. for (var j = 0; j < 7; j++)
  211. {
  212. var nDayValue;
  213. if (nIndex < nStartWeekday || nInputDay > nEndDay)
  214. {
  215. document.getElementById("HE_" + this.attribute["id"]+".item"+i+j).innerHTML = "";
  216. }
  217. else
  218. {
  219. document.getElementById("HE_" + this.attribute["id"]+".item"+i+j).innerHTML = nInputDay;
  220. if (nDay == nInputDay)
  221. {
  222. this.chooseDate(i.toString()+j.toString());
  223. }
  224. nInputDay = nInputDay + 1;
  225. }
  226. this.dayItem[i][j].label = this.dayItem[i][j].m_heControl.innerHTML;
  227. nIndex = nIndex + 1;
  228. }
  229. }
  230. };
  231. XFormsCalendar.prototype.chooseDate = function (strPosition)
  232. {
  233. var objChoosedDate = document.getElementById("HE_" + this.attribute["id"]+".item"+strPosition);
  234. if (objChoosedDate.innerHTML == "" || strPosition.substring(0,1) == "0")
  235. {
  236. return;
  237. }
  238. if (this.m_strChoosedPosition != null)
  239. {
  240. var strBackgroundColor = this.calendaritem.attribute["background-color"];
  241. if (!strBackgroundColor)
  242. {
  243. strBackgroundColor = "#ffffff";
  244. }
  245. var strFontColor = this.calendaritem.attribute["color"];
  246. if (!strFontColor)
  247. {
  248. strFontColor = "#000000";
  249. }
  250. var objTempDate = document.getElementById("HE_" + this.attribute["id"]+".item"+this.m_strChoosedPosition);
  251. objTempDate.style.backgroundColor = strBackgroundColor;
  252. if (this.m_strChoosedPosition.substring(1,2) == "0")
  253. {
  254. objTempDate.style.color = "#FF0000";
  255. }
  256. else if (this.m_strChoosedPosition.substring(1,2) == "6")
  257. {
  258. objTempDate.style.color = "#0000FF";
  259. }
  260. else
  261. {
  262. objTempDate.style.color = strFontColor;
  263. }
  264. }
  265. this.day = objChoosedDate.innerHTML;
  266. this.m_strChoosedPosition = strPosition;
  267. objChoosedDate.style.backgroundColor = this.calendaritem.getSelectAttribute("background-color");
  268. objChoosedDate.style.color = this.calendaritem.getSelectAttribute("color");
  269. };
  270. XFormsCalendar.prototype.moveCalendar = function (strMoveType)
  271. {
  272. // 기존의 선택 포지션 초기화
  273. if (this.m_strChoosedPosition != null)
  274. {
  275. var objTempDate = document.getElementById("HE_" + this.attribute["id"]+".item"+this.m_strChoosedPosition);
  276. objTempDate.style.backgroundColor = this.calendaritem.attribute["background-color"];
  277. if (this.calendaritem.attribute["color"])
  278. {
  279. objTempDate.style.color = this.calendaritem.attribute["color"];
  280. }
  281. else if (this.m_strChoosedPosition.substring(1,2) == "0")
  282. {
  283. objTempDate.style.color = "#FF0000";
  284. }
  285. else if (this.m_strChoosedPosition.substring(1,2) == "6")
  286. {
  287. objTempDate.style.color = "#0000FF";
  288. }
  289. else
  290. {
  291. objTempDate.style.color = "#000000";
  292. }
  293. }
  294. this.m_strChoosedPosition = null;
  295. // 년/월을 변경하여 다시 생성
  296. var strCurrentYear = document.getElementById("HE_" + this.attribute["id"]+"Year").innerHTML;
  297. var strCurrentMonth = document.getElementById("HE_" + this.attribute["id"]+"Month").innerHTML;
  298. if (strMoveType == "prevYear")
  299. {
  300. this.year = ((strCurrentYear)-1).toString();
  301. this.month = strCurrentMonth;
  302. }
  303. else if (strMoveType == "nextYear")
  304. {
  305. this.year = (parseInt(strCurrentYear)+1).toString();
  306. this.month = strCurrentMonth;
  307. }
  308. else if (strMoveType == "prevMonth")
  309. {
  310. if (strCurrentMonth == "1")
  311. {
  312. this.year = (parseInt(strCurrentYear)-1).toString();
  313. this.month = "12";
  314. }
  315. else
  316. {
  317. this.year = strCurrentYear;
  318. this.month = (parseInt(strCurrentMonth)-1).toString();
  319. }
  320. }
  321. else if (strMoveType == "nextMonth")
  322. {
  323. if (strCurrentMonth == "12")
  324. {
  325. this.year = (parseInt(strCurrentYear)+1).toString();
  326. this.month = "1";
  327. }
  328. else
  329. {
  330. this.year = strCurrentYear;
  331. this.month = (parseInt(strCurrentMonth)+1).toString();
  332. }
  333. }
  334. var objDate = new Date();
  335. if (this.year == objDate.getFullYear().toString() && this.month == (objDate.getMonth()+1).toString())
  336. {
  337. this.day = objDate.getDate().toString();
  338. }
  339. else
  340. {
  341. this.day = "";
  342. }
  343. this.makeCalendar(parseInt(this.year), parseInt(this.month), parseInt(this.day));
  344. };
  345. XFormsCalendar.prototype.setToday = function ()
  346. {
  347. var objPresentTime = new Date();
  348. this.day = objPresentTime.getDate().toString();
  349. this.month = (objPresentTime.getMonth()+1).toString();
  350. this.year = objPresentTime.getFullYear().toString();
  351. this.refresh();
  352. };
  353. XFormsCalendar.prototype.onMouseDown = function (event)
  354. {
  355. XFormsGroup.prototype.onMouseDown.call(this, event);
  356. if (!this.disabled)
  357. {
  358. if (event.target.substring(0, this.id.length+5) == this.id+".item")
  359. {
  360. this.chooseDate(event.target.substring(this.id.length+5,this.id.length+7));
  361. this.dispatch("ondayselect");
  362. }
  363. else if (event.target == this.id+".today")
  364. {
  365. this.setToday();
  366. this.dispatch("ondayselect");
  367. }
  368. }
  369. };
  370. XFormsCalendar.prototype.onClick = function (event)
  371. {
  372. XFormsGroup.prototype.onClick.call(this, event);
  373. if (!this.disabled)
  374. {
  375. var strPosition = this.m_strChoosedPosition;
  376. var bClickButton = false;
  377. if (event.target == this.id+".prevyear")
  378. {
  379. this.dispatch("onprevyear");
  380. this.moveCalendar("prevYear");
  381. bClickButton = true;
  382. }
  383. else if (event.target == this.id+".prevmonth")
  384. {
  385. this.dispatch("onprevmonth");
  386. this.moveCalendar("prevMonth");
  387. bClickButton = true;
  388. }
  389. else if (event.target == this.id+".nextmonth")
  390. {
  391. this.dispatch("onnextmonth");
  392. this.moveCalendar("nextMonth");
  393. bClickButton = true;
  394. }
  395. else if (event.target == this.id+".nextyear")
  396. {
  397. this.dispatch("onnextyear");
  398. this.moveCalendar("nextYear");
  399. bClickButton = true;
  400. }
  401. if (bClickButton)
  402. {
  403. this.setDeselect(strPosition);
  404. }
  405. }
  406. };
  407. XFormsCalendar.prototype.setDeselect = function (strPosition)
  408. {
  409. var objChoosedDate = document.getElementById("HE_" + this.id + ".item" + strPosition);
  410. if (null != objChoosedDate)
  411. {
  412. var strBackgroundColor = this.calendaritem.attribute["background-color"];
  413. if (!strBackgroundColor)
  414. {
  415. strBackgroundColor = "#ffffff";
  416. }
  417. var strFontColor = this.calendaritem.attribute["color"];
  418. if (!strFontColor)
  419. {
  420. strFontColor = "#000000";
  421. }
  422. objChoosedDate.style.backgroundColor = strBackgroundColor;
  423. objChoosedDate.style.color = strFontColor;
  424. }
  425. };
  426. XFormsCalendar.create = function (strParentId, clAttribute, strStyle)
  427. {
  428. // 메인노드 생성
  429. var xnCalendar = XFormsCalendar.createMainNode(clAttribute);
  430. var heParent = document.getElementById("HE_"+strParentId);
  431. var objParent = document.allElement.item(strParentId);
  432. if (objParent instanceof XFormsInput || objParent instanceof XFormsGridCol)
  433. {
  434. xnCalendar.style.zIndex = 100;
  435. var heBody = document.getElementById("HE_body");
  436. heBody.appendChild(xnCalendar);
  437. }
  438. else
  439. {
  440. heParent.appendChild(xnCalendar);
  441. }
  442. // 하위노드 생성
  443. xnCalendar = XFormsCalendar.createSubNodes(xnCalendar, clAttribute);
  444. // object 생성
  445. return XFormsCalendar.createObject(strParentId, xnCalendar, clAttribute, strStyle);
  446. };
  447. XFormsCalendar.createMainNode = function (clAttribute)
  448. {
  449. var xnCalendar = document.createElement("div");
  450. xnCalendar = XFormsCalendar.createAttribute(xnCalendar, clAttribute);
  451. return xnCalendar;
  452. };
  453. XFormsCalendar.createSubNodes = function (xnCalendar, clAttribute)
  454. {
  455. // 상위의 아이디를 가져온다.
  456. var strId = clAttribute.item("id");
  457. // 제목 부분 테이블 생성
  458. var xnHeadTable = document.createElement("table");
  459. if (clAttribute.exists("color"))
  460. {
  461. xnHeadTable.style.color = "#FFFFFF";
  462. }
  463. if (!clAttribute.exists("cursor"))
  464. {
  465. xnHeadTable.style.cursor = "default";
  466. }
  467. xnHeadTable.setAttribute("id", "HE_"+strId+".header");
  468. xnHeadTable.cellPadding = 0;
  469. xnHeadTable.cellSpacing = 0;
  470. xnHeadTable.setAttribute("width", "100%");
  471. xnHeadTable.setAttribute("height", "20%");
  472. xnHeadTable.style.color = "#FFFFFF";
  473. xnHeadTable.style.backgroundColor = "#0000FF";
  474. xnHeadTable.style.tableLayout = "fixed";
  475. var xnHeadTbody = document.createElement("tbody");
  476. var xnHeadTr = document.createElement("tr");
  477. var xnHeadTd1 = document.createElement("td");
  478. xnHeadTd1.setAttribute("width", "17%");
  479. xnHeadTd1.setAttribute("height", "100%");
  480. xnHeadTd1.setAttribute("align", "right");
  481. var xnPrevYear = document.createElement("button");
  482. xnPrevYear.setAttribute("id", "HE_"+strId+".prevyear");
  483. xnPrevYear.style.width = "25px";
  484. xnPrevYear.style.height = "15px";
  485. xnPrevYear.style.backgroundColor = "#D4D0C8";
  486. xnPrevYear.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/prevYear.gif)";
  487. xnPrevYear.style.backgroundRepeat = "no-repeat";
  488. xnPrevYear.style.backgroundPosition = "center";
  489. xnHeadTd1.appendChild(xnPrevYear);
  490. var xnHeadTd2 = document.createElement("td");
  491. xnHeadTd2.setAttribute("width", "13%");
  492. xnHeadTd2.setAttribute("height", "100%");
  493. xnHeadTd2.setAttribute("align", "right");
  494. var xnPrevMonth = document.createElement("button");
  495. xnPrevMonth.setAttribute("id", "HE_"+strId+".prevmonth");
  496. xnPrevMonth.style.width = "25px";
  497. xnPrevMonth.style.height = "15px";
  498. xnPrevMonth.style.backgroundColor = "#D4D0C8";
  499. xnPrevMonth.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/prevMonth.gif)";
  500. xnPrevMonth.style.backgroundRepeat = "no-repeat";
  501. xnPrevMonth.style.backgroundPosition = "center";
  502. xnHeadTd2.appendChild(xnPrevMonth);
  503. var xnHeadTd3 = document.createElement("td");
  504. xnHeadTd3.setAttribute("id", "HE_"+strId+".header_TEXT");
  505. xnHeadTd3.setAttribute("width", "40%");
  506. xnHeadTd3.setAttribute("height", "100%");
  507. xnHeadTd3.setAttribute("align", "center");
  508. var xnHeadYear = document.createElement("span");
  509. xnHeadYear.setAttribute("id", "HE_" + strId + "Year");
  510. xnHeadTd3.appendChild(xnHeadYear);
  511. xnHeadTd3.innerHTML += Lan_Year;
  512. var xnHeadMonth = document.createElement("span");
  513. xnHeadMonth.setAttribute("id", "HE_" + strId + "Month");
  514. xnHeadTd3.appendChild(xnHeadMonth);
  515. xnHeadTd3.innerHTML += Lan_Month;
  516. var xnHeadTd4 = document.createElement("td");
  517. xnHeadTd4.setAttribute("width", "13%");
  518. xnHeadTd4.setAttribute("height", "100%");
  519. var xnNextMonth = document.createElement("button");
  520. xnNextMonth.setAttribute("id", "HE_"+strId+".nextmonth");
  521. xnNextMonth.style.width = "25px";
  522. xnNextMonth.style.height = "15px";
  523. xnNextMonth.style.backgroundColor = "#D4D0C8";
  524. xnNextMonth.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/nextMonth.gif)";
  525. xnNextMonth.style.backgroundRepeat = "no-repeat";
  526. xnNextMonth.style.backgroundPosition = "center";
  527. xnHeadTd4.appendChild(xnNextMonth);
  528. var xnHeadTd5 = document.createElement("td");
  529. xnHeadTd5.setAttribute("width", "17%");
  530. xnHeadTd5.setAttribute("height", "100%");
  531. var xnNextYear = document.createElement("button");
  532. xnNextYear.setAttribute("id", "HE_"+strId+".nextyear");
  533. xnNextYear.style.width = "25px";
  534. xnNextYear.style.height = "15px";
  535. xnNextYear.style.backgroundColor = "#D4D0C8";
  536. xnNextYear.style.backgroundImage = "url(" + __getAppName() + "/kr/comsquare/image/calendar/nextYear.gif)";
  537. xnNextYear.style.backgroundRepeat = "no-repeat";
  538. xnNextYear.style.backgroundPosition = "center";
  539. xnHeadTd5.appendChild(xnNextYear);
  540. xnHeadTr.appendChild(xnHeadTd1);
  541. xnHeadTr.appendChild(xnHeadTd2);
  542. xnHeadTr.appendChild(xnHeadTd3);
  543. xnHeadTr.appendChild(xnHeadTd4);
  544. xnHeadTr.appendChild(xnHeadTd5);
  545. xnHeadTbody.appendChild(xnHeadTr);
  546. xnHeadTable.appendChild(xnHeadTbody);
  547. xnCalendar.appendChild(xnHeadTable);
  548. // 날짜 부분 테이블 생성
  549. var xnBodyTable = document.createElement("table");
  550. xnBodyTable.setAttribute("id", "HE_" + strId + ".item");
  551. xnBodyTable.cellPadding = 0;
  552. xnBodyTable.cellSpacing = 0;
  553. xnBodyTable.setAttribute("width", "100%");
  554. xnBodyTable.setAttribute("height", "80%");
  555. xnBodyTable.onclick = function () {};
  556. xnBodyTable.ondbclick = function () {};
  557. xnBodyTable.onmousedown = function () {};
  558. xnBodyTable.onmousemove = function () {};
  559. xnBodyTable.onmouseup = function () {};
  560. HtmlLib.setStyle(xnBodyTable, "cursor", "default");
  561. HtmlLib.setStyle(xnBodyTable, "line-height", "13px");
  562. var xnBodyTbody = document.createElement("tbody");
  563. for (var i = 0; i < 7; i++)
  564. {
  565. var xnBodyTr = document.createElement("tr");
  566. for (var j = 0; j < 7; j++)
  567. {
  568. var xnBodyTd = document.createElement("td");
  569. xnBodyTd.setAttribute("id", "HE_" + strId + ".item"+i+j);
  570. xnBodyTd.setAttribute("width", "12.5%");
  571. xnBodyTd.setAttribute("height", "12.5%");
  572. xnBodyTd.setAttribute("align", "center");
  573. if (j == 0)
  574. {
  575. HtmlLib.setStyle(xnBodyTd, "color", "#FF0000");
  576. }
  577. else if (j == 6)
  578. {
  579. HtmlLib.setStyle(xnBodyTd, "color", "#0000FF");
  580. }
  581. else
  582. {
  583. HtmlLib.setStyle(xnBodyTd, "color", "#000000");
  584. }
  585. if (i == 0)
  586. {
  587. if (j == 0)
  588. {
  589. xnBodyTd.innerHTML = Lan_Sunday;
  590. }
  591. else if (j == 1)
  592. {
  593. xnBodyTd.innerHTML = Lan_Monday;
  594. }
  595. else if (j == 2)
  596. {
  597. xnBodyTd.innerHTML = Lan_Tuesday;
  598. }
  599. else if (j == 3)
  600. {
  601. xnBodyTd.innerHTML = Lan_Wednesday;
  602. }
  603. else if (j == 4)
  604. {
  605. xnBodyTd.innerHTML = Lan_Thursday;
  606. }
  607. else if (j == 5)
  608. {
  609. xnBodyTd.innerHTML = Lan_Friday;
  610. }
  611. else if (j == 6)
  612. {
  613. xnBodyTd.innerHTML = Lan_Saturday;
  614. }
  615. }
  616. xnBodyTr.appendChild(xnBodyTd);
  617. }
  618. xnBodyTbody.appendChild(xnBodyTr);
  619. }
  620. var heTodayTR = document.createElement("tr");
  621. var heTodayTD = document.createElement("td");
  622. heTodayTR.appendChild(heTodayTD);
  623. heTodayTD.setAttribute("colspan", "7");
  624. heTodayTD.setAttribute("id", "HE_" + clAttribute.item("id") + ".today");
  625. xnBodyTbody.appendChild(heTodayTR);
  626. // // TODO Today 넣기
  627. // if ("true".equals(strShowToday))
  628. // {
  629. // Node xnTodayTR = HtmlLib.createChild(xnBodyTbody, TagName.TR);
  630. // Node xnTodayTD = HtmlLib.createChild(xnTodayTR, TagName.TD);
  631. // HtmlLib.setAttribute(xnTodayTD, AttributeName.COLSPAN, "7");
  632. // HtmlLib.setStyle(xnTodayTD, "height", strDayHeight);
  633. // HtmlLib.setAttribute(xnTodayTD, AttributeName.ID, "HE_" + strId + ".today");
  634. // }
  635. xnBodyTable.appendChild(xnBodyTbody);
  636. xnCalendar.appendChild(xnBodyTable);
  637. return xnCalendar;
  638. };
  639. XFormsCalendar.createObject = function (strParentId, xnCalendar, clAttribute, strStyle)
  640. {
  641. var strAlert = "";
  642. var strHelp = "";
  643. var strHint = "";
  644. var strAccesskey = "";
  645. var strBind = "";
  646. var strClass = "";
  647. var bDisabled = false;
  648. var strId = "";
  649. var nNavindex = 9007199254740992;
  650. var strOverflow = "";
  651. var strRef = "";
  652. var strScroll = "";
  653. var strShoweffect = "";
  654. var bShowToday = "";
  655. var strVisibility = "visible";
  656. var strUserDefineAttrib = "";
  657. for (var i=0; i<clAttribute.count(); i++)
  658. {
  659. var strAttributeName = clAttribute.keys()[i];
  660. switch (strAttributeName)
  661. {
  662. case "alert" :
  663. {
  664. strAlert = clAttribute.item(strAttributeName);
  665. break;
  666. }
  667. case "help" :
  668. {
  669. strHelp = clAttribute.item(strAttributeName);
  670. break;
  671. }
  672. case "hint" :
  673. {
  674. strHint = clAttribute.item(strAttributeName);
  675. break;
  676. }
  677. case "accesskey" :
  678. {
  679. strAccesskey = clAttribute.item(strAttributeName);
  680. break;
  681. }
  682. case "bind" :
  683. {
  684. strBind = clAttribute.item(strAttributeName);
  685. break;
  686. }
  687. case "class" :
  688. {
  689. strClass = clAttribute.item(strAttributeName);
  690. break;
  691. }
  692. case "disabled" :
  693. {
  694. if ("true" == clAttribute.item(strAttributeName))
  695. {
  696. bDisabled = true;
  697. }
  698. break;
  699. }
  700. case "id" :
  701. {
  702. strId = clAttribute.item(strAttributeName);
  703. break;
  704. }
  705. case "navindex" :
  706. {
  707. nNavindex = parseInt(clAttribute.item(strAttributeName));
  708. break;
  709. }
  710. case "overflow" :
  711. {
  712. strOverflow = clAttribute.item(strAttributeName);
  713. break;
  714. }
  715. case "ref" :
  716. {
  717. strRef = clAttribute.item(strAttributeName);
  718. break;
  719. }
  720. case "scroll" :
  721. {
  722. strScroll = clAttribute.item(strAttributeName);
  723. break;
  724. }
  725. case "showeffect" :
  726. {
  727. strShoweffect = clAttribute.item(strAttributeName);
  728. break;
  729. }
  730. case "showtoday" :
  731. {
  732. if ("true" == clAttribute.item(strAttributeName))
  733. {
  734. bShowToday = true;
  735. }
  736. break;
  737. }
  738. case "visibility" :
  739. {
  740. strVisibility = clAttribute.item(strAttributeName);
  741. break;
  742. }
  743. default :
  744. {
  745. if (!STYLE_LIST[strAttributeName])
  746. {
  747. strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
  748. }
  749. break;
  750. }
  751. }
  752. }
  753. var objCalendar = new XFormsCalendar (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex, strOverflow, strRef, strScroll, strShoweffect, bShowToday, strStyle, "xforms:calendar", strVisibility, strUserDefineAttrib);
  754. return objCalendar;
  755. };
  756. XFormsCalendar.createAttribute = function (xnHtmlNode, clAttribute)
  757. {
  758. xnHtmlNode = XFormsGroup.createAttribute(xnHtmlNode, clAttribute);
  759. return xnHtmlNode;
  760. };
  761. XFormsCalendarHeader.prototype = new XFormsCaption;
  762. function XFormsCalendarHeader (strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis, strFormat, strId, nNavindex, strRef, strRoundmode, nRoundposition, strStyle, strTag, strVisibility, strUserDefineAttrib)
  763. {
  764. if (!strId)
  765. {
  766. return;
  767. }
  768. XFormsCaption.call(this, strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis,
  769. strFormat, strId, nNavindex, strRef, strRoundmode, nRoundposition, strStyle, strTag, strVisibility, strUserDefineAttrib);
  770. };
  771. XFormsCalendarHeader.prototype.isCSSValid = function (strKey)
  772. {
  773. var bValid = false;
  774. if (null == this.attribute[strKey] || "" == this.attribute[strKey])
  775. {
  776. bValid = true;
  777. }
  778. return bValid;
  779. };
  780. XFormsCalendarToday.prototype = new XFormsCaption;
  781. function XFormsCalendarToday (strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis, strFormat, strId, nNavindex, strRef, strRoundmode, nRoundposition, strStyle, strTag, strVisibility, strUserDefineAttrib)
  782. {
  783. if (!strId)
  784. {
  785. return;
  786. }
  787. XFormsCaption.call(this, strParentId, strAlert, strHelp, strHint, strText, strAccesskey, bAutoresize, strBind, strClass, bDisabled, bEllipsis,
  788. strFormat, strId, nNavindex, strRef, strRoundmode, nRoundposition, strStyle, strTag, strVisibility, strUserDefineAttrib);
  789. };
  790. XFormsCalendarToday.prototype.isCSSValid = function (strKey)
  791. {
  792. var bValid = false;
  793. if (null == this.attribute[strKey] || "" == this.attribute[strKey])
  794. {
  795. bValid = true;
  796. }
  797. return bValid;
  798. };