source: Dev/branches/rest-dojo-ui/client/dojox/mdnd/DropIndicator.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.0 KB
Line 
1define(["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       
9                // node: DOMNode
10                //              the drop indicator node
11                node : null,
12                       
13                constructor: function(){
14                        //console.log("dojox.mdnd.DropIndicator ::: constructor");
15                        var dropIndicator = document.createElement("div");
16                        var subDropIndicator = document.createElement("div");
17                        dropIndicator.appendChild(subDropIndicator);
18                        dojo.addClass(dropIndicator, "dropIndicator");
19                        this.node = dropIndicator;
20                },
21               
22                place: function(/*Node*/area, /*Node*/nodeRef, /*Object*/size){
23                        // summary:
24                        //              Place the DropIndicator in the right place
25                        // area:
26                        //              the dnd targer area node
27                        // nodeRef:
28                        //              node where the dropIndicator have to be placed into the area
29                        // dragNode:
30                        //              the node which is dragged
31                        // returns:
32                        //              the node inserted or null if it crashes
33       
34                        //console.log("dojox.mdnd.DropIndicator ::: place");
35                        if(size){
36                                this.node.style.height = size.h + "px";
37                        }
38                        try{
39                                if(nodeRef){
40                                        area.insertBefore(this.node, nodeRef);
41                                }
42                                else{
43                                        // empty target area or last node => appendChild
44                                        area.appendChild(this.node);
45                                }
46                                return this.node;       // DOMNode
47                        }catch(e){
48                                return null;
49                        }
50                },
51               
52                remove: function(){
53                        // summary:
54                        //              remove the DropIndicator (not destroy)
55       
56                        //console.log("dojox.mdnd.DropIndicator ::: remove");
57                        if(this.node){
58                                //FIX : IE6 problem
59                                this.node.style.height = "";
60                                if(this.node.parentNode){
61                                        this.node.parentNode.removeChild(this.node);
62                                }
63                        }
64                },
65                 
66                destroy: function(){
67                        // summary:
68                        //              destroy the dropIndicator
69       
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
81        dojox.mdnd.areaManager()._dropIndicator = new dojox.mdnd.DropIndicator();
82       
83        return di;
84});
Note: See TracBrowser for help on using the repository browser.