home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / ProPlus.WW / ProPsWW.cab / HIERARCHY.JS < prev    next >
Text File  |  2007-02-04  |  6KB  |  176 lines

  1. function collapseExpandRow(i_strTaskID)
  2. {
  3.     var objTask = document.getElementById(i_strTaskID);
  4.     var objImage = document.getElementById(i_strTaskID + "Image");
  5.     var strChildStatus = objTask.getAttribute("childstatus");
  6.     if (strChildStatus != null && strChildStatus == "hidden")
  7.     {
  8.         objTask.setAttribute("childstatus", "visible");
  9.         objImage.src = "minus.gif";
  10.         expandRow(i_strTaskID);
  11.     }
  12.     else
  13.     {
  14.         objTask.setAttribute("childstatus", "hidden");
  15.         objImage.src = "plus.gif";
  16.         collapseRow(i_strTaskID);
  17.     }
  18. }
  19.  
  20. function collapseRow(i_strTaskID)
  21. {
  22.     var objTask = document.getElementById(i_strTaskID);
  23.     var intDepth = getTaskDepth(objTask);
  24.     // Search for children of this row.
  25.     if (intDepth != null)
  26.     {
  27.         objTask = objTask.nextSibling;
  28.         var intSiblingDepth = getTaskDepth(objTask);
  29.         // Find every descendant of the task and hide it.
  30.         while (objTask != null && intSiblingDepth != null && intSiblingDepth > intDepth)
  31.         {
  32.             objTask.style.display = "none";
  33.             objTask = objTask.nextSibling;
  34.             intSiblingDepth = getTaskDepth(objTask);
  35.         }
  36.     }
  37. }
  38.  
  39. function expandRow(i_strTaskID)
  40. {
  41.     var objTask = document.getElementById(i_strTaskID);
  42.     var intDepth = getTaskDepth(objTask);
  43.     // Search for children of this row.
  44.     if (intDepth != null)
  45.     {
  46.         objTask = objTask.nextSibling;
  47.         var intSiblingDepth = getTaskDepth(objTask);
  48.         while (objTask != null && intSiblingDepth != null && intSiblingDepth > intDepth)
  49.         {
  50.             objTask.style.display = "block";
  51.             // Search for children of this row if they are visible.
  52.             var strChildStatus = objTask.getAttribute("childstatus");
  53.             if (strChildStatus == null || (strChildStatus != null && strChildStatus == "hidden"))
  54.                 objTask = skipSibling(objTask, intSiblingDepth, intDepth);
  55.             else
  56.                 objTask = objTask.nextSibling;
  57.             // Get the depth of the current task.
  58.             intSiblingDepth = getTaskDepth(objTask);
  59.         }
  60.     }
  61. }
  62.  
  63. function skipSibling(i_objTask, i_intSiblingDepth, i_intDepth)
  64. {
  65.     i_objTask = i_objTask.nextSibling;
  66.     var intCurrentDepth = getTaskDepth(i_objTask);
  67.     while (i_objTask != null && intCurrentDepth != null && intCurrentDepth > i_intSiblingDepth)
  68.     {
  69.         i_objTask = i_objTask.nextSibling;
  70.         intCurrentDepth = getTaskDepth(i_objTask);
  71.     }
  72.  
  73.     // Return the new task so the search can continue.
  74.     if (i_objTask != null)
  75.         return i_objTask;
  76. }
  77.  
  78. function getTaskDepth(i_objTask)
  79. {
  80.     if (i_objTask != null)
  81.     {
  82.         var intTaskDepth = Number(i_objTask.getAttribute("depth"));
  83.         if (!isNaN(intTaskDepth))
  84.             return intTaskDepth;
  85.     }
  86.     return null;
  87. }
  88.  
  89. function highlightRow(i_objRow)
  90. {
  91.     var arrRows = document.getElementsByTagName("TR");
  92.     for (var i = 0; i < arrRows.length; i++)
  93.     {
  94.         arrRows[i].style.backgroundColor = "";
  95.     }
  96.     i_objRow.style.backgroundColor = "yellow";
  97.  
  98.     // Build the preview table for the selected row.
  99.     var strParentId = i_objRow.getAttribute("parentid");
  100.     var objParentRow = document.getElementById(strParentId + "_Subject");
  101.     if (objParentRow != null)
  102.         document.getElementById("previewParentSubject").innerHTML = objParentRow.innerText;
  103.     else
  104.         document.getElementById("previewParentSubject").innerHTML = " ";
  105.  
  106.     var strRowId = i_objRow.id;
  107.     var arrCells = i_objRow.getElementsByTagName("TD");
  108.     for (var i = 0; i < arrCells.length; i++)
  109.     {
  110.         var strCellId = arrCells[i].id;
  111.         var strCellText = trimEnds(arrCells[i].innerText);
  112.  
  113.         // Replace brackets since it will be interpreted as an HTML tag otherwise.
  114.         strCellText = strCellText.replace(/\&/g, "\&");
  115.         strCellText = strCellText.replace(/</g, "\<");
  116.         strCellText = strCellText.replace(/>/g, "\>");
  117.         if (strCellText == "")
  118.             strCellText = "N/A";
  119.         if (strCellId == strRowId + "_Subject")
  120.             document.getElementById("previewSubject").innerHTML = strCellText;
  121.         else if (strCellId == strRowId + "_AssignedTo")
  122.         {
  123.             // Adjust the Assigned To label for project record.
  124.             var strProjectTaskId = i_objRow.getAttribute("ProjectTaskId");
  125.             if (strProjectTaskId == "")
  126.                 document.getElementById("previewAssignedToLabel").innerText = "Assigned To:";
  127.             else
  128.                 document.getElementById("previewAssignedToLabel").innerText = "Project Leader:";
  129.  
  130.             var strProjectTaskLeader = i_objRow.getAttribute("ProjectTaskLeader");
  131.             if (strProjectTaskLeader == "")
  132.                 document.getElementById("previewAssignedTo").innerHTML = strCellText;
  133.             else
  134.             {
  135.                 strProjectTaskLeader = strProjectTaskLeader.replace(/\&/g, "\&");
  136.                 document.getElementById("previewAssignedTo").innerHTML = strProjectTaskLeader;
  137.             }
  138.         }
  139.         else if (strCellId == strRowId + "_StartDate")
  140.             document.getElementById("previewStartDate").innerHTML = strCellText;
  141.         else if (strCellId == strRowId + "_DueDate")
  142.             document.getElementById("previewDueDate").innerHTML = strCellText;
  143.         else if (strCellId == strRowId + "_Status")
  144.             document.getElementById("previewStatus").innerHTML = strCellText;
  145.         else if (strCellId == strRowId + "_Priority")
  146.             document.getElementById("previewPriority").innerHTML = strCellText;
  147.         else if (strCellId == strRowId + "_Description")
  148.             document.getElementById("previewDescription").innerHTML = strCellText;
  149.     }
  150.     /*
  151.     var strDescription = i_objRow.getAttribute("description");
  152.     if (strDescription != null && strDescription != "")
  153.         document.getElementById("previewDescription").innerHTML = strDescription;
  154.     */
  155. }
  156.  
  157. function highlightProjectTask()
  158. {
  159.     var arrRows = document.getElementsByTagName("TR");
  160.     for (var i = 0; i < arrRows.length; i++)
  161.     {
  162.         var objRow = arrRows[i];
  163.         if (objRow.getAttribute("ProjectTaskID") != null && objRow.getAttribute("ProjectTaskLeader"))
  164.         {
  165.             highlightRow(objRow);
  166.             break;
  167.         }
  168.     }
  169. }
  170.  
  171. function trimEnds(i_String)
  172. {
  173.     i_String = i_String.replace(/^(\s)*/, "");
  174.     i_String = i_String.replace(/(\s)*$/, "");
  175.     return i_String;
  176. }