source: Dev/trunk/src/client/dojox/mdnd/LazyManager.js @ 529

Last change on this file since 529 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.1 KB
Line 
1define([
2        "dojo/_base/kernel",   
3        "dojo/_base/declare",
4        "dojo/_base/lang",      // dojo.hitch
5        "dojo/dom-class",
6        "dojo/dom-construct",
7        "dojo/dom-attr",
8        "dojo/dnd/common",
9        "dojo/dnd/Manager",
10        "./PureSource",
11        "dojo/_base/unload"  // dojo.addOnUnload
12],function(dojo, declare, lang, domClass, domConstruct, domAttr, dnd, Manager, PureSource){
13        return declare(
14                "dojox.mdnd.LazyManager",
15                null,
16        {
17                // summary:
18                //              This class allows to launch a drag and drop dojo on the fly.
19               
20                constructor: function(){
21                        //console.log("dojox.mdnd.LazyManager ::: constructor");
22                        this._registry = {};
23                        // initialization of the _fakeSource to enabled DragAndDrop :
24                        this._fakeSource = new PureSource(domConstruct.create("div"), {
25                                'copyOnly': false
26                        });
27                        this._fakeSource.startup();
28                        dojo.addOnUnload(lang.hitch(this, "destroy"));
29                        this.manager = Manager.manager();
30                },
31               
32                getItem: function(/*DOMNode*/draggedNode){
33                        //console.log("dojox.mdnd.LazyManager ::: getItem");
34                        var type = draggedNode.getAttribute("dndType");
35                        return {
36                                'data' : draggedNode.getAttribute("dndData") || draggedNode.innerHTML,
37                                'type' : type ? type.split(/\s*,\s*/) : ["text"]
38                        }
39                },
40               
41                startDrag: function(/*Event*/e, /*DOMNode?*/draggedNode){
42                        // summary:
43                        //              launch a dojo drag and drop on the fly.
44       
45                        //console.log("dojox.mdnd.LazyManager ::: startDrag");
46                        draggedNode = draggedNode || e.target;
47                        if(draggedNode){
48                                var m = this.manager,
49                                        object = this.getItem(draggedNode);
50                                if(draggedNode.id == ""){
51                                  domAttr.set(draggedNode, "id", dnd.getUniqueId());
52                                }
53                                domClass.add(draggedNode, "dojoDndItem");
54                                this._fakeSource.setItem(draggedNode.id, object);
55                                m.startDrag(this._fakeSource, [draggedNode], false);
56                                m.onMouseMove(e);
57                        }
58                },
59               
60                cancelDrag: function(){
61                        // summary:
62                        //              cancel a drag and drop dojo on the fly.
63       
64                        //console.log("dojox.mdnd.LazyManager ::: cancelDrag");
65                        var m = this.manager;
66                        m.target = null;
67                        m.onMouseUp();
68                },
69               
70               
71                destroy: function(){
72                        //console.log("dojox.mdnd.LazyManager ::: destroy");
73                        this._fakeSource.destroy();
74                }
75        });
76});
Note: See TracBrowser for help on using the repository browser.