3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.dd.Registry"></div>/**
\r
10 * @class Ext.dd.Registry
\r
11 * Provides easy access to all drag drop components that are registered on a page. Items can be retrieved either
\r
12 * directly by DOM node id, or by passing in the drag drop event that occurred and looking up the event target.
\r
15 Ext.dd.Registry = function(){
\r
20 var getId = function(el, autogen){
\r
21 if(typeof el == "string"){
\r
25 if(!id && autogen !== false){
\r
26 id = "extdd-" + (++autoIdSeed);
\r
33 <div id="method-Ext.dd.Registry-register"></div>/**
\r
34 * Resgister a drag drop element
\r
35 * @param {String/HTMLElement) element The id or DOM node to register
\r
36 * @param {Object} data (optional) An custom data object that will be passed between the elements that are involved
\r
37 * in drag drop operations. You can populate this object with any arbitrary properties that your own code
\r
38 * knows how to interpret, plus there are some specific properties known to the Registry that should be
\r
39 * populated in the data object (if applicable):
\r
41 Value Description<br />
\r
42 --------- ------------------------------------------<br />
\r
43 handles Array of DOM nodes that trigger dragging<br />
\r
44 for the element being registered<br />
\r
45 isHandle True if the element passed in triggers<br />
\r
46 dragging itself, else false
\r
49 register : function(el, data){
\r
51 if(typeof el == "string"){
\r
52 el = document.getElementById(el);
\r
55 elements[getId(el)] = data;
\r
56 if(data.isHandle !== false){
\r
57 handles[data.ddel.id] = data;
\r
60 var hs = data.handles;
\r
61 for(var i = 0, len = hs.length; i < len; i++){
\r
62 handles[getId(hs[i])] = data;
\r
67 <div id="method-Ext.dd.Registry-unregister"></div>/**
\r
68 * Unregister a drag drop element
\r
69 * @param {String/HTMLElement) element The id or DOM node to unregister
\r
71 unregister : function(el){
\r
72 var id = getId(el, false);
\r
73 var data = elements[id];
\r
75 delete elements[id];
\r
77 var hs = data.handles;
\r
78 for(var i = 0, len = hs.length; i < len; i++){
\r
79 delete handles[getId(hs[i], false)];
\r
85 <div id="method-Ext.dd.Registry-getHandle"></div>/**
\r
86 * Returns the handle registered for a DOM Node by id
\r
87 * @param {String/HTMLElement} id The DOM node or id to look up
\r
88 * @return {Object} handle The custom handle data
\r
90 getHandle : function(id){
\r
91 if(typeof id != "string"){ // must be element?
\r
97 <div id="method-Ext.dd.Registry-getHandleFromEvent"></div>/**
\r
98 * Returns the handle that is registered for the DOM node that is the target of the event
\r
99 * @param {Event} e The event
\r
100 * @return {Object} handle The custom handle data
\r
102 getHandleFromEvent : function(e){
\r
103 var t = Ext.lib.Event.getTarget(e);
\r
104 return t ? handles[t.id] : null;
\r
107 <div id="method-Ext.dd.Registry-getTarget"></div>/**
\r
108 * Returns a custom data object that is registered for a DOM node by id
\r
109 * @param {String/HTMLElement} id The DOM node or id to look up
\r
110 * @return {Object} data The custom data
\r
112 getTarget : function(id){
\r
113 if(typeof id != "string"){ // must be element?
\r
116 return elements[id];
\r
119 <div id="method-Ext.dd.Registry-getTargetFromEvent"></div>/**
\r
120 * Returns a custom data object that is registered for the DOM node that is the target of the event
\r
121 * @param {Event} e The event
\r
122 * @return {Object} data The custom data
\r
124 getTargetFromEvent : function(e){
\r
125 var t = Ext.lib.Event.getTarget(e);
\r
126 return t ? elements[t.id] || handles[t.id] : null;
\r