3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.dd.Registry"></div>/**
16 * @class Ext.dd.Registry
17 * Provides easy access to all drag drop components that are registered on a page. Items can be retrieved either
18 * directly by DOM node id, or by passing in the drag drop event that occurred and looking up the event target.
21 Ext.dd.Registry = function(){
26 var getId = function(el, autogen){
27 if(typeof el == "string"){
31 if(!id && autogen !== false){
32 id = "extdd-" + (++autoIdSeed);
39 <div id="method-Ext.dd.Registry-register"></div>/**
40 * Resgister a drag drop element
41 * @param {String/HTMLElement} element The id or DOM node to register
42 * @param {Object} data (optional) An custom data object that will be passed between the elements that are involved
43 * in drag drop operations. You can populate this object with any arbitrary properties that your own code
44 * knows how to interpret, plus there are some specific properties known to the Registry that should be
45 * populated in the data object (if applicable):
47 Value Description<br />
48 --------- ------------------------------------------<br />
49 handles Array of DOM nodes that trigger dragging<br />
50 for the element being registered<br />
51 isHandle True if the element passed in triggers<br />
52 dragging itself, else false
55 register : function(el, data){
57 if(typeof el == "string"){
58 el = document.getElementById(el);
61 elements[getId(el)] = data;
62 if(data.isHandle !== false){
63 handles[data.ddel.id] = data;
66 var hs = data.handles;
67 for(var i = 0, len = hs.length; i < len; i++){
68 handles[getId(hs[i])] = data;
73 <div id="method-Ext.dd.Registry-unregister"></div>/**
74 * Unregister a drag drop element
75 * @param {String/HTMLElement} element The id or DOM node to unregister
77 unregister : function(el){
78 var id = getId(el, false);
79 var data = elements[id];
83 var hs = data.handles;
84 for(var i = 0, len = hs.length; i < len; i++){
85 delete handles[getId(hs[i], false)];
91 <div id="method-Ext.dd.Registry-getHandle"></div>/**
92 * Returns the handle registered for a DOM Node by id
93 * @param {String/HTMLElement} id The DOM node or id to look up
94 * @return {Object} handle The custom handle data
96 getHandle : function(id){
97 if(typeof id != "string"){ // must be element?
103 <div id="method-Ext.dd.Registry-getHandleFromEvent"></div>/**
104 * Returns the handle that is registered for the DOM node that is the target of the event
105 * @param {Event} e The event
106 * @return {Object} handle The custom handle data
108 getHandleFromEvent : function(e){
109 var t = Ext.lib.Event.getTarget(e);
110 return t ? handles[t.id] : null;
113 <div id="method-Ext.dd.Registry-getTarget"></div>/**
114 * Returns a custom data object that is registered for a DOM node by id
115 * @param {String/HTMLElement} id The DOM node or id to look up
116 * @return {Object} data The custom data
118 getTarget : function(id){
119 if(typeof id != "string"){ // must be element?
125 <div id="method-Ext.dd.Registry-getTargetFromEvent"></div>/**
126 * Returns a custom data object that is registered for the DOM node that is the target of the event
127 * @param {Event} e The event
128 * @return {Object} data The custom data
130 getTargetFromEvent : function(e){
131 var t = Ext.lib.Event.getTarget(e);
132 return t ? elements[t.id] || handles[t.id] : null;