DropIndicator.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.mdnd.DropIndicator"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.mdnd.DropIndicator"] = true;
  8. dojo.provide("dojox.mdnd.DropIndicator");
  9. dojo.require("dojox.mdnd.AreaManager");
  10. dojo.declare(
  11. "dojox.mdnd.DropIndicator",
  12. null,
  13. {
  14. // summary:
  15. // DropIndicator managment for DnD.
  16. // node: DOMNode
  17. // the drop indicator node
  18. node : null,
  19. constructor: function(){
  20. //console.log("dojox.mdnd.DropIndicator ::: constructor");
  21. var dropIndicator = document.createElement("div");
  22. var subDropIndicator = document.createElement("div");
  23. dropIndicator.appendChild(subDropIndicator);
  24. dojo.addClass(dropIndicator, "dropIndicator");
  25. this.node = dropIndicator;
  26. },
  27. place: function(/*Node*/area, /*Node*/nodeRef, /*Object*/size){
  28. // summary:
  29. // Place the DropIndicator in the right place
  30. // area:
  31. // the dnd targer area node
  32. // nodeRef:
  33. // node where the dropIndicator have to be placed into the area
  34. // dragNode:
  35. // the node which is dragged
  36. // returns:
  37. // the node inserted or null if it crashes
  38. //console.log("dojox.mdnd.DropIndicator ::: place");
  39. if(size){
  40. this.node.style.height = size.h + "px";
  41. }
  42. try{
  43. if(nodeRef){
  44. area.insertBefore(this.node, nodeRef);
  45. }
  46. else{
  47. // empty target area or last node => appendChild
  48. area.appendChild(this.node);
  49. }
  50. return this.node; // DOMNode
  51. }catch(e){
  52. return null;
  53. }
  54. },
  55. remove: function(){
  56. // summary:
  57. // remove the DropIndicator (not destroy)
  58. //console.log("dojox.mdnd.DropIndicator ::: remove");
  59. if(this.node){
  60. //FIX : IE6 problem
  61. this.node.style.height = "";
  62. if(this.node.parentNode){
  63. this.node.parentNode.removeChild(this.node);
  64. }
  65. }
  66. },
  67. destroy: function(){
  68. // summary:
  69. // destroy the dropIndicator
  70. //console.log("dojox.mdnd.DropIndicator ::: destroy");
  71. if(this.node){
  72. if(this.node.parentNode){
  73. this.node.parentNode.removeChild(this.node);
  74. }
  75. dojo._destroyElement(this.node);
  76. delete this.node;
  77. }
  78. }
  79. });
  80. (function(){
  81. dojox.mdnd.areaManager()._dropIndicator = new dojox.mdnd.DropIndicator();
  82. }());
  83. }