source: Dev/trunk/src/client/dojox/mdnd/AreaManager.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: 21.7 KB
Line 
1define(["dojo/_base/kernel",
2        "dojo/_base/declare",
3        "dojo/_base/connect",
4        "dojo/_base/window",
5        "dojo/_base/array",
6        "dojo/_base/sniff",
7        "dojo/_base/lang",
8        "dojo/query",
9        "dojo/topic", // topic.publish()
10        "dojo/dom-class",
11        "dojo/dom-geometry",
12        "dojo/dom-construct",
13        "dijit/registry",
14        "dijit/_Widget",
15        "./Moveable"
16],function(dojo, declare, connect, win, array, sniff, lang, query, topic, domClass, geom, domConstruct, registry, _Widget, Moveable){
17        var am = declare(
18                "dojox.mdnd.AreaManager",
19                null,
20        {
21                // summary:
22                //              Drag And Drop manager
23       
24                // autoRefresh: Boolean
25                //              Enable the refresh of registered areas on drag start.
26                autoRefresh: true,
27       
28       
29                // areaClass: String
30                //              CSS class enabled an area if areaClass is defined
31                areaClass: "dojoxDndArea",
32       
33                // dragHandleClass: String
34                //              CSS class enabled a drag handle.
35                dragHandleClass: "dojoxDragHandle",
36       
37                constructor: function(){
38                        // summary:
39                        //              Constructor of AreaManager class.
40                        //              Initialize arrays, connects and subscribes.
41       
42                        //console.log("dojox.mdnd.AreaManager ::: constructor");
43                        this._areaList = [];
44                        this.resizeHandler = connect.connect(dojo.global,"onresize", this, function(){
45                                this._dropMode.updateAreas(this._areaList);
46                        });
47                       
48                        this._oldIndexArea = this._currentIndexArea = this._oldDropIndex = this._currentDropIndex = this._sourceIndexArea = this._sourceDropIndex = -1;
49                },
50       
51                init: function(){
52                        // summary:
53                        //              Initialize the manager by calling the registerByClass method
54       
55                        //console.log("dojox.mdnd.AreaManager ::: init");
56                        this.registerByClass();
57                },
58       
59                registerByNode: function(/*DOMNode*/area, /*Boolean*/notInitAreas){
60                        // summary:
61                        //              To register Dnd Area : insert the DndArea using the specific sort of dropMode.
62                        // area:
63                        //              a DOM node corresponding to the Dnd Area
64                        // notInitAreas:
65                        //              if false or undefined, init the areas.
66       
67                        //console.log("dojox.mdnd.AreaManager ::: registerByNode", area);
68                        var index = this._getIndexArea(area);
69                        if(area && index == -1){
70                                var acceptType = area.getAttribute("accept");
71                                var accept = (acceptType) ? acceptType.split(/\s*,\s*/) : ["text"];
72                                var obj = {
73                                        'node': area,
74                                        'items': [],
75                                        'coords': {},
76                                        'margin': null,
77                                        'accept': accept,
78                                        'initItems': false
79                                };
80                                array.forEach(this._getChildren(area), function(item){
81                                        this._setMarginArea(obj, item);
82                                        obj.items.push(this._addMoveableItem(item));
83                                }, this);
84                                this._areaList = this._dropMode.addArea(this._areaList, obj);
85                                if(!notInitAreas){
86                                        this._dropMode.updateAreas(this._areaList);
87                                }
88                                connect.publish("/dojox/mdnd/manager/register",[area]);
89                        }
90                },
91       
92                registerByClass: function(){
93                        // summary:
94                        //              Register all Dnd Areas identified by the attribute areaClass :
95                        //              insert Dnd Areas using the specific sort of dropMode.
96       
97                        //console.log("dojox.mdnd.AreaManager ::: registerByClass");
98                        query('.'+this.areaClass).forEach(function(area){
99                                this.registerByNode(area, true);
100                        }, this);
101                        this._dropMode.updateAreas(this._areaList);
102                },
103       
104                unregister: function(/*DOMNode*/area){
105                        // summary:
106                        //              Unregister a D&D Area and its children into the AreaManager.
107                        // area:
108                        //              A node corresponding to the D&D Area.
109                        // returns:
110                        //              True if the area is found and unregistered.
111       
112                        //console.log("dojox.mdnd.AreaManager ::: unregister");
113                        var index = this._getIndexArea(area);
114                        if(index != -1){
115                                array.forEach(this._areaList[index].items, function(item){
116                                        this._deleteMoveableItem(item);
117                                }, this);
118                                this._areaList.splice(index,1);
119                                // refresh target area
120                                this._dropMode.updateAreas(this._areaList);
121                                return true; // Boolean
122                        }
123                        return false; // Boolean
124                },
125       
126                _addMoveableItem: function(/*DOMNode*/node){
127                        // summary:
128                        //              Create a draggable item with a DOM node.
129                        // node:
130                        //              A child of the D&D Area.
131                        // returns:
132                        //              The draggable item.
133                        // tags:
134                        //              protected
135       
136                        //console.log("dojox.mdnd.AreaManager ::: _addMoveableItem");
137                        node.setAttribute("tabIndex", "0");
138                        var handle = this._searchDragHandle(node);
139                        var moveable = new Moveable({ 'handle': handle, 'skip': true }, node);
140                        // add a css style :
141                        domClass.add(handle || node, "dragHandle");
142                        var type = node.getAttribute("dndType");
143                        var item = {
144                                'item': moveable,
145                                'type': type ? type.split(/\s*,\s*/) : ["text"],
146                                'handlers': [connect.connect(moveable, "onDragStart", this, "onDragStart")]
147                        }
148                        // connect to the uninitialize method of dijit._Widget to delete a moveable before a destruct
149                        if(registry && registry.byNode){
150                                var widget = registry.byNode(node);
151                                if(widget){
152                                        item.type = widget.dndType ? widget.dndType.split(/\s*,\s*/) : ["text"];
153                                        item.handlers.push(
154                                                connect.connect(widget, "uninitialize", this, function(){
155                                                        this.removeDragItem(node.parentNode, moveable.node);
156                                                })
157                                        );
158                                }
159                        }
160                        return item; // Object
161                },
162       
163                _deleteMoveableItem: function(/*Object*/ objItem){
164                        // summary:
165                        //              Delete the Moveable object associated with a node.
166                        // item:
167                        //              A moveable Object.
168                        // tags:
169                        //              protected
170       
171                        //console.log("dojox.mdnd.AreaManager ::: _deleteMoveableItem", objItem);
172                        // disconnect the handle
173                        array.forEach(objItem.handlers, function(handler){
174                                connect.disconnect(handler);
175                        });
176                        // delete css style :
177                        var node = objItem.item.node,
178                                handle = this._searchDragHandle(node);
179                        domClass.remove(handle || node, "dragHandle");
180                        // call destroy of Moveable class
181                        objItem.item.destroy();
182                },
183       
184                _getIndexArea: function(/*DOMNode*/area){
185                        // summary:
186                        //              Get the index of an area.
187                        // area:
188                        //              A moveable Object.
189                        // returns:
190                        //              area index or -1
191                        // tags:
192                        //              protected
193       
194                        //console.log("dojox.mdnd.AreaManager ::: _getIndexArea");
195                        if(area){
196                                for(var i = 0; i < this._areaList.length; i++){
197                                        if(this._areaList[i].node === area){
198                                                return i;       // Integer
199                                        }
200                                }
201                        }
202                        return -1;      // Integer
203                },
204       
205                _searchDragHandle: function(/*DOMNode*/node){
206                        // summary:
207                        //              Return the node which contains the first specific CSS class handle.
208                        // node:
209                        //              A child of the D&D Area.
210                        // returns:
211                        //              The drag handle node.
212                        // tags:
213                        //              protected
214       
215                        //console.log("dojox.mdnd.AreaManager ::: _searchDragHandle");
216                        if(node){
217                                var cssArray = this.dragHandleClass.split(' '),
218                                        length = cssArray.length,
219                                        queryCss = "";
220                                array.forEach(cssArray, function(css, i){
221                                        queryCss += "." + css;
222                                        if(i != length - 1){
223                                                queryCss += ", ";
224                                        }
225                                });
226                                return query(queryCss, node)[0]; // DomNode
227                        }
228                },
229       
230                addDragItem: function(/*DOMNode*/area, /*DOMNode*/node, /*Integer*/index, /*Boolean*/notCheckParent){
231                        // summary:
232                        //              To add an item programmatically.
233                        // area:
234                        //              a node corresponding to the D&D Area
235                        // node:
236                        //              the node which has to be treated.
237                        // index:
238                        //              the place in the area
239                        // noCheckParent:
240                        //              if true, doesn't check if node has a parent.
241                        // returns:
242                        //              True if the node has been inserted else false.
243       
244                        //console.log("dojox.mdnd.AreaManager ::: addDragItem");
245                        var add = true;
246                        if(!notCheckParent){
247                                add = area && node && (node.parentNode === null || (node.parentNode && node.parentNode.nodeType !== 1));
248                        }
249                        if(add){
250                                var indexArea = this._getIndexArea(area);
251                                if(indexArea !== -1){
252                                        var item = this._addMoveableItem(node),
253                                                items = this._areaList[indexArea].items;
254                                        if(0 <= index && index < items.length){
255                                                var firstListChild = items.slice(0, index),
256                                                        lastListChild = items.slice(index, items.length);
257                                                firstListChild[firstListChild.length] = item;
258                                                this._areaList[indexArea].items = firstListChild.concat(lastListChild);
259                                                area.insertBefore(node, items[index].item.node);
260                                        }
261                                        else{
262                                                this._areaList[indexArea].items.push(item);
263                                                area.appendChild(node);
264                                        }
265                                        this._setMarginArea(this._areaList[indexArea], node);
266                                        this._areaList[indexArea].initItems = false;
267                                        return true;    // Boolean
268                                }
269                        }
270                        return false;   // Boolean
271                },
272       
273                removeDragItem: function(/*DOMNode*/area, /*DOMNode*/node){
274                        // summary:
275                        //              Delete a moveable item programmatically. The node is removed from the area.
276                        // area:
277                        //              A node corresponding to the DndArea.
278                        // node:
279                        //              The node which has to be treated.
280                        // returns:
281                        //              the removed node
282       
283                        //console.log("dojox.mdnd.AreaManager ::: removeDragItem");
284                        var index = this._getIndexArea(area);
285                        if(area && index !== -1){
286                                var items = this._areaList[index].items;
287                                for(var j = 0; j < items.length; j++){
288                                        if(items[j].item.node === node){
289                                                this._deleteMoveableItem(items[j]);
290                                                // delete item of the array
291                                                items.splice(j, 1);
292                                                return area.removeChild(node); // Object
293                                        }
294                                }
295                        }
296                        return null;
297                },
298       
299                _getChildren: function(/*DOMNode*/area){
300                        // summary:
301                        //              Get the children of a D&D area.
302                        // area:
303                        //              A DnD area.
304                        // returns:
305                        //              The children of a DnD area
306                        // tags:
307                        //              protected
308       
309                        //console.log("dojox.mdnd.AreaManager ::: _getChildren");
310                        var children = [];
311                        array.forEach(area.childNodes, function(child){
312                                // delete \n
313                                if(child.nodeType == 1){
314                                        if(registry && registry.byNode){
315                                                var widget = registry.byNode(child);
316                                                if(widget){
317                                                        if(!widget.dragRestriction){
318                                                                children.push(child);
319                                                        }
320                                                }
321                                                else{
322                                                        children.push(child);
323                                                }
324                                        }
325                                        else{
326                                                children.push(child);
327                                        }
328                                }
329                        });
330                        return children;        //Array
331                },
332       
333                _setMarginArea: function(/*Object*/area,/*DOMNode*/node){
334                        // summary:
335                        //              Set the value of margin in the data type of areaManager
336                        //              only when the margin has never been computed.
337                        // area:
338                        //              The object of a D&D Area.
339                        // node:
340                        //              The node which contains margins
341                        // tags:
342                        //              protected
343       
344                        //console.log("dojox.mdnd.AreaManager ::: _setMarginArea");
345                        if(area && area.margin === null && node){
346                                area.margin = geom.getMarginExtents(node);
347                        }
348                },
349       
350                findCurrentIndexArea: function(/*Object*/coords, /*Object*/size){
351                        // summary:
352                        //              find the nearest target area according to coordinates.
353                        //              Coordinates are representing by an object : for example, {'x':10,'y':10}
354                        // coords:
355                        //              an object encapsulating X and Y position
356                        // size:
357                        //              an object encapsulating the area size
358                        // returns:
359                        //              an index of area
360       
361                        //console.log("dojox.mdnd.AreaManager ::: findCurrentIndexArea");
362                        this._oldIndexArea = this._currentIndexArea;
363                        this._currentIndexArea = this._dropMode.getTargetArea(this._areaList, coords, this._currentIndexArea);
364                        if(this._currentIndexArea != this._oldIndexArea){
365                                if(this._oldIndexArea != -1){
366                                        this.onDragExit(coords, size);
367                                }
368                                if(this._currentIndexArea != -1){
369                                        this.onDragEnter(coords, size);
370                                }
371                        }
372                        return this._currentIndexArea;  //Integer
373                },
374       
375                _isAccepted: function(/*Array*/ type, /*Array*/ accept){
376                        // summary:
377                        //              True if user can drop widget on this node.
378                        // type:
379                        //              Array containing item type
380                        // accept:
381                        //              Array containing types
382                        this._accept = false;
383                        for(var i = 0; i < accept.length; ++i){
384                                for(var j = 0; j < type.length;++j){
385                                        if(type[j] == accept[i]){
386                                                this._accept = true;
387                                                break;
388                                        }
389                                }
390                        }
391                },
392       
393                onDragStart: function(/*DOMNode*/node, /*Object*/coords, /*Object*/size){
394                        // summary:
395                        //              Initialize the drag (see dojox.mdnd.Moveable.initOffsetDrag())
396                        // node:
397                        //              The node which is about to be dragged
398                        // coords:
399                        //              an object encapsulating X and Y position
400                        // size:
401                        //              an object encapsulating width and height values
402                        // tags:
403                        //              callback
404       
405                        //console.log("dojox.mdnd.AreaManager ::: onDragStart");
406                        if(this.autoRefresh){
407                                this._dropMode.updateAreas(this._areaList);
408                        }
409       
410                        // Create the cover :
411                        var _html = (sniff("webkit")) ? dojo.body() : dojo.body().parentNode;
412                        if(!this._cover){
413                                this._cover = domConstruct.create('div', {
414                                        'class': "dndCover"
415                                });
416                                this._cover2 = lang.clone(this._cover);
417                                domClass.add(this._cover2, "dndCover2");
418                        }
419                        var h = _html.scrollHeight+"px";
420                        this._cover.style.height = this._cover2.style.height = h;
421                        dojo.body().appendChild(this._cover);
422                        dojo.body().appendChild(this._cover2);
423       
424                        this._dragStartHandler = connect.connect(node.ownerDocument, "ondragstart", dojo, "stopEvent");
425                        // to know the source
426                        this._sourceIndexArea = this._lastValidIndexArea = this._currentIndexArea = this._getIndexArea(node.parentNode);
427                        // delete the dragItem into the source area
428                        var sourceArea = this._areaList[this._sourceIndexArea];
429                        var children = sourceArea.items;
430                        for(var i = 0; i < children.length; i++){
431                                if(children[i].item.node == node){
432                                        this._dragItem = children[i];
433                                        this._dragItem.handlers.push(connect.connect(this._dragItem.item, "onDrag", this, "onDrag"));
434                                        this._dragItem.handlers.push(connect.connect(this._dragItem.item, "onDragEnd", this, "onDrop"));
435                                        children.splice(i,1);
436                                        this._currentDropIndex = this._sourceDropIndex = i;
437                                        break;
438                                }
439                        }
440                        var nodeRef = null;
441                        if(this._sourceDropIndex !== sourceArea.items.length){
442                                nodeRef = sourceArea.items[this._sourceDropIndex].item.node;
443                        }
444                        // IE7 OPTIMIZATION
445                        if(sniff("ie")> 7){
446                                // connect these events on the cover
447                                this._eventsIE7 = [
448                                        connect.connect(this._cover, "onmouseover", dojo, "stopEvent"),
449                                        connect.connect(this._cover, "onmouseout", dojo, "stopEvent"),
450                                        connect.connect(this._cover, "onmouseenter", dojo, "stopEvent"),
451                                        connect.connect(this._cover, "onmouseleave", dojo, "stopEvent")
452                                ];
453                        }
454       
455                        var s = node.style;
456                        s.left = coords.x+"px";
457                        s.top = coords.y+"px";
458                        // attach the node to the cover
459                        if(s.position == "relative" || s.position == ""){
460                                s.position = "absolute"; // enforcing the absolute mode
461                        }
462                        this._cover.appendChild(node);
463       
464                        this._dropIndicator.place(sourceArea.node, nodeRef, size);
465                        // add a style to place the _dragNode in foreground
466                        domClass.add(node, "dragNode");
467                        // A dragged node is always draggable in this source area.
468                        this._accept = true;
469                        connect.publish("/dojox/mdnd/drag/start",[node, sourceArea, this._sourceDropIndex]);
470                },
471       
472                onDragEnter: function(/*Object*/coords, /*Object*/size){
473                        // summary:
474                        //              Optionally called by the getTargetArea method of TargetFinder class.
475                        // coords:
476                        //              coordinates of the dragged Node.
477                        // size:
478                        //              size of the dragged Node.
479                        // tags:
480                        //              callback
481       
482                        //console.log("dojox.mdnd.AreaManager ::: onDragEnter", coords, size);
483                        if(this._currentIndexArea === this._sourceIndexArea){
484                                this._accept = true;
485                        }
486                        else{
487                                this._isAccepted(this._dragItem.type, this._areaList[this._currentIndexArea].accept);
488                        }
489                },
490       
491                onDragExit: function(/*Object*/coords, /*Object*/size){
492                        // summary:
493                        //              Optionally called by the getTargetArea method of TargetFinder class.
494                        // coords:
495                        //              coordinates of the dragged Node.
496                        // size:
497                        //              size of the dragged Node.
498                        // tags:
499                        //              callback
500       
501                        //console.log("dojox.mdnd.AreaManager ::: onDragExit");
502                        this._accept = false;
503                },
504       
505                onDrag: function(/*DOMNode*/node, /*Object*/coords, /*Object*/size, /*Object*/mousePosition){
506                        // summary:
507                        //              Occurs when the dojo.dnd.Moveable.onDrag is fired.
508                        //              Search the nearest target area and called the placeDropIndicator
509                        // node:
510                        //              The node which is dragged
511                        // coords:
512                        //              an object encapsulating X and Y position
513                        // size:
514                        //              an object encapsulating width and height values
515                        // mousePosition:
516                        //              coordinates of mouse
517                        // tags:
518                        //              callback
519       
520                        //console.log("dojox.mdnd.AreaManager ::: onDrag", node, ",", coords,size);
521                        var coordinates = this._dropMode.getDragPoint(coords, size, mousePosition);
522                        this.findCurrentIndexArea(coordinates, size);
523                        if(this._currentIndexArea !== -1 && this._accept){
524                                this.placeDropIndicator(coordinates, size);
525                        }
526                },
527       
528                placeDropIndicator: function(/*Object*/coords, /*Object*/size){
529                        // summary:
530                        //              Search the right place to insert the dropIndicator and display the dropIndicator.
531                        // coords:
532                        //              an object encapsulating X and Y position
533                        // size:
534                        //              an object encapsulating width and height values
535                        // returns:
536                        //              the current drop index
537       
538                        //console.log("dojox.mdnd.AreaManager ::: placeDropIndicator");
539                        //keep old drop Index
540                        this._oldDropIndex = this._currentDropIndex;
541                        // calculate all children marker (see VerticalDropMode.initItems())
542                        var area = this._areaList[this._currentIndexArea];
543                        if(!area.initItems){
544                                this._dropMode.initItems(area);
545                        }
546                        //get the index where the drop has to be placed.
547                        this._currentDropIndex = this._dropMode.getDropIndex(area, coords);
548                        if(!(this._currentIndexArea === this._oldIndexArea && this._oldDropIndex === this._currentDropIndex)){
549                                this._placeDropIndicator(size);
550                        }
551                        return this._currentDropIndex;  //Integer
552                },
553       
554                _placeDropIndicator: function(/*Object*/size){
555                        // summary:
556                        //              place the dropIndicator
557                        // size:
558                        //              an object encapsulating width and height values
559                        // tags:
560                        //              protected
561       
562                        var oldArea = this._areaList[this._lastValidIndexArea];
563                        var currentArea = this._areaList[this._currentIndexArea];
564                        //refresh the previous area after moving out the drop indicator
565                        this._dropMode.refreshItems(oldArea, this._oldDropIndex, size, false);
566                        // place dropIndicator
567                        var node = null;
568                        if(this._currentDropIndex != -1){
569                                node = currentArea.items[this._currentDropIndex].item.node;
570                        }
571                        this._dropIndicator.place(currentArea.node, node);
572                        this._lastValidIndexArea = this._currentIndexArea;
573                        //refresh the current area after placing the drop indicator
574                        this._dropMode.refreshItems(currentArea, this._currentDropIndex, size, true);
575                },
576       
577                onDropCancel: function(){
578                        // summary:
579                        //              Cancel the drop.
580                        //              The dragNode returns into the source.
581                        // tags:
582                        //              callback
583       
584                        //console.log("dojox.mdnd.AreaManager ::: onDropCancel");
585                        if(!this._accept){
586                                var index = this._getIndexArea(this._dropIndicator.node.parentNode);
587                                if(index != -1){
588                                        this._currentIndexArea = index;
589                                }
590                                else{
591                                        // case if the dropIndicator is in the area which has been unregistered during the drag.
592                                        // chose by default the first area.
593                                        this._currentIndexArea = 0;
594                                }
595                        }
596                },
597       
598                onDrop: function(/*DOMNode*/node){
599                        // summary:
600                        //              Drop the dragged item where the dropIndicator is displayed.
601                        // node:
602                        //              The node which is about to be dropped
603                        // tags:
604                        //              callback
605       
606                        //console.log("dojox.mdnd.AreaManager ::: onDrop");
607                        //dropCancel
608                        this.onDropCancel();
609                        var targetArea = this._areaList[this._currentIndexArea];
610                        domClass.remove(node, "dragNode");
611                        var style = node.style;
612                        style.position = "relative";
613                        style.left = "0";
614                        style.top = "0";
615                        style.width = "auto";
616                        if(targetArea.node == this._dropIndicator.node.parentNode){
617                                targetArea.node.insertBefore(node, this._dropIndicator.node);
618                        }
619                        else{
620                                // case if the dropIndicator is in the area which has been unregistered during the drag.
621                                targetArea.node.appendChild(node);
622                                this._currentDropIndex = targetArea.items.length;
623                        }
624                        // add child into the new target area.
625                        var indexChild = this._currentDropIndex;
626                        if(indexChild == -1){
627                                indexChild = targetArea.items.length;
628                        }
629                        var children = targetArea.items;
630                        var firstListArea = children.slice(0, indexChild);
631                        var lastListArea = children.slice(indexChild, children.length);
632                        firstListArea[firstListArea.length] = this._dragItem;
633                        targetArea.items = firstListArea.concat(lastListArea);
634       
635                        this._setMarginArea(targetArea, node);
636                        array.forEach(this._areaList, function(obj){
637                                obj.initItems = false;
638                        });
639                        // disconnect onDrop handler
640                        connect.disconnect(this._dragItem.handlers.pop());
641                        connect.disconnect(this._dragItem.handlers.pop());
642                        this._resetAfterDrop();
643                        // remove the cover
644                        if(this._cover){
645                                dojo.body().removeChild(this._cover);
646                                dojo.body().removeChild(this._cover2);
647                        }
648                        connect.publish("/dojox/mdnd/drop",[node, targetArea, indexChild]);
649                },
650       
651                _resetAfterDrop: function(){
652                        // summary:
653                        //              reset manager properties after dropping an item
654                        // tags:
655                        //              protected
656       
657                        this._accept = false;
658                        this._dragItem = null;
659                        this._currentDropIndex = -1;
660                        this._currentIndexArea = -1;
661                        this._oldDropIndex = -1;
662                        this._sourceIndexArea = -1;
663                        this._sourceDropIndex = -1;
664                        this._dropIndicator.remove();
665                        if(this._dragStartHandler){
666                                connect.disconnect(this._dragStartHandler);
667                        }
668                        if(sniff("ie") > 7){
669                                array.forEach(this._eventsIE7, connect.disconnect);
670                        }
671                },
672       
673                destroy: function(){
674                        // summary:
675                        //              Destroy the component.
676       
677                        //console.log("dojox.mdnd.AreaManager ::: destroy");
678                        //see implementation of unregister()
679                        while(this._areaList.length > 0){
680                                if(!this.unregister(this._areaList[0].node)){
681                                        throw new Error("Error while destroying AreaManager");
682                                }
683                        }
684                        connect.disconnect(this.resizeHandler);
685                        this._dropIndicator.destroy();
686                        this._dropMode.destroy();
687                        if(dojox.mdnd.autoScroll){
688                                dojox.mdnd.autoScroll.destroy();
689                        }
690                        if(this.refreshListener){
691                                connect.unsubscribe(this.refreshListener);
692                        }
693                        // destroy the cover
694                        if(this._cover){
695                                domConstruct.destroy(this._cover);
696                                domConstruct.destroy(this._cover2);
697                                delete this._cover;
698                                delete this._cover2;
699                        }
700                }
701        });
702       
703        if(_Widget){
704                //      Add a new property to widget
705                lang.extend(_Widget, {
706                        // dndType: String
707                        //              Defines a type of widget.
708                        dndType : "text"
709                });
710        }
711
712        // TODO for 2.0 (or earlier): these values should be set on "am", the export of this module, not in dojox.mdnd
713        dojox.mdnd._areaManager = null;
714        dojox.mdnd.areaManager = function(){
715                // summary:
716                //              Returns the current areaManager, creates one if it is not created yet.
717                if(!dojox.mdnd._areaManager){
718                        dojox.mdnd._areaManager = new dojox.mdnd.AreaManager();
719                }
720                return dojox.mdnd._areaManager; // Object
721        };
722        return am;
723});
Note: See TracBrowser for help on using the repository browser.