XFormsGroup.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. XFormsGroup.prototype = new XFormsBindableControl;
  2. function XFormsGroup (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex,
  3. strOverflow, bPopup, strRef, strScroll, strShowEffect, strStyle, strTag, strVisibility, strUserDefineAttrib)
  4. {
  5. if (!strId)
  6. {
  7. return;
  8. }
  9. XFormsBindableControl.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strBind,
  10. strClass, bDisabled, strId, nNavindex, strRef, strStyle, strTag, strVisibility, strUserDefineAttrib);
  11. this.m_winPopup = null;
  12. this.m_bApplyPadding = false;
  13. /**
  14. * Attribute
  15. */
  16. this.attribute["overflow"] = strOverflow;
  17. this.attribute["popup"] = String(bPopup);
  18. this.attribute["scroll"] = strScroll;
  19. this.attribute["showeffect"] = strShowEffect;
  20. this.m_nSelectedRow = -1;
  21. this.m_nSelectedCol = -1;
  22. this.m_bScoll = false;
  23. // SmartPhone
  24. if (is_smartphone)
  25. {
  26. this.bIsExpansion = false;
  27. }
  28. };
  29. XFormsGroup.prototype.init = function ()
  30. {
  31. XFormsBindableControl.prototype.init.call(this);
  32. this.vscroll = new XFormsScrollBar(this.id, this.id + "_vscroll", "xforms:scrollbar", "vscroll", -1 != this.attribute["tag"].indexOf("datagrid"));
  33. this.hscroll = new XFormsScrollBar(this.id, this.id + "_hscroll", "xforms:scrollbar", "hscroll", -1 != this.attribute["tag"].indexOf("datagrid"));
  34. if (null != this.m_heControl)
  35. {
  36. this.setAttribute("overflow", this.attribute["overflow"]);
  37. if("scroll" == this.attribute["overflow"])
  38. {
  39. this.setScroll(this.attribute["scroll"]);
  40. }
  41. // DataGrid의 자식이냐?
  42. var bIsDataGrid = false;
  43. var objParent = this;
  44. while ("xhtml:body" != objParent.elementName)
  45. {
  46. if ("xforms:datagrid" == objParent.elementName)
  47. {
  48. bIsDataGrid = true;
  49. break;
  50. }
  51. objParent = objParent.parent;
  52. }
  53. // if (!bIsDataGrid)
  54. // {
  55. // this.overflow();
  56. // }
  57. }
  58. // 스마트폰 확장 버튼
  59. if (is_smartphone)
  60. {
  61. // Treeview 원래 크기 저장해두기.
  62. if (null != this.m_heControl)
  63. {
  64. this.m_nOriginWidth = this.m_heControl.offsetWidth;
  65. this.m_nOriginHeight = this.m_heControl.offsetHeight;
  66. var strElementName = this.elementName;
  67. if ("xforms:group" == strElementName)
  68. {
  69. this.makeGroupExpansion();
  70. }
  71. }
  72. }
  73. this.resizeControl();
  74. };
  75. XFormsGroup.prototype.applyDefaultStyle = function()
  76. {
  77. XFormsBindableControl.prototype.applyDefaultStyle.call(this);
  78. if (!this.attribute["background-color"])
  79. {
  80. this.m_heControl.style.backgroundColor = "#FFFFFF";
  81. }
  82. };
  83. XFormsGroup.prototype.getAbility = function ()
  84. {
  85. return EA_GROUP;
  86. };
  87. XFormsGroup.prototype.getPopup = function ()
  88. {
  89. return this.m_winPopup;
  90. };
  91. XFormsGroup.prototype.isApplyPadding = function ()
  92. {
  93. return this.m_bApplyPadding;
  94. };
  95. XFormsGroup.prototype.setApplyPadding = function (bApplyPadding)
  96. {
  97. this.m_bApplyPadding = bApplyPadding;
  98. };
  99. /**
  100. * ************ Method ************
  101. */
  102. XFormsGroup.prototype.refresh = function ()
  103. {
  104. XFormsBindableControl.prototype.refresh.call(this);
  105. var arKeyset = this.children.keys();
  106. for (var i=0; i<arKeyset.length; i++)
  107. {
  108. var strId = arKeyset[i];
  109. var objChild = this.children.item(strId);
  110. if (null != objChild && objChild instanceof XFormsElement && objChild.refresh)
  111. {
  112. objChild.refresh();
  113. }
  114. }
  115. };
  116. /**
  117. * *********** property ***********
  118. */
  119. /**
  120. * Attribute 값을 변경시키고 Attribute 값 변화에 맞는 동작을 수행한다.
  121. * @param strAttribute
  122. * @param strValue
  123. * @return
  124. */
  125. XFormsGroup.prototype.setAttribute = function (strAttribute, strValue)
  126. {
  127. XFormsBindableControl.prototype.setAttribute.call(this, strAttribute, strValue);
  128. switch (strAttribute)
  129. {
  130. case "overflow" :
  131. {
  132. this.attribute["overflow"] = strValue;
  133. this.setOverflow(strValue);
  134. break;
  135. }
  136. case "scroll" :
  137. {
  138. this.attribute["scroll"] = strValue;
  139. this.setScroll(strValue);
  140. break;
  141. }
  142. }
  143. };
  144. XFormsGroup.prototype.setScroll = function(strScroll)
  145. {
  146. switch (strScroll)
  147. {
  148. case "vertical" :
  149. {
  150. this.m_heControl.style.overflowX = "hidden";
  151. this.m_heControl.style.overflowY = "scroll";
  152. break;
  153. }
  154. case "horizontal" :
  155. {
  156. this.m_heControl.style.overflowX = "scroll";
  157. this.m_heControl.style.overflowY = "hidden";
  158. break;
  159. }
  160. case "both" :
  161. {
  162. this.m_heControl.style.overflowX = "scroll";
  163. this.m_heControl.style.overflowY = "scroll";
  164. break;
  165. }
  166. case "autovscroll" :
  167. {
  168. this.m_heControl.style.overflowX = "hidden";
  169. this.m_heControl.style.overflowY = "auto";
  170. break;
  171. }
  172. case "autohscroll" :
  173. {
  174. this.m_heControl.style.overflowX = "auto";
  175. this.m_heControl.style.overflowY = "hidden";
  176. break;
  177. }
  178. case "none" :
  179. {
  180. this.m_heControl.style.overflowX = "visible";
  181. this.m_heControl.style.overflowY = "visible";
  182. break;
  183. }
  184. default :
  185. {
  186. this.m_heControl.style.overflowX = "auto";
  187. this.m_heControl.style.overflowY = "auto";
  188. break;
  189. }
  190. }
  191. };
  192. XFormsGroup.prototype.setOverflow = function(strOverflow)
  193. {
  194. switch (strOverflow)
  195. {
  196. case "visible" :
  197. {
  198. this.m_heControl.style.overflowX = "visible";
  199. this.m_heControl.style.overflowY = "visible";
  200. break;
  201. }
  202. case "hidden" :
  203. {
  204. this.m_heControl.style.overflowX = "hidden";
  205. this.m_heControl.style.overflowY = "hidden";
  206. break;
  207. }
  208. case "scroll" :
  209. {
  210. this.m_heControl.style.overflowX = "auto";
  211. this.m_heControl.style.overflowY = "auto";
  212. break;
  213. }
  214. default :
  215. {
  216. break;
  217. }
  218. }
  219. };
  220. XFormsGroup.prototype.overflow = function ()
  221. {
  222. // 자신의 위치와 크기
  223. var nOffsetRight = 0;
  224. var nOffsetBottom = 0;
  225. var objParent = this;
  226. var bIsDatagrid = false;
  227. while("xhtml:body" != objParent.elementName)
  228. {
  229. if (null != objParent.m_heControl)
  230. {
  231. nOffsetRight += objParent.m_heControl.offsetLeft;
  232. nOffsetBottom += objParent.m_heControl.offsetTop;
  233. }
  234. objParent = objParent.parent;
  235. }
  236. nOffsetRight += this.m_heControl.offsetWidth;
  237. nOffsetBottom += this.m_heControl.offsetHeight;
  238. objParent = this.parent;
  239. // objParent가 xhtml:body일때 return
  240. if ("xhtml:html" == objParent.elementName)
  241. {
  242. return;
  243. }
  244. var nParentOffsetRight = 0;
  245. var nParentOffsetBottom = 0;
  246. while ("xhtml:body" != objParent.elementName)
  247. {
  248. if ("xforms:group" == objParent.elementName && ("visible" == objParent.getAttribute("overflow")))
  249. {
  250. if (null != objParent.m_heControl)
  251. {
  252. // 부모의 offset 크기
  253. nParentOffsetRight = objParent.m_heControl.offsetLeft + objParent.m_heControl.offsetWidth;
  254. nParentOffsetRight = objParent.m_heControl.offsetTop + objParent.m_heControl.offsetHeight;
  255. var nFinalOffsetRight = (nOffsetRight > nParentOffsetRight) ? nOffsetRight : nParentOffsetRight ;
  256. var nFinalOffsetBottom = (nOffsetBottom > nParentOffsetBottom) ? nOffsetBottom : nParentOffsetBottom;
  257. objParent.setAttribute("width", nFinalOffsetRight - objParent.m_heControl.offsetLeft);
  258. objParent.setAttribute("height", nFinalOffsetBottom - objParent.m_heControl.offsetTop);
  259. }
  260. }
  261. objParent = objParent.parent;
  262. }
  263. };
  264. /**
  265. * ID가 strId인 컨트롤의 obj를 반환한다. 존재하지 않을 경우 null를 반환
  266. * @param strId 컨트롤의 ID
  267. * @return
  268. */
  269. XFormsGroup.prototype.childReturnObj = function (strId)
  270. {
  271. var objChild = this.children.item(strId);
  272. if (null != objChild)
  273. {
  274. return objChild;
  275. }
  276. else
  277. {
  278. return null;
  279. }
  280. };
  281. /**
  282. * ID가 strId인 컨트롤이 Switch의 자식인지 판단한다.
  283. * @param strId 컨트롤의 ID
  284. * @return
  285. */
  286. XFormsGroup.prototype.isChild = function (strId)
  287. {
  288. var objChild = this.children.item(strId);
  289. if (null != objChild)
  290. {
  291. return true;
  292. }
  293. else
  294. {
  295. return false;
  296. }
  297. };
  298. /**
  299. * ID가 strId인 컨트롤이 Switch의 자손인지 판단한다.
  300. * @param strId 컨트롤의 ID
  301. * @param bIncludeThis Switch 자신을 포함할지 여부
  302. * @return
  303. */
  304. XFormsGroup.prototype.isDescendants = function (strId, bIncludeThis)
  305. {
  306. if (null == bIncludeThis)
  307. {
  308. bIncludeThis = false;
  309. }
  310. var objChild = document.allElement.item(strId);
  311. if (null != objChild)
  312. {
  313. if (true == bIncludeThis)
  314. {
  315. if (objChild == this)
  316. {
  317. return true;
  318. }
  319. }
  320. var objParent = objChild.parent;
  321. while (null != objParent)
  322. {
  323. if (objParent == this)
  324. {
  325. return true;
  326. }
  327. objParent = objParent.parent;
  328. }
  329. return false;
  330. }
  331. return false;
  332. };
  333. XFormsGroup.prototype.setSelectedRow = function (nRow)
  334. {
  335. this.m_nSelectedRow = nRow;
  336. this.attribute["row"] = nRow;
  337. };
  338. XFormsGroup.prototype.setSelectedCol = function (nCol)
  339. {
  340. this.m_nSelectedCol = nCol;
  341. this.attribute["col"] = nCol;
  342. };
  343. XFormsGroup.prototype.getCellById = function (strCellId)
  344. {
  345. return document.allElement.item(strCellId);
  346. };
  347. XFormsGroup.prototype.getCell = function (nRow, nCol)
  348. {
  349. var strCellId = this.id + "_" + nRow + "_" + nCol;
  350. return document.allElement.item(strCellId);
  351. };
  352. XFormsGroup.prototype.isCell = function (strId)
  353. {
  354. var objElement = document.allElement.item(strId);
  355. if (null != objElement)
  356. {
  357. return (this == objElement.parent);
  358. }
  359. return false;
  360. };
  361. XFormsGroup.prototype.isScrollBar = function (event)
  362. {
  363. var nXPos = this.getClientLeft() + this.m_heControl.offsetWidth;
  364. var nYPos = this.getClientTop() + this.m_heControl.offsetHeight;
  365. if (this._isVScroll() && nXPos - 15 <= event.clientX && event.clientX <= nXPos)
  366. {
  367. return true;
  368. }
  369. if (this._isHScroll() && nYPos - 15 <= event.clientY && event.clientY <= nYPos)
  370. {
  371. return true;
  372. }
  373. return false;
  374. };
  375. XFormsGroup.prototype.isDragCellSelect = function (nRow, nCol, objCell)
  376. {
  377. if (objCell.getSelect())
  378. {
  379. var rectCell = this.getCellContentRect (nRow, nCol);
  380. if ((rectCell.getBottom() - 6) <= m_event.y)
  381. {
  382. return true;
  383. }
  384. }
  385. return false;
  386. };
  387. /**
  388. * 종스크롤이 생겼는지 판단한다.
  389. * @return
  390. */
  391. XFormsGroup.prototype._isVScroll = function ()
  392. {
  393. return this.m_heControl.clientHeight < this.m_heControl.scrollHeight;
  394. };
  395. /**
  396. * 횡스크롤이 생겼는지 판단한다.
  397. * @return
  398. */
  399. XFormsGroup.prototype._isHScroll = function ()
  400. {
  401. return this.m_heControl.clientWidth < this.m_heControl.scrollWidth;
  402. };
  403. XFormsGroup.prototype.getMouseRow = function ()
  404. {
  405. return this.getAttribute("row");
  406. };
  407. XFormsGroup.prototype.setMouseRow = function (nRow)
  408. {
  409. this.setAttribute("row", nRow);
  410. };
  411. XFormsGroup.prototype.getMouseCol = function ()
  412. {
  413. return this.getAttribute("col");
  414. };
  415. XFormsGroup.prototype.setMouseCol = function (nCol)
  416. {
  417. this.setAttribute("col", nCol);
  418. };
  419. XFormsGroup.create = function (strParentId, clAttribute, strStyle)
  420. {
  421. // 메인노드 생성
  422. var xnGroup = XFormsGroup.createMainNode(clAttribute);
  423. var xnParent = document.getElementById("HE_"+strParentId);
  424. xnParent.appendChild(xnGroup);
  425. // 하위노드 생성
  426. xnGroup = XFormsGroup.createSubNodes(xnGroup, clAttribute);
  427. // object 생성
  428. return XFormsGroup.createObject(strParentId, xnGroup, clAttribute, strStyle);
  429. };
  430. XFormsGroup.createMainNode = function (clAttribute)
  431. {
  432. var xnGroup = document.createElement("div");
  433. xnGroup = XFormsGroup.createAttribute(xnGroup, clAttribute);
  434. return xnGroup;
  435. };
  436. XFormsGroup.createSubNodes = function (xnGroup, clAttribute)
  437. {
  438. return xnGroup;
  439. };
  440. XFormsGroup.createObject = function (strParentId, xnGroup, clAttribute, strStyle)
  441. {
  442. var strAlert = "";
  443. var strHelp = "";
  444. var strHint = "";
  445. var strAccesskey = "";
  446. var strBind = "";
  447. var strClass = "";
  448. var bDisabled = false;
  449. var strId = "";
  450. var nNavindex = 9007199254740992;
  451. var strOverFlow = "scroll";
  452. var bPopup = false;
  453. var strRef = "";
  454. var strScroll = "auto";
  455. var strShowEffect = "blend 300";
  456. var strVisibility = "visible";
  457. var strUserDefineAttrib = "";
  458. for (var i=0; i<clAttribute.count(); i++)
  459. {
  460. var strAttributeName = clAttribute.keys()[i];
  461. switch (strAttributeName)
  462. {
  463. case "alert" :
  464. {
  465. strAlert = clAttribute.item(strAttributeName);
  466. break;
  467. }
  468. case "help" :
  469. {
  470. strHelp = clAttribute.item(strAttributeName);
  471. break;
  472. }
  473. case "hint" :
  474. {
  475. strHint = clAttribute.item(strAttributeName);
  476. break;
  477. }
  478. case "accesskey" :
  479. {
  480. strAccesskey = clAttribute.item(strAttributeName);
  481. break;
  482. }
  483. case "bind" :
  484. {
  485. strBind = clAttribute.item(strAttributeName);
  486. }
  487. case "class" :
  488. {
  489. strClass = clAttribute.item(strAttributeName);
  490. break;
  491. }
  492. case "disabled" :
  493. {
  494. if ("true" == clAttribute.item(strAttributeName))
  495. {
  496. bDisabled = true;
  497. }
  498. break;
  499. }
  500. case "id" :
  501. {
  502. strId = clAttribute.item(strAttributeName);
  503. break;
  504. }
  505. case "navindex" :
  506. {
  507. nNavindex = parseInt(clAttribute.item(strAttributeName));
  508. break;
  509. }
  510. case "overflow" :
  511. {
  512. strOverFlow = clAttribute.item(strAttributeName);
  513. break;
  514. }
  515. case "popup" :
  516. {
  517. if ("true" == clAttribute.item(strAttributeName))
  518. {
  519. bPopup = true;
  520. }
  521. break;
  522. }
  523. case "ref" :
  524. {
  525. strRef = clAttribute.item(strAttributeName);
  526. break;
  527. }
  528. case "scroll" :
  529. {
  530. strScroll = clAttribute.item(strAttributeName);
  531. break;
  532. }
  533. case "showeffect" :
  534. {
  535. strShowEffect = clAttribute.item(strAttributeName);
  536. break;
  537. }
  538. case "visibility" :
  539. {
  540. strVisibility = clAttribute.item(strAttributeName);
  541. break;
  542. }
  543. default :
  544. {
  545. if (!STYLE_LIST[strAttributeName])
  546. {
  547. strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
  548. }
  549. break;
  550. }
  551. }
  552. }
  553. var objGroup = new XFormsGroup (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass, bDisabled, strId, nNavindex, strOverFlow, bPopup, strRef, strScroll, strShowEffect, strStyle, "xforms:group", strVisibility, strUserDefineAttrib);
  554. return objGroup;
  555. };
  556. XFormsGroup.createAttribute = function (xnHtmlNode, clAttribute)
  557. {
  558. xnHtmlNode = XFormsBindableControl.createAttribute(xnHtmlNode, clAttribute);
  559. return xnHtmlNode;
  560. };
  561. // TODO 2010. 11. 29. SmartPhone 작업
  562. //smartphone에서 확장/축소 버튼 그리기
  563. XFormsGroup.prototype.makeGroupExpansion = function ()
  564. {
  565. var heExpansionButton = document.getElementById("__GROUP_EXPANSION_" + this.id);
  566. if (null == heExpansionButton)
  567. {
  568. heExpansionButton = document.createElement("image");
  569. heExpansionButton.setAttribute("onclick", "XFormsGroup.onClickExpansion(event, \""+this.id+"\")");
  570. heExpansionButton.setAttribute("id", "__GROUP_EXPANSION_" + this.id);
  571. heExpansionButton.setAttribute("src", __getAppName() + "/kr/comsquare/image/global/buttonExpansion.png");
  572. heExpansionButton.style.position = "absolute";
  573. heExpansionButton.style.top = (this.m_heControl.offsetTop + this.m_heControl.offsetHeight - 20) + "px";
  574. heExpansionButton.style.left = (this.m_heControl.offsetLeft + this.m_heControl.offsetWidth - 20) + "px";
  575. if ("visible" == this.getAttribute("overflow") || "hidden" == this.getAttribute("overflow"))
  576. {
  577. heExpansionButton.style.display = "none";
  578. }
  579. document.body.appendChild(heExpansionButton);
  580. }
  581. };
  582. XFormsGroup.prototype.getOffsetLeft = function ()
  583. {
  584. var strElementName = this.elementName;
  585. var objParent = this;
  586. var nLeft = 0;
  587. while ("xhtml:body" != strElementName)
  588. {
  589. nLeft += objParent.m_heControl.offsetLeft;
  590. objParent = objParent.parent;
  591. strElementName = objParent.elementName;
  592. }
  593. return nLeft;
  594. };
  595. XFormsGroup.prototype.getOffsetTop = function ()
  596. {
  597. var strElementName = this.elementName;
  598. var objParent = this;
  599. var nTop = 0;
  600. while ("xhtml:body" != strElementName)
  601. {
  602. nTop += objParent.m_heControl.offsetTop;
  603. objParent = objParent.parent;
  604. strElementName = objParent.elementName;
  605. }
  606. return nTop;
  607. };
  608. /**
  609. * 스마트폰 브라우저 상에서 그룹 확장/되돌림 버튼 위치를 조정한다.
  610. *
  611. * @return
  612. */
  613. XFormsGroup.prototype.moveGroupExpansion = function ()
  614. {
  615. if (is_smartphone)
  616. {
  617. if (this.bIsExpansion)
  618. {
  619. var heElementExpansion = document.getElementById("__GROUP_EXPANSION_" + this.id);
  620. if (null != heElementExpansion)
  621. {
  622. var nGroupEndXPosition = this.getOffsetLeft() + this.m_heControl.offsetWidth;
  623. var nGroupEndYPosition = this.getOffsetTop() + this.m_heControl.offsetHeight;
  624. var nScreenEndXPosition = window.scrollX + window.innerWidth;
  625. var nScreenEndYPosition = window.scrollY + window.innerHeight;
  626. var nGroupXPosition = this.m_heControl.offsetLeft;
  627. var nGroupYPosition = this.m_heControl.offsetTop;
  628. var nXPos = (nGroupEndXPosition > nScreenEndXPosition) ? nScreenEndXPosition : nGroupEndXPosition;
  629. var nYPos = (nGroupEndYPosition > nScreenEndYPosition) ? nScreenEndYPosition : nGroupEndYPosition;
  630. nXPos = (nGroupXPosition < nXPos) ? nXPos : nGroupXPosition;
  631. nYPos = (nGroupYPosition < nYPos) ? nYPos : nGroupYPosition;
  632. heElementExpansion.style.top = (nYPos - 20) + "px";
  633. heElementExpansion.style.left = (nXPos - 20) + "px";
  634. }
  635. }
  636. }
  637. };
  638. //
  639. //// Group 전체 크기 다시 그리기(DIV)
  640. //XFormsGroup.prototype.wholeSize = function ()
  641. //{
  642. // if (is_smartphone)
  643. // {
  644. // var objParent = this.parent;
  645. // var strElementName = objParent.elementName;
  646. // while ("xhtml:body" != strElementName)
  647. // {
  648. // if ("xforms:group" == strElementName ||
  649. // "xforms:switch" == strElementName)
  650. // {
  651. // if (objParent.bIsExpansion)
  652. // {
  653. // // 부모의 offset Right, Bottom을 구한다
  654. // var nParentRight = objParent.getOffsetLeft() + objParent.m_heControl.offsetWidth;
  655. // var nParentBottom = objParent.getOffsetTop() + objParent.m_heControl.offsetHeight;
  656. //
  657. // var nFinalRight = 0;
  658. // var nFinalBottom = 0;
  659. //
  660. // var objChildren = objParent.children;
  661. // for (var i=0; i<objChildren.length; i++)
  662. // {
  663. // var objChild = objChildren.item(i);
  664. // var nRight = 0;
  665. // var nBottom = 0;
  666. // if (objChild instanceof XFormsGroup)
  667. // {
  668. // nRight = objChild.getOffsetLeft() + objChild.m_heControl.offsetWidth;
  669. // nBottom = objChild.getOffsetTop() + objChild.m_heControl.offsetHeight;
  670. // }
  671. // else
  672. // {
  673. // nRight = objChild.getClientLeft(false) + objChild.m_heControl.offsetWidth;
  674. // nBottom = objChild.getClientTop(false) + objChild.m_heControl.offsetHeight;
  675. // }
  676. //
  677. // nFinalRight = (nFinalRight > nRight) ? nFinalRight : nRight;
  678. // nFinalBottom = (nFinalBottom > nBottom) ? nFinalBottom : nBottom;
  679. // }
  680. // objParent.m_heControl.style.width = nFinalRight - objParent.getOffsetLeft();
  681. // objParent.m_heControl.style.height = nFinalBottom - objParent.getOffsetTop();
  682. // }
  683. //
  684. // }
  685. // objParent.moveExpansion();
  686. // objParent = objParent.parent;
  687. // strElementName = objParent.elementName;
  688. // }
  689. // this.moveExpansion();
  690. // }
  691. //};
  692. //
  693. /**
  694. * 전역함수
  695. */
  696. XFormsGroup.onClickExpansion = function (event, strId)
  697. {
  698. var objGroup = document.allElement.item(strId);
  699. var heElementGroup = document.getElementById("HE_" + strId);
  700. var heElementExpansion = document.getElementById("__GROUP_EXPANSION_" + strId);
  701. if (null != heElementGroup)
  702. {
  703. if (!objGroup.bIsExpansion)
  704. {
  705. var scrollWidth = (objGroup.m_nOriginWidth > heElementGroup.scrollWidth) ? objGroup.m_nOriginWidth : heElementGroup.scrollWidth;
  706. var scrollHeight = (objGroup.m_nOriginHeight > heElementGroup.scrollHeight) ? objGroup.m_nOriginHeight : heElementGroup.scrollHeight;
  707. heElementGroup.style.width = scrollWidth + "px";
  708. heElementGroup.style.height = scrollHeight + "px";
  709. objGroup.setAttribute("overflow", "visible");
  710. objGroup.bIsExpansion = true;
  711. heElementExpansion.src = __getAppName() + "/kr/comsquare/image/global/buttonReturn.png";
  712. // 브라우저 Screen 마지막 x,y 좌표
  713. var nScreenEndXPosition = window.scrollX + window.innerWidth;
  714. var nScreenEndYPosition = window.scrollY + window.innerHeight;
  715. // Group 마지막 x,y 좌표
  716. var nGroupEndXPosition = objGroup.m_heControl.offsetLeft + heElementGroup.offsetWidth;
  717. var nGroupEndYPosition = objGroup.m_heControl.offsetTop + heElementGroup.offsetHeight;
  718. // 마지막 좌표 구하기
  719. var nXPos = ((nGroupEndXPosition > nScreenEndXPosition) ? nScreenEndXPosition : nGroupEndXPosition);
  720. var nYPos = ((nGroupEndYPosition > nScreenEndYPosition) ? nScreenEndYPosition : nGroupEndYPosition);
  721. heElementExpansion.style.left = ((nXPos - 20) < 0) ? "0px" : (nXPos - 20) + "px";
  722. heElementExpansion.style.top = ((nYPos - 20) < 0) ? "0px" : (nYPos - 20) + "px";
  723. }
  724. else
  725. {
  726. heElementGroup.style.width = objGroup.m_nOriginWidth + "px";
  727. heElementGroup.style.height = objGroup.m_nOriginHeight + "px";
  728. objGroup.setAttribute("overflow", "hidden");
  729. objGroup.bIsExpansion = false;
  730. heElementExpansion.src = __getAppName() + "/kr/comsquare/image/global/buttonExpansion.png";
  731. heElementExpansion.style.left = (objGroup.m_heControl.offsetLeft + heElementGroup.offsetWidth - 20) + "px";
  732. heElementExpansion.style.top = (objGroup.m_heControl.offsetTop + heElementGroup.offsetHeight - 20) + "px";
  733. }
  734. }
  735. };
  736. /**
  737. * 스크롤바의 객체를 만든다
  738. */
  739. XFormsScrollBar.prototype = new XFormsAttribute;
  740. function XFormsScrollBar (strParentId, strId, strTag, strType, bIsGrid)
  741. {
  742. if (!strParentId)
  743. {
  744. return;
  745. }
  746. XFormsAttribute.call(this, strParentId, strId, strTag);
  747. this.attribute["min"] = "0";
  748. this.attribute["max"] = "0";
  749. this.attribute["pos"] = "0";
  750. this.is_bGrid = bIsGrid;
  751. this.m_strType = strType;
  752. this.m_targetControl = null;
  753. };
  754. XFormsScrollBar.prototype.init = function ()
  755. {
  756. if (null != this.parent)
  757. {
  758. if (null != this.parent.m_heControl)
  759. {
  760. if (!this.is_bGrid)
  761. {
  762. this.m_targetControl = this.parent.m_heControl;
  763. }
  764. else
  765. {
  766. this.m_targetControl = document.getElementById("HE__DATAGRID_WHOLE_" + this.parent.id);
  767. }
  768. if (null != this.m_targetControl)
  769. {
  770. if ("vscroll" == this.m_strType)
  771. {
  772. this.attribute["max"] = parseInt(this.m_targetControl.scrollHeight - this.m_targetControl.offsetHeight);
  773. this.attribute["pos"] = parseInt(this.m_targetControl.scrollTop);
  774. }
  775. else
  776. {
  777. this.attribute["max"] = parseInt(this.m_targetControl.scrollWidth - this.m_targetControl.offsetWidth);
  778. this.attribute["pos"] = parseInt(this.m_targetControl.scrollLeft);
  779. }
  780. }
  781. }
  782. }
  783. };
  784. XFormsScrollBar.prototype.setAttribute = function (strAttribute, strValue)
  785. {
  786. switch (strAttribute)
  787. {
  788. case "pos" :
  789. {
  790. this.attribute["pos"] = strValue;
  791. if (null != this.m_targetControl)
  792. {
  793. if ("vscroll" == this.m_strType)
  794. {
  795. this.m_targetControl.scrollTop = parseInt(strValue);
  796. }
  797. else
  798. {
  799. this.m_targetControl.scrollLeft = parseInt(strValue);
  800. }
  801. }
  802. break;
  803. }
  804. }
  805. };
  806. XFormsScrollBar.prototype.refresh = function ()
  807. {
  808. if (null == this.m_targetControl)
  809. {
  810. this.init();
  811. return;
  812. }
  813. if (null != this.m_targetControl)
  814. {
  815. if ("vscroll" == this.m_strType)
  816. {
  817. this.attribute["max"] = parseInt(this.m_targetControl.scrollHeight - this.m_targetControl.offsetHeight);
  818. this.attribute["pos"] = parseInt(this.m_targetControl.scrollTop);
  819. }
  820. else
  821. {
  822. this.attribute["max"] = parseInt(this.m_targetControl.scrollWidth - this.m_targetControl.offsetWidth);
  823. this.attribute["pos"] = parseInt(this.m_targetControl.scrollLeft);
  824. }
  825. }
  826. };