4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-dd-Registry'>/**
19 </span> * @class Ext.dd.Registry
20 * Provides easy access to all drag drop components that are registered on a page. Items can be retrieved either
21 * directly by DOM node id, or by passing in the drag drop event that occurred and looking up the event target.
24 Ext.define('Ext.dd.Registry', {
26 constructor: function() {
32 getId: function(el, autogen){
33 if(typeof el == "string"){
37 if(!id && autogen !== false){
38 id = "extdd-" + (++this.autoIdSeed);
44 <span id='Ext-dd-Registry-method-register'> /**
45 </span> * Resgister a drag drop element
46 * @param {String/HTMLElement} element The id or DOM node to register
47 * @param {Object} data (optional) An custom data object that will be passed between the elements that are involved
48 * in drag drop operations. You can populate this object with any arbitrary properties that your own code
49 * knows how to interpret, plus there are some specific properties known to the Registry that should be
50 * populated in the data object (if applicable):
52 Value Description<br />
53 --------- ------------------------------------------<br />
54 handles Array of DOM nodes that trigger dragging<br />
55 for the element being registered<br />
56 isHandle True if the element passed in triggers<br />
57 dragging itself, else false
60 register : function(el, data){
62 if (typeof el == "string") {
63 el = document.getElementById(el);
66 this.elements[this.getId(el)] = data;
67 if (data.isHandle !== false) {
68 this.handles[data.ddel.id] = data;
71 var hs = data.handles;
72 for (var i = 0, len = hs.length; i < len; i++) {
73 this.handles[this.getId(hs[i])] = data;
78 <span id='Ext-dd-Registry-method-unregister'> /**
79 </span> * Unregister a drag drop element
80 * @param {String/HTMLElement} element The id or DOM node to unregister
82 unregister : function(el){
83 var id = this.getId(el, false);
84 var data = this.elements[id];
86 delete this.elements[id];
88 var hs = data.handles;
89 for (var i = 0, len = hs.length; i < len; i++) {
90 delete this.handles[this.getId(hs[i], false)];
96 <span id='Ext-dd-Registry-method-getHandle'> /**
97 </span> * Returns the handle registered for a DOM Node by id
98 * @param {String/HTMLElement} id The DOM node or id to look up
99 * @return {Object} handle The custom handle data
101 getHandle : function(id){
102 if(typeof id != "string"){ // must be element?
105 return this.handles[id];
108 <span id='Ext-dd-Registry-method-getHandleFromEvent'> /**
109 </span> * Returns the handle that is registered for the DOM node that is the target of the event
110 * @param {Event} e The event
111 * @return {Object} handle The custom handle data
113 getHandleFromEvent : function(e){
114 var t = e.getTarget();
115 return t ? this.handles[t.id] : null;
118 <span id='Ext-dd-Registry-method-getTarget'> /**
119 </span> * Returns a custom data object that is registered for a DOM node by id
120 * @param {String/HTMLElement} id The DOM node or id to look up
121 * @return {Object} data The custom data
123 getTarget : function(id){
124 if(typeof id != "string"){ // must be element?
127 return this.elements[id];
130 <span id='Ext-dd-Registry-method-getTargetFromEvent'> /**
131 </span> * Returns a custom data object that is registered for the DOM node that is the target of the event
132 * @param {Event} e The event
133 * @return {Object} data The custom data
135 getTargetFromEvent : function(e){
136 var t = e.getTarget();
137 return t ? this.elements[t.id] || this.handles[t.id] : null;