sort.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. var sortIcons = new Array();
  9. sortIcons[0] = topparent.getGlobal("imgPath") + "list_sort_no.gif";
  10. sortIcons[1] = topparent.getGlobal("imgPath") + "list_sort_descending.gif";
  11. sortIcons[2] = topparent.getGlobal("imgPath") + "list_sort_ascending.gif";
  12. function showSortState (obj, rowOrCol)
  13. {
  14. if (!obj || !obj.getAttribute("nodeId"))
  15. return;
  16. if (!obj.sort)
  17. showSortIcon (obj, rowOrCol, obj.getAttribute("nodeId"));
  18. }
  19. function showSortIcon (obj, rowOrCol, nodeId)
  20. {
  21. if (!obj || obj.sort)
  22. return;
  23. if (obj.hasChildNodes())
  24. {
  25. var children = obj.childNodes;
  26. for (var i = 0; i < children.length; i++)
  27. {
  28. if (children[i].tagName == "A" && children[i].hasChildNodes() && children[i].childNodes[0].tagName == "IMG" && children[i].childNodes[0].className.indexOf("hiddenSortIcon") >= 0)
  29. children[i].childNodes[0].className = "sortIcon";
  30. if (children[i].hasChildNodes())
  31. showSortIcon (children[i], rowOrCol, nodeId);
  32. }
  33. }
  34. }
  35. function hideSortIcon(obj)
  36. {
  37. if (!obj || obj.sort)
  38. return;
  39. if (obj.hasChildNodes())
  40. {
  41. var children = obj.childNodes;
  42. for (var i = 0; i < children.length; i++)
  43. {
  44. if (children[i].tagName == "A" && children[i].hasChildNodes() && children[i].childNodes[0].tagName == "IMG" && children[i].childNodes[0].className.indexOf("sortIcon") >= 0)
  45. children[i].childNodes[0].className = "hiddenSortIcon";
  46. if (children[i].hasChildNodes())
  47. hideSortIcon (children[i]);
  48. }
  49. }
  50. }
  51. //have to add parameters for border, etc...
  52. //this function can be used for any rollover functions on images
  53. function changeIcon (obj, src, alt)
  54. {
  55. obj.src = src;
  56. if (alt)
  57. {
  58. obj.alt = alt;
  59. what(alt);
  60. }
  61. }
  62. function showSortMenu(event, rowOrCol, nodeId, id) {
  63. var arrayContextMenu = topparent.getGlobal("main_ContextMenu");
  64. var nodePath = "";
  65. if (rowOrCol == "r")
  66. {
  67. nodePath = topparent.getToolbarFrame().getNestedPath(document.getElementById(id), "row", true);
  68. }
  69. else
  70. {
  71. nodePath = topparent.getToolbarFrame().getNestedPath(document.getElementById(id), "col", true);
  72. }
  73. ContextMenu.display(event, [
  74. new ContextItem('', arrayContextMenu["sort_desc"]._label, function() {doit("S1:" + rowOrCol + nodeId + "p" + nodePath)}),
  75. new ContextItem('', arrayContextMenu["sort_asce"]._label, function() {doit("S2:" + rowOrCol + nodeId + "p" + nodePath)}),
  76. new ContextItem('', arrayContextMenu["sort_none"]._label, function() {doit("S0:" + rowOrCol + nodeId + "p" + nodePath)})
  77. ], true);
  78. }