DropIndicator.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. define("dojox/mdnd/DropIndicator", ["dojo/_base/kernel","dojo/_base/declare","dojo/_base/html","./AreaManager"],function(dojo){
  2. var di = dojo.declare(
  3. "dojox.mdnd.DropIndicator",
  4. null,
  5. {
  6. // summary:
  7. // DropIndicator managment for DnD.
  8. // node: DOMNode
  9. // the drop indicator node
  10. node : null,
  11. constructor: function(){
  12. //console.log("dojox.mdnd.DropIndicator ::: constructor");
  13. var dropIndicator = document.createElement("div");
  14. var subDropIndicator = document.createElement("div");
  15. dropIndicator.appendChild(subDropIndicator);
  16. dojo.addClass(dropIndicator, "dropIndicator");
  17. this.node = dropIndicator;
  18. },
  19. place: function(/*Node*/area, /*Node*/nodeRef, /*Object*/size){
  20. // summary:
  21. // Place the DropIndicator in the right place
  22. // area:
  23. // the dnd targer area node
  24. // nodeRef:
  25. // node where the dropIndicator have to be placed into the area
  26. // dragNode:
  27. // the node which is dragged
  28. // returns:
  29. // the node inserted or null if it crashes
  30. //console.log("dojox.mdnd.DropIndicator ::: place");
  31. if(size){
  32. this.node.style.height = size.h + "px";
  33. }
  34. try{
  35. if(nodeRef){
  36. area.insertBefore(this.node, nodeRef);
  37. }
  38. else{
  39. // empty target area or last node => appendChild
  40. area.appendChild(this.node);
  41. }
  42. return this.node; // DOMNode
  43. }catch(e){
  44. return null;
  45. }
  46. },
  47. remove: function(){
  48. // summary:
  49. // remove the DropIndicator (not destroy)
  50. //console.log("dojox.mdnd.DropIndicator ::: remove");
  51. if(this.node){
  52. //FIX : IE6 problem
  53. this.node.style.height = "";
  54. if(this.node.parentNode){
  55. this.node.parentNode.removeChild(this.node);
  56. }
  57. }
  58. },
  59. destroy: function(){
  60. // summary:
  61. // destroy the dropIndicator
  62. //console.log("dojox.mdnd.DropIndicator ::: destroy");
  63. if(this.node){
  64. if(this.node.parentNode){
  65. this.node.parentNode.removeChild(this.node);
  66. }
  67. dojo._destroyElement(this.node);
  68. delete this.node;
  69. }
  70. }
  71. });
  72. dojox.mdnd.areaManager()._dropIndicator = new dojox.mdnd.DropIndicator();
  73. return di;
  74. });