Avatar.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.layout.dnd.Avatar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.layout.dnd.Avatar"] = true;
  8. dojo.provide("dojox.layout.dnd.Avatar");
  9. dojo.require("dojo.dnd.Avatar");
  10. dojo.require("dojo.dnd.common");
  11. dojo.declare("dojox.layout.dnd.Avatar", dojo.dnd.Avatar, {
  12. // summary:
  13. // An Object, which represents the object being moved in a GridContainer
  14. constructor: function(manager, opacity){
  15. this.opacity = opacity || 0.9;
  16. },
  17. construct: function(){
  18. // summary:
  19. // A constructor function. it is separate so it can be (dynamically)
  20. // overwritten in case of need.
  21. var source = this.manager.source,
  22. node = source.creator ?
  23. // create an avatar representation of the node
  24. source._normalizedCreator(source.getItem(this.manager.nodes[0].id).data, "avatar").node :
  25. // or just clone the node and hope it works
  26. this.manager.nodes[0].cloneNode(true)
  27. ;
  28. dojo.addClass(node, "dojoDndAvatar");
  29. node.id = dojo.dnd.getUniqueId();
  30. node.style.position = "absolute";
  31. node.style.zIndex = 1999;
  32. node.style.margin = "0px"
  33. node.style.width = dojo.marginBox(source.node).w + "px"
  34. // add contructor object params to define it
  35. dojo.style(node, "opacity", this.opacity);
  36. this.node = node;
  37. },
  38. update: function(){
  39. // summary: Updates the avatar to reflect the current DnD state.
  40. dojo.toggleClass(this.node, "dojoDndAvatarCanDrop", this.manager.canDropFlag);
  41. },
  42. _generateText: function(){ /* nada. */ }
  43. });
  44. }