dojo/dnd/Manager.js

  • Provides:

    • dojo.dnd.Manager
  • dojo.dnd.Manager

    • type
      Function
    • summary
      the manager of DnD operations (usually a singleton)
    • source: [view]
        this.avatar = null;
        this.source = null;
        this.nodes = [];
        this.copy = true;
        this.target = null;
        this.canDropFlag = false;
        this.events = [];
  • dojo.dnd.Manager.OFFSET_X

    • summary
  • dojo.dnd.Manager.OFFSET_Y

    • summary
  • dojo.dnd.Manager.overSource

    • type
      Function
    • parameters:
      • source: (typeof Object)
        the reporter
    • source: [view]
        if(this.avatar){
         this.target = (source && source.targetState != "Disabled") ? source : null;
         this.canDropFlag = Boolean(this.target);
         this.avatar.update();
        }
        dojo.publish("/dnd/source/over", [source]);
    • summary
      called when a source detected a mouse-over condition
  • dojo.dnd.Manager.outSource

    • type
      Function
    • parameters:
      • source: (typeof Object)
        the reporter
    • source: [view]
        if(this.avatar){
         if(this.target == source){
          this.target = null;
          this.canDropFlag = false;
          this.avatar.update();
          dojo.publish("/dnd/source/over", [null]);
         }
        }else{
         dojo.publish("/dnd/source/over", [null]);
        }
    • summary
      called when a source detected a mouse-out condition
  • dojo.dnd.Manager.startDrag

    • type
      Function
    • parameters:
      • source: (typeof Object)
        the source which provides items
      • nodes: (typeof Array)
        the list of transferred items
      • copy: (typeof Boolean)
        copy items, if true, move items otherwise
    • source: [view]
        this.source = source;
        this.nodes = nodes;
        this.copy = Boolean(copy); // normalizing to true boolean
        this.avatar = this.makeAvatar();
        dojo.body().appendChild(this.avatar.node);
        dojo.publish("/dnd/start", [source, nodes, this.copy]);
        this.events = [
         dojo.connect(dojo.doc, "onmousemove", this, "onMouseMove"),
         dojo.connect(dojo.doc, "onmouseup", this, "onMouseUp"),
         dojo.connect(dojo.doc, "onkeydown", this, "onKeyDown"),
         dojo.connect(dojo.doc, "onkeyup", this, "onKeyUp"),
         // cancel text selection and text dragging
         dojo.connect(dojo.doc, "ondragstart", dojo.stopEvent),
         dojo.connect(dojo.body(), "onselectstart", dojo.stopEvent)
        ];
        var c = "dojoDnd" + (copy ? "Copy" : "Move");
        dojo.addClass(dojo.body(), c);
    • summary
      called to initiate the DnD operation
  • dojo.dnd.Manager.canDrop

    • type
      Function
    • parameters:
      • flag: (typeof )
    • source: [view]
        var canDropFlag = Boolean(this.target && flag);
        if(this.canDropFlag != canDropFlag){
         this.canDropFlag = canDropFlag;
         this.avatar.update();
        }
    • summary
      called to notify if the current target can accept items
  • dojo.dnd.Manager.stopDrag

    • type
      Function
    • source: [view]
        dojo.removeClass(dojo.body(), ["dojoDndCopy", "dojoDndMove"]);
        dojo.forEach(this.events, dojo.disconnect);
        this.events = [];
        this.avatar.destroy();
        this.avatar = null;
        this.source = this.target = null;
        this.nodes = [];
    • summary
      stop the DnD in progress
  • dojo.dnd.Manager.makeAvatar

    • type
      Function
    • source: [view]
        return new dojo.dnd.Avatar(this);
    • summary
      makes the avatar; it is separate to be overwritten dynamically, if needed
  • dojo.dnd.Manager.updateAvatar

    • type
      Function
    • source: [view]
        this.avatar.update();
    • summary
      updates the avatar; it is separate to be overwritten dynamically, if needed
  • dojo.dnd.Manager.onMouseMove

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        var a = this.avatar;
        if(a){
         dojo.dnd.autoScrollNodes(e);
         //dojo.dnd.autoScroll(e);
         var s = a.node.style;
         s.left = (e.pageX + this.OFFSET_X) + "px";
         s.top = (e.pageY + this.OFFSET_Y) + "px";
         var copy = Boolean(this.source.copyState(dojo.isCopyKey(e)));
         if(this.copy != copy){
          this._setCopyStatus(copy);
         }
        }
    • summary
      event processor for onmousemove
  • dojo.dnd.Manager.onMouseUp

    • type
      Function
    • parameters:
      • e: (typeof Event)
        mouse event
    • source: [view]
        if(this.avatar){
         if(this.target && this.canDropFlag){
          var copy = Boolean(this.source.copyState(dojo.isCopyKey(e))),
          params = [this.source, this.nodes, copy, this.target, e];
          dojo.publish("/dnd/drop/before", params);
          dojo.publish("/dnd/drop", params);
         }else{
          dojo.publish("/dnd/cancel");
         }
         this.stopDrag();
        }
    • summary
      event processor for onmouseup
  • dojo.dnd.Manager.onKeyDown

    • type
      Function
    • parameters:
      • e: (typeof Event)
        keyboard event
    • source: [view]
        if(this.avatar){
         switch(e.keyCode){
          case dojo.keys.CTRL:
           var copy = Boolean(this.source.copyState(true));
           if(this.copy != copy){
            this._setCopyStatus(copy);
           }
           break;
          case dojo.keys.ESCAPE:
           dojo.publish("/dnd/cancel");
           this.stopDrag();
           break;
         }
        }
    • summary
      event processor for onkeydown:
      watching for CTRL for copy/move status, watching for ESCAPE to cancel the drag
  • dojo.dnd.Manager.onKeyUp

    • type
      Function
    • parameters:
      • e: (typeof Event)
        keyboard event
    • source: [view]
        if(this.avatar && e.keyCode == dojo.keys.CTRL){
         var copy = Boolean(this.source.copyState(false));
         if(this.copy != copy){
          this._setCopyStatus(copy);
         }
        }
    • summary
      event processor for onkeyup, watching for CTRL for copy/move status
  • dojo.dnd.Manager._setCopyStatus

    • type
      Function
    • parameters:
      • copy: (typeof Boolean)
        the copy status
    • source: [view]
        this.copy = copy;
        this.source._markDndStatus(this.copy);
        this.updateAvatar();
        dojo.replaceClass(dojo.body(),
         "dojoDnd" + (this.copy ? "Copy" : "Move"),
         "dojoDnd" + (this.copy ? "Move" : "Copy"));
    • summary
      changes the copy status
  • dojo.dnd.Manager.target

    • summary
  • dojo.dnd.Manager.canDropFlag

    • summary
  • dojo.dnd.Manager.source

    • summary
  • dojo.dnd.Manager.nodes

    • summary
  • dojo.dnd.Manager.copy

    • summary
  • dojo.dnd.Manager.avatar

    • summary
  • dojo.dnd.Manager.events

    • summary
  • dojo.dnd.Manager.startDrag.source

    • type
      Object
    • summary
      the source which provides items
  • dojo.dnd.Manager.startDrag.nodes

    • type
      Array
    • summary
      the list of transferred items
  • dojo.dnd.Manager.startDrag.copy

    • type
      Boolean
    • summary
      copy items, if true, move items otherwise
  • dojo.dnd.Manager._setCopyStatus.copy

    • type
      Boolean
    • summary
      the copy status
  • dojo.dnd.manager

    • type
      Function
    • source: [view]
       if(!dojo.dnd._manager){
        dojo.dnd._manager = new dojo.dnd.Manager();
       }
       return dojo.dnd._manager; // Object
    • summary
      Returns the current DnD manager.  Creates one if it is not created yet.
    • returns
      Object
  • dojo.dnd._manager

    • summary
  • dojo.dnd

    • type
      Object
    • summary
  • dojo

    • type
      Object
    • summary