dndManager.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. //The drag and Drop gloabl object that allows for a common Drag and Drop
  9. //Framework between Netscape and IE.
  10. function dragAndDropManager() {
  11. //Memeber variables
  12. this.isDragging = false;
  13. this.isXtabElementDragging = false;
  14. this.isCarrying = false;
  15. this.data = "";
  16. this.clickedItem = null;
  17. this.isMeasure = false;
  18. this.hierRootofDraggedCategory = 0;
  19. this.setDrag = function(text) {
  20. this.isDragging = true;
  21. this.data = text;
  22. }
  23. this.isDraggingAnItem = function() {
  24. return (this.isDragging || this.isXtabElementDragging || this.isCarrying);
  25. }
  26. this.setCarry = function(item) {
  27. this.isCarrying = true;
  28. this.isMeasure = gDimensionInfo[item.getAttribute("dimIdx")].isMeasureDimension;
  29. this.clickedItem = item;
  30. window.TreeToolBar.setAllButtons();
  31. }
  32. this.setHierRootOfDraggedCategory = function(hierRoot) {
  33. this.hierRootofDraggedCategory = hierRoot;
  34. }
  35. this.getHierRootOfDraggedCategory = function() {
  36. return this.hierRootofDraggedCategory;
  37. }
  38. this.setXtabElementDrag = function(obj) {
  39. this.isXtabElementDragging = true;
  40. this.data = obj;
  41. }
  42. this.cancelDrag = function() {
  43. if (this.isCarrying) {
  44. this.clickedItem = null;
  45. this.isCarrying = false;
  46. window.TreeToolBar.setAllButtons();
  47. }
  48. this.isDragging = false;
  49. this.isXtabElementDragging = false;
  50. this.hierRootofDraggedCategory = 0;
  51. window.DimTree.deselectAll();
  52. }
  53. this.getData = function() {
  54. if (this.isDragging || this.isXtabElementDragging)
  55. return this.data;
  56. else
  57. return "";
  58. }
  59. }
  60. function clickProcessDrop(event) {
  61. var dndManager = topparent.getGlobal("dndManager");
  62. if (dndManager.isCarrying) {
  63. processDrop(event);
  64. }
  65. }
  66. function clearDrag(event) {
  67. var dndManager = topparent.getGlobal("dndManager");
  68. if (dndManager.isCarrying) {
  69. dndManager.cancelDrag();
  70. }
  71. }
  72. function dropOrSelect(event) {
  73. if (topparent.getGlobal("dndManager").isCarrying)
  74. processDrop(event);
  75. else
  76. processSelection(event);
  77. }
  78. function dragMouseOver(event) {
  79. if (topparent.getGlobal("dndManager").isCarrying)
  80. processDragEnter(event);
  81. }
  82. function dragMouseOut(event) {
  83. if (topparent.getGlobal("dndManager").isCarrying)
  84. processDragLeave(event);
  85. }
  86. function preventNetscapeDrag(event) {
  87. // Deprecated function: Drag&Drop now enabled on all browsers
  88. // var eventM = new eventManager(event);
  89. // eventM.preventDefault();
  90. }