1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-dd.Registry'>/**
2 </span> * @class Ext.dd.Registry
3 * Provides easy access to all drag drop components that are registered on a page. Items can be retrieved either
4 * directly by DOM node id, or by passing in the drag drop event that occurred and looking up the event target.
7 Ext.define('Ext.dd.Registry', {
9 constructor: function() {
15 getId: function(el, autogen){
16 if(typeof el == "string"){
20 if(!id && autogen !== false){
21 id = "extdd-" + (++this.autoIdSeed);
27 <span id='Ext-dd.Registry-method-register'> /**
28 </span> * Resgister a drag drop element
29 * @param {String/HTMLElement} element The id or DOM node to register
30 * @param {Object} data (optional) An custom data object that will be passed between the elements that are involved
31 * in drag drop operations. You can populate this object with any arbitrary properties that your own code
32 * knows how to interpret, plus there are some specific properties known to the Registry that should be
33 * populated in the data object (if applicable):
35 Value Description<br />
36 --------- ------------------------------------------<br />
37 handles Array of DOM nodes that trigger dragging<br />
38 for the element being registered<br />
39 isHandle True if the element passed in triggers<br />
40 dragging itself, else false
43 register : function(el, data){
45 if (typeof el == "string") {
46 el = document.getElementById(el);
49 this.elements[this.getId(el)] = data;
50 if (data.isHandle !== false) {
51 this.handles[data.ddel.id] = data;
54 var hs = data.handles;
55 for (var i = 0, len = hs.length; i < len; i++) {
56 this.handles[this.getId(hs[i])] = data;
61 <span id='Ext-dd.Registry-method-unregister'> /**
62 </span> * Unregister a drag drop element
63 * @param {String/HTMLElement} element The id or DOM node to unregister
65 unregister : function(el){
66 var id = this.getId(el, false);
67 var data = this.elements[id];
69 delete this.elements[id];
71 var hs = data.handles;
72 for (var i = 0, len = hs.length; i < len; i++) {
73 delete this.handles[this.getId(hs[i], false)];
79 <span id='Ext-dd.Registry-method-getHandle'> /**
80 </span> * Returns the handle registered for a DOM Node by id
81 * @param {String/HTMLElement} id The DOM node or id to look up
82 * @return {Object} handle The custom handle data
84 getHandle : function(id){
85 if(typeof id != "string"){ // must be element?
88 return this.handles[id];
91 <span id='Ext-dd.Registry-method-getHandleFromEvent'> /**
92 </span> * Returns the handle that is registered for the DOM node that is the target of the event
93 * @param {Event} e The event
94 * @return {Object} handle The custom handle data
96 getHandleFromEvent : function(e){
97 var t = e.getTarget();
98 return t ? this.handles[t.id] : null;
101 <span id='Ext-dd.Registry-method-getTarget'> /**
102 </span> * Returns a custom data object that is registered for a DOM node by id
103 * @param {String/HTMLElement} id The DOM node or id to look up
104 * @return {Object} data The custom data
106 getTarget : function(id){
107 if(typeof id != "string"){ // must be element?
110 return this.elements[id];
113 <span id='Ext-dd.Registry-method-getTargetFromEvent'> /**
114 </span> * Returns a custom data object that is registered for the DOM node that is the target of the event
115 * @param {Event} e The event
116 * @return {Object} data The custom data
118 getTargetFromEvent : function(e){
119 var t = e.getTarget();
120 return t ? this.elements[t.id] || this.handles[t.id] : null;
122 });</pre></pre></body></html>